Skip to contentSkip to conversation

filelock: always define for_each_file_lock()

PATCH Applied Jeff Layton 2 participants 2 messages Feb 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 filelock: always define for_each_file_lock()

...and eliminate the stub version when CONFIG_FILE_LOCKING is disabled. This silences the following warning that crept in recently:

fs/ceph/locks.c: In function 'ceph_count_locks':
fs/ceph/locks.c:380:27: error: unused variable 'lock' [-Werror=unused-variable]
380 | struct file_lock *lock;

Fixes 75cabec0111b ("filelock: add some new helper functions")
---
 include/linux/filelock.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
include/linux/filelock.h +3 -5
index aabd4bdf7eba..daee999d05f3 100644
@@ -180,9 +180,6 @@ static inline void locks_wake_up(struct file_lock *fl)
 	wake_up(&fl->c.flc_wait);
 }
 
-/* for walking lists of file_locks linked by fl_list */
-#define for_each_file_lock(_fl, _head)	list_for_each_entry(_fl, _head, c.flc_list)
-
 /* fs/locks.c */
 void locks_free_lock_context(struct inode *inode);
 void locks_free_lock(struct file_lock *fl);
@@ -283,8 +280,6 @@ static inline void locks_wake_up(struct file_lock *fl)
 {
 }
 
-#define for_each_file_lock(_fl, _head)	while(false)
-
 static inline void
 locks_free_lock_context(struct inode *inode)
 {
@@ -414,6 +409,9 @@ locks_inode_context(const struct inode *inode)
 
 #endif /* !CONFIG_FILE_LOCKING */
 
+/* for walking lists of file_locks linked by fl_list */
+#define for_each_file_lock(_fl, _head)	list_for_each_entry(_fl, _head, c.flc_list)
+
 static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
 {
 	return locks_lock_inode_wait(file_inode(filp), fl);

---
base-commit: 292fcaa1f937345cb65f3af82a1ee6692c8df9eb
change-id: 20240212-flsplit3-174effe3675a

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
#1 lore raw
Quoted 8 lines · Jeff Layton

...and eliminate the stub version when CONFIG_FILE_LOCKING is disabled. This silences the following warning that crept in recently:

fs/ceph/locks.c: In function 'ceph_count_locks':
fs/ceph/locks.c:380:27: error: unused variable 'lock' [-Werror=unused-variable]
380 | struct file_lock *lock;

[...]

Thanks Jeff and thanks Arnd!

---

Applied to the vfs.file branch of the vfs/vfs.git tree. Patches in the vfs.file 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.file

[1/1] filelock: always define for_each_file_lock()

      https://git.kernel.org/vfs/vfs/c/582a3bf999df