From patchwork Mon Jul 29 16:19:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13745297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EDC5C3DA61 for ; Mon, 29 Jul 2024 16:22:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C79DD6B00AA; Mon, 29 Jul 2024 12:22:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C29CF6B00AC; Mon, 29 Jul 2024 12:22:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACA0B6B00AD; Mon, 29 Jul 2024 12:22:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8F0956B00AA for ; Mon, 29 Jul 2024 12:22:05 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5AB87403D3 for ; Mon, 29 Jul 2024 16:22:05 +0000 (UTC) X-FDA: 82393307010.24.2652F9C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 9DA12C002C for ; Mon, 29 Jul 2024 16:22:03 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dKe3WVGp; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722270120; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v61GO21S8pTlp0s2AWk5G5oSQ+p84Fns5OqZB2t4B40=; b=qHrZdUmpcCvR+S0qQrbAReiwoKCzaSQGtuQU37/xKC+TlQiLknmNSgtn0ZNjkY8/29UUUm JI+LMBUAb+gThEx+YMl9NKdI652PxUutc1M+WD0fmu0XSj7uJndPnfuGBnptWOr8E2Oos+ 7cBZx1ZETFyoCQqg2KvDjYAiMX0SUBY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dKe3WVGp; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722270120; a=rsa-sha256; cv=none; b=loQae3GJ35IAFy409IdAf8nEcT9uKboUW62LDWhKzHLAtIQgNFC/JP8LnvmmzqlGnBWMuq 2gUEFDEisf8v6nL4sowv4kZibfXe0bFB+cHZ4zWKuPpxU0oVe/RYZBrh5cfgnQ7gm3VRBC q/q8x3LoRLGZTxmPa62fLnJTXlcmAyo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722270123; 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=v61GO21S8pTlp0s2AWk5G5oSQ+p84Fns5OqZB2t4B40=; b=dKe3WVGpuVgKDvTcF8DMDWyhQLwxBOHeysuLKie6X9v0eoYon0No5lfSwUsZczqbC/srCc 7MShM0vNAm2MrFrDvHarhhxeEpxqv9mGs/Sj7lEh/FFa8RnO43rVhEv6qrdplK7xVrqInF DawkDNc80S+X+bcK11S87d9AGEVZYEE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-eZ-S57SQPJGwXvgPZFdtag-1; Mon, 29 Jul 2024 12:21:58 -0400 X-MC-Unique: eZ-S57SQPJGwXvgPZFdtag-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF40C1955F3F; Mon, 29 Jul 2024 16:21:51 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.216]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AE8611955F68; Mon, 29 Jul 2024 16:21:45 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, 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-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Enzo Matsumiya Subject: [PATCH 13/24] cifs: Provide the capability to extract from ITER_FOLIOQ to RDMA SGEs Date: Mon, 29 Jul 2024 17:19:42 +0100 Message-ID: <20240729162002.3436763-14-dhowells@redhat.com> In-Reply-To: <20240729162002.3436763-1-dhowells@redhat.com> References: <20240729162002.3436763-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Stat-Signature: ty8z67xcng4xbd8764pqi5k8bacmb6ft X-Rspamd-Queue-Id: 9DA12C002C X-Rspamd-Server: rspam11 X-HE-Tag: 1722270123-794067 X-HE-Meta: U2FsdGVkX1/5jp6nvb1Oat8xjupxEmLO/wX4w0e3y1qKS6OgO3RkUZdvyb7SIUz5JnefASHTkutdbvKlJekco4tVoPNn/TaAFNz3O9P1mKSdN3ppQH5it4ToM7j9d3+RcfJODywPtlB04nEt9sUYAxDha5eC4qJc33gBn0RxpbT9UWQcHNGwXXRfKJIEdorA7lHF8XJWJmcvdL+oN6DHysUBG53FNP9nLjMuyBYJYfGlkmaEIXvkfGTPwllw1EaF9RrPCHqooxM2ur2E+1fyR3BWqfYD1e271VV2pJ3hnnXKtIgH0BCw9dmSnGR+lf8CkT1TZO2YdsA9zW4Vhp6IwJCdP9sdpc2sEQpgo73Ig9qb8qMqzspfK4fT3lGlD2dKXyVXc0V9EiklO3Xm0rgiNSRlegoDzTvzJwRZT91KPwArzndjeTmSIefdRdDIpG8oQxXioCAsSLiv2Rd9nnidygu+x4P+1dnda7df1rJcnyucFys8jftk4eX42aqtuynT8tP9ZrzGvP+/c9BuFWOsiFQMQxPrs2kPQEv3cSpXaSoUs+NcbqYbCxO1Am4HGXFisC0BWBNQZ8fycW4KworD0eCjfzU8YwGOgDspNhygMEeOBlQAEsly+/b3lIHjmfSTfcAltGEQoVDI8X29tr7EU6HNy3kIlwrsIhm/twCappZHqywaXWGN5QVcCtmbLXRDRWyhhq/Y20+hnoN8tjpxEhEVzhABkqak2tzfv8NASogStV8mUc21YU+WkiWW9Hw+8wzJv9OBpr7Tw15cul3GWCdR5FFTb+2rCu1qADk+crPG3o6oNJLXRTAzYgL2grZTq4bP0W9LoVGK7yFED64tcBkL/7M8g6spTMpGAa8V/twMNK3HWjWSIbXiWi+Y/HfjPvgKihDBX2XqZykqUfCAD+0AJwXb/rCqaMc3hKUST9ssgGcfXk44gmZyngm2wrIwweDQf9+5ceDqOM706tZ 4jt1Qm36 kLD1pBm+kxcq7Ao71ukw4/JVGrZlBa4yFDrgbPfWCf6O7vESxntdqlpiqwp9UnJ2IMQrKeof9hfU47hC+DaZH7H4QQ0MywWgpa6a11RTE5fa67kLTfQztMAJG5u9He6FykURUhdMrN043FB/BDQXGv+oq5N51WA/3wE9T/95M9IHKHCv6HkuqC+lCBWHCHJOjbARlKxKpqiM5o9FbdWkAZai7oHMAtFW01gWYAEdYCFszFzzrm1+ZrpHlNDhU0RcTYi7X2yF4m7iSlt3yJuF57c+0SS4IsYM6H5JK+YVyWKLo7gSPlahCuxBxtoBC0t6Fv8btH36QqUqRYZ+ijaGdHZqSKp1LEqaNXplO0bqcAtF7OLVMvOxNzdwYec3wbXsiLnY2xx2XtWBzrewDPIJ8SrhldCuoYog3Fy8taXc4UIYdfrcy0x+zJrWveMR7MFFXbO7IWjJpGws9Fz7hWuyIhBS2DVKkIAEOmm8EmWZfQoKbBi055wxU9aF3BJCnm+DdphZCZDyUI0r/u/gyGQip7TCAzkaX1gM0H+cTfM1C6MVrk6ozQDCWWmVmIapJtlu200JsriXAro1I0dc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Make smb_extract_iter_to_rdma() extract page fragments from an ITER_FOLIOQ iterator into RDMA SGEs. Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Tom Talpey cc: Enzo Matsumiya cc: linux-cifs@vger.kernel.org --- fs/smb/client/smbdirect.c | 71 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c index d74e829de51c..52acead63d9d 100644 --- a/fs/smb/client/smbdirect.c +++ b/fs/smb/client/smbdirect.c @@ -6,6 +6,7 @@ */ #include #include +#include #include "smbdirect.h" #include "cifs_debug.h" #include "cifsproto.h" @@ -2463,6 +2464,8 @@ static ssize_t smb_extract_bvec_to_rdma(struct iov_iter *iter, start = 0; } + if (ret > 0) + iov_iter_advance(iter, ret); return ret; } @@ -2519,6 +2522,65 @@ static ssize_t smb_extract_kvec_to_rdma(struct iov_iter *iter, start = 0; } + if (ret > 0) + iov_iter_advance(iter, ret); + return ret; +} + +/* + * Extract folio fragments from a FOLIOQ-class iterator and add them to an RDMA + * list. The folios are not pinned. + */ +static ssize_t smb_extract_folioq_to_rdma(struct iov_iter *iter, + struct smb_extract_to_rdma *rdma, + ssize_t maxsize) +{ + const struct folio_queue *folioq = iter->folioq; + unsigned int slot = iter->folioq_slot; + ssize_t ret = 0; + size_t offset = iter->iov_offset; + + BUG_ON(!folioq); + + if (slot >= folioq_nr_slots(folioq)) { + folioq = folioq->next; + if (WARN_ON_ONCE(!folioq)) + return -EIO; + slot = 0; + } + + do { + struct folio *folio = folioq_folio(folioq, slot); + size_t fsize = folioq_folio_size(folioq, slot); + + if (offset < fsize) { + size_t part = umin(maxsize - ret, fsize - offset); + + if (!smb_set_sge(rdma, folio_page(folio, 0), offset, part)) + return -EIO; + + offset += part; + ret += part; + } + + if (offset >= fsize) { + offset = 0; + slot++; + if (slot >= folioq_nr_slots(folioq)) { + if (!folioq->next) { + WARN_ON_ONCE(ret < iter->count); + break; + } + folioq = folioq->next; + slot = 0; + } + } + } while (rdma->nr_sge < rdma->max_sge || maxsize > 0); + + iter->folioq = folioq; + iter->folioq_slot = slot; + iter->iov_offset = offset; + iter->count -= ret; return ret; } @@ -2563,6 +2625,8 @@ static ssize_t smb_extract_xarray_to_rdma(struct iov_iter *iter, } rcu_read_unlock(); + if (ret > 0) + iov_iter_advance(iter, ret); return ret; } @@ -2590,6 +2654,9 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len, case ITER_KVEC: ret = smb_extract_kvec_to_rdma(iter, rdma, len); break; + case ITER_FOLIOQ: + ret = smb_extract_folioq_to_rdma(iter, rdma, len); + break; case ITER_XARRAY: ret = smb_extract_xarray_to_rdma(iter, rdma, len); break; @@ -2598,9 +2665,7 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len, return -EIO; } - if (ret > 0) { - iov_iter_advance(iter, ret); - } else if (ret < 0) { + if (ret < 0) { while (rdma->nr_sge > before) { struct ib_sge *sge = &rdma->sge[rdma->nr_sge--];