Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1062471rdg; Fri, 13 Oct 2023 09:07:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfNtH1eOHbOVJQMGhV1jI7Fw0pTuNJX5x1Ojyrb0HvamlbJ1IzzK3s4oFNjpGgAX1iXo/w X-Received: by 2002:a17:902:8e87:b0:1b2:4852:9a5f with SMTP id bg7-20020a1709028e8700b001b248529a5fmr23396329plb.54.1697213241416; Fri, 13 Oct 2023 09:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697213241; cv=none; d=google.com; s=arc-20160816; b=KM+kTQA33hvu8XzXjU9AldRpGLHcR/XTs7FPuHkS6gjvLLl6X3D5jinwNfPkjUB7eb mJRyafgoPg0vt4jUdpFzYV9sExWurWESh4CsIOhAJupG/MCJZPTd/GpUZy82fRrgVzmw 9YYz0T8dEp4cyyuGj6YUHPM1hSLQBMwwH19IAUnqEdjMHYYAHnCGTzxlyeMD58MRWwWN cs/oedSeLVswSNL40lnWWSg5HPuYdPx+F/DqjJakev4k1zsAbbbxqfDXcNfEBL8N4ra3 DiXN/jIb/X0EQNXkewjWBfRsL8yVu9/lucmmJSjaKledhCZDBNMWLmNdImvmA8406tUr 8Lxg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=My5vhPID0cGh8dfo8fU6SjTEUwiUM3vyJnExzTG3s6g=; fh=QCasRecNkSMoqSQLnZiX89u33dCID3L05AOtURpI2pA=; b=AFIZcCb10tCVGaJ1FvNsQMIDdiUgkDQ/4ZIYD5Rg8FrUksLde2/Zt9FnvMQdnmYgNE 4jcKLBR1lxP0WovMgJdo5bKjuEAA2zsFQUiiIK8SH7aY9FU1bcBzaOhwZs8MFZLL7rvD kJjsCM9le4AZ4AdCwK+YWHfBCCGO9cLd9Lk3InU9KqkW8k35RTZN1Fcxd31SCZ3LUg68 C0Ju9kKuOEhtu2Kzzujw4+asOFxfxA3xDNvZ9qd60/smCDhHPqyFhaPIH3C9pewTG+ML GRFPUe+OfZyiqMBKeWFKNH8i5EPaiL4UtFZ2nJLINbLHevlO1Fi7caE4Er9d/2id/PgW c65w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FpWXk9RL; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a10-20020a170902ecca00b001c474ff2fdesi5258016plh.378.2023.10.13.09.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 09:07:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FpWXk9RL; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id BED0B835FD29; Fri, 13 Oct 2023 09:07:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbjJMQHE (ORCPT + 99 others); Fri, 13 Oct 2023 12:07:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232756AbjJMQGS (ORCPT ); Fri, 13 Oct 2023 12:06:18 -0400 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 A0D6AD9 for ; Fri, 13 Oct 2023 09:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697213123; 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: in-reply-to:in-reply-to:references:references; bh=My5vhPID0cGh8dfo8fU6SjTEUwiUM3vyJnExzTG3s6g=; b=FpWXk9RLpotBLNP5oAEaEx0eaj/5QG9dRc0wdQCeCywAP8VpYJqAAHLrPotosAHgEvHqRY PlV95YXEwfEKQVwPo1czIo3R7iogNYQzFKbIhiXhJWqUFxGYx3qw5dQ+cMLzXU46iCviJv +zsRhSkuqIQo2YCL3EEW8kFEFeV1yyw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-UOB1c2_XOhGlcUUO4m1fqg-1; Fri, 13 Oct 2023 12:05:18 -0400 X-MC-Unique: UOB1c2_XOhGlcUUO4m1fqg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5743E382333F; Fri, 13 Oct 2023 16:05:17 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF5040C6CA5; Fri, 13 Oct 2023 16:05:14 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Ilya Dryomov , Christian Brauner , linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH 15/53] netfs: Limit subrequest by size or number of segments Date: Fri, 13 Oct 2023 17:03:44 +0100 Message-ID: <20231013160423.2218093-16-dhowells@redhat.com> In-Reply-To: <20231013160423.2218093-1-dhowells@redhat.com> References: <20231013160423.2218093-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 13 Oct 2023 09:07:16 -0700 (PDT) Limit a subrequest to a maximum size and/or a maximum number of contiguous physical regions. This permits, for instance, an subreq's iterator to be limited to the number of DMA'able segments that a large RDMA request can handle. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/io.c | 18 ++++++++++++++++++ include/linux/netfs.h | 1 + include/trace/events/netfs.h | 1 + 3 files changed, 20 insertions(+) diff --git a/fs/netfs/io.c b/fs/netfs/io.c index d8e9cd6ce338..c80b8eed1209 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -525,6 +525,7 @@ netfs_rreq_prepare_read(struct netfs_io_request *rreq, struct iov_iter *io_iter) { enum netfs_io_source source; + size_t lsize; _enter("%llx-%llx,%llx", subreq->start, subreq->start + subreq->len, rreq->i_size); @@ -547,13 +548,30 @@ netfs_rreq_prepare_read(struct netfs_io_request *rreq, source = NETFS_INVALID_READ; goto out; } + + if (subreq->max_nr_segs) { + lsize = netfs_limit_iter(io_iter, 0, subreq->len, + subreq->max_nr_segs); + if (subreq->len > lsize) { + subreq->len = lsize; + trace_netfs_sreq(subreq, netfs_sreq_trace_limited); + } + } } + if (subreq->len > rreq->len) + pr_warn("R=%08x[%u] SREQ>RREQ %zx > %zx\n", + rreq->debug_id, subreq->debug_index, + subreq->len, rreq->len); + if (WARN_ON(subreq->len == 0)) { source = NETFS_INVALID_READ; goto out; } + subreq->source = source; + trace_netfs_sreq(subreq, netfs_sreq_trace_prepare); + subreq->io_iter = *io_iter; iov_iter_truncate(&subreq->io_iter, subreq->len); iov_iter_advance(io_iter, subreq->len); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 2b5e04ea4db2..aaf1c1d4de51 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -163,6 +163,7 @@ struct netfs_io_subrequest { refcount_t ref; short error; /* 0 or error that occurred */ unsigned short debug_index; /* Index in list (for debugging output) */ + unsigned int max_nr_segs; /* 0 or max number of segments in an iterator */ enum netfs_io_source source; /* Where to read from/write to */ unsigned long flags; #define NETFS_SREQ_COPY_TO_CACHE 0 /* Set if should copy the data to the cache */ diff --git a/include/trace/events/netfs.h b/include/trace/events/netfs.h index beec534cbaab..fce6d0bc78e5 100644 --- a/include/trace/events/netfs.h +++ b/include/trace/events/netfs.h @@ -44,6 +44,7 @@ #define netfs_sreq_traces \ EM(netfs_sreq_trace_download_instead, "RDOWN") \ EM(netfs_sreq_trace_free, "FREE ") \ + EM(netfs_sreq_trace_limited, "LIMIT") \ EM(netfs_sreq_trace_prepare, "PREP ") \ EM(netfs_sreq_trace_resubmit_short, "SHORT") \ EM(netfs_sreq_trace_submit, "SUBMT") \