reiserfs: port block device access to file

Link: https://lore.kernel.org/r/20240123-vfs-bdev-file-v2-26-adbd023e19cc@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2024-01-23 14:26:43 +01:00
parent 1d3aa0b97c
commit 9de31ee6d7
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
3 changed files with 24 additions and 24 deletions

View File

@ -2386,7 +2386,7 @@ static int journal_read(struct super_block *sb)
cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(sb); cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(sb);
reiserfs_info(sb, "checking transaction log (%pg)\n", reiserfs_info(sb, "checking transaction log (%pg)\n",
journal->j_bdev_handle->bdev); file_bdev(journal->j_bdev_file));
start = ktime_get_seconds(); start = ktime_get_seconds();
/* /*
@ -2447,7 +2447,7 @@ static int journal_read(struct super_block *sb)
* device and journal device to be the same * device and journal device to be the same
*/ */
d_bh = d_bh =
reiserfs_breada(journal->j_bdev_handle->bdev, cur_dblock, reiserfs_breada(file_bdev(journal->j_bdev_file), cur_dblock,
sb->s_blocksize, sb->s_blocksize,
SB_ONDISK_JOURNAL_1st_BLOCK(sb) + SB_ONDISK_JOURNAL_1st_BLOCK(sb) +
SB_ONDISK_JOURNAL_SIZE(sb)); SB_ONDISK_JOURNAL_SIZE(sb));
@ -2588,9 +2588,9 @@ static void journal_list_init(struct super_block *sb)
static void release_journal_dev(struct reiserfs_journal *journal) static void release_journal_dev(struct reiserfs_journal *journal)
{ {
if (journal->j_bdev_handle) { if (journal->j_bdev_file) {
bdev_release(journal->j_bdev_handle); fput(journal->j_bdev_file);
journal->j_bdev_handle = NULL; journal->j_bdev_file = NULL;
} }
} }
@ -2605,7 +2605,7 @@ static int journal_init_dev(struct super_block *super,
result = 0; result = 0;
journal->j_bdev_handle = NULL; journal->j_bdev_file = NULL;
jdev = SB_ONDISK_JOURNAL_DEVICE(super) ? jdev = SB_ONDISK_JOURNAL_DEVICE(super) ?
new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev; new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev;
@ -2616,37 +2616,37 @@ static int journal_init_dev(struct super_block *super,
if ((!jdev_name || !jdev_name[0])) { if ((!jdev_name || !jdev_name[0])) {
if (jdev == super->s_dev) if (jdev == super->s_dev)
holder = NULL; holder = NULL;
journal->j_bdev_handle = bdev_open_by_dev(jdev, blkdev_mode, journal->j_bdev_file = bdev_file_open_by_dev(jdev, blkdev_mode,
holder, NULL); holder, NULL);
if (IS_ERR(journal->j_bdev_handle)) { if (IS_ERR(journal->j_bdev_file)) {
result = PTR_ERR(journal->j_bdev_handle); result = PTR_ERR(journal->j_bdev_file);
journal->j_bdev_handle = NULL; journal->j_bdev_file = NULL;
reiserfs_warning(super, "sh-458", reiserfs_warning(super, "sh-458",
"cannot init journal device unknown-block(%u,%u): %i", "cannot init journal device unknown-block(%u,%u): %i",
MAJOR(jdev), MINOR(jdev), result); MAJOR(jdev), MINOR(jdev), result);
return result; return result;
} else if (jdev != super->s_dev) } else if (jdev != super->s_dev)
set_blocksize(journal->j_bdev_handle->bdev, set_blocksize(file_bdev(journal->j_bdev_file),
super->s_blocksize); super->s_blocksize);
return 0; return 0;
} }
journal->j_bdev_handle = bdev_open_by_path(jdev_name, blkdev_mode, journal->j_bdev_file = bdev_file_open_by_path(jdev_name, blkdev_mode,
holder, NULL); holder, NULL);
if (IS_ERR(journal->j_bdev_handle)) { if (IS_ERR(journal->j_bdev_file)) {
result = PTR_ERR(journal->j_bdev_handle); result = PTR_ERR(journal->j_bdev_file);
journal->j_bdev_handle = NULL; journal->j_bdev_file = NULL;
reiserfs_warning(super, "sh-457", reiserfs_warning(super, "sh-457",
"journal_init_dev: Cannot open '%s': %i", "journal_init_dev: Cannot open '%s': %i",
jdev_name, result); jdev_name, result);
return result; return result;
} }
set_blocksize(journal->j_bdev_handle->bdev, super->s_blocksize); set_blocksize(file_bdev(journal->j_bdev_file), super->s_blocksize);
reiserfs_info(super, reiserfs_info(super,
"journal_init_dev: journal device: %pg\n", "journal_init_dev: journal device: %pg\n",
journal->j_bdev_handle->bdev); file_bdev(journal->j_bdev_file));
return 0; return 0;
} }
@ -2804,7 +2804,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
"journal header magic %x (device %pg) does " "journal header magic %x (device %pg) does "
"not match to magic found in super block %x", "not match to magic found in super block %x",
jh->jh_journal.jp_journal_magic, jh->jh_journal.jp_journal_magic,
journal->j_bdev_handle->bdev, file_bdev(journal->j_bdev_file),
sb_jp_journal_magic(rs)); sb_jp_journal_magic(rs));
brelse(bhjh); brelse(bhjh);
goto free_and_return; goto free_and_return;
@ -2828,7 +2828,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
reiserfs_info(sb, "journal params: device %pg, size %u, " reiserfs_info(sb, "journal params: device %pg, size %u, "
"journal first block %u, max trans len %u, max batch %u, " "journal first block %u, max trans len %u, max batch %u, "
"max commit age %u, max trans age %u\n", "max commit age %u, max trans age %u\n",
journal->j_bdev_handle->bdev, file_bdev(journal->j_bdev_file),
SB_ONDISK_JOURNAL_SIZE(sb), SB_ONDISK_JOURNAL_SIZE(sb),
SB_ONDISK_JOURNAL_1st_BLOCK(sb), SB_ONDISK_JOURNAL_1st_BLOCK(sb),
journal->j_trans_max, journal->j_trans_max,

View File

@ -354,7 +354,7 @@ static int show_journal(struct seq_file *m, void *unused)
"prepare: \t%12lu\n" "prepare: \t%12lu\n"
"prepare_retry: \t%12lu\n", "prepare_retry: \t%12lu\n",
DJP(jp_journal_1st_block), DJP(jp_journal_1st_block),
SB_JOURNAL(sb)->j_bdev_handle->bdev, file_bdev(SB_JOURNAL(sb)->j_bdev_file),
DJP(jp_journal_dev), DJP(jp_journal_dev),
DJP(jp_journal_size), DJP(jp_journal_size),
DJP(jp_journal_trans_max), DJP(jp_journal_trans_max),

View File

@ -299,7 +299,7 @@ struct reiserfs_journal {
/* oldest journal block. start here for traverse */ /* oldest journal block. start here for traverse */
struct reiserfs_journal_cnode *j_first; struct reiserfs_journal_cnode *j_first;
struct bdev_handle *j_bdev_handle; struct file *j_bdev_file;
/* first block on s_dev of reserved area journal */ /* first block on s_dev of reserved area journal */
int j_1st_reserved_block; int j_1st_reserved_block;
@ -2810,10 +2810,10 @@ struct reiserfs_journal_header {
/* We need these to make journal.c code more readable */ /* We need these to make journal.c code more readable */
#define journal_find_get_block(s, block) __find_get_block(\ #define journal_find_get_block(s, block) __find_get_block(\
SB_JOURNAL(s)->j_bdev_handle->bdev, block, s->s_blocksize) file_bdev(SB_JOURNAL(s)->j_bdev_file), block, s->s_blocksize)
#define journal_getblk(s, block) __getblk(SB_JOURNAL(s)->j_bdev_handle->bdev,\ #define journal_getblk(s, block) __getblk(file_bdev(SB_JOURNAL(s)->j_bdev_file),\
block, s->s_blocksize) block, s->s_blocksize)
#define journal_bread(s, block) __bread(SB_JOURNAL(s)->j_bdev_handle->bdev,\ #define journal_bread(s, block) __bread(file_bdev(SB_JOURNAL(s)->j_bdev_file),\
block, s->s_blocksize) block, s->s_blocksize)
enum reiserfs_bh_state_bits { enum reiserfs_bh_state_bits {