On 2021/2/26 10:20, Chengguang Xu wrote:
  ---- 在 星期四, 2021-02-25 09:24:51 Chao Yu <[email protected]> 撰写 ----
  > On 2021/2/23 19:50, Chengguang Xu wrote:
  > > F2FS inode may have different max size,
  > > so change to use per-inode maxbytes.
  > >
  > > Signed-off-by: Chengguang Xu <[email protected]>
  > > ---
  > >   fs/f2fs/data.c | 5 +++++
  > >   1 file changed, 5 insertions(+)
  > >
  > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
  > > index b9721c8f116c..b330c6a27b14 100644
  > > --- a/fs/f2fs/data.c
  > > +++ b/fs/f2fs/data.c
  > > @@ -1838,6 +1838,7 @@ int f2fs_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
  > >       int ret = 0;
  > >       bool compr_cluster = false;
  > >       unsigned int cluster_size = F2FS_I(inode)->i_cluster_size;
  > > +    loff_t maxbytes;
  > >
  > >       if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
  > >           ret = f2fs_precache_extents(inode);
  > > @@ -1845,6 +1846,10 @@ int f2fs_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
  > >               return ret;
  > >       }
  > >
  > > +    maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
  > > +    if (len > maxbytes || (maxbytes - len) < start)
  > > +        len = maxbytes - start;
  >
  > This should be checked under inode lock, otherwise the max filesize 
calculation
  > can race with compress inode conversion.
  >

Thanks for your review. There are some other places also calling 
max_file_blocks() and f2fs_compressed_file(),

You mean sbi->max_file_blocks? I guess it should be replaced with 
max_inode_blocks().

so  I'm wondering  if we should add lock inside f2fs_compressed_file() to avoid 
race with compress inode conversion.

I think max_inode_blocks()'s caller should keep do the size check under inode 
lock
rather than adding lock into f2fs_compressed_file().

Thanks,


Thanks,
Chengguang
.



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to