Skip to content

Commit 4952f35

Browse files
Julian Sunbrauner
authored andcommitted
fs: Make wbc_to_tag() inline and use it in fs.
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>
1 parent 891bea7 commit 4952f35

7 files changed

Lines changed: 12 additions & 27 deletions

File tree

fs/btrfs/extent_io.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,10 +2460,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
24602460
&BTRFS_I(inode)->runtime_flags))
24612461
wbc->tagged_writepages = 1;
24622462

2463-
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
2464-
tag = PAGECACHE_TAG_TOWRITE;
2465-
else
2466-
tag = PAGECACHE_TAG_DIRTY;
2463+
tag = wbc_to_tag(wbc);
24672464
retry:
24682465
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
24692466
tag_pages_for_writeback(mapping, index, end);

fs/ceph/addr.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,7 @@ void ceph_init_writeback_ctl(struct address_space *mapping,
10451045
ceph_wbc->index = ceph_wbc->start_index;
10461046
ceph_wbc->end = -1;
10471047

1048-
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) {
1049-
ceph_wbc->tag = PAGECACHE_TAG_TOWRITE;
1050-
} else {
1051-
ceph_wbc->tag = PAGECACHE_TAG_DIRTY;
1052-
}
1048+
ceph_wbc->tag = wbc_to_tag(wbc);
10531049

10541050
ceph_wbc->op_idx = -1;
10551051
ceph_wbc->num_ops = 0;

fs/ext4/inode.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,10 +2619,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
26192619
handle_t *handle = NULL;
26202620
int bpp = ext4_journal_blocks_per_folio(mpd->inode);
26212621

2622-
if (mpd->wbc->sync_mode == WB_SYNC_ALL || mpd->wbc->tagged_writepages)
2623-
tag = PAGECACHE_TAG_TOWRITE;
2624-
else
2625-
tag = PAGECACHE_TAG_DIRTY;
2622+
tag = wbc_to_tag(mpd->wbc);
26262623

26272624
mpd->map.m_len = 0;
26282625
mpd->next_pos = mpd->start_pos;

fs/f2fs/data.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,10 +2986,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
29862986
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
29872987
range_whole = 1;
29882988
}
2989-
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
2990-
tag = PAGECACHE_TAG_TOWRITE;
2991-
else
2992-
tag = PAGECACHE_TAG_DIRTY;
2989+
tag = wbc_to_tag(wbc);
29932990
retry:
29942991
retry = 0;
29952992
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)

fs/gfs2/aops.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,7 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,
311311
range_whole = 1;
312312
cycled = 1; /* ignore range_cyclic tests */
313313
}
314-
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
315-
tag = PAGECACHE_TAG_TOWRITE;
316-
else
317-
tag = PAGECACHE_TAG_DIRTY;
314+
tag = wbc_to_tag(wbc);
318315

319316
retry:
320317
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)

include/linux/writeback.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ static inline void wait_on_inode(struct inode *inode)
196196
!(READ_ONCE(inode->i_state) & I_NEW));
197197
}
198198

199+
static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc)
200+
{
201+
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
202+
return PAGECACHE_TAG_TOWRITE;
203+
return PAGECACHE_TAG_DIRTY;
204+
}
205+
199206
#ifdef CONFIG_CGROUP_WRITEBACK
200207

201208
#include <linux/cgroup.h>

mm/page-writeback.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,12 +2434,6 @@ static bool folio_prepare_writeback(struct address_space *mapping,
24342434
return true;
24352435
}
24362436

2437-
static xa_mark_t wbc_to_tag(struct writeback_control *wbc)
2438-
{
2439-
if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
2440-
return PAGECACHE_TAG_TOWRITE;
2441-
return PAGECACHE_TAG_DIRTY;
2442-
}
24432437

24442438
static pgoff_t wbc_end(struct writeback_control *wbc)
24452439
{

0 commit comments

Comments
 (0)