From: Ojaswin Mujoo <ojaswin@linux.ibm.com>
To: "Pankaj Raghav (Samsung)" <pankaj.raghav@linux.dev>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
djwong@kernel.org, john.g.garry@oracle.com, willy@infradead.org,
hch@lst.de, ritesh.list@gmail.com, jack@suse.cz,
Luis Chamberlain <mcgrof@kernel.org>,
dgc@kernel.org, tytso@mit.edu, p.raghav@samsung.com,
andres@anarazel.de, brauner@kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [RFC PATCH v2 2/5] iomap: Add initial support for buffered RWF_WRITETHROUGH
Date: Sat, 18 Apr 2026 13:03:00 +0530 [thread overview]
Message-ID: <aeMzrKNO7SPgjLyc@li-dc0c254c-257c-11b2-a85c-98b6c1322444.ibm.com> (raw)
In-Reply-To: <2dmo4my5rml4ymfuw5afc2fnbcxn2l3w3bz2boj4eevognilni@vgy4vwlikqx7>
On Fri, Apr 17, 2026 at 06:13:31AM +0200, Pankaj Raghav (Samsung) wrote:
> <snip>
> > 3.3. Wait for any current writeback to complete and then call
> > folio_mkclean() to prevent mmap writes from changing it.
> > 3.4. Start writeback on the folio
> <snip>
> > +
> > +/**
> > + * iomap_writethrough_begin - prepare the various structures for writethrough
> > + * @folio: folio to prepare for writethrough
> > + * @off: offset of write within folio
> > + * @len: len of write within folio
> > + *
> > + * This function does the major preparation work needed before starting the
> > + * writethrough. The main task is to prepare folio for writeththrough by blocking
> > + * mmap writes and setting writeback on it. Further, we must clear the write range
> > + * to non-dirty. If this results in the complete folio becoming non-dirty, then we
> > + * need to clear the master dirty bit.
> > + */
> > +static void iomap_folio_prepare_writethrough(struct folio *folio, size_t off,
> > + size_t len)
> > +{
> > + bool fully_written;
> > + u64 zero = 0;
> > +
> > + if (folio_test_writeback(folio))
> > + folio_wait_writeback(folio);
> > +
> > + if (folio_mkclean(folio))
> > + folio_mark_dirty(folio);
> > +
> > + /*
> > + * We might either write through the complete folio or a partial folio
> > + * writethrough might result in all blocks becoming non-dirty, so we need to
> > + * check and mark the folio clean if that is the case.
> > + */
> > + fully_written = (off == 0 && len == folio_size(folio));
> > + iomap_clear_range_dirty(folio, off, len);
> > + if (fully_written ||
> > + !iomap_find_dirty_range(folio, &zero, folio_size(folio)))
> > + folio_clear_dirty_for_writethrough(folio);
>
> I get the point where you want to prevent mmap writes before the current
> writeback completes. It is not very obvious to me why folio_mkclean
> and folio_mark_dirty had to be moved out and then we call the
> folio_clear_dirty_for_writethrough wrapper. Anyway those calls are made
> after we do folio_wait_writeback right?
> Is to cover the cases where we do partial write in which case we don't
> end up calling folio_clear_dirty_for_io? If that is the case, then a small
> comment on top of folio_mkclean would make it a bit more clear.
Hey Pankaj,
Yes you are right, we need to call folio_wait_writeback() and mkclean()
for partial or complete writes. However, clearing of foliodirty bit and
accounting shall only be done when the complete folio becomes clean, and
hence we call folio_clear_dirty_for_writethrough() only for those cases.
I will add a more clear comment for this in v3.
Thanks,
Ojaswin
>
> --
> Pankaj
next prev parent reply other threads:[~2026-04-18 7:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 18:45 [RFC PATCH v2 0/5] Add buffered write-through support to iomap & xfs Ojaswin Mujoo
2026-04-08 18:45 ` [RFC PATCH v2 1/5] mm: Refactor folio_clear_dirty_for_io() Ojaswin Mujoo
2026-04-15 6:14 ` Christoph Hellwig
2026-04-08 18:45 ` [RFC PATCH v2 2/5] iomap: Add initial support for buffered RWF_WRITETHROUGH Ojaswin Mujoo
2026-04-16 12:05 ` Jan Kara
2026-04-16 12:34 ` Jan Kara
2026-04-17 19:42 ` Ojaswin Mujoo
2026-04-17 4:13 ` Pankaj Raghav (Samsung)
2026-04-18 7:33 ` Ojaswin Mujoo [this message]
2026-04-08 18:45 ` [RFC PATCH v2 3/5] xfs: Add RWF_WRITETHROUGH support to xfs Ojaswin Mujoo
2026-04-08 18:45 ` [RFC PATCH v2 4/5] iomap: Add aio support to RWF_WRITETHROUGH Ojaswin Mujoo
2026-04-08 18:45 ` [RFC PATCH v2 5/5] iomap: Add DSYNC support to writethrough Ojaswin Mujoo
2026-04-17 3:54 ` [RFC PATCH v2 0/5] Add buffered write-through support to iomap & xfs Pankaj Raghav (Samsung)
2026-04-18 7:26 ` Ojaswin Mujoo
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=aeMzrKNO7SPgjLyc@li-dc0c254c-257c-11b2-a85c-98b6c1322444.ibm.com \
--to=ojaswin@linux.ibm.com \
--cc=andres@anarazel.de \
--cc=brauner@kernel.org \
--cc=dgc@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=john.g.garry@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.com \
--cc=pankaj.raghav@linux.dev \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=willy@infradead.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