Re: [PATCH] mm,tmpfs: consider end of file write in shmem_is_huge

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 30, 2024 at 09:11:32AM -0400, Rik van Riel wrote:
> On Thu, 2024-08-29 at 22:52 -0700, Darrick J. Wong wrote:
> > On Thu, Aug 29, 2024 at 11:54:15PM -0400, Rik van Riel wrote:
> > > 
> > > @@ -196,7 +196,7 @@ xfile_store(
> > >  		unsigned int	len;
> > >  		unsigned int	offset;
> > >  
> > > -		if (shmem_get_folio(inode, pos >> PAGE_SHIFT,
> > > &folio,
> > > +		if (shmem_get_folio(inode, pos >> PAGE_SHIFT, 0,
> > > &folio,
> > 
> > Technically speaking, the "0" here could be (pos + count), though for
> > the current xfile users this isn't likely to make much difference
> > because online fsck's index building only appends small amounts of
> > data
> > (i.e. not larger than a PAGE_SIZE) at a time.
> > 
> > >  				SGP_CACHE) < 0)
> 
> With SGP_CACHE, won't shmem_get_folio simply refuse to allocate
> any pages beyond the end of the inode?

Yes, though we're careful to i_size_write appropriate beforehand such
that @index is always within EOF.

--D

>         if (sgp <= SGP_CACHE &&
>             ((loff_t)index << PAGE_SHIFT) >= i_size_read(inode))
>                 return -EINVAL;
> 
> > >  			break;
> > >  		if (filemap_check_wb_err(inode->i_mapping, 0)) {
> > > @@ -267,7 +267,7 @@ xfile_get_folio(
> > >  		i_size_write(inode, pos + len);
> > >  
> > >  	pflags = memalloc_nofs_save();
> > > -	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio,
> > > +	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, 0,
> > > &folio,
> > 
> > This 0 could be pos + len, since the only caller is xfarray_sort,
> > which
> > runs much faster when it can heapsort a large folio's worth of data
> > at a
> > time.
> > 
> > >  			(flags & XFILE_ALLOC) ? SGP_CACHE :
> > > SGP_READ);
> 
> The same applies here.
> 
> > >  	memalloc_nofs_restore(pflags);
> > >  	if (error)
> > > diff --git a/fs/xfs/xfs_buf_mem.c b/fs/xfs/xfs_buf_mem.c
> > > index 9bb2d24de709..07bebbfb16ee 100644
> > > --- a/fs/xfs/xfs_buf_mem.c
> > > +++ b/fs/xfs/xfs_buf_mem.c
> > > @@ -149,7 +149,7 @@ xmbuf_map_page(
> > >  		return -ENOMEM;
> > >  	}
> > >  
> > > -	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio,
> > > SGP_CACHE);
> > > +	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, 0,
> > > &folio, SGP_CACHE);
> > 
> > The "0" here could be (pos + BBTOB(bp->length)) since we're likely
> > going
> > to write there soon.  Granted, no current user of xmbufs actually
> > uses a
> > blocksize larger than PAGE_SIZE, but in theory we could someday turn
> > that on.
> > 
> > Everything below here looks sane enough to me, but I'm not that much
> > of
> > an expert on mm/ things outside of the pagecache and shmem.c.
> 
> ... and here.
> 
> XFS is no using an SGP flag that allows shmem_get_folio to allocate
> a page beyond the end of the i_size.
> 
> -- 
> All Rights Reversed.




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux