From patchwork Wed Jan 31 23:01:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 195028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp83276dyc; Wed, 31 Jan 2024 15:14:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjUGWOPIfr91T9waJuCYmHchRNoRX1pTzPOI9kduj68n0AVk6CkwbfMqO7vSfFTDFobwRG X-Received: by 2002:a17:902:7406:b0:1d4:35ad:41cb with SMTP id g6-20020a170902740600b001d435ad41cbmr439322pll.49.1706742848136; Wed, 31 Jan 2024 15:14:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742848; cv=pass; d=google.com; s=arc-20160816; b=mTRxVfu6HStKr7kGspukDc9cFcQzBNiSQJBE+ggyrwXCMbgJH73tvWYCUrnCoIELb9 ZWjaQFz0buS8MRNCE+iBEMYRNlr/8edWXLWQefbv7kmDQIn84wv+xABkwKacYXJEpOeJ V4qrR7DfblC9MybRWJWNzB+CV3uAUTtYUb2nWbcQOvF/P5u/V8fBCW9lYX9y/9WZ9Tn8 ztRyXluJsJ9qRrTZu8p2ndJ4gdHafTrlQWYJSLWmn6EBkhmhAMnFjzr3R+s+3RprXpPn emchZ74opMqPxehLeuckD957mrxzpTe67Qtof6CU2e8B0G6FUQ9Y93vh1YYB3s7Foub+ CgPA== 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=jMu3x2l6wnZ0KdteYLae4bu+x+USZxoUjB6n3y+4DSg=; fh=FyP+OO5jmnRSDpHJrYiikHJc1+xICz+I5VVUn79rWAM=; b=TPxrUxUKhv97RQSSUTO1qE8G58mklJiUT87s4VfIi16HkKrsA/kiCv91NEnj8jXdFR 4f5D2EITIGzWfD/bf3GgVtxdDh+S384943kzUbUn2+clXc5Vy8SC2qq9lypqTvdZijFs aqTzyh+ki2GovYCgUpwM203Vqa/09Xo1/l8MmMsyHWaMgt/ozssWmhVUFZoBmHtviOV+ 3ONo2pVhYrSQ5TRR8fpkXbrcSZtfGW14vyLrE5JIyBj58w3lNMxYZ2SgiiUq4cQB/vP0 qtnPQixVZunfc0VQYSMsTyPaU6ScAagZuwkrMADFm69Bdz9AdBjB+ZkhxK3m24HhKVd6 KLbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=omrorkuN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47298-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47298-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVEs5K227XkGNZ1m65PSERwdp/ggcqnGW+24MzAtQlUK3y/997wAHzlKH3PKCrMTWJRbtLV8wpfNwU+dUFjmwHdUeeTTg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q10-20020a170902b10a00b001d748e13788si10583363plr.93.2024.01.31.15.14.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:14:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47298-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=omrorkuN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47298-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47298-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BFB36287FE6 for ; Wed, 31 Jan 2024 23:08:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1247E48795; Wed, 31 Jan 2024 23:03:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="omrorkuN" 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 873D23B793; Wed, 31 Jan 2024 23:03:04 +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=1706742184; cv=none; b=TynPFAyDqmS/2/SHc6jFsKf4dRHYf6PZ2NCYQ0JFDxtoTNpFU+dUiMnL3Vy/qQAmV65k5BIE6sNEpJzvfVP9usGk8ZXuUExsCo6XYvTtle/g42VYoYSDLmAWEghavpdC8wlYMUE7J5I7kuec86V+LD3gkyMQ5gTcqm/5xcClRXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742184; c=relaxed/simple; bh=V/Cml+ndEU7iQrcDHnjT9HOwBZUwf1ET15f3AAfB7zM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GuvXwufYFyrrCJktlOkHsSklkvCV2z/XKcYJOVTdwPSl+3sTR4PbOGyVUQkwXxAO6AarNQ+pzscX1KYHF+X0N9zbt3n1R9Pnov14NjrNJLAUun51mt/THIgNIWH7BhriYUI/45B1Hof5yMsyG28S/Bggg/qgCaZoXERprOyzBW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=omrorkuN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45726C43394; Wed, 31 Jan 2024 23:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742184; bh=V/Cml+ndEU7iQrcDHnjT9HOwBZUwf1ET15f3AAfB7zM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=omrorkuNj3diaNJvYiK9P5+yx8p60ff8FukG+v2+B7wTGbS+e8zUhtTdCf1MQZFY7 uIKg/y1b5LpNxfuOuU8KNS9shaWxuIBBe+E+OmEQdgfbLFrDMNDdgJhRiSgq02szf3 QFdOkSxUpkThzjYhrcqyY6FWBqGsoODi4kh+YZjecu37Ivn4CEPfqAi50VRibJuT5Z VmzQQXu6IK6lGoj+h5US3L/67zesRUV3XGFBb7TEVwlsHD23aTJGvaZkUyOUs5kfa3 tnap+AncKNLD8P/Gjf1RjVIqKCUg6VsYygeac4MfnZ6hN1dx0VzD+dDovyQkG4MuEz Hpy7xDXkAP8Qw== From: Jeff Layton Date: Wed, 31 Jan 2024 18:01:53 -0500 Subject: [PATCH v3 12/47] nfsd: 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-12-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=4942; i=jlayton@kernel.org; h=from:subject:message-id; bh=V/Cml+ndEU7iQrcDHnjT9HOwBZUwf1ET15f3AAfB7zM=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFveQ3kAMFR+bNak+EV0mzECrq5iciXdyE9m QnN6JXrqtCJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRbwAKCRAADmhBGVaC FXtUEACeQ33gx59LXWKBtRatMw8bD3yv2bYtjghaJJvF5XfMUmiX14V065boE5cV3gXMnZGrspQ tqo4DJIEaQ4lFXTIARdtx64HQCI9lMABI4gZAP2XzrYGm9LHCCPyuny9jIC6cBytL2tckxf4O8j glgdiO10rXdFZdGVpSBFE/6Vrf91Fjmk21eifR2nLK0MF7MRTX/+otIhthokSqkYD+bNbe+Bx2Z +JH3O1lkf6bRoWgKw2L24nOT5seYXPsvL0KXAeabZP74WNeOPO30W7PwmxmINQhxCBJzPBsWjWg 9dJR52MP/a6Um6S9LELMGq0TAScE7fxYm5j5uJRnk7NXT7Z7OC/r9NRdXv8EudCYt8r4n/sNp7m QcbwifvyLq0WZIwaDZ+rWmxGaNSk8tRgBSdO0rD1vOYHZc5itN63NLMbKjnhSGtQWHAiS7c0bRc 1+wRNBZdfWD9VMf1YnYijA0xkJ2bJtVRLUtOX3FbmFvrKqidD9qg/UL+uq6LIKtZU6WssLAJZbS QKurKERrbp7mxYpVTObWJYAZnFmfeiOIsgYze7WiPuuGX/Bvr/iN8qT8WBcL14ckMvPBSSftF1V giRoBcq/9JOMgiZjTkDr60d2K8crFpvOXfKgh+3bxIyrbYuwc0QHzcJMp5TJVZ0TJWigsB6/zhO hP0MjuSrsZ+3msg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789649588963560233 X-GMAIL-MSGID: 1789649588963560233 Convert to using the new file locking helper functions. Also, in later patches we're going to introduce some macros with names that clash with the variable names in nfsd4_lock. Rename them. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 6dc6340e2852..83d605ecdcdc 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -7493,8 +7493,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, int lkflg; int err; bool new = false; - unsigned char fl_type; - unsigned int fl_flags = FL_POSIX; + unsigned char type; + unsigned int flags = FL_POSIX; struct net *net = SVC_NET(rqstp); struct nfsd_net *nn = net_generic(net, nfsd_net_id); @@ -7557,14 +7557,14 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out; if (lock->lk_reclaim) - fl_flags |= FL_RECLAIM; + flags |= FL_RECLAIM; fp = lock_stp->st_stid.sc_file; switch (lock->lk_type) { case NFS4_READW_LT: if (nfsd4_has_session(cstate) || exportfs_lock_op_is_async(sb->s_export_op)) - fl_flags |= FL_SLEEP; + flags |= FL_SLEEP; fallthrough; case NFS4_READ_LT: spin_lock(&fp->fi_lock); @@ -7572,12 +7572,12 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, if (nf) get_lock_access(lock_stp, NFS4_SHARE_ACCESS_READ); spin_unlock(&fp->fi_lock); - fl_type = F_RDLCK; + type = F_RDLCK; break; case NFS4_WRITEW_LT: if (nfsd4_has_session(cstate) || exportfs_lock_op_is_async(sb->s_export_op)) - fl_flags |= FL_SLEEP; + flags |= FL_SLEEP; fallthrough; case NFS4_WRITE_LT: spin_lock(&fp->fi_lock); @@ -7585,7 +7585,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, if (nf) get_lock_access(lock_stp, NFS4_SHARE_ACCESS_WRITE); spin_unlock(&fp->fi_lock); - fl_type = F_WRLCK; + type = F_WRLCK; break; default: status = nfserr_inval; @@ -7605,7 +7605,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, * on those filesystems: */ if (!exportfs_lock_op_is_async(sb->s_export_op)) - fl_flags &= ~FL_SLEEP; + flags &= ~FL_SLEEP; nbl = find_or_allocate_block(lock_sop, &fp->fi_fhandle, nn); if (!nbl) { @@ -7615,11 +7615,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, } file_lock = &nbl->nbl_lock; - file_lock->fl_type = fl_type; + file_lock->fl_type = type; file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(&lock_sop->lo_owner)); file_lock->fl_pid = current->tgid; file_lock->fl_file = nf->nf_file; - file_lock->fl_flags = fl_flags; + file_lock->fl_flags = flags; file_lock->fl_lmops = &nfsd_posix_mng_ops; file_lock->fl_start = lock->lk_offset; file_lock->fl_end = last_byte_offset(lock->lk_offset, lock->lk_length); @@ -7632,7 +7632,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out; } - if (fl_flags & FL_SLEEP) { + if (flags & FL_SLEEP) { nbl->nbl_time = ktime_get_boottime_seconds(); spin_lock(&nn->blocked_locks_lock); list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked); @@ -7669,7 +7669,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, out: if (nbl) { /* dequeue it if we queued it before */ - if (fl_flags & FL_SLEEP) { + if (flags & FL_SLEEP) { spin_lock(&nn->blocked_locks_lock); if (!list_empty(&nbl->nbl_list) && !list_empty(&nbl->nbl_lru)) { @@ -7928,7 +7928,7 @@ check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner) if (flctx && !list_empty_careful(&flctx->flc_posix)) { spin_lock(&flctx->flc_lock); - list_for_each_entry(fl, &flctx->flc_posix, fl_list) { + for_each_file_lock(fl, &flctx->flc_posix) { if (fl->fl_owner == (fl_owner_t)lowner) { status = true; break; @@ -8459,7 +8459,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) if (!ctx) return 0; spin_lock(&ctx->flc_lock); - list_for_each_entry(fl, &ctx->flc_lease, fl_list) { + for_each_file_lock(fl, &ctx->flc_lease) { if (fl->fl_flags == FL_LAYOUT) continue; if (fl->fl_lmops != &nfsd_lease_mng_ops) { @@ -8468,11 +8468,11 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) * we are done; there isn't any write delegation * on this inode */ - if (fl->fl_type == F_RDLCK) + if (lock_is_read(fl)) break; goto break_lease; } - if (fl->fl_type == F_WRLCK) { + if (lock_is_write(fl)) { dp = fl->fl_owner; if (dp->dl_recall.cb_clp == *(rqstp->rq_lease_breaker)) { spin_unlock(&ctx->flc_lock);