From patchwork Thu Jun 13 05:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696115 Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC5B3131E33 for ; Thu, 13 Jun 2024 05:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255227; cv=none; b=RECF3eixfLlJMKKqlbCKc/vdrqLjVu8zqNCeGo9PRhiatdv2LXBd5b2IVWFroF5ZxHMQzAu6Ms8JVYuykd8KvM8koe+rGBqkBbjMfSRLXsYVhh4eVFVGzlFuGX8CbDHBTjB1bRYJ1JfLgsQKNMjky7jqoYaf6NyrmCuuU7LVxcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255227; c=relaxed/simple; bh=I/fSEgCwaXQ1JmLqmzs5nyD+/J6/JeaaClTY/1UsuUE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hARtuuz18994PhM5ZMlty5Q8cWTKQnLfMrXSvHY3fo3UM4i1NvA9MzP/l/NGvU9UygR5CURPzQl8kx77iKVUQ50TEUiyH3V5BIlj8Nq870gI221B3BAwLzXbG+PktxjgLovp7RrNttUVfWn6DFwpHaKgHixTSuGKGdY2mJqw0oU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M1VJ0sff; arc=none smtp.client-ip=209.85.219.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M1VJ0sff" Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-dfef5980a69so706717276.3 for ; Wed, 12 Jun 2024 22:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255224; x=1718860024; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=BREbmmDaPNq4NqcMp3Sku2uf9WgvnITc3SNlmS6RNxU=; b=M1VJ0sffNkxt3XfOdk508mG/Rq6k8lur8BBhhhrysfYwwAjs5aaGBVYzHXraLng2gj QCa2IakfdyrNGVKDmsvR2Ebz+uY1S27M90eY9nLs9WOECGmHdIE8cOllXLwUa5EzsFhN hG1eJxUXb9LtecQyNXQwiFXXEOzppUW2sfy4AjYloyLbMDHi9hN2J2cIJRaZy4HTJPkX WwxmvEYTqP/1/PQTGFPdPL8IL3QV/hIOBwVF0YmOXSUeQ0IJUozCDH9rb3HeEY2N8CEf y7gF6xbnijoqNG+SO5qipIinIntetIOXPcG+UY1ITVhiZMuwSlNcV5oaZitNiUMr0Cqq p9rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255224; x=1718860024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BREbmmDaPNq4NqcMp3Sku2uf9WgvnITc3SNlmS6RNxU=; b=etmqzEIN5PC7x9jsUJlMAlw+k7yS8geAy2qMVmbE7eTsX92tTcq3tbKkypW4zdgWk4 2MzrSCITuKdpz7abNnWIQ3xHVaJcFap4oV4166ObmX8Ap2DrI6oecF8UeZ0PJ++lBzK9 2JeFzO49TeVz3M8PAUXt1+vVn3OaEL0J9NijJNrLRJz52BuCe2hPQri7m9qVxCTokd3q 4UN5H00Q3NTpFwm0eldA77FIYeDExZWAXqEhDw3QB9K5e/gDoNGtr6aXrqEAkvlL36Kz ip9EQdEi4uh03SZnwxp5IV3aXCJvdEEctDag0vLEESfz8xlYEtX7Fne3oqOykw6lQpWZ ZX8g== X-Gm-Message-State: AOJu0YzWPtU53HRXhnOj/MioN5kvQTw2Ee0edQypNiCK+ppafJPh4Cfd mB4aSVa2hRYBkqKa5s1H3OX9OfZQzaacTUI4TR+lNutcbM9VDHOAyEPG X-Google-Smtp-Source: AGHT+IEQgYxQNcaTkNrCQRv6MiFkQJOIwmqLWp4JvqzO/UZlIllDdaRWIalUQS8MxbhIXM6ln3msnw== X-Received: by 2002:a25:db03:0:b0:dfe:3e59:5a94 with SMTP id 3f1490d57ef6-dfe6891fc68mr3702806276.47.1718255224024; Wed, 12 Jun 2024 22:07:04 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:03 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 01/11] NFSv4/pnfs: Remove redundant list check Date: Thu, 13 Jun 2024 01:00:45 -0400 Message-ID: <20240613050055.854323-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-1-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust pnfs_layout_free_bulk_destroy_list() already checks for whether the list is empty or not. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index b5834728f31b..bbbb692b2a47 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -923,8 +923,6 @@ pnfs_destroy_layouts_byfsid(struct nfs_client *clp, rcu_read_unlock(); spin_unlock(&clp->cl_lock); - if (list_empty(&layout_list)) - return 0; return pnfs_layout_free_bulk_destroy_list(&layout_list, is_recall); } @@ -947,8 +945,6 @@ pnfs_destroy_layouts_byclid(struct nfs_client *clp, rcu_read_unlock(); spin_unlock(&clp->cl_lock); - if (list_empty(&layout_list)) - return 0; return pnfs_layout_free_bulk_destroy_list(&layout_list, is_recall); } From patchwork Thu Jun 13 05:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696116 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61C6E131BDF for ; Thu, 13 Jun 2024 05:07:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255227; cv=none; b=o+lfMN80dS3ccm90/aqx+Eh+9GMaj/4l2Q34Lv205qLPIYnAZapEnqLdckI19RCp+j0MrQJVtkaoiNIPvkwjqWtIUxr+dbGGHaVT5xyV45xetRuLzUC8IkZg9RxmJyf1vLZ5nPMmRNYu9Y0xyUdkVo1VSy5u5EhyeEaCZvS19es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255227; c=relaxed/simple; bh=CUek43QMrepAFh0fuXJPwtkz5MUUdrtLkRUjfji+lyE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PphlvxhPObL0yMaxr/4auaiVmnxPrFLROinsIHeoe4cLpbrwl27DFHloXlSG4FIRYioYn/vd92OnRKShIgtNiPMSFfG6qq1MCTAFXQty246WVVKF0IohqycAAe4yZe/rDwt7c2iy3gjApYZaLai3WCHZhBbfSWhcObO85LovW9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bVmTMOWg; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bVmTMOWg" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-797a8cfc4ecso34744785a.3 for ; Wed, 12 Jun 2024 22:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255225; x=1718860025; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=AXVYNIM3ySb8hyMlrwzCwsvmVbam1K3t/jNlIKoSsrI=; b=bVmTMOWgGYrsfiu+P9PHLc6hhe8iM/vVdipYnlc9GUsAApJmVytwLP5FWyANwubg7C b8vCX13eAMhgJw53di5oZTzAkrf5X3DwcIP9/qaG0khM2QgNoTrAZKQeiIvJiaFQjLr4 OzYwXgy/CVqI6w9CKjSTvrp7m/VhL4OnJKa1KOanpncwtp8NGJLfgGU99+GRxSgWtYOX oev8dMMml8E07WTE8DpdIqcAjlbSQs/7+LWHGNvO7sDXu4ycCh0DydYo3Sv4fQ3a6adG 6LfQkD9ysfpb1YLA/k2rq2VbVqfHxjlBAkUI54Qerj7SXYkD8jn6K1UuE2T4xgiDdCy2 sDOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255225; x=1718860025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AXVYNIM3ySb8hyMlrwzCwsvmVbam1K3t/jNlIKoSsrI=; b=OfDNiCIzBp9d0+Ssr90oLxWbdYEKgAaKXJcmbdWQKFuaGTEmq3XSUypphlxi+9046b h2r6Ss5z0mSJRn4HAtxUeNvxMlOL0naKvHgoYNPgB9bgfMhFv1/FIubaIquY+8FXXEsa +C8L5ly0JgEhGYV37kUsukRQW5QBTdok4XgY0BelP2AKUoVPAQqsCVdRXvGBrfS0MYWM Fin6rScNdWIyf5bR+U19ZdVXb7apWy/5LChWYpdtoEeOdmDGAPWChlcoinQnrKI1t81d 1IUzUWEGC6BtyNnODXOz9jbMIsxX7XDtUnKshJpgJeHbXLR7qmkNQ40flQKZtTWq2+mA 83+g== X-Gm-Message-State: AOJu0YxlP8qwY0vXSSJ15hktTH3vnct4L2nUZC2Jfcqp2C3EJhnCuKMv RBe9znLOeBhw3KrGo59T2Xgmj0Kiv9iXbwGI+AnCKHeuQwR3NXrSLPZc X-Google-Smtp-Source: AGHT+IGRRFqW1ZEMXFmqXRhb1U12FebxPrimCb8ni+vz8O0c9KyX6jVTjJDGcHPeTEdusmxxOIdtLw== X-Received: by 2002:a05:6214:5b83:b0:6b0:71c0:cbaa with SMTP id 6a1803df08f44-6b191e3bfa4mr49168096d6.33.1718255224643; Wed, 12 Jun 2024 22:07:04 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:04 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 02/11] NFSv4.1: constify the stateid argument in nfs41_test_stateid() Date: Thu, 13 Jun 2024 01:00:46 -0400 Message-ID: <20240613050055.854323-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-2-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 3 ++- fs/nfs/nfs4proc.c | 24 ++++++++++++------------ fs/nfs/nfs4xdr.c | 2 +- include/linux/nfs_xdr.h | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 7024230f0d1d..c2045a2a9d0f 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -67,7 +67,8 @@ struct nfs4_minor_version_ops { void (*free_lock_state)(struct nfs_server *, struct nfs4_lock_state *); int (*test_and_free_expired)(struct nfs_server *, - nfs4_stateid *, const struct cred *); + const nfs4_stateid *, + const struct cred *); struct nfs_seqid * (*alloc_seqid)(struct nfs_seqid_counter *, gfp_t); void (*session_trunk)(struct rpc_clnt *clnt, diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index a4f85af880c2..ae835d14ac75 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -103,10 +103,10 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, const struct cred *cred, struct nfs4_slot *slot, bool is_privileged); -static int nfs41_test_stateid(struct nfs_server *, nfs4_stateid *, - const struct cred *); +static int nfs41_test_stateid(struct nfs_server *, const nfs4_stateid *, + const struct cred *); static int nfs41_free_stateid(struct nfs_server *, const nfs4_stateid *, - const struct cred *, bool); + const struct cred *, bool); #endif #ifdef CONFIG_NFS_V4_SECURITY_LABEL @@ -2867,16 +2867,16 @@ static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st } static int nfs40_test_and_free_expired_stateid(struct nfs_server *server, - nfs4_stateid *stateid, - const struct cred *cred) + const nfs4_stateid *stateid, + const struct cred *cred) { return -NFS4ERR_BAD_STATEID; } #if defined(CONFIG_NFS_V4_1) static int nfs41_test_and_free_expired_stateid(struct nfs_server *server, - nfs4_stateid *stateid, - const struct cred *cred) + const nfs4_stateid *stateid, + const struct cred *cred) { int status; @@ -10357,12 +10357,12 @@ nfs41_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle, } static int _nfs41_test_stateid(struct nfs_server *server, - nfs4_stateid *stateid, - const struct cred *cred) + const nfs4_stateid *stateid, + const struct cred *cred) { int status; struct nfs41_test_stateid_args args = { - .stateid = stateid, + .stateid = *stateid, }; struct nfs41_test_stateid_res res; struct rpc_message msg = { @@ -10418,8 +10418,8 @@ static void nfs4_handle_delay_or_session_error(struct nfs_server *server, * failed or the state ID is not currently valid. */ static int nfs41_test_stateid(struct nfs_server *server, - nfs4_stateid *stateid, - const struct cred *cred) + const nfs4_stateid *stateid, + const struct cred *cred) { struct nfs4_exception exception = { .interruptible = true, diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 98aab2c324c9..4bf7d5c09282 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -2137,7 +2137,7 @@ static void encode_test_stateid(struct xdr_stream *xdr, { encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); encode_uint32(xdr, 1); - encode_nfs4_stateid(xdr, args->stateid); + encode_nfs4_stateid(xdr, &args->stateid); } static void encode_free_stateid(struct xdr_stream *xdr, diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 01efacae4634..45623af3e7b8 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1438,7 +1438,7 @@ struct nfs41_secinfo_no_name_args { struct nfs41_test_stateid_args { struct nfs4_sequence_args seq_args; - nfs4_stateid *stateid; + nfs4_stateid stateid; }; struct nfs41_test_stateid_res { From patchwork Thu Jun 13 05:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696117 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B195313210A for ; Thu, 13 Jun 2024 05:07:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255228; cv=none; b=DdpQaJQC4bbvMK7OyGlX9dlPwN1q6CVV73D0CDi95f18MxDnm7qzwxXNK/yU26cfJ7t/p1x/EaSrZ6UYnY32M9mVDkKhA2mU0wt73/9AJWzn2htn4OoNBbUR/lpGEEwqNXwASa8GziRsJmggcajEPjp0AJHbHcjvLUkF4oH+ru0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255228; c=relaxed/simple; bh=CdANIOaNsG8iASQaX0gla21G3OnBWY7i2Ee32nL8g4g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jg4Np8GB3+juD6dtttD0jL0PoODRq/Ggfy4j4eaG+rNPMe04Wy9yxyy8eUvr14u1WpzaQSuQQUJMdB7RHDk2Ph31SIZ3l/RqF4TZM2kt+wPG1ql6Szww/V32OWrA8kMFmq1wrzLXrXxj2kQHXfiFbM4j9YuYvMiSwmuSA3j8hSc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JD2pCDVL; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JD2pCDVL" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6b06bdbf9fdso3568636d6.0 for ; Wed, 12 Jun 2024 22:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255225; x=1718860025; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=iy//GQLlcZ5aHkYIb8MscB8H27aF06UkdefW9lmLNCA=; b=JD2pCDVLLZLdNHkkPZUU7xIYFxdQmQ9gZz1X+LLZV4i+eH8vJSazJnqyEUd4j/40Zx qrB5PWHtCnOW/gX9JY0DLo8+EMqu6B1toqunvoY+aCVG1OPjF86EXAlz3oWZugdYrzGR zGwF5whLcw2M3CaWVDv5UThekSiaGuRlJlBkxnJ4kq0KCC0sAARirXeUc+HRtp6yDkVp GOGaF21ReRauQIL3qPWSoeTrDsOQ9O9bX/wOUO+78RGq7/AIrMFGNzEQ0WH2hW5vcZRI nqkWpPpdOGyjxwxo7Ac9Ng1myVNddSuhGBuudbP24Bd3LZvT1uZkgOglE6T6tIjHA1Za 12Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255225; x=1718860025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iy//GQLlcZ5aHkYIb8MscB8H27aF06UkdefW9lmLNCA=; b=HT046dPbU9vDl0vPoh3hgadHOWzulwr+A59SeZp8V1IdSCGokgN+/z0r5KfEn1Va1D K78bJjk+yWk/io0fj+ndbY+DjUsEiQbBVmT4ClU45H1soMiAuNVex00QEnU/Xr7meA6R HCzHp8bZVitNcdaJsuCSNLzsohHH+WdQCoPvYt6KUsuj4OQ0XfBzAQITkxraaEKyPEwT ZuPGTJ0j17U791QoxgutMFrNHv1QSmUN/WuvPrQABG483V/cNvyPQtCMpEO3YQF24KZj LAqFWe2qybDsJR3tVoTJEhlcuzz2JHf5UjVaS/cY2PZHJilLM/niJD5IpEAFTtfMcYfw S6Gg== X-Gm-Message-State: AOJu0Yyzn5bmIeyVJZjn8lfVMan8KSHN4Aah3OcJDW06fCcT2fCtBFxw llVK/gChR1uuGmiWqXC7RYWp99YC7ZTS7x7E4bvW/MJ+llTClYr7C/Lx X-Google-Smtp-Source: AGHT+IHcaqVRCCLFoXjAVYYK+QDu7nH/mg1uNh04sJmX6Ln3d9t3Qn89jckU6nVENv0dVWJkNThnnA== X-Received: by 2002:ad4:4484:0:b0:6b1:e371:99d9 with SMTP id 6a1803df08f44-6b1e3719b2dmr31717346d6.8.1718255225197; Wed, 12 Jun 2024 22:07:05 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:04 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 03/11] NFSv4: Clean up encode_nfs4_stateid() Date: Thu, 13 Jun 2024 01:00:47 -0400 Message-ID: <20240613050055.854323-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-3-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust Ensure that we encode the actual stateid, and not any metadata. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4xdr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 4bf7d5c09282..7704a4509676 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1067,9 +1067,10 @@ static void encode_nops(struct compound_hdr *hdr) *hdr->nops_p = htonl(hdr->nops); } -static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) +static void encode_nfs4_stateid(struct xdr_stream *xdr, + const nfs4_stateid *stateid) { - encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); + encode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE); } static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) From patchwork Thu Jun 13 05:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696118 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9E0C131E33 for ; Thu, 13 Jun 2024 05:07:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255229; cv=none; b=GWr5042emFMq6OoDedznOLXQA+YHMXK71dw6taLstRuiRyj3MaEqU8PX2apcegDS0GoRUpjhmFxUfk6cbyg3166sHKM1DpOGZKJtxnf/4d8UXgPmeoVUQ48Y0QN6NNm2azwaWEdRnuVvCKWwImvYjAPG0LF10YeVbAB1XyeZJO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255229; c=relaxed/simple; bh=SHJGL2LLldrprrV2HH/Loa0SAXdAhcU15rnhOwaZPtg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KxacMb/UEC7khb++tgsK7OYQc4aqVDtMjpWyYqR0+O23BU3YGmKazgY15itEolhRWRfe0nb26oLuZuMVPqqQsouGReoZcFvYBWJNFPQ8UBUJD88vlQKdbnN4/Uf30EBIlhwDHyHch13ZeKtYysySNcUnGE3AgBkohvf/UL3L5PQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jT0z9qhm; arc=none smtp.client-ip=209.85.128.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jT0z9qhm" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-62fffd5d36bso7255747b3.2 for ; Wed, 12 Jun 2024 22:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255226; x=1718860026; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KZCB+D9naYo0Z2ERgDE24DcBCSvH0W2aKyk9RZMcA7c=; b=jT0z9qhmIUY6UB8WLTz+elI3YJey37G0JxPUeW1KpaJen50O6gkn00Y/5IrAww/H/t 5vN9gqy42vjiCRMYITJygY24i0VQJOM5oLXAi/fI5b4jti6H5+4yszg9PeKtWwdOGYxh +LdqgmTTHkqOu1TJXMrtrNkFkdIXCpP4Lj16+5iNmuScQhTTdiXchrCalKCEmwoRSah4 hq/KKVBRTsn5FgMkYmqZoN7rdv25FFUmvoByD4WOZPZBgvM65hSQ73y66a3S2t8Xy64a 2qtPyqLqy5i2wG2FrP8mn+7IQFBWzZVQIQVpfpO55nX16zVq0uqLDMrd+WsTP5agv+vT JwGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255226; x=1718860026; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KZCB+D9naYo0Z2ERgDE24DcBCSvH0W2aKyk9RZMcA7c=; b=ZVYliMVkiNDOZfgHIDWHZ8e8MMm8wjCY5pGMOMPT7t6j/VNVk/kPP7lv3wT4LZAZXQ pw5gRdkq7KdmtkJPgs4T6RKcUXyOb9s69XG6xiuvbC3mb7EHABE3p+4GA+nGjAxdXW+m wnkDl1KejfDR4+ZgHJcKew6j4YUGse7JfSc3YzdkiJB1NGipNvLUKio95us+FO3ck1SB 2HxBpqg3Li51aYyzngDAVjuzDoVaBBZS9rCxz3QZXidzsBjaTbuwREURaDUPbNFabQJR jq3amRmpG1bpwX2b8vX2KQYrgJK3i6UNs8Q21pzFlh3WW5C08exd2PE1e6O3HjbYiJ8n togg== X-Gm-Message-State: AOJu0YzrY5eAMNTL32FEkjIH5UQJAXP9WfG97+6npH/OVh8c4+Tl1+XG oira8cZY9MgxpQeIlCYwI3GyLkuSSE5B1z65Gd2pwhQVLO7vaz0Gef2m X-Google-Smtp-Source: AGHT+IHOE1de4p1DVWmxjSY3gJMeo8tZ5NjueaSO71qgSJOXEsCgQkBt8K7S8p/SY0CPx3SJ8pdx0w== X-Received: by 2002:a81:b641:0:b0:627:89be:397f with SMTP id 00721157ae682-62fbb8edcb6mr37396407b3.4.1718255226243; Wed, 12 Jun 2024 22:07:06 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:05 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 04/11] pNFS: Add a flag argument to pnfs_destroy_layouts_byclid() Date: Thu, 13 Jun 2024 01:00:48 -0400 Message-ID: <20240613050055.854323-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-4-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust Change the bool argument to a flag so that we can add different modes for doing bulk destroy of a layout. In particular, we will want the ability to schedule return of all the layouts associated with a given NFS server when it reboots. Signed-off-by: Trond Myklebust --- fs/nfs/callback_proc.c | 5 +++-- fs/nfs/pnfs.c | 21 +++++++++------------ fs/nfs/pnfs.h | 14 +++++++++----- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 199c52788640..7832fb0369a1 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -323,9 +323,10 @@ static u32 initiate_bulk_draining(struct nfs_client *clp, int stat; if (args->cbl_recall_type == RETURN_FSID) - stat = pnfs_destroy_layouts_byfsid(clp, &args->cbl_fsid, true); + stat = pnfs_layout_destroy_byfsid(clp, &args->cbl_fsid, + PNFS_LAYOUT_BULK_RETURN); else - stat = pnfs_destroy_layouts_byclid(clp, true); + stat = pnfs_layout_destroy_byclid(clp, PNFS_LAYOUT_BULK_RETURN); if (stat != 0) return NFS4ERR_DELAY; return NFS4ERR_NOMATCHING_LAYOUT; diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index bbbb692b2a47..0e188bc303ee 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -868,7 +868,7 @@ pnfs_layout_bulk_destroy_byserver_locked(struct nfs_client *clp, static int pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list, - bool is_bulk_recall) + enum pnfs_layout_destroy_mode mode) { struct pnfs_layout_hdr *lo; struct inode *inode; @@ -887,7 +887,7 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list, spin_lock(&inode->i_lock); list_del_init(&lo->plh_bulk_destroy); if (pnfs_mark_layout_stateid_invalid(lo, &lseg_list)) { - if (is_bulk_recall) + if (mode == PNFS_LAYOUT_BULK_RETURN) set_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); ret = -EAGAIN; } @@ -901,10 +901,8 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list, return ret; } -int -pnfs_destroy_layouts_byfsid(struct nfs_client *clp, - struct nfs_fsid *fsid, - bool is_recall) +int pnfs_layout_destroy_byfsid(struct nfs_client *clp, struct nfs_fsid *fsid, + enum pnfs_layout_destroy_mode mode) { struct nfs_server *server; LIST_HEAD(layout_list); @@ -923,12 +921,11 @@ pnfs_destroy_layouts_byfsid(struct nfs_client *clp, rcu_read_unlock(); spin_unlock(&clp->cl_lock); - return pnfs_layout_free_bulk_destroy_list(&layout_list, is_recall); + return pnfs_layout_free_bulk_destroy_list(&layout_list, mode); } -int -pnfs_destroy_layouts_byclid(struct nfs_client *clp, - bool is_recall) +int pnfs_layout_destroy_byclid(struct nfs_client *clp, + enum pnfs_layout_destroy_mode mode) { struct nfs_server *server; LIST_HEAD(layout_list); @@ -945,7 +942,7 @@ pnfs_destroy_layouts_byclid(struct nfs_client *clp, rcu_read_unlock(); spin_unlock(&clp->cl_lock); - return pnfs_layout_free_bulk_destroy_list(&layout_list, is_recall); + return pnfs_layout_free_bulk_destroy_list(&layout_list, mode); } /* @@ -958,7 +955,7 @@ pnfs_destroy_all_layouts(struct nfs_client *clp) nfs4_deviceid_mark_client_invalid(clp); nfs4_deviceid_purge_client(clp); - pnfs_destroy_layouts_byclid(clp, false); + pnfs_layout_destroy_byclid(clp, PNFS_LAYOUT_INVALIDATE); } static void diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index fa5beeaaf5da..a6f9427782c2 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -118,6 +118,11 @@ enum layoutdriver_policy_flags { PNFS_LAYOUTGET_ON_OPEN = 1 << 3, }; +enum pnfs_layout_destroy_mode { + PNFS_LAYOUT_INVALIDATE = 0, + PNFS_LAYOUT_BULK_RETURN, +}; + struct nfs4_deviceid_node; /* Per-layout driver specific registration structure */ @@ -273,11 +278,10 @@ void pnfs_free_lseg_list(struct list_head *tmp_list); void pnfs_destroy_layout(struct nfs_inode *); void pnfs_destroy_layout_final(struct nfs_inode *); void pnfs_destroy_all_layouts(struct nfs_client *); -int pnfs_destroy_layouts_byfsid(struct nfs_client *clp, - struct nfs_fsid *fsid, - bool is_recall); -int pnfs_destroy_layouts_byclid(struct nfs_client *clp, - bool is_recall); +int pnfs_layout_destroy_byfsid(struct nfs_client *clp, struct nfs_fsid *fsid, + enum pnfs_layout_destroy_mode mode); +int pnfs_layout_destroy_byclid(struct nfs_client *clp, + enum pnfs_layout_destroy_mode mode); bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst, struct pnfs_layout_range *dst_range, struct inode *inode); From patchwork Thu Jun 13 05:00:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696119 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9060F135A7F for ; Thu, 13 Jun 2024 05:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255230; cv=none; b=R3+MeougiHLYc5lD5VdJEi1CNt9WCVoLgnZYRGSolbeC/ztC5XghRFBuNfY5uQPAXEGvhalMTjWl/plr8MhwkLfc4W8M5MwqDcBWmn2M1Lg2LIvv7JECLYu9fOw4TeBEmKQzjlhaCtCC7UQ6WURYmn/fDU32QKSqqZjeDBJG5Gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255230; c=relaxed/simple; bh=aT4ooRWy6Q9mHjAJ43jWjy4JB4MBPAdYv6OxUJAusvQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O0xry6bcsiuxe6uFt3ccKPSh9K3LjAUsz+AyZRafkj1rlpLdmSb7Hmz3WDV3bRGfpNxyNxpYjUb7G3wB3If8eFB4Fzsmpiy7in9NFFnMvg4hYnCorvM7hqCRNF+LL0Pz2tcLpfyQoTGuIfImt4DMlc9C07J+h4kzVxUTmuf6I+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Rhed+FoM; arc=none smtp.client-ip=209.85.219.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rhed+FoM" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-6adc63c2ee0so2905556d6.3 for ; Wed, 12 Jun 2024 22:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255227; x=1718860027; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=N+nTzPMvSWl4m5h2cBhbYEHOr/LrU5BlmjvCINmnnkI=; b=Rhed+FoMTI+1tIt2EgDjj9eXqLNC+tBZIt+T7+kILFszm6rUCVY4jvsEd8xir9i2Lb MjOn24RIC+CZ6wLHtc/LgXMb1VtshJcMzjs33sDS4lPeN2YSb/8OQaDQpZuxAipNyMUz Sy64mwRIvF/Bd3crRmk5ZWGEUzlT6IfZu/psZl55tbcEL4l2a3GSfESseDZViHpcfQF6 FYfvMEGK6MDH0rFd0hLg6IAF4IXvtGAXShYKTGAXZG5B87lmEYIJD5JkQHCVLsdpidQG HGTl3X6TfLI7hjS417I7kklJ47CGN3HNPzZZD+XtMJckLXiltiUCZPqY7dg+28YZS7GI fowQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255227; x=1718860027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N+nTzPMvSWl4m5h2cBhbYEHOr/LrU5BlmjvCINmnnkI=; b=TDyzSWdHt+dvmZP5ikN1FEwO6LCdTN5WVSGKeMctF9caDFnxYOSdIAWS+ABay0+aDa BeLso5WjFmTtD7s/eU8aeadlffeVwcBsWH/PCrMWnmYDPuaJquxUrhMfPfWQwKPjJ603 9xh3y4aJYG7TwmJt6T8NlWFJC5I611rCR5Kcr60f5TFb6Fifg/p3gxp9wDupzCYuILu5 y8xrhNyZLDLb0EaNXqLDLuYoUjD53fcviHG5BI3+nxpzDK9SYtkObmXniGOUqyyiarFw Ar/PkMtt7AQngp8ssstO2pxLl3nJWV9Vy7JQageI05CDpnlNCfpDFbd7tvQA0E54MVzp Q1dQ== X-Gm-Message-State: AOJu0Yzi1i28molzDO3cEaRY/6J5vtdkivV1sqmx6fNNCZ4bcV/4I4Mr IvJRpVJTwsSH0hti9wj7DyqgRR4Z+zNr6GkDj7fDkB5f/A6xAux9uf4B X-Google-Smtp-Source: AGHT+IFcR5ftOSwgtWqtUeguDAsUwiIqhPwqTuzwukZ0j6FWbnTKY38JvqdLYFkKpzveaaadqlQclg== X-Received: by 2002:a05:6214:4801:b0:6b0:8b48:f7e5 with SMTP id 6a1803df08f44-6b191778b54mr45047316d6.3.1718255226899; Wed, 12 Jun 2024 22:07:06 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:06 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 05/11] NFSv4/pnfs: Add support for the PNFS_LAYOUT_FILE_BULK_RETURN flag Date: Thu, 13 Jun 2024 01:00:49 -0400 Message-ID: <20240613050055.854323-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-5-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> <20240613050055.854323-5-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust Add a flag PNFS_LAYOUT_FILE_BULK_RETURN, that will attempt to return all the layouts in a pnfs_layout_destroy_byfsid/pnfs_layout_destroy_byclid call, instead of just invalidating them. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 35 +++++++++++++++++++---------------- fs/nfs/pnfs.h | 1 + 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 0e188bc303ee..3bfc74841831 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -476,6 +476,18 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo, return !list_empty(&lo->plh_segs); } +static int pnfs_mark_layout_stateid_return(struct pnfs_layout_hdr *lo, + struct list_head *lseg_list, + enum pnfs_iomode iomode, u32 seq) +{ + struct pnfs_layout_range range = { + .iomode = iomode, + .length = NFS4_MAX_UINT64, + }; + + return pnfs_mark_matching_lsegs_return(lo, lseg_list, &range, seq); +} + static int pnfs_iomode_to_fail_bit(u32 iomode) { @@ -886,7 +898,10 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list, spin_lock(&inode->i_lock); list_del_init(&lo->plh_bulk_destroy); - if (pnfs_mark_layout_stateid_invalid(lo, &lseg_list)) { + if (mode == PNFS_LAYOUT_FILE_BULK_RETURN) { + pnfs_mark_layout_stateid_return(lo, &lseg_list, + IOMODE_ANY, 0); + } else if (pnfs_mark_layout_stateid_invalid(lo, &lseg_list)) { if (mode == PNFS_LAYOUT_BULK_RETURN) set_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); ret = -EAGAIN; @@ -1265,27 +1280,15 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, return status; } -static bool -pnfs_layout_segments_returnable(struct pnfs_layout_hdr *lo, - enum pnfs_iomode iomode, - u32 seq) -{ - struct pnfs_layout_range recall_range = { - .length = NFS4_MAX_UINT64, - .iomode = iomode, - }; - return pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs, - &recall_range, seq) != -EBUSY; -} - /* Return true if layoutreturn is needed */ static bool pnfs_layout_need_return(struct pnfs_layout_hdr *lo) { if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) return false; - return pnfs_layout_segments_returnable(lo, lo->plh_return_iomode, - lo->plh_return_seq); + return pnfs_mark_layout_stateid_return(lo, &lo->plh_return_segs, + lo->plh_return_iomode, + lo->plh_return_seq) != EBUSY; } static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo) diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index a6f9427782c2..8fa0f152ed19 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -121,6 +121,7 @@ enum layoutdriver_policy_flags { enum pnfs_layout_destroy_mode { PNFS_LAYOUT_INVALIDATE = 0, PNFS_LAYOUT_BULK_RETURN, + PNFS_LAYOUT_FILE_BULK_RETURN, }; struct nfs4_deviceid_node; From patchwork Thu Jun 13 05:00:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696120 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5D1E13210A for ; Thu, 13 Jun 2024 05:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255230; cv=none; b=scpRD6yCmTkB8xX3LfuAyb5dCdLKHzjCIzj39QjI/wd1X6xq76+FmlJcv9wmpABGJvdml8IIHrlbeUIReqUrNU6OxWCf9Ar4S9Mnh39RgOMGr8zvkybiarddAZh2EDwKhNoxV60XA/zSYmqG3VJ4a378lOYkxxRt1ETY0Frieak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255230; c=relaxed/simple; bh=LnQsu0aP6BeTihev6r9MalDiCOww0CE+Bb7G0p9mEm8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q3uW/2qvs7ZdXVk+dNlESO1AEIC423xIdt/zeXwWnM2k2zRQaQJgI794L5zayNfTEN80SaypqaRyyLcGig6DfaJvXwZMN4OkQI0ZINS8rsInDFmfJPhFpHzNfqv1G4iT5RsCBVeyWu7NU/4uo0jLKT7Wr8eim/6cnwxTtz6Z48o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dLzBqcmn; arc=none smtp.client-ip=209.85.219.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dLzBqcmn" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6b072522bd5so3012536d6.2 for ; Wed, 12 Jun 2024 22:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255228; x=1718860028; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=33CRu+C2JgTRZankJporQEOV03dfUw9PM9dUe4iPxTQ=; b=dLzBqcmnmmUX1hTA7+kYOZHEj4kLE4j/d7ZxHe4BlshAz0W8cLx+//CHTZvMdIr+m0 LMh1LCbeOoNoImAseKVnvQGGAtOWq31hzR1NuCnl41SOHHjC7Qq+MeLssLb7kpR7Iqub ieTQskTTCL4EvQgAH5drIi+5LbtaBb41DyRIKSKzY2b/FKbZ55ho9D8l5nR2KbiUSSMw 36hOKJ/dtOJuIeoELu1t7bgpWPlZ+QbGKhyARs1eG4joQ9jh/zXH24OE2NcdlvVWspw2 RK46E31FI/YpYdxPfuh3D/WXjOMKzS0YJDq2ZSA8NL2EpG1hM1AVeX0+CbcKrXF92KpQ j7Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255228; x=1718860028; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=33CRu+C2JgTRZankJporQEOV03dfUw9PM9dUe4iPxTQ=; b=MfscD8of84h8P/B8FPIRwnxnnQwBGasdRfWqYpjv00mR7kESg+XradMNbnmZuSNXrX c+DchVtRQuRyg6HbVHyoUgb9xl1zd2Qbg2DU78dIwwv54G6A2mco5cbVkZ20wbaNOMqc 8HJEtwG7u+6MJIJm/h2XQ9MtruH0ktKyHWFGTLTqgWxjdoFW9JohYbsml4MJxdvvBV7L Hfrz5Ffgf6GQKKq8nkS6p3Em7GlpGQtS6I7lrk2raynvt0bAEnYSLCpLUdqw0EswvSSR vAtS5BzNYEv5rXBBQ5oDHEqx0z4wWyBY1nbkaK1m692DhVAkktxANQHqt2i0wAwWsDBk qmxA== X-Gm-Message-State: AOJu0YwLKDuPNQAr7zVXaVvheDy1jOMVI3HKvJTAvSS26GplXPK3rvVg VjrvLJ1sE1obdEXCGwzDNcW1GDwRd78DcZGMpABDH1H4yuZew7HT06dE X-Google-Smtp-Source: AGHT+IGxP49onCBYE4YlSLJjsG5M+Gm8CqwtWP4NEDhu70hkKr6eBTSHYMxSpXxDJt/Si4htzoem5g== X-Received: by 2002:a05:6214:7ec:b0:6b2:9e65:2246 with SMTP id 6a1803df08f44-6b29e652402mr25881906d6.1.1718255227575; Wed, 12 Jun 2024 22:07:07 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:07 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 06/11] NFSv4/pNFS: Add a helper to defer failed layoutreturn calls Date: Thu, 13 Jun 2024 01:00:50 -0400 Message-ID: <20240613050055.854323-7-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-6-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> <20240613050055.854323-5-trond.myklebust@hammerspace.com> <20240613050055.854323-6-trond.myklebust@hammerspace.com> 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 layoutreturn-on-close fails due to an RPC layer problem, such as a timeout, then we want to retry at a later time. Add a helper function to allow this. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 3bfc74841831..a79ae47b3842 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1171,6 +1171,26 @@ static void pnfs_clear_layoutcommit(struct inode *inode, } } +static void +pnfs_layoutreturn_retry_later_locked(struct pnfs_layout_hdr *lo, + const nfs4_stateid *arg_stateid, + const struct pnfs_layout_range *range) +{ + const struct pnfs_layout_segment *lseg; + u32 seq = be32_to_cpu(arg_stateid->seqid); + + if (pnfs_layout_is_valid(lo) && + nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid)) { + list_for_each_entry(lseg, &lo->plh_return_segs, pls_list) { + if (pnfs_seqid_is_newer(lseg->pls_seq, seq) || + !pnfs_should_free_range(&lseg->pls_range, range)) + continue; + pnfs_set_plh_return_info(lo, range->iomode, seq); + break; + } + } +} + void pnfs_layoutreturn_free_lsegs(struct pnfs_layout_hdr *lo, const nfs4_stateid *arg_stateid, const struct pnfs_layout_range *range, @@ -1577,9 +1597,8 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args, switch (ret) { case -NFS4ERR_NOMATCHING_LAYOUT: spin_lock(&inode->i_lock); - if (pnfs_layout_is_valid(lo) && - nfs4_stateid_match_other(&args->stateid, &lo->plh_stateid)) - pnfs_set_plh_return_info(lo, args->range.iomode, 0); + pnfs_layoutreturn_retry_later_locked(lo, &args->stateid, + &args->range); pnfs_clear_layoutreturn_waitbit(lo); spin_unlock(&inode->i_lock); break; From patchwork Thu Jun 13 05:00:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696121 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC83913665A for ; Thu, 13 Jun 2024 05:07:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255231; cv=none; b=g+ewEc8HDyK6bZ9UY1jBY0TjwyD52foS+y/4tVdhCuQ32iFxeKz7TW3IWha3fgzZ+9j8Aq5NO4fNj3hXuzNKfhdROJrXBKV8ouo8KsX5oAKwrRAaZI8sAfc8jcwb8HuJQ99WJ9P+bfpn62UDh0UUFSq/bLzqUpP/GQbqP+fN2S0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255231; c=relaxed/simple; bh=1EIiKsj88/HIuhpKyPwdj6LpSobgwewSKk2VrkXHeMY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CPzxviGrbkjzP/+W2PK0rtovMWaVgHcs3IhMmznOcY42hNocwy5JGVSjcc9pbBnhuPAhX3f0s1JqFdc23BpdPIIl/jxhgVx/ZaLZKE1Id5SMNln/SJbUgvemsMCB9LMXLjN78ia34uBuFZnfttvKsb2akPs8moUyuCz0yXuv0bc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hPmrd0QC; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hPmrd0QC" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6afbf9c9bc0so3632606d6.3 for ; Wed, 12 Jun 2024 22:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255229; x=1718860029; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xMuo2SFpnJUwQ5H78MYK/+ITRASzfZD05ziEoGSxRnc=; b=hPmrd0QC8cEnm/SzYmdV5kaVeSbpVWtEFQCL2OhJHGonNakmtj8Pt7PiXO7v+hY5ZJ UdDnEqHemwysPkMxodh6gPEZIpegElOY2PT4VtLFZHrVB6UR0dCtnRxnFOnGjH0ESGws D88Z0s7yKGqDjP/3lM0l6TX6K3gyNvb5WWGggnZRvdk0JfHxkkPvReWm7G6Bo/xqbIdB D+z/3ePH6Kt/7lqsGNNtWr4H2fdMUuQRnfIB7BN+Lau2Ub3+fD4RARaVGvnO4LqUEiTE iaNHsNDnUIyfZQAueQEwdy2/CZfw+976x2fEjlRNuP/X1bvIp92QkRmZVfJenuXC5p7i ihxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255229; x=1718860029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xMuo2SFpnJUwQ5H78MYK/+ITRASzfZD05ziEoGSxRnc=; b=lp+FlpEBS/MOf07fXNqOhpzbVeAKUCpeqKiK9rxM+Wix171huHTiJDlTjJYJ8N5+4a Ziqz/ACIz5XxNsKkWRi5IKuwPrCLJLI6jLaA4mZoxwJNZK1NEhoeNYwiqXrI2+zdTHKg wTfqS4J446PFzAsy8iSOCivZAqYsGbnGjlGZMp0jCpC34GSE2Mf/a2bOg/p87ySecl/K Zdbjh5pG74hWIUWuK8cbiTe2h9CG4dDEStv6wos433AL1RpUxM6KSXUPHyX/of/b3qBi SZwvldJO/IoZb/P/0+I+BAVdt5GcFu9GqpVCXuYd5A9tOOUqLQYFdkBvXykrmob3++Re iV9g== X-Gm-Message-State: AOJu0YzVdeHwHOwSvIx9slIZILylShQUiuR8dOdp1Z1LgXysiFOitq8y UPPa82NSzfxZTH3H7HHZijhr2AobZ0m0sq1CjtRwrt37Cy0BI6U/aT6F X-Google-Smtp-Source: AGHT+IHsE97LGR1k9rkhfopXcYoGmDOqq/47xLIm+YbcWPv52/28rrnJoCAIRUwnKdJ4SqKjBUa8/A== X-Received: by 2002:a05:6214:4a08:b0:6b0:6a26:9083 with SMTP id 6a1803df08f44-6b1a7225bc8mr47603236d6.40.1718255228557; Wed, 12 Jun 2024 22:07:08 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:08 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 07/11] NFSv4/pNFS: Handle server reboots in pnfs_poc_release() Date: Thu, 13 Jun 2024 01:00:51 -0400 Message-ID: <20240613050055.854323-8-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-7-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> <20240613050055.854323-5-trond.myklebust@hammerspace.com> <20240613050055.854323-6-trond.myklebust@hammerspace.com> <20240613050055.854323-7-trond.myklebust@hammerspace.com> 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 server reboots, then handle it by deferring the layout return. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index a79ae47b3842..c8b1be1810e2 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1586,8 +1586,7 @@ int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp, } void pnfs_roc_release(struct nfs4_layoutreturn_args *args, - struct nfs4_layoutreturn_res *res, - int ret) + struct nfs4_layoutreturn_res *res, int ret) { struct pnfs_layout_hdr *lo = args->layout; struct inode *inode = args->inode; @@ -1595,6 +1594,9 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args, struct nfs4_xdr_opaque_data *ld_private = args->ld_private; switch (ret) { + case -NFS4ERR_BADSESSION: + case -NFS4ERR_DEADSESSION: + case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: case -NFS4ERR_NOMATCHING_LAYOUT: spin_lock(&inode->i_lock); pnfs_layoutreturn_retry_later_locked(lo, &args->stateid, From patchwork Thu Jun 13 05:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696122 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2C5913210A for ; Thu, 13 Jun 2024 05:07:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255232; cv=none; b=P5CScVu/Qyoxuoa04xYLUq4EFnkhWrOaxhY2nI9G96P5ppXyR2Pbpsx1YqVh/0hhDc4/aFa9va5D80QJLK2Sak8l/Io1hgsC3iQOHzWfhaorzEzriV7GXLsdOWrCYwLl+ZbPu8i0B2Ia+Tgk+/jZNiuKolQbbmBO46VomyCPtd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255232; c=relaxed/simple; bh=pCc6rlbod+O9ZWNvTMer6pP/iko2kam/3qbJqW80Ghc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qPRCAe1EKm4iPYv0NI+ep6+nsQU5k5S8aqMTzUGeix05UXutcSaBWJOKMyzHoeaLuSZ7OW8ocZOIV1fvfQdGDxYfaYoi9TcLiwiMuQoJzp8CJtTwy5zZKGwHPvFWr0qj68scnW5FDP8IGlvPZfeyidd9pCiWayWZaq8rUL2YixI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N1olhVmH; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N1olhVmH" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-795569eedcaso31337385a.3 for ; Wed, 12 Jun 2024 22:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255229; x=1718860029; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SG1mrRXIW79vbW1cM4s2VqfFgsAl+cVVKt3gnIv/h5k=; b=N1olhVmHAfiFrwMHqbl64tnAOO8R27sYybctp3NDVqIW4u87LuvWXvCW2XinSvDYjQ /aEZlmhTX8jMMJrWbvvJqRYRsSBXpT3CCbe67/WjML7uU8U0ydZKAz+4jV1MEMJZphBs mARDrNxIm/IVg8oo82P24rmzCwHFU3/CsVFX3xNVAvrAJomH8KvAjhJ367GBWdtyBGAk cY6coGMa1mRNCrqc0+gt3Jd0uDUwYDMFULNVkz+mcCxDzLmXWqc2LpF39x57CWl2xgXU paKJ7y1jUukdn9gEc5Cqs3KKNmMgo7d6gfGm6Ut/NWpB754cF1pKM4nC1xzH3lPg7fEc 4pfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255229; x=1718860029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SG1mrRXIW79vbW1cM4s2VqfFgsAl+cVVKt3gnIv/h5k=; b=YPAp/kpByVHKGMsiFc3EY39B2j2ttJL6/FFwbzXw0YqfeZmFEEbMEUCKl4IjzfQiWr IPgtvBL5mGe22ILxfKiEjimm0ufKC4P6M7jivwSX7lkxOnj4YpsRPXGF//qd5pjOTrvE /MgpYmFRsY0RcRxNVummqrkYLQwkGMealwg/TYM1qQma1AkbiuZwQ610WOq4yPvZvg49 3tI1nk4XgVg1qQtCv7iqZwrwvvF90kFSfvRW0RqbtFVYD8oRZSaETkgs+SpuBIhou3SO ixvMdTPof5e2OdAh2ANSTlwFADFnfiXTbbRXWD/9OwqiXMfdPdgSSfm2LWJfyDRs87BG HG5g== X-Gm-Message-State: AOJu0YwL0J6NcmTKa//41QigS6eiIOBUjfeZGVWfdTliQ/Hx1r47f1zm EEfKXH+7rauQFZd/PQoK2HJH+UJLk4aRJE3ph9pe0TTx5/kOJD9S+p42 X-Google-Smtp-Source: AGHT+IHbzFwE19p1MdNb3VB/GmVgjv3RLrTgkY8f0PvBB+zosqnaT+Dl+LCf/KpYHZuWHO+2UMpoJg== X-Received: by 2002:a05:6214:4801:b0:6b0:8fa9:6cac with SMTP id 6a1803df08f44-6b1a712f106mr46364466d6.57.1718255229550; Wed, 12 Jun 2024 22:07:09 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:08 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 08/11] NFSv4/pNFS: Retry the layout return later in case of a timeout or reboot Date: Thu, 13 Jun 2024 01:00:52 -0400 Message-ID: <20240613050055.854323-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-8-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> <20240613050055.854323-5-trond.myklebust@hammerspace.com> <20240613050055.854323-6-trond.myklebust@hammerspace.com> <20240613050055.854323-7-trond.myklebust@hammerspace.com> <20240613050055.854323-8-trond.myklebust@hammerspace.com> 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 layout return failed due to a timeout or reboot, then leave the layout segments on the list so that the layout return gets replayed later. The exception would be if we're freeing the inode. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 21 ++++++++++++++++++++- fs/nfs/pnfs.c | 12 ++++++++++++ fs/nfs/pnfs.h | 3 +++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ae835d14ac75..952d1e930185 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9944,6 +9944,11 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) if (!nfs41_sequence_process(task, &lrp->res.seq_res)) return; + if (task->tk_rpc_status == -ETIMEDOUT) { + lrp->rpc_status = -EAGAIN; + lrp->res.lrs_present = 0; + return; + } /* * Was there an RPC level error? Assume the call succeeded, * and that we need to release the layout @@ -9966,6 +9971,15 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) fallthrough; case 0: break; + case -NFS4ERR_BADSESSION: + case -NFS4ERR_DEADSESSION: + case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: + nfs4_schedule_session_recovery(server->nfs_client->cl_session, + task->tk_status); + lrp->res.lrs_present = 0; + lrp->rpc_status = -EAGAIN; + task->tk_status = 0; + break; case -NFS4ERR_DELAY: if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN) break; @@ -9983,8 +9997,13 @@ static void nfs4_layoutreturn_release(void *calldata) struct nfs4_layoutreturn *lrp = calldata; struct pnfs_layout_hdr *lo = lrp->args.layout; - pnfs_layoutreturn_free_lsegs(lo, &lrp->args.stateid, &lrp->args.range, + if (lrp->rpc_status == 0 || !lrp->inode) + pnfs_layoutreturn_free_lsegs( + lo, &lrp->args.stateid, &lrp->args.range, lrp->res.lrs_present ? &lrp->res.stateid : NULL); + else + pnfs_layoutreturn_retry_later(lo, &lrp->args.stateid, + &lrp->args.range); nfs4_sequence_free_slot(&lrp->res.seq_res); if (lrp->ld_private.ops && lrp->ld_private.ops->free) lrp->ld_private.ops->free(&lrp->ld_private); diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index c8b1be1810e2..04a52fa3d28c 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1191,6 +1191,18 @@ pnfs_layoutreturn_retry_later_locked(struct pnfs_layout_hdr *lo, } } +void pnfs_layoutreturn_retry_later(struct pnfs_layout_hdr *lo, + const nfs4_stateid *arg_stateid, + const struct pnfs_layout_range *range) +{ + struct inode *inode = lo->plh_inode; + + spin_lock(&inode->i_lock); + pnfs_layoutreturn_retry_later_locked(lo, arg_stateid, range); + pnfs_clear_layoutreturn_waitbit(lo); + spin_unlock(&inode->i_lock); +} + void pnfs_layoutreturn_free_lsegs(struct pnfs_layout_hdr *lo, const nfs4_stateid *arg_stateid, const struct pnfs_layout_range *range, diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 8fa0f152ed19..cd23a38eac75 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -328,6 +328,9 @@ struct pnfs_layout_segment *pnfs_update_layout(struct inode *ino, enum pnfs_iomode iomode, bool strict_iomode, gfp_t gfp_flags); +void pnfs_layoutreturn_retry_later(struct pnfs_layout_hdr *lo, + const nfs4_stateid *arg_stateid, + const struct pnfs_layout_range *range); void pnfs_layoutreturn_free_lsegs(struct pnfs_layout_hdr *lo, const nfs4_stateid *arg_stateid, const struct pnfs_layout_range *range, From patchwork Thu Jun 13 05:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696123 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B3E1133406 for ; Thu, 13 Jun 2024 05:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255233; cv=none; b=NF1zHZBXjX7APjxyb7YuEwWEdsidhrhMYdbqrTvLFfJhL62QE/fzYD3fDbkq/2fDBtt6fKXxlYjZVQkb7raZeUi/Ui74EY6qCppUSsSzsjr9vAV6oFBHPzASIz6bEseHSya3mHYynh4xpXBbwS1g8n38YoV4wz1BeuCteNZRaeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255233; c=relaxed/simple; bh=kRGIw9Uo9z620W/i9ejpmqh8kfzjQtYpREdpQFJpWrE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FS17HvY3hJd58vZmpoSfCNRFHStCv1x86l9J0u21YxAm/USN+lKos5jEyPInJ7uuG3wEbLwYmD4bkDnQ0L3uUiM7Sgeg5fHuMH9trNpuP7V83zXlACthgUnGOCtAKdBEZa5ujVAnZnCQtfbqQuPAsR71fiuWk3dyhRkA95xqahQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YCQ1ldwu; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YCQ1ldwu" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6312f1f83d9so1611067b3.2 for ; Wed, 12 Jun 2024 22:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255231; x=1718860031; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=e0plCIfkUm6ngCoLGe2L1FwABR/YpxSwIuegH/uFftM=; b=YCQ1ldwud+kjpyluVjYl6W/7fRG40+wHM3UV4nvF90MUw1/WNIdBlE8GqtPdVYgd5q /gZHdJwM65OTraCMKnuPRln3sz91qSFWK6kjQ4AoADBcRQfN3BdXwkCKtPg2txGe+PrV fFfrIOipjLg5gkyl+yrBPSZaD/6KPdK9yfqAx/CADrxJBOpV7GgIvSZBnIsxNO5ahTqE oRKKV4ZoA+OV8DxcfAQQxRVMe3BJM26moGdYYlGy4SZ1y5moJ99lI8dL0U8bmbx/cVIl mXsep0Md20xPisJwPhKjmucvNcqhIC4BOgR8DV8OIisjtRVzgvVQwYXaquP773Wnwb7Q SAsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255231; x=1718860031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e0plCIfkUm6ngCoLGe2L1FwABR/YpxSwIuegH/uFftM=; b=Hf/n9IylGn1Aj/wcwhOhCCSjO7LENUmxfCone/gPhjSBgOuBY3TlTlNK+k6vWpKgsm OLESQpp2lDlQAJZHnbmnjmZkf6+kvWEITK9qodBdXyX24CVE2LZ6sJ/1K5CP+WnbMtko 04DQybsjnGA/myYmbPyhmAUccjrhfNhEgux5LMZtHXzTBEtnfAQAbm9qKstcTMrVVNEz Mh6w7XSduPCMVSGhbAE4Buq1FvLmMwiA6/AgOa2c2tx1uIovlxrl820aXVRDDuw5qfUL 0+UV74IGSvud6uILLP/DpcG2nAQsIiSMgGFzjPHC+u7nGTteCT2L0OEOoxZuWOlcHiCn 8e/g== X-Gm-Message-State: AOJu0YwKWe5ZQnm1eW+svyXcsAYou0MLbvBJmx11sK4ru8ByUtzh3EdY M27qbPSLkrJ1yE5gMC1pyNdNmyenz7trTKuiOsvfp4bKGvly+nVBY9xI X-Google-Smtp-Source: AGHT+IErbKUmcw4BDgxvZKRFL+rUk8UcpvN5asY+zqEaRI2FJrjyZibTUoLr3YBXqSQdGI+IQB47WQ== X-Received: by 2002:a0d:eac8:0:b0:630:8c74:eab8 with SMTP id 00721157ae682-6308c74eb4cmr22736627b3.42.1718255230543; Wed, 12 Jun 2024 22:07:10 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:09 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 09/11] NFSv4/pnfs: Give nfs4_proc_layoutreturn() a flags argument Date: Thu, 13 Jun 2024 01:00:53 -0400 Message-ID: <20240613050055.854323-10-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-9-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> <20240613050055.854323-5-trond.myklebust@hammerspace.com> <20240613050055.854323-6-trond.myklebust@hammerspace.com> <20240613050055.854323-7-trond.myklebust@hammerspace.com> <20240613050055.854323-8-trond.myklebust@hammerspace.com> <20240613050055.854323-9-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust Replace the boolean in nfs4_proc_layoutreturn() with a set of flags that will allow us to craft a version that is appropriate for reboot recovery. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 8 +++++--- fs/nfs/pnfs.c | 18 +++++++++++------- fs/nfs/pnfs.h | 6 +++++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 952d1e930185..8d237cf15a03 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -10019,7 +10019,7 @@ static const struct rpc_call_ops nfs4_layoutreturn_call_ops = { .rpc_release = nfs4_layoutreturn_release, }; -int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) +int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, unsigned int flags) { struct rpc_task *task; struct rpc_message msg = { @@ -10042,7 +10042,7 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) &task_setup_data.rpc_client, &msg); lrp->inode = nfs_igrab_and_active(lrp->args.inode); - if (!sync) { + if (flags & PNFS_FL_LAYOUTRETURN_ASYNC) { if (!lrp->inode) { nfs4_layoutreturn_release(lrp); return -EAGAIN; @@ -10050,6 +10050,8 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) task_setup_data.flags |= RPC_TASK_ASYNC; } if (!lrp->inode) + flags |= PNFS_FL_LAYOUTRETURN_PRIVILEGED; + if (flags & PNFS_FL_LAYOUTRETURN_PRIVILEGED) nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, 1); else @@ -10058,7 +10060,7 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) task = rpc_run_task(&task_setup_data); if (IS_ERR(task)) return PTR_ERR(task); - if (sync) + if (!(flags & PNFS_FL_LAYOUTRETURN_ASYNC)) status = task->tk_status; trace_nfs4_layoutreturn(lrp->args.inode, &lrp->args.stateid, status); dprintk("<-- %s status=%d\n", __func__, status); diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 04a52fa3d28c..c482088cb485 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1279,7 +1279,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, const nfs4_stateid *stateid, const struct cred **pcred, enum pnfs_iomode iomode, - bool sync) + unsigned int flags) { struct inode *ino = lo->plh_inode; struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld; @@ -1306,7 +1306,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, if (ld->prepare_layoutreturn) ld->prepare_layoutreturn(&lrp->args); - status = nfs4_proc_layoutreturn(lrp, sync); + status = nfs4_proc_layoutreturn(lrp, flags); out: dprintk("<-- %s status: %d\n", __func__, status); return status; @@ -1340,7 +1340,8 @@ static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo) spin_unlock(&inode->i_lock); if (send) { /* Send an async layoutreturn so we dont deadlock */ - pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, false); + pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, + PNFS_FL_LAYOUTRETURN_ASYNC); } } else spin_unlock(&inode->i_lock); @@ -1407,7 +1408,8 @@ _pnfs_return_layout(struct inode *ino) send = pnfs_prepare_layoutreturn(lo, &stateid, &cred, NULL); spin_unlock(&ino->i_lock); if (send) - status = pnfs_send_layoutreturn(lo, &stateid, &cred, IOMODE_ANY, true); + status = pnfs_send_layoutreturn(lo, &stateid, &cred, IOMODE_ANY, + 0); out_wait_layoutreturn: wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, TASK_UNINTERRUPTIBLE); out_put_layout_hdr: @@ -1548,7 +1550,7 @@ bool pnfs_roc(struct inode *ino, return true; } if (layoutreturn) - pnfs_send_layoutreturn(lo, &stateid, &lc_cred, iomode, true); + pnfs_send_layoutreturn(lo, &stateid, &lc_cred, iomode, 0); pnfs_put_layout_hdr(lo); return false; } @@ -2595,7 +2597,8 @@ pnfs_mark_layout_for_return(struct inode *inode, return_now = pnfs_prepare_layoutreturn(lo, &stateid, &cred, &iomode); spin_unlock(&inode->i_lock); if (return_now) - pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, false); + pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, + PNFS_FL_LAYOUTRETURN_ASYNC); } else { spin_unlock(&inode->i_lock); nfs_commit_inode(inode, 0); @@ -2711,7 +2714,8 @@ static int pnfs_layout_return_unused_byserver(struct nfs_server *server, } spin_unlock(&inode->i_lock); rcu_read_unlock(); - pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, false); + pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, + PNFS_FL_LAYOUTRETURN_ASYNC); pnfs_put_layout_hdr(lo); cond_resched(); goto restart; diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index cd23a38eac75..d192feb346b4 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -248,6 +248,9 @@ extern const struct pnfs_layoutdriver_type *pnfs_find_layoutdriver(u32 id); extern void pnfs_put_layoutdriver(const struct pnfs_layoutdriver_type *ld); /* nfs4proc.c */ +#define PNFS_FL_LAYOUTRETURN_ASYNC (1U << 0) +#define PNFS_FL_LAYOUTRETURN_PRIVILEGED (1U << 1) + extern size_t max_response_pages(struct nfs_server *server); extern int nfs4_proc_getdeviceinfo(struct nfs_server *server, struct pnfs_device *dev, @@ -255,7 +258,8 @@ extern int nfs4_proc_getdeviceinfo(struct nfs_server *server, extern struct pnfs_layout_segment * nfs4_proc_layoutget(struct nfs4_layoutget *lgp, struct nfs4_exception *exception); -extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync); +extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, + unsigned int flags); /* pnfs.c */ void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo); From patchwork Thu Jun 13 05:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696124 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD846136678 for ; Thu, 13 Jun 2024 05:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255234; cv=none; b=fyUETEpthi5pny81WpEfvbaHbkqnZOmkZYjnnWEsYzth/YgwEtZ1ReN6AziMpDN8EvB9WutFA2jKcSdIEwsjS3lNWmHWdlLvgae0l18rMBdDumrDg793rYrfaqMKMIpHx+mam6Ugh5zHSqJJA88uU/vmTk1V/ZqGDIQHWza88mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255234; c=relaxed/simple; bh=5FZhCCJQZGcQdkRuePEMKsfwZUFzXZGeLyF3v6GzOlY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AjtYoUY5EJfe5q8soBfnqAMbwbby7hb0F7C1OskiQ21lNi56VRgOgxRN77C/OuDmDx9ncRuYjgQhRUSetp7vmFdIs6QHIw+jkKlmx2RzEUHQQQ8eAQHjRq/YSw00I+gykU5+fOOHnsrC3w60xXXCUP54X9BOiE54rUhR3ExLvwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VTwH3o++; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VTwH3o++" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-62cecde1db9so6698147b3.2 for ; Wed, 12 Jun 2024 22:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255231; x=1718860031; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YjtiytHHeZfurrH0JqFSXJ6hkoUtVs2kenFI3vJOeVU=; b=VTwH3o++F+7nO5VV2xTgNkgx53UgU0NF0a8cDq3aBsuhE+yKI8ZwZctPoYWAz3JK5y tLqZM5FbsqcC+hXCKsQEm0jMg23eaEgo/GfeKVmG64F7PcVMkYMn0w0fVDiBiNP2iG48 dZKdtRKA5MoAp2pnAjLLYy5VYTPUxVIdWqo9gjjncRtHa6WeIYaZwKGGxTRl9e6pszaL ROBVjZiTBcs8qE4Y1fIQkaIB9sij5UVpn2YarYPWIN2zc85hwJbLY1zAIggyofYdf6MA uaX0jCqpFNJTZKuAAyrWoAFawYwiD0VI7OM2hO6kqjJC+tc6BQCsKl6qBaTOQGQcRxUM wCkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255231; x=1718860031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YjtiytHHeZfurrH0JqFSXJ6hkoUtVs2kenFI3vJOeVU=; b=UPwzmEGpDLeCUf7zlA4xp/GguulOoldKinj7p5P9f65pl2w19MbY4lJb/eAGn8P2ms EdeJ4BA6AfSST/7WitD//lEpQpovItG9OkroW4zFdyNMn5RhMbdIwnR0j3a5UiyYtu0I jOR4l1NFCJ63Nzhas5zcRrMd9U2FlJ9/jU3zTMdI/SVGM0gHeO8oqXIk2lV9zFGed1KI iDulwVjrigHWb4KLI1uHdjpjpb995jwun15WxT0n6EhRNLWV3pQxE+Y5C9/gtv6bbqHj IMFzoj6Q31WZo/a9RdBD2sfs9NXDBmlFMIIiwE1PbLdK56JpkHZ4iSQaHD3C3g9cCdyQ i+Xg== X-Gm-Message-State: AOJu0YyZYzhA8Kjqem3h7LDFaWU0pofq+Wki8ZTNH2fUWB3f0C3aZSFI oxQCMi6e7EDhNoEP3v4QZqiK9fqMFo1J2rFACwZcjlyqMM2jbkvHuqGf X-Google-Smtp-Source: AGHT+IG6RYd0OWZP1nBJbe2q/6OWAgiUaGocZV9YZ24D2UxkrVWIB+HoSJ4NLc+PD6/U24l8162wWw== X-Received: by 2002:a81:c24f:0:b0:627:e1f9:a147 with SMTP id 00721157ae682-62fbb7f65b1mr40877037b3.5.1718255231269; Wed, 12 Jun 2024 22:07:11 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:10 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 10/11] NFSv4/pNFS: Remove redundant call to unhash the layout Date: Thu, 13 Jun 2024 01:00:54 -0400 Message-ID: <20240613050055.854323-11-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-10-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> <20240613050055.854323-5-trond.myklebust@hammerspace.com> <20240613050055.854323-6-trond.myklebust@hammerspace.com> <20240613050055.854323-7-trond.myklebust@hammerspace.com> <20240613050055.854323-8-trond.myklebust@hammerspace.com> <20240613050055.854323-9-trond.myklebust@hammerspace.com> <20240613050055.854323-10-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust The layout will be automatically unhashed on final release of the reference count. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index c482088cb485..31df5fae7acb 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -858,8 +858,6 @@ pnfs_layout_bulk_destroy_byserver_locked(struct nfs_client *clp, break; inode = pnfs_grab_inode_layout_hdr(lo); if (inode != NULL) { - if (test_and_clear_bit(NFS_LAYOUT_HASHED, &lo->plh_flags)) - list_del_rcu(&lo->plh_layouts); if (pnfs_layout_add_bulk_destroy_list(inode, layout_list)) continue; From patchwork Thu Jun 13 05:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696125 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8569413210A for ; Thu, 13 Jun 2024 05:07:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255235; cv=none; b=dIdk9dZQGrT1E7JjlCoGEm9Xg23N9v8AG+HtJRtabXQKKmavpCohbjQ4C2nhncRneu8Fyw1nqg+9oF4PYjzfX2j513xOpb/DDL8uedh8NUcgcM8Snj+Ry1yFxfcytnVPH2teTUd9pw9v4sBiEi2V9mEcbV9LhTediv7TIbIPjiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718255235; c=relaxed/simple; bh=+kbrTHhQLVgOVah+qw0vntNsDDb4fLOQUEfdN8pZThM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DvWg37E1SWXzraM3c3C3zb8VfCeaP+LL4Uist3iD8xNzwu5RD6qPZUQWfBOaUyFm/WtxkxZ5Gb/RfX3OAUIaLBdFUDwP+voR7sFx64rx5Oui8v6RN8hd5cZCfOtjV3hZ3uKmAwqPMtpQV/qNf/ffilx6GHTmcb76mXe/XQKxVis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F7R8zD3z; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F7R8zD3z" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-797f1287aa3so37083685a.2 for ; Wed, 12 Jun 2024 22:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718255232; x=1718860032; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9jxvFBjQjt1vBoNL/YgO6suiNciopobLtS98D6qMJ64=; b=F7R8zD3z33jX1HbZh9zwF00gg85tAP3ZVMG+UPRqS6yofScKCbY15SIkTu9zA4X5wT IOaT6g+oySBc1yF1gX6l7kTqJiND2GkVXCo03XNA8FYUSf6LCY1HdzItrIrnvNH7KxvO tPGmzFOikC33xynoSWEEJlzsiEWtyEwbtqAlbG9SIVeelRe7X5QPK6kbYCcDBgmTiOW7 CdwUu2HSkLtwzsf7l6AVNuN6G6g3rmxziNpuhLpW1oN4fbmJfbbi+xScJYqLYK+f6aNl H0DktdykbmZsBUvamkg6hC4ndFiExkbfpM3rU8l/4V0NuaYm1Q+8w8UiJiv1Kd16UNeD +r1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718255232; x=1718860032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9jxvFBjQjt1vBoNL/YgO6suiNciopobLtS98D6qMJ64=; b=ETY2pdS2wZI9zOy5QNpMB47WlNRJDdC1vDC6qolsG05CIfboXTnibaI2mRXvyVxtnM fKQOTXGemlI0G7gNY1oSeFyw3F+cuqS7tFPhGU7WpzmT9jdVxyyPtvIb2dowkgh4VPIz wABm+Ye213AjTcUcnILO2m90TRiUWIA6u/4qHwH1TLK0pDc0ZPHrCGUR3RTwbC5VUaPV mQ6zH/u/A8hTlkRsIciXaN7cub+S43NkzdFmtrxGxx3wNjdEI/3TP/SD0eVjmPX3FJ/E 9pPiCjMk81Pkv8jkbMoaw/0wdqQy6A9CR7LaBIaOuNI3OUXw7I1p/pztBVpBzp6TDSY2 HgOQ== X-Gm-Message-State: AOJu0YwK/ihfhPWm/Y9iJxmM8L8ScwRs6jSdaAosu98cABuWk/SLcaaE lyTWYT963LZV+5YjGJm18GrO/XWvq7WB9vxSpc+2JGlo547AtWRRWblK X-Google-Smtp-Source: AGHT+IHuCWjb25GltIYUC4BCRFWS9cuZ85ZUMIMYcjfJjiHcqXo4KHgSQHpY/xamwk5mMtx51+jAqg== X-Received: by 2002:a05:6214:5d8d:b0:6b0:88e1:3093 with SMTP id 6a1803df08f44-6b1910c274emr41527096d6.1.1718255232013; Wed, 12 Jun 2024 22:07:12 -0700 (PDT) Received: from leira.trondhjem.org (c-68-40-188-158.hsd1.mi.comcast.net. [68.40.188.158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5ed4527sm3079036d6.101.2024.06.12.22.07.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 22:07:11 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 11/11] NFSv4/pNFS: Do layout state recovery upon reboot Date: Thu, 13 Jun 2024 01:00:55 -0400 Message-ID: <20240613050055.854323-12-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613050055.854323-11-trond.myklebust@hammerspace.com> References: <20240613050055.854323-1-trond.myklebust@hammerspace.com> <20240613050055.854323-2-trond.myklebust@hammerspace.com> <20240613050055.854323-3-trond.myklebust@hammerspace.com> <20240613050055.854323-4-trond.myklebust@hammerspace.com> <20240613050055.854323-5-trond.myklebust@hammerspace.com> <20240613050055.854323-6-trond.myklebust@hammerspace.com> <20240613050055.854323-7-trond.myklebust@hammerspace.com> <20240613050055.854323-8-trond.myklebust@hammerspace.com> <20240613050055.854323-9-trond.myklebust@hammerspace.com> <20240613050055.854323-10-trond.myklebust@hammerspace.com> <20240613050055.854323-11-trond.myklebust@hammerspace.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Trond Myklebust Some pNFS implementations, such as flexible files, want the client to send the layout stats and layout errors that may have incurred while the metadata server was booting. To do so, the client sends a layoutreturn with an all-zero stateid while the server is in grace during reboot recovery. Signed-off-by: Trond Myklebust --- fs/nfs/flexfilelayout/flexfilelayout.c | 2 +- fs/nfs/nfs4state.c | 4 +- fs/nfs/pnfs.c | 106 +++++++++++++++++++++++-- fs/nfs/pnfs.h | 6 ++ include/linux/nfs_fs_sb.h | 1 + 5 files changed, 110 insertions(+), 9 deletions(-) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 24188af56d5b..39ba9f4208aa 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -2548,7 +2548,7 @@ ff_layout_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *dummy) { #if IS_ENABLED(CONFIG_NFS_V4_2) - server->caps |= NFS_CAP_LAYOUTSTATS; + server->caps |= NFS_CAP_LAYOUTSTATS | NFS_CAP_REBOOT_LAYOUTRETURN; #endif return 0; } diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 5b452411e8fd..877f682b45f2 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1863,6 +1863,7 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) if (!nfs4_state_clear_reclaim_reboot(clp)) return; + pnfs_destroy_all_layouts(clp); ops = clp->cl_mvops->reboot_recovery_ops; cred = nfs4_get_clid_cred(clp); err = nfs4_reclaim_complete(clp, ops, cred); @@ -2068,7 +2069,6 @@ static int nfs4_establish_lease(struct nfs_client *clp) put_cred(cred); if (status != 0) return status; - pnfs_destroy_all_layouts(clp); return 0; } @@ -2680,6 +2680,8 @@ static void nfs4_state_manager(struct nfs_client *clp) section = "reclaim reboot"; status = nfs4_do_reclaim(clp, clp->cl_mvops->reboot_recovery_ops); + if (status == 0) + status = pnfs_layout_handle_reboot(clp); if (status == -EAGAIN) continue; if (status < 0) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 31df5fae7acb..aa698481bec8 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -61,6 +61,7 @@ static void pnfs_free_returned_lsegs(struct pnfs_layout_hdr *lo, u32 seq); static bool pnfs_lseg_dec_and_remove_zero(struct pnfs_layout_segment *lseg, struct list_head *tmp_list); +static int pnfs_layout_return_on_reboot(struct pnfs_layout_hdr *lo); /* Return the registered pnfs layout driver module matching given id */ static struct pnfs_layoutdriver_type * @@ -937,25 +938,37 @@ int pnfs_layout_destroy_byfsid(struct nfs_client *clp, struct nfs_fsid *fsid, return pnfs_layout_free_bulk_destroy_list(&layout_list, mode); } -int pnfs_layout_destroy_byclid(struct nfs_client *clp, - enum pnfs_layout_destroy_mode mode) +static void pnfs_layout_build_destroy_list_byclient(struct nfs_client *clp, + struct list_head *list) { struct nfs_server *server; - LIST_HEAD(layout_list); spin_lock(&clp->cl_lock); rcu_read_lock(); restart: list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { - if (pnfs_layout_bulk_destroy_byserver_locked(clp, - server, - &layout_list) != 0) + if (pnfs_layout_bulk_destroy_byserver_locked(clp, server, + list) != 0) goto restart; } rcu_read_unlock(); spin_unlock(&clp->cl_lock); +} - return pnfs_layout_free_bulk_destroy_list(&layout_list, mode); +static int pnfs_layout_do_destroy_byclid(struct nfs_client *clp, + struct list_head *list, + enum pnfs_layout_destroy_mode mode) +{ + pnfs_layout_build_destroy_list_byclient(clp, list); + return pnfs_layout_free_bulk_destroy_list(list, mode); +} + +int pnfs_layout_destroy_byclid(struct nfs_client *clp, + enum pnfs_layout_destroy_mode mode) +{ + LIST_HEAD(layout_list); + + return pnfs_layout_do_destroy_byclid(clp, &layout_list, mode); } /* @@ -971,6 +984,67 @@ pnfs_destroy_all_layouts(struct nfs_client *clp) pnfs_layout_destroy_byclid(clp, PNFS_LAYOUT_INVALIDATE); } +static void pnfs_layout_build_recover_list_byclient(struct nfs_client *clp, + struct list_head *list) +{ + struct nfs_server *server; + + spin_lock(&clp->cl_lock); + rcu_read_lock(); +restart: + list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { + if (!(server->caps & NFS_CAP_REBOOT_LAYOUTRETURN)) + continue; + if (pnfs_layout_bulk_destroy_byserver_locked(clp, server, + list) != 0) + goto restart; + } + rcu_read_unlock(); + spin_unlock(&clp->cl_lock); +} + +static int pnfs_layout_bulk_list_reboot(struct list_head *list) +{ + struct pnfs_layout_hdr *lo; + struct nfs_server *server; + int ret; + + list_for_each_entry(lo, list, plh_bulk_destroy) { + server = NFS_SERVER(lo->plh_inode); + ret = pnfs_layout_return_on_reboot(lo); + switch (ret) { + case 0: + continue; + case -NFS4ERR_BAD_STATEID: + server->caps &= ~NFS_CAP_REBOOT_LAYOUTRETURN; + break; + case -NFS4ERR_NO_GRACE: + break; + default: + goto err; + } + break; + } + return 0; +err: + return ret; +} + +int pnfs_layout_handle_reboot(struct nfs_client *clp) +{ + LIST_HEAD(list); + int ret = 0, ret2; + + pnfs_layout_build_recover_list_byclient(clp, &list); + if (!list_empty(&list)) + ret = pnfs_layout_bulk_list_reboot(&list); + ret2 = pnfs_layout_do_destroy_byclid(clp, &list, + PNFS_LAYOUT_INVALIDATE); + if (!ret) + ret = ret2; + return (ret == 0) ? 0 : -EAGAIN; +} + static void pnfs_set_layout_cred(struct pnfs_layout_hdr *lo, const struct cred *cred) { @@ -1445,6 +1519,24 @@ pnfs_commit_and_return_layout(struct inode *inode) return ret; } +static int pnfs_layout_return_on_reboot(struct pnfs_layout_hdr *lo) +{ + struct inode *inode = lo->plh_inode; + const struct cred *cred; + + spin_lock(&inode->i_lock); + if (!pnfs_layout_is_valid(lo)) { + spin_unlock(&inode->i_lock); + return 0; + } + cred = get_cred(lo->plh_lc_cred); + pnfs_get_layout_hdr(lo); + spin_unlock(&inode->i_lock); + + return pnfs_send_layoutreturn(lo, &zero_stateid, &cred, IOMODE_ANY, + PNFS_FL_LAYOUTRETURN_PRIVILEGED); +} + bool pnfs_roc(struct inode *ino, struct nfs4_layoutreturn_args *args, struct nfs4_layoutreturn_res *res, diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index d192feb346b4..bb5142b4e67a 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -356,6 +356,7 @@ void pnfs_error_mark_layout_for_return(struct inode *inode, struct pnfs_layout_segment *lseg); void pnfs_layout_return_unused_byclid(struct nfs_client *clp, enum pnfs_iomode iomode); +int pnfs_layout_handle_reboot(struct nfs_client *clp); /* nfs4_deviceid_flags */ enum { @@ -737,6 +738,11 @@ static inline void pnfs_destroy_layout_final(struct nfs_inode *nfsi) { } +static inline int pnfs_layout_handle_reboot(struct nfs_client *clp) +{ + return 0; +} + static inline struct pnfs_layout_segment * pnfs_get_lseg(struct pnfs_layout_segment *lseg) { diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index fe5b1a8bd723..ba9df1848b35 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -278,6 +278,7 @@ struct nfs_server { #define NFS_CAP_LGOPEN (1U << 5) #define NFS_CAP_CASE_INSENSITIVE (1U << 6) #define NFS_CAP_CASE_PRESERVING (1U << 7) +#define NFS_CAP_REBOOT_LAYOUTRETURN (1U << 8) #define NFS_CAP_OPEN_XOR (1U << 12) #define NFS_CAP_DELEGTIME (1U << 13) #define NFS_CAP_POSIX_LOCK (1U << 14)