From patchwork Wed Jan 31 23:02:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 195030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp83500dyc; Wed, 31 Jan 2024 15:14:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEo4GkdliMTdwKtqwlS2wH9G1HKvuI/IHUld47TL2gav32aUgiXFYA1TixPU7OKRv5H55KL X-Received: by 2002:a0c:b2d5:0:b0:681:74d2:36f0 with SMTP id d21-20020a0cb2d5000000b0068174d236f0mr5899080qvf.27.1706742880842; Wed, 31 Jan 2024 15:14:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742880; cv=pass; d=google.com; s=arc-20160816; b=nB5Qhj7thsCflPTe6QHAk+nK8pIixnXVIY2ZNuUePLAdSOpqNVDc3ha84DronAQBx7 /WG/KLjGx6tj1gvHZJAMszFsjS/aIMHlYK88Hmih8FXwC1IyPqDwoGNdo8H9BRXTRpfD x0LKmJV9aaFZ7oqlRex0btG1EGcKwhDzq9l7Lz+DHoIDT7EUF7XrRxo8KRdLKJkazyVy 3hQqN4ioSUfql3YGCB9rDnwM2GHrb/UbiUfbR/UBK7ZhvM35igjQjI0o1jBNathSQ+Zx G/PTERthkkDtzXYT9hxheGLBkv+ZdZ47aDUydNzwjyngmS6TiRAEz5FcVey7/EpzLlSN b5kw== 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=HsfMfzp500HMgFmIIA3GwB7TcY2Fvv1n6OTgONxj/wI=; fh=GwO0PTstPf1picn0xljsEqKu/wfVu41AWVvxcxqEJqM=; b=ls5baXBMaMs7+H8iVqP4n3cVUSEbgd9kxWI77bih+Htxa7Ov84ddYvM4GRDwIQdDR/ W3jem91k1fgSZPPfCrRr1C0At4XUzhAHuO8FmtNQjSRdGI+AKQEAEMBzZC5EYhy7grZI lV6EX1b0ZnBjGvhFD7EYRZkmIWTc6i5y4OtBCthQqxXdBcMpUczaFBsk0LdTgzyII1/0 1QWj2xq6ujZfX8etFd76ej3/fxOkNIeyPp0AV++NYex6aZ7DX6OqngXA9dSeW6sSvQN3 ZSuBKdQSXo3LLZHl0HLBjG62PVi8JdI2kBR4e8urYR4DYrNV0ugBOcvJn5T43zfAQne4 tTEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P41UGYqa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47313-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47313-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUe1f9AWORkxlaNleNdD8AzdOVxMBysxlAnW8OZzoz3Cwyrxczh/s86l+JNvbmm5MhKnysdYgvzlm2wavEJA7758cebvg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d2-20020a05621421c200b0068c427612cbsi10460857qvh.553.2024.01.31.15.14.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:14:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47313-ouuuleilei=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=P41UGYqa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47313-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47313-ouuuleilei=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 921B81C24F66 for ; Wed, 31 Jan 2024 23:14:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D792141994; Wed, 31 Jan 2024 23:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P41UGYqa" 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 C02AB140781; Wed, 31 Jan 2024 23:03:59 +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=1706742239; cv=none; b=Xiyq2i0VCZDMsNKM1nxGkIZgIDskHQTIQVBFXkCneK1Ov8eSB6gltHlhim5PYcJ9uVnLRo1PODZx85chQaap9QmYPZZhINkc40iDJAW8hxTioa+mKUUu2j7yjp3PyRkGR3OwUHmZiIScvyYnF0LewHbE0184b/GdvM75DXUc6no= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742239; c=relaxed/simple; bh=IeTENray2gSzrhF+1zVNOLrjXqQyLU529tCaMhSpwV0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MyPBcPPyaC4lrkHIgbyA0Gu4oj8+Zij0AVysgjdSMJ5V9mg0PZYp7ht/1h4Rx2/PJ82seZHfuCy2RQTf0AwD21npy3jSzvZ0WO7kzY5FojcJGl8X2gJKbRZsWivqe9Cv4fslyZVlINIJu7TpuM6GNyX16Yt5bgh8jSeNO1IxXUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P41UGYqa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCE31C43390; Wed, 31 Jan 2024 23:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742239; bh=IeTENray2gSzrhF+1zVNOLrjXqQyLU529tCaMhSpwV0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=P41UGYqauJWFVK0bmXh1aftAWWLHCiixaFfM4X6JIsW6scyLAbzv4fCIHVFjdoD00 P+O2Acig1P0+jXsN68gPCzMKg6Duq0FHNQvs314TIYq4YX8CjxKe0PZFatGlFGLmbg r85Hl/t3cmQSDtXC+HV0j+sp+Lh9TsJLz1EOJmhZurTDjY6scZ4iovIv3OpKJ0WfL7 VhYVrhlYeIyMBrWnAds++9ji8OH+3otexYC51dIIEA7/zyna2LwfcDRK2AviGOLjwF 9svoe2IqzSauVAd8jGoMT38xO/XXKW2/9n8cJRZ/G3M62SyCLzjCWJNdWEIgDKONr1 cjFSHnfpDoXgA== From: Jeff Layton Date: Wed, 31 Jan 2024 18:02:07 -0500 Subject: [PATCH v3 26/47] filelock: convert fl_blocker to file_lock_core Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240131-flsplit-v3-26-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=4221; i=jlayton@kernel.org; h=from:subject:message-id; bh=IeTENray2gSzrhF+1zVNOLrjXqQyLU529tCaMhSpwV0=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFx2VdVwn6zbUu1eXEoq1C2FLlhrp1iCkdup bEzm8yJtd6JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRcQAKCRAADmhBGVaC FaoGD/4rGXrnX7Zvd/LNc2r4gyI1Y2HBaNAZRb1j+KbTFXF9/sVCSnhwrMEIzkX8Npc6Y3Tuypb ErL/3L3JCt4InQFbaKGs6bjUOZBAJwxL2ag86WRAKShWOhdF8EItkK3mHy/6P449ULlDtI6aBbH qjho1v297KlMCsrogb87QkZ7frmY6IB0HU57ueZz2YQWu7Nq1oTjjRXEk7ADTLwQ7vhsw9sUQl2 WYe90FDde2jijdXY64+xKRk5LUTZh7xFbPiseIFbXbgGIxJLxWM5v9/6W+1XuUy6lynBn8bjV5n FhUjQZtYLTQXrdIDBG4CTHjijUpKMyXN9wvo8D/CEeHRDXnhDxfO4ePP+F7QKiBIbSQnIg3m2MF DBrgBrJ4Sz+1KVlISAxVZqslhnQIHgESdkWEk5lECy19QJ/kUUe5TdE+POQB51gkjM83EvXG3q/ l69WsLCs33tENyg6j4HLn2ewA1FjD0NCncjGNS7mF/8ho0d8DBnt1fY1QfB93qNavxnvuHCgdbO QuDN1ZtLtbPA4L0vFsXpv1ssH0s7R4/aT0bR791ZZ5tILHHZ1EaFSQ4NcITRfBRt74ym84P8Gna OvLKxYhooXzS2aFy9gqGu63RjOkf0DNG+6YaNCoU+LYF0uW+vFLOABd5i/GDDvRWGOyjiOymZ4G ckFU3M3PKM9D92w== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789649623042037944 X-GMAIL-MSGID: 1789649623042037944 Both locks and leases deal with fl_blocker. Switch the fl_blocker pointer in struct file_lock_core to point to the file_lock_core of the blocker instead of a file_lock structure. Signed-off-by: Jeff Layton --- fs/locks.c | 16 ++++++++-------- include/linux/filelock.h | 2 +- include/trace/events/filelock.h | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 0dc1c9da858c..0aa1c94671cd 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -400,7 +400,7 @@ static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) /* * As ctx->flc_lock is held, new requests cannot be added to - * ->fl_blocked_requests, so we don't need a lock to check if it + * ->flc_blocked_requests, so we don't need a lock to check if it * is empty. */ if (list_empty(&fl->c.flc_blocked_requests)) @@ -410,7 +410,7 @@ static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) &new->c.flc_blocked_requests); list_for_each_entry(f, &new->c.flc_blocked_requests, c.flc_blocked_member) - f->c.flc_blocker = new; + f->c.flc_blocker = &new->c; spin_unlock(&blocked_lock_lock); } @@ -773,7 +773,7 @@ static void __locks_insert_block(struct file_lock *blocker_fl, blocker = flc; goto new_blocker; } - waiter->flc_blocker = file_lock(blocker); + waiter->flc_blocker = blocker; list_add_tail(&waiter->flc_blocked_member, &blocker->flc_blocked_requests); @@ -996,7 +996,7 @@ static struct file_lock_core *what_owner_is_waiting_for(struct file_lock_core *b hash_for_each_possible(blocked_hash, flc, flc_link, posix_owner_key(blocker)) { if (posix_same_owner(flc, blocker)) { while (flc->flc_blocker) - flc = &flc->flc_blocker->c; + flc = flc->flc_blocker; return flc; } } @@ -2798,9 +2798,9 @@ static struct file_lock *get_next_blocked_member(struct file_lock *node) /* Next member in the linked list could be itself */ tmp = list_next_entry(node, c.flc_blocked_member); - if (list_entry_is_head(tmp, &node->c.flc_blocker->c.flc_blocked_requests, - c.flc_blocked_member) - || tmp == node) { + if (list_entry_is_head(tmp, &node->c.flc_blocker->flc_blocked_requests, + c.flc_blocked_member) + || tmp == node) { return NULL; } @@ -2841,7 +2841,7 @@ static int locks_show(struct seq_file *f, void *v) tmp = get_next_blocked_member(cur); /* Fall back to parent node */ while (tmp == NULL && cur->c.flc_blocker != NULL) { - cur = cur->c.flc_blocker; + cur = file_lock(cur->c.flc_blocker); level--; tmp = get_next_blocked_member(cur); } diff --git a/include/linux/filelock.h b/include/linux/filelock.h index 4dab73bb34b9..fdec838a3ca7 100644 --- a/include/linux/filelock.h +++ b/include/linux/filelock.h @@ -87,7 +87,7 @@ bool opens_in_grace(struct net *); */ struct file_lock_core { - struct file_lock *flc_blocker; /* The lock that is blocking us */ + struct file_lock_core *flc_blocker; /* The lock that is blocking us */ struct list_head flc_list; /* link into file_lock_context */ struct hlist_node flc_link; /* node in global lists */ struct list_head flc_blocked_requests; /* list of requests with diff --git a/include/trace/events/filelock.h b/include/trace/events/filelock.h index 4be341b5ead0..c778061c6249 100644 --- a/include/trace/events/filelock.h +++ b/include/trace/events/filelock.h @@ -68,7 +68,7 @@ DECLARE_EVENT_CLASS(filelock_lock, __field(struct file_lock *, fl) __field(unsigned long, i_ino) __field(dev_t, s_dev) - __field(struct file_lock *, blocker) + __field(struct file_lock_core *, blocker) __field(fl_owner_t, owner) __field(unsigned int, pid) __field(unsigned int, flags) @@ -125,7 +125,7 @@ DECLARE_EVENT_CLASS(filelock_lease, __field(struct file_lock *, fl) __field(unsigned long, i_ino) __field(dev_t, s_dev) - __field(struct file_lock *, blocker) + __field(struct file_lock_core *, blocker) __field(fl_owner_t, owner) __field(unsigned int, flags) __field(unsigned char, type)