jfs: atomically read inode size
PATCH 1/1 jfs: atomically read inode size
See i_size_read() comments in include/linux/fs.h
--- fs/jfs/resize.c | 4 ++-- fs/jfs/super.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/jfs/resize.c +2 -2
@@ -98,7 +98,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize) goto out; } - VolumeSize = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; + VolumeSize =i_size_read (sb->s_bdev->bd_inode) >> sb->s_blocksize_bits;if (VolumeSize) {if (newLVSize > VolumeSize) {
@@ -211,7 +211,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)txQuiesce (sb);/* Reset size of direct inode */ - sbi->direct_inode->i_size = sb->s_bdev->bd_inode->i_size; + sbi->direct_inode->i_size =i_size_read (sb->s_bdev->bd_inode);if (sbi->mntflag &JFS_INLINELOG ) {/*
fs/jfs/super.c +2 -2
@@ -283,7 +283,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, }case Opt_resize_nosize: { - *newLVSize = sb->s_bdev->bd_inode->i_size >> + *newLVSize =i_size_read (sb->s_bdev->bd_inode) >> sb->s_blocksize_bits;if (*newLVSize ==0 )pr_err ("JFS: Cannot determine volume size\n" );
@@ -549,7 +549,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) goto out_unload; } inode->i_ino =0 ; - inode->i_size = sb->s_bdev->bd_inode->i_size; + inode->i_size =i_size_read (sb->s_bdev->bd_inode); inode->i_mapping->a_ops = &jfs_metapage_aops;hlist_add_fake (&inode->i_hash);mapping_set_gfp_mask (inode->i_mapping,GFP_NOFS );
Signature · 1 line
2.9.3
Quoted 1 line · Fabian Frederick
See
i_size_read()comments ininclude/linux/fs.h
Is this fixing a real problem? Can the bd_inode size change while we're mounting or resizing the filesystem?
Quoted 52 lines
Signed-off-by Fabian Frederick <[email protected]>--- fs/jfs/resize.c | 4 ++-- fs/jfs/super.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)fs/jfs/resize.c +2
-2@@ -98,7 +98,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize) goto out; } - VolumeSize = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; + VolumeSize =i_size_read (sb->s_bdev->bd_inode) >> sb->s_blocksize_bits;if (VolumeSize) {if (newLVSize > VolumeSize) {@@ -211,7 +211,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)txQuiesce (sb);/* Reset size of direct inode */ - sbi->direct_inode->i_size = sb->s_bdev->bd_inode->i_size; + sbi->direct_inode->i_size =i_size_read (sb->s_bdev->bd_inode);if (sbi->mntflag &JFS_INLINELOG ) {/* fs/jfs/super.c +2
-2@@ -283,7 +283,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, }case Opt_resize_nosize: { - *newLVSize = sb->s_bdev->bd_inode->i_size >> + *newLVSize =i_size_read (sb->s_bdev->bd_inode) >> sb->s_blocksize_bits;if (*newLVSize ==0 )pr_err ("JFS: Cannot determine volume size\n" );@@ -549,7 +549,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) goto out_unload; } inode->i_ino =0 ; - inode->i_size = sb->s_bdev->bd_inode->i_size; + inode->i_size =i_size_read (sb->s_bdev->bd_inode); inode->i_mapping->a_ops = &jfs_metapage_aops;hlist_add_fake (&inode->i_hash);mapping_set_gfp_mask (inode->i_mapping,GFP_NOFS );
Quoted 11 lines · On 23 January 2017 at 19:43 Dave Kleikamp <[email protected]> wrote:
Quoted 1 line · Fabian Frederick
See
i_size_read()comments ininclude/linux/fs.hIs this fixing a real problem? Can the
bd_inodesize change while we're mounting or resizing the filesystem?
Behind good locking, there should be no problem.
I made some patches like this to use read operation to remove any ambiguity.
Regards,
Fabian
Quoted 56 lines
Quoted 56 lines
Signed-off-by Fabian Frederick <[email protected]>---
fs/jfs/resize.c| 4 ++--
fs/jfs/super.c | 4 ++--2 files changed, 4 insertions(+), 4 deletions(-)fs/jfs/resize.c +0
-0@@ -98,7 +98,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize) goto out; }
- VolumeSize =sb->s_bdev->bd_inode->i_size>>sb->s_blocksize_bits; + VolumeSize =i_size_read(sb->s_bdev->bd_inode)>>sb->s_blocksize_bits;
if (VolumeSize) {
if (newLVSize > VolumeSize) {fs/jfs/resize.c +0
-0@@ -211,7 +211,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize) txQuiesce(sb);
/* Reset size of direct inode */
- sbi->direct_inode->i_size =sb->s_bdev->bd_inode->i_size; + sbi->direct_inode->i_size =i_size_read(sb->s_bdev->bd_inode);
if (sbi->mntflag&JFS_INLINELOG) {
/*fs/jfs/super.c +0
-0@@ -283,7 +283,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, }case
Opt_resize_nosize:
{
- *newLVSize =sb->s_bdev->bd_inode->i_size>> + *newLVSize =i_size_read(sb->s_bdev->bd_inode)>>sb->s_blocksize_bits;
if (*newLVSize == 0)
pr_err("JFS: Cannot determine volume size\n");fs/jfs/super.c +1
-1@@ -549,7 +549,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) goto out_unload; } inode->i_ino = 0; - inode->i_size = sb->s_bdev->bd_inode->i_size; + inode->i_size = i_size_read(sb->s_bdev->bd_inode); inode->i_mapping->a_ops = &jfs_metapage_aops; hlist_add_fake(&inode->i_hash);mapping_set_gfp_mask(inode->i_mapping,
GFP_NOFS);
Quoted 8 lines · Fabian Frederick
Quoted 8 lines · On 23 January 2017 at 19:43 Dave Kleikamp <[email protected]> wrote:
Quoted 1 line · Fabian Frederick
See
i_size_read()comments ininclude/linux/fs.h
Quoted 7 lines
Quoted 3 lines
Is this fixing a real problem? Can the
bd_inodesize change while we're mounting or resizing the filesystem?Behind good locking, there should be no problem.
I made some patches like this to use read operation to remove any ambiguity.
There are a lot of places where i_size_read/write is used for bd_inode, so I'll go ahead and take this patch for consistency of the code.
Thanks,
Shaggy
Quoted 60 lines
Regards,
FabianQuoted 56 lines
Quoted 56 lines
Signed-off-by Fabian Frederick <[email protected]>--- fs/jfs/resize.c | 4 ++-- fs/jfs/super.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)fs/jfs/resize.c +1
-1@@ -98,7 +98,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize) goto out; } - VolumeSize = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; + VolumeSize =i_size_read (sb->s_bdev->bd_inode) >> sb->s_blocksize_bits;if (VolumeSize) {if (newLVSize > VolumeSize) {fs/jfs/resize.c +1
-1@@ -211,7 +211,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)txQuiesce (sb );/* Reset size of direct inode */ - sbi->direct_inode->i_size = sb->s_bdev->bd_inode->i_size; + sbi->direct_inode->i_size =i_size_read (sb->s_bdev->bd_inode);if (sbi->mntflag &JFS_INLINELOG ) {/*fs/jfs/super.c +1
-1@@ -283,7 +283,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize, }case Opt_resize_nosize: { - *newLVSize = sb->s_bdev->bd_inode->i_size >> + *newLVSize =i_size_read (sb->s_bdev->bd_inode) >> sb->s_blocksize_bits;if (*newLVSize ==0 )pr_err("JFS: Cannot determine volume size\n");fs/jfs/super.c +1
-1@@ -549,7 +549,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) goto out_unload; } inode->i_ino =0 ; - inode->i_size = sb->s_bdev->bd_inode->i_size; + inode->i_size =i_size_read (sb->s_bdev->bd_inode); inode->i_mapping->a_ops = &jfs_metapage_aops;hlist_add_fake (&inode->i_hash);mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);