Skip to content

Commit 39bb1bf

Browse files
committed
Merge patch series "two little writeback cleanups v2"
Christoph Hellwig <[email protected]> says: This fixes one (of multiple) sparse warnings in fs-writeback.c, and then reshuffles the code a bit that only the proper high level API instead of low-level helpers is exported. * patches from https://lore.kernel.org/r/[email protected]: writeback: wbc_attach_fdatawrite_inode out of line writeback: add a __releases annoation to wbc_attach_and_unlock_inode Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents 3a6ffeb + 8182a8b commit 39bb1bf

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

fs/fs-writeback.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ void __inode_attach_wb(struct inode *inode, struct folio *folio)
290290
if (unlikely(cmpxchg(&inode->i_wb, NULL, wb)))
291291
wb_put(wb);
292292
}
293-
EXPORT_SYMBOL_GPL(__inode_attach_wb);
294293

295294
/**
296295
* inode_cgwb_move_to_attached - put the inode onto wb->b_attached list
@@ -731,8 +730,9 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb)
731730
* writeback completion, wbc_detach_inode() should be called. This is used
732731
* to track the cgroup writeback context.
733732
*/
734-
void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
735-
struct inode *inode)
733+
static void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
734+
struct inode *inode)
735+
__releases(&inode->i_lock)
736736
{
737737
if (!inode_cgwb_enabled(inode)) {
738738
spin_unlock(&inode->i_lock);
@@ -762,7 +762,24 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
762762
if (unlikely(wb_dying(wbc->wb) && !css_is_dying(wbc->wb->memcg_css)))
763763
inode_switch_wbs(inode, wbc->wb_id);
764764
}
765-
EXPORT_SYMBOL_GPL(wbc_attach_and_unlock_inode);
765+
766+
/**
767+
* wbc_attach_fdatawrite_inode - associate wbc and inode for fdatawrite
768+
* @wbc: writeback_control of interest
769+
* @inode: target inode
770+
*
771+
* This function is to be used by __filemap_fdatawrite_range(), which is an
772+
* alternative entry point into writeback code, and first ensures @inode is
773+
* associated with a bdi_writeback and attaches it to @wbc.
774+
*/
775+
void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
776+
struct inode *inode)
777+
{
778+
spin_lock(&inode->i_lock);
779+
inode_attach_wb(inode, NULL);
780+
wbc_attach_and_unlock_inode(wbc, inode);
781+
}
782+
EXPORT_SYMBOL_GPL(wbc_attach_fdatawrite_inode);
766783

767784
/**
768785
* wbc_detach_inode - disassociate wbc from inode and perform foreign detection
@@ -1225,6 +1242,13 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi,
12251242
}
12261243
}
12271244

1245+
static inline void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
1246+
struct inode *inode)
1247+
__releases(&inode->i_lock)
1248+
{
1249+
spin_unlock(&inode->i_lock);
1250+
}
1251+
12281252
#endif /* CONFIG_CGROUP_WRITEBACK */
12291253

12301254
/*

include/linux/writeback.h

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ static inline void wait_on_inode(struct inode *inode)
213213
#include <linux/bio.h>
214214

215215
void __inode_attach_wb(struct inode *inode, struct folio *folio);
216-
void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
217-
struct inode *inode)
218-
__releases(&inode->i_lock);
219216
void wbc_detach_inode(struct writeback_control *wbc);
220217
void wbc_account_cgroup_owner(struct writeback_control *wbc, struct folio *folio,
221218
size_t bytes);
@@ -254,22 +251,8 @@ static inline void inode_detach_wb(struct inode *inode)
254251
}
255252
}
256253

257-
/**
258-
* wbc_attach_fdatawrite_inode - associate wbc and inode for fdatawrite
259-
* @wbc: writeback_control of interest
260-
* @inode: target inode
261-
*
262-
* This function is to be used by __filemap_fdatawrite_range(), which is an
263-
* alternative entry point into writeback code, and first ensures @inode is
264-
* associated with a bdi_writeback and attaches it to @wbc.
265-
*/
266-
static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
267-
struct inode *inode)
268-
{
269-
spin_lock(&inode->i_lock);
270-
inode_attach_wb(inode, NULL);
271-
wbc_attach_and_unlock_inode(wbc, inode);
272-
}
254+
void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
255+
struct inode *inode);
273256

274257
/**
275258
* wbc_init_bio - writeback specific initializtion of bio
@@ -303,13 +286,6 @@ static inline void inode_detach_wb(struct inode *inode)
303286
{
304287
}
305288

306-
static inline void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
307-
struct inode *inode)
308-
__releases(&inode->i_lock)
309-
{
310-
spin_unlock(&inode->i_lock);
311-
}
312-
313289
static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
314290
struct inode *inode)
315291
{

0 commit comments

Comments
 (0)