mm: Fix sparse warnings in backing-dev.h

Message ID 20230623170737.3965705-1-willy@infradead.org
State New
Headers
Series mm: Fix sparse warnings in backing-dev.h |

Commit Message

Matthew Wilcox June 23, 2023, 5:07 p.m. UTC
  Sparse reports a context imbalance, and indeed _begin() returns
with the RCU lock held and _end() releases it.  Reassure sparse that
this is fine by adding appropriate annotations.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/backing-dev.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Matthew Wilcox June 23, 2023, 5:36 p.m. UTC | #1
On Fri, Jun 23, 2023 at 06:07:37PM +0100, Matthew Wilcox (Oracle) wrote:
> Sparse reports a context imbalance, and indeed _begin() returns
> with the RCU lock held and _end() releases it.  Reassure sparse that
> this is fine by adding appropriate annotations.

Please ignore; I failed to drive my tools correctly.
  

Patch

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index fbad4fcd408e..69bb13412a3e 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -284,8 +284,9 @@  static inline struct bdi_writeback *inode_to_wb_wbc(
  * can't sleep during the transaction.  IRQs may or may not be disabled on
  * return.
  */
-static inline struct bdi_writeback *
-unlocked_inode_to_wb_begin(struct inode *inode, struct wb_lock_cookie *cookie)
+static inline
+struct bdi_writeback *unlocked_inode_to_wb_begin(struct inode *inode,
+		struct wb_lock_cookie *cookie) __acquires(RCU)
 {
 	rcu_read_lock();
 
@@ -311,7 +312,7 @@  unlocked_inode_to_wb_begin(struct inode *inode, struct wb_lock_cookie *cookie)
  * @cookie: @cookie from unlocked_inode_to_wb_begin()
  */
 static inline void unlocked_inode_to_wb_end(struct inode *inode,
-					    struct wb_lock_cookie *cookie)
+		struct wb_lock_cookie *cookie) __releases(RCU)
 {
 	if (unlikely(cookie->locked))
 		xa_unlock_irqrestore(&inode->i_mapping->i_pages, cookie->flags);