Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp494986rdb; Fri, 17 Nov 2023 05:04:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IErT8TNSRHhrAioB8Dxj9MkTMhKjvzUiZhbgaU7GjH+VMo3Ubwf7vLtmQSx5v5Is6yI8mOW X-Received: by 2002:a17:902:e5cd:b0:1cc:51b8:8100 with SMTP id u13-20020a170902e5cd00b001cc51b88100mr13352558plf.7.1700226280602; Fri, 17 Nov 2023 05:04:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700226280; cv=none; d=google.com; s=arc-20160816; b=HNoqveMiCuk1F3PbJR2bZGpTRFk/1K9XSQOpsR1KnOvfoYX4qUfnyy1YnhzVtIr0kA N22994uHqZKfp1ktwL91y54t8mztjVAllKwOO60dZ7huTtBKiSrzMpotuD2DDYGBnbLn Pr15H0mZh105wfZP5+HM+Xhbe7mnObYasYnsD2Citq93n3X+lU5f+NhyM3pfeI8ZGtnB dK7WX02fgzOZ7qP2K1QdIr6oNjVzYUghdeRw2e78ysJb/4zWfh4tw33jCAEGBmx6sFJO IBaJPC4Odpw1+vun1T69fRb7IE7rjU+V2RlFDs9TM3BruSVH+b53HOfzCz7e30ckbocZ X99g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uo1kgCdkTwrjI5cP4C8NMzcAVl9mOmCA57e+hhUGPNI=; fh=NJKEtfqXUQbYn4ZYvqYRQES6G3uJXVw+Ugj0L560IAo=; b=lPdEmjlavc+dY/PB5lUc3NLD7zBKvKBgdsmFTAxujcl7nxLg89Z+blYPBkCF5G+7cN 95rYinGxKzNmPeFnYCXzGYOULD6tH7PVF9wie/Cas+hrS1GJMfi0VZJBl02WIx3MtGKd +m/wYUJoX+lALbD0du6SoYWFh8lo0jreKh6Y39tvd1UUylcNUMQEdU+bL0vqdXeKJi96 L0UtNTVgznqcgWruJFbOZyOwwgT/1rJhD6Pe4rPggKEA34CKHyWkry+Ap9tKGMj/lmcT 6f58kQcVzZehYeDHR0SBsklpfdxvX6Ve7BM4jtVvl2UWSUV3SLrjTvxh+dw/js4HngM/ XhBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=TgVlPpQQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l10-20020a170903244a00b001ca85fddf9esi1820584pls.483.2023.11.17.05.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 05:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=TgVlPpQQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 28B1E809EC9E; Fri, 17 Nov 2023 05:04:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbjKQNEW (ORCPT + 99 others); Fri, 17 Nov 2023 08:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjKQNEW (ORCPT ); Fri, 17 Nov 2023 08:04:22 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AF10D52 for ; Fri, 17 Nov 2023 05:04:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uo1kgCdkTwrjI5cP4C8NMzcAVl9mOmCA57e+hhUGPNI=; b=TgVlPpQQByy/XyxLQIz1sSL8yI h1BLFP1QHaAESKWCNiw2IzXRLAPh5r58TPFJNjdSsnlvyXndC3cT8iGfoUCycWJWM9rRNM7/PENTY IXYtXfOj4E3okbw3iHtvAma3cBgGfYjExIgV4KjceRCVipNLmhFbE3t/dqQcfptXxrYA+/AQR/5Cr lPprRK6J1GiiDstvtvnijqwWU3l83Fs3xBRN7Fql8WszOKjybAiqRqAV50ctc9TLcnkbtOJABuMbl i4PlKlCOJRbvIUWKNb2ZumbFsYLMWhtuQ85DlGB4o/Sq7b0arZezOE5kbCx5pCbSKj9b7Q7EA/R4C oFjf8IxQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1r3yW9-006bQv-0K; Fri, 17 Nov 2023 13:04:17 +0000 Date: Fri, 17 Nov 2023 05:04:17 -0800 From: Christoph Hellwig To: Benjamin Coddington Cc: trond.myklebust@hammerspace.com, anna@kernel.org, linux-nfs@vger.kernel.org Subject: Re: [PATCH v2 1/2] pNFS: Fix the pnfs block driver's calculation of layoutget size Message-ID: References: <21a1f2a6155398965f79ed64f0bd23bf38a50367.1700220277.git.bcodding@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21a1f2a6155398965f79ed64f0bd23bf38a50367.1700220277.git.bcodding@redhat.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 17 Nov 2023 05:04:31 -0800 (PST) On Fri, Nov 17, 2023 at 06:25:13AM -0500, Benjamin Coddington wrote: > From: Trond Myklebust > > Instead of relying on the value of the 'bytes_left' field, we should > calculate the layout size based on the offset of the request that is > being written out. > > Reported-by: Benjamin Coddington > Signed-off-by: Trond Myklebust > Fixes: 954998b60caa ("NFS: Fix error handling for O_DIRECT write scheduling") > Reviewed-by: Benjamin Coddington > Tested-by: Benjamin Coddington > --- > fs/nfs/blocklayout/blocklayout.c | 5 ++--- > fs/nfs/direct.c | 5 +++-- > fs/nfs/internal.h | 2 +- > fs/nfs/pnfs.c | 3 ++- > 4 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c > index 943aeea1eb16..c1cc9fe93dd4 100644 > --- a/fs/nfs/blocklayout/blocklayout.c > +++ b/fs/nfs/blocklayout/blocklayout.c > @@ -893,10 +893,9 @@ bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) > } > > if (pgio->pg_dreq == NULL) > - wb_size = pnfs_num_cont_bytes(pgio->pg_inode, > - req->wb_index); > + wb_size = pnfs_num_cont_bytes(pgio->pg_inode, req->wb_index); > else > - wb_size = nfs_dreq_bytes_left(pgio->pg_dreq); > + wb_size = nfs_dreq_bytes_left(pgio->pg_dreq, req_offset(req)); > > pnfs_generic_pg_init_write(pgio, req, wb_size); > > diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c > index f6c74f424691..5918c67dae0d 100644 > --- a/fs/nfs/direct.c > +++ b/fs/nfs/direct.c > @@ -205,9 +205,10 @@ static void nfs_direct_req_release(struct nfs_direct_req *dreq) > kref_put(&dreq->kref, nfs_direct_req_free); > } > > -ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq) > +ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq, loff_t offset) > { > - return dreq->bytes_left; > + loff_t start = offset - dreq->io_start; > + return dreq->max_count - start; We normally put an empty line after the variable declarations. But looking at this, thee local variables seems a bit pointless to me, as does not simply making this an inline function. > +extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq, loff_t offset); and you might as well drop the pointless extern here while you're at it. Otherwise this looks good to me: Reviewed-by: Christoph Hellwig