Skip to content

Commit 8182a8b

Browse files
Christoph Hellwigbrauner
authored andcommitted
writeback: wbc_attach_fdatawrite_inode out of line
This allows exporting this high-level interface only while keeping wbc_attach_and_unlock_inode private in fs-writeback.c and unexporting __inode_attach_wb. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 4d7485c commit 8182a8b

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

fs/fs-writeback.c

Lines changed: 27 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,8 @@ 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)
736735
__releases(&inode->i_lock)
737736
{
738737
if (!inode_cgwb_enabled(inode)) {
@@ -763,7 +762,24 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
763762
if (unlikely(wb_dying(wbc->wb) && !css_is_dying(wbc->wb->memcg_css)))
764763
inode_switch_wbs(inode, wbc->wb_id);
765764
}
766-
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);
767783

768784
/**
769785
* wbc_detach_inode - disassociate wbc from inode and perform foreign detection
@@ -1228,6 +1244,13 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi,
12281244
}
12291245
}
12301246

1247+
static inline void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
1248+
struct inode *inode)
1249+
__releases(&inode->i_lock)
1250+
{
1251+
spin_unlock(&inode->i_lock);
1252+
}
1253+
12311254
#endif /* CONFIG_CGROUP_WRITEBACK */
12321255

12331256
/*

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 page *page,
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)