From patchwork Wed Aug 21 18:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13771942 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 705AD199926 for ; Wed, 21 Aug 2024 18:07:14 +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=1724263634; cv=none; b=Ts0TK91CiGwDF9Ygqj/H7j7cxU6etoS60e12eHN1MDT0G0NyI4bb4f2A5/3cuWgsL5nYM9hPBceUicWHKkbBZqggB0z57UQqhDaL4PkezcybchChjqEtveGrMXHUIO8ZdAJpC2Rj1+Zq8fA7+Xrj/Qkn7UIWwGO+1EO3uWWEQek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263634; c=relaxed/simple; bh=QQPLw3EIGYPA36/aWNW4ooZNMGb8m6xy9XH1KESc4I8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q08c7dBNlCyg/+bd/eEYbLdsdLOz7f99cukisTiTDAbJftLLl4YQYhPAAJvok96W0387X/Ha8MUaQSwCPKrU/2g3FCn2Ej/Yf8duYH1z9b0Q/XSGCiALNv1Lbij5y8lGUR+x96PStu1niCWz5TE+T7JynKYsQhHuUjNTBl60vlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XHMzeECx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XHMzeECx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8FF8C32781; Wed, 21 Aug 2024 18:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724263634; bh=QQPLw3EIGYPA36/aWNW4ooZNMGb8m6xy9XH1KESc4I8=; h=From:To:Cc:Subject:Date:From; b=XHMzeECxHIaCTpJ2ZvhurCfJtTLKA/cRumSGIEB1Ez7h5MmKXUMo39F+GTkLdNBPH 4GQtLpOeeuuQa6gL4BycfmDS4Sem41WnAdJIX2cCNMfDdWw+ww2tyK0MBAz9c/p1Mg ucOo4PHoMqTmOTYaOyM7JCSAJEbJpA9KK/s79Tixtaff7wFQJdFQqS3jktJe3I2Xkd RGTrax7DSH4TqQgmcVh9BLCXjjFp2MZervYrbk1BAdlK9Vc5kEGOBDQIiuYcbNqIsX 4nDEIgeYy+fmgG40ILR4S9+wm3wbh8jrrvv7XEi5H0gfRKv7KkVf3DVx2R8kEddGng IQo8ggKqbiszw== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/3] NFSv4: Add missing rescheduling points in nfs_client_return_marked_delegations Date: Wed, 21 Aug 2024 14:05:00 -0400 Message-ID: X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust We're seeing reports of soft lockups when iterating through the loops, so let's add rescheduling points. Signed-off-by: Trond Myklebust Reviewed-by: Jeff Layton --- fs/nfs/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index cbbd4866b0b7..97b386032b71 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -228,6 +229,7 @@ static int __nfs_list_for_each_server(struct list_head *head, ret = fn(server, data); if (ret) goto out; + cond_resched(); rcu_read_lock(); } rcu_read_unlock(); From patchwork Wed Aug 21 18:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13771943 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 BBE901B2EFE for ; Wed, 21 Aug 2024 18:07:14 +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=1724263634; cv=none; b=YwCnwOwhdZeUWtr3za6IMyLWMKreciUzPUMABK4l3Zlr5jLSoDNXqJLGbXkItIjdqmL+IGkfh0+iKcIwDz6XbFuqX/PVeKpAUZckDY27PgYW2yEDcKqLXXIcOjqET4lWdy/ZBN6T2ePSL9ItrewB7CXomaZUQFg3yQyACgpZ9Dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263634; c=relaxed/simple; bh=ypAZ3CyKq507gWVKGe2b2IRjoQ6G3MNFB2klTRf/QBM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kuPXXW75b/EmPyLpJTuFEkFr7KfNc4ZQoW8LWL2CnLjZ0HyuXlFHqa3Qf4NzIteG4e2v2ZjnAhEMK8uULUxVxKjpO9ZS/FiA2/C6H27VzRWdLH8NoN8a0rdW3jODaYque5JkdMFH6KsxNPY+852eQaVSyjjuQ5OVGyWvT81QOkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iz59sbO6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iz59sbO6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3663BC4AF09; Wed, 21 Aug 2024 18:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724263634; bh=ypAZ3CyKq507gWVKGe2b2IRjoQ6G3MNFB2klTRf/QBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iz59sbO6m+KIAd+zI3JyKUo1g+mifTN9mxlvB/08i7uNbUxujCfZ8RQDPDV9jL/cq nHK+d/zBHfy85RNA9Bx7C1qM81zBPqAhh2+mOlLEJMPP3jVdObDtkXzMcs9XfyGsuY nWESVoXW07XTm5WUVTiKj8o4RVXM6hY6FVc5Z0I8Nj/ltlI7s+O3vlucEOaqo9CbKH QlsOvHGsucOgcupsmUiSCLGK+L0fPxTsN4cPhvXVw5v2CVvVcYLgdg4RpPnUbjCQix vWpEsNwG/2MIN8Mub5wNpRVZDpZsSo9qj6Vnnb5WdgPV3uJ2w4HnhYpr5/dyeebX0h LvLQedKcFX+7w== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/3] NFSv4: Fix clearing of layout segments in layoutreturn Date: Wed, 21 Aug 2024 14:05:01 -0400 Message-ID: <219bcbc91166e476ef996901ae8f3ddb2278d166.1724263426.git.trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust Make sure that we clear the layout segments in cases where we see a fatal error, and also in the case where the layout is invalid. Signed-off-by: Trond Myklebust Reviewed-by: Jeff Layton --- fs/nfs/nfs4proc.c | 9 ++++++--- fs/nfs/pnfs.c | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 8883016c551c..daba7d89a0cf 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9997,6 +9997,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) fallthrough; default: task->tk_status = 0; + lrp->res.lrs_present = 0; fallthrough; case 0: break; @@ -10010,9 +10011,11 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) task->tk_status = 0; break; case -NFS4ERR_DELAY: - if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN) - break; - goto out_restart; + if (nfs4_async_handle_error(task, server, NULL, NULL) == + -EAGAIN) + goto out_restart; + lrp->res.lrs_present = 0; + break; } return; out_restart: diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index aa698481bec8..0d16b383a452 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1284,10 +1284,9 @@ void pnfs_layoutreturn_free_lsegs(struct pnfs_layout_hdr *lo, LIST_HEAD(freeme); spin_lock(&inode->i_lock); - if (!pnfs_layout_is_valid(lo) || - !nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid)) + if (!nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid)) goto out_unlock; - if (stateid) { + if (stateid && pnfs_layout_is_valid(lo)) { u32 seq = be32_to_cpu(arg_stateid->seqid); pnfs_mark_matching_lsegs_invalid(lo, &freeme, range, seq); From patchwork Wed Aug 21 18:05:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13771944 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 EF9B81B2EE2 for ; Wed, 21 Aug 2024 18:07:14 +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=1724263635; cv=none; b=L8Bso1YV3eRHmggrWqdKTWQ8XloMCb8MISkcxbYOxtMR58czXWbXumJxqwrfkBwr3xh1x0SnjkdmSMYePgTZSw2Ztn97Ue83+xOlBlwH9YgNSdqFE1mD8ldmc9l8RZljlyp7kwS129/yQL46Q7OSw3Hq0oWwH+fdTh7KvCykxpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263635; c=relaxed/simple; bh=eHJj2SmhuEHcfVH/vtUFAR/Gy9AITO/Lp3HaONhdx64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HTXmHO57hK/kg4cvE7aMgsHTxpmYlNQgfoh+pJE0TCV/50l1zN12Y3295OhXLHHvMT8TCIMLGBUdbXKIab/IZs/02RhG9uSQGiTq3mxXrw9Jh2Y16iX5CnGqyxVt6ZJNidCqYK+Emt/BRo5u+KqhUexjQxBcEtCwKFdpfR6zILs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MxcFX87L; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MxcFX87L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96C8AC32786; Wed, 21 Aug 2024 18:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724263634; bh=eHJj2SmhuEHcfVH/vtUFAR/Gy9AITO/Lp3HaONhdx64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MxcFX87Lnk0R/6R2/pejvXKUgdDPWLBcGA7nzr04WweZ1ZQC9VRVw8raNcLlokgRK w63wZWXPbobDTgwN7HOzkNbB9ftEzaj4rhEvJBbPTZwqsrCnNbD+Fkp1Qua6+fgT+q 5seKPG0ervhveA+bQGBkhH7imiT0h/ei58o3iI9qcD5G6JEdklNl3563/ZSqHux3Fs oPUwmvgnJXPo44Gp+DdQ+Uq6oU0SzVsgXTM4MtVhpF4/UHZ2wYtuM4J2HLr2FHHXBL MyJMG89ABDcb1JTE8BG8Y2NPUhb3VQHEzHt2rdtZf7o6kKtMjljY4tfnxR5yoR/NAI oxZrRaU1SWvhg== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/3] NFS: Avoid unnecessary rescanning of the per-server delegation list Date: Wed, 21 Aug 2024 14:05:02 -0400 Message-ID: <3fe20b13641fe569107f1474d17befd8caa0b076.1724263426.git.trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust If the call to nfs_delegation_grab_inode() fails, we will not have dropped any locks that require us to rescan the list. Signed-off-by: Trond Myklebust Reviewed-by: Jeff Layton --- fs/nfs/delegation.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index d5edb3b3eeef..20cb2008f9e4 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -647,6 +647,9 @@ static int nfs_server_return_marked_delegations(struct nfs_server *server, prev = delegation; continue; } + inode = nfs_delegation_grab_inode(delegation); + if (inode == NULL) + continue; if (prev) { struct inode *tmp = nfs_delegation_grab_inode(prev); @@ -657,12 +660,6 @@ static int nfs_server_return_marked_delegations(struct nfs_server *server, } } - inode = nfs_delegation_grab_inode(delegation); - if (inode == NULL) { - rcu_read_unlock(); - iput(to_put); - goto restart; - } delegation = nfs_start_delegation_return_locked(NFS_I(inode)); rcu_read_unlock(); @@ -1184,7 +1181,6 @@ static int nfs_server_reap_unclaimed_delegations(struct nfs_server *server, struct inode *inode; restart: rcu_read_lock(); -restart_locked: list_for_each_entry_rcu(delegation, &server->delegations, super_list) { if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags) || @@ -1195,7 +1191,7 @@ static int nfs_server_reap_unclaimed_delegations(struct nfs_server *server, continue; inode = nfs_delegation_grab_inode(delegation); if (inode == NULL) - goto restart_locked; + continue; delegation = nfs_start_delegation_return_locked(NFS_I(inode)); rcu_read_unlock(); if (delegation != NULL) { @@ -1318,7 +1314,6 @@ static int nfs_server_reap_expired_delegations(struct nfs_server *server, restart: rcu_read_lock(); -restart_locked: list_for_each_entry_rcu(delegation, &server->delegations, super_list) { if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags) || @@ -1330,7 +1325,7 @@ static int nfs_server_reap_expired_delegations(struct nfs_server *server, continue; inode = nfs_delegation_grab_inode(delegation); if (inode == NULL) - goto restart_locked; + continue; spin_lock(&delegation->lock); cred = get_cred_rcu(delegation->cred); nfs4_stateid_copy(&stateid, &delegation->stateid);