|
@@ -233,15 +233,40 @@ out:
|
|
return ctx;
|
|
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
|
|
void
|
|
locks_free_lock_context(struct inode *inode)
|
|
locks_free_lock_context(struct inode *inode)
|
|
{
|
|
{
|
|
struct file_lock_context *ctx = inode->i_flctx;
|
|
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);
|
|
kmem_cache_free(flctx_cache, ctx);
|
|
}
|
|
}
|
|
}
|
|
}
|