Skip to content

Commit 61ead71

Browse files
committed
ext4: port block device access to file
Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 87b355f commit 61ead71

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

fs/ext4/ext4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ struct ext4_sb_info {
15481548
unsigned long s_commit_interval;
15491549
u32 s_max_batch_time;
15501550
u32 s_min_batch_time;
1551-
struct bdev_handle *s_journal_bdev_handle;
1551+
struct file *s_journal_bdev_file;
15521552
#ifdef CONFIG_QUOTA
15531553
/* Names of quota files with journalled quota */
15541554
char __rcu *s_qf_names[EXT4_MAXQUOTAS];

fs/ext4/fsmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,9 @@ static bool ext4_getfsmap_is_valid_device(struct super_block *sb,
576576
if (fm->fmr_device == 0 || fm->fmr_device == UINT_MAX ||
577577
fm->fmr_device == new_encode_dev(sb->s_bdev->bd_dev))
578578
return true;
579-
if (EXT4_SB(sb)->s_journal_bdev_handle &&
579+
if (EXT4_SB(sb)->s_journal_bdev_file &&
580580
fm->fmr_device ==
581-
new_encode_dev(EXT4_SB(sb)->s_journal_bdev_handle->bdev->bd_dev))
581+
new_encode_dev(file_bdev(EXT4_SB(sb)->s_journal_bdev_file)->bd_dev))
582582
return true;
583583
return false;
584584
}
@@ -648,9 +648,9 @@ int ext4_getfsmap(struct super_block *sb, struct ext4_fsmap_head *head,
648648
memset(handlers, 0, sizeof(handlers));
649649
handlers[0].gfd_dev = new_encode_dev(sb->s_bdev->bd_dev);
650650
handlers[0].gfd_fn = ext4_getfsmap_datadev;
651-
if (EXT4_SB(sb)->s_journal_bdev_handle) {
651+
if (EXT4_SB(sb)->s_journal_bdev_file) {
652652
handlers[1].gfd_dev = new_encode_dev(
653-
EXT4_SB(sb)->s_journal_bdev_handle->bdev->bd_dev);
653+
file_bdev(EXT4_SB(sb)->s_journal_bdev_file)->bd_dev);
654654
handlers[1].gfd_fn = ext4_getfsmap_logdev;
655655
}
656656

fs/ext4/super.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,14 +1359,14 @@ static void ext4_put_super(struct super_block *sb)
13591359

13601360
sync_blockdev(sb->s_bdev);
13611361
invalidate_bdev(sb->s_bdev);
1362-
if (sbi->s_journal_bdev_handle) {
1362+
if (sbi->s_journal_bdev_file) {
13631363
/*
13641364
* Invalidate the journal device's buffers. We don't want them
13651365
* floating about in memory - the physical journal device may
13661366
* hotswapped, and it breaks the `ro-after' testing code.
13671367
*/
1368-
sync_blockdev(sbi->s_journal_bdev_handle->bdev);
1369-
invalidate_bdev(sbi->s_journal_bdev_handle->bdev);
1368+
sync_blockdev(file_bdev(sbi->s_journal_bdev_file));
1369+
invalidate_bdev(file_bdev(sbi->s_journal_bdev_file));
13701370
}
13711371

13721372
ext4_xattr_destroy_cache(sbi->s_ea_inode_cache);
@@ -4233,7 +4233,7 @@ int ext4_calculate_overhead(struct super_block *sb)
42334233
* Add the internal journal blocks whether the journal has been
42344234
* loaded or not
42354235
*/
4236-
if (sbi->s_journal && !sbi->s_journal_bdev_handle)
4236+
if (sbi->s_journal && !sbi->s_journal_bdev_file)
42374237
overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_total_len);
42384238
else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) {
42394239
/* j_inum for internal journal is non-zero */
@@ -5670,9 +5670,9 @@ failed_mount9: __maybe_unused
56705670
#endif
56715671
fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy);
56725672
brelse(sbi->s_sbh);
5673-
if (sbi->s_journal_bdev_handle) {
5674-
invalidate_bdev(sbi->s_journal_bdev_handle->bdev);
5675-
bdev_release(sbi->s_journal_bdev_handle);
5673+
if (sbi->s_journal_bdev_file) {
5674+
invalidate_bdev(file_bdev(sbi->s_journal_bdev_file));
5675+
fput(sbi->s_journal_bdev_file);
56765676
}
56775677
out_fail:
56785678
invalidate_bdev(sb->s_bdev);
@@ -5842,30 +5842,30 @@ static journal_t *ext4_open_inode_journal(struct super_block *sb,
58425842
return journal;
58435843
}
58445844

5845-
static struct bdev_handle *ext4_get_journal_blkdev(struct super_block *sb,
5845+
static struct file *ext4_get_journal_blkdev(struct super_block *sb,
58465846
dev_t j_dev, ext4_fsblk_t *j_start,
58475847
ext4_fsblk_t *j_len)
58485848
{
58495849
struct buffer_head *bh;
58505850
struct block_device *bdev;
5851-
struct bdev_handle *bdev_handle;
5851+
struct file *bdev_file;
58525852
int hblock, blocksize;
58535853
ext4_fsblk_t sb_block;
58545854
unsigned long offset;
58555855
struct ext4_super_block *es;
58565856
int errno;
58575857

5858-
bdev_handle = bdev_open_by_dev(j_dev,
5858+
bdev_file = bdev_file_open_by_dev(j_dev,
58595859
BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES,
58605860
sb, &fs_holder_ops);
5861-
if (IS_ERR(bdev_handle)) {
5861+
if (IS_ERR(bdev_file)) {
58625862
ext4_msg(sb, KERN_ERR,
58635863
"failed to open journal device unknown-block(%u,%u) %ld",
5864-
MAJOR(j_dev), MINOR(j_dev), PTR_ERR(bdev_handle));
5865-
return bdev_handle;
5864+
MAJOR(j_dev), MINOR(j_dev), PTR_ERR(bdev_file));
5865+
return bdev_file;
58665866
}
58675867

5868-
bdev = bdev_handle->bdev;
5868+
bdev = file_bdev(bdev_file);
58695869
blocksize = sb->s_blocksize;
58705870
hblock = bdev_logical_block_size(bdev);
58715871
if (blocksize < hblock) {
@@ -5912,12 +5912,12 @@ static struct bdev_handle *ext4_get_journal_blkdev(struct super_block *sb,
59125912
*j_start = sb_block + 1;
59135913
*j_len = ext4_blocks_count(es);
59145914
brelse(bh);
5915-
return bdev_handle;
5915+
return bdev_file;
59165916

59175917
out_bh:
59185918
brelse(bh);
59195919
out_bdev:
5920-
bdev_release(bdev_handle);
5920+
fput(bdev_file);
59215921
return ERR_PTR(errno);
59225922
}
59235923

@@ -5927,14 +5927,14 @@ static journal_t *ext4_open_dev_journal(struct super_block *sb,
59275927
journal_t *journal;
59285928
ext4_fsblk_t j_start;
59295929
ext4_fsblk_t j_len;
5930-
struct bdev_handle *bdev_handle;
5930+
struct file *bdev_file;
59315931
int errno = 0;
59325932

5933-
bdev_handle = ext4_get_journal_blkdev(sb, j_dev, &j_start, &j_len);
5934-
if (IS_ERR(bdev_handle))
5935-
return ERR_CAST(bdev_handle);
5933+
bdev_file = ext4_get_journal_blkdev(sb, j_dev, &j_start, &j_len);
5934+
if (IS_ERR(bdev_file))
5935+
return ERR_CAST(bdev_file);
59365936

5937-
journal = jbd2_journal_init_dev(bdev_handle->bdev, sb->s_bdev, j_start,
5937+
journal = jbd2_journal_init_dev(file_bdev(bdev_file), sb->s_bdev, j_start,
59385938
j_len, sb->s_blocksize);
59395939
if (IS_ERR(journal)) {
59405940
ext4_msg(sb, KERN_ERR, "failed to create device journal");
@@ -5949,14 +5949,14 @@ static journal_t *ext4_open_dev_journal(struct super_block *sb,
59495949
goto out_journal;
59505950
}
59515951
journal->j_private = sb;
5952-
EXT4_SB(sb)->s_journal_bdev_handle = bdev_handle;
5952+
EXT4_SB(sb)->s_journal_bdev_file = bdev_file;
59535953
ext4_init_journal_params(sb, journal);
59545954
return journal;
59555955

59565956
out_journal:
59575957
jbd2_journal_destroy(journal);
59585958
out_bdev:
5959-
bdev_release(bdev_handle);
5959+
fput(bdev_file);
59605960
return ERR_PTR(errno);
59615961
}
59625962

@@ -7314,12 +7314,12 @@ static inline int ext3_feature_set_ok(struct super_block *sb)
73147314
static void ext4_kill_sb(struct super_block *sb)
73157315
{
73167316
struct ext4_sb_info *sbi = EXT4_SB(sb);
7317-
struct bdev_handle *handle = sbi ? sbi->s_journal_bdev_handle : NULL;
7317+
struct file *bdev_file = sbi ? sbi->s_journal_bdev_file : NULL;
73187318

73197319
kill_block_super(sb);
73207320

7321-
if (handle)
7322-
bdev_release(handle);
7321+
if (bdev_file)
7322+
fput(bdev_file);
73237323
}
73247324

73257325
static struct file_system_type ext4_fs_type = {

0 commit comments

Comments
 (0)