Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1674224rdb; Thu, 25 Jan 2024 02:52:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8ogsBPlbz4a37N5qTHp8C+J2kJXYmh+dVXo0Ngno605hqhF7XOPz9epafK2aC05VxZpXZ X-Received: by 2002:a2e:86cc:0:b0:2cd:fafe:13d7 with SMTP id n12-20020a2e86cc000000b002cdfafe13d7mr259128ljj.1.1706179946744; Thu, 25 Jan 2024 02:52:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706179946; cv=pass; d=google.com; s=arc-20160816; b=hFinBq7pQh1zLPcXH/R1Y7qcaNLNIhWkFUagHsKsno5fOMuxMKU/T6C+nyeTyoegdi gRhzfS/Ap+W8DhREN17KSfrnjZh800EkLOIzbGal++Xyrek+ib1ubmcXchOxIq7KElw7 kb8242QGkx5sDr4/XnZtVWrh42IeoHIG5WqJc/og851zFrSNsavyT75Gt04JjpWqDfAd DzZb9DCDLI0gSBHcQsdeG/BIMjw3tS/ltZE5Ih2/wPChkkaZt8RGEZLjiZ9MFPBws7ap 2oef9kDoF2eAul36ASwplLAwAKW3mCQqyUEkHYwwpV+Qle+W2oTKSZwMXREdLNP4I5pP qIdg== 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=gpJU/vQRIeNBstTDQioWpKIzfb52ghtvHSGks2nE7mw=; fh=AED2lrIQZhdppGHbaRrNz6/BI48B+mbutB2egpFPmJc=; b=yWsisRyCo5HrhcgG0BdTYvV7HRH7dAb2EWikne6Y7rzXtls+40D2PORqASrLECurBH Iwqh1SWSvXCfpmadzBC1BP3TiRaitGiHBDc7OuJfedUkzMfeo+tbzZpOeOQ7D3k2uVtN a+JFP87hd7bj013jCFzJ/rljhsxF3LnlbWW0ysOVl0fk4VL0fu1o6inJB12QgCe89R4t E2t0h/p/qJ8IGH/OQG0cOoRXsMzUJ81Wg23gg/ZYCZeji8wwgvdsTu+mNdRWFf0aTRAh wey84ki/16NxMzwH7v38xB4e5xtOKuwNIBd1wQnIM30UxZlD+tlgdwJq1A8cEHQzFWJ1 X6Sg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CSKpKtae; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x13-20020a056402414d00b00559e6a52fe0si8620143eda.426.2024.01.25.02.52.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 02:52:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CSKpKtae; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1347-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9F6D41F2918E for ; Thu, 25 Jan 2024 10:52:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 638355A7B9; Thu, 25 Jan 2024 10:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CSKpKtae" 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 284905BAF3; Thu, 25 Jan 2024 10:44:08 +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=1706179449; cv=none; b=B3QXU535pKeR+75ZjE1yCygihoqBOgeTARRIdgO9oHtYcw5TYwxDN5jZk01tLEFjmzYOJMIbaehL0jWWDzz/IJ0YTZC7b3CpOYOHvEDjRijUHLnGlQO0tTCiyzLu8rVcYBtd5oJ292O97DZU9juY3FM0kU43xKOJSxe882kTctk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706179449; c=relaxed/simple; bh=SE+jYS/yZlt9ls0SIupp0FcJqUlb1fCGOHRTNcE5DEc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G3uDKCdLGIDgyd/66FVK0fsZiTrSttSIQFqjDQFk46lWp8kqQuAiMWq1WiYz9tdU6RyWXIBT6D6ozAuVGx1S4UILfzgC7ET1WvhRSRRrfBCWvD2/oULjo+HkA9Shh0bFguFQviEYQZaNoV+lGiFUW3siLirKV9U+QqMo/MpZNik= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CSKpKtae; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21FBEC43142; Thu, 25 Jan 2024 10:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706179448; bh=SE+jYS/yZlt9ls0SIupp0FcJqUlb1fCGOHRTNcE5DEc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CSKpKtaeM1ZK2EklKrPZzbfB8uWFGiSfnTjub51zshkJZquDPvZyjVy9wKFxBkt54 XSDgjfv0PZWvdA0aDFCMcKJAwET/y8xugm/1yYS27cTS7SYsMFuLVWOUEQcp9mnHT0 /Sa/xdwtx/HiY7C8o/EQ0SrysHw4hwog0+IhhbffRLBe+9ztQy0at1+BscdX7pXyTH qsSU9NDW+HKgLEFrO2GGbsN5+J+QIgV1ekUkmPozlpZ5LCW4OpNfBiriidvIMk1iA/ VYs89tq9CXvGAgfSuS+FtyqRI+IGNMIkt/pmdFOwm8LM4vwGpPNLB5ClxBZ1Bb8v2y ptnVP6tmEzVcQ== From: Jeff Layton Date: Thu, 25 Jan 2024 05:42:55 -0500 Subject: [PATCH v2 14/41] filelock: convert more internal functions 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-14-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=4016; i=jlayton@kernel.org; h=from:subject:message-id; bh=SE+jYS/yZlt9ls0SIupp0FcJqUlb1fCGOHRTNcE5DEc=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlsjs7CyTqjRhTFya1dpSE1Jkuzb6RdPbxLgubP qsSiCmBW1SJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbI7OwAKCRAADmhBGVaC FQIcD/93Zc7iwmooco6metDCV3wsSZtdwrnxmrT6ntDE5l87jDi2cPJqsbVTZaAxYz5VS57fS4t QygJ8hjppkpKhVtQF5xuv/qpo8pkEBNkWQIvilv0VYifByBCgp6g14OscFBfLZ+QGrruzv/WdAO iA2zxtZO8McI4brX/KPEL0kV6mgQ+5jn8vx7Bhw/DFnrZEE2eWHRNZo/suDrIYmWso8UwIIP5iG dbdDzp051GFbsi+3IujspidJrWIN89NUc3hFxCqM96bM603S36glEuzARFD8Wp+Oj2I0RCOUrQ+ IE2BKMEAzVFuTofo4HgX/hwycZUcWK6VbBcUI+JPXyJDqllx11rmPl8cg9u/7gdACVtM+MrWbpX YuA9P96oQNej0ZedXeaUJLdHXYhaOwfofmimFGytflIPM4a+Q0XTM80Qgt8uYEUVrDDFYZW3yj7 SmACVlYE/qBAaXh/jnsAso9v3toZPiGEz0V7JmeHuispGByCt7+QPNH9P4ZrTn2E3eSyhpGUgT6 HD5OyZ71ytsMwza08qCQLQJETclWBtlz5jjWDbLiFG9oF+SMmbjzcgKlR27Z0tbxzteQVlSkqDX juoD/+oPWZt0WSU9gOZ65bowfq5HxC1SfwGlWV3uyIghXaKLhl2RKVpXafdcCtsmXhO8cDvKsna J4lHFYtATPQtuNQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 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 --- fs/locks.c | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 3a91515dbccd..a0d6fc0e043a 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -197,13 +197,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.flc_list) { - pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, - fl->fl_core.flc_owner, fl->fl_core.flc_flags, - fl->fl_core.flc_type, fl->fl_core.flc_pid); - } + 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, flc->flc_owner, flc->flc_flags, + flc->flc_type, flc->flc_pid); } static void @@ -224,20 +223,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.flc_list) - if (fl->fl_core.flc_file == filp) + list_for_each_entry(flc, list, flc_list) + if (flc->flc_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.flc_owner, fl->fl_core.flc_flags, - fl->fl_core.flc_type, fl->fl_core.flc_pid); + flc->flc_owner, flc->flc_flags, + flc->flc_type, flc->flc_pid); } void @@ -274,11 +272,13 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock); void locks_release_private(struct file_lock *fl) { - BUG_ON(waitqueue_active(&fl->fl_core.flc_wait)); - BUG_ON(!list_empty(&fl->fl_core.flc_list)); - BUG_ON(!list_empty(&fl->fl_core.flc_blocked_requests)); - BUG_ON(!list_empty(&fl->fl_core.flc_blocked_member)); - BUG_ON(!hlist_unhashed(&fl->fl_core.flc_link)); + struct file_lock_core *flc = &fl->fl_core; + + BUG_ON(waitqueue_active(&flc->flc_wait)); + BUG_ON(!list_empty(&flc->flc_list)); + 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->fl_release_private) @@ -288,8 +288,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.flc_owner); - fl->fl_core.flc_owner = NULL; + fl->fl_lmops->lm_put_owner(flc->flc_owner); + flc->flc_owner = NULL; } fl->fl_lmops = NULL; } @@ -305,16 +305,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.flc_list) { - if (fl->fl_core.flc_owner != owner) + list_for_each_entry(flc, &flctx->flc_posix, flc_list) { + if (flc->flc_owner != owner) continue; - if (!list_empty(&fl->fl_core.flc_blocked_requests)) { + if (!list_empty(&flc->flc_blocked_requests)) { spin_unlock(&flctx->flc_lock); return true; } -- 2.43.0