public inbox for linux-xfs@vger.kernel.org
 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 RFCv2 2/4] iomap: optional zero range dirty folio processing
Date: Wed, 8 Jan 2025 23:20:39 -0800	[thread overview]
Message-ID: <Z394x1XyN5F0fd4h@infradead.org> (raw)
In-Reply-To: <20241213150528.1003662-3-bfoster@redhat.com>

Just a bit of nitpicking, otherwise this looks sane, although I'd
want to return to proper review of the squashed prep patches first.

>  	if (!mapping_large_folio_support(iter->inode->i_mapping))
>  		len = min_t(size_t, len, PAGE_SIZE - offset_in_page(pos));
>  
> +	if (iter->fbatch) {
> +		struct folio *folio = folio_batch_next(iter->fbatch);
> +		if (folio) {

Missing empty line after the variable declaration.

> +	if (!folio) {
> +		WARN_ON_ONCE(!iter->fbatch);
> +		len = 0;
> +		goto out;

Given that the put label really just updates the return by reference
folio and len arguments we might as well do that here and avoid the
goto.

> +	} else if (folio_pos(folio) > iter->pos) {

Also no need for an else after a goto (or return).

> @@ -1374,6 +1393,11 @@ static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
>  		if (iter->iomap.flags & IOMAP_F_STALE)
>  			break;
>  
> +		if (!folio) {
> +			iomap_iter_advance(iter, iomap_length(iter));
> +			break;
> +		}

Maybe throw in a comment here how the NULL folio can happen?

> +	while (filemap_get_folios(mapping, &start, end, &fbatch) &&
> +	       folio_batch_space(iter->fbatch)) {
> +		struct folio *folio;
> +		while ((folio = folio_batch_next(&fbatch))) {
> +			if (folio_trylock(folio)) {
> +				bool clean = !folio_test_dirty(folio) &&
> +					     !folio_test_writeback(folio);
> +				folio_unlock(folio);
> +				if (clean)
> +					continue;
> +			}
> +
> +			folio_get(folio);
> +			if (!folio_batch_add(iter->fbatch, folio)) {
> +				end_pos = folio_pos(folio) + folio_size(folio);
> +				break;
> +			}
> +		}
> +		folio_batch_release(&fbatch);

I think I mentioned this last time, but I'd much prefer to do away
with the locla fbatch used for processing and rewrite this using a
find_get_entry() loop.  That probably means this helper needs to move
to filemap.c, which should be easy if we pass in the mapping and outer
fbatch.

> +		if (WARN_ON_ONCE(iter.fbatch && srcmap->type != IOMAP_UNWRITTEN))

Overly long line.

>  static inline void iomap_iter_reset_iomap(struct iomap_iter *iter)
>  {
> +	if (iter->fbatch) {
> +		folio_batch_release(iter->fbatch);
> +		kfree(iter->fbatch);
> +		iter->fbatch = NULL;
> +	}

Does it make sense to free the fbatch allocation on every iteration,
or should we keep the memory allocation around and only free it after
the last iteration?


  reply	other threads:[~2025-01-09  7:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13 15:05 [PATCH RFCv2 0/4] iomap: zero range folio batch processing prototype Brian Foster
2024-12-13 15:05 ` [PATCH RFCv2 1/4] iomap: prep work for folio_batch support Brian Foster
2024-12-13 15:05 ` [PATCH RFCv2 2/4] iomap: optional zero range dirty folio processing Brian Foster
2025-01-09  7:20   ` Christoph Hellwig [this message]
2025-01-10 17:53     ` Brian Foster
2025-01-13  4:51       ` Christoph Hellwig
2025-01-13 14:32         ` Brian Foster
2025-01-15  5:47           ` Christoph Hellwig
2025-01-16 14:14             ` Brian Foster
2024-12-13 15:05 ` [PATCH RFCv2 3/4] xfs: always trim mapping to requested range for zero range Brian Foster
2025-01-09  7:22   ` Christoph Hellwig
2024-12-13 15:05 ` [PATCH RFCv2 4/4] xfs: fill dirty folios on zero range of unwritten mappings Brian Foster
2025-01-09  7:26   ` Christoph Hellwig

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=Z394x1XyN5F0fd4h@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