Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1200573rdg; Fri, 11 Aug 2023 13:11:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlc9YhaUlR8wN3A2II1ieFRWt7+Ee6OBkAvQ/S3bEcrIubDK0RImyuKaCAgBGzMF3EKBcW X-Received: by 2002:a05:6000:929:b0:313:f45f:74a1 with SMTP id cx9-20020a056000092900b00313f45f74a1mr2101256wrb.51.1691784672301; Fri, 11 Aug 2023 13:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691784672; cv=none; d=google.com; s=arc-20160816; b=IoZkr2KcdLE7j7Ps5E0jOMRnB4GowjSKc6ZQeWuvNOJVZfe5Prw4gbQ/Jj8AceIaQx J4td+LbRHjy9xvuZhGn590MClVxq9jijy6pKjfqb3/pgVhiXgVMxpUAH6p9CID/zhMp+ lu0JrD3JagiiSYaVjrK0d6a8FGVLDbn53D0KQmuCf9kbBV3M/uJInzVxhoxYJ4fEL3Nj lcV2jC/4ebuOxcq/rCiZ99f64VObnNhP0ArdH6AIwc9lJqdl8JSMxT7ogzIWvln5pMxj F3R+NjEGTDCDxeEjhCUvrl6Zvk0gaMqc+4UM2G+CMpqdy2P6FmnRjW3DdxeUUfEIIeRe YrdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=Q/KV4ZyzjIxiQiYLvyy4mUYNP1g/j/BFDbC/ynZvj2g=; fh=oiqboK5sPipeFr1IY4dZ+ni85hLvfZW11Kltr/uHLNQ=; b=T2CkcoNyJLSUaqiuSYXB1QCQ8WAg2a/QVitEaDDx+WYHR4yafZf2BqIb/BxHq0r4ID G00btccugSl4unZFAZ9b/hRHDLSISI/KesNXczQFcN6L6n1OZlJZKcd0jtM3AHtwcLMt 6XxBdTt47egW9iSx1Gqo3gmIXzcdlql2V7RYghrwwSVWL4rYMWyP5QwcUc8nXsNyg0Vf gbIjNIQH3N7SQhEkR/FnxNHfeSeamIJVz+lFaaBbcnCaJAFkTuEvDS2uyioyXZFe301j Dj6SWtGH60Il/0MOIPVmwjQA59SwA7h33yTfrZPC0TiP72Jr5zZq72yYZvKUNDNV0E2L Qc7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XHKGmxUF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m24-20020aa7c498000000b0052277b28365si3920866edq.338.2023.08.11.13.10.37; Fri, 11 Aug 2023 13:11:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XHKGmxUF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231132AbjHKTGZ (ORCPT + 99 others); Fri, 11 Aug 2023 15:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbjHKTGZ (ORCPT ); Fri, 11 Aug 2023 15:06:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93F251BD for ; Fri, 11 Aug 2023 12:06:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2AA75676BD for ; Fri, 11 Aug 2023 19:06:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EFDFC433C9; Fri, 11 Aug 2023 19:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691780783; bh=hoys41yFemf6a0T+2lcov2FXbEF4lUjf4vdybkGOl1g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=XHKGmxUFO6L9mFU6k+PvU/GsH6aFBEWAuMIk+fxYlAkP7JxAY7q80MSz+wIUKp2JQ CdkeSmC1kCoGx0uYNcQ89v4tXObToUvYpRWunOd0g8ZaLkaFdhQpXTeKbrjW8RpVqC 8Uni+vH2RXX6pW4BOBO+7afLScJKNLFAbRljFPpfgT7261zrrbtDmupeV5aEpuujYw f6F64lNCL1/TssiJFngkMZ0LGQ4pdOG7K08y2ku93dpRGfyTu5PB7u/4PIHbxTPcA5 IH1M6MEoVpzltYrRsm0hdpUpe+0BWMkcHjqVkfRZe4AZsjP078BAfh5pXUNxNVxx53 pRjhr0kcJORSg== Message-ID: <41b59c4a1359c5b0224fbe95e9fec062b6d8bdbf.camel@kernel.org> Subject: Re: [PATCH v7 2/4] NFSD: allow client to use write delegation stateid for READ From: Jeff Layton To: dai.ngo@oracle.com, chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Date: Fri, 11 Aug 2023 15:06:22 -0400 In-Reply-To: <83cd1107-2efe-f16c-2015-3da15aec12a5@oracle.com> References: <1688089960-24568-1-git-send-email-dai.ngo@oracle.com> <1688089960-24568-3-git-send-email-dai.ngo@oracle.com> <6756f84c4ff92845298ce4d7e3c4f0fb20671d3d.camel@kernel.org> <83cd1107-2efe-f16c-2015-3da15aec12a5@oracle.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Yep. Reverting that patch seemed to fix the problem. Chuck, mind just dropping this patch from nfsd-next? Thanks, Jeff On Fri, 2023-08-11 at 10:47 -0700, dai.ngo@oracle.com wrote: > Hi Jeff, >=20 > I have not looked at this carefully, but since now we only grant > write delegation for OPEN with both read and write access then > perhaps this patch is no longer needed? >=20 > -Dai >=20 > On 8/11/23 10:22 AM, Jeff Layton wrote: > > On Thu, 2023-06-29 at 18:52 -0700, Dai Ngo wrote: > > > Allow NFSv4 client to use write delegation stateid for READ operation= . > > > Per RFC 8881 section 9.1.2. Use of the Stateid and Locking. > > >=20 > > > Signed-off-by: Dai Ngo > > > --- > > > fs/nfsd/nfs4proc.c | 16 ++++++++++++++-- > > > fs/nfsd/nfs4xdr.c | 9 +++++++++ > > > fs/nfsd/xdr4.h | 2 ++ > > > 3 files changed, 25 insertions(+), 2 deletions(-) > > >=20 > > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > > > index 5ae670807449..3fa66cb38780 100644 > > > --- a/fs/nfsd/nfs4proc.c > > > +++ b/fs/nfsd/nfs4proc.c > > > @@ -942,8 +942,18 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_= compound_state *cstate, > > > /* check stateid */ > > > status =3D nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->curr= ent_fh, > > > &read->rd_stateid, RD_STATE, > > > - &read->rd_nf, NULL); > > > - > > > + &read->rd_nf, &read->rd_wd_stid); > > I think this patch is causing breakage with pynfs. WRT3 sends a READ > > operation with the zero-stateid. On earlier kernels, this works, but a > > linux-next kernel=A0rejects this with BAD_STATEID. > >=20 > > nfs4_preprocess_stateid_op seems to assume that if cstid is set, then > > it's a copy operation and anonymous stateids aren't allowed. Maybe that > > test should be something besides checking cstid =3D=3D NULL? > >=20 > > > + /* > > > + * rd_wd_stid is needed for nfsd4_encode_read to allow write > > > + * delegation stateid used for read. Its refcount is decremented > > > + * by nfsd4_read_release when read is done. > > > + */ > > > + if (!status && (read->rd_wd_stid->sc_type !=3D NFS4_DELEG_STID || > > > + delegstateid(read->rd_wd_stid)->dl_type !=3D > > > + NFS4_OPEN_DELEGATE_WRITE)) { > > > + nfs4_put_stid(read->rd_wd_stid); > > > + read->rd_wd_stid =3D NULL; > > > + } > > > read->rd_rqstp =3D rqstp; > > > read->rd_fhp =3D &cstate->current_fh; > > > return status; > > > @@ -953,6 +963,8 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_c= ompound_state *cstate, > > > static void > > > nfsd4_read_release(union nfsd4_op_u *u) > > > { > > > + if (u->read.rd_wd_stid) > > > + nfs4_put_stid(u->read.rd_wd_stid); > > > if (u->read.rd_nf) > > > nfsd_file_put(u->read.rd_nf); > > > trace_nfsd_read_done(u->read.rd_rqstp, u->read.rd_fhp, > > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > > > index 76db2fe29624..e0640b31d041 100644 > > > --- a/fs/nfsd/nfs4xdr.c > > > +++ b/fs/nfsd/nfs4xdr.c > > > @@ -4120,6 +4120,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *res= p, __be32 nfserr, > > > struct file *file; > > > int starting_len =3D xdr->buf->len; > > > __be32 *p; > > > + fmode_t o_fmode =3D 0; > > > =20 > > > if (nfserr) > > > return nfserr; > > > @@ -4139,10 +4140,18 @@ nfsd4_encode_read(struct nfsd4_compoundres *r= esp, __be32 nfserr, > > > maxcount =3D min_t(unsigned long, read->rd_length, > > > (xdr->buf->buflen - xdr->buf->len)); > > > =20 > > > + if (read->rd_wd_stid) { > > > + /* allow READ using write delegation stateid */ > > > + o_fmode =3D file->f_mode; > > > + file->f_mode |=3D FMODE_READ; > > > + } > > > if (file->f_op->splice_read && splice_ok) > > > nfserr =3D nfsd4_encode_splice_read(resp, read, file, maxcount); > > > else > > > nfserr =3D nfsd4_encode_readv(resp, read, file, maxcount); > > > + if (o_fmode) > > > + file->f_mode =3D o_fmode; > > > + > > > if (nfserr) { > > > xdr_truncate_encode(xdr, starting_len); > > > return nfserr; > > > diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h > > > index 510978e602da..3ccc40f9274a 100644 > > > --- a/fs/nfsd/xdr4.h > > > +++ b/fs/nfsd/xdr4.h > > > @@ -307,6 +307,8 @@ struct nfsd4_read { > > > struct svc_rqst *rd_rqstp; /* response */ > > > struct svc_fh *rd_fhp; /* response */ > > > u32 rd_eof; /* response */ > > > + > > > + struct nfs4_stid *rd_wd_stid; /* internal */ > > > }; > > > =20 > > > struct nfsd4_readdir { --=20 Jeff Layton