Re: [PATCH 1/1 linux-next] jfs: atomically read inode size

From: Fabian Frederick
Date: Mon Jan 23 2017 - 14:52:09 EST




> On 23 January 2017 at 19:43 Dave Kleikamp <dave.kleikamp@xxxxxxxxxx> wrote:
>
>
> On 01/23/2017 11:50 AM, Fabian Frederick wrote:
> > See i_size_read() comments in include/linux/fs.h
>
> Is this fixing a real problem? Can the bd_inode size 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

> >
> > Signed-off-by: Fabian Frederick <fabf@xxxxxxxxx>
> > ---
> >Â fs/jfs/resize.c | 4 ++--
> > fs/jfs/super.c | 4 ++--
> >Â 2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/jfs/resize.c b/fs/jfs/resize.c
> > index bd9b641..7ddcb44 100644
> > --- a/fs/jfs/resize.c
> > +++ b/fs/jfs/resize.c
> > @@ -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) {
> >Â Â Â Â Â Â Â/*
> > diff --git a/fs/jfs/super.c b/fs/jfs/super.c
> > index c64c257..ad02f00 100644
> > --- a/fs/jfs/super.c
> > +++ b/fs/jfs/super.c
> > @@ -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);
> >