Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2884054rdb; Wed, 15 Nov 2023 13:34:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGD83jI/gTkcSvIiXT4/vzQ43SOkJKYm4km64Lhzr/WTUkKES1ej9VV8qru8LnnfvDvqLGV X-Received: by 2002:a05:6808:2006:b0:3a7:7988:9916 with SMTP id q6-20020a056808200600b003a779889916mr17655544oiw.59.1700084079099; Wed, 15 Nov 2023 13:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700084079; cv=none; d=google.com; s=arc-20160816; b=GpMcX5lIxQhI72uRwfwVbdjCZs8MVEJO/c/0GZ8sxxOSGfjeA2kP7ryA1VOk89UpbF y26yCwURFLu0Q3PONITDWYAufZTQxPoLTF06+R7fgeF1fcqudlJpBU7+bl+m7By6BMb7 4hJltlH/BG4s+h0k5FMUrgW9NBUeri88j6Pak6iUVzLJEwWzFqe++r4iaP3YuiKH6uSj ALvcLjTTVL8oXG+doKq79QyIL1FUxNGQSsv8qqkZUEYgFJVA4PnFj/xYe9mQ+VYRmbwi HADygXuuZbLnoL7SQe4RLQ+jJ6efdSKWH3FoIM41ObIpxP4AlOpePk9N+1N1mMFRcrey 7yww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Xe/u3nfBzX7MivjnKud0JI8n4zYuwq4AWzE0imDEXhY=; fh=kMe8ipV+H2zZMCwplNV8b/uzUHICYp+b9TeU6KoaKrQ=; b=j/LDEAtmJPhIac0E9JiEUZUkZaUrwUE+wLMv3V1Gev3taD0+x6tT4x09XvRkB3ezBn OzCzMGXDd5LVfB+bnjk1DmtKqZ0V81E2CYJ742ogIBIveCeiMNdPvakVC2kFCh8nQ8tB tpNiryPCz5qRrtfraBqrMu5g7FSDuDSlFuHPCPbs3MRAF/1pqOl1QqhRL3plo0oUasS4 uJG8zq+QDpLn6FHKGF2JTQ3LmwUWRtcxLju5kp3J91DzqQJMXCqnhvM8jwMdBQUG+NyN T5hSZUQITshySLMFykxOaqGUAJ5Ii69jKdQLM84ppJMALMRZTmCqknEhpwKj6PpXfNoj QXzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BH7n1k8M; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b005b966a6960csi1603578pgb.786.2023.11.15.13.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 13:34:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BH7n1k8M; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5218180A9B3E; Wed, 15 Nov 2023 13:34:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235053AbjKOVef (ORCPT + 99 others); Wed, 15 Nov 2023 16:34:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjKOVee (ORCPT ); Wed, 15 Nov 2023 16:34:34 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05AA6B7 for ; Wed, 15 Nov 2023 13:34:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700084066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Xe/u3nfBzX7MivjnKud0JI8n4zYuwq4AWzE0imDEXhY=; b=BH7n1k8M9/LCkTXJCbhluHDwK0x0B5qQaA25QaxMDJ2GkkalukALOffuGcxXdSn2IGtOO2 shDkMK+PdHsdKwShMYf66F0jYONNGQjLige1HELyb3Pfg5W9W3qYAVldRxZUaQsWX4NCIW Yvj/NOTtBV04jfnM5MxEI+YWuDE+Eno= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-_6e7LgoGPgu4oEQGdyIytA-1; Wed, 15 Nov 2023 16:34:24 -0500 X-MC-Unique: _6e7LgoGPgu4oEQGdyIytA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99E9385CBE1; Wed, 15 Nov 2023 21:34:24 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.48.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D5BCC1596F; Wed, 15 Nov 2023 21:34:24 +0000 (UTC) From: Benjamin Coddington To: trond.myklebust@hammerspace.com, anna@kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/2] pNFS: Fix the pnfs block driver's calculation of layoutget size Date: Wed, 15 Nov 2023 16:34:22 -0500 Message-ID: <21a1f2a6155398965f79ed64f0bd23bf38a50367.1700083991.git.bcodding@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 15 Nov 2023 13:34:34 -0800 (PST) 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; } EXPORT_SYMBOL_GPL(nfs_dreq_bytes_left); diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 9c9cf764f600..b1fa81c9dff6 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -655,7 +655,7 @@ extern int nfs_sillyrename(struct inode *dir, struct dentry *dentry); /* direct.c */ void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo, struct nfs_direct_req *dreq); -extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq); +extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq, loff_t offset); /* nfs4proc.c */ extern struct nfs_client *nfs4_init_client(struct nfs_client *clp, diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 84343aefbbd6..9084f156d67b 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -2729,7 +2729,8 @@ pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *r if (pgio->pg_dreq == NULL) rd_size = i_size_read(pgio->pg_inode) - req_offset(req); else - rd_size = nfs_dreq_bytes_left(pgio->pg_dreq); + rd_size = nfs_dreq_bytes_left(pgio->pg_dreq, + req_offset(req)); pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), -- 2.41.0