From patchwork Wed Jan 31 23:01:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 195016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp79147dyc; Wed, 31 Jan 2024 15:05:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFq+u6ub3YOKnJjs4c8H6A/ALkZNxqXE3vX6A4lrdSdx4XIc1/0wn6DDP6HL9ukx17CNeHl X-Received: by 2002:a05:620a:228a:b0:783:f553:98a0 with SMTP id o10-20020a05620a228a00b00783f55398a0mr587083qkh.48.1706742340378; Wed, 31 Jan 2024 15:05:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742340; cv=pass; d=google.com; s=arc-20160816; b=wpNqZogT0ZtU4eT///hCscMgtEtq4ctJTqnxcs9FoKuBDuJwzkaUy/IFUKWKeOWXkN VYsGoePMSbiw2DwPzud9TVFpTX4U9LdujYO8/SHkASX1ZD5pspQSol8o5MyjKoklGFyV ZI5ZuM+QPONEm8/HuZ/y1jSVT6HbCmrs0wjwRtic/sulF4zD+SYD7ITqKMRWKq5mKmTy HDroUTft52rVhnvZdgSEhY/yukVVbGRczz0vGl/hWgnygq7EzKkQno4mX2R3FgTa6926 UT/KCDHBPXws33r0F3MRetLIo4hJhUX++A/0btovUJP0sd3YYB4ma+yhxPibcd5g+O1t iidA== 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=CrNnLti7WLBLGV0+jMsQ36gvnH1KjBZxBzkPeo3nRCU=; fh=ekhybr8nrkomBXKPcgG82F77FOVKqIQvjl6orLHaHv8=; b=QlnUZzxrqBthE+xz0QkCEiiZQbehRLkqTRYDmo4wBMr1lH+4N38+3tZaBZW18XMV6x DZu00Ymhz0omPowKRzJYK9n2HNIaEYyYEyTneuQ4EWi2iScBuv0dnrYHjmIo31ymlojE Pg/msPxXqw/C9to6WG197vMZpP7q4w8KamqjRX1OOmatJK4zXH4FTnbCbm3gBIXpFP2I pjNdskXemitfSKzlhcTAANQKPWz95QiLBeCS+4l1gtsYVs5xgmYF7EmWbI1G5+joqF0G uGLdySD7Xkc0jhgzgTHlMgcOCBXRweogLECeVlanhUFbAIicW6k4wN4WFBJJN1Q+0Hwg l/MA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K6y3TvL7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47292-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47292-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWlHyxxtWatSMzyqiVz/XuPktyHmBtxlVuNawIDgXnUiblN37ksmoDdpR2RR0IAuY7Z9gBszn7JW9qZw3hcj0p2VFQdaA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b8-20020a05620a088800b00783f6f175dasi8589867qka.576.2024.01.31.15.05.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:05:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47292-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K6y3TvL7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47292-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47292-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 1C1381C21423 for ; Wed, 31 Jan 2024 23:05:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24D3340C0C; Wed, 31 Jan 2024 23:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K6y3TvL7" 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 B95BC405D8; Wed, 31 Jan 2024 23:02:40 +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=1706742160; cv=none; b=t6bBnAymU8JBlNMYGwzHlHZtD7Iby3rWgJirmTEBEXv50lyzDNoI+nVGYg1lMnqnuSS8vqu2PGFOKrn+pTaWBk6/vsmxpIoom6IqIO1YvoUeIR6AX8Shn6g3V5tmPhuWcIjOJ8MZvCyC96wQYGL/JYGVD8rj0aq6ioCMvmqXp4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742160; c=relaxed/simple; bh=euQqh/A/+3u/1dNNztrBljXWB1tU1Qxda+6XvMysb2g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tM44cTe6Y1vgh7CjhAIVXBDGhKc0VX0N/5buRzdeKgt1AOgt3UF7giIchVdXMX+ru/mvLtiEkRqTnupqjrdfyJ1VvnglC9j5O5rHf7MxzF53QjtxCvagQjGD4is9Rk9dhOPHKVk/rciH+JQV5hg45zkyUvBOYyymUovoRQ+iyGo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K6y3TvL7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 715EDC43330; Wed, 31 Jan 2024 23:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742160; bh=euQqh/A/+3u/1dNNztrBljXWB1tU1Qxda+6XvMysb2g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K6y3TvL7j0rQElOl8HMEpLwbfrfxXuMKxVdoFQ3vgJ3ncwuuu/kBtLNyze9uTYgLs Mtlxb4165EITslBjPrQMVOf0HhqhJ5Sgb8om56edXFSr4W8+9lPr3oLG8hRZyQacDm /A7YiqoDAVF4wKGXipQa2IFjzr7xuRNnYRTtWD24A3OnCWSydmKS8QZuj5QTDJtqGI hfY3wHpUjDqryoK2iEQCmDfTzVDkWh0YiMc4A0Bn0GA3nypjgHP7XuXassRrzPYfsy tTESwFBLmDYV0KC18FtIkGnlvf7CB/tZJ5PsSJPhxllRR+LlpAnNVZqa5dq6Y/BlJA 6SMqYNSXYty2w== From: Jeff Layton Date: Wed, 31 Jan 2024 18:01:47 -0500 Subject: [PATCH v3 06/47] afs: convert to using new filelock helpers 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-6-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=4039; i=jlayton@kernel.org; h=from:subject:message-id; bh=euQqh/A/+3u/1dNNztrBljXWB1tU1Qxda+6XvMysb2g=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFv8yrZZCeCMjQ60t++Gsw+NdizIjXTDmNg4 KOb65q4wzOJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRbwAKCRAADmhBGVaC FZ4QD/9Vi6c4kB8+RSFR5LlyQN3yX1tMkrbOdr9+a+r9Xyjc4SMI1Byv14fPo4Zo/pVtd0wgJ64 DqLL+0QXI+LAul0z1i/FEqi4nZFzePe7gwvo0B2rEJNlybGkWogHndodfkHg/h+k3MFtSVIRJHS yrAPe1xgxYZKCysYMrwPz0lT7+8sBpCYawrQ3XXFB7MOI9Vu9V7T5zxsp9JlmlMm0gyl7Pa1sRA kss+/mFdpBSrOiTsc9Q6R2AqCgTh8Dlb215EMZNKdIRznapilE5aXyUDz721aL9kUUro9aYpMf7 DMR5k1OFfCN65imlnt0XWAiHpte7Sy/wsXCgda+TYqh6LQB9qqvfJAke22Yz2yTs9jbZHIfv/J9 Q8WXmhhWFJK0G9od4Bppa+qpW0bmdqrorEHJcUVRnw46OgVACua/gCsO88Hu6OTf66mo8U48lrA 6KFTGCyA88BHNr/65GpaQgC76t5EK4aqeHtnxPOKjlITvUbp6F5Si3upRwZyxLkhTKKVjj/pDlj GqbmFsMDqEDwsOHtj/Exq5+WcmPELcMCA4bIalDR9zLJsn9JQ3U7jGqBvcZ+qV5KEne7NwudjrD /eOiw4QyENYJ6C8NmZkah7xN0Zi8Tq3qY55ibo7IEFtbafCO59jFROGFEcwXtM9YGuhuVswEuT1 edoNh7AArUatVLQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789649056271577104 X-GMAIL-MSGID: 1789649056271577104 Convert to using the new file locking helper functions. Also, in later patches we're going to introduce macros that conflict with the variable name in afs_next_locker. Rename it. Signed-off-by: Jeff Layton --- fs/afs/flock.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/afs/flock.c b/fs/afs/flock.c index 9c6dea3139f5..4eee3d1ca5ad 100644 --- a/fs/afs/flock.c +++ b/fs/afs/flock.c @@ -93,13 +93,13 @@ static void afs_grant_locks(struct afs_vnode *vnode) bool exclusive = (vnode->lock_type == AFS_LOCK_WRITE); list_for_each_entry_safe(p, _p, &vnode->pending_locks, fl_u.afs.link) { - if (!exclusive && p->fl_type == F_WRLCK) + if (!exclusive && lock_is_write(p)) continue; list_move_tail(&p->fl_u.afs.link, &vnode->granted_locks); p->fl_u.afs.state = AFS_LOCK_GRANTED; trace_afs_flock_op(vnode, p, afs_flock_op_grant); - wake_up(&p->fl_wait); + locks_wake_up(p); } } @@ -112,25 +112,25 @@ static void afs_next_locker(struct afs_vnode *vnode, int error) { struct file_lock *p, *_p, *next = NULL; struct key *key = vnode->lock_key; - unsigned int fl_type = F_RDLCK; + unsigned int type = F_RDLCK; _enter(""); if (vnode->lock_type == AFS_LOCK_WRITE) - fl_type = F_WRLCK; + type = F_WRLCK; list_for_each_entry_safe(p, _p, &vnode->pending_locks, fl_u.afs.link) { if (error && - p->fl_type == fl_type && + p->fl_type == type && afs_file_key(p->fl_file) == key) { list_del_init(&p->fl_u.afs.link); p->fl_u.afs.state = error; - wake_up(&p->fl_wait); + locks_wake_up(p); } /* Select the next locker to hand off to. */ if (next && - (next->fl_type == F_WRLCK || p->fl_type == F_RDLCK)) + (lock_is_write(next) || lock_is_read(p))) continue; next = p; } @@ -142,7 +142,7 @@ static void afs_next_locker(struct afs_vnode *vnode, int error) afs_set_lock_state(vnode, AFS_VNODE_LOCK_SETTING); next->fl_u.afs.state = AFS_LOCK_YOUR_TRY; trace_afs_flock_op(vnode, next, afs_flock_op_wake); - wake_up(&next->fl_wait); + locks_wake_up(next); } else { afs_set_lock_state(vnode, AFS_VNODE_LOCK_NONE); trace_afs_flock_ev(vnode, NULL, afs_flock_no_lockers, 0); @@ -166,7 +166,7 @@ static void afs_kill_lockers_enoent(struct afs_vnode *vnode) struct file_lock, fl_u.afs.link); list_del_init(&p->fl_u.afs.link); p->fl_u.afs.state = -ENOENT; - wake_up(&p->fl_wait); + locks_wake_up(p); } key_put(vnode->lock_key); @@ -471,7 +471,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl) fl->fl_u.afs.state = AFS_LOCK_PENDING; partial = (fl->fl_start != 0 || fl->fl_end != OFFSET_MAX); - type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; + type = lock_is_read(fl) ? AFS_LOCK_READ : AFS_LOCK_WRITE; if (mode == afs_flock_mode_write && partial) type = AFS_LOCK_WRITE; @@ -734,7 +734,7 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl) /* check local lock records first */ posix_test_lock(file, fl); - if (fl->fl_type == F_UNLCK) { + if (lock_is_unlock(fl)) { /* no local locks; consult the server */ ret = afs_fetch_status(vnode, key, false, NULL); if (ret < 0) @@ -778,7 +778,7 @@ int afs_lock(struct file *file, int cmd, struct file_lock *fl) fl->fl_u.afs.debug_id = atomic_inc_return(&afs_file_lock_debug_id); trace_afs_flock_op(vnode, fl, afs_flock_op_lock); - if (fl->fl_type == F_UNLCK) + if (lock_is_unlock(fl)) ret = afs_do_unlk(file, fl); else ret = afs_do_setlk(file, fl); @@ -820,7 +820,7 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl) trace_afs_flock_op(vnode, fl, afs_flock_op_flock); /* we're simulating flock() locks using posix locks on the server */ - if (fl->fl_type == F_UNLCK) + if (lock_is_unlock(fl)) ret = afs_do_unlk(file, fl); else ret = afs_do_setlk(file, fl);