Message ID | 20211109083309.584081-20-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/29] nvdimm/pmem: move dax_attribute_group from dax to pmem | expand |
On Tue, Nov 9, 2021 at 12:34 AM Christoph Hellwig <hch@lst.de> wrote: > > Only call fs_dax_get_by_bdev once the sbi has been allocated and remove > the need for the dax_dev local variable. Looks good. Reviewed-by: Dan Williams <dan.j.williams@intel.com>
On Tue, Nov 09, 2021 at 09:32:59AM +0100, Christoph Hellwig wrote: > 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 <hch@lst.de> Looks good, Reviewed-by: Darrick J. Wong <djwong@kernel.org> --D > --- > fs/ext2/super.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/fs/ext2/super.c b/fs/ext2/super.c > index a964066a80aa7..7e23482862e69 100644 > --- a/fs/ext2/super.c > +++ b/fs/ext2/super.c > @@ -802,7 +802,6 @@ static unsigned long descriptor_loc(struct super_block *sb, > > static int ext2_fill_super(struct super_block *sb, void *data, int silent) > { > - struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev); > struct buffer_head * bh; > struct ext2_sb_info * sbi; > struct ext2_super_block * es; > @@ -822,17 +821,17 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) > > sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); > if (!sbi) > - goto failed; > + return -ENOMEM; > > sbi->s_blockgroup_lock = > kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); > if (!sbi->s_blockgroup_lock) { > kfree(sbi); > - goto failed; > + return -ENOMEM; > } > sb->s_fs_info = sbi; > sbi->s_sb_block = sb_block; > - sbi->s_daxdev = dax_dev; > + sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev); > > spin_lock_init(&sbi->s_lock); > ret = -EINVAL; > @@ -946,7 +945,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) > blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); > > if (test_opt(sb, DAX)) { > - if (!dax_dev) { > + if (!sbi->s_daxdev) { > ext2_msg(sb, KERN_ERR, > "DAX unsupported by block device. Turning off DAX."); > clear_opt(sbi->s_mount_opt, DAX); > @@ -1201,11 +1200,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) > failed_mount: > brelse(bh); > failed_sbi: > + fs_put_dax(sbi->s_daxdev); > sb->s_fs_info = NULL; > kfree(sbi->s_blockgroup_lock); > kfree(sbi); > -failed: > - fs_put_dax(dax_dev); > return ret; > } > > -- > 2.30.2 >
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index a964066a80aa7..7e23482862e69 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -802,7 +802,6 @@ static unsigned long descriptor_loc(struct super_block *sb, static int ext2_fill_super(struct super_block *sb, void *data, int silent) { - struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev); struct buffer_head * bh; struct ext2_sb_info * sbi; struct ext2_super_block * es; @@ -822,17 +821,17 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) - goto failed; + return -ENOMEM; sbi->s_blockgroup_lock = kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); if (!sbi->s_blockgroup_lock) { kfree(sbi); - goto failed; + return -ENOMEM; } sb->s_fs_info = sbi; sbi->s_sb_block = sb_block; - sbi->s_daxdev = dax_dev; + sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev); spin_lock_init(&sbi->s_lock); ret = -EINVAL; @@ -946,7 +945,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); if (test_opt(sb, DAX)) { - if (!dax_dev) { + if (!sbi->s_daxdev) { ext2_msg(sb, KERN_ERR, "DAX unsupported by block device. Turning off DAX."); clear_opt(sbi->s_mount_opt, DAX); @@ -1201,11 +1200,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) failed_mount: brelse(bh); failed_sbi: + fs_put_dax(sbi->s_daxdev); sb->s_fs_info = NULL; kfree(sbi->s_blockgroup_lock); kfree(sbi); -failed: - fs_put_dax(dax_dev); return ret; }
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 <hch@lst.de> --- fs/ext2/super.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)