Commit fde49518 authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner

filelock: convert more internal functions to use file_lock_core

Convert more internal fs/locks.c functions to take and deal with struct
file_lock_core instead of struct file_lock:

- locks_dump_ctx_list
- locks_check_ctx_file_list
- locks_release_private
- locks_owner_has_blockers
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-19-c6129007ee8d@kernel.orgReviewed-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 4ca52f53
...@@ -197,13 +197,12 @@ locks_get_lock_context(struct inode *inode, int type) ...@@ -197,13 +197,12 @@ locks_get_lock_context(struct inode *inode, int type)
static void static void
locks_dump_ctx_list(struct list_head *list, char *list_type) locks_dump_ctx_list(struct list_head *list, char *list_type)
{ {
struct file_lock *fl; struct file_lock_core *flc;
list_for_each_entry(fl, list, c.flc_list) { list_for_each_entry(flc, list, flc_list)
pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
fl->c.flc_owner, fl->c.flc_flags, list_type, flc->flc_owner, flc->flc_flags,
fl->c.flc_type, fl->c.flc_pid); flc->flc_type, flc->flc_pid);
}
} }
static void static void
...@@ -224,20 +223,19 @@ locks_check_ctx_lists(struct inode *inode) ...@@ -224,20 +223,19 @@ locks_check_ctx_lists(struct inode *inode)
} }
static void static void
locks_check_ctx_file_list(struct file *filp, struct list_head *list, locks_check_ctx_file_list(struct file *filp, struct list_head *list, char *list_type)
char *list_type)
{ {
struct file_lock *fl; struct file_lock_core *flc;
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
list_for_each_entry(fl, list, c.flc_list) list_for_each_entry(flc, list, flc_list)
if (fl->c.flc_file == filp) if (flc->flc_file == filp)
pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx " pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx "
" fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", " fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
list_type, MAJOR(inode->i_sb->s_dev), list_type, MAJOR(inode->i_sb->s_dev),
MINOR(inode->i_sb->s_dev), inode->i_ino, MINOR(inode->i_sb->s_dev), inode->i_ino,
fl->c.flc_owner, fl->c.flc_flags, flc->flc_owner, flc->flc_flags,
fl->c.flc_type, fl->c.flc_pid); flc->flc_type, flc->flc_pid);
} }
void void
...@@ -274,11 +272,13 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock); ...@@ -274,11 +272,13 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock);
void locks_release_private(struct file_lock *fl) void locks_release_private(struct file_lock *fl)
{ {
BUG_ON(waitqueue_active(&fl->c.flc_wait)); struct file_lock_core *flc = &fl->c;
BUG_ON(!list_empty(&fl->c.flc_list));
BUG_ON(!list_empty(&fl->c.flc_blocked_requests)); BUG_ON(waitqueue_active(&flc->flc_wait));
BUG_ON(!list_empty(&fl->c.flc_blocked_member)); BUG_ON(!list_empty(&flc->flc_list));
BUG_ON(!hlist_unhashed(&fl->c.flc_link)); BUG_ON(!list_empty(&flc->flc_blocked_requests));
BUG_ON(!list_empty(&flc->flc_blocked_member));
BUG_ON(!hlist_unhashed(&flc->flc_link));
if (fl->fl_ops) { if (fl->fl_ops) {
if (fl->fl_ops->fl_release_private) if (fl->fl_ops->fl_release_private)
...@@ -288,8 +288,8 @@ void locks_release_private(struct file_lock *fl) ...@@ -288,8 +288,8 @@ void locks_release_private(struct file_lock *fl)
if (fl->fl_lmops) { if (fl->fl_lmops) {
if (fl->fl_lmops->lm_put_owner) { if (fl->fl_lmops->lm_put_owner) {
fl->fl_lmops->lm_put_owner(fl->c.flc_owner); fl->fl_lmops->lm_put_owner(flc->flc_owner);
fl->c.flc_owner = NULL; flc->flc_owner = NULL;
} }
fl->fl_lmops = NULL; fl->fl_lmops = NULL;
} }
...@@ -305,16 +305,15 @@ EXPORT_SYMBOL_GPL(locks_release_private); ...@@ -305,16 +305,15 @@ EXPORT_SYMBOL_GPL(locks_release_private);
* %true: @owner has at least one blocker * %true: @owner has at least one blocker
* %false: @owner has no blockers * %false: @owner has no blockers
*/ */
bool locks_owner_has_blockers(struct file_lock_context *flctx, bool locks_owner_has_blockers(struct file_lock_context *flctx, fl_owner_t owner)
fl_owner_t owner)
{ {
struct file_lock *fl; struct file_lock_core *flc;
spin_lock(&flctx->flc_lock); spin_lock(&flctx->flc_lock);
list_for_each_entry(fl, &flctx->flc_posix, c.flc_list) { list_for_each_entry(flc, &flctx->flc_posix, flc_list) {
if (fl->c.flc_owner != owner) if (flc->flc_owner != owner)
continue; continue;
if (!list_empty(&fl->c.flc_blocked_requests)) { if (!list_empty(&flc->flc_blocked_requests)) {
spin_unlock(&flctx->flc_lock); spin_unlock(&flctx->flc_lock);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment