Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp441385rdb; Fri, 17 Nov 2023 03:25:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdQ27ECCwNSv1mDQNiQrBUg8W/zZmWRGpOYTkL6/8XPr9qbl6xcGb0lbUJSTryk2JM9oaN X-Received: by 2002:a17:90b:3883:b0:280:2652:d4e with SMTP id mu3-20020a17090b388300b0028026520d4emr15772354pjb.29.1700220328079; Fri, 17 Nov 2023 03:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700220328; cv=none; d=google.com; s=arc-20160816; b=GmEIKnzLM6ZrZJ/g4krB4Hx69TSbRPP36hYHbyY2k6953UtjQ19zLn/PpF014u6qeY C8Dd1wd0N6OFOHpyfnzeT5ybaU/22iWn8lP/9kiN6NlkWZLX0qaQJxCebhJSEAoW6/ll GWuUI+5+95TOCWo690FmkbX6yteoJzT47HwFGK/c+avK4va2YQuRzhbIl1Gl/wGBBWqJ XiFi52touJsf1Xh8jvWgtdPATfCXlSHSxDTE7ef0lvHnlFjyyvhc/wK8RWb6lFVQxd6U Tyc8LVe6V0M/AYnFxu8UEa6g0A5fnMprYcp6Cn6i7h6pBIAykyZTszpH/kGE20Bc8JtR U7SQ== 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=cnazbrUd/PnZ5mhNm41OavCmK24oC7U6oIjjkBFqHTUGlVY0IoxavE0Bwnpz8ONJJI 3b0ZscDcetR5Al0DHxChcfYIEFL6HaSNJRF79KfBPHOtUDBOtG6B13zE9jYax8zqXqDv dEBhLPQlh5AiAw3eGzLbxDzH8t7B3I9bgawJTtpZpqmSjKyFi0hzlIMFpS9qDNdnXfIe PQPYpBcHoStfat6AmvAl18EQYeuoICEVtBPkQOS3xnhwltFojbHP0ZCrQ5vfENhiJr+g pCCzPFovHfwAT5+3FdimO083piBRAEOVNZcjjxSiJhr6kSF6SU8Kvh3qVy3kFC99l+4c ALXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="T/kPxLMB"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h3-20020a17090aa88300b00280145d5114si1731142pjq.5.2023.11.17.03.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 03:25:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="T/kPxLMB"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 7C57C82DAFE7; Fri, 17 Nov 2023 03:25:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230377AbjKQLZY (ORCPT + 99 others); Fri, 17 Nov 2023 06:25:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbjKQLZX (ORCPT ); Fri, 17 Nov 2023 06:25:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8528A131 for ; Fri, 17 Nov 2023 03:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700220319; 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=T/kPxLMBlN0m2sA+TziohyYKxTb3mpGO0RO5FNZt62CHizUZuv7d8OMTmqzxZT0N+gret2 pR/C713TeHm1TS9p38c9rNgLkhJpmhIlZf06Bh2EGaI2pYi5J6tARLcW4H9GjYHCL2VRzQ ajRHUwmzD+dEbv+ZH1mITJpEJc+fczM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-disnBCg5Pj2jT_4ZYZkJ_Q-1; Fri, 17 Nov 2023 06:25:16 -0500 X-MC-Unique: disnBCg5Pj2jT_4ZYZkJ_Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 5642338116E0; Fri, 17 Nov 2023 11:25:16 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.48.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id B45E92026D4C; Fri, 17 Nov 2023 11:25:15 +0000 (UTC) From: Benjamin Coddington To: trond.myklebust@hammerspace.com, anna@kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 1/2] pNFS: Fix the pnfs block driver's calculation of layoutget size Date: Fri, 17 Nov 2023 06:25:13 -0500 Message-ID: <21a1f2a6155398965f79ed64f0bd23bf38a50367.1700220277.git.bcodding@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 17 Nov 2023 03:25:23 -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