Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1304563
| From | Jeff Layton <jlayton@poochiereds.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 5/6] locks: prink more detail when there are leaked locks |
| Date | 2016-01-08 15:00 +0100 |
| Message-ID | <qOFKb-7uJ-23@gated-at.bofh.it> (permalink) |
| References | <qOuYq-8uq-15@gated-at.bofh.it> <qOFKa-7uJ-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Right now, we just get WARN_ON_ONCE, which is not particularly helpful.
Have it dump some info about the locks and the inode to make it easier
to track down leaked locks in the future.
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
---
fs/locks.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/fs/locks.c b/fs/locks.c
index ed9ab930d093..ca272eb63c30 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -233,15 +233,40 @@ out:
return ctx;
}
+static void
+locks_dump_ctx_list(struct list_head *list, char *list_type)
+{
+ struct file_lock *fl;
+
+ list_for_each_entry(fl, list, fl_list) {
+ pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, fl->fl_owner, fl->fl_flags, fl->fl_type, fl->fl_pid);
+ }
+}
+
+static void
+locks_check_ctx_lists(struct inode *inode)
+{
+ struct file_lock_context *ctx = inode->i_flctx;
+
+ if (unlikely(!list_empty(&ctx->flc_flock) ||
+ !list_empty(&ctx->flc_posix) ||
+ !list_empty(&ctx->flc_lease))) {
+ pr_warn("Leaked locks on dev=0x%x:0x%x ino=0x%lx:\n",
+ MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev),
+ inode->i_ino);
+ locks_dump_ctx_list(&ctx->flc_flock, "FLOCK");
+ locks_dump_ctx_list(&ctx->flc_posix, "POSIX");
+ locks_dump_ctx_list(&ctx->flc_lease, "LEASE");
+ }
+}
+
void
locks_free_lock_context(struct inode *inode)
{
struct file_lock_context *ctx = inode->i_flctx;
- if (ctx) {
- WARN_ON_ONCE(!list_empty(&ctx->flc_flock));
- WARN_ON_ONCE(!list_empty(&ctx->flc_posix));
- WARN_ON_ONCE(!list_empty(&ctx->flc_lease));
+ if (unlikely(ctx)) {
+ locks_check_ctx_lists(inode);
kmem_cache_free(flctx_cache, ctx);
}
}
--
2.5.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] locks: fix unlock when fcntl_setlk races with a close Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 03:30 +0100
Re: [PATCH] locks: fix unlock when fcntl_setlk races with a close Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 13:50 +0100
Re: [PATCH] locks: fix unlock when fcntl_setlk races with a close "J. Bruce Fields" <bfields@fieldses.org> - 2016-01-08 17:20 +0100
[PATCH v2 1/6] locks: fix unlock when fcntl_setlk races with a close Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 15:00 +0100
Re: [PATCH v2 1/6] locks: fix unlock when fcntl_setlk races with a close "J. Bruce Fields" <bfields@fieldses.org> - 2016-01-08 17:00 +0100
Re: [PATCH v2 1/6] locks: fix unlock when fcntl_setlk races with a close Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 17:20 +0100
Re: [PATCH v2 1/6] locks: fix unlock when fcntl_setlk races with a close "J. Bruce Fields" <bfields@fieldses.org> - 2016-01-08 17:30 +0100
Re: [PATCH v2 1/6] locks: fix unlock when fcntl_setlk races with a close "J. Bruce Fields" <bfields@fieldses.org> - 2016-01-08 17:30 +0100
Re: [PATCH v2 1/6] locks: fix unlock when fcntl_setlk races with a close "J. Bruce Fields" <bfields@fieldses.org> - 2016-01-08 17:30 +0100
[PATCH v2 4/6] locks: pass inode pointer to locks_free_lock_context Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 15:00 +0100
[PATCH v2 0/6] locks: better debugging and fix for setlk/close race handling Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 15:00 +0100
[PATCH v2 6/6] locks: rename __posix_lock_file to posix_lock_inode Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 15:00 +0100
[PATCH v2 5/6] locks: prink more detail when there are leaked locks Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 15:00 +0100
[PATCH v2 3/6] locks: sprinkle some tracepoints around the file locking code Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 15:00 +0100
[PATCH v2 2/6] locks: don't check for race with close when setting OFD lock Jeff Layton <jlayton@poochiereds.net> - 2016-01-08 15:10 +0100
csiph-web