diff mbox series

[2/2] lockd: fix failure to cleanup client locks

Message ID 20220118220051.GC16108@fieldses.org (mailing list archive)
State New, archived
Headers show
Series [1/2] lockd: fix server crash on reboot of client holding lock | expand

Commit Message

J. Bruce Fields Jan. 18, 2022, 10 p.m. UTC
From: "J. Bruce Fields" <bfields@redhat.com>

In my testing, we're sometimes hitting the request->fl_flags & FL_EXISTS
case in posix_lock_inode, presumably just by random luck since we're not
actually initializing fl_flags here.

This probably didn't matter before 7f024fcd5c97 "Keep read and write fds
with each nlm_file" since we wouldn't previously unlock unless we knew
there were locks.

But now it causes lockd to give up on removing more locks.

We could just initialize fl_flags, but really it seems dubious to be
calling vfs_lock_file with random values in some of the fields.

Fixes: 7f024fcd5c97 ("Keep read and write fds with each nlm_file")
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/lockd/svcsubs.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 54c2e42130ca..0a22a2faf552 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -180,6 +180,7 @@  static int nlm_unlock_files(struct nlm_file *file)
 {
 	struct file_lock lock;
 
+	locks_init_lock(&lock);
 	lock.fl_type  = F_UNLCK;
 	lock.fl_start = 0;
 	lock.fl_end   = OFFSET_MAX;