Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp804007rdb; Fri, 17 Nov 2023 13:17:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IErRgkJLLJJ7DAjwNDnZjlJMg5taXEzApH6+J7BBHyPxGXBgarsY9a7HhKo1lMt/Z9ogjtW X-Received: by 2002:a17:902:e749:b0:1cc:5db8:7eb1 with SMTP id p9-20020a170902e74900b001cc5db87eb1mr1069653plf.51.1700255866368; Fri, 17 Nov 2023 13:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700255866; cv=none; d=google.com; s=arc-20160816; b=VdluFEWWlJ9dVkX6lXzeRpkBnqMFSJd5JIsyYxOBDX420wu6YLoX+7y9yZILmM7uh9 i9wscaq+ZQ3wdX4mGeQz7iG2F9FG9avtFALNznHFI1InhVvtYUSvdj30RgAxAiM+q9fi /dwVDIHxSLEPBufrWh9p14b/HKRBSyXPSYhyOfeGiMBZYnxlGjsieDW+mFXaBdRZU+jQ t3/uCGADh+4fT8vsBDkm/IaCmBK80PfU88bkFmzcikc1pWUJHbHlGbgisxvChqCFpzEM cUvlcY8FS9WP71jUS2elgNEUZuOTrCcjiuGv5tgzprsiMz57WfPmJukVHIvwRDpVlWd/ ho7A== 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=aymUqh8tNqy/9mbxQPB2e2M5NzhlTlDvAtO1iWjEkMc=; fh=lVY/c7gYUTDnyYYKKvGQU3Q29dA69hck6eN/HP5dBQ0=; b=CIg9fHuuF7uVVPvIUi3faPZYwl5ZOxRCEe9V3tvbRdAB6INHyj2at5Wl/9AAPfkF46 AwYbzu97wBLlGFT6Btz+nPF2mhBRdzBbCjHh0F7J+qXuNeln5oZkGZUi9XRBc6qjOl8l JhxBE3w0P26/B7AEOAQpFDTnCdFsGr/YIUxEfYWD1CE1Hrs4m/nvuPsplML5yu3YI2kQ C7fZcjc1I2oWQ7NOrYeMfDrXcfi62pzCzC+ElCbB1jFUfUAEZW3Je+Lt50VWT3YyZOr1 lLnCNAnSxsfedtpjDA66o+2ZIQSVeiin/Xpo7u7VmlGeb9u3oG9iIbbGyyd363I9BAKo YDAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=az4q1HAE; 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 x13-20020a170902ea8d00b001c9faf1439esi2403272plb.288.2023.11.17.13.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 13:17:46 -0800 (PST) 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=az4q1HAE; 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 091AE8253FE7; Fri, 17 Nov 2023 13:17:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235761AbjKQVRW (ORCPT + 99 others); Fri, 17 Nov 2023 16:17:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235770AbjKQVRA (ORCPT ); Fri, 17 Nov 2023 16:17:00 -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 7680B1FEF for ; Fri, 17 Nov 2023 13:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700255798; 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=aymUqh8tNqy/9mbxQPB2e2M5NzhlTlDvAtO1iWjEkMc=; b=az4q1HAE7wQifSgnjUWkVAGiv5GWoocQzH+9iKMz4A9JEiknHIdOT7wtgG834RccUo8dI5 o3DNOnkOOBxD7d6UzYKrGf1JpnJqv9CBPQN+xXbaKETRloZGO7TJyCqIcSkNyFCYr8QKC3 0uChYSMbOc0DAZvsEYFJ1yARN5O8/nQ= 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-318-QQ2MUg3zMpa_F036AItkIg-1; Fri, 17 Nov 2023 16:16:34 -0500 X-MC-Unique: QQ2MUg3zMpa_F036AItkIg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 20F093821359; Fri, 17 Nov 2023 21:16:33 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 863BC492BE0; Fri, 17 Nov 2023 21:16:30 +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-cachefs@redhat.com, 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 Subject: [PATCH v2 13/51] netfs: Limit subrequest by size or number of segments Date: Fri, 17 Nov 2023 21:15:05 +0000 Message-ID: <20231117211544.1740466-14-dhowells@redhat.com> In-Reply-To: <20231117211544.1740466-1-dhowells@redhat.com> References: <20231117211544.1740466-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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 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, 17 Nov 2023 13:17:34 -0800 (PST) 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 cd673596b411..20ddd46fa0bc 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") \