Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1968433rdb; Wed, 31 Jan 2024 15:13:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkKsTKd8MV04uR8kem8ZlQ2/VS3lrgOTSd1jYOJREGS+5pyEChkAth/dNnNN6fdjvziSms X-Received: by 2002:a05:6402:310a:b0:55c:93c1:4a50 with SMTP id dc10-20020a056402310a00b0055c93c14a50mr2701562edb.13.1706742796755; Wed, 31 Jan 2024 15:13:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742796; cv=pass; d=google.com; s=arc-20160816; b=u/zFAG1T3xKa6eilEgO2MoZIxvcmDVzsvLNRm5XzO1XhDVDGMmS/FH4rQJghlsrJuf hpOhZio/r4IwelTBtGuxVxmZeQzcsIh2vHUoK4AkBimcmfB//bqX4bAoJ0oyKN2Ph7+A sPItnRrTc7oAAKfUvaRvc6FRxQYlzJwABo1YIIqGh49wnr9E2OKr4jO5upyoZwehjBy0 GlMywF0GzkNnNmkULx2+y8fx9adfnnbfknw5uNtMYH4D8oBnb5zOK1dNL6Kpu/NPYGrG 9z7qWzC/agrASNlLdOR6InoM5twA51/mv8q+kkV4WRLFFhmPlK7PhVYwqltjpdrwjcbl oBkQ== 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=JKUWTSVGbMk/bimJqzBgF/lMLJ78PSQhPA5cK3IwVgg=; fh=OVLxrAkS5HLupkxvJATQ7iaTg+2rl0+xaaqjJT7MS3E=; b=Ua+rhER1kKDza9WVzqbbIJD8om+ozYnu43vFxgVsIR0MjM0W7dU/dlPDaikujGgqIC y2PiRIn6DKnz4LFkNH/7ioGMlSp6JYpCxb1Y5YjE23MdTTj2DjYgrMBakknGZD0dkMjl q+lS74tl/iQGM34z6UNTLQ/wccL9lOWXMk+bZsMUdIDfLdc85MbDom2V5fcXoOgNY0z+ BXpoYgLoBNLcfNwdxt3axDQEemd/dkrRCYhaQho1rcnNALat9AJardDGERxvwRPDllxH ubIV09CIL1HGwWBggTEi6YPitpVuaTBLCWWP+FtVK4J6UIzkNntW2AHPE3LpVzBDoBUZ H/Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bM/ekbRV"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWI1butmkc0dEgUnZStOyeIw4XTru2F+Wxx3C3kA+6VIncfmgjcAAlHL3qLxy0d/V4t1Gub8IYPUKh4kdPJAOK23Q4qssiPI/LJTy3k5Q== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t23-20020a508d57000000b0055f12cf8244si3138705edt.151.2024.01.31.15.13.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:13:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bM/ekbRV"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47310-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 53DF21F2C9A6 for ; Wed, 31 Jan 2024 23:13:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62CA213E238; Wed, 31 Jan 2024 23:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bM/ekbRV" 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 3402D13E211; Wed, 31 Jan 2024 23:03:51 +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=1706742232; cv=none; b=M/2b6qFJRe1tTKvYUH72v5iHBtej4OU0ncV+wQkbVu3kijO0McGDWKjDOQJE1ZuJKUpW9gZb4XGOaGjKkmuEPeU2iOVjbuX6+QGC2lGTwW5WjzFpDDsTdVF+Pyw51goRL2gZq+/j/Ns6Pe87f0R3DyaMN2MinYNrY9QrOylXQ0o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742232; c=relaxed/simple; bh=+fh0Pyz60IyaAdOx+0EoERtKYPFhqrIpllRCidYLo4Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z6imatu71v+il6C8JJZeDQPgw6kwcAh3rThZcKpgANo71IybuCi9IbvD9/qTSDfb8pZe8/4+kRB9XlMDDL70nStboNO/1TiaIpyzJgKOJTNCkJ/w28c5Zu1SwIkUDRLNTc+z84C1V9C36u6Q64LitJ1AK01vEpVRccSASZX42ac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bM/ekbRV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED23DC43390; Wed, 31 Jan 2024 23:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742231; bh=+fh0Pyz60IyaAdOx+0EoERtKYPFhqrIpllRCidYLo4Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bM/ekbRViAsY+5DUTUT/5NUOUze2DbyGhWio8gErtKqeAff1puRV3oVoFidhFxcrC 74+Y/EbuBOUKRsoOP6iH6jpYg4ZkxJd5FgCYz5i1YfheC8gB6jotkv28djCoZ5CHCl 0tIDSchku+P+ziP0FisUyux1IOGT+3oXNBf1b3YXYu6D6HiEmZbD7V4GJMjHBt4oTn kttrW4HaMwmDKHFes5s4df23+V/rh0S4SJ5NsllOLU60xiFTtQeipmlGfqJrlyVRxB vGWMHcS1ODdJ54p6UcLKQHM6XQSDn8hjyN8Yzr97Ij6tDJQFpQpTbgHroWJq7SRDeZ 1wYiPZ0v8v1Uw== From: Jeff Layton Date: Wed, 31 Jan 2024 18:02:05 -0500 Subject: [PATCH v3 24/47] filelock: make __locks_delete_block and __locks_wake_up_blocks take file_lock_core Precedence: bulk X-Mailing-List: linux-kernel@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: <20240131-flsplit-v3-24-c6129007ee8d@kernel.org> References: <20240131-flsplit-v3-0-c6129007ee8d@kernel.org> In-Reply-To: <20240131-flsplit-v3-0-c6129007ee8d@kernel.org> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , Alexander Viro , Christian Brauner , Jan Kara , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Andreas Gruenbacher , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Miklos Szeredi Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4001; i=jlayton@kernel.org; h=from:subject:message-id; bh=+fh0Pyz60IyaAdOx+0EoERtKYPFhqrIpllRCidYLo4Y=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFxs5terizvq50AGfajQ5gB4SSv/QE7zun6s 7LfTA+Vb+yJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRcQAKCRAADmhBGVaC FTzmD/9jWU1AHowJsmJW2yQFaIH0ea4koaFqzMTBSqcK+HWHLMXGEkBSwD7pZaPUvN5mzp1/E8W 1b0C34g48/w3VQ2AnR65/mmhehnLZdjb19USwIEcyHVt+fvGuT/K8af5sMCd16GKP35di1euDE5 Knu35ZM8cbwywmNp7HZapaH89KYCHVZcFx3G++GoKh2KBauAXv8B9ha1zb3hB0RMFj3MDikNVV0 u0b6xmUGUVDZeHDV90U7MAe/nFj0cst36l+1Ea1s30Wpcr1K42eL6MqZ70HRWE93WXH5NTqG6nT h44ogNN9gqZUPZq/vO/RVPcVJd6ofWcKMLJLizOr+Uhbf1lEbKaXlORiNebQDXWr84ViPdFlDtE sDOlX1kP6HbWA2wa7Lv/w+6dAk8rou/cD7/SOr2g+Uu/3ftDPMNYoUYTWxO1AiRMkGMXGA408pw 0xlpWo+JikKkcktjPyZdjg04MVlPjGl2SjL+PfeGuPAXmDGl+u4jo52iBSQW79g3Gnaf4ovsF0d p4B2Dm0f+sKXtcR4ZUNZpigsOxk4G6s3nLfyA2lTZ2QB+jaMEH+2lWPL2A09jY1Z7j76sGIlRAK OGXZdEt7Q0xgUFTGdAOc2iyFZq2i5qGKHJiAoLARcU0E6eoE/LDAgR5ZFLTv/mHmm+6bKZkHh4i lKZhCpia9wEtUPQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Convert __locks_delete_block and __locks_wake_up_blocks to take a struct file_lock_core pointer. While we could do this in another way, we're going to need to add a file_lock() helper function later anyway, so introduce and use it now. Signed-off-by: Jeff Layton --- fs/locks.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index ef67a5a7bae8..1e8b943bd7f9 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -69,6 +69,11 @@ #include +static struct file_lock *file_lock(struct file_lock_core *flc) +{ + return container_of(flc, struct file_lock, c); +} + static bool lease_breaking(struct file_lock *fl) { return fl->c.flc_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); @@ -654,31 +659,35 @@ static void locks_delete_global_blocked(struct file_lock_core *waiter) * * Must be called with blocked_lock_lock held. */ -static void __locks_delete_block(struct file_lock *waiter) +static void __locks_delete_block(struct file_lock_core *waiter) { - locks_delete_global_blocked(&waiter->c); - list_del_init(&waiter->c.flc_blocked_member); + locks_delete_global_blocked(waiter); + list_del_init(&waiter->flc_blocked_member); } -static void __locks_wake_up_blocks(struct file_lock *blocker) +static void __locks_wake_up_blocks(struct file_lock_core *blocker) { - while (!list_empty(&blocker->c.flc_blocked_requests)) { - struct file_lock *waiter; + while (!list_empty(&blocker->flc_blocked_requests)) { + struct file_lock_core *waiter; + struct file_lock *fl; + + waiter = list_first_entry(&blocker->flc_blocked_requests, + struct file_lock_core, flc_blocked_member); - waiter = list_first_entry(&blocker->c.flc_blocked_requests, - struct file_lock, c.flc_blocked_member); + fl = file_lock(waiter); __locks_delete_block(waiter); - if (waiter->fl_lmops && waiter->fl_lmops->lm_notify) - waiter->fl_lmops->lm_notify(waiter); + if ((waiter->flc_flags & (FL_POSIX | FL_FLOCK)) && + fl->fl_lmops && fl->fl_lmops->lm_notify) + fl->fl_lmops->lm_notify(fl); else - locks_wake_up(waiter); + locks_wake_up(fl); /* - * The setting of fl_blocker to NULL marks the "done" + * The setting of flc_blocker to NULL marks the "done" * point in deleting a block. Paired with acquire at the top * of locks_delete_block(). */ - smp_store_release(&waiter->c.flc_blocker, NULL); + smp_store_release(&waiter->flc_blocker, NULL); } } @@ -720,8 +729,8 @@ int locks_delete_block(struct file_lock *waiter) spin_lock(&blocked_lock_lock); if (waiter->c.flc_blocker) status = 0; - __locks_wake_up_blocks(waiter); - __locks_delete_block(waiter); + __locks_wake_up_blocks(&waiter->c); + __locks_delete_block(&waiter->c); /* * The setting of fl_blocker to NULL marks the "done" point in deleting @@ -773,7 +782,7 @@ static void __locks_insert_block(struct file_lock *blocker, * waiter, but might not conflict with blocker, or the requests * and lock which block it. So they all need to be woken. */ - __locks_wake_up_blocks(waiter); + __locks_wake_up_blocks(&waiter->c); } /* Must be called with flc_lock held. */ @@ -805,7 +814,7 @@ static void locks_wake_up_blocks(struct file_lock *blocker) return; spin_lock(&blocked_lock_lock); - __locks_wake_up_blocks(blocker); + __locks_wake_up_blocks(&blocker->c); spin_unlock(&blocked_lock_lock); } @@ -1159,7 +1168,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, * Ensure that we don't find any locks blocked on this * request during deadlock detection. */ - __locks_wake_up_blocks(request); + __locks_wake_up_blocks(&request->c); if (likely(!posix_locks_deadlock(request, fl))) { error = FILE_LOCK_DEFERRED; __locks_insert_block(fl, request, -- 2.43.0