Skip to content

Commit cea845c

Browse files
Christoph Hellwigdjbw
authored andcommitted
ext2: cleanup the dax handling in ext2_fill_super
Only call fs_dax_get_by_bdev once the sbi has been allocated and remove the need for the dax_dev local variable. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent c6f4046 commit cea845c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

fs/ext2/super.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ static unsigned long descriptor_loc(struct super_block *sb,
802802

803803
static int ext2_fill_super(struct super_block *sb, void *data, int silent)
804804
{
805-
struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev);
806805
struct buffer_head * bh;
807806
struct ext2_sb_info * sbi;
808807
struct ext2_super_block * es;
@@ -822,17 +821,17 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
822821

823822
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
824823
if (!sbi)
825-
goto failed;
824+
return -ENOMEM;
826825

827826
sbi->s_blockgroup_lock =
828827
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
829828
if (!sbi->s_blockgroup_lock) {
830829
kfree(sbi);
831-
goto failed;
830+
return -ENOMEM;
832831
}
833832
sb->s_fs_info = sbi;
834833
sbi->s_sb_block = sb_block;
835-
sbi->s_daxdev = dax_dev;
834+
sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev);
836835

837836
spin_lock_init(&sbi->s_lock);
838837
ret = -EINVAL;
@@ -946,7 +945,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
946945
blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
947946

948947
if (test_opt(sb, DAX)) {
949-
if (!dax_dev) {
948+
if (!sbi->s_daxdev) {
950949
ext2_msg(sb, KERN_ERR,
951950
"DAX unsupported by block device. Turning off DAX.");
952951
clear_opt(sbi->s_mount_opt, DAX);
@@ -1201,11 +1200,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
12011200
failed_mount:
12021201
brelse(bh);
12031202
failed_sbi:
1203+
fs_put_dax(sbi->s_daxdev);
12041204
sb->s_fs_info = NULL;
12051205
kfree(sbi->s_blockgroup_lock);
12061206
kfree(sbi);
1207-
failed:
1208-
fs_put_dax(dax_dev);
12091207
return ret;
12101208
}
12111209

0 commit comments

Comments
 (0)