Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4633898ybp; Mon, 7 Oct 2019 11:21:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVx0LiMt5Lins8GE3CyQvnnG/5OUNTPKaIDuqFTht0GKKEqfmIwBu+GOvvLTt5gMY8rBO3 X-Received: by 2002:a50:d084:: with SMTP id v4mr30707816edd.48.1570472464405; Mon, 07 Oct 2019 11:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570472464; cv=none; d=google.com; s=arc-20160816; b=ij7CeJB4yMIHzdZE/E1n08C7ZkZtPyvvYasUEzG1ETY/DWrnaYiCA3FiMm6VGYnQo+ DHp0gCQGWg2jrQKeYgQWy33QRR/4ee/z2ZvXBDFyAsuYNsD2kCIY0TH3U351OLiTpWPg Pm+gjhubJux4Jh6Xss/5KDqIhG6zTdiSExFVVM+IQHNv+RRPF2vJMsnkmkvg7RqLfITJ Icw7VhAlodhL8jls/kzfTrlmrh3EqBLVW5iWXq9FoF2l2VNr9UyIfyzhivzhZDi5ahyB AIdKL8JZugpS3fHqRul3GHpIIS+SBTJOti5nwY1xzgcAcbN5Z4nD3BH3SS4RghUt/IwU YUzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=yd63oZ2QZEdvz/9cYodehsCpkxZy4lA2u3H7BgzXCI4=; b=WTG4B1h5g5w8rWAKArG6Zoc+G2ZHaw26s1bp94xcIa8l5iu/bqyvfHlB/hjDowPYYs s9s9hGfTrj+q5dzT1Lj8xwl5SgCODGOBhAaITXQiIxRm+7ir+XfogBEvYfbiPbrZwhS3 GpLX7g2ZD5LWli99ZryVPZvutyX1z9XasbP0s1Q0Fu5VE6zOS6BR0vCekrJ3nHjUGGK7 cMz6We6Ru3vB0tgQQDVnTtIX5JSDYR372iTGrZj4oaX17J825iIxRWICPdnB0zuxej9h fU7gIyEVCz9hcUgS6LSyycPPdq/g+VHD0i2mGW05ka0cNmIcBesgP4948K1TJXt7+Mxa Vvqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si7409318ejz.381.2019.10.07.11.20.29; Mon, 07 Oct 2019 11:21:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728081AbfJGSUZ (ORCPT + 99 others); Mon, 7 Oct 2019 14:20:25 -0400 Received: from fieldses.org ([173.255.197.46]:46146 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728031AbfJGSUZ (ORCPT ); Mon, 7 Oct 2019 14:20:25 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 7A8C07EC; Mon, 7 Oct 2019 14:20:24 -0400 (EDT) Date: Mon, 7 Oct 2019 14:20:24 -0400 From: "J. Bruce Fields" To: Olga Kornievskaia Cc: trond.myklebust@hammerspace.com, Anna Schumaker , "J. Bruce Fields" , linux-nfs Subject: Re: [PATCH v7 18/19] NFSD: allow inter server COPY to have a STALE source server fh Message-ID: <20191007182024.GB22450@fieldses.org> References: <20190916211353.18802-1-olga.kornievskaia@gmail.com> <20190916211353.18802-19-olga.kornievskaia@gmail.com> <20191002195511.GA21809@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, Oct 07, 2019 at 10:31:04AM -0400, Olga Kornievskaia wrote: > On Wed, Oct 2, 2019 at 3:55 PM J. Bruce Fields wrote: > > > > On Mon, Sep 16, 2019 at 05:13:52PM -0400, Olga Kornievskaia wrote: > > > @@ -1956,6 +1964,45 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp, > > > - rqstp->rq_auth_slack; > > > } > > > > > > +#ifdef CONFIG_NFSD_V4_2_INTER_SSC > > > +static __be32 > > > +check_if_stalefh_allowed(struct nfsd4_compoundargs *args) > > > +{ > > > + struct nfsd4_op *op, *current_op, *saved_op; > > > > current_op and saved_op need to be initialized to NULL here. > > > > > + struct nfsd4_copy *copy; > > > + struct nfsd4_putfh *putfh; > > > + int i; > > > + > > > + /* traverse all operation and if it's a COPY compound, mark the > > > + * source filehandle to skip verification > > > + */ > > > + for (i = 0; i < args->opcnt; i++) { > > > + op = &args->ops[i]; > > > + if (op->opnum == OP_PUTFH) > > > + current_op = op; > > > + else if (op->opnum == OP_SAVEFH) > > > + saved_op = current_op; > > > + else if (op->opnum == OP_RESTOREFH) > > > + current_op = saved_op; > > > + else if (op->opnum == OP_COPY) { > > > + copy = (struct nfsd4_copy *)&op->u; > > > + if (!saved_op) > > > + return nfserr_nofilehandle; > > > > Looks like this results in returning an empty compound result with just > > the bare result. I believe what we need to do is execute all the > > ops preceding the COPY normally, then return the nofilehandle error on > > the COPY. > > > > One approach might be > > > > if (!saved_op) { > > op->status = nfserr_nofilehandle; > > return; > > } > > > > and change check_if_stalefh_allowed to have no return value. > > Ok thanks. I'm just curious if op->status assignment is necessary or I > can just do a return. When nfsd4_copy() calls nfs4_verify_copy() it > would check > if (!cstate->save_fh.fh_dentry) > return nfserr_nofilehandle; Catching the error here might be a little safer if you think there's ever a risk of messing up the later logic? But, really, either should work. Since a real client is never going to hit any interesting cases here, it could be useful to have a pynfs test or two that sent some weird illegal compounds. --b. > > > > > --b. > > > > > + putfh = (struct nfsd4_putfh *)&saved_op->u; > > > + if (!copy->cp_intra) > > > + putfh->no_verify = true; > > > + } > > > + } > > > + return nfs_ok; > > > +} > > ... > > > @@ -2004,6 +2051,9 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp, > > > resp->opcnt = 1; > > > goto encode_op; > > > } > > > + status = check_if_stalefh_allowed(args); > > > + if (status) > > > + goto out; > > > > > > > > trace_nfsd_compound(rqstp, args->opcnt); > > > while (!status && resp->opcnt < args->opcnt) {