Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1968721rdb; Wed, 31 Jan 2024 15:14:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3YSlSwk9AklN9dLCf3IUulT76jc5BGU/+DYQ0m9WbnNjcXwyvOCkaMkKbA/Hom8Ee/Y67 X-Received: by 2002:a17:90a:e398:b0:296:3ed:e7e with SMTP id b24-20020a17090ae39800b0029603ed0e7emr445432pjz.9.1706742841185; Wed, 31 Jan 2024 15:14:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742841; cv=pass; d=google.com; s=arc-20160816; b=dmLjLFd0dboDJVqoirLa7TFvHu/i5W/6AHwQrc/uN3EZQCJ9wdWKDIhveFvXXjEkL4 8SaOZzkp9r3ANPhWPzU0m64ulOZ/NCsfn+c4bXwMbCBMQJ+N5AEnTN15s4Ic6x57i1dE mOue8jbjjLrrL40UYyA+4hDrLsDyti1bXi0S/dareZ9nlmosHcA6SHwegalHp3yYNjW0 klTNgZuSlrI2Oe80sNGp9z1F7ngg4xVackHzXjUWCWJn93/nAl6v4xlyl3LDGEzC9h8f ZhyWU102kvoofRZ1WnXaiLso59t3I2LFynHcq4S3GxQU0FNRZjIFKTI6qIG6YLpHhGiL C/ug== 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=A00wNC8483i1JUjzM02cSiu3UfUHGNWSAy5WTQpdt1o=; b=TR7ZfHme8iB42PaXCfV/6n+6hPnxW4VzSSyUwGOh2ciuGNFgjCSySEGTdiCSQvmbPM Xj4fMQogfYAN6+3vN9kb9xwj27Ie2UBwn0lfmYYzbQdIDCfQTS2us8fUmvmatbHDhPcX kBi8kCmGI6H4THCELSD9h7P35gNZizsW811bq+6iWecYTEudXsbksstJoufnLdB/K7Xr 3Nj+lEm2KZ89KJTFB5XxK87H8Bs/ROLycYDFYy+b8kN2t1Ym8CKpgxbtFCgFMoTA3hJ8 2l8mPispiEyQEOZ8RHX1rFNA0pfI/yhz89TkuvhYHMZhV1+KQuquClLKOHsyNLf1W9zv kDDg==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47298-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; AJvYcCX5WCAmN33HHPaKCgSHUUIwhtwCaazSYuwXMbEZn7A6YqyURc9mBl20HeMEifLvk1J74qaEWmbW044pyQtRBF5a1Q47bzgPUL1LWWlO9w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 95-20020a17090a09e800b00292cc08e601si2190219pjo.27.2024.01.31.15.14.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:14:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47298-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47298-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 45A0128306E for ; Wed, 31 Jan 2024 23:08:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4648482F9; Wed, 31 Jan 2024 23:03:05 +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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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); -- 2.43.0