]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs: Make wbc_to_tag() inline and use it in fs.
authorJulian Sun <sunjunchao@bytedance.com>
Mon, 29 Sep 2025 11:13:49 +0000 (19:13 +0800)
committerChristian Brauner <brauner@kernel.org>
Wed, 29 Oct 2025 22:33:48 +0000 (23:33 +0100)
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>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/btrfs/extent_io.c
fs/ceph/addr.c
fs/ext4/inode.c
fs/f2fs/data.c
fs/gfs2/aops.c
include/linux/writeback.h
mm/page-writeback.c

index c123a3ef154ae5fb5575b78c55608a8f9ac78fc7..170dd7e80d11fbedd31323ccbf408f8ed9b993b0 100644 (file)
@@ -2460,10 +2460,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);
index 322ed268f14aa9b96bde8e2657fbd29acae90402..63b75d2142102e9e217aae49689642c69e6b6e89 100644 (file)
@@ -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;
index f9e4ac87211ec108c58f5e313a374647e0cc2e03..58d6194045e2b8643a5b16efb0e7cd59cfe0dc7b 100644 (file)
@@ -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;
index ef38e62cda8fe6ddf784b16e0a725bf4dc075f52..826bcfb8230caf192492a35766526d8c21a92ee9 100644 (file)
@@ -2986,10 +2986,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)
index 47d74afd63ac99e5db0ba548c103e2b2d968edff..12394fc5dd2956127621068df6a3878bf9f98189 100644 (file)
@@ -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)
index 49e1dd96f43e53d4d7ae01ab47030076ad4f797a..2a81816f7507ac5598e199fc8646507034d5c0a8 100644 (file)
@@ -196,6 +196,13 @@ static inline void wait_on_inode(struct inode *inode)
                       !(READ_ONCE(inode->i_state) & I_NEW));
 }
 
+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;
+}
+
 #ifdef CONFIG_CGROUP_WRITEBACK
 
 #include <linux/cgroup.h>
index 757bc4d3b5b5515c5b69fdeaaecb8307d8cc451b..a124ab6a205d522758b89679c36d1a0e33c2cbd1 100644 (file)
@@ -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)
 {