Re: [PATCH 4/6] iomap: helper to trim pos/bytes to within folio

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

 



On Mon, May 05, 2025 at 02:03:07AM -0700, Christoph Hellwig wrote:
> On Wed, Apr 30, 2025 at 03:01:10PM -0400, Brian Foster wrote:
> > +/* trim pos and bytes to within a given folio */
> > +static loff_t iomap_trim_folio_range(struct iomap_iter *iter,
> > +		struct folio *folio, size_t *offset, u64 *bytes)
> > +{
> > +	loff_t pos = iter->pos;
> > +	size_t fsize = folio_size(folio);
> > +
> > +	WARN_ON_ONCE(pos < folio_pos(folio) || pos >= folio_pos(folio) + fsize);
> 
> Should this be two separate WARN_ON_ONCE calls to see which one
> triggered?
> 

Sure, can't hurt.

> > +
> > +	*offset = offset_in_folio(folio, pos);
> > +	if (*bytes > fsize - *offset)
> > +		*bytes = fsize - *offset;
> 
> 	*bytes = min(*bytes, fsize - *offset);
> 

Yep.

> ?
> 
> Otherwise looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>
> 

Thanks.

Brian





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux