public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* two little writeback cleanups v2
@ 2024-11-12  5:43 Christoph Hellwig
  2024-11-12  5:43 ` [PATCH 1/2] writeback: add a __releases annoation to wbc_attach_and_unlock_inode Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-11-12  5:43 UTC (permalink / raw)
  To: Al Viro, Christian Brauner, Jan Kara; +Cc: linux-fsdevel

Hi all,

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.

Changes since v1:
 - mention the correct function in the patch 2 subject

Diffstat:
 fs/fs-writeback.c         |   32 ++++++++++++++++++++++++++++----
 include/linux/writeback.h |   28 ++--------------------------
 2 files changed, 30 insertions(+), 30 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] writeback: add a __releases annoation to wbc_attach_and_unlock_inode
  2024-11-12  5:43 two little writeback cleanups v2 Christoph Hellwig
@ 2024-11-12  5:43 ` Christoph Hellwig
  2024-11-12  5:43 ` [PATCH 2/2] writeback: wbc_attach_fdatawrite_inode out of line Christoph Hellwig
  2024-11-12 13:44 ` two little writeback cleanups v2 Christian Brauner
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-11-12  5:43 UTC (permalink / raw)
  To: Al Viro, Christian Brauner, Jan Kara; +Cc: linux-fsdevel

This shuts up a sparse lock context tracking warning.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/fs-writeback.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index d8bec3c1bb1f..3fb115ae44b1 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -733,6 +733,7 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb)
  */
 void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
 				 struct inode *inode)
+	__releases(&inode->i_lock)
 {
 	if (!inode_cgwb_enabled(inode)) {
 		spin_unlock(&inode->i_lock);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] writeback: wbc_attach_fdatawrite_inode out of line
  2024-11-12  5:43 two little writeback cleanups v2 Christoph Hellwig
  2024-11-12  5:43 ` [PATCH 1/2] writeback: add a __releases annoation to wbc_attach_and_unlock_inode Christoph Hellwig
@ 2024-11-12  5:43 ` Christoph Hellwig
  2024-11-12 13:44 ` two little writeback cleanups v2 Christian Brauner
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-11-12  5:43 UTC (permalink / raw)
  To: Al Viro, Christian Brauner, Jan Kara; +Cc: linux-fsdevel

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 <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/fs-writeback.c         | 31 +++++++++++++++++++++++++++----
 include/linux/writeback.h | 28 ++--------------------------
 2 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 3fb115ae44b1..77db1f10023e 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -290,7 +290,6 @@ void __inode_attach_wb(struct inode *inode, struct folio *folio)
 	if (unlikely(cmpxchg(&inode->i_wb, NULL, wb)))
 		wb_put(wb);
 }
-EXPORT_SYMBOL_GPL(__inode_attach_wb);
 
 /**
  * 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)
  * writeback completion, wbc_detach_inode() should be called.  This is used
  * to track the cgroup writeback context.
  */
-void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
-				 struct inode *inode)
+static void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
+		struct inode *inode)
 	__releases(&inode->i_lock)
 {
 	if (!inode_cgwb_enabled(inode)) {
@@ -763,7 +762,24 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
 	if (unlikely(wb_dying(wbc->wb) && !css_is_dying(wbc->wb->memcg_css)))
 		inode_switch_wbs(inode, wbc->wb_id);
 }
-EXPORT_SYMBOL_GPL(wbc_attach_and_unlock_inode);
+
+/**
+ * wbc_attach_fdatawrite_inode - associate wbc and inode for fdatawrite
+ * @wbc: writeback_control of interest
+ * @inode: target inode
+ *
+ * This function is to be used by __filemap_fdatawrite_range(), which is an
+ * alternative entry point into writeback code, and first ensures @inode is
+ * associated with a bdi_writeback and attaches it to @wbc.
+ */
+void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
+		struct inode *inode)
+{
+	spin_lock(&inode->i_lock);
+	inode_attach_wb(inode, NULL);
+	wbc_attach_and_unlock_inode(wbc, inode);
+}
+EXPORT_SYMBOL_GPL(wbc_attach_fdatawrite_inode);
 
 /**
  * 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,
 	}
 }
 
+static inline void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
+					       struct inode *inode)
+	__releases(&inode->i_lock)
+{
+	spin_unlock(&inode->i_lock);
+}
+
 #endif	/* CONFIG_CGROUP_WRITEBACK */
 
 /*
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index d6db822e4bb3..aee3e1b4c50f 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -213,9 +213,6 @@ static inline void wait_on_inode(struct inode *inode)
 #include <linux/bio.h>
 
 void __inode_attach_wb(struct inode *inode, struct folio *folio);
-void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
-				 struct inode *inode)
-	__releases(&inode->i_lock);
 void wbc_detach_inode(struct writeback_control *wbc);
 void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
 			      size_t bytes);
@@ -254,22 +251,8 @@ static inline void inode_detach_wb(struct inode *inode)
 	}
 }
 
-/**
- * wbc_attach_fdatawrite_inode - associate wbc and inode for fdatawrite
- * @wbc: writeback_control of interest
- * @inode: target inode
- *
- * This function is to be used by __filemap_fdatawrite_range(), which is an
- * alternative entry point into writeback code, and first ensures @inode is
- * associated with a bdi_writeback and attaches it to @wbc.
- */
-static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
-					       struct inode *inode)
-{
-	spin_lock(&inode->i_lock);
-	inode_attach_wb(inode, NULL);
-	wbc_attach_and_unlock_inode(wbc, inode);
-}
+void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
+		struct inode *inode);
 
 /**
  * wbc_init_bio - writeback specific initializtion of bio
@@ -303,13 +286,6 @@ static inline void inode_detach_wb(struct inode *inode)
 {
 }
 
-static inline void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
-					       struct inode *inode)
-	__releases(&inode->i_lock)
-{
-	spin_unlock(&inode->i_lock);
-}
-
 static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
 					       struct inode *inode)
 {
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: two little writeback cleanups v2
  2024-11-12  5:43 two little writeback cleanups v2 Christoph Hellwig
  2024-11-12  5:43 ` [PATCH 1/2] writeback: add a __releases annoation to wbc_attach_and_unlock_inode Christoph Hellwig
  2024-11-12  5:43 ` [PATCH 2/2] writeback: wbc_attach_fdatawrite_inode out of line Christoph Hellwig
@ 2024-11-12 13:44 ` Christian Brauner
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2024-11-12 13:44 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Christian Brauner, linux-fsdevel, Al Viro, Jan Kara

On Tue, 12 Nov 2024 06:43:53 +0100, Christoph Hellwig wrote:
> 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.
> 
> Changes since v1:
>  - mention the correct function in the patch 2 subject
> 
> [...]

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[1/2] writeback: add a __releases annoation to wbc_attach_and_unlock_inode
      https://git.kernel.org/vfs/vfs/c/4d7485cff599
[2/2] writeback: wbc_attach_fdatawrite_inode out of line
      https://git.kernel.org/vfs/vfs/c/8182a8b39aa2

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-12 13:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12  5:43 two little writeback cleanups v2 Christoph Hellwig
2024-11-12  5:43 ` [PATCH 1/2] writeback: add a __releases annoation to wbc_attach_and_unlock_inode Christoph Hellwig
2024-11-12  5:43 ` [PATCH 2/2] writeback: wbc_attach_fdatawrite_inode out of line Christoph Hellwig
2024-11-12 13:44 ` two little writeback cleanups v2 Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox