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]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux