From: Qu Wenruo <wqu@suse.com>
To: Julian Sun <sunjunchao@bytedance.com>,
linux-fsdevel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-ext4@vger.kernel.org, ceph-devel@vger.kernel.org,
linux-btrfs@vger.kernel.org
Cc: clm@fb.com, dsterba@suse.com, xiubli@redhat.com,
idryomov@gmail.com, tytso@mit.edu, adilger.kernel@dilger.ca,
jaegeuk@kernel.org, chao@kernel.org, willy@infradead.org,
jack@suse.cz, brauner@kernel.org, agruenba@redhat.com
Subject: Re: [PATCH v2] fs: Make wbc_to_tag() inline and use it in fs.
Date: Tue, 30 Sep 2025 07:16:30 +0930 [thread overview]
Message-ID: <356ac25e-496e-4192-a3e6-2f9f41aa4864@suse.com> (raw)
In-Reply-To: <20250929111349.448324-1-sunjunchao@bytedance.com>
在 2025/9/29 20:43, Julian Sun 写道:
> The logic in wbc_to_tag() is widely used in file systems, so modify this
> function to be inline and use it in file systems.
>
> This patch has only passed compilation tests, but it should be fine.
>
> Signed-off-by: Julian Sun <sunjunchao@bytedance.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/extent_io.c | 5 +----
> fs/ceph/addr.c | 6 +-----
> fs/ext4/inode.c | 5 +----
> fs/f2fs/data.c | 5 +----
> fs/gfs2/aops.c | 5 +----
> include/linux/writeback.h | 7 +++++++
> mm/page-writeback.c | 6 ------
> 7 files changed, 12 insertions(+), 27 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index b21cb72835cc..0fea58287175 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -2390,10 +2390,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
> &BTRFS_I(inode)->runtime_flags))
> wbc->tagged_writepages = 1;
>
> - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> - tag = PAGECACHE_TAG_TOWRITE;
> - else
> - tag = PAGECACHE_TAG_DIRTY;
> + tag = wbc_to_tag(wbc);
> retry:
> if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> tag_pages_for_writeback(mapping, index, end);
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 322ed268f14a..63b75d214210 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -1045,11 +1045,7 @@ void ceph_init_writeback_ctl(struct address_space *mapping,
> ceph_wbc->index = ceph_wbc->start_index;
> ceph_wbc->end = -1;
>
> - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) {
> - ceph_wbc->tag = PAGECACHE_TAG_TOWRITE;
> - } else {
> - ceph_wbc->tag = PAGECACHE_TAG_DIRTY;
> - }
> + ceph_wbc->tag = wbc_to_tag(wbc);
>
> ceph_wbc->op_idx = -1;
> ceph_wbc->num_ops = 0;
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 5b7a15db4953..196eba7fa39c 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2619,10 +2619,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
> handle_t *handle = NULL;
> int bpp = ext4_journal_blocks_per_folio(mpd->inode);
>
> - if (mpd->wbc->sync_mode == WB_SYNC_ALL || mpd->wbc->tagged_writepages)
> - tag = PAGECACHE_TAG_TOWRITE;
> - else
> - tag = PAGECACHE_TAG_DIRTY;
> + tag = wbc_to_tag(mpd->wbc);
>
> mpd->map.m_len = 0;
> mpd->next_pos = mpd->start_pos;
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 7961e0ddfca3..101e962845db 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3003,10 +3003,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
> if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
> range_whole = 1;
> }
> - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> - tag = PAGECACHE_TAG_TOWRITE;
> - else
> - tag = PAGECACHE_TAG_DIRTY;
> + tag = wbc_to_tag(wbc);
> retry:
> retry = 0;
> if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
> index 47d74afd63ac..12394fc5dd29 100644
> --- a/fs/gfs2/aops.c
> +++ b/fs/gfs2/aops.c
> @@ -311,10 +311,7 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,
> range_whole = 1;
> cycled = 1; /* ignore range_cyclic tests */
> }
> - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> - tag = PAGECACHE_TAG_TOWRITE;
> - else
> - tag = PAGECACHE_TAG_DIRTY;
> + tag = wbc_to_tag(wbc);
>
> retry:
> if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> diff --git a/include/linux/writeback.h b/include/linux/writeback.h
> index a2848d731a46..dde77d13a200 100644
> --- a/include/linux/writeback.h
> +++ b/include/linux/writeback.h
> @@ -240,6 +240,13 @@ static inline void inode_detach_wb(struct inode *inode)
> }
> }
>
> +static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc)
> +{
> + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> + return PAGECACHE_TAG_TOWRITE;
> + return PAGECACHE_TAG_DIRTY;
> +}
> +
> void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
> struct inode *inode);
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 3e248d1c3969..ae1181a46dea 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2434,12 +2434,6 @@ static bool folio_prepare_writeback(struct address_space *mapping,
> return true;
> }
>
> -static xa_mark_t wbc_to_tag(struct writeback_control *wbc)
> -{
> - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
> - return PAGECACHE_TAG_TOWRITE;
> - return PAGECACHE_TAG_DIRTY;
> -}
>
> static pgoff_t wbc_end(struct writeback_control *wbc)
> {
next prev parent reply other threads:[~2025-09-29 21:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 11:13 [PATCH v2] fs: Make wbc_to_tag() inline and use it in fs Julian Sun
2025-09-29 11:50 ` Jan Kara
2025-09-29 21:46 ` Qu Wenruo [this message]
2025-09-30 1:57 ` kernel test robot
2025-10-06 10:30 ` Christian Brauner
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=356ac25e-496e-4192-a3e6-2f9f41aa4864@suse.com \
--to=wqu@suse.com \
--cc=adilger.kernel@dilger.ca \
--cc=agruenba@redhat.com \
--cc=brauner@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=chao@kernel.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=idryomov@gmail.com \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sunjunchao@bytedance.com \
--cc=tytso@mit.edu \
--cc=willy@infradead.org \
--cc=xiubli@redhat.com \
/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).