[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240116-flsplit-v1-6-c9d0f4370a5d@kernel.org>
Date: Tue, 16 Jan 2024 14:46:02 -0500
From: Jeff Layton <jlayton@...nel.org>
To: Christian Brauner <brauner@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Eric Van Hensbergen <ericvh@...nel.org>,
Latchesar Ionkov <lucho@...kov.net>,
Dominique Martinet <asmadeus@...ewreck.org>,
Christian Schoenebeck <linux_oss@...debyte.com>,
David Howells <dhowells@...hat.com>, Marc Dionne <marc.dionne@...istor.com>,
Xiubo Li <xiubli@...hat.com>, Ilya Dryomov <idryomov@...il.com>,
Alexander Aring <aahringo@...hat.com>, David Teigland <teigland@...hat.com>,
Miklos Szeredi <miklos@...redi.hu>,
Andreas Gruenbacher <agruenba@...hat.com>,
Trond Myklebust <trond.myklebust@...merspace.com>,
Anna Schumaker <anna@...nel.org>, Chuck Lever <chuck.lever@...cle.com>,
Neil Brown <neilb@...e.de>, Olga Kornievskaia <kolga@...app.com>,
Dai Ngo <Dai.Ngo@...cle.com>, Tom Talpey <tom@...pey.com>,
Jan Kara <jack@...e.cz>, Mark Fasheh <mark@...heh.com>,
Joel Becker <jlbec@...lplan.org>, Joseph Qi <joseph.qi@...ux.alibaba.com>,
Steve French <sfrench@...ba.org>, Paulo Alcantara <pc@...guebit.com>,
Ronnie Sahlberg <lsahlber@...hat.com>,
Shyam Prasad N <sprasad@...rosoft.com>, Namjae Jeon <linkinjeon@...nel.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: linux-kernel@...r.kernel.org, v9fs@...ts.linux.dev,
linux-afs@...ts.infradead.org, ceph-devel@...r.kernel.org,
gfs2@...ts.linux.dev, linux-fsdevel@...r.kernel.org,
linux-nfs@...r.kernel.org, ocfs2-devel@...ts.linux.dev,
linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org,
linux-trace-kernel@...r.kernel.org, Jeff Layton <jlayton@...nel.org>
Subject: [PATCH 06/20] 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: Jeff Layton <jlayton@...nel.org>
---
fs/locks.c | 51 +++++++++++++++++++++++++--------------------------
1 file changed, 25 insertions(+), 26 deletions(-)
diff --git a/fs/locks.c b/fs/locks.c
index 42221cecd331..e09920cc9da2 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -204,13 +204,12 @@ locks_get_lock_context(struct inode *inode, int type)
static void
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, fl_core.fl_list) {
- pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type,
- fl->fl_core.fl_owner, fl->fl_core.fl_flags,
- fl->fl_core.fl_type, fl->fl_core.fl_pid);
- }
+ list_for_each_entry(flc, list, fl_list)
+ pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
+ list_type, flc->fl_owner, flc->fl_flags,
+ flc->fl_type, flc->fl_pid);
}
static void
@@ -231,20 +230,19 @@ locks_check_ctx_lists(struct inode *inode)
}
static void
-locks_check_ctx_file_list(struct file *filp, struct list_head *list,
- char *list_type)
+locks_check_ctx_file_list(struct file *filp, struct list_head *list, char *list_type)
{
- struct file_lock *fl;
+ struct file_lock_core *flc;
struct inode *inode = file_inode(filp);
- list_for_each_entry(fl, list, fl_core.fl_list)
- if (fl->fl_core.fl_file == filp)
+ list_for_each_entry(flc, list, fl_list)
+ if (flc->fl_file == filp)
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",
list_type, MAJOR(inode->i_sb->s_dev),
MINOR(inode->i_sb->s_dev), inode->i_ino,
- fl->fl_core.fl_owner, fl->fl_core.fl_flags,
- fl->fl_core.fl_type, fl->fl_core.fl_pid);
+ flc->fl_owner, flc->fl_flags,
+ flc->fl_type, flc->fl_pid);
}
void
@@ -281,11 +279,13 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock);
void locks_release_private(struct file_lock *fl)
{
- BUG_ON(waitqueue_active(&fl->fl_core.fl_wait));
- BUG_ON(!list_empty(&fl->fl_core.fl_list));
- BUG_ON(!list_empty(&fl->fl_core.fl_blocked_requests));
- BUG_ON(!list_empty(&fl->fl_core.fl_blocked_member));
- BUG_ON(!hlist_unhashed(&fl->fl_core.fl_link));
+ struct file_lock_core *flc = &fl->fl_core;
+
+ BUG_ON(waitqueue_active(&flc->fl_wait));
+ BUG_ON(!list_empty(&flc->fl_list));
+ BUG_ON(!list_empty(&flc->fl_blocked_requests));
+ BUG_ON(!list_empty(&flc->fl_blocked_member));
+ BUG_ON(!hlist_unhashed(&flc->fl_link));
if (fl->fl_ops) {
if (fl->fl_ops->fl_release_private)
@@ -295,8 +295,8 @@ void locks_release_private(struct file_lock *fl)
if (fl->fl_lmops) {
if (fl->fl_lmops->lm_put_owner) {
- fl->fl_lmops->lm_put_owner(fl->fl_core.fl_owner);
- fl->fl_core.fl_owner = NULL;
+ fl->fl_lmops->lm_put_owner(flc->fl_owner);
+ flc->fl_owner = NULL;
}
fl->fl_lmops = NULL;
}
@@ -312,16 +312,15 @@ EXPORT_SYMBOL_GPL(locks_release_private);
* %true: @owner has at least one blocker
* %false: @owner has no blockers
*/
-bool locks_owner_has_blockers(struct file_lock_context *flctx,
- fl_owner_t owner)
+bool locks_owner_has_blockers(struct file_lock_context *flctx, fl_owner_t owner)
{
- struct file_lock *fl;
+ struct file_lock_core *flc;
spin_lock(&flctx->flc_lock);
- list_for_each_entry(fl, &flctx->flc_posix, fl_core.fl_list) {
- if (fl->fl_core.fl_owner != owner)
+ list_for_each_entry(flc, &flctx->flc_posix, fl_list) {
+ if (flc->fl_owner != owner)
continue;
- if (!list_empty(&fl->fl_core.fl_blocked_requests)) {
+ if (!list_empty(&flc->fl_blocked_requests)) {
spin_unlock(&flctx->flc_lock);
return true;
}
--
2.43.0
Powered by blists - more mailing lists