From patchwork Thu Jun 13 04:11:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696087 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 3ADC6748E for ; Thu, 13 Jun 2024 04:17:41 +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=1718252263; cv=none; b=jehOrpqEYZoG/MLCIGT8DZK3GPGIhH2B1UJy62TY8aVRGkW57XRr2pq/ZHrGwTUwZKJ9HRdeLV13BWtvt0EqzA71bULGL/7iWekctzrXAPP7girdir4ADPMXQMXE5slqd4Lez0TRwrFmhxizdLZYSBXb0NT6sD9oIqTG/+HCCyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252263; c=relaxed/simple; bh=zFgjZOyt/SXgAeTpfzsKhYvfi+iqaDPzYgp46heNcjA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p25WkRs2scpCKojWlxlj88iBJomoDr4g2rb63WsUcbnN6E9OYXCsi9Bc7VHUySM0Q6NXI+r5qzuAScCYJQdH3xCwvLlWsNnAMaTxuyQR6uUj8pWFUPMFqhVetXA7djDjD0NbnAY69bfu4a7wg+IF6/THjShOERKfEmWDb3SF41Y= 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=JJFOAj4c; 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="JJFOAj4c" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6b081c675e7so3452916d6.1 for ; Wed, 12 Jun 2024 21:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252261; x=1718857061; 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=AKLqey/xWTmH19HOBt6Vgd09H4wIzu2YiNfsJFIAaAs=; b=JJFOAj4cLySQq57Qmn/J/i4vsR+0tn+GiX1S3VQjqr3GfBXdCIVfNrP8qP0qa7SRyS U6aCeCCmRskRcRR5W8jios+9Io4L/b65zCz6tBD/p0GYShAvIFrorAtuQ0kw4Y6RdxIx 1tLDzGsj4By8D8KvKGBKFXI9GEXD3JKcaKC9n2yAnpXptxeo0NfxR7BJN2/lGhA6OkyV TO6CmS93w1JTCnoVr730qSVgir6wi3vaFqTYF0zBMM0PoUlUaeOt/ZkoUG8HR2Hyg/sy bSchbV9PT+OvB+sS5zgRTqAZM+TbFge8TKlUZUOfpUjAhaTx/Fuz9IAUasq37gOSZCvC KhOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252261; x=1718857061; 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=AKLqey/xWTmH19HOBt6Vgd09H4wIzu2YiNfsJFIAaAs=; b=JRsuMthXSVSH8F3KCcpaKH3g3PaHAqYoW9Nv2NH0+Go0hDp5T1FwYREtwEUjuhlmS4 JsG06AuzixFyHMOKP7YfdGP5g4NsA0OTRI5BhnogT1yZzH1ejSWrpGty9VbT51hMAFj7 HKjnJR9s3V3+nLVkyRceERi4zIuQdDA7MfUNXk+XUbwYw4V6m3yDwjgdst7PEe1Y4HLP b3y/8ZiqnZuG9Jt0OKre5ZgUH3WiNg6MXpukQNL4HxZLXzWtoiI6EpEUMnyHLnO5zGf/ uVSNJ3HjIallISSemzyRAf8L0s4nXGGvvG1yzQ2H00JPP7XDy/Ogz89fx5Zzbn9wt6Wi 4bCQ== X-Gm-Message-State: AOJu0Yx+WjgfPKHd9mnnFYBe1AIGKdShOgS50fB9z7uJ/PswUcNW7Mys gcn0y1gAs6hWJLPvB5/WwyQXmzu1D7WrbBepzfqcLDmt3XT/WP4uUrJV X-Google-Smtp-Source: AGHT+IFNRIikYufSppK9L4Y21uWgDj6V2F7D3Rruc+5+tLp4SuxwXMJb3MlEgK+8qELupo9gSNcqCw== X-Received: by 2002:a05:6214:4293:b0:6b0:6965:511 with SMTP id 6a1803df08f44-6b1910c198cmr43523636d6.7.1718252260404; Wed, 12 Jun 2024 21:17:40 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:40 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 01/19] NFSv4: Clean up open delegation return structure Date: Thu, 13 Jun 2024 00:11:18 -0400 Message-ID: <20240613041136.506908-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-1-trond.myklebust@hammerspace.com> References: <20240613041136.506908-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 Instead of having the fields open coded in the struct nfs_openres, add a separate structure for them so that we can reuse that code for the WANT_DELEGATION case. Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 30 ++++++++++++++++++------------ fs/nfs/nfs4xdr.c | 38 +++++++++++++++++++------------------- include/linux/nfs_xdr.h | 21 +++++++++++++++++---- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 94c07875aa3f..d3781ce7e0a5 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1960,6 +1960,13 @@ nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) struct nfs_delegation *delegation; int delegation_flags = 0; + switch (data->o_res.delegation.open_delegation_type) { + case NFS4_OPEN_DELEGATE_READ: + case NFS4_OPEN_DELEGATE_WRITE: + break; + default: + return; + }; rcu_read_lock(); delegation = rcu_dereference(NFS_I(state->inode)->delegation); if (delegation) @@ -1979,19 +1986,19 @@ nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) if ((delegation_flags & 1UL<inode, data->owner->so_cred, - data->o_res.delegation_type, - &data->o_res.delegation, - data->o_res.pagemod_limit); + data->o_res.delegation.type, + &data->o_res.delegation.stateid, + data->o_res.delegation.pagemod_limit); else nfs_inode_reclaim_delegation(state->inode, data->owner->so_cred, - data->o_res.delegation_type, - &data->o_res.delegation, - data->o_res.pagemod_limit); + data->o_res.delegation.type, + &data->o_res.delegation.stateid, + data->o_res.delegation.pagemod_limit); - if (data->o_res.do_recall) + if (data->o_res.delegation.do_recall) nfs_async_inode_return_delegation(state->inode, - &data->o_res.delegation); + &data->o_res.delegation.stateid); } /* @@ -2015,8 +2022,7 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data) if (ret) return ERR_PTR(ret); - if (data->o_res.delegation_type != 0) - nfs4_opendata_check_deleg(data, state); + nfs4_opendata_check_deleg(data, state); if (!update_open_stateid(state, &data->o_res.stateid, NULL, data->o_arg.fmode)) @@ -2083,7 +2089,7 @@ _nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) if (IS_ERR(state)) goto out; - if (data->o_res.delegation_type != 0) + if (data->o_res.delegation.type != 0) nfs4_opendata_check_deleg(data, state); if (!update_open_stateid(state, &data->o_res.stateid, NULL, data->o_arg.fmode)) { @@ -3111,7 +3117,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, case NFS4_OPEN_CLAIM_DELEGATE_PREV: if (!opendata->rpc_done) break; - if (opendata->o_res.delegation_type != 0) + if (opendata->o_res.delegation.type != 0) dir_verifier = nfs_save_change_attribute(dir); nfs_set_verifier(dentry, dir_verifier); } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 1416099dfcd1..119061da5298 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -5148,13 +5148,12 @@ static int decode_space_limit(struct xdr_stream *xdr, } static int decode_rw_delegation(struct xdr_stream *xdr, - uint32_t delegation_type, - struct nfs_openres *res) + struct nfs4_open_delegation *res) { __be32 *p; int status; - status = decode_delegation_stateid(xdr, &res->delegation); + status = decode_delegation_stateid(xdr, &res->stateid); if (unlikely(status)) return status; p = xdr_inline_decode(xdr, 4); @@ -5162,52 +5161,53 @@ static int decode_rw_delegation(struct xdr_stream *xdr, return -EIO; res->do_recall = be32_to_cpup(p); - switch (delegation_type) { + switch (res->open_delegation_type) { case NFS4_OPEN_DELEGATE_READ: - res->delegation_type = FMODE_READ; + res->type = FMODE_READ; break; case NFS4_OPEN_DELEGATE_WRITE: - res->delegation_type = FMODE_WRITE|FMODE_READ; + res->type = FMODE_WRITE|FMODE_READ; if (decode_space_limit(xdr, &res->pagemod_limit) < 0) return -EIO; } return decode_ace(xdr, NULL); } -static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) +static int decode_no_delegation(struct xdr_stream *xdr, + struct nfs4_open_delegation *res) { __be32 *p; - uint32_t why_no_delegation; p = xdr_inline_decode(xdr, 4); if (unlikely(!p)) return -EIO; - why_no_delegation = be32_to_cpup(p); - switch (why_no_delegation) { + res->why_no_delegation = be32_to_cpup(p); + switch (res->why_no_delegation) { case WND4_CONTENTION: case WND4_RESOURCE: - xdr_inline_decode(xdr, 4); - /* Ignore for now */ + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + res->will_notify = be32_to_cpup(p); } return 0; } -static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) +static int decode_delegation(struct xdr_stream *xdr, + struct nfs4_open_delegation *res) { __be32 *p; - uint32_t delegation_type; p = xdr_inline_decode(xdr, 4); if (unlikely(!p)) return -EIO; - delegation_type = be32_to_cpup(p); - res->delegation_type = 0; - switch (delegation_type) { + res->open_delegation_type = be32_to_cpup(p); + switch (res->open_delegation_type) { case NFS4_OPEN_DELEGATE_NONE: return 0; case NFS4_OPEN_DELEGATE_READ: case NFS4_OPEN_DELEGATE_WRITE: - return decode_rw_delegation(xdr, delegation_type, res); + return decode_rw_delegation(xdr, res); case NFS4_OPEN_DELEGATE_NONE_EXT: return decode_no_delegation(xdr, res); } @@ -5248,7 +5248,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) for (; i < NFS4_BITMAP_SIZE; i++) res->attrset[i] = 0; - return decode_delegation(xdr, res); + return decode_delegation(xdr, &res->delegation); xdr_error: dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); return -EIO; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index d09b9773b20c..682559e19d9d 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -449,6 +449,22 @@ struct stateowner_id { __u32 uniquifier; }; +struct nfs4_open_delegation { + __u32 open_delegation_type; + union { + struct { + fmode_t type; + __u32 do_recall; + nfs4_stateid stateid; + unsigned long pagemod_limit; + }; + struct { + __u32 why_no_delegation; + __u32 will_notify; + }; + }; +}; + /* * Arguments to the open call. */ @@ -490,13 +506,10 @@ struct nfs_openres { struct nfs_fattr * f_attr; struct nfs_seqid * seqid; const struct nfs_server *server; - fmode_t delegation_type; - nfs4_stateid delegation; - unsigned long pagemod_limit; - __u32 do_recall; __u32 attrset[NFS4_BITMAP_SIZE]; struct nfs4_string *owner; struct nfs4_string *group_owner; + struct nfs4_open_delegation delegation; __u32 access_request; __u32 access_supported; __u32 access_result; From patchwork Thu Jun 13 04:11:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696088 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 9F1F62A1C5 for ; Thu, 13 Jun 2024 04:17:42 +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=1718252264; cv=none; b=r1QIRNlz/IJTewAs4F5L30jSgwfOUkIygOkMsH1e3SRFI5hDRCzcbsMvHfqLfKaerTRKBBQFHfmS6LeSsNpoUXizc0CCIc7RboAlcaaes59wHt4QKwxFIYdrvR6ctlzyCcD+yLuzzxtWvPtJpmuSX5GOTzzDe8Oc3SMYasvM0k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252264; c=relaxed/simple; bh=gTOKXyK0Mh8jlToZGiyHSrwvoFpsRLJlcw3/myGohH8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K+XwTDLrNU17vGJJJQJu1VV/i7cNKYojKXBlksG1gaJ0HS8ct23uHbAfmTaRiJQ1PWRePlDwlpDU1Wdz9OrRzBj8yNTRj00bCwxLmzdHlO6H3FlUV/FtUXatCLx+JuKMeiRCwQMiYF27gn4lJuE6JyWgXE8Z5JWxIYmdG4UrgSE= 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=iA6VltYf; 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="iA6VltYf" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6b065d12dc6so3206846d6.0 for ; Wed, 12 Jun 2024 21:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252261; x=1718857061; 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=iVG1hooISUIjolQvzpMxZSslS3Wph3h8y/hMHfcV0Ns=; b=iA6VltYfk2Wd0f4kuiGvj7416bKNNR/lSJwsdHorj486FqlBMNgQGfXEvMddwfzQbH dRq6KERFpQSr884FqYinRPwP44Bd/EvEbcQodAgNaQj9QtZc+J+PfTYCCqpNHuDV0zry 8mRH8UO2cLrClbSwE6qr45F2zBbuXAx0gfTLeANcCvjk+AQAg8k9++1+TxGZ0StqldEM ++Z/Jyy5x0w9l9CcceU2UeonpWaX68wdkHz5/bkjyY0p3X7OnOb6yMTjJEsSQMy0k3Yy cTR6y5w+QGybLpKFrXzVxI72M7ixmtOoZgny+PYWxIatglZFyWZ1QZMjKrWraBRBMjEc Fktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252261; x=1718857061; 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=iVG1hooISUIjolQvzpMxZSslS3Wph3h8y/hMHfcV0Ns=; b=vqI/JNgqvlVML1df2Bj2O3ZXuQ2pAEK3QceYRCDOkP16nbNojZ1kTVn6UCaMgpjAFS 0HXhNICffpgbAPrN3CuafFLy2Y5cqrx65uWRIo7vXgCIyLBBvbWxMt4vdVu3F0/YUbYV JzFfL5/XwuhFqQyayStIZjMFqpD3mBv4GaaTpON/lw03uLj8LVrRR8VstooGBGmgDpBg q6Z+zNas/pfkeDtDh4GclFoqblI4tprG7fwSMHO3ReNtbBZ3tP20y/Me3juJqik5eARd rgqMHEezcQSsZf/zpUlN60mY5tQus7Rn+ziTXIW4f9foSeic+rl/kzLFlM6pjzPL1wqH 6HnA== X-Gm-Message-State: AOJu0YyUMJZcXVGNhgnD/BmLJtdzrILbzkzLGIIZEggWRJDV1swBFF8P 9Xm1dM/vJ3BnEoeYr48PXs01cZOE4IcWo8BNnd69y9h4R2rf2QulZdKE X-Google-Smtp-Source: AGHT+IF7PjOKBPRnlYHKc9QQyYK4o7dbSWt4RuI4M8wmZkoXuL1GpG9m1MaYhvhrs6LzbTqFqGXxig== X-Received: by 2002:a05:6214:2f01:b0:6b0:6c40:ccf0 with SMTP id 6a1803df08f44-6b192028c43mr49259196d6.20.1718252261099; Wed, 12 Jun 2024 21:17:41 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:40 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 02/19] NFSv4: Refactor nfs4_opendata_check_deleg() Date: Thu, 13 Jun 2024 00:11:19 -0400 Message-ID: <20240613041136.506908-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-2-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Modify it to no longer depend directly on the struct opendata. This will enable sharing with WANT_DELEGATION. Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 66 +++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index d3781ce7e0a5..639f075e01e9 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1954,51 +1954,39 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) } static void -nfs4_opendata_check_deleg(struct nfs4_opendata *data, struct nfs4_state *state) +nfs4_process_delegation(struct inode *inode, const struct cred *cred, + enum open_claim_type4 claim, + const struct nfs4_open_delegation *delegation) { - struct nfs_client *clp = NFS_SERVER(state->inode)->nfs_client; - struct nfs_delegation *delegation; - int delegation_flags = 0; - - switch (data->o_res.delegation.open_delegation_type) { + switch (delegation->open_delegation_type) { case NFS4_OPEN_DELEGATE_READ: case NFS4_OPEN_DELEGATE_WRITE: break; default: return; - }; - rcu_read_lock(); - delegation = rcu_dereference(NFS_I(state->inode)->delegation); - if (delegation) - delegation_flags = delegation->flags; - rcu_read_unlock(); - switch (data->o_arg.claim) { - default: - break; + } + switch (claim) { case NFS4_OPEN_CLAIM_DELEGATE_CUR: case NFS4_OPEN_CLAIM_DELEG_CUR_FH: pr_err_ratelimited("NFS: Broken NFSv4 server %s is " "returning a delegation for " "OPEN(CLAIM_DELEGATE_CUR)\n", - clp->cl_hostname); - return; + NFS_SERVER(inode)->nfs_client->cl_hostname); + break; + case NFS4_OPEN_CLAIM_PREVIOUS: + nfs_inode_reclaim_delegation(inode, cred, + delegation->type, + &delegation->stateid, + delegation->pagemod_limit); + break; + default: + nfs_inode_set_delegation(inode, cred, + delegation->type, + &delegation->stateid, + delegation->pagemod_limit); } - if ((delegation_flags & 1UL<inode, - data->owner->so_cred, - data->o_res.delegation.type, - &data->o_res.delegation.stateid, - data->o_res.delegation.pagemod_limit); - else - nfs_inode_reclaim_delegation(state->inode, - data->owner->so_cred, - data->o_res.delegation.type, - &data->o_res.delegation.stateid, - data->o_res.delegation.pagemod_limit); - - if (data->o_res.delegation.do_recall) - nfs_async_inode_return_delegation(state->inode, - &data->o_res.delegation.stateid); + if (delegation->do_recall) + nfs_async_inode_return_delegation(inode, &delegation->stateid); } /* @@ -2022,7 +2010,10 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data) if (ret) return ERR_PTR(ret); - nfs4_opendata_check_deleg(data, state); + nfs4_process_delegation(state->inode, + data->owner->so_cred, + data->o_arg.claim, + &data->o_res.delegation); if (!update_open_stateid(state, &data->o_res.stateid, NULL, data->o_arg.fmode)) @@ -2089,8 +2080,11 @@ _nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) if (IS_ERR(state)) goto out; - if (data->o_res.delegation.type != 0) - nfs4_opendata_check_deleg(data, state); + nfs4_process_delegation(state->inode, + data->owner->so_cred, + data->o_arg.claim, + &data->o_res.delegation); + if (!update_open_stateid(state, &data->o_res.stateid, NULL, data->o_arg.fmode)) { nfs4_put_open_state(state); From patchwork Thu Jun 13 04:11:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696089 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.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 3291C4084E for ; Thu, 13 Jun 2024 04:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252264; cv=none; b=Wx+DDb4ZuMDH/x0VzagSB5I++xuebu5l86FpFwYsY9RtHf/OkCSd7E4SEv8nN3ITrCgYeGlxjx9lnSgxVne9FJeLXOtmRnr0whxW/rTxpPaXNqHOWf02nVmazt9Vh98eT0GdMJ2lLXkDvTLUvPTtk2TABQ8GOAoGTB34FKJvwtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252264; c=relaxed/simple; bh=4DpuIv/XKePEoOz/wMeCOu1qC6FKeWU8sPXC/I4ZWSM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TDdnfnRF1AixRutTK/M95cjwwuBJDQ+MK0YFWcniT969A+0AiGMCZS56Q0NEgy0Rr+diyjjZIVuXuKAfuGz4cw6Ci3OaBp7k0emM/EkJ/PIw3owhMjcvXKKkK817T6BQE/Sz4gnyRPtrd552jkL2Xo0Xk+E6FdY2cpmF/XZuFLs= 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=CQzrXj4V; arc=none smtp.client-ip=209.85.160.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="CQzrXj4V" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-44056295c8cso2948431cf.3 for ; Wed, 12 Jun 2024 21:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252262; x=1718857062; 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=y54cIM5xzZkxpTVACLvhO5OLYhYLH77S4+KM+7kOVrU=; b=CQzrXj4VcsIQjPKeiUkvnCanvDb5vunHb4ZX/TzXRCpmQrWZI1dRAzsa9lS7Cm65tH MZzmNwYr5i1ID+6fSMrlcuukB9ZlMR5yWGZ9SxtZXZWjzZiB5uVCPGf5lqVHzOOqXn1Q okqrjf4P/gDK67g+X80KUG5lzzvCye+5TKM+fnAlUMzVT+diUj7mT+VKszoLkT/4TkbW 11aXKCY+db1gwctYKhuDJ6sSKzTMd88xRguepjS0NE9sg2iBVRuyl/OctizeMUZ0Fkr3 w/XRDDNX35JLepF971JN1Rhh0bkY96baTP0UrWcPQd/KWoB/i5miE6wb8dlyRiEvpjCs 9F4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252262; x=1718857062; 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=y54cIM5xzZkxpTVACLvhO5OLYhYLH77S4+KM+7kOVrU=; b=lxxiaC8EuFNUjv59hfEyxBOANnpikAJFL54JTRQPWPfGqVs1Dz6sDI0LltQNKfxwKV fZ8pXpceskVtS05KlFqMbKvliPS/dTDGU6/HowZp3biBV0rVrCV7h510iWSFnl1IkRiS Huwib7Vv4XGnp8wG0pofqGfPs1+/F6SK4wMzVF0NBB229vQyr9/wpSATmgb+HbqKwQgt w3l/v/2hZ1G+JwPIggslSQMfJ8SwLNSZnb/JxI50pWn6wt6y6dKchMciKk6ObitirGy0 1In9V2QCmdJK1moWkz/ROpzrTzURYDGk7dbrRVpzzizO75mvJQqFPLhqKDKqIy/kv5oL K4Qw== X-Gm-Message-State: AOJu0YzIsStP0VBulixxFErQU59fCBWzCjSQ877q8oihviuBoTANdNS8 HgsvMvmr1w1zaDLUO6vQVAfe8u4YPW71qzxGWNJ8HMGgxSp6AYlukrgN X-Google-Smtp-Source: AGHT+IG2t9eDgBgfi4SR5+SbkzrJYmt9f/9BornQAfsyyLsD0i9xZd6EUQvqO40JZb5/I44pIt0Xtw== X-Received: by 2002:a05:6214:2b93:b0:6b0:7f36:8ae1 with SMTP id 6a1803df08f44-6b1a731b5b9mr38278526d6.52.1718252261693; Wed, 12 Jun 2024 21:17:41 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:41 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 03/19] NFSv4: Add new attribute delegation definitions Date: Thu, 13 Jun 2024 00:11:20 -0400 Message-ID: <20240613041136.506908-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-3-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Signed-off-by: Tom Haynes Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 2 +- include/linux/nfs4.h | 9 +++++++++ include/uapi/linux/nfs4.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 639f075e01e9..ce47cf2f9301 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3852,7 +3852,7 @@ static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) #define FATTR4_WORD1_NFS40_MASK (2*FATTR4_WORD1_MOUNTED_ON_FILEID - 1UL) #define FATTR4_WORD2_NFS41_MASK (2*FATTR4_WORD2_SUPPATTR_EXCLCREAT - 1UL) -#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_XATTR_SUPPORT - 1UL) +#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_TIME_DELEG_MODIFY - 1UL) static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) { diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index ef8d2d618d5b..bc13d7f04e8d 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -367,6 +367,8 @@ enum open_delegation_type4 { NFS4_OPEN_DELEGATE_READ = 1, NFS4_OPEN_DELEGATE_WRITE = 2, NFS4_OPEN_DELEGATE_NONE_EXT = 3, /* 4.1 */ + NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG = 4, + NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG = 5, }; enum why_no_delegation4 { /* new to v4.1 */ @@ -507,6 +509,11 @@ enum { FATTR4_XATTR_SUPPORT = 82, }; +enum { + FATTR4_TIME_DELEG_ACCESS = 84, + FATTR4_TIME_DELEG_MODIFY = 85, +}; + /* * The following internal definitions enable processing the above * attribute bits within 32-bit word boundaries. @@ -586,6 +593,8 @@ enum { #define FATTR4_WORD2_SECURITY_LABEL BIT(FATTR4_SEC_LABEL - 64) #define FATTR4_WORD2_MODE_UMASK BIT(FATTR4_MODE_UMASK - 64) #define FATTR4_WORD2_XATTR_SUPPORT BIT(FATTR4_XATTR_SUPPORT - 64) +#define FATTR4_WORD2_TIME_DELEG_ACCESS BIT(FATTR4_TIME_DELEG_ACCESS - 64) +#define FATTR4_WORD2_TIME_DELEG_MODIFY BIT(FATTR4_TIME_DELEG_MODIFY - 64) /* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0) diff --git a/include/uapi/linux/nfs4.h b/include/uapi/linux/nfs4.h index 1d2043708bf1..afd7e32906c3 100644 --- a/include/uapi/linux/nfs4.h +++ b/include/uapi/linux/nfs4.h @@ -69,6 +69,8 @@ #define NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL 0x10000 #define NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED 0x20000 +#define NFS4_SHARE_WANT_DELEG_TIMESTAMPS 0x100000 + #define NFS4_CDFC4_FORE 0x1 #define NFS4_CDFC4_BACK 0x2 #define NFS4_CDFC4_BOTH 0x3 From patchwork Thu Jun 13 04:11:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696090 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.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 169F0132114 for ; Thu, 13 Jun 2024 04:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252265; cv=none; b=rXFvpKa1gGUhsAuUvMq0NX9MGklgAyuxl2BKy7dxBtfUHgppt1ZRM1upj3Xvl/aMpOLKioBNtxc3izueIot1/fdREaUuwBl8/wqei2u0yMeBYltL//zr3jmzCPogA+UqehKuh+Mq1M0H1PR3lGKECen8gyVZdMQo320JY6VZykU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252265; c=relaxed/simple; bh=RKnx8TqGkworGn0L2i8+t79TZpqlV/3OSdHEWmd7FYQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fy5kGweicMsbEL4OPk0TcsgJjo532BUtExqA9QLe45vD4Y8U0ksuJDNlC5qdCe/XdwyZPFLfhigbAgLF4NVCGtEpcrFxHDwa8ygNGCoZ5GXo3y2xILHuPBs+YDGNN3owkRda7+D5VjTRcI4IWqAU2jQ2Gi3dRXm1Mpj+QtPqmd8= 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=JZdYqWag; arc=none smtp.client-ip=209.85.128.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="JZdYqWag" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-62a2424ed00so7585147b3.1 for ; Wed, 12 Jun 2024 21:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252263; x=1718857063; 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=kECqbDJ7em0dM3SPVzyC3iT2ndqlyqpNW4GykyAK58M=; b=JZdYqWaguCfb1q72WpOVlVzdxInw7hRgHCjhR2w9w/IoqBHnTzHoMjPqy9pU4826NO AWetYXtOxxsT2/o+KrAsbLPPEYAWCxPbk0vSMHXrhQdRKzuXHUZTDJ/0cgHC3VF3e6Lu OIdBqEidEBWIJ12axIic2M8BmarYZ4TeGS5EmRvpsKNtn39viWHL3sdY32M8bi/euJd0 62iZY+onY1cEmo+cEWluS2RtgYlY3JSBJx0s32BL1xeAfP/cHuGhJwUIMBpdSrIAbA1Z kdEw96367jsbmCbmT0231v40V6JegsiG2W00Xg1y/bkEVvW5lt89yatKpQF/x9XIA6Iw 5vrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252263; x=1718857063; 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=kECqbDJ7em0dM3SPVzyC3iT2ndqlyqpNW4GykyAK58M=; b=xCla6xvg1cJ3vfv1PCiBpDlXGE4F/4I0nroWqTp8vouSMlpr/IhT76dzLfQel/LRCp Hn1LlokSTqah1UPgsl4jpjNWHarTK3y4dnAnMCFwcXf6iq9H0xhETUXXzCr5fnQdMwi9 faEIb5cu/MkRvuR+mNKlc+xnXa88FxOSjpK3D5TQ0SLRW8SfIPTvLgsqr7eqFoS6sDG5 ASkVqD56ojOGikQs04W+brnmSg1xx4YTfN8M4yvXDsN1A/ogSkpYzq/kOdlhQP482i3A ouGp7BRsw6GAFbIGZL8YoxlELd5HHYCrEpO+a/AqwsOrtrNP5JZ4iQZWv77S4ROWW4jQ goDg== X-Gm-Message-State: AOJu0Yy+VbedLdjpe50CzT9MBy7yw95yDjHf3odO8Ez/K5jtmEsfvVyK rtkI9l3LiQano2fzeB2/VzP7NvzB5Wf1o70VkiE40Gi7bgIZ5FPOgESI X-Google-Smtp-Source: AGHT+IFAsjQrJmO4JStcRzOKEPqDlMq/m8ukebpB+yxhbsDIeGLTr3E5AxFHNRAodlLsd7UI+fuEvw== X-Received: by 2002:a25:df8e:0:b0:dfd:c2df:32 with SMTP id 3f1490d57ef6-dfe68d07110mr3391563276.63.1718252262705; Wed, 12 Jun 2024 21:17:42 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:42 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 04/19] NFSv4: Plumb in XDR support for the new delegation-only setattr op Date: Thu, 13 Jun 2024 00:11:21 -0400 Message-ID: <20240613041136.506908-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-4-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-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 We want to send the updated atime and mtime as part of the delegreturn compound. Add a special structure to hold those variables. Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 25 ++++++++++++++++++++ fs/nfs/nfs4xdr.c | 51 +++++++++++++++++++++++++++++++++++++++++ include/linux/nfs_xdr.h | 10 ++++++++ 3 files changed, 86 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ce47cf2f9301..0ed734ab448e 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6554,6 +6554,7 @@ struct nfs4_delegreturndata { u32 roc_barrier; bool roc; } lr; + struct nfs4_delegattr sattr; struct nfs_fattr fattr; int rpc_status; struct inode *inode; @@ -6578,6 +6579,30 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) &data->res.lr_ret) == -EAGAIN) goto out_restart; + if (data->args.sattr_args && task->tk_status != 0) { + switch(data->res.sattr_ret) { + case 0: + data->args.sattr_args = NULL; + data->res.sattr_res = false; + break; + case -NFS4ERR_ADMIN_REVOKED: + case -NFS4ERR_DELEG_REVOKED: + case -NFS4ERR_EXPIRED: + case -NFS4ERR_BAD_STATEID: + /* Let the main handler below do stateid recovery */ + break; + case -NFS4ERR_OLD_STATEID: + if (nfs4_refresh_delegation_stateid(&data->stateid, + data->inode)) + goto out_restart; + fallthrough; + default: + data->args.sattr_args = NULL; + data->res.sattr_res = false; + goto out_restart; + } + } + switch (task->tk_status) { case 0: renew_lease(data->res.server, data->timestamp); diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 119061da5298..4c22b865b9c9 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -224,6 +224,11 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, encode_attrs_maxsz) #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ nfs4_fattr_bitmap_maxsz) +#define encode_delegattr_maxsz (op_encode_hdr_maxsz + \ + encode_stateid_maxsz + \ + nfs4_fattr_bitmap_maxsz + \ + 2*nfstime4_maxsz) +#define decode_delegattr_maxsz (decode_setattr_maxsz) #define encode_read_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + 3) #define decode_read_maxsz (op_decode_hdr_maxsz + 2 + pagepad_maxsz) @@ -758,12 +763,14 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, encode_sequence_maxsz + \ encode_putfh_maxsz + \ encode_layoutreturn_maxsz + \ + encode_delegattr_maxsz + \ encode_delegreturn_maxsz + \ encode_getattr_maxsz) #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ decode_sequence_maxsz + \ decode_putfh_maxsz + \ decode_layoutreturn_maxsz + \ + decode_delegattr_maxsz + \ decode_delegreturn_maxsz + \ decode_getattr_maxsz) #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ @@ -1735,6 +1742,33 @@ static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs server->attr_bitmask); } +static void encode_delegattr(struct xdr_stream *xdr, + const nfs4_stateid *stateid, + const struct nfs4_delegattr *attr, + struct compound_hdr *hdr) +{ + uint32_t bitmap[3] = { 0 }; + uint32_t len = 0; + __be32 *p; + + encode_op_hdr(xdr, OP_SETATTR, encode_delegattr_maxsz, hdr); + encode_nfs4_stateid(xdr, stateid); + if (attr->atime_set) { + bitmap[2] |= FATTR4_WORD2_TIME_DELEG_ACCESS; + len += (nfstime4_maxsz << 2); + } + if (attr->mtime_set) { + bitmap[2] |= FATTR4_WORD2_TIME_DELEG_MODIFY; + len += (nfstime4_maxsz << 2); + } + xdr_encode_bitmap4(xdr, bitmap, ARRAY_SIZE(bitmap)); + xdr_stream_encode_opaque_inline(xdr, (void **)&p, len); + if (bitmap[2] & FATTR4_WORD2_TIME_DELEG_ACCESS) + p = xdr_encode_nfstime4(p, &attr->atime); + if (bitmap[2] & FATTR4_WORD2_TIME_DELEG_MODIFY) + p = xdr_encode_nfstime4(p, &attr->mtime); +} + static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr) { __be32 *p; @@ -2812,6 +2846,8 @@ static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, encode_putfh(xdr, args->fhandle, &hdr); if (args->lr_args) encode_layoutreturn(xdr, args->lr_args, &hdr); + if (args->sattr_args) + encode_delegattr(xdr, args->stateid, args->sattr_args, &hdr); if (args->bitmask) encode_getfattr(xdr, args->bitmask, &hdr); encode_delegreturn(xdr, args->stateid, &hdr); @@ -5163,9 +5199,11 @@ static int decode_rw_delegation(struct xdr_stream *xdr, switch (res->open_delegation_type) { case NFS4_OPEN_DELEGATE_READ: + case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG: res->type = FMODE_READ; break; case NFS4_OPEN_DELEGATE_WRITE: + case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG: res->type = FMODE_WRITE|FMODE_READ; if (decode_space_limit(xdr, &res->pagemod_limit) < 0) return -EIO; @@ -5207,6 +5245,8 @@ static int decode_delegation(struct xdr_stream *xdr, return 0; case NFS4_OPEN_DELEGATE_READ: case NFS4_OPEN_DELEGATE_WRITE: + case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG: + case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG: return decode_rw_delegation(xdr, res); case NFS4_OPEN_DELEGATE_NONE_EXT: return decode_no_delegation(xdr, res); @@ -5480,6 +5520,11 @@ static int decode_setattr(struct xdr_stream *xdr) return -EIO; } +static int decode_delegattr(struct xdr_stream *xdr) +{ + return decode_setattr(xdr); +} + static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res) { __be32 *p; @@ -7052,6 +7097,12 @@ static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, if (status) goto out; } + if (res->sattr_res) { + status = decode_delegattr(xdr); + res->sattr_ret = status; + if (status) + goto out; + } if (res->fattr) { status = decode_getfattr(xdr, res->fattr, res->server); if (status != 0) diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 682559e19d9d..f40be64ce942 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -622,6 +622,13 @@ struct nfs_release_lockowner_res { struct nfs4_sequence_res seq_res; }; +struct nfs4_delegattr { + struct timespec64 atime; + struct timespec64 mtime; + bool atime_set; + bool mtime_set; +}; + struct nfs4_delegreturnargs { struct nfs4_sequence_args seq_args; const struct nfs_fh *fhandle; @@ -629,6 +636,7 @@ struct nfs4_delegreturnargs { const u32 *bitmask; u32 bitmask_store[NFS_BITMASK_SZ]; struct nfs4_layoutreturn_args *lr_args; + struct nfs4_delegattr *sattr_args; }; struct nfs4_delegreturnres { @@ -637,6 +645,8 @@ struct nfs4_delegreturnres { struct nfs_server *server; struct nfs4_layoutreturn_res *lr_res; int lr_ret; + bool sattr_res; + int sattr_ret; }; /* From patchwork Thu Jun 13 04:11:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696091 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 778B04084E for ; Thu, 13 Jun 2024 04:17:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252267; cv=none; b=MjI60OjvJ7d3D54KY0dP0DXThUxi0Gk3qwNtw1u1tPBRqlp0PAPZKQcpzMuhhrGBjHbVjel4rPqGIVKC6wc69Ax1OTwZD0XMoS5cmSaYzOWcExN61jV2pDgNneALOS9CUmK1zRTbLd8MJYTGQVXoqYRyacNhKJrtGhcEqZsrRdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252267; c=relaxed/simple; bh=Zir1trA8aA0mdOMcxTqe6KNFw64sqlwAtuGb9oZl+vo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D7StJt7krHFTNVCxwAPwuagrPNCjI2jLFz+ydTMVnXfQULSIHANrYhip/Z18tWGEMgAKsCuZEUG1KJwuGHz6kz0zgOdG0+7Ov1rQRrlxkXGweHFTjv0JWDYpup1ej+ad6KcW04Nl7N1Jh6o5PCUdbGBbK+pHZdJq2/BeAHCndTU= 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=npL0HhkW; arc=none smtp.client-ip=209.85.219.49 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="npL0HhkW" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6ad86f3cc34so2772286d6.1 for ; Wed, 12 Jun 2024 21:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252264; x=1718857064; 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=5HpetJNYjrXkHtczPdfKK2xFtaKCa5qOKIfYi3lbXsA=; b=npL0HhkWjapejYYLEbYRJx0m89NK3EEvurN5hv5WUbqT488MfDpJs+5DhPggOgVbGh l4BQ79lTOAFBDc0e6lHB9lYZgxln9dsLi4PehjYgbgOLQ/TufUjnxXglYzttnM0Tl83v SkCzeSwmWbNyIj0zdI6Xlex+hR3gCPbBTro285iskFFWbiwXemMFzQnI4Mt1DbSZUHx6 m0yzRhi27dKnINBoxZnJrrSJSl97KJNt4j6rUjFkzp3p64vjKToIZfTizb7r1kLXA6Z/ pBjamTBjLGazGtAXiN1RiLzE6qYuk+monubakDf9JrQf7pcPYDO17JJig/qf7/unjPEq epjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252264; x=1718857064; 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=5HpetJNYjrXkHtczPdfKK2xFtaKCa5qOKIfYi3lbXsA=; b=sjjHnxft7v3cxwQYLsSwWlD2WX8gvqX+d26Iq9YtM43ZQFDD/Y2qIgm/Ggn4vrXk8V 1TcnglX7GkMzBJrVrCIrX27pPfQYO/SNBgKbSlTBxCYuVDWGxzHoFxImXisFLTnXgrqb KB6Rv7dTW0IOrWcgRmrOawD5UzaP1bMgZxmMEAkkG4AN9ZubF5ZUntSJY+ze0NPjhA8d OSrkeVSMXxx8ulGH8DrETJZ2Yr6MiR7SfOgo/gHIM8SebWMPc4X9XRPr0QLeVH3lCtyS KEhW1SqAdjhlxgMqgD4rzA+dRsKJjpj5WZoyyuOOXUZSwTsEX/9GbQLWSWnb8WcvroPJ +gEA== X-Gm-Message-State: AOJu0YyCmol5IAoljoYE6e7ZWjYqyHQeuJoctxpiaMWLFNwPWLh6y2JF wo8WouYC+eQzVJvBr2pV5YkCrRmJAJnh8P7D4cTXUWLf5cfUWOelLAyi X-Google-Smtp-Source: AGHT+IGdtBe/uKKTL06QGz8yaZErBoQMeHbYMtJzbPdy6XMo2cDLA4P1l3M5W3uldgKmoepnJg5MFw== X-Received: by 2002:a05:6214:5544:b0:6b0:92f4:7ca5 with SMTP id 6a1803df08f44-6b1a712e064mr38579026d6.54.1718252263695; Wed, 12 Jun 2024 21:17:43 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:43 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 05/19] NFSv4: Add CB_GETATTR support for delegated attributes Date: Thu, 13 Jun 2024 00:11:22 -0400 Message-ID: <20240613041136.506908-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-5-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/callback.h | 5 +++-- fs/nfs/callback_proc.c | 14 +++++++++----- fs/nfs/callback_xdr.c | 39 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index 650758ee0d5f..154a6ed1299f 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h @@ -46,14 +46,15 @@ struct cb_compound_hdr_res { struct cb_getattrargs { struct nfs_fh fh; - uint32_t bitmap[2]; + uint32_t bitmap[3]; }; struct cb_getattrres { __be32 status; - uint32_t bitmap[2]; + uint32_t bitmap[3]; uint64_t size; uint64_t change_attr; + struct timespec64 atime; struct timespec64 ctime; struct timespec64 mtime; }; diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 76cea34477ae..199c52788640 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -37,7 +37,7 @@ __be32 nfs4_callback_getattr(void *argp, void *resp, if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */ goto out; - res->bitmap[0] = res->bitmap[1] = 0; + memset(res->bitmap, 0, sizeof(res->bitmap)); res->status = htonl(NFS4ERR_BADHANDLE); dprintk_rcu("NFS: GETATTR callback request from %s\n", @@ -59,12 +59,16 @@ __be32 nfs4_callback_getattr(void *argp, void *resp, res->change_attr = delegation->change_attr; if (nfs_have_writebacks(inode)) res->change_attr++; + res->atime = inode_get_atime(inode); res->ctime = inode_get_ctime(inode); res->mtime = inode_get_mtime(inode); - res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) & - args->bitmap[0]; - res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) & - args->bitmap[1]; + res->bitmap[0] = (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE) & + args->bitmap[0]; + res->bitmap[1] = (FATTR4_WORD1_TIME_ACCESS | + FATTR4_WORD1_TIME_METADATA | + FATTR4_WORD1_TIME_MODIFY) & args->bitmap[1]; + res->bitmap[2] = (FATTR4_WORD2_TIME_DELEG_ACCESS | + FATTR4_WORD2_TIME_DELEG_MODIFY) & args->bitmap[2]; res->status = 0; out_iput: rcu_read_unlock(); diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 9369488f2ed4..29c49a7e5fe1 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c @@ -25,8 +25,9 @@ #define CB_OP_GETATTR_BITMAP_MAXSZ (4 * 4) // bitmap length, 3 bitmaps #define CB_OP_GETATTR_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ CB_OP_GETATTR_BITMAP_MAXSZ + \ - /* change, size, ctime, mtime */\ - (2 + 2 + 3 + 3) * 4) + /* change, size, atime, ctime, + * mtime, deleg_atime, deleg_mtime */\ + (2 + 2 + 3 + 3 + 3 + 3 + 3) * 4) #define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) #if defined(CONFIG_NFS_V4_1) @@ -635,6 +636,13 @@ static __be32 encode_attr_time(struct xdr_stream *xdr, const struct timespec64 * return 0; } +static __be32 encode_attr_atime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec64 *time) +{ + if (!(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) + return 0; + return encode_attr_time(xdr,time); +} + static __be32 encode_attr_ctime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec64 *time) { if (!(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) @@ -649,6 +657,24 @@ static __be32 encode_attr_mtime(struct xdr_stream *xdr, const uint32_t *bitmap, return encode_attr_time(xdr,time); } +static __be32 encode_attr_delegatime(struct xdr_stream *xdr, + const uint32_t *bitmap, + const struct timespec64 *time) +{ + if (!(bitmap[2] & FATTR4_WORD2_TIME_DELEG_ACCESS)) + return 0; + return encode_attr_time(xdr,time); +} + +static __be32 encode_attr_delegmtime(struct xdr_stream *xdr, + const uint32_t *bitmap, + const struct timespec64 *time) +{ + if (!(bitmap[2] & FATTR4_WORD2_TIME_DELEG_MODIFY)) + return 0; + return encode_attr_time(xdr,time); +} + static __be32 encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compound_hdr_res *hdr) { __be32 status; @@ -697,12 +723,21 @@ static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr, if (unlikely(status != 0)) goto out; status = encode_attr_size(xdr, res->bitmap, res->size); + if (unlikely(status != 0)) + goto out; + status = encode_attr_atime(xdr, res->bitmap, &res->atime); if (unlikely(status != 0)) goto out; status = encode_attr_ctime(xdr, res->bitmap, &res->ctime); if (unlikely(status != 0)) goto out; status = encode_attr_mtime(xdr, res->bitmap, &res->mtime); + if (unlikely(status != 0)) + goto out; + status = encode_attr_delegatime(xdr, res->bitmap, &res->atime); + if (unlikely(status != 0)) + goto out; + status = encode_attr_delegmtime(xdr, res->bitmap, &res->mtime); *savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1))); out: return status; From patchwork Thu Jun 13 04:11:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696092 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 23D76132811 for ; Thu, 13 Jun 2024 04:17:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252268; cv=none; b=YIXofSIVE5upZ6xt/9YbnPcic/H7q9H9GQTN313y1c5vAQ6EZ8g8IR7EAGqollloSNJrFZOvaGzRazCwMbZTzQT5sw8Bc8tjDYfcnHIXFlUrmfeMHAZ0wGV5NPoC8t8yJGtIOKMpWm9/mVWAUB/1MCMpSk57SijBJuxvF9NJI1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252268; c=relaxed/simple; bh=yhdNvFn9uVnhwgZy+rADuQU1YlBZItMBetAWtInX/H0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IzAWby7/BZqOeQdXz+Ky6urMs1jmMryVgyVC6HGExDWyxpho+zzcX4vrkUSjW1/88UVNBsf67N2bpt9D/bzXMrzPHs1ZQvnWb5DhfrrNA4PsnGEJ7rtfrVg+msEN/QFGtfg7iRG1eQ6NbE2UOtiSeZ7rWf1PXO5GY2rb7nAgzVE= 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=kG8pXTRQ; arc=none smtp.client-ip=209.85.128.181 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="kG8pXTRQ" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6301aa3a89eso6600017b3.2 for ; Wed, 12 Jun 2024 21:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252265; x=1718857065; 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=352dKP4GAqpQzxwich6A8f9MPwb5Kt/tjt5E2AhScgU=; b=kG8pXTRQAYds/ufitJ6flKPCesBpzZQbVWitu5o4O/Wt4GSlxPMoqyQfBEJx7z+orY hNE7eLmDe6w6HFBRONbNgQsIfSDRLagbmiuVpL4EgxtmKqnyv02Ah/q0zVrvb04y9zl6 lRURCYCVYkuXojbSxOCte5UUp/Zl4r+4ZlD4BokrLb5BsTWPhywnSA+ujkCnMLCIv/d7 BkYVZjpWoTKYLNgvCCfIYc2iih+w3sUQ0NP1ML4GAjohYH0iN5kJ9Bety+fHaWFkzK6Q jn8Sxib2ekzMzlg41wygLHrZvKSMLLFTMpnd/Bo0O8PZNSPZVyz2wlSCFSdROaSTbJaX bgFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252265; x=1718857065; 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=352dKP4GAqpQzxwich6A8f9MPwb5Kt/tjt5E2AhScgU=; b=hPKIvPbaZHMxJejK0Yc82P9bYr60AZ9FTCjwjHbfYLN5CJo4FUtFusd4eseIR2BkeY +RuaXMewLmT30EzjMy0I3E72A2k+BkeZs+ytrsHAw4LJU7ehiLTwbxg81sw5aF95x7hv pPSk4Utxgn1H8qdohtz8iiXbzTMGywkma4X0wg2C+QHyMSYjEyy6jQ3IJ1c+Ney3u/aX kPNuOpsDWDh5XcxvobW9UnotYwMMao2Ngo4nzeVIxDOUYGPF6RXZYTyWSiBTiwVQxmo0 AuJS4LQTScoJzGQEUcGLlhQckmvSYjZLH4Jj3UWLcQin9AkjnvAqWjmeUR4baPsnC34s zfHA== X-Gm-Message-State: AOJu0YwgKlORPztK0oRV+oqqWUIK1GQ3IaotNzxUeD1C+5FLJF3STHg8 tgJ6RgBCsdWAxmfk5od/nEn385PxneQMOX93lrIWp1GlFMYkxbLZmBzR X-Google-Smtp-Source: AGHT+IH/LYkb46Dd/qjWcc2Asg0yycR86irGdmXCFRb6WNrYgDv16ssptfA20T0ZIR3L86kQPtEdFw== X-Received: by 2002:a81:6908:0:b0:627:dfbd:89e with SMTP id 00721157ae682-62fbb7f5e56mr39431377b3.11.1718252264587; Wed, 12 Jun 2024 21:17:44 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:44 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 06/19] NFSv4: Add a flags argument to the 'have_delegation' callback Date: Thu, 13 Jun 2024 00:11:23 -0400 Message-ID: <20240613041136.506908-7-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-6-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 26 +++++++++++++------------- fs/nfs/delegation.h | 16 +++++++++++++--- fs/nfs/dir.c | 2 +- fs/nfs/file.c | 4 ++-- fs/nfs/inode.c | 7 +++---- fs/nfs/nfs3proc.c | 2 +- fs/nfs/nfs4proc.c | 14 +++++++------- fs/nfs/proc.c | 2 +- fs/nfs/write.c | 2 +- include/linux/nfs_xdr.h | 2 +- 10 files changed, 43 insertions(+), 34 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 6bace5fece04..6fdffd25cb2b 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -82,11 +82,10 @@ static void nfs_mark_return_delegation(struct nfs_server *server, set_bit(NFS4CLNT_DELEGRETURN, &server->nfs_client->cl_state); } -static bool -nfs4_is_valid_delegation(const struct nfs_delegation *delegation, - fmode_t flags) +static bool nfs4_is_valid_delegation(const struct nfs_delegation *delegation, + fmode_t type) { - if (delegation != NULL && (delegation->type & flags) == flags && + if (delegation != NULL && (delegation->type & type) == type && !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) return true; @@ -103,16 +102,16 @@ struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode) return NULL; } -static int -nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) +static int nfs4_do_check_delegation(struct inode *inode, fmode_t type, + int flags, bool mark) { struct nfs_delegation *delegation; int ret = 0; - flags &= FMODE_READ|FMODE_WRITE; + type &= FMODE_READ|FMODE_WRITE; rcu_read_lock(); delegation = rcu_dereference(NFS_I(inode)->delegation); - if (nfs4_is_valid_delegation(delegation, flags)) { + if (nfs4_is_valid_delegation(delegation, type)) { if (mark) nfs_mark_delegation_referenced(delegation); ret = 1; @@ -124,22 +123,23 @@ nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark) * nfs4_have_delegation - check if inode has a delegation, mark it * NFS_DELEGATION_REFERENCED if there is one. * @inode: inode to check - * @flags: delegation types to check for + * @type: delegation types to check for + * @flags: various modifiers * * Returns one if inode has the indicated delegation, otherwise zero. */ -int nfs4_have_delegation(struct inode *inode, fmode_t flags) +int nfs4_have_delegation(struct inode *inode, fmode_t type, int flags) { - return nfs4_do_check_delegation(inode, flags, true); + return nfs4_do_check_delegation(inode, type, flags, true); } /* * nfs4_check_delegation - check if inode has a delegation, do not mark * NFS_DELEGATION_REFERENCED if it has one. */ -int nfs4_check_delegation(struct inode *inode, fmode_t flags) +int nfs4_check_delegation(struct inode *inode, fmode_t type) { - return nfs4_do_check_delegation(inode, flags, false); + return nfs4_do_check_delegation(inode, type, 0, false); } static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_stateid *stateid) diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index a6f495d012cf..257b3d726043 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -75,8 +75,8 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode); struct nfs_delegation *nfs4_get_valid_delegation(const struct inode *inode); void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); -int nfs4_have_delegation(struct inode *inode, fmode_t flags); -int nfs4_check_delegation(struct inode *inode, fmode_t flags); +int nfs4_have_delegation(struct inode *inode, fmode_t type, int flags); +int nfs4_check_delegation(struct inode *inode, fmode_t type); bool nfs4_delegation_flush_on_close(const struct inode *inode); void nfs_inode_find_delegation_state_and_recover(struct inode *inode, const nfs4_stateid *stateid); @@ -84,9 +84,19 @@ int nfs4_inode_make_writeable(struct inode *inode); #endif +static inline int nfs_have_read_or_write_delegation(struct inode *inode) +{ + return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0); +} + +static inline int nfs_have_write_delegation(struct inode *inode) +{ + return NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE, 0); +} + static inline int nfs_have_delegated_attributes(struct inode *inode) { - return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ); + return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0); } #endif diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 788077a4feb9..6b63d1ecd2c2 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1437,7 +1437,7 @@ static void nfs_set_verifier_locked(struct dentry *dentry, unsigned long verf) if (!dir || !nfs_verify_change_attribute(dir, verf)) return; - if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) + if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0)) nfs_set_verifier_delegated(&verf); dentry->d_time = verf; } diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 407c6e15afe2..8c13b9a41aaa 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -730,7 +730,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) } fl->c.flc_type = saved_type; - if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) + if (nfs_have_read_or_write_delegation(inode)) goto out_noconflict; if (is_local) @@ -813,7 +813,7 @@ do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) * This makes locking act as a cache coherency point. */ nfs_sync_mapping(filp->f_mapping); - if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) { + if (!nfs_have_read_or_write_delegation(inode)) { nfs_zap_caches(inode); if (mapping_mapped(filp->f_mapping)) nfs_revalidate_mapping(inode, filp->f_mapping); diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index acef52ecb1bb..89722919b463 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -190,9 +190,8 @@ static bool nfs_has_xattr_cache(const struct nfs_inode *nfsi) void nfs_set_cache_invalid(struct inode *inode, unsigned long flags) { struct nfs_inode *nfsi = NFS_I(inode); - bool have_delegation = NFS_PROTO(inode)->have_delegation(inode, FMODE_READ); - if (have_delegation) { + if (nfs_have_delegated_attributes(inode)) { if (!(flags & NFS_INO_REVAL_FORCED)) flags &= ~(NFS_INO_INVALID_MODE | NFS_INO_INVALID_OTHER | @@ -1012,7 +1011,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync) if (!is_sync) return; inode = d_inode(ctx->dentry); - if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) + if (nfs_have_read_or_write_delegation(inode)) return; nfsi = NFS_I(inode); if (inode->i_mapping->nrpages == 0) @@ -1482,7 +1481,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat unsigned long invalid = 0; struct timespec64 ts; - if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) + if (nfs_have_delegated_attributes(inode)) return 0; if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) { diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 74bda639a7cf..cab6c73d25d6 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -979,7 +979,7 @@ nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl) return status; } -static int nfs3_have_delegation(struct inode *inode, fmode_t flags) +static int nfs3_have_delegation(struct inode *inode, fmode_t type, int flags) { return 0; } diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 0ed734ab448e..27fb40653f1d 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -293,7 +293,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src, unsigned long cache_validity; memcpy(dst, src, NFS4_BITMASK_SZ*sizeof(*dst)); - if (!inode || !nfs4_have_delegation(inode, FMODE_READ)) + if (!inode || !nfs_have_read_or_write_delegation(inode)) return; cache_validity = READ_ONCE(NFS_I(inode)->cache_validity) | flags; @@ -1264,7 +1264,7 @@ nfs4_update_changeattr_locked(struct inode *inode, if (S_ISDIR(inode->i_mode)) nfs_force_lookup_revalidate(inode); - if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) + if (!nfs_have_delegated_attributes(inode)) cache_validity |= NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL | NFS_INO_INVALID_SIZE | NFS_INO_INVALID_OTHER | @@ -3700,7 +3700,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) if (calldata->arg.fmode == 0 || calldata->arg.fmode == FMODE_READ) { /* Close-to-open cache consistency revalidation */ - if (!nfs4_have_delegation(inode, FMODE_READ)) { + if (!nfs4_have_delegation(inode, FMODE_READ, 0)) { nfs4_bitmask_set(calldata->arg.bitmask_store, server->cache_consistency_bitmask, inode, 0); @@ -4617,7 +4617,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry }; int status = 0; - if (!nfs4_have_delegation(inode, FMODE_READ)) { + if (!nfs4_have_delegation(inode, FMODE_READ, 0)) { res.fattr = nfs_alloc_fattr(); if (res.fattr == NULL) return -ENOMEM; @@ -5586,7 +5586,7 @@ bool nfs4_write_need_cache_consistency_data(struct nfs_pgio_header *hdr) /* Otherwise, request attributes if and only if we don't hold * a delegation */ - return nfs4_have_delegation(hdr->inode, FMODE_READ) == 0; + return nfs4_have_delegation(hdr->inode, FMODE_READ, 0) == 0; } void nfs4_bitmask_set(__u32 bitmask[], const __u32 src[], @@ -7633,10 +7633,10 @@ static int nfs4_add_lease(struct file *file, int arg, struct file_lease **lease, int ret; /* No delegation, no lease */ - if (!nfs4_have_delegation(inode, type)) + if (!nfs4_have_delegation(inode, type, 0)) return -EAGAIN; ret = generic_setlease(file, arg, lease, priv); - if (ret || nfs4_have_delegation(inode, type)) + if (ret || nfs4_have_delegation(inode, type, 0)) return ret; /* We raced with a delegation return */ nfs4_delete_lease(file, priv); diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index d105e5b2659d..995cc42b0fa0 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -687,7 +687,7 @@ static int nfs_lock_check_bounds(const struct file_lock *fl) return -EINVAL; } -static int nfs_have_delegation(struct inode *inode, fmode_t flags) +static int nfs_have_delegation(struct inode *inode, fmode_t type, int flags) { return 0; } diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 5de85d725fb9..a9186b113fe7 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1320,7 +1320,7 @@ static int nfs_can_extend_write(struct file *file, struct folio *folio, return 0; if (!nfs_folio_write_uptodate(folio, pagelen)) return 0; - if (NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE)) + if (nfs_have_write_delegation(inode)) return 1; if (!flctx || (list_empty_careful(&flctx->flc_flock) && list_empty_careful(&flctx->flc_posix))) diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index f40be64ce942..51611583af51 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1830,7 +1830,7 @@ struct nfs_rpc_ops { int open_flags, struct iattr *iattr, int *); - int (*have_delegation)(struct inode *, fmode_t); + int (*have_delegation)(struct inode *, fmode_t, int); struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *); struct nfs_client *(*init_client) (struct nfs_client *, const struct nfs_client_initdata *); From patchwork Thu Jun 13 04:11:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696093 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 DDE24132114 for ; Thu, 13 Jun 2024 04:17:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252268; cv=none; b=H3+yIXtlHMygbwfX++eLwoYR2h/fzg/FOXHRt3e6cWRmvb/0RCX8onvASn5x+eTMXm1oLSAtQFT5oq5z3jlWxzD4aeGcEJtJzKJeptmMT4cYNW0R8hVF+Ex4hkefBPn342pqg3sx3Q7Z8cAnFg3nEr+MMU4SaTC5ZWa3xgzV80Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252268; c=relaxed/simple; bh=MyXJxOFduuOO7vIKV0xhXCDCHNuAU7aiT3TY9cIZI4U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a7OMw8TjKMQIFTHHk6PXY1dmiNgFHdKhCphaTISCpGUgv8NHlocWwA1jxfmcATvisxtFXeGt0y6mCNTi1xFKAqym2V3VGURCI4pxReUaZmB6z41ujtpR+U8D5CBj9qkGhI9bVI+jgYDj5msvxzneE+4JlhxX3glhG87vQERC9eE= 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=llnf1qWy; arc=none smtp.client-ip=209.85.222.178 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="llnf1qWy" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7955f3d4516so155065285a.1 for ; Wed, 12 Jun 2024 21:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252265; x=1718857065; 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=byFZqyYW/bRGDY2x6J39wtPoZv35HJsyt7GNtw2tAYk=; b=llnf1qWy5D3rImlqhTGgr0uz5lbG0H55S797tqfkxJ7t7PbsUVRJt7QZvYla0qbKxY i8z7vNxfddZsLD7xacYSduPCKKt8eiI3AW0rUn6fg7SxiA7XBlHlsqJBTqmjJWKEqBQ/ uDaVNlehQ6T4jLwZBgMlBCE9lQKE+K/XB9FI5yogcbNllPHAslXz1ejfy+X6s9UE0HUJ aF1vu12vFKExv8eUin9nIJvCOJXVyc7VCIFtc5a7aSAGYj4kUGpxGe92eP2lJ+mmTXiZ ACwJgZYgtiC4gKDrW1KbEZL8T0B2+d28ajFZHVIO5KFaKoKKXwbsRW+RTGrpnlnAEbfR FUow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252265; x=1718857065; 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=byFZqyYW/bRGDY2x6J39wtPoZv35HJsyt7GNtw2tAYk=; b=ZjRD61W6ec7aD4rSQqjnI98XBrUtU4bb3mTKG7kST0UkfhSDe07fFp8SIv2dERxi26 LbT7vd7CKNrm0lIqwnOAKXEXZiSv71mGSB378jNKL9zxbngM4UIb3uzDWYZtwrneWC8k Y5isJ+ro/wHeAmOAMbKeE1lET3Q3XQH5aNXStFADSm7iSs9xA1L5WM5tkDBMkt/iouHq kxv231BVg+evEX/ExVfX/n407y8UwseJu9QXMa/DLdZHJk6SBpfgugJ/nhcIyt/LUAnR 5j9x4AfepalyZT6LWNX1aZTA6RJ84PFG7BCZ3uyectObwRmkpX78ZUttUnde72Zzslkt HMaA== X-Gm-Message-State: AOJu0YxPsVafaqusZnYJ9KEMlui9fgg9BdDpe6el0U+wektFuLMt9y5n /j5Tp6APoQnKTMXW/ZCqA98+Zml2kSjDPJfdxiLsC012h1TkXXZAWA9C X-Google-Smtp-Source: AGHT+IFdpctwMr7K0SXsKYL5Y+QpBkIXB55yGN4lb8XwmtTRKjnhVQ/CrW9kbcEgbY4ADQSOT6QgTA== X-Received: by 2002:a05:6214:f6a:b0:6ab:9214:ffd3 with SMTP id 6a1803df08f44-6b2a343ccf8mr29238406d6.25.1718252265248; Wed, 12 Jun 2024 21:17:45 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:44 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 07/19] NFSv4: Add support for delegated atime and mtime attributes Date: Thu, 13 Jun 2024 00:11:24 -0400 Message-ID: <20240613041136.506908-8-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-7-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Ensure that we update the mtime and atime correctly when we read or write data to the file and when we truncate. Let the server manage ctime on other attribute updates. Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 24 +++++++++++++++----- fs/nfs/delegation.h | 25 +++++++++++++++++++-- fs/nfs/inode.c | 54 +++++++++++++++++++++++++++++++++++++++++---- fs/nfs/nfs4proc.c | 21 ++++++++++-------- fs/nfs/read.c | 3 +++ fs/nfs/write.c | 9 ++++++++ 6 files changed, 116 insertions(+), 20 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 6fdffd25cb2b..e72eead06c08 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -115,6 +115,9 @@ static int nfs4_do_check_delegation(struct inode *inode, fmode_t type, if (mark) nfs_mark_delegation_referenced(delegation); ret = 1; + if ((flags & NFS_DELEGATION_FLAG_TIME) && + !test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) + ret = 0; } rcu_read_unlock(); return ret; @@ -221,11 +224,12 @@ static int nfs_delegation_claim_opens(struct inode *inode, * @type: delegation type * @stateid: delegation stateid * @pagemod_limit: write delegation "space_limit" + * @deleg_type: raw delegation type * */ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, fmode_t type, const nfs4_stateid *stateid, - unsigned long pagemod_limit) + unsigned long pagemod_limit, u32 deleg_type) { struct nfs_delegation *delegation; const struct cred *oldcred = NULL; @@ -250,7 +254,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, } else { rcu_read_unlock(); nfs_inode_set_delegation(inode, cred, type, stateid, - pagemod_limit); + pagemod_limit, deleg_type); } } @@ -418,13 +422,13 @@ nfs_update_inplace_delegation(struct nfs_delegation *delegation, * @type: delegation type * @stateid: delegation stateid * @pagemod_limit: write delegation "space_limit" + * @deleg_type: raw delegation type * * Returns zero on success, or a negative errno value. */ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, - fmode_t type, - const nfs4_stateid *stateid, - unsigned long pagemod_limit) + fmode_t type, const nfs4_stateid *stateid, + unsigned long pagemod_limit, u32 deleg_type) { struct nfs_server *server = NFS_SERVER(inode); struct nfs_client *clp = server->nfs_client; @@ -444,6 +448,11 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, delegation->cred = get_cred(cred); delegation->inode = inode; delegation->flags = 1<flags |= BIT(NFS_DELEGATION_DELEGTIME); + } delegation->test_gen = 0; spin_lock_init(&delegation->lock); @@ -508,6 +517,11 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, atomic_long_inc(&nfs_active_delegations); trace_nfs4_set_delegation(inode, type); + + /* If we hold writebacks and have delegated mtime then update */ + if (deleg_type == NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG && + nfs_have_writebacks(inode)) + nfs_update_delegated_mtime(inode); out: spin_unlock(&clp->cl_lock); if (delegation != NULL) diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 257b3d726043..2e9ad83acf2c 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -38,12 +38,17 @@ enum { NFS_DELEGATION_TEST_EXPIRED, NFS_DELEGATION_INODE_FREEING, NFS_DELEGATION_RETURN_DELAYED, + NFS_DELEGATION_DELEGTIME, }; +#define NFS_DELEGATION_FLAG_TIME BIT(1) + int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, - fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); + fmode_t type, const nfs4_stateid *stateid, + unsigned long pagemod_limit, u32 deleg_type); void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, - fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); + fmode_t type, const nfs4_stateid *stateid, + unsigned long pagemod_limit, u32 deleg_type); int nfs4_inode_return_delegation(struct inode *inode); void nfs4_inode_return_delegation_on_close(struct inode *inode); int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); @@ -84,6 +89,10 @@ int nfs4_inode_make_writeable(struct inode *inode); #endif +void nfs_update_delegated_atime(struct inode *inode); +void nfs_update_delegated_mtime(struct inode *inode); +void nfs_update_delegated_mtime_locked(struct inode *inode); + static inline int nfs_have_read_or_write_delegation(struct inode *inode) { return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0); @@ -99,4 +108,16 @@ static inline int nfs_have_delegated_attributes(struct inode *inode) return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, 0); } +static inline int nfs_have_delegated_atime(struct inode *inode) +{ + return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ, + NFS_DELEGATION_FLAG_TIME); +} + +static inline int nfs_have_delegated_mtime(struct inode *inode) +{ + return NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE, + NFS_DELEGATION_FLAG_TIME); +} + #endif diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 89722919b463..91c0aeaf6c1e 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -275,6 +275,8 @@ EXPORT_SYMBOL_GPL(nfs_zap_acl_cache); void nfs_invalidate_atime(struct inode *inode) { + if (nfs_have_delegated_atime(inode)) + return; spin_lock(&inode->i_lock); nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME); spin_unlock(&inode->i_lock); @@ -603,6 +605,33 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) } EXPORT_SYMBOL_GPL(nfs_fhget); +void nfs_update_delegated_atime(struct inode *inode) +{ + spin_lock(&inode->i_lock); + if (nfs_have_delegated_atime(inode)) { + inode_update_timestamps(inode, S_ATIME); + NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ATIME; + } + spin_unlock(&inode->i_lock); +} + +void nfs_update_delegated_mtime_locked(struct inode *inode) +{ + if (nfs_have_delegated_mtime(inode)) { + inode_update_timestamps(inode, S_CTIME | S_MTIME); + NFS_I(inode)->cache_validity &= ~(NFS_INO_INVALID_CTIME | + NFS_INO_INVALID_MTIME); + } +} + +void nfs_update_delegated_mtime(struct inode *inode) +{ + spin_lock(&inode->i_lock); + nfs_update_delegated_mtime_locked(inode); + spin_unlock(&inode->i_lock); +} +EXPORT_SYMBOL_GPL(nfs_update_delegated_mtime); + #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN) int @@ -630,6 +659,17 @@ nfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, attr->ia_valid &= ~ATTR_SIZE; } + if (nfs_have_delegated_mtime(inode)) { + if (attr->ia_valid & ATTR_MTIME) { + nfs_update_delegated_mtime(inode); + attr->ia_valid &= ~ATTR_MTIME; + } + if (attr->ia_valid & ATTR_ATIME) { + nfs_update_delegated_atime(inode); + attr->ia_valid &= ~ATTR_ATIME; + } + } + /* Optimization: if the end result is no change, don't RPC */ if (((attr->ia_valid & NFS_VALID_ATTRS) & ~(ATTR_FILE|ATTR_OPEN)) == 0) return 0; @@ -685,6 +725,7 @@ static int nfs_vmtruncate(struct inode * inode, loff_t offset) spin_unlock(&inode->i_lock); truncate_pagecache(inode, offset); + nfs_update_delegated_mtime_locked(inode); spin_lock(&inode->i_lock); out: return err; @@ -708,8 +749,9 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, spin_lock(&inode->i_lock); NFS_I(inode)->attr_gencount = fattr->gencount; if ((attr->ia_valid & ATTR_SIZE) != 0) { - nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME | - NFS_INO_INVALID_BLOCKS); + if (!nfs_have_delegated_mtime(inode)) + nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME); + nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS); nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); nfs_vmtruncate(inode, attr->ia_size); } @@ -855,8 +897,12 @@ int nfs_getattr(struct mnt_idmap *idmap, const struct path *path, /* Flush out writes to the server in order to update c/mtime/version. */ if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_CHANGE_COOKIE)) && - S_ISREG(inode->i_mode)) - filemap_write_and_wait(inode->i_mapping); + S_ISREG(inode->i_mode)) { + if (nfs_have_delegated_mtime(inode)) + filemap_fdatawrite(inode->i_mapping); + else + filemap_write_and_wait(inode->i_mapping); + } /* * We may force a getattr if the user cares about atime. diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 27fb40653f1d..83edbc7a3bcc 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1245,7 +1245,8 @@ nfs4_update_changeattr_locked(struct inode *inode, struct nfs_inode *nfsi = NFS_I(inode); u64 change_attr = inode_peek_iversion_raw(inode); - cache_validity |= NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME; + if (!nfs_have_delegated_mtime(inode)) + cache_validity |= NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME; if (S_ISDIR(inode->i_mode)) cache_validity |= NFS_INO_INVALID_DATA; @@ -1961,6 +1962,8 @@ nfs4_process_delegation(struct inode *inode, const struct cred *cred, switch (delegation->open_delegation_type) { case NFS4_OPEN_DELEGATE_READ: case NFS4_OPEN_DELEGATE_WRITE: + case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG: + case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG: break; default: return; @@ -1974,16 +1977,16 @@ nfs4_process_delegation(struct inode *inode, const struct cred *cred, NFS_SERVER(inode)->nfs_client->cl_hostname); break; case NFS4_OPEN_CLAIM_PREVIOUS: - nfs_inode_reclaim_delegation(inode, cred, - delegation->type, - &delegation->stateid, - delegation->pagemod_limit); + nfs_inode_reclaim_delegation(inode, cred, delegation->type, + &delegation->stateid, + delegation->pagemod_limit, + delegation->open_delegation_type); break; default: - nfs_inode_set_delegation(inode, cred, - delegation->type, - &delegation->stateid, - delegation->pagemod_limit); + nfs_inode_set_delegation(inode, cred, delegation->type, + &delegation->stateid, + delegation->pagemod_limit, + delegation->open_delegation_type); } if (delegation->do_recall) nfs_async_inode_return_delegation(inode, &delegation->stateid); diff --git a/fs/nfs/read.c b/fs/nfs/read.c index a142287d86f6..1b0e06c11983 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -28,6 +28,7 @@ #include "fscache.h" #include "pnfs.h" #include "nfstrace.h" +#include "delegation.h" #define NFSDBG_FACILITY NFSDBG_PAGECACHE @@ -372,6 +373,7 @@ int nfs_read_folio(struct file *file, struct folio *folio) goto out_put; nfs_pageio_complete_read(&pgio); + nfs_update_delegated_atime(inode); ret = pgio.pg_error < 0 ? pgio.pg_error : 0; if (!ret) { ret = folio_wait_locked_killable(folio); @@ -428,6 +430,7 @@ void nfs_readahead(struct readahead_control *ractl) } nfs_pageio_complete_read(&pgio); + nfs_update_delegated_atime(inode); put_nfs_open_context(ctx); out: diff --git a/fs/nfs/write.c b/fs/nfs/write.c index a9186b113fe7..c0cd644b97ff 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -289,6 +289,8 @@ static void nfs_grow_file(struct folio *folio, unsigned int offset, NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_SIZE; nfs_inc_stats(inode, NFSIOS_EXTENDWRITE); out: + /* Atomically update timestamps if they are delegated to us. */ + nfs_update_delegated_mtime_locked(inode); spin_unlock(&inode->i_lock); nfs_fscache_invalidate(inode, 0); } @@ -1514,6 +1516,13 @@ void nfs_writeback_update_inode(struct nfs_pgio_header *hdr) struct nfs_fattr *fattr = &hdr->fattr; struct inode *inode = hdr->inode; + if (nfs_have_delegated_mtime(inode)) { + spin_lock(&inode->i_lock); + nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS); + spin_unlock(&inode->i_lock); + return; + } + spin_lock(&inode->i_lock); nfs_writeback_check_extend(hdr, fattr); nfs_post_op_update_inode_force_wcc_locked(inode, fattr); From patchwork Thu Jun 13 04:11:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696094 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 60A19133402 for ; Thu, 13 Jun 2024 04:17:47 +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=1718252269; cv=none; b=FEL1ZakKN8GAIDPXCqwJw/mJi9hmBBX+IEEcx5lYK2MbdkZor91OwWb6jb+Wyol0fsnbHaQctQBP+si4EH1C31l0gHjmta4plTqjuKZC/mlz/mt+YeOmC0u1cUFs/3QXRteNJZR9aMINcwTxfT7694cX9PYTqzspiJSD/8re7hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252269; c=relaxed/simple; bh=TAEL7q4hgZcv5YVterdQ6T2z8L4rY3I2ZOHBx4kSLdc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DW8ytP9zo7B0jCHZLJWg5kwSNIE0tZoBL4JpECpmiyzjOIL43REpfHGpUyUvO/h9g45lWBMlNeoOlJhN/tMZhwFm+BX57QTOUPJcT//GGBfeIjH0bFw3gRjClRBSjRxL+L5EpvsdaNVZL+bRhbbyz8ceBnAT9ljx5tfYmXk4soc= 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=M++5t6h/; 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="M++5t6h/" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6b06b78e716so3560156d6.3 for ; Wed, 12 Jun 2024 21:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252266; x=1718857066; 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=XL/7LACE4TIP97s7YbulyVv9AoIs+282TFrueNiZnug=; b=M++5t6h/r0ZzYxt9Jq0lTfvJVCoo7dgqijTfR56NSswERtZ9Qrtw2CiLD//F2bq9q7 v6xO9GB8T/6t3iXzAdGi1OfwpCXYKvIzlqxKDd3dVHmID+axHTJrTaoisXQFhUeAMNbV uB4fkG0DEaYSpC63KKjNAUOGuvjMPFK8/dMo+SvgnsCKt+i1Q9Jy2Ra+mIUX3fQ1YzNt pYoyj3AGmzWdb9exsrh/GUNhvUK55Xv3WB7HdvzfZrHbsIDqk1XN8phHhkFGSs90HC+e b63v9p9y/Iy4Cp2txNm46mxwKGKb4DPCW1JxpDtUS9TYj09m1dxzNz72Cd5b+leRZMeW V0Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252266; x=1718857066; 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=XL/7LACE4TIP97s7YbulyVv9AoIs+282TFrueNiZnug=; b=YiKU/7N+0uHfTXo+sROS9qTrjHzwOFlscnCcwlajag8RP5Sg5zQUjJoRpQIJj6B4rx dAt6kb1e43kssyBjwV8jHXVMNfRN0tcPGEZHfy6newgu1XQfFELJC1HX33DKPmKLF7d0 ezSUIOHmbDG1pTubw0Z5LkN+be49aJnbEK7xcaUPlc4fmJ5kt6LczIplBUJjnpOhXwT1 thV/DqW4tURRIYBG95zbx8EMDtd/KwJ4sS5f7eTHnja1W9C1Jus0Q6HIJWk34I+OLnHM CgCI4YA+boOaOheyt/NN6L2d4KxsrqPWeZ/0ge2nEDa+h1QCKMoW971J1GxMBuK5OUDc t77g== X-Gm-Message-State: AOJu0YzXPOty1Z+LDmcuqQ6AoRV2TE4LVJn8MKMXR0P9IjIZf+p7ZP4P fmOi87zXSMmV/VMeyfrnuMJ/g6pIdRYSPDRwi7O/LUmTLwP1ZhApnNVj X-Google-Smtp-Source: AGHT+IHcv3j2mIJcEQqyiMrdL+xlRtZ/A3nlDDiVPeTpX6AHPmxmjyoJ+Y0Ow5kPaVvuN4lifzxSlQ== X-Received: by 2002:a05:6214:524a:b0:6b0:6619:20b7 with SMTP id 6a1803df08f44-6b1920287ccmr42843216d6.17.1718252265921; Wed, 12 Jun 2024 21:17:45 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:45 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 08/19] NFSv4: Add recovery of attribute delegations Date: Thu, 13 Jun 2024 00:11:25 -0400 Message-ID: <20240613041136.506908-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-8-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 18 +++++++++++++++--- fs/nfs/nfs4xdr.c | 18 ++++++++---------- include/linux/nfs_xdr.h | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 83edbc7a3bcc..b613c11fac09 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2225,7 +2225,7 @@ static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state { struct nfs_delegation *delegation; struct nfs4_opendata *opendata; - fmode_t delegation_type = 0; + u32 delegation_type = NFS4_OPEN_DELEGATE_NONE; int status; opendata = nfs4_open_recoverdata_alloc(ctx, state, @@ -2234,8 +2234,20 @@ static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state return PTR_ERR(opendata); rcu_read_lock(); delegation = rcu_dereference(NFS_I(state->inode)->delegation); - if (delegation != NULL && test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) != 0) - delegation_type = delegation->type; + if (delegation != NULL && test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) != 0) { + switch(delegation->type) { + case FMODE_READ: + delegation_type = NFS4_OPEN_DELEGATE_READ; + if (test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) + delegation_type = NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG; + break; + case FMODE_WRITE: + case FMODE_READ|FMODE_WRITE: + delegation_type = NFS4_OPEN_DELEGATE_WRITE; + if (test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) + delegation_type = NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG; + } + } rcu_read_unlock(); opendata->o_arg.u.delegation_type = delegation_type; status = nfs4_open_recover(opendata, state); diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 4c22b865b9c9..e160a275ad4a 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1475,20 +1475,18 @@ static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *a } } -static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type) +static inline void encode_delegation_type(struct xdr_stream *xdr, u32 delegation_type) { __be32 *p; p = reserve_space(xdr, 4); switch (delegation_type) { - case 0: - *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); - break; - case FMODE_READ: - *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); - break; - case FMODE_WRITE|FMODE_READ: - *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); + case NFS4_OPEN_DELEGATE_NONE: + case NFS4_OPEN_DELEGATE_READ: + case NFS4_OPEN_DELEGATE_WRITE: + case NFS4_OPEN_DELEGATE_READ_ATTRS_DELEG: + case NFS4_OPEN_DELEGATE_WRITE_ATTRS_DELEG: + *p = cpu_to_be32(delegation_type); break; default: BUG(); @@ -1504,7 +1502,7 @@ static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr * encode_string(xdr, name->len, name->name); } -static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type) +static inline void encode_claim_previous(struct xdr_stream *xdr, u32 type) { __be32 *p; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 51611583af51..d8cfa956d24c 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -484,7 +484,7 @@ struct nfs_openargs { nfs4_verifier verifier; /* EXCLUSIVE */ }; nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */ - fmode_t delegation_type; /* CLAIM_PREVIOUS */ + __u32 delegation_type; /* CLAIM_PREVIOUS */ } u; const struct qstr * name; const struct nfs_server *server; /* Needed for ID mapping */ From patchwork Thu Jun 13 04:11:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696095 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (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 4E2EC1339A4 for ; Thu, 13 Jun 2024 04:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252269; cv=none; b=bGcFk07yWn4yCu2pGP8U75FaQI6w5GDaaMFxB04QMP/5py0kPsNAhMlsYA8bhTQWqRf6WLirMQe8zaPKr4J1BNK3IduKNU0hXDkp1w/KPQbe5uguySoDzxp63Z5GX4jDWgkiGW1459bgWHWnFNzeFSLMRZbxdy+N+owY5OPHbhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252269; c=relaxed/simple; bh=uchDaSxoiBihPJaVbfjdkv8zT6brkwCTp93vdpr5PdM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F2AQQIz0YGCq7bFPNLCtkXgEbynLV4SsrJT4THu8j2TrnMjl0gNV/E6Y5a+uo4QdgLggdd7yHKRFhMxHB9KEqXTPdZTOOcEJo6gbupriyqZKZyR8ZNjWTMpngKinuOQB1Wkol9WXIBLFN0Kxmgs2kzRpzN7Zqn3wZb/gHSsgbmI= 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=BFbbGCi1; arc=none smtp.client-ip=209.85.219.182 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="BFbbGCi1" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-dff0712ede2so168587276.2 for ; Wed, 12 Jun 2024 21:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252267; x=1718857067; 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=tcbhNeh3lEUhaC4Ltb//45PFvbWHeFYX1K9+ueo6Pk0=; b=BFbbGCi1Xj1n99pzcDiPdMhDX46NoRZBuFEQ9sCi84NsCquvWWH380oHc/k0t6HfXR LVDpJSRctAOR4ImbSlclBe0izQm1OVALap98Q0BSnDlOi5pzOfyAdJWyoUlXJNmO0ciZ anLOhiEp1S7rSPGBLeNWGdRvKih3gQ98Q8bvlfy0P3Ze7WwFT92UhBgNOob4L6r+LFq5 xYbMuobiw33WiQJdVEDnGsYPJNNZQrHAbFHB2qcmnJPWnwFxiYj7AZFV//GhX031SJfR iQvoi/PmbiSEZRBbCbhPYvwwejUlEOwdPlPmcwSqYUTXDGLVzHq/GfwpFqVCD1NShA4b iyWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252267; x=1718857067; 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=tcbhNeh3lEUhaC4Ltb//45PFvbWHeFYX1K9+ueo6Pk0=; b=t2Q5P/yak3zfdEwK5ZwyNtd+Rf+pWxosjJkdAGf3dHuYjYj42D7TaMI8HiKfRNxiVy Vryf+daOkdoLcSxgrLmtqbVjoEii2CwDGex9MIRqscjRPB+WIojADVY7ZItCjLQMdgsU 8pEX8AevqX6OXMeDP3eRbdJmIXPK0l/bx+wq+N9I8q6Mk+iG0RLsHH51hdaTft4gRuGr D4Cu7s1kdGkm6NKGjyBEjFUOl4a+PPFUnZ0A/GqAOsBDKJyCmyeBo93HAtWZOrhzFFQz 2P58hqfDUAP76HskxLupByleL07iQViNaieXCRJEeI2G4MoHnpdd0xAeWc+8X7i0fkx7 go+Q== X-Gm-Message-State: AOJu0Yw9DSvIV34YN/x40Dg7VwbhyKW2l6jCp7wBAre4C2v83fTFcZQu 91So5vwiBhQm0Q8cmZPEZBcARExpRCFMKKmUC6Qc6RTXsYGM2kLdUD0v X-Google-Smtp-Source: AGHT+IH6emcnwzWePUlqlEgSp052ZyWR9rtfYkC/YmxUb5UU/7wcEuziR5Fusklu9VXqTZoDwn5/FA== X-Received: by 2002:a25:aac5:0:b0:df4:dfee:3572 with SMTP id 3f1490d57ef6-dfe675566e6mr3833934276.38.1718252266999; Wed, 12 Jun 2024 21:17:46 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:46 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 09/19] NFSv4: Add a capability for delegated attributes Date: Thu, 13 Jun 2024 00:11:26 -0400 Message-ID: <20240613041136.506908-10-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-9-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 2 ++ include/linux/nfs_fs_sb.h | 1 + 2 files changed, 3 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index b613c11fac09..efa07c275338 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3930,6 +3930,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f #endif if (res.attr_bitmask[0] & FATTR4_WORD0_FS_LOCATIONS) server->caps |= NFS_CAP_FS_LOCATIONS; + if (res.attr_bitmask[2] & FATTR4_WORD2_TIME_DELEG_MODIFY) + server->caps |= NFS_CAP_DELEGTIME; if (!(res.attr_bitmask[0] & FATTR4_WORD0_FILEID)) server->fattr_valid &= ~NFS_ATTR_FATTR_FILEID; if (!(res.attr_bitmask[1] & FATTR4_WORD1_MODE)) diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 92de074e63b9..5a76a87cd924 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_DELEGTIME (1U << 13) #define NFS_CAP_POSIX_LOCK (1U << 14) #define NFS_CAP_UIDGID_NOMAP (1U << 15) #define NFS_CAP_STATEID_NFSV41 (1U << 16) From patchwork Thu Jun 13 04:11:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696096 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 68DC8134414 for ; Thu, 13 Jun 2024 04:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252270; cv=none; b=fmnKjP15U4xiXHQI8PsUhGWEQQAGJNT9KK09OCyonFtHP4qd4XIiy1R72RZMSFw1co9rurRStAOMH/VGw0Vow+k8VEEt9OxKc437vILr/SqZOZJgLUwpQp40W5NZAcewIe6qR/8IXBVen2digHtebiN/onpRM4ztBo83cmNrPbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252270; c=relaxed/simple; bh=aoL/lDctGiS3XXACQ5vdk0QGeF6ZqSQouBkuNBuAjLI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H8iN0dV77/KwI8Q9d1x7lHDImLxEih/VtFbCVzl0ZrSDZoK6px6SRHX0G4LGozp7ImMcQXp9ZHjskZndBreb9W8BEkhIg6TjDxIP7eXFpH8+scjfRIwoqFAIRsZ6P1Rb3M2ZJa2uMTaGIC/mQ4y9zerc6LBvxPSkOHSXperwtnk= 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=Y0MNEvVH; arc=none smtp.client-ip=209.85.219.47 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="Y0MNEvVH" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6b0825b8421so3608986d6.1 for ; Wed, 12 Jun 2024 21:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252268; x=1718857068; 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=/QtVwbega8NvnHdt/uKvwDjYc1+36fjrMQHuiAk477o=; b=Y0MNEvVHPgl9DCN5h9lLkV0CRDp2or/P/MB7KSqoieg7rk/dfm75IkMSGuvrcEpOxi 2tEnQa7HJnYHb+w+TcQ/eQh5fEqYsyQJs824jWqgUIZHg9RXAdO8t9t+mLxYptC6mDVU X311D4G8fo89uSYNyIj4p3hsCgZD7ugtQ2jDIvFFwVg4KBW/H+6QBWbqg27ArQ824Aq8 Ls3RM3mhia+SBcPm48vhcZuNVtbrNp/JBTQFE8VuRPqkk4XGdFyhdL+uHGPZOCtYbz5c w9fREzEpf+uRpB04l6fPLzDXq2V1OxDnBlaLE6QsxgWsU0HJzj9dChwxy8MQE0R7v/lw 0ccQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252268; x=1718857068; 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=/QtVwbega8NvnHdt/uKvwDjYc1+36fjrMQHuiAk477o=; b=ZoqbAT9k1fQNHIBFJFb3jsLnDT7UjwB+UeiQCXNIxbs2GebCMnMU7BjDWIcp43hSIa R2+kWSt8IE6ACN4T7mGGuvZ4TffCvMlzqSoM26nS6N2EuhCSQ1iaENSW7rH4xVkjiY6c yPd1f9GUeZAkATsIPxM9E8JjTF4STQcmlkbdUH5sLqpLa1lmqALcznnlruyA8//ueS44 8deMPavfEuvL6bgqojphO8PBmol3X6++LONjZ0/luQbPuKKy0jABLIBC7zJgdfQD+hY5 /dHVuNRm336GUpDQPP3cT8ouB1Tbn8lFtupqXvqxW5Ya3fzB+9apuB9HBWOdy3UUVnf9 s1Mw== X-Gm-Message-State: AOJu0Ywy2zA5WnaXC32QgdImttAMR+jb+TU7Lm8ITOsBrzcKhcdlFwyw zBp8mjxu0zsbSIYq7sZtsvpwBODgFcl9f3CVqwCtVBIbcP6UCCvrN4Fb X-Google-Smtp-Source: AGHT+IEmVS6P96QdC/hvKbRbfDXHnSR/S3HcoBSuJEfiCwRL8PrAVvhCG+B8a+P2lJQ7oeZyRu5d8w== X-Received: by 2002:a05:6214:5248:b0:6b0:7caa:457c with SMTP id 6a1803df08f44-6b192028a7bmr37890306d6.24.1718252267908; Wed, 12 Jun 2024 21:17:47 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:47 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 10/19] NFSv4: Enable attribute delegations Date: Thu, 13 Jun 2024 00:11:27 -0400 Message-ID: <20240613041136.506908-11-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-10-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index efa07c275338..140ff1d75320 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1339,8 +1339,13 @@ nfs4_map_atomic_open_share(struct nfs_server *server, if (!(server->caps & NFS_CAP_ATOMIC_OPEN_V1)) goto out; /* Want no delegation if we're using O_DIRECT */ - if (openflags & O_DIRECT) + if (openflags & O_DIRECT) { res |= NFS4_SHARE_WANT_NO_DELEG; + goto out; + } + /* res |= NFS4_SHARE_WANT_NO_PREFERENCE; */ + if (server->caps & NFS_CAP_DELEGTIME) + res |= NFS4_SHARE_WANT_DELEG_TIMESTAMPS; out: return res; } From patchwork Thu Jun 13 04:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696097 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 4A35E1339A4 for ; Thu, 13 Jun 2024 04:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252271; cv=none; b=cpK41/vB49R1a9UBrqrC18a82p+qoAuGyGSK0YnGJsJXZ8eWfdyoNelnEgP8o5Bvv7yzZUfos6O0XZ+eFeQhsZwPT2J0ch71BCPEXumN8qXiCVqISS+lrJIeBCuwwNDbjG05b37ZJnLx0u1YB5c7ymHsnEMI4ip6OJIap+Xt3yg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252271; c=relaxed/simple; bh=xX1I07808zeQLJDKalOIwpnPcqOJ7GBLddGiJO+Bhp4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e3zMufONTUEaTv/vHZ+sLaRYsvEGvlhfnL7BiZ7XuAgkddrCKvbOEAdGYR8FFI8q4wcEQsH+HidpMzXrbTbarucw1IcZ5+7Slx6smH4mOUU5S0rjvSaGlhAdQmFm7WNCtHPoTGeqdqsaLkOQlnKBfnQmVhkFlVM0KKpEzTRhN7c= 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=XHOncNjS; arc=none smtp.client-ip=209.85.219.49 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="XHOncNjS" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6b065d12e81so3150506d6.0 for ; Wed, 12 Jun 2024 21:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252269; x=1718857069; 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=0XiA5qEzlqnxVRasj1LKRioRSNf661cBYZKDDv6Cs9o=; b=XHOncNjSbVTunyHAHlyaTqJOFcnKD3R4Ffj5zgt0yn/Gl58fITTC5phzDNYGhpur8F 2vtjYMzLk5R3o5xzbjijh3Dx3Q3i93Qbl4fDwS4hXXed6Xg4MXkFS62qHimP2pXwazVx uDztXqtIMMm8E6KdGsTVpZmK61dIo3nuD55uCuotN2trFlx0bMWsAJP4wr+jCa6D0+Ep 6US9rjEjTrKwFpeA9WNVO0+zuEqZR2HiUOROmuZoJppYFowChWlbDkfMF4ZwIAmNht2A sr795/HYXBWaDqJp1T3T/dk7YYoR/tPZCaCakGNU7eEWLHwdnWZKpkVnlaLpzbhnJbvw VuNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252269; x=1718857069; 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=0XiA5qEzlqnxVRasj1LKRioRSNf661cBYZKDDv6Cs9o=; b=Q6OPq68Vdv0lO5fo7oCIbJWlUlWFZVqYObjoTPr/VnkM3KhZQwl3EX4wp/a/wROINP gahYeK3qmb/YaMzlTIL0WgVP//UfxOfSya8WzLqIeAJYDY6spHylrYC1aB+HYfR8L53p YHuBymIuZXIjYD9C8S7HQIO1UmnPleWMw6TDjHXf4fL9PcqQpUEOsZJgC6Nm/svD5mQS 6uzg2Nn1qiA2qA9FfCR9JUY67p5MBEhgwZr/hXKncLRIXqTBfr4Ns2/Ku+TfaZuoklQy sO++dMnIweWKe0ZaQ83dxo2+w9gStvksoi5ScZl1vJVpAqgFEyUb7qAUwgyiPkRrH8+8 ihfA== X-Gm-Message-State: AOJu0YzeG7LlFs5dKQEh5+SNbQhXTww31KhtN88Ng9TF95L08ylSbDn7 Lh0jK9vgiMtOQ9c/30C++fM2Auo75uHBAH9oci1KYH7Izz53MaXV6AYE X-Google-Smtp-Source: AGHT+IGvt5Fv/+p32/j8GfB6rbUmAUGksJVcvLQU2zLGpjYVEBxGHI/dJT5dJzrxUpxI8ZrOLXmUwA== X-Received: by 2002:a05:6214:419d:b0:6b0:6f20:fed5 with SMTP id 6a1803df08f44-6b1a79dc1a7mr39812106d6.49.1718252268520; Wed, 12 Jun 2024 21:17:48 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:48 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 11/19] NFSv4: Delegreturn must set m/atime when they are delegated Date: Thu, 13 Jun 2024 00:11:28 -0400 Message-ID: <20240613041136.506908-12-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-11-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-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 Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton --- fs/nfs/delegation.c | 9 +++++---- fs/nfs/delegation.h | 4 +++- fs/nfs/nfs4proc.c | 27 ++++++++++++++++++++++++--- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index e72eead06c08..d8f4a1cdbc8e 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -258,7 +258,9 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, } } -static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) +static int nfs_do_return_delegation(struct inode *inode, + struct nfs_delegation *delegation, + int issync) { const struct cred *cred; int res = 0; @@ -267,9 +269,8 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation * spin_lock(&delegation->lock); cred = get_cred(delegation->cred); spin_unlock(&delegation->lock); - res = nfs4_proc_delegreturn(inode, cred, - &delegation->stateid, - issync); + res = nfs4_proc_delegreturn(inode, cred, &delegation->stateid, + delegation, issync); put_cred(cred); } return res; diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 2e9ad83acf2c..da910e2e98a4 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -72,7 +72,9 @@ void nfs_test_expired_all_delegations(struct nfs_client *clp); void nfs_reap_expired_delegations(struct nfs_client *clp); /* NFSv4 delegation-related procedures */ -int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync); +int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, + const nfs4_stateid *stateid, + struct nfs_delegation *delegation, int issync); int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid); int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, const nfs4_stateid *stateid); bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags, nfs4_stateid *dst, const struct cred **cred); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 140ff1d75320..b0c1564a7bc7 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6718,7 +6718,10 @@ static const struct rpc_call_ops nfs4_delegreturn_ops = { .rpc_release = nfs4_delegreturn_release, }; -static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync) +static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, + const nfs4_stateid *stateid, + struct nfs_delegation *delegation, + int issync) { struct nfs4_delegreturndata *data; struct nfs_server *server = NFS_SERVER(inode); @@ -6770,12 +6773,27 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, } } + if (delegation && + test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) { + if (delegation->type & FMODE_READ) { + data->sattr.atime = inode_get_atime(inode); + data->sattr.atime_set = true; + } + if (delegation->type & FMODE_WRITE) { + data->sattr.mtime = inode_get_mtime(inode); + data->sattr.mtime_set = true; + } + data->args.sattr_args = &data->sattr; + data->res.sattr_res = true; + } + if (!data->inode) nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 1); else nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0); + task_setup_data.callback_data = data; msg.rpc_argp = &data->args; msg.rpc_resp = &data->res; @@ -6793,13 +6811,16 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, return status; } -int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, const nfs4_stateid *stateid, int issync) +int nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, + const nfs4_stateid *stateid, + struct nfs_delegation *delegation, int issync) { struct nfs_server *server = NFS_SERVER(inode); struct nfs4_exception exception = { }; int err; do { - err = _nfs4_proc_delegreturn(inode, cred, stateid, issync); + err = _nfs4_proc_delegreturn(inode, cred, stateid, + delegation, issync); trace_nfs4_delegreturn(inode, stateid, err); switch (err) { case -NFS4ERR_STALE_STATEID: From patchwork Thu Jun 13 04:11:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696098 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.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 99CD813211A for ; Thu, 13 Jun 2024 04:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252272; cv=none; b=VF4oDcz8nLzTf5d5bnmz58AWI/UEIXs/39yg/wedfBeWPBnJxPPErtB0Sxs6kGbhlKYK8fI0M67GC9BgNwL3b98aPIMGDbbTevzeA9ABDPQv9mbIUJuMPe4HFiMp4NtnxVJYCkz3PqdITpFhXeUsTb4inETwXsHRLLvebcrCwCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252272; c=relaxed/simple; bh=JUa26y4trDMjXv8kJNspKCpm0ZB2QdGxG8Rie3Z4Jus=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aiE29rnduJHqKxeQcqd/zE9h51/ats3Dqm4Va5ISpFTg1hB4Hk6vN06WbOXqyM9RhtV4k0Fj9gVfVMClBnf9bmRPawn21ZIK+GENA54iDlWayT/O9DJ49oSgjMUYfG5lFPB07uHNI+JQOJg+g9y6PnqYzEGAg7B/CruszpJYGCY= 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=daVm3DJ0; arc=none smtp.client-ip=209.85.219.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="daVm3DJ0" Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-dfef552d425so747781276.0 for ; Wed, 12 Jun 2024 21:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252269; x=1718857069; 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=aXhoor7Xv4QJH68bc35T5Xdx6w4YGZDyOa4YHXPzbbg=; b=daVm3DJ0qSa6dCu1W+YY8phtWl2w6ROQzkw77JTRTZfXewv3GOlJYWIugoqOc8fBIQ dJd+VfpEvrOJZGTe7knWrRNuiXI8qkWKf2OvCTDEMmmw6dDiMHktoAoVMFS7PbGKRxn6 lLq5G/Njlj6zHL1rgMH8uqNOtB1WeYCujuw7ELM1W1hF9G3b2eO+fjjeBWAU2xBsA9Vg GWurgTW0m7ByYED03C4OSOFyX3MtaH6JNA2JX2spYEfdPqS2ZH4cqHd3WAQ2jLF804K7 xCW/3RQYh6QpEIK58m9H4P81cXmUKzjf0eW/V9fYeG0ORxp++P7FgtBMjvtDXsGwJKIV jBNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252269; x=1718857069; 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=aXhoor7Xv4QJH68bc35T5Xdx6w4YGZDyOa4YHXPzbbg=; b=rB/9aEDQQ78l7vqnzmejPU43wk303igk54cJl4cMIYBTL/TJJEcKgYyCpAGY1zhJZ/ X7UxVj18exOrQzdk03tcfCJ6JOABTQGTYh/U0if23AEH5N9kPf4kAcq/LlZ5XKNvlMi0 SW/LtzvaHWzhlwSvh5VpLXkdhQFPYOmz1dZIHVUg2GkG40qVYk6P8izm47KpA0j1iKHf PZwvoSRM76UW2jKlcQoa9Eu+7Qq3w1FNZyAhSjaNUHnL331qiYyMoEyo4q9AyBbh4i8K Y+y2gLM9KDSDBZqPjT+Gg/GIiaiHVT9X/kZjt8cvKsU9genwFGVUOS3r6+xvsFy/94op Z3Cw== X-Gm-Message-State: AOJu0YywhqB9l6AaaMleltKAss3dsuGmtaHD2/nRZmNxEyZg3tH0i1GL YX4wl9J8Ko9I6sYVHHgDUf3Y4cfNFGsUoNjSPvS1u4W8f//CQHAEA10W X-Google-Smtp-Source: AGHT+IFm0+bize7ayOACXX7yFKnmB3UcIFwBQ51TuEaD+9ahe103xHEjZIiu35kYy1UIF6OWo5Mlzg== X-Received: by 2002:a25:26cd:0:b0:dff:1a2:a408 with SMTP id 3f1490d57ef6-dff01a2a6b8mr972119276.35.1718252269323; Wed, 12 Jun 2024 21:17:49 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:49 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 12/19] NFSv4: Fix up delegated attributes in nfs_setattr Date: Thu, 13 Jun 2024 00:11:29 -0400 Message-ID: <20240613041136.506908-13-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-12-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-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 nfs_setattr calls nfs_update_inode() directly, so we have to reset the m/ctime there. Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 91c0aeaf6c1e..e03c512c8535 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -605,6 +605,46 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) } EXPORT_SYMBOL_GPL(nfs_fhget); +static void +nfs_fattr_fixup_delegated(struct inode *inode, struct nfs_fattr *fattr) +{ + unsigned long cache_validity = NFS_I(inode)->cache_validity; + + if (!nfs_have_read_or_write_delegation(inode)) + return; + + if (!(cache_validity & NFS_INO_REVAL_FORCED)) + cache_validity &= ~(NFS_INO_INVALID_ATIME + | NFS_INO_INVALID_CHANGE + | NFS_INO_INVALID_CTIME + | NFS_INO_INVALID_MTIME + | NFS_INO_INVALID_SIZE); + + if (!(cache_validity & NFS_INO_INVALID_SIZE)) + fattr->valid &= ~(NFS_ATTR_FATTR_PRESIZE + | NFS_ATTR_FATTR_SIZE); + + if (!(cache_validity & NFS_INO_INVALID_CHANGE)) + fattr->valid &= ~(NFS_ATTR_FATTR_PRECHANGE + | NFS_ATTR_FATTR_CHANGE); + + if (nfs_have_delegated_mtime(inode)) { + if (!(cache_validity & NFS_INO_INVALID_CTIME)) + fattr->valid &= ~(NFS_ATTR_FATTR_PRECTIME + | NFS_ATTR_FATTR_CTIME); + + if (!(cache_validity & NFS_INO_INVALID_MTIME)) + fattr->valid &= ~(NFS_ATTR_FATTR_PREMTIME + | NFS_ATTR_FATTR_MTIME); + + if (!(cache_validity & NFS_INO_INVALID_ATIME)) + fattr->valid &= ~NFS_ATTR_FATTR_ATIME; + } else if (nfs_have_delegated_atime(inode)) { + if (!(cache_validity & NFS_INO_INVALID_ATIME)) + fattr->valid &= ~NFS_ATTR_FATTR_ATIME; + } +} + void nfs_update_delegated_atime(struct inode *inode) { spin_lock(&inode->i_lock); @@ -2163,6 +2203,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) */ nfsi->read_cache_jiffies = fattr->time_start; + /* Fix up any delegated attributes in the struct nfs_fattr */ + nfs_fattr_fixup_delegated(inode, fattr); + save_cache_validity = nfsi->cache_validity; nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ATIME From patchwork Thu Jun 13 04:11:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696099 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (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 9B9BD132126 for ; Thu, 13 Jun 2024 04:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252273; cv=none; b=LNoPOhYfvNbM0SjyeV1koR4LSdA0pKaYr5lXd8fZyjkn7OhMPWpTxlo6NoRKeGQ686PmaR7UnOgZvq6ojOX7KyIZYrqIp4xPJZj1W1Pe/md5yFQMIGlEAdCTvPItHu0EmNmjL6p4L0QuXDxRji1+G2o5c5XMVy+NpQvCsA8Njvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252273; c=relaxed/simple; bh=G27ACknVe5YVvRgo+hV5Oonf899wVt4uaegDn9bmehI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WX7oTUnULOpTBzf2Ic3G2ZMgmNCUqUAZ7aGdARJM3lgSx0h/6QMGRd698FiIUFEJ2BDxo4i9n6b87XzI/zxJhNsD7rc/yP+/FPoWZwO5b/1u2VFdziAOWQneNoWJwjfXy3UB4szWnUkmJUPimRCJbyCYeV55Ipo1a0dy/yRomEk= 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=khUykbhp; arc=none smtp.client-ip=209.85.219.181 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="khUykbhp" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-dfab4779d95so623125276.0 for ; Wed, 12 Jun 2024 21:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252270; x=1718857070; 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=1DBuH0RuQOohPHmiRiU+vGGomKOGtGnHlYyjvtJmgSA=; b=khUykbhpYEGkKk5yTHNP0zlS90SyHitlXzNBP4wIvTqlMyJxfZmJBMmks/4xtxCPEG NJdRqw4AjnJwJ1/9z8XgANj2181Z+LeSegDtBrPJiJomixSVJkgwqzj811jcfkTgcQnA QjS+KJl3EuNbjiKUjXX2f+hZgDr9gZfw+snjWzZ86fERCwoOscFkdEGrt0DawTGPR+SA A6AO0tlb4tmfQTAcMz5RdPGVCKbzjPJ/jxZnWBIwT89MW7HooGb67bV6R01lqUjGabPh l1X1HgGR7bhObelvM5lYeTpXIIYa9g+tezloVsN2qrU8YxuJlPrqjWQUlnn96itLQkBt czUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252270; x=1718857070; 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=1DBuH0RuQOohPHmiRiU+vGGomKOGtGnHlYyjvtJmgSA=; b=LTC5OoynCSCWMzxN1PWbyeqqPxZCUTyTtnGJHJopfAcR5mi3DOKQ07LGzAdlRUuXQB +N23hniPX8eJRg1HFJM+gLTX1/l6XsHzoCsGVJ1oBT+MXhkjJAZMUK8Tv8yIi7PRGkho XLC9est7yxmlixQcFsdCS/1QN4Ywe4SQhX9EZb7EuJxUpXg8M6oU/wqW4tAyqt22lI2P dbUeLm/IRSHaCzn9g4Jv0aLNrnEeqOzdMmBgY6tj/rIX8MvdybaH5cZ6win7K71txzda XgUoGL13NH2CDKZmYOylhPXMvN2YoCx2WPT24PkU/AgNGA+H80c0zehagIh7sr73KQvg eEVA== X-Gm-Message-State: AOJu0YzJ+baDKZ8gfDWbZJMqbledbUCx7Kmt6KwwC8EVJ6WB0JTg2X4M Fo0Xxhousq5eqxrb3X9c6XxdezrREfw9wIZm/9IuauwZBQZZ1zAIIuv8 X-Google-Smtp-Source: AGHT+IGcOTyWteDQNy+wdRQkSm8RnHpkTKhC6iuV1shuWif9Gi4bu4Rg8JLYXFU34PEWQO7phvCd+A== X-Received: by 2002:a25:aa43:0:b0:dff:237:4cca with SMTP id 3f1490d57ef6-dff02374dd8mr1160906276.7.1718252270345; Wed, 12 Jun 2024 21:17:50 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:49 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 13/19] NFSv4: Don't request atime/mtime/size if they are delegated to us Date: Thu, 13 Jun 2024 00:11:30 -0400 Message-ID: <20240613041136.506908-14-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-13-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-trond.myklebust@hammerspace.com> <20240613041136.506908-13-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 Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index b0c1564a7bc7..512268c732a1 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -310,6 +310,18 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src, dst[1] &= ~FATTR4_WORD1_MODE; if (!(cache_validity & NFS_INO_INVALID_OTHER)) dst[1] &= ~(FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP); + + if (nfs_have_delegated_mtime(inode)) { + if (!(cache_validity & NFS_INO_INVALID_ATIME)) + dst[1] &= ~FATTR4_WORD1_TIME_ACCESS; + if (!(cache_validity & NFS_INO_INVALID_MTIME)) + dst[1] &= ~FATTR4_WORD1_TIME_MODIFY; + if (!(cache_validity & NFS_INO_INVALID_CTIME)) + dst[1] &= ~FATTR4_WORD1_TIME_METADATA; + } else if (nfs_have_delegated_atime(inode)) { + if (!(cache_validity & NFS_INO_INVALID_ATIME)) + dst[1] &= ~FATTR4_WORD1_TIME_ACCESS; + } } static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry, @@ -3414,7 +3426,8 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, .inode = inode, .stateid = &arg.stateid, }; - unsigned long adjust_flags = NFS_INO_INVALID_CHANGE; + unsigned long adjust_flags = NFS_INO_INVALID_CHANGE | + NFS_INO_INVALID_CTIME; int err; if (sattr->ia_valid & (ATTR_MODE | ATTR_KILL_SUID | ATTR_KILL_SGID)) @@ -4958,7 +4971,7 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct nfs4_inode_make_writeable(inode); nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, res.fattr->label), inode, - NFS_INO_INVALID_CHANGE); + NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME); status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); if (!status) { nfs4_update_changeattr(dir, &res.cinfo, res.fattr->time_start, From patchwork Thu Jun 13 04:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696100 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.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 C089E13211A for ; Thu, 13 Jun 2024 04:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252274; cv=none; b=TL8qPkl2BxCJMRu400IopxniEVToplBn/bFTfDrjQ6jrDWlPh7XQf/HVxZ473eY2Ufsx3zTB5hhmtZntMxuaXlr9aBJI+Tzq0nedZZqbEUlw4Ns9NU0UoQkquwk/mmkRStwVDScl+74muxjneaV6X021TVr58Qdc/cKY3ZnDHP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252274; c=relaxed/simple; bh=07FslQxfhRuiCT1lzSE6hQIMVSjuNpT3IZmEsf/J2dE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RpDiWnXWXfKnmz3icyVZzWO4J/uPMhYk8Ns/3jYTNCLtKQ4SWG26MZoDwQlVrRtN+l35NyZYLZ+zdvhGcbavdCZ8KoVloeOsistd+s2IKlFtsejRT+b9M9kUATmaY0yUxVdNXswgpxUjNoxDUgGGoAyJnXJCcbO3IjGQuSq8Kl4= 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=NVKFrkTl; arc=none smtp.client-ip=209.85.160.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="NVKFrkTl" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-44056295c8cso2949251cf.3 for ; Wed, 12 Jun 2024 21:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252271; x=1718857071; 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=x/ilMGruigntXB9Npx/yb7IkeGQuex+cB4H78QdlVs8=; b=NVKFrkTldPtNKdBd86q1EvtOi5TtMw+MtJPsJcpyq7DbmJuNGGS4wdd5FIPGVn60bD car0vORPOTkmzlpcnR2dy9cH7TSEKwLd4y8s41Sniuma384tTjUyeh3qe4uqp1JXAYYI kHS8cEzCkvjfiS7X44uQZ8MV4MXV/lstI1IdCzOH5H9BXisEZ3Wv2eRKfpn7liTIFxB6 Dd0sLfzSDimzyg6rT4MMswGs6NwcZxI4XvDeYaJKfJWiKMnVdVGWunRAhih8rEOU+8K6 klJyal4hFmaLnqdWK7bOkHVXkyNsy8SIOuuRMfd+Jto8UtZZou81mQO00OO1nQWwvHp8 PUsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252271; x=1718857071; 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=x/ilMGruigntXB9Npx/yb7IkeGQuex+cB4H78QdlVs8=; b=uBE23ibyXik7vfgOhvUn1FHUIWehd3bhZD1IBnbBT5LeQ0iRU1vR1VeRk64j7qVPUA JKP1QUPpzgj3ueKTE86b/DiQETriFlG/CCeLyiUVhXjGYqTu0msIMsEdo9kuMjt+kcZG QT8Ig4LSijR5ruwPjB0offuZSeZ6skPMH5XMgNadRNwcJvDPf57/ZLss5a/2bEPlmS0x zmU5o4ZudL6hbN13sHxBeLTRBNfWDHXtKsW09w8+k1YQE+QfnfCg2JDFD5wUJcP8h0qn uIEHpV1np7QIV0IL4UmjgtISQ10D0Kmym0kUUxcFXT9qF9y3+C+sp3vup4RjuUdUI2Uc xkZQ== X-Gm-Message-State: AOJu0Yx/tkroFGxILStHSbjdfkHEhGU5lqRbk7xDa0o/luM9Ok2DS/ba mH2NnBmWEm5t2tekBsxVDLVublFNGfazoVAvJNH70r4zpA8YJfeRcpNO X-Google-Smtp-Source: AGHT+IFD1bKxrAJzwodjb7tPCLoyX91MEU/gkpsLOFgiNsiJgnrOR2KU3ltMCgwwBNlCEy20BfJBKw== X-Received: by 2002:a05:6214:468a:b0:6b0:75bd:7fb with SMTP id 6a1803df08f44-6b1a731b50fmr52742996d6.40.1718252271385; Wed, 12 Jun 2024 21:17:51 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:50 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 14/19] NFSv4: Add support for the FATTR4_OPEN_ARGUMENTS attribute Date: Thu, 13 Jun 2024 00:11:31 -0400 Message-ID: <20240613041136.506908-15-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-14-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-trond.myklebust@hammerspace.com> <20240613041136.506908-13-trond.myklebust@hammerspace.com> <20240613041136.506908-14-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 Query the server for the OPEN arguments that it supports so that we can figure out which extensions we can use. Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 20 ++++++++++++++++++-- fs/nfs/nfs4xdr.c | 24 ++++++++++++++++++++++++ include/linux/nfs4.h | 2 ++ include/linux/nfs_xdr.h | 9 +++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 512268c732a1..ca2c115b6545 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3885,11 +3885,14 @@ static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) #define FATTR4_WORD1_NFS40_MASK (2*FATTR4_WORD1_MOUNTED_ON_FILEID - 1UL) #define FATTR4_WORD2_NFS41_MASK (2*FATTR4_WORD2_SUPPATTR_EXCLCREAT - 1UL) -#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_TIME_DELEG_MODIFY - 1UL) +#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_OPEN_ARGUMENTS - 1UL) static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) { - u32 bitmask[3] = {}, minorversion = server->nfs_client->cl_minorversion; + u32 minorversion = server->nfs_client->cl_minorversion; + u32 bitmask[3] = { + [0] = FATTR4_WORD0_SUPPORTED_ATTRS, + }; struct nfs4_server_caps_arg args = { .fhandle = fhandle, .bitmask = bitmask, @@ -3915,6 +3918,14 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); if (status == 0) { + bitmask[0] = (FATTR4_WORD0_SUPPORTED_ATTRS | + FATTR4_WORD0_FH_EXPIRE_TYPE | + FATTR4_WORD0_LINK_SUPPORT | + FATTR4_WORD0_SYMLINK_SUPPORT | + FATTR4_WORD0_ACLSUPPORT | + FATTR4_WORD0_CASE_INSENSITIVE | + FATTR4_WORD0_CASE_PRESERVING) & + res.attr_bitmask[0]; /* Sanity check the server answers */ switch (minorversion) { case 0: @@ -3923,9 +3934,14 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f break; case 1: res.attr_bitmask[2] &= FATTR4_WORD2_NFS41_MASK; + bitmask[2] = FATTR4_WORD2_SUPPATTR_EXCLCREAT & + res.attr_bitmask[2]; break; case 2: res.attr_bitmask[2] &= FATTR4_WORD2_NFS42_MASK; + bitmask[2] = (FATTR4_WORD2_SUPPATTR_EXCLCREAT | + FATTR4_WORD2_OPEN_ARGUMENTS) & + res.attr_bitmask[2]; } memcpy(server->attr_bitmask, res.attr_bitmask, sizeof(server->attr_bitmask)); server->caps &= ~(NFS_CAP_ACLS | NFS_CAP_HARDLINKS | diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index e160a275ad4a..98aab2c324c9 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -4337,6 +4337,28 @@ static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap, return 0; } +static int decode_attr_open_arguments(struct xdr_stream *xdr, uint32_t *bitmap, + struct nfs4_open_caps *res) +{ + memset(res, 0, sizeof(*res)); + if (unlikely(bitmap[2] & (FATTR4_WORD2_OPEN_ARGUMENTS - 1U))) + return -EIO; + if (likely(bitmap[2] & FATTR4_WORD2_OPEN_ARGUMENTS)) { + if (decode_bitmap4(xdr, res->oa_share_access, ARRAY_SIZE(res->oa_share_access)) < 0) + return -EIO; + if (decode_bitmap4(xdr, res->oa_share_deny, ARRAY_SIZE(res->oa_share_deny)) < 0) + return -EIO; + if (decode_bitmap4(xdr, res->oa_share_access_want, ARRAY_SIZE(res->oa_share_access_want)) < 0) + return -EIO; + if (decode_bitmap4(xdr, res->oa_open_claim, ARRAY_SIZE(res->oa_open_claim)) < 0) + return -EIO; + if (decode_bitmap4(xdr, res->oa_createmode, ARRAY_SIZE(res->oa_createmode)) < 0) + return -EIO; + bitmap[2] &= ~FATTR4_WORD2_OPEN_ARGUMENTS; + } + return 0; +} + static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen) { unsigned int attrwords = XDR_QUADLEN(attrlen); @@ -4511,6 +4533,8 @@ static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_re if ((status = decode_attr_exclcreat_supported(xdr, bitmap, res->exclcreat_bitmask)) != 0) goto xdr_error; + if ((status = decode_attr_open_arguments(xdr, bitmap, &res->open_caps)) != 0) + goto xdr_error; status = verify_attr_len(xdr, savep, attrlen); xdr_error: dprintk("%s: xdr returned %d!\n", __func__, -status); diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index bc13d7f04e8d..79b23ad674c8 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -512,6 +512,7 @@ enum { enum { FATTR4_TIME_DELEG_ACCESS = 84, FATTR4_TIME_DELEG_MODIFY = 85, + FATTR4_OPEN_ARGUMENTS = 86, }; /* @@ -595,6 +596,7 @@ enum { #define FATTR4_WORD2_XATTR_SUPPORT BIT(FATTR4_XATTR_SUPPORT - 64) #define FATTR4_WORD2_TIME_DELEG_ACCESS BIT(FATTR4_TIME_DELEG_ACCESS - 64) #define FATTR4_WORD2_TIME_DELEG_MODIFY BIT(FATTR4_TIME_DELEG_MODIFY - 64) +#define FATTR4_WORD2_OPEN_ARGUMENTS BIT(FATTR4_OPEN_ARGUMENTS - 64) /* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0) diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index d8cfa956d24c..af510a7ec46a 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1213,6 +1213,14 @@ struct nfs4_statfs_res { struct nfs_fsstat *fsstat; }; +struct nfs4_open_caps { + u32 oa_share_access[1]; + u32 oa_share_deny[1]; + u32 oa_share_access_want[1]; + u32 oa_open_claim[1]; + u32 oa_createmode[1]; +}; + struct nfs4_server_caps_arg { struct nfs4_sequence_args seq_args; struct nfs_fh *fhandle; @@ -1229,6 +1237,7 @@ struct nfs4_server_caps_res { u32 fh_expire_type; u32 case_insensitive; u32 case_preserving; + struct nfs4_open_caps open_caps; }; #define NFS4_PATHNAME_MAXCOMPONENTS 512 From patchwork Thu Jun 13 04:11:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696101 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 DB3A72A1C5 for ; Thu, 13 Jun 2024 04:17:53 +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=1718252275; cv=none; b=FOLPtX5/u6AXo+d/zaU7txdlet7w6yiIFamAK5Nqwj+sUM3cicKlIStosGnjrYvOo3ojGi6ApieoFSNkc6EF4jD+GwoLiskb74mpHgwDFcmBOdmVpa82t1MAK1vMoLYUgYstCZOMLklOlo8uW7EbnRtOFyu86rZePqwC97ReN1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252275; c=relaxed/simple; bh=3T0lVk0s05b94t3g+WI4sOi/ux5TRvqg3k33wukiVMY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W+1ahd9Y9aCgR5m099Crh64kLweC7SVYS7m2LldfTUAlF2Hlu9uTUN69L36Yp/fytpprbR0zNwgmCqshd4Ln03WJkW9lLeskLradHNp+LuvOghuzN5udAJjuc8KDruzbwrcY+uX9qhS8SVLoZG5A85XgYzRwuGmZAuI4ScZRjqA= 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=VzNZqhDm; 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="VzNZqhDm" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-6b06446f667so3121406d6.2 for ; Wed, 12 Jun 2024 21:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252272; x=1718857072; 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=9bjuzTSTyyuy7nSHWdlaaw758n1TGH2uD8+CpJLQezE=; b=VzNZqhDmWwVIrZ+r1oddn2DwVkAUWCHC2QU71a9BMam9nwD2zaP0O5M6Ck+Vb5AkTI aTQLGUSoixWxsc6spvrlJyBeQgPUmVqOme8wviyr2g1D5cn0HBqb3ivq5IJ0EfFYxpsV faHQG4HyTmgpL+d7kc/nn2D6OlL/ovikaw9BtZsw+mwlwu/V8nirLlA0jk34F7HWXUUO VCGj+I5sFi2T8JHzzLknlT/XaI/auVdwgLWu86n3pqtXmgwMDDKuKXaS/WYfS7sNKRF7 /CQDEncHLTzW6/FPfmOpVLGCiiNF1akcLklgu6td/aATqwvspFLkkUt7s3gZTsrHgO6n evew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252272; x=1718857072; 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=9bjuzTSTyyuy7nSHWdlaaw758n1TGH2uD8+CpJLQezE=; b=w1D1x7RxZRWTSeRfieg2uWbrUv1gR+IogK/Z0E2pB8QR579zyiFK0zd9E+6YDANq9b Z8oUTQoq+7Z+d9udGg1Biu2fFfeKcwlc6BynAQ4lWkskklEtQPsnL1Q+Rz82jLDgew6c DhJlKXkduyKMhkyerzexzcK18Ctu35sw5JeE8w6fXX6l9klrv4GKYWyfNz8dDYcgC3cU qOCzufb1+fWnk0Pkd7zb81NMsb9ICdkKZnNmiTUXP+BY0gBFqysYYIjXZnBFs+2rjjkC YHVzY8PK18xE/5LQrmUnUt0qPXJtuHDyBZAba6uCA/gTIRusRadtEQu3n6DsqKplBMYp Hs7Q== X-Gm-Message-State: AOJu0YxxM5fISk2X0MkopX5dsnuchXaugtITj07017cuwejGVHsALu5v qd4uLkdhZjEI8GzL5FQZAfnoyq9iIhx2a4j+0piuleL2OOwkI/H1/tM/ X-Google-Smtp-Source: AGHT+IFY3d+twPm6Y4QWYnxnmQUXUjCRoomiBBHae8hLMYNAd3rp8N2vJWzvlXuSgxQDCyzWXvg4gg== X-Received: by 2002:a05:6214:2d43:b0:6b0:8d8d:8d1 with SMTP id 6a1803df08f44-6b19230dcfbmr33497496d6.32.1718252272457; Wed, 12 Jun 2024 21:17:52 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:51 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 15/19] NFSv4: Detect support for OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION Date: Thu, 13 Jun 2024 00:11:32 -0400 Message-ID: <20240613041136.506908-16-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-15-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-trond.myklebust@hammerspace.com> <20240613041136.506908-13-trond.myklebust@hammerspace.com> <20240613041136.506908-14-trond.myklebust@hammerspace.com> <20240613041136.506908-15-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 Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 4 ++++ include/linux/nfs_fs_sb.h | 1 + include/uapi/linux/nfs4.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ca2c115b6545..87a197864277 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3990,6 +3990,10 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f sizeof(server->attr_bitmask)); server->attr_bitmask_nl[2] &= ~FATTR4_WORD2_SECURITY_LABEL; + if (res.open_caps.oa_share_access_want[0] & + NFS4_SHARE_WANT_OPEN_XOR_DELEGATION) + server->caps |= NFS_CAP_OPEN_XOR; + memcpy(server->cache_consistency_bitmask, res.attr_bitmask, sizeof(server->cache_consistency_bitmask)); server->cache_consistency_bitmask[0] &= FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE; server->cache_consistency_bitmask[1] &= FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 5a76a87cd924..fe5b1a8bd723 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_OPEN_XOR (1U << 12) #define NFS_CAP_DELEGTIME (1U << 13) #define NFS_CAP_POSIX_LOCK (1U << 14) #define NFS_CAP_UIDGID_NOMAP (1U << 15) diff --git a/include/uapi/linux/nfs4.h b/include/uapi/linux/nfs4.h index afd7e32906c3..caf4db2fcbb9 100644 --- a/include/uapi/linux/nfs4.h +++ b/include/uapi/linux/nfs4.h @@ -46,6 +46,7 @@ #define NFS4_OPEN_RESULT_CONFIRM 0x0002 #define NFS4_OPEN_RESULT_LOCKTYPE_POSIX 0x0004 #define NFS4_OPEN_RESULT_PRESERVE_UNLINKED 0x0008 +#define NFS4_OPEN_RESULT_NO_OPEN_STATEID 0x0010 #define NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK 0x0020 #define NFS4_SHARE_ACCESS_MASK 0x000F @@ -70,6 +71,7 @@ #define NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED 0x20000 #define NFS4_SHARE_WANT_DELEG_TIMESTAMPS 0x100000 +#define NFS4_SHARE_WANT_OPEN_XOR_DELEGATION 0x200000 #define NFS4_CDFC4_FORE 0x1 #define NFS4_CDFC4_BACK 0x2 From patchwork Thu Jun 13 04:11:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696102 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 EF06613211A for ; Thu, 13 Jun 2024 04:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252276; cv=none; b=dmUYeEVamDVJBkeE0Ms65DxYSaVz+3T5SzeslsJ4MH0cCUcTP6777gETlbAeM9x/E/LmdQgAV/Q1ZC+y7MTsgohDonjp5QyIwvSUT0GPqpksAEbaWRV5HnMneV/DtsSpsyOfLFiZ9/w55iTQ+W5JIvdHrsuLK/5xE31j18vBurk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252276; c=relaxed/simple; bh=1FfBd74Ye+zPIx8Ibbq6He/677g4YFyWYMS1PSilE9w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iboDSons8VbJnifTQJ5Pq7LlQQHgzx43d1trMlqG5zqu6ESmZdrJXIsRPXLOJpybycjR0ZF67BOfQFiayO1KkDN14QPqeDWosjy+eXktn6O5dmU/PjTgVIunNihNrXhHdSQDRkiTtXs7C37zotA5B0o1GpcOAuX2VxswO9crWwk= 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=KrSk1sI+; arc=none smtp.client-ip=209.85.219.48 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="KrSk1sI+" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-6b064c4857dso2838636d6.2 for ; Wed, 12 Jun 2024 21:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252273; x=1718857073; 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=v+tXPgV4kU1JZhivf9nh6YCdWg3Uo67z8Sq5MNbxaaA=; b=KrSk1sI+rnLqNny5+dH6QFvqeEL5WZHnoA+whGivKrrr5a3T5QeluoTs4w3U8lpNPV FM2S2kznl+1YveqvJlceVGSKtrAJowDVZqKpMVUzIr3uGN1UJc45jJSbCc/BJISIOJoT ia4v1wOhDh+npBxroLs1xDnkTUKl7HhEEH8YZL7h2eE0ubUM0oD1NE1i2zbNeCbxugwD jEuVJqvwZ1zmYNf4UBzelKWSN5QrFZnefEC6CdPjJZ7oMyXIVYxaAglx6dpqbOkJE9vC j1qfsso1Pv5ZROa5VI+O/dvQZ3EJWr1DGtuN5dQTaxdw6wmEQeFCUVqrrTNgNWGFH7+I vqSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252273; x=1718857073; 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=v+tXPgV4kU1JZhivf9nh6YCdWg3Uo67z8Sq5MNbxaaA=; b=wuO+iWYbftfVzK6M0z1pvLo32kmXX5FW9PBJimxBsrHyvwm6JssmMtFN85qkEbohoR BxzlWKMZrZ3T2KPpYT7FJmLO6/+StXk+ll24Iw1y/HGnMYdDZpiQGPYwLQLtkli3PSOP /0MU02zmhJZ3w5MMRMN9ZTTU72cvnAVS0ogvWIBAvcjPH4h+Q1hN77UseYGPVKX3TGlw 7XN2HEm/eYAI7QvoD/TxtuhUoGH4vCo46+wQo9HbD0KZ3J+Xc2SJd4SyoQBvzFySfSrx EadyLk6pTSmTvOyfyL6+IXIuDl6vOEXsciqs1J1RxANdJOQhp9LjRw3/rMPhgQv5tysd Ro/w== X-Gm-Message-State: AOJu0YzrQ168wXZWhCay79CBkl+0lUK9lYdtL6K462xY4V8m/pspkJuN lsguHX+CityOdfjosJgfuY6kgIdFcfGsJAyOxf4LxhZzDgoIqfWae988 X-Google-Smtp-Source: AGHT+IHHUsBM8087uQ9pzw3xYvVfiemE5c232dCEzEn0txwlhQKtJW0SCZ17FuJbk5APNX7qIYyPtg== X-Received: by 2002:a05:6214:5247:b0:6b0:4201:3840 with SMTP id 6a1803df08f44-6b1a696a190mr53462266d6.40.1718252273477; Wed, 12 Jun 2024 21:17:53 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:52 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 16/19] NFSv4: Add support for OPEN4_RESULT_NO_OPEN_STATEID Date: Thu, 13 Jun 2024 00:11:33 -0400 Message-ID: <20240613041136.506908-17-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-16-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-trond.myklebust@hammerspace.com> <20240613041136.506908-13-trond.myklebust@hammerspace.com> <20240613041136.506908-14-trond.myklebust@hammerspace.com> <20240613041136.506908-15-trond.myklebust@hammerspace.com> <20240613041136.506908-16-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 returns a delegation stateid only, then don't try to set an open stateid. Signed-off-by: Trond Myklebust Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 87a197864277..23947fca78fe 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2035,8 +2035,11 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data) data->o_arg.claim, &data->o_res.delegation); - if (!update_open_stateid(state, &data->o_res.stateid, - NULL, data->o_arg.fmode)) + if (!(data->o_res.rflags & NFS4_OPEN_RESULT_NO_OPEN_STATEID)) { + if (!update_open_stateid(state, &data->o_res.stateid, + NULL, data->o_arg.fmode)) + return ERR_PTR(-EAGAIN); + } else if (!update_open_stateid(state, NULL, NULL, data->o_arg.fmode)) return ERR_PTR(-EAGAIN); refcount_inc(&state->count); @@ -2105,8 +2108,13 @@ _nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) data->o_arg.claim, &data->o_res.delegation); - if (!update_open_stateid(state, &data->o_res.stateid, - NULL, data->o_arg.fmode)) { + if (!(data->o_res.rflags & NFS4_OPEN_RESULT_NO_OPEN_STATEID)) { + if (!update_open_stateid(state, &data->o_res.stateid, + NULL, data->o_arg.fmode)) { + nfs4_put_open_state(state); + state = ERR_PTR(-EAGAIN); + } + } else if (!update_open_stateid(state, NULL, NULL, data->o_arg.fmode)) { nfs4_put_open_state(state); state = ERR_PTR(-EAGAIN); } From patchwork Thu Jun 13 04:11:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696103 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 65DD313213B for ; Thu, 13 Jun 2024 04:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252276; cv=none; b=d1nk/KCnJJbkYHfleh6lzdDbNtCpPVeR030FiGcGNEMAfbFvry3dZk3DhR+t0o1gltOkQwrEI0Z9t9euttMoAlwaCsQRzru0ijzxkpUaXbfL4pb8KjbtLOjTWCxB7kuOj/YdPbx+hHr1LsPChyRDZ76lEfqYyJcB1Zp17ol0lkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252276; c=relaxed/simple; bh=+QhbD0cJHsmZUUnuXTTup0buGi79bNCNfbL5JtYs/Os=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qqu/Cd5sZWJNJxTXpzCfq8tL4NvIVY/eTbPL1kh1os5YR8YHGwZ/m/lmLiAIj2tGl30tJb8SgKEvF7OqIOC1+ib38+ocQ+p2bZM98wn9k35pA6Ap5Yx900Kmr5uW9/FEvR7gJHxeYqBJnGXjl9Xd205zThSff2Xqk8LJEK1eQQc= 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=cuh8earp; arc=none smtp.client-ip=209.85.219.43 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="cuh8earp" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6b06bdbf9fdso3412516d6.0 for ; Wed, 12 Jun 2024 21:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252274; x=1718857074; 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=CBi0Avyni3XvXGjN9VHc5/6ljyXF9oVpp2RRruw1EB8=; b=cuh8earpE5LbblwEksKSl6935Ghnzyw+QoTbeFXWSZblKBvqATUuZ+nbfCMx+o3MDd RA/97xfRaX60hPfOrdw10Dh9tNmnhxkVtnZhljkFgg0FELll4cwiu2AUYJ6imFqpgiy0 nMNlf043DWjeAh7enPY49CUCE3WDYOwj8QWMUyoEJRflm16e++q0M6xNCdxawtbjBElx 354ulmGRBE6Vz+ZMTi2qFF7rRpW0pIID0g4fKcz9RxMQ1wTa2TD0Rc75DN/NvOY46k4S pedDOO0uvDFQrSAZHDQjNg++af6bgtjQxcmi7Vjw0z5tfZR3k7YVCpeATzSLcPbVHfFH hbEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252274; x=1718857074; 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=CBi0Avyni3XvXGjN9VHc5/6ljyXF9oVpp2RRruw1EB8=; b=bO/uAuOdFOMaHn2RBzZTWt1w1RsBlZGZMvkWlOM2MvMCzoNqaoM3jG9QKtphtYDftE rOr4vqFftZf1MoFOWllyFBPUUrbwLmOwy5Zfh5JXo8m4TpA70hWHhK+LJBwA5xiR617D cKcbQZo5X3AzM8elzsXVmKvCrkVOjQKo7rpQIUIIDvF2u5e0mOF9rnbDbgjI/2WAUsYd 4RzcsfIaTuebCsIN8zf8/3SM09IrQXBhR3OVEVFHZoyvNn2VxZzLYtOU2k1Rh5DNlUjM 1cvlDfSD8HIE6jb6Kzf3ZC5WlUXWW7DP1/hCJcrSl12WYx8onW33S6AyZyH1DsHAMJ+p U1cw== X-Gm-Message-State: AOJu0YyJLRzobvXlZDyke4wySq6pG4YYl4TLIzVqAKmnv3UQG3aNeeFm atJfcH+NxKmLbL/+fXJwKz80jZZzhLDWfHy/yDMM7sK3Wm3ufWYuxr/g X-Google-Smtp-Source: AGHT+IF4aMLk3TebsgXJXWxTPC5yITL7Crh7RZHXKFgGU28a0QP5bpmps7/ap8HPLeq8GxhJ7qsHdg== X-Received: by 2002:a05:6214:3d8d:b0:6b0:6fc2:a6ef with SMTP id 6a1803df08f44-6b19196ce55mr38269166d6.21.1718252274083; Wed, 12 Jun 2024 21:17:54 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:53 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 17/19] NFSv4: Ask for a delegation or an open stateid in OPEN Date: Thu, 13 Jun 2024 00:11:34 -0400 Message-ID: <20240613041136.506908-18-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-17-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-trond.myklebust@hammerspace.com> <20240613041136.506908-13-trond.myklebust@hammerspace.com> <20240613041136.506908-14-trond.myklebust@hammerspace.com> <20240613041136.506908-15-trond.myklebust@hammerspace.com> <20240613041136.506908-16-trond.myklebust@hammerspace.com> <20240613041136.506908-17-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 Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 23947fca78fe..d41d86c713ea 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1358,6 +1358,8 @@ nfs4_map_atomic_open_share(struct nfs_server *server, /* res |= NFS4_SHARE_WANT_NO_PREFERENCE; */ if (server->caps & NFS_CAP_DELEGTIME) res |= NFS4_SHARE_WANT_DELEG_TIMESTAMPS; + if (server->caps & NFS_CAP_OPEN_XOR) + res |= NFS4_SHARE_WANT_OPEN_XOR_DELEGATION; out: return res; } From patchwork Thu Jun 13 04:11:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696104 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 88590132804 for ; Thu, 13 Jun 2024 04:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252278; cv=none; b=fJXN6S24lnhLpXv2WimRwLiYXMnGGQD7j+3dgyv3YDcEVlhswk7+4Znp4qZGi/LzpeKbvHfiEW5yHscP/pSJHihqiZAkHBgMoV7akiCp1h960gMsw48VO7HhR2oMKlbaB2ddJb/B5wQUJxGk62uqqJqsXDrTKpAvGe5PlnXM0RE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252278; c=relaxed/simple; bh=1LBPvvtlZHa28WUHRVA0vfG2pidThOG2IpXVIh2sJqY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCgMKNKmhHeoZrLo+hKy98FGbSWMPmh8NWNvYzI3mSRMvDKB9yPTF87rXE4jCjpCwMxFK+lyyitShl5F0HfyPQL/HTj3hkVzk/sFjiPxadlDVHfv3q4z7kKXFc0HPoSjC/VEKjyvHwo77oDbLEebORc+IsfkdidfMRK2Ej/MhK8= 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=no0IaaDE; arc=none smtp.client-ip=209.85.160.171 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="no0IaaDE" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-440952018fbso3368211cf.0 for ; Wed, 12 Jun 2024 21:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252275; x=1718857075; 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=vkH9pFmPV9zL+4pS1VYWpD/UMwAp9PQpyY7aL9EgcMg=; b=no0IaaDEnJtyDb5I6DE1m9sr6roF5yUszc+aDsd5lgZBkOwBsUvMfBNQrETsaaYfFI uNVMeB59tvyaMB1lLWpPyA/7MK7EXHHkXqC6vThF6vgOz6bzNkAhRnVWYfymk0ZdmfKD 7zkrwjyyyOOtp/h2EhxmnFY4gI0UFSZjl3OKhLO/Nm8SL4cPzJR7Ehzpb5fEHuPICnwG rFQZrlk6tgQQuIPq/GzVLUaeZxbcsDIaKKUqTSsTsKcl2kR9VcxRw/yIOlw/Y4KPQnlY mA1OY8r5pinSjfAxZlKDvDD6jGHcstj03xP4qiaXvsyymo936Ssg9/SldBxxyRsqEXlY Akvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252275; x=1718857075; 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=vkH9pFmPV9zL+4pS1VYWpD/UMwAp9PQpyY7aL9EgcMg=; b=la2B+QhtgahZ/XlxSpF2Ov5VT0zsMcNTe7LomnszXniTOvx4TGpyXHSCMqFbRhqjYu Byd188ZvRUQyZNaMjh/c7EOPJMIlOyZ0lw09DqFK5KKkw6o6QD186zhxy0O4DxdIjJ4d 0RhfVr/kT85RIRvXWgGa9xUkM3OzVL4M2VNlltbYQSXHT3Za/fT2nl9/0K/i1B+ZUxkD Pp5LD8VsgQL+mYpxLjAndISjs8+5dUZzyqb7NOSot5NnquOJmA/eDeu2nTCjVWmKZ7FZ A+567BZhEr3Kt0p1nArPo8OcDVgnAn1Bm8ariIyoc+qSqf5/vg/MFkD6QWRMHmWiRpoD CWbg== X-Gm-Message-State: AOJu0YyCK6rkrea8QrgB+PGvNmRGQrrkTabPjSkwBMu5DOkOa5HcT7aY bSgxdpVm5u/ulM7AOCy5Zm7seQUODaYiF5txbqWJ/8KiHvk55xG7tLj5 X-Google-Smtp-Source: AGHT+IEW0pK2rpI5lSUM04zS7HXoz8pLdZfvKn1Rri33nCsNHqvRpxSUfqZ7A9xa+YxZJ8sIX+1enQ== X-Received: by 2002:a05:6214:5908:b0:6b0:63fa:c42 with SMTP id 6a1803df08f44-6b191a64578mr43690396d6.26.1718252275090; Wed, 12 Jun 2024 21:17:55 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:54 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 18/19] NFS: Add a generic callback to return the delegation Date: Thu, 13 Jun 2024 00:11:35 -0400 Message-ID: <20240613041136.506908-19-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-18-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-trond.myklebust@hammerspace.com> <20240613041136.506908-13-trond.myklebust@hammerspace.com> <20240613041136.506908-14-trond.myklebust@hammerspace.com> <20240613041136.506908-15-trond.myklebust@hammerspace.com> <20240613041136.506908-16-trond.myklebust@hammerspace.com> <20240613041136.506908-17-trond.myklebust@hammerspace.com> <20240613041136.506908-18-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: Lance Shelton Allow generic NFS code to return the delegation when appropriate. Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/nfs3proc.c | 8 ++++++++ fs/nfs/nfs4proc.c | 1 + fs/nfs/proc.c | 8 ++++++++ include/linux/nfs_xdr.h | 1 + 4 files changed, 18 insertions(+) diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index cab6c73d25d6..1566163c6d85 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -984,6 +984,13 @@ static int nfs3_have_delegation(struct inode *inode, fmode_t type, int flags) return 0; } +static int nfs3_return_delegation(struct inode *inode) +{ + if (S_ISREG(inode->i_mode)) + nfs_wb_all(inode); + return 0; +} + static const struct inode_operations nfs3_dir_inode_operations = { .create = nfs_create, .atomic_open = nfs_atomic_open_v23, @@ -1062,6 +1069,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .clear_acl_cache = forget_all_cached_acls, .close_context = nfs_close_context, .have_delegation = nfs3_have_delegation, + .return_delegation = nfs3_return_delegation, .alloc_client = nfs_alloc_client, .init_client = nfs_init_client, .free_client = nfs_free_client, diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index d41d86c713ea..a4f85af880c2 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -10849,6 +10849,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .close_context = nfs4_close_context, .open_context = nfs4_atomic_open, .have_delegation = nfs4_have_delegation, + .return_delegation = nfs4_inode_return_delegation, .alloc_client = nfs4_alloc_client, .init_client = nfs4_init_client, .free_client = nfs4_free_client, diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 995cc42b0fa0..6c09cd090c34 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -692,6 +692,13 @@ static int nfs_have_delegation(struct inode *inode, fmode_t type, int flags) return 0; } +static int nfs_return_delegation(struct inode *inode) +{ + if (S_ISREG(inode->i_mode)) + nfs_wb_all(inode); + return 0; +} + static const struct inode_operations nfs_dir_inode_operations = { .create = nfs_create, .lookup = nfs_lookup, @@ -757,6 +764,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = { .lock_check_bounds = nfs_lock_check_bounds, .close_context = nfs_close_context, .have_delegation = nfs_have_delegation, + .return_delegation = nfs_return_delegation, .alloc_client = nfs_alloc_client, .init_client = nfs_init_client, .free_client = nfs_free_client, diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index af510a7ec46a..01efacae4634 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1840,6 +1840,7 @@ struct nfs_rpc_ops { struct iattr *iattr, int *); int (*have_delegation)(struct inode *, fmode_t, int); + int (*return_delegation)(struct inode *); struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *); struct nfs_client *(*init_client) (struct nfs_client *, const struct nfs_client_initdata *); From patchwork Thu Jun 13 04:11:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13696105 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (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 15B35132C3B for ; Thu, 13 Jun 2024 04:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252278; cv=none; b=GOwfSTj5n/CHS66mGNjyyT7BzMjbM/Kiod9/tknR9iD0Wn4WuBuf0RVNwHqYNJ0x2um9jwZxeoJLsFxCIkTAaN9S0r7ZZgSdUn0I/FIwCwWmt6e8XlRDWc/uFU0KfvTBhFQZdMysncloC90a2h1Ut7oeqm2fiAVRrA9iUKwcRhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718252278; c=relaxed/simple; bh=l/JP3v9x70TAg/NEFnMLNCt9tijubDiHDpNYOyEMc7c=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PWV6QMmpmacH4hoJztgRjPrLvq2nrJSdKyhNBWbqbEZM3w7HQ6sruxmto36Ohui6TbROyOFZ9KBPwgvifwB6V/x+CqOcehV9zhm2qBqH8aPY57n8/nFDQ0KpJOjxIYvYv3oVXKjSC+Dn9575c5X7IxcWUOcKK53OB6xuo7vsQmc= 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=Jp6XYYKZ; arc=none smtp.client-ip=209.85.219.46 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="Jp6XYYKZ" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-6afc61f9a2eso5957126d6.0 for ; Wed, 12 Jun 2024 21:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718252276; x=1718857076; 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=NpBIbWSgQHLAIBUajMrBNhcehFY7KD/Xz44sbnRKseI=; b=Jp6XYYKZRnxJpDpwa5OGonrL+/4zy3FEArWH76rY0zebLdx+7mD7xUDTnhOZzxsGid ePD0ZMGEBiCnKifkO1QxXz2WTBzwLaUl9etOJM5nGk1PR8moMZTr3im6fPbxyhw2nKP/ JRmiBcUzzVE2tlwYl364maMOjCGL3CJFm6opmqAG8durJWXM4dJcetQtBK/Ex5HemMLM cxX5XzDlEEg5DkJokwdcpErzX3eMLBXTvqm5l7wEIieq3KlzERyyrPjNGGORVwgWU1sp M0I7vQOx4Nb2hgXQn+vus+vGB/3uHvLmsu9id4kgyAXQvN5/foYeStzg2T3W6t3K2pY1 KzsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718252276; x=1718857076; 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=NpBIbWSgQHLAIBUajMrBNhcehFY7KD/Xz44sbnRKseI=; b=oPrlcqsGVG1iBK2nBE8C3znS+OemdxEjKl00TCeC49vC7UZmM2/PiPMqRoFAqtg/S7 8tq/PV+o4CG/9k/rF17qy9oJ3R4alUGUwn4w45orcXaGBO78BWqUMSqS++UesXqOOR9w yImMT/FDCjsb4XDKKrLFDels6FlQ7bHNfMsJZcLdyJphvXQHuQntKy659QI48ExxDcG6 WrrEWRcIxv8wC1kMSzcdB7qjUryzs+CgKZhKHalsT/B1cfMP8DIxhkki+N812Z9Kii5l w8MuJJeM3TgibsAlTHqvaZQohyOuIFVKUPpvDnDPkRja6o111+9jVyWMPBNZkB/N/029 hZDA== X-Gm-Message-State: AOJu0YxWRzVEWSsfilKI0XRq2lXsb6Tzw8lYdyDQv3D1zMChu7E/Z9Bc vfnYFG1ayFBDxuiEzUS6nOIpwWNo26clgdwO8WFXEcyOm16NgThJokIB X-Google-Smtp-Source: AGHT+IEu40wiUCYPpvD0N2xT1OvrFasTuA6tXp5T5cqg0+VSkdjkn9LlVLScBB4WeeVzqgiMCuV7DQ== X-Received: by 2002:a0c:df88:0:b0:6b2:a47d:8f2d with SMTP id 6a1803df08f44-6b2a47d915amr21796906d6.24.1718252275677; Wed, 12 Jun 2024 21:17:55 -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-6b2a5c68ff3sm2851546d6.74.2024.06.12.21.17.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 21:17:55 -0700 (PDT) From: trondmy@gmail.com X-Google-Original-From: trond.myklebust@hammerspace.com To: linux-nfs@vger.kernel.org Subject: [PATCH 19/19] Return the delegation when deleting the sillyrenamed file Date: Thu, 13 Jun 2024 00:11:36 -0400 Message-ID: <20240613041136.506908-20-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613041136.506908-19-trond.myklebust@hammerspace.com> References: <20240613041136.506908-1-trond.myklebust@hammerspace.com> <20240613041136.506908-2-trond.myklebust@hammerspace.com> <20240613041136.506908-3-trond.myklebust@hammerspace.com> <20240613041136.506908-4-trond.myklebust@hammerspace.com> <20240613041136.506908-5-trond.myklebust@hammerspace.com> <20240613041136.506908-6-trond.myklebust@hammerspace.com> <20240613041136.506908-7-trond.myklebust@hammerspace.com> <20240613041136.506908-8-trond.myklebust@hammerspace.com> <20240613041136.506908-9-trond.myklebust@hammerspace.com> <20240613041136.506908-10-trond.myklebust@hammerspace.com> <20240613041136.506908-11-trond.myklebust@hammerspace.com> <20240613041136.506908-12-trond.myklebust@hammerspace.com> <20240613041136.506908-13-trond.myklebust@hammerspace.com> <20240613041136.506908-14-trond.myklebust@hammerspace.com> <20240613041136.506908-15-trond.myklebust@hammerspace.com> <20240613041136.506908-16-trond.myklebust@hammerspace.com> <20240613041136.506908-17-trond.myklebust@hammerspace.com> <20240613041136.506908-18-trond.myklebust@hammerspace.com> <20240613041136.506908-19-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 Signed-off-by: Lance Shelton Signed-off-by: Trond Myklebust --- fs/nfs/unlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 0110299643a2..bf77399696a7 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -232,6 +232,8 @@ nfs_complete_unlink(struct dentry *dentry, struct inode *inode) dentry->d_fsdata = NULL; spin_unlock(&dentry->d_lock); + NFS_PROTO(inode)->return_delegation(inode); + if (NFS_STALE(inode) || !nfs_call_unlink(dentry, inode, data)) nfs_free_unlinkdata(data); }