linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/6] iomap: helper to trim pos/bytes to within folio
Date: Mon, 5 May 2025 02:03:07 -0700	[thread overview]
Message-ID: <aBh-y_qLVZUGxMU_@infradead.org> (raw)
In-Reply-To: <20250430190112.690800-5-bfoster@redhat.com>

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?

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

	*bytes = min(*bytes, fsize - *offset);

?

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

  reply	other threads:[~2025-05-05  9:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30 19:01 [PATCH 0/6] iomap: misc buffered write path cleanups and prep Brian Foster
2025-04-30 19:01 ` [PATCH 1/6] iomap: resample iter->pos after iomap_write_begin() calls Brian Foster
2025-05-05  9:00   ` Christoph Hellwig
2025-04-30 19:01 ` [PATCH 2/6] iomap: drop unnecessary pos param from iomap_write_[begin|end] Brian Foster
2025-05-01 22:22   ` Darrick J. Wong
2025-05-05  9:01   ` Christoph Hellwig
2025-04-30 19:01 ` [PATCH 3/6] iomap: drop pos param from __iomap_[get|put]_folio() Brian Foster
2025-05-01 22:22   ` Darrick J. Wong
2025-05-05  9:01   ` Christoph Hellwig
2025-04-30 19:01 ` [PATCH 4/6] iomap: helper to trim pos/bytes to within folio Brian Foster
2025-05-05  9:03   ` Christoph Hellwig [this message]
2025-05-05 14:38     ` Brian Foster
2025-04-30 19:01 ` [PATCH 5/6] iomap: push non-large folio check into get folio path Brian Foster
2025-05-05  9:03   ` Christoph Hellwig
2025-04-30 19:01 ` [PATCH 6/6] iomap: rework iomap_write_begin() to return folio offset and length Brian Foster
2025-05-01 22:22   ` Darrick J. Wong
2025-05-02 13:18     ` Brian Foster
2025-05-02 19:40       ` Darrick J. Wong
2025-05-02 20:00   ` Darrick J. Wong
2025-05-05 14:39     ` Brian Foster
2025-05-05  9:05   ` Christoph Hellwig
2025-05-05 14:39     ` Brian Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aBh-y_qLVZUGxMU_@infradead.org \
    --to=hch@infradead.org \
    --cc=bfoster@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).