Commit e145fcfa authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] more reiserfs cleanups

	More cleanups (getblk() use, etc.) in reiserfs (again, cleaning
up after merge).
parent 29da67a0
......@@ -2099,7 +2099,7 @@ static void tb_buffer_sanity_check (struct super_block * p_s_sb,
reiserfs_panic (p_s_sb, "tb_buffer_sanity_check(): buffer is not in tree %s[%d] (%b)\n", descr, level, p_s_bh);
}
if (!kdev_same(p_s_bh->b_dev, p_s_sb->s_dev) ||
if (p_s_bh->b_bdev != p_s_sb->s_bdev ||
p_s_bh->b_size != p_s_sb->s_blocksize ||
p_s_bh->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) {
reiserfs_panic (p_s_sb, "tb_buffer_sanity_check(): check failed for buffer %s[%d] (%b)\n", descr, level, p_s_bh);
......
......@@ -1702,7 +1702,7 @@ static int grab_tail_page(struct inode *p_s_inode,
** call prepare_write
*/
reiserfs_warning("clm-6000: error reading block %lu on dev %s\n",
bh->b_blocknr, kdevname(bh->b_dev)) ;
bh->b_blocknr, p_s_inode->i_sb->s_id) ;
error = -EIO ;
goto unlock ;
}
......
......@@ -98,6 +98,21 @@ static int journal_join(struct reiserfs_transaction_handle *th, struct super_blo
static int release_journal_dev( struct super_block *super,
struct reiserfs_journal *journal );
static inline struct buffer_head *journ_get_hash_table(struct super_block *s, int block)
{
return __get_hash_table(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize);
}
static inline struct buffer_head *journ_getblk(struct super_block *s, int block)
{
return __getblk(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize);
}
static inline struct buffer_head *journ_bread(struct super_block *s, int block)
{
return __bread(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize);
}
static void init_journal_hash(struct super_block *p_s_sb) {
memset(SB_JOURNAL(p_s_sb)->j_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ;
}
......@@ -690,7 +705,7 @@ static int flush_commit_list(struct super_block *s, struct reiserfs_journal_list
count = 0 ;
for (i = 0 ; atomic_read(&(jl->j_commit_left)) > 1 && i < (jl->j_len + 1) ; i++) { /* everything but commit_bh */
bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + (jl->j_start+i) % SB_ONDISK_JOURNAL_SIZE(s);
tbh = get_hash_table(SB_JOURNAL_DEV(s), bn, s->s_blocksize) ;
tbh = journ_get_hash_table(s, bn) ;
/* kill this sanity check */
if (count > (orig_commit_left + 2)) {
......@@ -719,7 +734,7 @@ reiserfs_panic(s, "journal-539: flush_commit_list: BAD count(%d) > orig_commit_l
for (i = 0 ; atomic_read(&(jl->j_commit_left)) > 1 &&
i < (jl->j_len + 1) ; i++) { /* everything but commit_bh */
bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + (jl->j_start + i) % SB_ONDISK_JOURNAL_SIZE(s) ;
tbh = get_hash_table(SB_JOURNAL_DEV(s), bn, s->s_blocksize) ;
tbh = journ_get_hash_table(s, bn) ;
wait_on_buffer(tbh) ;
if (!buffer_uptodate(tbh)) {
......@@ -1410,9 +1425,8 @@ static int journal_transaction_is_valid(struct super_block *p_s_sb, struct buffe
offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
/* ok, we have a journal description block, lets see if the transaction was valid */
c_bh = bread(SB_JOURNAL_DEV(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
((offset + le32_to_cpu(desc->j_len) + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)),
p_s_sb->s_blocksize) ;
c_bh = journ_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
((offset + le32_to_cpu(desc->j_len) + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
if (!c_bh)
return 0 ;
commit = (struct reiserfs_journal_commit *)c_bh->b_data ;
......@@ -1466,7 +1480,7 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
unsigned long trans_offset ;
int i;
d_bh = bread(SB_JOURNAL_DEV(p_s_sb), cur_dblock, p_s_sb->s_blocksize) ;
d_bh = journ_bread(p_s_sb, cur_dblock) ;
if (!d_bh)
return 1 ;
desc = (struct reiserfs_journal_desc *)d_bh->b_data ;
......@@ -1490,9 +1504,9 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
brelse(d_bh) ;
return 1 ;
}
c_bh = bread(SB_JOURNAL_DEV(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
c_bh = journ_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
((trans_offset + le32_to_cpu(desc->j_len) + 1) %
SB_ONDISK_JOURNAL_SIZE(p_s_sb)), p_s_sb->s_blocksize) ;
SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
if (!c_bh) {
brelse(d_bh) ;
return 1 ;
......@@ -1521,7 +1535,7 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
}
/* get all the buffer heads */
for(i = 0 ; i < le32_to_cpu(desc->j_len) ; i++) {
log_blocks[i] = getblk(SB_JOURNAL_DEV(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + (trans_offset + 1 + i) % SB_ONDISK_JOURNAL_SIZE(p_s_sb), p_s_sb->s_blocksize);
log_blocks[i] = journ_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + (trans_offset + 1 + i) % SB_ONDISK_JOURNAL_SIZE(p_s_sb));
if (i < JOURNAL_TRANS_HALF) {
real_blocks[i] = sb_getblk(p_s_sb, le32_to_cpu(desc->j_realblock[i])) ;
} else {
......@@ -1600,7 +1614,7 @@ static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cu
**
** On exit, it sets things up so the first transaction will work correctly.
*/
struct buffer_head * reiserfs_breada (kdev_t dev, int block, int bufsize,
struct buffer_head * reiserfs_breada (struct super_block *sb, int block,
unsigned int max_block)
{
struct buffer_head * bhlist[BUFNR];
......@@ -1608,7 +1622,7 @@ struct buffer_head * reiserfs_breada (kdev_t dev, int block, int bufsize,
struct buffer_head * bh;
int i, j;
bh = getblk (dev, block, bufsize);
bh = sb_getblk (sb, block);
if (buffer_uptodate (bh))
return (bh);
......@@ -1618,7 +1632,7 @@ struct buffer_head * reiserfs_breada (kdev_t dev, int block, int bufsize,
bhlist[0] = bh;
j = 1;
for (i = 1; i < blocks; i++) {
bh = getblk (dev, block + i, bufsize);
bh = sb_getblk (sb, block + i);
if (buffer_uptodate (bh)) {
brelse (bh);
break;
......@@ -1661,10 +1675,9 @@ static int journal_read(struct super_block *p_s_sb) {
** is the first unflushed, and if that transaction is not valid,
** replay is done
*/
SB_JOURNAL(p_s_sb)->j_header_bh = bread (SB_JOURNAL_DEV(p_s_sb),
SB_JOURNAL(p_s_sb)->j_header_bh = journ_bread(p_s_sb,
SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
SB_ONDISK_JOURNAL_SIZE(p_s_sb),
p_s_sb->s_blocksize) ;
SB_ONDISK_JOURNAL_SIZE(p_s_sb));
if (!SB_JOURNAL(p_s_sb)->j_header_bh) {
return 1 ;
}
......@@ -1685,7 +1698,7 @@ static int journal_read(struct super_block *p_s_sb) {
** there is nothing more we can do, and it makes no sense to read
** through the whole log.
*/
d_bh = bread(SB_JOURNAL_DEV(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + le32_to_cpu(jh->j_first_unflushed_offset), p_s_sb->s_blocksize) ;
d_bh = journ_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + le32_to_cpu(jh->j_first_unflushed_offset)) ;
ret = journal_transaction_is_valid(p_s_sb, d_bh, NULL, NULL) ;
if (!ret) {
continue_replay = 0 ;
......@@ -1705,7 +1718,7 @@ static int journal_read(struct super_block *p_s_sb) {
** all the valid transactions, and pick out the oldest.
*/
while(continue_replay && cur_dblock < (SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb))) {
d_bh = reiserfs_breada(p_s_sb->s_dev, cur_dblock, p_s_sb->s_blocksize,
d_bh = reiserfs_breada(p_s_sb, cur_dblock,
SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb)) ;
ret = journal_transaction_is_valid(p_s_sb, d_bh, &oldest_invalid_trans_id, &newest_mount_id) ;
if (ret == 1) {
......@@ -1973,9 +1986,6 @@ static int journal_init_dev( struct super_block *super,
if( !S_ISBLK( jdev_inode -> i_mode ) ) {
printk( "journal_init_dev: '%s' is not a block device", jdev_name );
result = -ENOTBLK;
} else if( journal -> j_dev_file -> f_vfsmnt -> mnt_flags & MNT_NODEV) {
printk( "journal_init_dev: Cannot use devices on '%s'", jdev_name );
result = -EACCES;
} else if( jdev_inode -> i_bdev == NULL ) {
printk( "journal_init_dev: bdev unintialized for '%s'", jdev_name );
result = -ENOMEM;
......@@ -2039,9 +2049,8 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo
rs = SB_DISK_SUPER_BLOCK(p_s_sb);
/* read journal header */
bhjh = bread (SB_JOURNAL_DEV(p_s_sb),
SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb),
SB_BLOCKSIZE(p_s_sb));
bhjh = journ_bread(p_s_sb,
SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb));
if (!bhjh) {
printk("sh-459: unable to read journal header\n") ;
return 1 ;
......@@ -2054,7 +2063,7 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo
char fname[ 32 ];
strcpy( jname, kdevname( SB_JOURNAL_DEV(p_s_sb) ) );
strcpy( fname, kdevname( p_s_sb->s_dev ) );
strcpy( fname, p_s_sb->s_id);
printk("sh-460: journal header magic %x (device %s) does not match "
"to magic found in super block %x (device %s)\n",
jh->jh_journal.jp_journal_magic, jname,
......@@ -2979,7 +2988,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, struct super_b
rs = SB_DISK_SUPER_BLOCK(p_s_sb) ;
/* setup description block */
d_bh = getblk(SB_JOURNAL_DEV(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_JOURNAL(p_s_sb)->j_start, p_s_sb->s_blocksize) ;
d_bh = journ_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_JOURNAL(p_s_sb)->j_start) ;
mark_buffer_uptodate(d_bh, 1) ;
desc = (struct reiserfs_journal_desc *)(d_bh)->b_data ;
memset(desc, 0, sizeof(struct reiserfs_journal_desc)) ;
......@@ -2987,9 +2996,8 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, struct super_b
desc->j_trans_id = cpu_to_le32(SB_JOURNAL(p_s_sb)->j_trans_id) ;
/* setup commit block. Don't write (keep it clean too) this one until after everyone else is written */
c_bh = getblk(SB_JOURNAL_DEV(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
((SB_JOURNAL(p_s_sb)->j_start + SB_JOURNAL(p_s_sb)->j_len + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)),
p_s_sb->s_blocksize) ;
c_bh = journ_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
((SB_JOURNAL(p_s_sb)->j_start + SB_JOURNAL(p_s_sb)->j_len + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
commit = (struct reiserfs_journal_commit *)c_bh->b_data ;
memset(commit, 0, sizeof(struct reiserfs_journal_commit)) ;
commit->j_trans_id = cpu_to_le32(SB_JOURNAL(p_s_sb)->j_trans_id) ;
......@@ -3079,9 +3087,8 @@ printk("journal-2020: do_journal_end: BAD desc->j_len is ZERO\n") ;
/* copy all the real blocks into log area. dirty log blocks */
if (test_bit(BH_JDirty, &cn->bh->b_state)) {
struct buffer_head *tmp_bh ;
tmp_bh = getblk(SB_JOURNAL_DEV(p_s_sb), SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
((cur_write_start + jindex) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)),
p_s_sb->s_blocksize) ;
tmp_bh = journ_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
((cur_write_start + jindex) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
mark_buffer_uptodate(tmp_bh, 1) ;
memcpy(tmp_bh->b_data, cn->bh->b_data, cn->bh->b_size) ;
jindex++ ;
......
......@@ -581,11 +581,6 @@ static int parse_options (char * options, unsigned long * mount_options, unsigne
}
int reiserfs_is_super(struct super_block *s) {
return (!kdev_same(s->s_dev, NODEV) && s->s_op == &reiserfs_sops) ;
}
//
// a portion of this function, particularly the VFS interface portion,
// was derived from minix or ext2's analog and evolved as the
......@@ -1201,6 +1196,11 @@ static struct file_system_type reiserfs_fs_type = {
fs_flags: FS_REQUIRES_DEV,
};
int reiserfs_is_super(struct super_block *s)
{
return s->s_type == &reiserfs_fs_type;
}
//
// this is exactly what 2.3.99-pre9's init_ext2_fs is
//
......
......@@ -455,5 +455,4 @@ int reiserfs_resize(struct super_block *, unsigned long) ;
#define SB_JOURNAL_MAX_TRANS_AGE(s) (SB_JOURNAL(s)->s_journal_max_trans_age)
#define SB_JOURNAL_DEV(s) (SB_JOURNAL(s)->j_dev)
#endif /* _LINUX_REISER_FS_SB */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment