Skip to content

Commit a9e61e2

Browse files
Felix BlyakherJ. Bruce Fields
authored andcommitted
lockd: call locks_release_private to cleanup per-filesystem state
For every lock request lockd creates a new file_lock object in nlmsvc_setgrantargs() by copying the passed in file_lock with locks_copy_lock(). A filesystem can attach it's own lock_operations vector to the file_lock. It has to be cleaned up at the end of the file_lock's life. However, lockd doesn't do it today, yet it asserts in nlmclnt_release_lockargs() that the per-filesystem state is clean. This patch fixes it by exporting locks_release_private() and adding it to nlmsvc_freegrantargs(), to be symmetrical to creating a file_lock in nlmsvc_setgrantargs(). Signed-off-by: Felix Blyakher <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 80492e7 commit a9e61e2

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

fs/lockd/svclock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ static void nlmsvc_freegrantargs(struct nlm_rqst *call)
326326
{
327327
if (call->a_args.lock.oh.data != call->a_owner)
328328
kfree(call->a_args.lock.oh.data);
329+
330+
locks_release_private(&call->a_args.lock.fl);
329331
}
330332

331333
/*

fs/locks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static struct file_lock *locks_alloc_lock(void)
151151
return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
152152
}
153153

154-
static void locks_release_private(struct file_lock *fl)
154+
void locks_release_private(struct file_lock *fl)
155155
{
156156
if (fl->fl_ops) {
157157
if (fl->fl_ops->fl_release_private)
@@ -165,6 +165,7 @@ static void locks_release_private(struct file_lock *fl)
165165
}
166166

167167
}
168+
EXPORT_SYMBOL_GPL(locks_release_private);
168169

169170
/* Free a lock which is not in use. */
170171
static void locks_free_lock(struct file_lock *fl)

include/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ extern void locks_copy_lock(struct file_lock *, struct file_lock *);
11081108
extern void __locks_copy_lock(struct file_lock *, const struct file_lock *);
11091109
extern void locks_remove_posix(struct file *, fl_owner_t);
11101110
extern void locks_remove_flock(struct file *);
1111+
extern void locks_release_private(struct file_lock *);
11111112
extern void posix_test_lock(struct file *, struct file_lock *);
11121113
extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
11131114
extern int posix_lock_file_wait(struct file *, struct file_lock *);

0 commit comments

Comments
 (0)