Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1676774rdb; Thu, 25 Jan 2024 02:59:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmQXFWuce1Ttjxqh4d7+hDOc3QipV9cF2XDTcD+HcMQ5zCetb/YVW/oS5D3g3DLzjXmSeX X-Received: by 2002:a05:6214:2a8e:b0:686:af08:f9e0 with SMTP id jr14-20020a0562142a8e00b00686af08f9e0mr801968qvb.66.1706180373751; Thu, 25 Jan 2024 02:59:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706180373; cv=pass; d=google.com; s=arc-20160816; b=b3wgI/T14KdR3urqsqH0Bj5xJmTUHXZ0ruk9a3x5KK9d8YfFKWyCBW9y91wcJ/vUgN god+R2ZDaihY4mHIFEBhli2KTo4b5Hq8NnSvy9jNEQxvB9BknOoYZk71k862q6okMr3G JomQ4JTnCLDQxz0wBvw/wK3D37vo2RWk43nUtqAPFFG6KcaMq1L9L4G7CQSjC6xWbQpE Dw6Xl7u5npP7WgO2cGem4PVaodInOuIhkW0TnCTyvL/fROTd4MO9QZdUsVbdqaSOU2Cl 4i+2ID7iraI+WYlwc6rQh8TIqBJfzy21rB6M41VB71/KWP2gBqL0JDfwMFqTGAUG6Plk Dlbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=bYccEhl2/ey5tkamafClp9RqmKHrtkx9HuA6mOzhQ7c=; fh=AED2lrIQZhdppGHbaRrNz6/BI48B+mbutB2egpFPmJc=; b=jvQFSUZ/zhXJVAlnFJcqTnyYI1TLTqD3D9xDFCW8KRVvWCwfrGFiEGrx50Dn/SGpzy nDeEHm0S4dM6JZUgiZhX8qYMRP8shsr4yYnj7T5VEiZVd+IT87nVA7TsDjW3dzksMz8Y K0wOuubDw1B1gj5IkqBNeF0hiP9O7P+5SNfyKg8YN1NbohoWyCPAF+J0vQVzMa8onaHX U5+c7sC8YsuA5btjiL0irnGefjeI2lAsThzDSVyAWFZaGo4AX1QZbhv8I2NMUx3uOHhn xa1QGhsE0kPnH1veNLTCC5ExtFw41ipBPfG70xWmPcrlcI9BOttqVq6sUsC2g9O8b9ff utXQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Rdu3TUw6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d5-20020a0cdb05000000b0067f49d274besi12131748qvk.428.2024.01.25.02.59.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 02:59:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Rdu3TUw6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 822C61C22660 for ; Thu, 25 Jan 2024 10:59:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1103141744; Thu, 25 Jan 2024 10:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rdu3TUw6" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D014864AB0; Thu, 25 Jan 2024 10:45:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706179503; cv=none; b=ViFYDDeQhHdQsDSr0ceSVD+tmPQZsoKv5ZrgzOl7sXGuz2ZBIS6npc+RkT7+LbMZMlOoPKqxntdyXqTm8SL4kkLY86rlSQwETaUV8KP34VPbMPqYjVAZlBQ5pfbdE5RlEfyH6YtqM0T8h2gDYlCvZOFODO3VtF6U0XTQt10Y7xg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706179503; c=relaxed/simple; bh=v8PSdf1izCEgBD5ZJh8KPcAAwqgcrnxIZtLrcC5ncwo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UfacRuA8Dpm7tPY7YApMGBkXOSKZ9B4OYWolwHeQJoVpGUURv8LbF+3ME0XstVnL4hewbW+ApogVaIEy7Ko+k5cmr6HMncxrsxfLjS6SlWy56JrSCl4FsAGRLk89HfIgxioMRiZE7snvSFe7Lb6FHJPQ9ZtjcFn3n6u8LzYhQsk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rdu3TUw6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7CDFC43394; Thu, 25 Jan 2024 10:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706179502; bh=v8PSdf1izCEgBD5ZJh8KPcAAwqgcrnxIZtLrcC5ncwo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Rdu3TUw6huG9di9piQog0QmobrboYo6xDOn2KRn3C6nR/xFZxeUHtO1T+XYIrU+s/ jXzhdP4H04RpL5RCjvL7xJMrsbxv7ew/ek30gPpbbjV9Nb4v+xpjjombnUT8oIOIq8 iObTfIsPWK99AbLf040uZPjMAol3IKca7CVCVTqab0q0PiF7pakuQn88M6w7PM0Gom NSxZrrBEtvg/ZFgg3v8mTtwelEAPMZ64krlvJxo64+mMb6pD2IyOt5moOawb7NL01P hVpQZY6wW737ZweygcTTbIhbJc4bHLN9qLK/8YJtFnEO8az1Ns6jvfuxp9Xfv7ZyMW bX9106dl4uHCw== From: Jeff Layton Date: Thu, 25 Jan 2024 05:43:09 -0500 Subject: [PATCH v2 28/41] filelock: convert seqfile handling to use file_lock_core Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240125-flsplit-v2-28-7485322b62c7@kernel.org> References: <20240125-flsplit-v2-0-7485322b62c7@kernel.org> In-Reply-To: <20240125-flsplit-v2-0-7485322b62c7@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Ronnie Sahlberg Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6528; i=jlayton@kernel.org; h=from:subject:message-id; bh=v8PSdf1izCEgBD5ZJh8KPcAAwqgcrnxIZtLrcC5ncwo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlsjs9NABERfDWZKLfE5/QgXU8whcVzuCVD38fQ 1aXWqVkdWmJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbI7PQAKCRAADmhBGVaC FU5xD/0f8xTr4iVqZCdVGNFmdPV6lhNTcg6FDiP68QA32M0HwcHjAiHNmpdivK2XZYgHjsn5m8w c4WokQJNcExcscyZZuPOoHpeNeXqTDMK8mVLuhZmXhZiL5/nZXUmjmw+5SX2TzzsqrXpI8xgzab p/C+nw1QQMkP2Xe5bYiq7j0DH3uGXOls5yZ/HowDFNP8AsSXljo//8W6b+2pJz483M2jYwpq9gr qr483PD2jx5PxtV44snb5iI3Gxhymee/WLrx71wMTdYfGLxoHZRAXYMMi2Vw2NuY2njBRHqogD4 INTxWFatqw3cwb7HTVARSQ6cDTUS2pTLQx3oSsvahy7RlvDDgc9Ti8PKN3470U0S27KJ33SKWUC Qvph3RroeKmTcnSSfv4HRsVPsmVeLMwKwKgXE+jX+a7VJV3WxR+IHwxFYxOUwue2HmcvGK6mBcN xKobLIE0WF2ckTkqAQfZG8ZfA39bv0kpdSe5DChODmUS3kofbRn0eF36ovhS+GikEeaAoVb3nz0 J2EdKP2z91Q0wCkRctQTpWQEbL9xrKrYCp7a1vmXPJFlFmHomlf9ZhwXlZR+V0JZ3vdytXWV5F3 Hl1ZiuW9ZeuTYH4IIEd6IocRVc2DDtoIUFrXuGlT6R8gZrxVEYQ3f6YASlu+UOQD0M4vKhVan4Z ewSirartqcatUZA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Reduce some pointer manipulation by just using file_lock_core where we can and only translate to a file_lock when needed. Signed-off-by: Jeff Layton --- fs/locks.c | 71 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index e8afdd084245..de93d38da2f9 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2718,52 +2718,54 @@ struct locks_iterator { loff_t li_pos; }; -static void lock_get_status(struct seq_file *f, struct file_lock *fl, +static void lock_get_status(struct seq_file *f, struct file_lock_core *flc, loff_t id, char *pfx, int repeat) { struct inode *inode = NULL; unsigned int pid; struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)->i_sb); - int type = fl->fl_core.flc_type; + int type = flc->flc_type; + struct file_lock *fl = file_lock(flc); + + pid = locks_translate_pid(flc, proc_pidns); - pid = locks_translate_pid(&fl->fl_core, proc_pidns); /* * If lock owner is dead (and pid is freed) or not visible in current * pidns, zero is shown as a pid value. Check lock info from * init_pid_ns to get saved lock pid value. */ - if (fl->fl_core.flc_file != NULL) - inode = file_inode(fl->fl_core.flc_file); + if (flc->flc_file != NULL) + inode = file_inode(flc->flc_file); seq_printf(f, "%lld: ", id); if (repeat) seq_printf(f, "%*s", repeat - 1 + (int)strlen(pfx), pfx); - if (fl->fl_core.flc_flags & FL_POSIX) { - if (fl->fl_core.flc_flags & FL_ACCESS) + if (flc->flc_flags & FL_POSIX) { + if (flc->flc_flags & FL_ACCESS) seq_puts(f, "ACCESS"); - else if (fl->fl_core.flc_flags & FL_OFDLCK) + else if (flc->flc_flags & FL_OFDLCK) seq_puts(f, "OFDLCK"); else seq_puts(f, "POSIX "); seq_printf(f, " %s ", (inode == NULL) ? "*NOINODE*" : "ADVISORY "); - } else if (fl->fl_core.flc_flags & FL_FLOCK) { + } else if (flc->flc_flags & FL_FLOCK) { seq_puts(f, "FLOCK ADVISORY "); - } else if (fl->fl_core.flc_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) { + } else if (flc->flc_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) { type = target_leasetype(fl); - if (fl->fl_core.flc_flags & FL_DELEG) + if (flc->flc_flags & FL_DELEG) seq_puts(f, "DELEG "); else seq_puts(f, "LEASE "); if (lease_breaking(fl)) seq_puts(f, "BREAKING "); - else if (fl->fl_core.flc_file) + else if (flc->flc_file) seq_puts(f, "ACTIVE "); else seq_puts(f, "BREAKER "); @@ -2781,7 +2783,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, } else { seq_printf(f, "%d :0 ", pid); } - if (fl->fl_core.flc_flags & FL_POSIX) { + if (flc->flc_flags & FL_POSIX) { if (fl->fl_end == OFFSET_MAX) seq_printf(f, "%Ld EOF\n", fl->fl_start); else @@ -2791,18 +2793,18 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, } } -static struct file_lock *get_next_blocked_member(struct file_lock *node) +static struct file_lock_core *get_next_blocked_member(struct file_lock_core *node) { - struct file_lock *tmp; + struct file_lock_core *tmp; /* NULL node or root node */ - if (node == NULL || node->fl_core.flc_blocker == NULL) + if (node == NULL || node->flc_blocker == NULL) return NULL; /* Next member in the linked list could be itself */ - tmp = list_next_entry(node, fl_core.flc_blocked_member); - if (list_entry_is_head(tmp, &node->fl_core.flc_blocker->flc_blocked_requests, - fl_core.flc_blocked_member) + tmp = list_next_entry(node, flc_blocked_member); + if (list_entry_is_head(tmp, &node->flc_blocker->flc_blocked_requests, + flc_blocked_member) || tmp == node) { return NULL; } @@ -2813,18 +2815,18 @@ static struct file_lock *get_next_blocked_member(struct file_lock *node) static int locks_show(struct seq_file *f, void *v) { struct locks_iterator *iter = f->private; - struct file_lock *cur, *tmp; + struct file_lock_core *cur, *tmp; struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)->i_sb); int level = 0; - cur = hlist_entry(v, struct file_lock, fl_core.flc_link); + cur = hlist_entry(v, struct file_lock_core, flc_link); - if (locks_translate_pid(&cur->fl_core, proc_pidns) == 0) + if (locks_translate_pid(cur, proc_pidns) == 0) return 0; - /* View this crossed linked list as a binary tree, the first member of fl_blocked_requests + /* View this crossed linked list as a binary tree, the first member of flc_blocked_requests * is the left child of current node, the next silibing in flc_blocked_member is the - * right child, we can alse get the parent of current node from fl_blocker, so this + * right child, we can alse get the parent of current node from flc_blocker, so this * question becomes traversal of a binary tree */ while (cur != NULL) { @@ -2833,18 +2835,18 @@ static int locks_show(struct seq_file *f, void *v) else lock_get_status(f, cur, iter->li_pos, "", level); - if (!list_empty(&cur->fl_core.flc_blocked_requests)) { + if (!list_empty(&cur->flc_blocked_requests)) { /* Turn left */ - cur = list_first_entry_or_null(&cur->fl_core.flc_blocked_requests, - struct file_lock, - fl_core.flc_blocked_member); + cur = list_first_entry_or_null(&cur->flc_blocked_requests, + struct file_lock_core, + flc_blocked_member); level++; } else { /* Turn right */ tmp = get_next_blocked_member(cur); /* Fall back to parent node */ - while (tmp == NULL && cur->fl_core.flc_blocker != NULL) { - cur = file_lock(cur->fl_core.flc_blocker); + while (tmp == NULL && cur->flc_blocker != NULL) { + cur = cur->flc_blocker; level--; tmp = get_next_blocked_member(cur); } @@ -2859,14 +2861,13 @@ static void __show_fd_locks(struct seq_file *f, struct list_head *head, int *id, struct file *filp, struct files_struct *files) { - struct file_lock *fl; + struct file_lock_core *fl; - list_for_each_entry(fl, head, fl_core.flc_list) { + list_for_each_entry(fl, head, flc_list) { - if (filp != fl->fl_core.flc_file) + if (filp != fl->flc_file) continue; - if (fl->fl_core.flc_owner != files && - fl->fl_core.flc_owner != filp) + if (fl->flc_owner != files && fl->flc_owner != filp) continue; (*id)++; -- 2.43.0