From patchwork Thu Oct 24 17:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849474 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E9871FBF58 for ; Thu, 24 Oct 2024 17:21:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790492; cv=none; b=MXSDZOugqL7nxZ5qP2iHGzZ4yZ5tZzH/JlNVVBmV7MCKBit32eVaN/B27FZktBHB4D2+gbHXiotqK6XaGeUajjtmeQ1TPCsq524OxHtBD6r7FSiSwAdJnFiGQ1/K8PpC8G5izypRIoN8PC5Zgjo4tAxw+1OjkfAinEIbZNoMoGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790492; c=relaxed/simple; bh=F+ufyoJY3zog6/A38PhsTPOv6+lHASYgyIXe4rfC0b8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T2TKxZbK1zPiHLPtH0x5iPgaeQAYOLX73hz53SugcR8EfMBxSKcHyx1ackafQYzFeT0uQUofHnPrKHRdN4sq2ZZbKla1BTtYnTh+S+8QS8xPrzIf5QCwxlYmaiIw/E1Oeh7nDVrlRL3yXiOcEOSBMYNmNN5hFuv/3elo8KQfYH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DBxZ4t25; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DBxZ4t25" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6e2e508bd28so10560937b3.2 for ; Thu, 24 Oct 2024 10:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790489; x=1730395289; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oCHdLUJmpgTM9PmoKNfhcDScWcGzgJ/xcsnMnuzV9+8=; b=DBxZ4t255niD4hUl+gqPpB7ldDzTarW1bmBmUSw0zsBW1wH+yCxEbVT6B2yQhcuVzP 7tF6Bswhi6AU8NbhiF10nts4aKBToldqCTzRWIE0y6knsH2VvJduwuJAjqrK4uNSwEsc v8lj8Wfr00V+7P4smhQEKxXmKZzE5Z1PcQUr6zfo00wdmEK7QHjJVS2ofcsfSxwV75a7 7hFx0HwrFBB9zAIbz8x8ML2u3w+JRDmdPaW43aDPg3bZp34DqNHPc4n4lRNROeI/Xmj9 6bleIsXkaiYF0v8TO1B/ASInzyoXnGDeqxA7sOqm54AW7/gtflvQtg4Mlwx9Fhv+5z6K ag/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790489; x=1730395289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oCHdLUJmpgTM9PmoKNfhcDScWcGzgJ/xcsnMnuzV9+8=; b=ArftLqXfSFlGV0j7YTohT03a9ZD/MkvUesZ//wbW7Q2Xy5AoctDY7FIoshYJtp/Xq/ /caiLvGWWG8QVC5wXNkzotqAzuTDCcvNMlzDX8JgBFzCbd7oM+dXD7lJXBAPl3qbDUOS F+Tdbqknll7eBmjBSsDUOQ/zTDeykY8Mtv5Krz1hNd38EZAghdk1g69XKULERz9M9P97 3htnjlOJNVLOj0mVEwtx+lHTkktkWdf/t+aSO/Fz7939ltRT+lQOlh84A07CAs/6PePZ eCCLDtGkCI1+cZk131Lww/IysGos1pWqQO+r29DzC8GihMvoTODfl5hSXr7IlUi8yfbP 8pKA== X-Forwarded-Encrypted: i=1; AJvYcCWmOh9dowE2cwiEDDw4POvHryoBmuhxnyqnjf8s28n1xt+bnoAkfkls3hBoMyP0PgYj6RR+PefwLN7L+ZK+@vger.kernel.org X-Gm-Message-State: AOJu0Yx3EU0RRocMTU/cIhGc0BWdXmP6b3062SV7n2cCPPtkcvDci3YZ Jj1YuqdH/NTt90hMJSfNRDSN505anllyEGUcveuNx+MpI0IIriyhpJKUrQ== X-Google-Smtp-Source: AGHT+IG5t06mid9hu/V94sx0Poiw8Ijrpy/+t789I8rCDSrKoZzyIh9AZq2W4/yi/di/V9/kmJmczA== X-Received: by 2002:a05:690c:9a88:b0:6e6:45b:5d0 with SMTP id 00721157ae682-6e86635006fmr29018277b3.45.1729790487460; Thu, 24 Oct 2024 10:21:27 -0700 (PDT) Received: from localhost (fwdproxy-nha-002.fbsv.net. [2a03:2880:25ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5a6199esm20631967b3.46.2024.10.24.10.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:27 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 01/13] fuse: support folios in struct fuse_args_pages and fuse_copy_pages() Date: Thu, 24 Oct 2024 10:17:57 -0700 Message-ID: <20241024171809.3142801-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This adds support in struct fuse_args_pages and fuse_copy_pages() for using folios instead of pages for transferring data. Both folios and pages must be supported right now in struct fuse_args_pages and fuse_copy_pages() until all request types have been converted to use folios. Once all have been converted, then struct fuse_args_pages and fuse_copy_pages() will only support folios. Right now in fuse, all folios are one page (large folios are not yet supported). As such, copying folio->page is sufficient for copying the entire folio in fuse_copy_pages(). No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 40 ++++++++++++++++++++++++++++++++-------- fs/fuse/fuse_i.h | 22 +++++++++++++++++++--- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 5edad55750b0..9f860bd655a4 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1028,17 +1028,41 @@ static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, struct fuse_req *req = cs->req; struct fuse_args_pages *ap = container_of(req->args, typeof(*ap), args); + if (ap->uses_folios) { + for (i = 0; i < ap->num_folios && (nbytes || zeroing); i++) { + int err; + unsigned int offset = ap->folio_descs[i].offset; + unsigned int count = min(nbytes, ap->folio_descs[i].length); + struct page *orig, *pagep; - for (i = 0; i < ap->num_pages && (nbytes || zeroing); i++) { - int err; - unsigned int offset = ap->descs[i].offset; - unsigned int count = min(nbytes, ap->descs[i].length); + orig = pagep = &ap->folios[i]->page; - err = fuse_copy_page(cs, &ap->pages[i], offset, count, zeroing); - if (err) - return err; + err = fuse_copy_page(cs, &pagep, offset, count, zeroing); + if (err) + return err; + + nbytes -= count; + + /* + * fuse_copy_page may have moved a page from a pipe + * instead of copying into our given page, so update + * the folios if it was replaced. + */ + if (pagep != orig) + ap->folios[i] = page_folio(pagep); + } + } else { + for (i = 0; i < ap->num_pages && (nbytes || zeroing); i++) { + int err; + unsigned int offset = ap->descs[i].offset; + unsigned int count = min(nbytes, ap->descs[i].length); - nbytes -= count; + err = fuse_copy_page(cs, &ap->pages[i], offset, count, zeroing); + if (err) + return err; + + nbytes -= count; + } } return 0; } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 671daa4d07ad..24a3da8400d1 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -291,6 +291,12 @@ struct fuse_page_desc { unsigned int offset; }; +/** FUSE folio descriptor */ +struct fuse_folio_desc { + unsigned int length; + unsigned int offset; +}; + struct fuse_args { uint64_t nodeid; uint32_t opcode; @@ -319,9 +325,19 @@ struct fuse_args { struct fuse_args_pages { struct fuse_args args; - struct page **pages; - struct fuse_page_desc *descs; - unsigned int num_pages; + union { + struct { + struct page **pages; + struct fuse_page_desc *descs; + unsigned int num_pages; + }; + struct { + struct folio **folios; + struct fuse_folio_desc *folio_descs; + unsigned int num_folios; + }; + }; + bool uses_folios; }; struct fuse_release_args { From patchwork Thu Oct 24 17:17:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849472 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AE341FAC51 for ; Thu, 24 Oct 2024 17:21:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790491; cv=none; b=QFPYIpzj1l+6WUoPs1I8muaQTsl7+YJpzuFHB9qSksFU6n3fA2UVCuRAitbdJok947SkaOAdm0QCF4nccd9OGzu2Op5BR0IPQYzCwZF/mUQr+77oPS1PHOxjsRPbetJgl+Gx6rLWSL/7nuEZxZU5Kdmat1oijXa0AbLi8u7ndl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790491; c=relaxed/simple; bh=aCBS0E8uI/g2bfKdlxec+OEaLI9quKfamNOOdj4G1rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hZTNFXMNhDdMcOcu6lywD9rv0s1cQgFkijDjQr2dRsB7DvO8FTTZHarDLwIhYdsci3E9zh220iKHT363DHjkCSQmUh4vHvow521xNxuz49rmIo8Y6Cv/7uAIROUbelJoFKuQv9bnSPYezpFzsoq+hWBWCvivv459ou2PFhQzt8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XJkbt4ou; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XJkbt4ou" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e290d48d3f7so1281954276.3 for ; Thu, 24 Oct 2024 10:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790488; x=1730395288; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wgB3T3HXxfx+orA1DK8znN5gB3bUWbsMmvZklQRTvig=; b=XJkbt4oudLqt5pMbnHnKzkzsgR0e80DwwMeP9aXONcCLCKXNoO5RH+STvEMA2+DN+2 5iW6VEztKajgl3gUHWyqqru6IqULg4gNeQB5U19mY0R1OjNM89Qu4FB84+f3kJkw2H/M 7gIunU4jcmZeu6NU9Th1ebRwylcH0uSMe2DsDvAt8PIXt5+1VU+06dihrOGLYd5O01s4 avbmOBLalvQ7KxtxIlGUjJYrPiuNUPDPjBs6sBucVeVsWsrPJwNFfWn6XU5jA4fvWKx5 v0Jettpx2+dBfWitK8nrvYEE0kJKVhXYVwgr+AgvPF/2wmvGG3cJs9ykHU9aR7QKgZcw ijPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790488; x=1730395288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wgB3T3HXxfx+orA1DK8znN5gB3bUWbsMmvZklQRTvig=; b=MMiFRl52jQKKjVAmN0ADsW2hTxQjEuIMiEsvoLRTIbR4vsSnZiKFvIgIs0JcYJutJ+ LkuxUk9op+bMjjx9OXLnl3oHrlNF93VE0w+bDcz3FSWepi6o2IGe6UjqPTcfRPuVes21 3Z9cy9Li0CeL3v9OVD2fzI/Extu2stAiByqBg04Rin885wwg/dNk8gdhaiDV7+ZwqV+F XMcjRDL91+j1JPwv7Wt8FIjMkfcfBzhV9ADQCfCPdhJXYeaEjfvYdd7jJs08W7Pkn0T4 /PkY0pY45oQadY9n35j/GjHKntrfmmPKsuxslU3wUF05kQXS6KXbZzXU7nDPo03STHHs hNzw== X-Forwarded-Encrypted: i=1; AJvYcCUoamDJZKlXAZZ0I0yMjYakZLYuN3aD4QMBkET392nVdEPDtg0NChQRCzaHUqM06OvV3Tm3Ln7k/JETwrwH@vger.kernel.org X-Gm-Message-State: AOJu0Yy6kW2dWcrBtSukl7haavjh7liJ+nnaDPXWa/77nXt7A1VVMVD+ Xc9ask4dzTdsUPzBxgghaI5gBw/9DdYrXytr/BAKIku784JpqKwIdhztnA== X-Google-Smtp-Source: AGHT+IGU1hbb/G4Em2EPTA0d7haR3Xley8TW+mtQ9hJCOlR5aHqKlurrwRQEdw7Mh7jKUbPRnmHK0g== X-Received: by 2002:a05:6902:150f:b0:e2b:9ae5:5bf7 with SMTP id 3f1490d57ef6-e2e3a634fd9mr8073794276.19.1729790488166; Thu, 24 Oct 2024 10:21:28 -0700 (PDT) Received: from localhost (fwdproxy-nha-010.fbsv.net. [2a03:2880:25ff:a::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2bdcaebe52sm1933585276.41.2024.10.24.10.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:27 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 02/13] fuse: add support in virtio for requests using folios Date: Thu, 24 Oct 2024 10:17:58 -0700 Message-ID: <20241024171809.3142801-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Until all requests have been converted to use folios instead of pages, virtio will need to support both types. Once all requests have been converted, then virtio will support just folios. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/virtio_fs.c | 87 +++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 31 deletions(-) diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index f68527891929..9f0d98cc20d3 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -766,6 +766,7 @@ static void virtio_fs_request_complete(struct fuse_req *req, struct fuse_args_pages *ap; unsigned int len, i, thislen; struct page *page; + struct folio *folio; /* * TODO verify that server properly follows FUSE protocol @@ -777,15 +778,29 @@ static void virtio_fs_request_complete(struct fuse_req *req, if (args->out_pages && args->page_zeroing) { len = args->out_args[args->out_numargs - 1].size; ap = container_of(args, typeof(*ap), args); - for (i = 0; i < ap->num_pages; i++) { - thislen = ap->descs[i].length; - if (len < thislen) { - WARN_ON(ap->descs[i].offset); - page = ap->pages[i]; - zero_user_segment(page, len, thislen); - len = 0; - } else { - len -= thislen; + if (ap->uses_folios) { + for (i = 0; i < ap->num_folios; i++) { + thislen = ap->folio_descs[i].length; + if (len < thislen) { + WARN_ON(ap->folio_descs[i].offset); + folio = ap->folios[i]; + folio_zero_segment(folio, len, thislen); + len = 0; + } else { + len -= thislen; + } + } + } else { + for (i = 0; i < ap->num_pages; i++) { + thislen = ap->descs[i].length; + if (len < thislen) { + WARN_ON(ap->descs[i].offset); + page = ap->pages[i]; + zero_user_segment(page, len, thislen); + len = 0; + } else { + len -= thislen; + } } } } @@ -1272,16 +1287,22 @@ static void virtio_fs_send_interrupt(struct fuse_iqueue *fiq, struct fuse_req *r } /* Count number of scatter-gather elements required */ -static unsigned int sg_count_fuse_pages(struct fuse_page_desc *page_descs, - unsigned int num_pages, - unsigned int total_len) +static unsigned int sg_count_fuse_pages(struct fuse_args_pages *ap, + unsigned int total_len) { unsigned int i; unsigned int this_len; - for (i = 0; i < num_pages && total_len; i++) { - this_len = min(page_descs[i].length, total_len); - total_len -= this_len; + if (ap->uses_folios) { + for (i = 0; i < ap->num_folios && total_len; i++) { + this_len = min(ap->folio_descs[i].length, total_len); + total_len -= this_len; + } + } else { + for (i = 0; i < ap->num_pages && total_len; i++) { + this_len = min(ap->descs[i].length, total_len); + total_len -= this_len; + } } return i; @@ -1299,8 +1320,7 @@ static unsigned int sg_count_fuse_req(struct fuse_req *req) if (args->in_pages) { size = args->in_args[args->in_numargs - 1].size; - total_sgs += sg_count_fuse_pages(ap->descs, ap->num_pages, - size); + total_sgs += sg_count_fuse_pages(ap, size); } if (!test_bit(FR_ISREPLY, &req->flags)) @@ -1313,28 +1333,35 @@ static unsigned int sg_count_fuse_req(struct fuse_req *req) if (args->out_pages) { size = args->out_args[args->out_numargs - 1].size; - total_sgs += sg_count_fuse_pages(ap->descs, ap->num_pages, - size); + total_sgs += sg_count_fuse_pages(ap, size); } return total_sgs; } -/* Add pages to scatter-gather list and return number of elements used */ +/* Add pages/folios to scatter-gather list and return number of elements used */ static unsigned int sg_init_fuse_pages(struct scatterlist *sg, - struct page **pages, - struct fuse_page_desc *page_descs, - unsigned int num_pages, + struct fuse_args_pages *ap, unsigned int total_len) { unsigned int i; unsigned int this_len; - for (i = 0; i < num_pages && total_len; i++) { - sg_init_table(&sg[i], 1); - this_len = min(page_descs[i].length, total_len); - sg_set_page(&sg[i], pages[i], this_len, page_descs[i].offset); - total_len -= this_len; + if (ap->uses_folios) { + for (i = 0; i < ap->num_folios && total_len; i++) { + sg_init_table(&sg[i], 1); + this_len = min(ap->folio_descs[i].length, total_len); + sg_set_folio(&sg[i], ap->folios[i], this_len, + ap->folio_descs[i].offset); + total_len -= this_len; + } + } else { + for (i = 0; i < ap->num_pages && total_len; i++) { + sg_init_table(&sg[i], 1); + this_len = min(ap->descs[i].length, total_len); + sg_set_page(&sg[i], ap->pages[i], this_len, ap->descs[i].offset); + total_len -= this_len; + } } return i; @@ -1358,9 +1385,7 @@ static unsigned int sg_init_fuse_args(struct scatterlist *sg, sg_init_one(&sg[total_sgs++], argbuf, len); if (argpages) - total_sgs += sg_init_fuse_pages(&sg[total_sgs], - ap->pages, ap->descs, - ap->num_pages, + total_sgs += sg_init_fuse_pages(&sg[total_sgs], ap, args[numargs - 1].size); if (len_used) From patchwork Thu Oct 24 17:17:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849473 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 149721FBF4F for ; Thu, 24 Oct 2024 17:21:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790492; cv=none; b=uIiaBUk2Hkke1pBzRl6vBTvz7eSr6ydzuQAQ7ObMKasbuGcOaBmMBQY8Zj4UjBdI22QiR/wLcwfp7I2DwW0g/Bp6b/HCPtwDGx7jS6mUAVOS+mMzqdDLaxoARd+W4bEZ6wp4xArj7tNuGBh4dreSW5jUkxr2zuV56aMYB9xdCbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790492; c=relaxed/simple; bh=ioEojwyjzo508/cf3Oxu/mg0XMx+FgQ2Ivxxr+uviBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I8Kglr+EsKMCN0Li63MVOGpkEEQCcPN/M8LuUpl5y8tfFiKOk4Dn5dMEkhZH1+rYBUGXCJiV6jNeVcvw/MfBr0RvRNvUI28a+ntSWVZiPhvxmTLrq04qUJB6Qc+ndH5cZ3nx4/Hv3gZqi7FqaYaDfEMlOV7Jhpk8NuJXh6YX200= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fenF9Tje; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fenF9Tje" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e28fd83b5bbso1322214276.0 for ; Thu, 24 Oct 2024 10:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790489; x=1730395289; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+pLChAthDKHO8hW8O7IV3CdRgH7581sXq9YBpmfyJv4=; b=fenF9TjeEh+lBiYRccStK1FOlP8uSQEIR9rnMtk8ZAiNh7NMAMAjcpzjeHxw0Jj0OG tIB2+qUMuJizPxHmCSO/cL/R+8K9w9LWUreL8U9kHFxnnAS6+PS8QG3r631asKNmQWoS S/jZaVtwrVFx43wJZhzcKExh2sJufm8WNJYUvZw0HFxBb7QY1b6g9mDFaW86qJzh/W2Z 89aHRRnwT03sdFzUuxu7ALNJKkXSjmiyRK5Ipg2DyKcytE8GV4EhNBPSa9NGve9hu7hG 4WvU2tqL/k+BS8uoekcDkI8ZEBGgzB6fnCmEIkGriAOsyexqFtMjD2Z6maEf0ntp2BBS YF5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790489; x=1730395289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+pLChAthDKHO8hW8O7IV3CdRgH7581sXq9YBpmfyJv4=; b=sUsUpJh2tVVPxUhTHIdBXYe75H+plijwjlrKj0EEuyqLyLB/wIVjbFmZEFfFPeAvD6 IFZNrHaS8OR7qCRWq3LEeC0YPIf3SGqjQSRBbQ/CHAlcdILUSSIMVDgNLUwr2pHt1T6T ePdYMXS+6FeIwiOxXC1trJ27I1ALfbR2Ow6K5cZU/aXYut77sj6ssJqbcpzbUfyaZsCx 0Fa9uO9rzd98fuqBjbjrn2FLOCU/UGk7BlXqr0M7S09KcML0vmT6cda3IF2sItfZpI0a ETSnwsWoyhL6OG3kolqMrXkL15qGGYeiJ3PHVB9ImMT63FG3hpTpub34Z1ihvCNroB6L mkHg== X-Forwarded-Encrypted: i=1; AJvYcCWX+AwaWyCbmYeKaWbyYHyWT92+Q08aX7j1Mxbr53qYPb5Fp+BKscV3QGmSE5q6fD1rS/ZTwajUPN07lW57@vger.kernel.org X-Gm-Message-State: AOJu0Yw051uB6PzGjMko+SEyqpgzgsGnhHN56W8fwBsWTRxL6ZbBRfEM XfosxFrkLKgyoohaUU/36vzxGsqK78FEfgt+M8Vmcaxfc642IgtX X-Google-Smtp-Source: AGHT+IFkQ37vFL7A9ND5sRC6RQzQYgNiqHBRgmds9gNUEC3jO9cEF4tUU8e+yoNQcMeUnsy2+MbTBw== X-Received: by 2002:a05:690c:660f:b0:6e2:c5d:4edf with SMTP id 00721157ae682-6e7f0dc17e6mr80327697b3.9.1729790489001; Thu, 24 Oct 2024 10:21:29 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5ccb5c3sm20343277b3.102.2024.10.24.10.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:28 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 03/13] fuse: convert cuse to use folios Date: Thu, 24 Oct 2024 10:17:59 -0700 Message-ID: <20241024171809.3142801-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert cuse requests to use a folio instead of a page. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/cuse.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index 0b2da7b7e2ad..eed78e303139 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c @@ -303,8 +303,8 @@ struct cuse_init_args { struct fuse_args_pages ap; struct cuse_init_in in; struct cuse_init_out out; - struct page *page; - struct fuse_page_desc desc; + struct folio *folio; + struct fuse_folio_desc desc; }; /** @@ -326,7 +326,7 @@ static void cuse_process_init_reply(struct fuse_mount *fm, struct fuse_args_pages *ap = &ia->ap; struct cuse_conn *cc = fc_to_cc(fc), *pos; struct cuse_init_out *arg = &ia->out; - struct page *page = ap->pages[0]; + struct folio *folio = ap->folios[0]; struct cuse_devinfo devinfo = { }; struct device *dev; struct cdev *cdev; @@ -343,7 +343,7 @@ static void cuse_process_init_reply(struct fuse_mount *fm, /* parse init reply */ cc->unrestricted_ioctl = arg->flags & CUSE_UNRESTRICTED_IOCTL; - rc = cuse_parse_devinfo(page_address(page), ap->args.out_args[1].size, + rc = cuse_parse_devinfo(folio_address(folio), ap->args.out_args[1].size, &devinfo); if (rc) goto err; @@ -411,7 +411,7 @@ static void cuse_process_init_reply(struct fuse_mount *fm, kobject_uevent(&dev->kobj, KOBJ_ADD); out: kfree(ia); - __free_page(page); + folio_put(folio); return; err_cdev: @@ -429,7 +429,7 @@ static void cuse_process_init_reply(struct fuse_mount *fm, static int cuse_send_init(struct cuse_conn *cc) { int rc; - struct page *page; + struct folio *folio; struct fuse_mount *fm = &cc->fm; struct cuse_init_args *ia; struct fuse_args_pages *ap; @@ -437,13 +437,14 @@ static int cuse_send_init(struct cuse_conn *cc) BUILD_BUG_ON(CUSE_INIT_INFO_MAX > PAGE_SIZE); rc = -ENOMEM; - page = alloc_page(GFP_KERNEL | __GFP_ZERO); - if (!page) + + folio = folio_alloc(GFP_KERNEL | __GFP_ZERO, 0); + if (!folio) goto err; ia = kzalloc(sizeof(*ia), GFP_KERNEL); if (!ia) - goto err_free_page; + goto err_free_folio; ap = &ia->ap; ia->in.major = FUSE_KERNEL_VERSION; @@ -459,18 +460,19 @@ static int cuse_send_init(struct cuse_conn *cc) ap->args.out_args[1].size = CUSE_INIT_INFO_MAX; ap->args.out_argvar = true; ap->args.out_pages = true; - ap->num_pages = 1; - ap->pages = &ia->page; - ap->descs = &ia->desc; - ia->page = page; + ap->uses_folios = true; + ap->num_folios = 1; + ap->folios = &ia->folio; + ap->folio_descs = &ia->desc; + ia->folio = folio; ia->desc.length = ap->args.out_args[1].size; ap->args.end = cuse_process_init_reply; rc = fuse_simple_background(fm, &ap->args, GFP_KERNEL); if (rc) { kfree(ia); -err_free_page: - __free_page(page); +err_free_folio: + folio_put(folio); } err: return rc; From patchwork Thu Oct 24 17:18:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849475 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6C831FBF7A for ; Thu, 24 Oct 2024 17:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790493; cv=none; b=E86jEbzMA3GxD9KiWOgVDARkvpPl/qcKUgeMbr6gweX6pEWHx4Q2GSReNapDwG3jRRoyiWpkdypgbb/sRG07yixCilfve72VTfCraZglQLJsvFRFN7hR5qltl1D0EK2u9VEHPc0Kk7lW3WUvj7lLiHmZm4WgEOoXZMHpxUL6txg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790493; c=relaxed/simple; bh=C+ZFmBhkWJBEUf+QVYPJlux2aWYUCRl3Cvoa6yedOko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tF40f1GSjMJFK4aJY4jMuZlD0e3ZPps7Lll/fUnZfV7xXUHufbLQJPbN69q6w10VuanTJSrWaOh8yOKiuzmRI98O5LodI08knqnrRHCeDtfyDYaO3YRCYDbTQ47f0Ql/YlegUbd3+/2f0M/6hyaeu6YulfIG3LogcG9fagOMUFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F5goB1oT; arc=none smtp.client-ip=209.85.219.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F5goB1oT" Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e290d48d3f7so1281976276.3 for ; Thu, 24 Oct 2024 10:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790490; x=1730395290; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QLh99GkXyq+kP9pQTLVSJdqNoY2DuPZPcJCXbuMVIms=; b=F5goB1oTrPwkBOWWdjP1eU0xadWfHS3Y3O/OtDwFZm5JRzAhv1FtRs4X3Ba3vbvyDi SAbz0k5ssI73FGZ/OUmOsIlTKAL6DcPHLWZw4tqNS7AZdxIDyndB7Sevkqs5+vG3KW6N nBWpNUA92BI0cwFAJiz9Nt14d1AeHKSRfRWKpanS//83MTKIKA2FiuZp1VgqX+gEOIGI K+EXrLiJ7yfogS02CZGRdWBv9d/bw/BCkceV0NGF32k0vsnKFN2ZH3Fd/Y6QQpzpFQ+i WoGt0KUcXGMizars2GHgar03BuWHR43k8pglEsnV8H6QBkBV7+8wkhzlApwfGU88IEfe RF9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790490; x=1730395290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QLh99GkXyq+kP9pQTLVSJdqNoY2DuPZPcJCXbuMVIms=; b=kDU3ad7cZtriItXstK6kj68ZuVg62MccBTjqSeqBeLh4k93jYNWdbQLMVCwXrT+XIH T99MI8rnfmOAQXE60AFYlyllE5TnMSJt2JlVP77n2G+YeYdlxgXD/WEMlez9o0ijboSx y16lanmUjbEXe5NOSsorU/RhceLgxwUB2abbrIdyox0uqMOS4ixRfM1SolLyCnSLbHek N6E7wBb7SA7LQlCsYnFa+wa0+yy8DG+cemP+FdvL+pF7MZupRGKe+CowqL0ZxOpHPAC2 uODRg5BLvZpiFifXEsU/mLj6vQ8OnauhPlehuNeQJiao41wV5qlbJ7JxLglxq7I9JIti kpcQ== X-Forwarded-Encrypted: i=1; AJvYcCV2IsMEyWdO+l+PWmvtI/iWgGjl9rJMJYMKM8nsD2ARJARZEK9fG8p2A8ppIAi+pbGgERlfL+Blc//mizy7@vger.kernel.org X-Gm-Message-State: AOJu0YyBSlConI6B/ULI3H+XFFgC4NA0P/J16+OXlGFwBaL0sIgmsyQp PmWEJXfs2MPbZ7oBTmI5aGwlpN00+UGeebpCLWQa9eOGwwFT4/ca X-Google-Smtp-Source: AGHT+IG97x0F4qsnZh34R0UhnmjM6sQQRZfbfidA46jeZ0OezPZWwmdfpdj8wWkwxzP7bO/VjZn82g== X-Received: by 2002:a05:6902:2088:b0:e29:29b0:2b2a with SMTP id 3f1490d57ef6-e2e3a6e4ed4mr7767533276.51.1729790489794; Thu, 24 Oct 2024 10:21:29 -0700 (PDT) Received: from localhost (fwdproxy-nha-014.fbsv.net. [2a03:2880:25ff:e::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2bdc9926c0sm2047881276.17.2024.10.24.10.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:29 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 04/13] fuse: convert readlink to use folios Date: Thu, 24 Oct 2024 10:18:00 -0700 Message-ID: <20241024171809.3142801-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert readlink requests to use a folio instead of a page. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/dir.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 54104dd48af7..a08c532068d0 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1585,14 +1585,15 @@ static int fuse_permission(struct mnt_idmap *idmap, return err; } -static int fuse_readlink_page(struct inode *inode, struct page *page) +static int fuse_readlink_page(struct inode *inode, struct folio *folio) { struct fuse_mount *fm = get_fuse_mount(inode); - struct fuse_page_desc desc = { .length = PAGE_SIZE - 1 }; + struct fuse_folio_desc desc = { .length = PAGE_SIZE - 1 }; struct fuse_args_pages ap = { - .num_pages = 1, - .pages = &page, - .descs = &desc, + .uses_folios = true, + .num_folios = 1, + .folios = &folio, + .folio_descs = &desc, }; char *link; ssize_t res; @@ -1614,7 +1615,7 @@ static int fuse_readlink_page(struct inode *inode, struct page *page) if (WARN_ON(res >= PAGE_SIZE)) return -EIO; - link = page_address(page); + link = folio_address(folio); link[res] = '\0'; return 0; @@ -1624,7 +1625,7 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *callback) { struct fuse_conn *fc = get_fuse_conn(inode); - struct page *page; + struct folio *folio; int err; err = -EIO; @@ -1638,20 +1639,20 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode, if (!dentry) goto out_err; - page = alloc_page(GFP_KERNEL); + folio = folio_alloc(GFP_KERNEL, 0); err = -ENOMEM; - if (!page) + if (!folio) goto out_err; - err = fuse_readlink_page(inode, page); + err = fuse_readlink_page(inode, folio); if (err) { - __free_page(page); + folio_put(folio); goto out_err; } - set_delayed_call(callback, page_put_link, page); + set_delayed_call(callback, page_put_link, &folio->page); - return page_address(page); + return folio_address(folio); out_err: return ERR_PTR(err); @@ -2231,7 +2232,7 @@ void fuse_init_dir(struct inode *inode) static int fuse_symlink_read_folio(struct file *null, struct folio *folio) { - int err = fuse_readlink_page(folio->mapping->host, &folio->page); + int err = fuse_readlink_page(folio->mapping->host, folio); if (!err) folio_mark_uptodate(folio); From patchwork Thu Oct 24 17:18:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849476 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B85A71F76B4 for ; Thu, 24 Oct 2024 17:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790493; cv=none; b=pqQy+TO6I+HkdLt8TQNGkCTOU7lNOcYPohGgKP19GiZyZdSy1X7yAm0xSUENNL9Kdzvjf3Xzu5C7HRu0vKVLEmTltsheGyFzRcJdGqx6+h1c2AGi1QhdUnFuoyyF28Yq9dRuB6eftP4mp69bkYWdYkHXjx6fK/O0xgITqKmSJ0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790493; c=relaxed/simple; bh=mXnBpqKiRVmhwxcDZZR85Sp7SEzxNvCFukeXW0p4gvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d3kdVXrXnbc44E5skMblEj+Tzzt/3CZbPTYjX0LxWVuP48IaGne2E89m3IUG9ZZwBfUHKGtr4DuiXAT0EKZwhFa5txfVLEbWoVoeABk0F4qWnb/YNrZ2KFk8eBPA/4/qXNMWE1mFvZGqEQF4pc0IKn8XDarbdCjchR4zE6l4Bp0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IeFj0SKx; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IeFj0SKx" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e290554afb4so1411534276.0 for ; Thu, 24 Oct 2024 10:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790490; x=1730395290; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sc/+LRnlXGharux7jo9tP8eHIQUBzqZeR7LIDCREooQ=; b=IeFj0SKxWZKBl1GNwfi+2qhrc6o301sfXmVbtb/aorMiPI+nvY6PlHaEokC92e8xxr Lg0aHk7SVf3kVxXLE0Jomg1gTI0laZdwk/wZviYN5oY7ULHrn5SxMSwoMuMlk/DsN9/w KuJBY9Y4StTteB7+CcmCN2Q/lG14RMQJygIDE4DktVQVs5idI/ZLkZWeSdvZzx12nl8T BzRQM+ysl3fFn+iyAZsUSI0SarSR+oFeyYLk3OJHkwFomWJKKmnSrfHrnC5VHSCnD37w dOCYUrKAyR1k/cs3gAIy0Q2jgKkaUmmepgxHfiN8B+CYWu1hqvRxoOY7p0dAYKjbqmYc IAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790490; x=1730395290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sc/+LRnlXGharux7jo9tP8eHIQUBzqZeR7LIDCREooQ=; b=ckObVFT+5HJJc7wFm1HGCmcXzqCVbKkHkTgilpSnVVejsDu4GSNZmU2h6K7SjJrB6O qSlmvbDTR9zUnwfBmXBIq1F3tg2y5CMCoGKlyz9GbRPueTOaTpMpj8u1e7S4F5LheM2Z CJcl4pNaf4wxe9rcs+YFzrllgZQnh7/vryxl29hkmFSalqFHUUIldRhypROT30GKOwkI dX1094HA3qNUXt7MSRVlm0KLkq++qxZ2VtUM6PqUePMcB3kvp5qiKeqKJcpwIIb6dycg Gryy4xgsXty5wf678T+REJQKXOB1VdlbEho/EOpYbbKUdHDeDfT3xirP5lio8z6Ow2uS GPLQ== X-Forwarded-Encrypted: i=1; AJvYcCWkbMlHkOlQjkkfuciASdigoijtoNIGsC27XpPpZ9GDiOB6efQCh10bERdw7SnYI1uCYzsqa4qKc4R9gJOO@vger.kernel.org X-Gm-Message-State: AOJu0YxTP2JQsJqWy+KJhDyTeYKElu1WHI6/crlxmwcL1Db/FLWk6TOJ umqOjHmq6pYhgiR7DZoGeb70STsVa4cWp3PK1yZgg6hBH0mpff+h X-Google-Smtp-Source: AGHT+IHrXmKF1FngBUoWBpHkT8ITWUJX4KUGji1xNOriD+fqIIkT21H6y8H16ted96zYAbHPaYXgOg== X-Received: by 2002:a05:6902:1692:b0:e29:33d1:a3b7 with SMTP id 3f1490d57ef6-e2e3a626666mr7472930276.1.1729790490472; Thu, 24 Oct 2024 10:21:30 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2e2e67c6dfsm1055626276.50.2024.10.24.10.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:30 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 05/13] fuse: convert readdir to use folios Date: Thu, 24 Oct 2024 10:18:01 -0700 Message-ID: <20241024171809.3142801-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert readdir requests to use a folio instead of a page. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/readdir.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index 0377b6dc24c8..fd0eff1b9f2d 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -331,24 +331,25 @@ static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx) { int plus; ssize_t res; - struct page *page; + struct folio *folio; struct inode *inode = file_inode(file); struct fuse_mount *fm = get_fuse_mount(inode); struct fuse_io_args ia = {}; struct fuse_args_pages *ap = &ia.ap; - struct fuse_page_desc desc = { .length = PAGE_SIZE }; + struct fuse_folio_desc desc = { .length = PAGE_SIZE }; u64 attr_version = 0; bool locked; - page = alloc_page(GFP_KERNEL); - if (!page) + folio = folio_alloc(GFP_KERNEL, 0); + if (!folio) return -ENOMEM; plus = fuse_use_readdirplus(inode, ctx); ap->args.out_pages = true; - ap->num_pages = 1; - ap->pages = &page; - ap->descs = &desc; + ap->uses_folios = true; + ap->num_folios = 1; + ap->folios = &folio; + ap->folio_descs = &desc; if (plus) { attr_version = fuse_get_attr_version(fm->fc); fuse_read_args_fill(&ia, file, ctx->pos, PAGE_SIZE, @@ -367,15 +368,15 @@ static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx) if (ff->open_flags & FOPEN_CACHE_DIR) fuse_readdir_cache_end(file, ctx->pos); } else if (plus) { - res = parse_dirplusfile(page_address(page), res, + res = parse_dirplusfile(folio_address(folio), res, file, ctx, attr_version); } else { - res = parse_dirfile(page_address(page), res, file, + res = parse_dirfile(folio_address(folio), res, file, ctx); } } - __free_page(page); + folio_put(folio); fuse_invalidate_atime(inode); return res; } From patchwork Thu Oct 24 17:18:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849477 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 859171FC7D6 for ; Thu, 24 Oct 2024 17:21:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790494; cv=none; b=FeEG08NMoc998JwflKeS4xfTJoU/+SPiyHzkBcpfC1jW4uONC2O/mcYTce4lwifWoy4hiqqBAb/YuNLykJFHq0rkaNaicITXKsd9jbODTQc6kP4YWb95iW8A5/ojG6KVHLdwXsZ0Oezh8DneJIYrnHVS7Z5lrRVcYlWeSaQHNrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790494; c=relaxed/simple; bh=+GvzxVcw3NR96WLeKClotYmjGsPHcyFUD/PGVHN4+aM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aji8D1YKWjX1paq8CM6IYobhghFKQ2r/GlSQIyaNp5pYKSC+k9RjqlT8HUxjqsbgbV7E8wMtb94PaDbPIQGrtY7dtNDm1+MPV/ntWHPq9O6PGtKlpXHiT/0LqgrQDmWrF0RLJPaOaS27Q0ssjmfTDCUf7UVKfKwCa8GTUzatOjo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Def8GqJ2; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Def8GqJ2" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e2bdbdee559so1340393276.1 for ; Thu, 24 Oct 2024 10:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790491; x=1730395291; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W2okvCM9Mz7H/1j4q0oAIGkWxD4MzsN3YCiMJzP58qw=; b=Def8GqJ2w5LH8MTB4hwC9O6sEll9fKN4H5oWVMVeyiC7XH3MIEFVJ40BFsp0w2gRUU kuquXrXup5D8au+naGJgjN65GE6ryhBJsaMMS1f54Pjoysxm+K33JIknBLKQozjossU7 We22kfh6IryQpXJcZrjhjz4aiTSXh7UKOfJgG8ezHFiQvp98hOAhKHFy9YkJ6HwagkqU L0QLWUkr328W3c+j+QcR+ncIWXSZiwcpf7EU0AT1zkoOIewnX2yRy6KeAma08tYfpU3g tX44UY0Ufu6zB2IDTVOG9hh5buXTQmPzlJS4UefInUhRHVSB74TybEUqZImtv87DcuoL rcEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790491; x=1730395291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W2okvCM9Mz7H/1j4q0oAIGkWxD4MzsN3YCiMJzP58qw=; b=iFfevT+3juflO291VbRoa8P/NovCde+Hb1vWWzkh69R43ovbsL4omxKvoXHIbf6JXt Vt3h9uvIfjwUsJ3Hf7b2pCoG2H7XrcZ33Bf18iaVYcytLYXZMzOAzXUzVMLwTHPe44Nm KtbJmufOP8OgPAPYKmIP8euSMwPFzwy6B+A6ma4qfmuV0NqEB8NmVz0v86dkrPK6IPIq oq6kzuJw9BemvpM4v/kVzX2FJ6coLI8gepEtYI3C45i8v+vFg7NBAk+EiLNYFfEC6DLO +bOvt6dMIVB66Fg0WdxacWRUEkP1UXH32SWJNY9jDyUU2LUNhzMhoGLCedaq7Wxrn2NV RojA== X-Forwarded-Encrypted: i=1; AJvYcCVHnyqmKDNlhi7C3Eunl6TV8mP0DX+b/McE9wGI9b34uzQcVRnD52QqMVR1JiwT67dSY0899xfTLx2kBY40@vger.kernel.org X-Gm-Message-State: AOJu0YxgspTt6iwt9zJUQlxxNDuU8FhzKqYWxuZp+ugxWX85X+EdY2QZ uJiq+GyHWzCWLTfb4e8HmdlarMRCfEN9K+iyGfUqdxcAm5wQVPMy X-Google-Smtp-Source: AGHT+IEVau3YClcmLxtR+9Up4nGFKYOoIn5mLYZgzfM4Dvp/TXbf4QxD3hlcf+8l5Z2JFU8dc0DpCA== X-Received: by 2002:a05:6902:a83:b0:e29:27c4:3c6b with SMTP id 3f1490d57ef6-e2e3a66599fmr6768078276.30.1729790491321; Thu, 24 Oct 2024 10:21:31 -0700 (PDT) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2bdc96ab29sm1952582276.10.2024.10.24.10.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:30 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 06/13] fuse: convert reads to use folios Date: Thu, 24 Oct 2024 10:18:02 -0700 Message-ID: <20241024171809.3142801-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert read requests to use folios instead of pages. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 67 ++++++++++++++++++++++++++++++++---------------- fs/fuse/fuse_i.h | 12 +++++++++ 2 files changed, 57 insertions(+), 22 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ce67af163c9a..ece1c0319e35 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -760,12 +760,37 @@ static struct fuse_io_args *fuse_io_alloc(struct fuse_io_priv *io, return ia; } +static struct fuse_io_args *fuse_io_folios_alloc(struct fuse_io_priv *io, + unsigned int nfolios) +{ + struct fuse_io_args *ia; + + ia = kzalloc(sizeof(*ia), GFP_KERNEL); + if (ia) { + ia->io = io; + ia->ap.uses_folios = true; + ia->ap.folios = fuse_folios_alloc(nfolios, GFP_KERNEL, + &ia->ap.folio_descs); + if (!ia->ap.folios) { + kfree(ia); + ia = NULL; + } + } + return ia; +} + static void fuse_io_free(struct fuse_io_args *ia) { kfree(ia->ap.pages); kfree(ia); } +static void fuse_io_folios_free(struct fuse_io_args *ia) +{ + kfree(ia->ap.folios); + kfree(ia); +} + static void fuse_aio_complete_req(struct fuse_mount *fm, struct fuse_args *args, int err) { @@ -865,7 +890,7 @@ static void fuse_short_read(struct inode *inode, u64 attr_ver, size_t num_read, * reached the client fs yet. So the hole is not present there. */ if (!fc->writeback_cache) { - loff_t pos = page_offset(ap->pages[0]) + num_read; + loff_t pos = folio_pos(ap->folios[0]) + num_read; fuse_read_update_size(inode, pos, attr_ver); } } @@ -875,14 +900,14 @@ static int fuse_do_readfolio(struct file *file, struct folio *folio) struct inode *inode = folio->mapping->host; struct fuse_mount *fm = get_fuse_mount(inode); loff_t pos = folio_pos(folio); - struct fuse_page_desc desc = { .length = PAGE_SIZE }; - struct page *page = &folio->page; + struct fuse_folio_desc desc = { .length = PAGE_SIZE }; struct fuse_io_args ia = { .ap.args.page_zeroing = true, .ap.args.out_pages = true, - .ap.num_pages = 1, - .ap.pages = &page, - .ap.descs = &desc, + .ap.uses_folios = true, + .ap.num_folios = 1, + .ap.folios = &folio, + .ap.folio_descs = &desc, }; ssize_t res; u64 attr_ver; @@ -941,8 +966,8 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args, size_t num_read = args->out_args[0].size; struct address_space *mapping = NULL; - for (i = 0; mapping == NULL && i < ap->num_pages; i++) - mapping = ap->pages[i]->mapping; + for (i = 0; mapping == NULL && i < ap->num_folios; i++) + mapping = ap->folios[i]->mapping; if (mapping) { struct inode *inode = mapping->host; @@ -956,15 +981,12 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args, fuse_invalidate_atime(inode); } - for (i = 0; i < ap->num_pages; i++) { - struct folio *folio = page_folio(ap->pages[i]); - - folio_end_read(folio, !err); - } + for (i = 0; i < ap->num_folios; i++) + folio_end_read(ap->folios[i], !err); if (ia->ff) fuse_file_put(ia->ff, false); - fuse_io_free(ia); + fuse_io_folios_free(ia); } static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) @@ -972,8 +994,9 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) struct fuse_file *ff = file->private_data; struct fuse_mount *fm = ff->fm; struct fuse_args_pages *ap = &ia->ap; - loff_t pos = page_offset(ap->pages[0]); - size_t count = ap->num_pages << PAGE_SHIFT; + loff_t pos = folio_pos(ap->folios[0]); + /* Currently, all folios in FUSE are one page */ + size_t count = ap->num_folios << PAGE_SHIFT; ssize_t res; int err; @@ -984,7 +1007,7 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) /* Don't overflow end offset */ if (pos + (count - 1) == LLONG_MAX) { count--; - ap->descs[ap->num_pages - 1].length--; + ap->folio_descs[ap->num_folios - 1].length--; } WARN_ON((loff_t) (pos + count) < 0); @@ -1045,16 +1068,16 @@ static void fuse_readahead(struct readahead_control *rac) */ break; - ia = fuse_io_alloc(NULL, cur_pages); + ia = fuse_io_folios_alloc(NULL, cur_pages); if (!ia) return; ap = &ia->ap; - while (ap->num_pages < cur_pages) { + while (ap->num_folios < cur_pages) { folio = readahead_folio(rac); - ap->pages[ap->num_pages] = &folio->page; - ap->descs[ap->num_pages].length = folio_size(folio); - ap->num_pages++; + ap->folios[ap->num_folios] = folio; + ap->folio_descs[ap->num_folios].length = folio_size(folio); + ap->num_folios++; } fuse_send_readpages(ia, rac->file); nr_pages -= cur_pages; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 24a3da8400d1..b6877064c071 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1029,6 +1029,18 @@ static inline struct page **fuse_pages_alloc(unsigned int npages, gfp_t flags, return pages; } +static inline struct folio **fuse_folios_alloc(unsigned int nfolios, gfp_t flags, + struct fuse_folio_desc **desc) +{ + struct folio **folios; + + folios = kzalloc(nfolios * (sizeof(struct folio *) + + sizeof(struct fuse_folio_desc)), flags); + *desc = (void *) (folios + nfolios); + + return folios; +} + static inline void fuse_page_descs_length_init(struct fuse_page_desc *descs, unsigned int index, unsigned int nr_pages) From patchwork Thu Oct 24 17:18:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849479 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87D801FC7F7 for ; Thu, 24 Oct 2024 17:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790496; cv=none; b=Jv3W1TUo1dNcPPNOGpQlV2sEsfJ8uBYGfoT7bqF9p1wkO/EgY+lXkYA/BBMq9w7Af9aR95+hotTXhV0Z4Zt86AoSiG+wp8ZCwJrwgR25RkM5isbQ/FmzxemgIKZfpT278O83iDg83wD/gT8rMRDhf380T/00jz3Ww/opk9dU3Os= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790496; c=relaxed/simple; bh=4MEV22g4XjsggbYOYj2TugUOdvoBUWfpcLG9LT8sZss=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fq2djcRbvJchRk/l4cM0YuS0o54C5br1Qg9vsTGkG2AGGV3fvNaJzLGwhtHA1jPav255vPocbiKdeIJGhDPEGSVVFv4YNcrqDNH67B1y58XmvzsGz1xQCnonpRXQDKhQYDP67l0Q5QoUpz5vP/h0D9GDjX/+NVJnQBYMCMnEsS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MOVc4LZi; arc=none smtp.client-ip=209.85.128.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MOVc4LZi" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6e35bf59cf6so23170517b3.0 for ; Thu, 24 Oct 2024 10:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790492; x=1730395292; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+fnLj/x/wj/MDATez8fu+sEbs2DKFZMz09D7xlaJo8s=; b=MOVc4LZihLv/ZhSiGZejVjmAeywmpBt4P8eKakHfSsdcptS9ufODn6YBevKapuM70R exhQi1D6VMzaVKhIovZQOKZEYS1NISTmY9NgoWyErH4zG4ARsZYZZnnrLutLvUWJtH5d kZAlVMtIKTt+ncUfRav+Timd1oykemZ6oAPfWB+u4Ac0jv/5qzA+7vU1dvu8hS3fU/wN 3wsjWDVd/MbiFMP2+rna+uvKtMZd644n/eYc2jMtFPKj+uQiW5lFQq/bpYiD8E8hIKOg kvHV/eBjHV1iAQNcXIV+0J69GjhGQzMwBCKs9UB6hJQRebRshu6SJeKyMZ43VLKqFpTX /kqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790492; x=1730395292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+fnLj/x/wj/MDATez8fu+sEbs2DKFZMz09D7xlaJo8s=; b=CM3pwQxlmFRHY82XGmLsCpoyd7N+Bd1xrAB0JKBnRTMnl788eYFexnN3bMBXItQIiS pshhDS2PeXNTtnOKsybcXke6SG9kKgOZ7VLz+osIXW1fuUx7Py+IQYh0Ai9sLkgnNvva 2ZibDGRydv3Nm8PQr54U7a74mDX+6T4iUbHTAV00e4UeFABYBGTV6TVkiBledduiMsWy PqdHz4Li7XI/2j6CZEpx6eYYGDIWfHYG5H8Zcy3Otwh365PrzUfVLN5jtT3Uh7id0Sjr qN05ngvWRk2jXHZphERk5lF0tFB89L4xkDNeX/zn3rxa6Uvq1JOpvdanFCGNXs/Zj8VE dpzA== X-Forwarded-Encrypted: i=1; AJvYcCWz1Ym4BWsTegJDpUnbtXW1A2pG6tKQsZjzrNMsGaEzmNwRvOBms9KPlbMw6iHwXg6CktkG7XPsJ39eR42w@vger.kernel.org X-Gm-Message-State: AOJu0YzY2J2OkmY4pPm4w7Q03zSrMBthntfyzTFSH7cqCHn0aoBFvjdw I4mmg0hlL3fEAU1UGnPOwVRWZJgtucEic/gm3Hv3HqX7TWrpcQHj X-Google-Smtp-Source: AGHT+IGqwderlHoH9Rx7tTdrPq4WNv797Exhgm84fMDEBWRlJfm1DJ/z+kW+qexJadeUqsJVj91HTw== X-Received: by 2002:a05:690c:2c8c:b0:6e5:2adf:d584 with SMTP id 00721157ae682-6e84df79fc6mr20629977b3.14.1729790492066; Thu, 24 Oct 2024 10:21:32 -0700 (PDT) Received: from localhost (fwdproxy-nha-012.fbsv.net. [2a03:2880:25ff:c::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5a4d3aesm20603327b3.37.2024.10.24.10.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:31 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 07/13] fuse: convert writes (non-writeback) to use folios Date: Thu, 24 Oct 2024 10:18:03 -0700 Message-ID: <20241024171809.3142801-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert non-writeback write requests to use folios instead of pages. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 33 ++++++++++++++++++--------------- fs/fuse/fuse_i.h | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ece1c0319e35..b3d5b7b5da52 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1197,8 +1197,8 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia, bool short_write; int err; - for (i = 0; i < ap->num_pages; i++) - fuse_wait_on_page_writeback(inode, ap->pages[i]->index); + for (i = 0; i < ap->num_folios; i++) + fuse_wait_on_folio_writeback(inode, ap->folios[i]); fuse_write_args_fill(ia, ff, pos, count); ia->write.in.flags = fuse_write_flags(iocb); @@ -1210,10 +1210,10 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia, err = -EIO; short_write = ia->write.out.size < count; - offset = ap->descs[0].offset; + offset = ap->folio_descs[0].offset; count = ia->write.out.size; - for (i = 0; i < ap->num_pages; i++) { - struct folio *folio = page_folio(ap->pages[i]); + for (i = 0; i < ap->num_folios; i++) { + struct folio *folio = ap->folios[i]; if (err) { folio_clear_uptodate(folio); @@ -1227,7 +1227,7 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia, } offset = 0; } - if (ia->write.page_locked && (i == ap->num_pages - 1)) + if (ia->write.folio_locked && (i == ap->num_folios - 1)) folio_unlock(folio); folio_put(folio); } @@ -1243,11 +1243,12 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, struct fuse_args_pages *ap = &ia->ap; struct fuse_conn *fc = get_fuse_conn(mapping->host); unsigned offset = pos & (PAGE_SIZE - 1); + unsigned int nr_pages = 0; size_t count = 0; int err; ap->args.in_pages = true; - ap->descs[0].offset = offset; + ap->folio_descs[0].offset = offset; do { size_t tmp; @@ -1283,9 +1284,10 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, } err = 0; - ap->pages[ap->num_pages] = &folio->page; - ap->descs[ap->num_pages].length = tmp; - ap->num_pages++; + ap->folios[ap->num_folios] = folio; + ap->folio_descs[ap->num_folios].length = tmp; + ap->num_folios++; + nr_pages++; count += tmp; pos += tmp; @@ -1300,13 +1302,13 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, if (folio_test_uptodate(folio)) { folio_unlock(folio); } else { - ia->write.page_locked = true; + ia->write.folio_locked = true; break; } if (!fc->big_writes) break; } while (iov_iter_count(ii) && count < fc->max_write && - ap->num_pages < max_pages && offset == 0); + nr_pages < max_pages && offset == 0); return count > 0 ? count : err; } @@ -1340,8 +1342,9 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) unsigned int nr_pages = fuse_wr_pages(pos, iov_iter_count(ii), fc->max_pages); - ap->pages = fuse_pages_alloc(nr_pages, GFP_KERNEL, &ap->descs); - if (!ap->pages) { + ap->uses_folios = true; + ap->folios = fuse_folios_alloc(nr_pages, GFP_KERNEL, &ap->folio_descs); + if (!ap->folios) { err = -ENOMEM; break; } @@ -1363,7 +1366,7 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) err = -EIO; } } - kfree(ap->pages); + kfree(ap->folios); } while (!err && iov_iter_count(ii)); fuse_write_update_attr(inode, pos, res); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index b6877064c071..201b08562b6b 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1096,7 +1096,7 @@ struct fuse_io_args { struct { struct fuse_write_in in; struct fuse_write_out out; - bool page_locked; + bool folio_locked; } write; }; struct fuse_args_pages ap; From patchwork Thu Oct 24 17:18:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849478 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CDCC1FAF1E for ; Thu, 24 Oct 2024 17:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790496; cv=none; b=qdnkEVm3lpA7MjxGowg4agF3ljbJq3UJv//7ed4ZxhvQ6V5mjEF+nNmfFAajIo0eCwBUBvlyXIP908fnbZDAHFjQtNKHo8tmhc6lDKTlbWB2E8uJxbnerJJLBpFKyfLrOlwTeiJWpjTElSF5rgjLpTkjdA2GetMC5G3GsqVoGJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790496; c=relaxed/simple; bh=Husv96TOMO2qIvKRZvj2W7AV+kR/pj194D/faJu/Lkk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h0wUQMD5VTHW0MsBT01Zq3/17T06+7i6iur3RX99Zgodcyz57wYD0uH6mBoyG+bfbKgzlRXFMJxwtsl5ydge3xw2mHUOCf5rw4F5fsFJ/mft/Pienj5Ksiwb3csNymr3zeoFquRR7G0iu0wvyb+tSzXKB3+pVGIPJ0dLOfS2MRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=me+v/1lM; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="me+v/1lM" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6e5a5a59094so10932217b3.3 for ; Thu, 24 Oct 2024 10:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790493; x=1730395293; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FmMFL8Z717LngE8XgMJcblRHxFbxLWA01uvsBYHeR/c=; b=me+v/1lMcj/VOqd+mudXo9ccpCKAasoZAt/FNVbP5b0lhvzPKbUhE1CYduJryWU+ho 3y0yeKpHilV4y5SuUWHtkGt0vxtrmXaen8G6ti7//A+3OT1wK/kJXAFj2R1eoM/pleym gXj7+EWuGqxNONuYolbDQlB6wUeA7owA04b+k9RERFa0zfJELCmOpW3+RFPeHDEebx9t 7Pb43r0X9TLkCpTmbendidqxTusIk+6bFCmXKgwIDK4CJq2i/jZAVSyYDEWIYJfchyTV pYJ4cjWxS/P06FwhNfqwXROBGXXMbqKNU/nj6gMNdl5UioUb0FrDpTn+1iCcibTOvqYP B5IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790493; x=1730395293; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FmMFL8Z717LngE8XgMJcblRHxFbxLWA01uvsBYHeR/c=; b=UypbY+STUSQrw9bk94f/CrFNlvSguqGRB3wrcxNk9SmwheQt5lOU/5U9tq5Lo8cuk6 x6Tz8c/8vpRkj937eL55hJ+IILoXT1sZwX9iSfygBRsOmkSfnNAT3z6umanrsJmEV8MX NaeR6ly7VcCTdOyimgThHdPVBQPI/pgkFTTl6ytHEnavENdbz4iN8s2Su1YTAzKqDNtF /88VVNQ5Hs6AzBbK67o7UtwRkOT76UTBSPUZHgD9bZTmH63mif6Uj6zF2h8n50aMUvXT 470ks0eaYgvccDiu3Q5bj4IYh+CdXpDRe975cucCmM2WrdNBtasCXoKBYDTvjFBdn1tU oXTQ== X-Forwarded-Encrypted: i=1; AJvYcCVqdqDZ4fmqzRnJ/izHlnsjc5q+SPSjx1enB921fhD/oXUXkxTtdG6cYlgT2Ghytf4k1tRmTOI2h9nAFQC7@vger.kernel.org X-Gm-Message-State: AOJu0YxLDa+vSAyjv6qrwShxyFyb6bKE9dObZ9NYNe7pov/a10LAJp81 odUmHcfPmstDQ+sI1x5Xwzr2oFYvn09Nb1LQBKUd8e2FJ4uzLO+L X-Google-Smtp-Source: AGHT+IGOLaJWd9wMI5C33pZctqcot6R56/oxOYrU4iLhRICRsvkRLtwjuL2nXuucCnoX5/MrLWIKzw== X-Received: by 2002:a05:690c:67ca:b0:6e2:7dd:af61 with SMTP id 00721157ae682-6e7f0e04c70mr78960967b3.17.1729790492835; Thu, 24 Oct 2024 10:21:32 -0700 (PDT) Received: from localhost (fwdproxy-nha-010.fbsv.net. [2a03:2880:25ff:a::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5d142f4sm20721577b3.115.2024.10.24.10.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:32 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 08/13] fuse: convert ioctls to use folios Date: Thu, 24 Oct 2024 10:18:04 -0700 Message-ID: <20241024171809.3142801-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert ioctl requests to use folios instead of pages. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/fuse_i.h | 10 ++++++++++ fs/fuse/ioctl.c | 32 ++++++++++++++++---------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 201b08562b6b..c1c7def8ee4b 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1051,6 +1051,16 @@ static inline void fuse_page_descs_length_init(struct fuse_page_desc *descs, descs[i].length = PAGE_SIZE - descs[i].offset; } +static inline void fuse_folio_descs_length_init(struct fuse_folio_desc *descs, + unsigned int index, + unsigned int nr_folios) +{ + int i; + + for (i = index; i < index + nr_folios; i++) + descs[i].length = PAGE_SIZE - descs[i].offset; +} + static inline void fuse_sync_bucket_dec(struct fuse_sync_bucket *bucket) { /* Need RCU protection to prevent use after free after the decrement */ diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c index a6c8ee551635..1c77d8a27950 100644 --- a/fs/fuse/ioctl.c +++ b/fs/fuse/ioctl.c @@ -251,12 +251,12 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, BUILD_BUG_ON(sizeof(struct fuse_ioctl_iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE); err = -ENOMEM; - ap.pages = fuse_pages_alloc(fm->fc->max_pages, GFP_KERNEL, &ap.descs); + ap.folios = fuse_folios_alloc(fm->fc->max_pages, GFP_KERNEL, &ap.folio_descs); iov_page = (struct iovec *) __get_free_page(GFP_KERNEL); - if (!ap.pages || !iov_page) + if (!ap.folios || !iov_page) goto out; - fuse_page_descs_length_init(ap.descs, 0, fm->fc->max_pages); + fuse_folio_descs_length_init(ap.folio_descs, 0, fm->fc->max_pages); /* * If restricted, initialize IO parameters as encoded in @cmd. @@ -306,14 +306,14 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, err = -ENOMEM; if (max_pages > fm->fc->max_pages) goto out; - while (ap.num_pages < max_pages) { - ap.pages[ap.num_pages] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM); - if (!ap.pages[ap.num_pages]) + ap.uses_folios = true; + while (ap.num_folios < max_pages) { + ap.folios[ap.num_folios] = folio_alloc(GFP_KERNEL | __GFP_HIGHMEM, 0); + if (!ap.folios[ap.num_folios]) goto out; - ap.num_pages++; + ap.num_folios++; } - /* okay, let's send it to the client */ ap.args.opcode = FUSE_IOCTL; ap.args.nodeid = ff->nodeid; @@ -327,8 +327,8 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, err = -EFAULT; iov_iter_init(&ii, ITER_SOURCE, in_iov, in_iovs, in_size); - for (i = 0; iov_iter_count(&ii) && !WARN_ON(i >= ap.num_pages); i++) { - c = copy_page_from_iter(ap.pages[i], 0, PAGE_SIZE, &ii); + for (i = 0; iov_iter_count(&ii) && !WARN_ON(i >= ap.num_folios); i++) { + c = copy_folio_from_iter(ap.folios[i], 0, PAGE_SIZE, &ii); if (c != PAGE_SIZE && iov_iter_count(&ii)) goto out; } @@ -366,7 +366,7 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, in_iovs + out_iovs > FUSE_IOCTL_MAX_IOV) goto out; - vaddr = kmap_local_page(ap.pages[0]); + vaddr = kmap_local_folio(ap.folios[0], 0); err = fuse_copy_ioctl_iovec(fm->fc, iov_page, vaddr, transferred, in_iovs + out_iovs, (flags & FUSE_IOCTL_COMPAT) != 0); @@ -394,17 +394,17 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, err = -EFAULT; iov_iter_init(&ii, ITER_DEST, out_iov, out_iovs, transferred); - for (i = 0; iov_iter_count(&ii) && !WARN_ON(i >= ap.num_pages); i++) { - c = copy_page_to_iter(ap.pages[i], 0, PAGE_SIZE, &ii); + for (i = 0; iov_iter_count(&ii) && !WARN_ON(i >= ap.num_folios); i++) { + c = copy_folio_to_iter(ap.folios[i], 0, PAGE_SIZE, &ii); if (c != PAGE_SIZE && iov_iter_count(&ii)) goto out; } err = 0; out: free_page((unsigned long) iov_page); - while (ap.num_pages) - __free_page(ap.pages[--ap.num_pages]); - kfree(ap.pages); + while (ap.num_folios) + folio_put(ap.folios[--ap.num_folios]); + kfree(ap.folios); return err ? err : outarg.result; } From patchwork Thu Oct 24 17:18:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849480 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFCE21F76B4 for ; Thu, 24 Oct 2024 17:21:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790497; cv=none; b=ia+wyTf0866Ue/lulcCZ1Qs1gpxCDKYGZQBVzCP3XXsRG0QVl7oXOoHJZ7Y3GquK3upVTYS02ct9IePYJsNL4MQxHYsl/vaR6+ARNEqyQDC4E8lSvSEzBkyx6NP5rK3u5pyVpOCLoPjnVj3evyomiClR+54kzYCSaTHBGQEjMxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790497; c=relaxed/simple; bh=u5QKa7U9Psgt6XNgOMf0yckRg7JO97OBkthD/xegzFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=It6huwstJlk0sfEKvlTvkk4NXHxminyRqEUeNfvdvKkhBy1fwEUBC4YSDZUdUIQ0lKzYE8hB9VB3atNLypdRZ5mf8/1ogqVuPjg7a1s+Jma9fPyrdzxiOTodfid31uze2T2laacScI93YCsbu7le+JYSKGZqbm4DwQoyKL6W+CQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QEOkkdj/; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QEOkkdj/" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6e5b7cd1ef5so12122277b3.1 for ; Thu, 24 Oct 2024 10:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790494; x=1730395294; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gzxtYdjhLYm7SpLm5LWselHwEnY7l1Z1CL7gsS4M7V4=; b=QEOkkdj/X/S6O7O4rXJ224lNhLE/JmGb48eUlu4LviFUMLlPmoO1vjL31+q40g4R7s GFvs4wbtsxBIPrKl5w5oZuIC4nTrd6CGJpGRXYsOOssgL2zxH0lJ1nJy3rX7ZEzZB59D tDOVU55qJtO0ibJp47S7HcebmD9nMlJqSKYJGB6vN/XYWjCVaTcPU9YubugZH33dJ5sw HuKNmGj7XVYtKISQnGst2L7SYjacttZFdtqjTWxylPuQORZ7495SUeWRZksEUNA7SmX1 GNAiLRbuvxOnfp5982oQAh+JAU3jr5DG6o6y3ZNIKo5upaIws5aWHclxOaj8Fz8MTqvl DvSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790494; x=1730395294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gzxtYdjhLYm7SpLm5LWselHwEnY7l1Z1CL7gsS4M7V4=; b=kDv0YtsjjIkPGjxIA1K9goCWwnilb6LfqI1YbRwQAw6Zcmtuz6if7GMEbs+plhB8zO 3LiGKHbKHWppc+au0kBhWB9F1e0td1uTKBp0K1Pao82Jz9X4e4SwXcMz2oouq2/ju8fK 9HC3dPjKQ32ma8TL5G69p77EJgG3EhjV1PKUzIbfX7ROZ0MODpdFRRihe4mixD+eJfmR nUMtTb2rha/8NhdCLBjZ+Q7SqUFvgA2UzIwSQwRlYcbYGNDrqgEEG4r9ipWfMECIC7FF 1BXBfgNjeuLqk7EjOTwisX27vPOx8utTNstojwkIydG3JHV6RKBjGsQJ6zKXnY4zFFQj O2Tw== X-Forwarded-Encrypted: i=1; AJvYcCUEMTd3Jmkxy167FXXmK0VvHLMOWiiP6TSuu7wO0o0q7GWnEF6zyFYhxqIKHI1n0gThxR3a00lXCURWynjv@vger.kernel.org X-Gm-Message-State: AOJu0Yyytt89ijCUFiRIZAe5g5fk/oXldSCpTqXJVqyakV1H5ddcdE1R KruZy4kJ0kavt11cdGIVas2HXehA+idaYd12s/uSPutGovnblsIp4GX+WQ== X-Google-Smtp-Source: AGHT+IE/FcJswtK6gc3+EPebDTs1qD8PW2VsYdTrNo1lj9Bwce4u8d3RnjHXJ+UMp4Rr/oPV46Ev9g== X-Received: by 2002:a05:690c:6c0c:b0:6e3:1063:91ca with SMTP id 00721157ae682-6e86632cdd3mr34706437b3.40.1729790493551; Thu, 24 Oct 2024 10:21:33 -0700 (PDT) Received: from localhost (fwdproxy-nha-004.fbsv.net. [2a03:2880:25ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5acfbb4sm20501867b3.65.2024.10.24.10.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:33 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 09/13] fuse: convert retrieves to use folios Date: Thu, 24 Oct 2024 10:18:05 -0700 Message-ID: <20241024171809.3142801-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert retrieve requests to use folios instead of pages. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 9f860bd655a4..9467b05d3d4a 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1728,7 +1728,7 @@ static void fuse_retrieve_end(struct fuse_mount *fm, struct fuse_args *args, struct fuse_retrieve_args *ra = container_of(args, typeof(*ra), ap.args); - release_pages(ra->ap.pages, ra->ap.num_pages); + release_pages(ra->ap.folios, ra->ap.num_folios); kfree(ra); } @@ -1742,7 +1742,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, unsigned int num; unsigned int offset; size_t total_len = 0; - unsigned int num_pages; + unsigned int num_pages, cur_pages = 0; struct fuse_conn *fc = fm->fc; struct fuse_retrieve_args *ra; size_t args_size = sizeof(*ra); @@ -1761,15 +1761,16 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; num_pages = min(num_pages, fc->max_pages); - args_size += num_pages * (sizeof(ap->pages[0]) + sizeof(ap->descs[0])); + args_size += num_pages * (sizeof(ap->folios[0]) + sizeof(ap->folio_descs[0])); ra = kzalloc(args_size, GFP_KERNEL); if (!ra) return -ENOMEM; ap = &ra->ap; - ap->pages = (void *) (ra + 1); - ap->descs = (void *) (ap->pages + num_pages); + ap->folios = (void *) (ra + 1); + ap->folio_descs = (void *) (ap->folios + num_pages); + ap->uses_folios = true; args = &ap->args; args->nodeid = outarg->nodeid; @@ -1780,7 +1781,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, index = outarg->offset >> PAGE_SHIFT; - while (num && ap->num_pages < num_pages) { + while (num && cur_pages < num_pages) { struct folio *folio; unsigned int this_num; @@ -1789,10 +1790,11 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, break; this_num = min_t(unsigned, num, PAGE_SIZE - offset); - ap->pages[ap->num_pages] = &folio->page; - ap->descs[ap->num_pages].offset = offset; - ap->descs[ap->num_pages].length = this_num; - ap->num_pages++; + ap->folios[ap->num_folios] = folio; + ap->folio_descs[ap->num_folios].offset = offset; + ap->folio_descs[ap->num_folios].length = this_num; + ap->num_folios++; + cur_pages++; offset = 0; num -= this_num; From patchwork Thu Oct 24 17:18:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849482 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C857F1FDFB4 for ; Thu, 24 Oct 2024 17:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790499; cv=none; b=lg5WiKv47m/h7o3ZX3p0VfdZ1R4D/93qq9jzVebh2Rglv7MKVu2Qj4Cll534HqxT3uL3QNoL+cZCqrUUP2C9VO8NCWiMYAB+3NY+1LmpUc00e5noMV1fvXU7oVpRrhG43a28XvWeHgzi9+gC5Uv6LqK2rzevlbUmtOlhpIe3MOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790499; c=relaxed/simple; bh=1HaPk6EzjG7VdCSKTLuQIOpXFdsINrd32PweVP9Fvd4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m3LyCQJDluYYEkiwvfO/daWMWjQH9hE74R/GjsdVahSFmkPlo87JTNYJz/iv8U8YbPgVm+0inbsIDRPrhtihb43P0sbTTWaLp95s6RL2LUaFmk83izu4wudUNAqARPRQtKmGZb5MDAwUetAxm+9ujf4AhEz6G5Ro8DiRYeyDTEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DUlQNq99; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DUlQNq99" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-6e5b7cd1ef5so12122407b3.1 for ; Thu, 24 Oct 2024 10:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790495; x=1730395295; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z0KOt5uiDqhAKm2lG1E6tmLsQZkwQMxuXKLy3i7vj9g=; b=DUlQNq99uFuWMEcf7vdPhBBydu99S7YBY7ccjxQwVogvS4936eu2G3Rups0IM5E8bd hsqT3yciJigDV8YyYXEB5TlbAfN+ISM6uc/7fK0GO8lt92zfyGZeKPSM22UCyIvBB6Da u8rz05Ax+Fp4/TQh24/YVcKggRA1IKOP+j1Zg2hA5jR/tDnsapJyuppbH11vmpjWdcbR fCMh7OMDzVKP9P6At5LvZlTdWM/fEmCRhEFgg6A3ExOmsZHWZcu5JkSeMrH8n9/U1P7Q xYGlwmMhWG0dt8K7huj15n9HmSVnxf1dh1UelWwa8wAi8eYPh1U3I0DxicZVjwgvSWOx VzNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790495; x=1730395295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z0KOt5uiDqhAKm2lG1E6tmLsQZkwQMxuXKLy3i7vj9g=; b=rJSfwtDsvAwGMKX5hE2jGAuyzBccKJPVkRWabpPKWqQMlC6mfoLT3CwblT32KQ9dqk Tu2vBS+pgtHEk5oBETVAkLGcaGpvuJ1bJ7/iK4GInxCC32xDuYoc4/5FCqz+FrHAkiie Fy0pv+xMqp2ytfg1RiB6IYmI0PWPM9jBnD5VhyfsUZcJZrLkZ+K9dg3RpqWAwoYehidu 5L20pC5xXAjPUh6kXRjo5M7wegah0wu8bb2ZIT+2WE5OHy405DJZYvQmynHhtTPhSEfS Oi9SPhkW/Run0pOJZ4Z6JZjzjhIkBcjR1io+rjGFxc6IQVA8utFPPdxVMxZfQZjNvqWM BBGA== X-Forwarded-Encrypted: i=1; AJvYcCVQhwlGqoILdigaB8Fyw65XsdK+63pVz6JnoHpu+S8lqBhn0dDgezlXG0aNLybVpC4oOtRd7EkpR82gNo/S@vger.kernel.org X-Gm-Message-State: AOJu0Yz0pBldTx06BtP59gkEfrlo0iYzlcH7sW0Urs+/Nryh45gwPyYX nFIk7/q+yoh5Z4YkXkJ4sBac9PIjdA7D/8uwPc70F4K3bpKpqTFJ X-Google-Smtp-Source: AGHT+IGQzq2GyrvTf58sWsQmU27GK4l1oCLBdYtG4kGVUY+t7wAAYu8CGrOm/5ZoJA7NAlQLNzm8GQ== X-Received: by 2002:a05:690c:4b0a:b0:6e7:d974:8d05 with SMTP id 00721157ae682-6e858152039mr37245387b3.4.1729790494445; Thu, 24 Oct 2024 10:21:34 -0700 (PDT) Received: from localhost (fwdproxy-nha-014.fbsv.net. [2a03:2880:25ff:e::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5d6f92bsm21074977b3.138.2024.10.24.10.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:33 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 10/13] fuse: convert writebacks to use folios Date: Thu, 24 Oct 2024 10:18:06 -0700 Message-ID: <20241024171809.3142801-11-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert writeback requests to use folios instead of pages. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 126 +++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b3d5b7b5da52..99af3c39e529 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -436,7 +436,7 @@ static struct fuse_writepage_args *fuse_find_writeback(struct fuse_inode *fi, wpa = rb_entry(n, struct fuse_writepage_args, writepages_entry); WARN_ON(get_fuse_inode(wpa->inode) != fi); curr_index = wpa->ia.write.in.offset >> PAGE_SHIFT; - if (idx_from >= curr_index + wpa->ia.ap.num_pages) + if (idx_from >= curr_index + wpa->ia.ap.num_folios) n = n->rb_right; else if (idx_to < curr_index) n = n->rb_left; @@ -1837,12 +1837,12 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa) if (wpa->bucket) fuse_sync_bucket_dec(wpa->bucket); - for (i = 0; i < ap->num_pages; i++) - __free_page(ap->pages[i]); + for (i = 0; i < ap->num_folios; i++) + folio_put(ap->folios[i]); fuse_file_put(wpa->ia.ff, false); - kfree(ap->pages); + kfree(ap->folios); kfree(wpa); } @@ -1862,8 +1862,8 @@ static void fuse_writepage_finish(struct fuse_writepage_args *wpa) struct fuse_inode *fi = get_fuse_inode(inode); int i; - for (i = 0; i < ap->num_pages; i++) - fuse_writepage_finish_stat(inode, page_folio(ap->pages[i])); + for (i = 0; i < ap->num_folios; i++) + fuse_writepage_finish_stat(inode, ap->folios[i]); wake_up(&fi->page_waitq); } @@ -1878,7 +1878,8 @@ __acquires(fi->lock) struct fuse_inode *fi = get_fuse_inode(wpa->inode); struct fuse_write_in *inarg = &wpa->ia.write.in; struct fuse_args *args = &wpa->ia.ap.args; - __u64 data_size = wpa->ia.ap.num_pages * PAGE_SIZE; + /* Currently, all folios in FUSE are one page */ + __u64 data_size = wpa->ia.ap.num_folios * PAGE_SIZE; int err; fi->writectr++; @@ -1919,7 +1920,7 @@ __acquires(fi->lock) next = aux->next; aux->next = NULL; fuse_writepage_finish_stat(aux->inode, - page_folio(aux->ia.ap.pages[0])); + aux->ia.ap.folios[0]); fuse_writepage_free(aux); } @@ -1954,11 +1955,11 @@ static struct fuse_writepage_args *fuse_insert_writeback(struct rb_root *root, struct fuse_writepage_args *wpa) { pgoff_t idx_from = wpa->ia.write.in.offset >> PAGE_SHIFT; - pgoff_t idx_to = idx_from + wpa->ia.ap.num_pages - 1; + pgoff_t idx_to = idx_from + wpa->ia.ap.num_folios - 1; struct rb_node **p = &root->rb_node; struct rb_node *parent = NULL; - WARN_ON(!wpa->ia.ap.num_pages); + WARN_ON(!wpa->ia.ap.num_folios); while (*p) { struct fuse_writepage_args *curr; pgoff_t curr_index; @@ -1969,7 +1970,7 @@ static struct fuse_writepage_args *fuse_insert_writeback(struct rb_root *root, WARN_ON(curr->inode != wpa->inode); curr_index = curr->ia.write.in.offset >> PAGE_SHIFT; - if (idx_from >= curr_index + curr->ia.ap.num_pages) + if (idx_from >= curr_index + curr->ia.ap.num_folios) p = &(*p)->rb_right; else if (idx_to < curr_index) p = &(*p)->rb_left; @@ -2101,9 +2102,10 @@ static struct fuse_writepage_args *fuse_writepage_args_alloc(void) wpa = kzalloc(sizeof(*wpa), GFP_NOFS); if (wpa) { ap = &wpa->ia.ap; - ap->num_pages = 0; - ap->pages = fuse_pages_alloc(1, GFP_NOFS, &ap->descs); - if (!ap->pages) { + ap->num_folios = 0; + ap->uses_folios = true; + ap->folios = fuse_folios_alloc(1, GFP_NOFS, &ap->folio_descs); + if (!ap->folios) { kfree(wpa); wpa = NULL; } @@ -2127,16 +2129,16 @@ static void fuse_writepage_add_to_bucket(struct fuse_conn *fc, } static void fuse_writepage_args_page_fill(struct fuse_writepage_args *wpa, struct folio *folio, - struct folio *tmp_folio, uint32_t page_index) + struct folio *tmp_folio, uint32_t folio_index) { struct inode *inode = folio->mapping->host; struct fuse_args_pages *ap = &wpa->ia.ap; folio_copy(tmp_folio, folio); - ap->pages[page_index] = &tmp_folio->page; - ap->descs[page_index].offset = 0; - ap->descs[page_index].length = PAGE_SIZE; + ap->folios[folio_index] = tmp_folio; + ap->folio_descs[folio_index].offset = 0; + ap->folio_descs[folio_index].length = PAGE_SIZE; inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); node_stat_add_folio(tmp_folio, NR_WRITEBACK_TEMP); @@ -2193,7 +2195,7 @@ static int fuse_writepage_locked(struct folio *folio) goto err_writepage_args; ap = &wpa->ia.ap; - ap->num_pages = 1; + ap->num_folios = 1; folio_start_writeback(folio); fuse_writepage_args_page_fill(wpa, folio, tmp_folio, 0); @@ -2221,32 +2223,32 @@ struct fuse_fill_wb_data { struct fuse_writepage_args *wpa; struct fuse_file *ff; struct inode *inode; - struct page **orig_pages; - unsigned int max_pages; + struct folio **orig_folios; + unsigned int max_folios; }; static bool fuse_pages_realloc(struct fuse_fill_wb_data *data) { struct fuse_args_pages *ap = &data->wpa->ia.ap; struct fuse_conn *fc = get_fuse_conn(data->inode); - struct page **pages; - struct fuse_page_desc *descs; - unsigned int npages = min_t(unsigned int, - max_t(unsigned int, data->max_pages * 2, - FUSE_DEFAULT_MAX_PAGES_PER_REQ), + struct folio **folios; + struct fuse_folio_desc *descs; + unsigned int nfolios = min_t(unsigned int, + max_t(unsigned int, data->max_folios * 2, + FUSE_DEFAULT_MAX_PAGES_PER_REQ), fc->max_pages); - WARN_ON(npages <= data->max_pages); + WARN_ON(nfolios <= data->max_folios); - pages = fuse_pages_alloc(npages, GFP_NOFS, &descs); - if (!pages) + folios = fuse_folios_alloc(nfolios, GFP_NOFS, &descs); + if (!folios) return false; - memcpy(pages, ap->pages, sizeof(struct page *) * ap->num_pages); - memcpy(descs, ap->descs, sizeof(struct fuse_page_desc) * ap->num_pages); - kfree(ap->pages); - ap->pages = pages; - ap->descs = descs; - data->max_pages = npages; + memcpy(folios, ap->folios, sizeof(struct folio *) * ap->num_folios); + memcpy(descs, ap->folio_descs, sizeof(struct fuse_folio_desc) * ap->num_folios); + kfree(ap->folios); + ap->folios = folios; + ap->folio_descs = descs; + data->max_folios = nfolios; return true; } @@ -2256,7 +2258,7 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) struct fuse_writepage_args *wpa = data->wpa; struct inode *inode = data->inode; struct fuse_inode *fi = get_fuse_inode(inode); - int num_pages = wpa->ia.ap.num_pages; + int num_folios = wpa->ia.ap.num_folios; int i; spin_lock(&fi->lock); @@ -2264,8 +2266,8 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) fuse_flush_writepages(inode); spin_unlock(&fi->lock); - for (i = 0; i < num_pages; i++) - end_page_writeback(data->orig_pages[i]); + for (i = 0; i < num_folios; i++) + folio_end_writeback(data->orig_folios[i]); } /* @@ -2276,15 +2278,15 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) * swapping the new temp page with the old one. */ static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa, - struct page *page) + struct folio *folio) { struct fuse_inode *fi = get_fuse_inode(new_wpa->inode); struct fuse_writepage_args *tmp; struct fuse_writepage_args *old_wpa; struct fuse_args_pages *new_ap = &new_wpa->ia.ap; - WARN_ON(new_ap->num_pages != 0); - new_ap->num_pages = 1; + WARN_ON(new_ap->num_folios != 0); + new_ap->num_folios = 1; spin_lock(&fi->lock); old_wpa = fuse_insert_writeback(&fi->writepages, new_wpa); @@ -2298,9 +2300,9 @@ static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa, WARN_ON(tmp->inode != new_wpa->inode); curr_index = tmp->ia.write.in.offset >> PAGE_SHIFT; - if (curr_index == page->index) { - WARN_ON(tmp->ia.ap.num_pages != 1); - swap(tmp->ia.ap.pages[0], new_ap->pages[0]); + if (curr_index == folio->index) { + WARN_ON(tmp->ia.ap.num_folios != 1); + swap(tmp->ia.ap.folios[0], new_ap->folios[0]); break; } } @@ -2314,7 +2316,7 @@ static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa, if (tmp) { fuse_writepage_finish_stat(new_wpa->inode, - page_folio(new_ap->pages[0])); + folio); fuse_writepage_free(new_wpa); } @@ -2325,7 +2327,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio, struct fuse_args_pages *ap, struct fuse_fill_wb_data *data) { - WARN_ON(!ap->num_pages); + WARN_ON(!ap->num_folios); /* * Being under writeback is unlikely but possible. For example direct @@ -2337,19 +2339,19 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio, return true; /* Reached max pages */ - if (ap->num_pages == fc->max_pages) + if (ap->num_folios == fc->max_pages) return true; /* Reached max write bytes */ - if ((ap->num_pages + 1) * PAGE_SIZE > fc->max_write) + if ((ap->num_folios + 1) * PAGE_SIZE > fc->max_write) return true; /* Discontinuity */ - if (data->orig_pages[ap->num_pages - 1]->index + 1 != folio_index(folio)) + if (data->orig_folios[ap->num_folios - 1]->index + 1 != folio_index(folio)) return true; /* Need to grow the pages array? If so, did the expansion fail? */ - if (ap->num_pages == data->max_pages && !fuse_pages_realloc(data)) + if (ap->num_folios == data->max_folios && !fuse_pages_realloc(data)) return true; return false; @@ -2393,7 +2395,7 @@ static int fuse_writepages_fill(struct folio *folio, * This is ensured by holding the page lock in page_mkwrite() while * checking fuse_page_is_writeback(). We already hold the page lock * since clear_page_dirty_for_io() and keep it held until we add the - * request to the fi->writepages list and increment ap->num_pages. + * request to the fi->writepages list and increment ap->num_folios. * After this fuse_page_is_writeback() will indicate that the page is * under writeback, so we can release the page lock. */ @@ -2405,13 +2407,13 @@ static int fuse_writepages_fill(struct folio *folio, goto out_unlock; } fuse_file_get(wpa->ia.ff); - data->max_pages = 1; + data->max_folios = 1; ap = &wpa->ia.ap; } folio_start_writeback(folio); - fuse_writepage_args_page_fill(wpa, folio, tmp_folio, ap->num_pages); - data->orig_pages[ap->num_pages] = &folio->page; + fuse_writepage_args_page_fill(wpa, folio, tmp_folio, ap->num_folios); + data->orig_folios[ap->num_folios] = folio; err = 0; if (data->wpa) { @@ -2420,9 +2422,9 @@ static int fuse_writepages_fill(struct folio *folio, * fuse_page_is_writeback(). */ spin_lock(&fi->lock); - ap->num_pages++; + ap->num_folios++; spin_unlock(&fi->lock); - } else if (fuse_writepage_add(wpa, &folio->page)) { + } else if (fuse_writepage_add(wpa, folio)) { data->wpa = wpa; } else { folio_end_writeback(folio); @@ -2454,21 +2456,21 @@ static int fuse_writepages(struct address_space *mapping, data.ff = NULL; err = -ENOMEM; - data.orig_pages = kcalloc(fc->max_pages, - sizeof(struct page *), - GFP_NOFS); - if (!data.orig_pages) + data.orig_folios = kcalloc(fc->max_pages, + sizeof(struct folio *), + GFP_NOFS); + if (!data.orig_folios) goto out; err = write_cache_pages(mapping, wbc, fuse_writepages_fill, &data); if (data.wpa) { - WARN_ON(!data.wpa->ia.ap.num_pages); + WARN_ON(!data.wpa->ia.ap.num_folios); fuse_writepages_send(&data); } if (data.ff) fuse_file_put(data.ff, false); - kfree(data.orig_pages); + kfree(data.orig_folios); out: return err; } From patchwork Thu Oct 24 17:18:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849481 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B8431FDFB0 for ; Thu, 24 Oct 2024 17:21:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790498; cv=none; b=YN+D4auTwtcvJke7swqqOVB0y2+oY78DTd/VmDlppA/Y6o149wXxtbKn5L0aLTTcuL3H3q/wasgITyEc3MP6V+v5mdJi6UdyGhflsGgfLh1lzmhplMIWVRI7OKDcTqtYlnvONSQsHvjzRiFCeJolmzy0ObXGaZzSqlXIrICwB3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790498; c=relaxed/simple; bh=Gu2YSvK2+EbyNYnxZcb7N27GGbib1KlhygWAxajgM9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VWRob9aJ6MGkIP6rJ05b/AqNcwzFR8Wef7SmK3GI4r5+IP7mpZPjtd5RE99ueJ6t+Ou1CqR67jlQJHU8zuEPYMjHSesc0HkjTCnUzrA5WPqVnue9WbC4f0S4Sa7d+33lans/8bBU2+pxilM6HiC9rsVBDtP+OWov7HEIGrXPTGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uog6nR7v; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uog6nR7v" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6e5fadb5e23so10715667b3.3 for ; Thu, 24 Oct 2024 10:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790495; x=1730395295; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r0lb+FlCJ27wc1DnrIwBxhXfE5e/7ONhHuRmNbuyD0I=; b=Uog6nR7vbxqJjC4/Xb/L9lNV2bgZVcuL4IxaI/isZQVdYo2sZOFDLt2Ot2LE+riqfb myFWZ1aFqKJ8z8/PHVVY0xAfJxvvjZVB3JuhPQLTPsulWB+9yf+U7pQgVi9BzPWpuoZA BUmUU5sdI0qf0yp7y8P74qX8hJZZmhy5EwOipyERlHlTPaSMbVEx3FQeWeL2Z+NtuhpJ ysNOJS3n013XUG0F2Ur6AEph3AWOcP9F9TSDut8wnXD54jSvIfKhYvKJzfo9P2Cxm0Os /oxynhf2Nf6UpJ25rbmIn9Fc7caCpoPijkBXT9CZxVMczimQ3PKXNsvvYqZVAaUwX54Q U7mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790495; x=1730395295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r0lb+FlCJ27wc1DnrIwBxhXfE5e/7ONhHuRmNbuyD0I=; b=hGtjJxBiovaZXibxsllVodMMZAe7/cYaOCyQU477T31eOYcb8wOW3EU3u56GQOTu/G mxPaUuDNuKVgCfIxrgTQk82u3CC/Djl36wbL/CSLInwKA+8IQBJjez4d+vks/0+9cHZH sofnHlzRxmE9tIA/nypx/CjYoXu0Ug6ecQ4RVZMOm4aaVo16/Eg0pdFpmQ/B5Vf3jWlI AZJQZhdCziIPQTDp+Jj1ob7Pv4pcqxwu1sd5PgyDzoZkHjAiRbP0FDw7HBEY5APWCr4o plldKk9XsuB+EQ4IJ2HLzyjwo9FcJcpA+mUXHCZUM+megJZIhNCog9c0qFTQONQzDTW6 BQ+w== X-Forwarded-Encrypted: i=1; AJvYcCWo+jQvRYkcNjsLusxulQnB8UDy8oeqwtg0pqYJimzH/1M5rJQt7sE4J4erJ0UyA7oXZnu0HpYLEPH9dFKX@vger.kernel.org X-Gm-Message-State: AOJu0YwMlXSQiXEd7z0Ceq2WEkPwro6gub6BCvieOcjmayCzpfZnj2f4 J30Ax+3i38gu48GDAw9P5HUVNnjVo5Lu8PZlUF1fGk243S7PwSvp X-Google-Smtp-Source: AGHT+IGe5u/RgvzaFz7YeGd/DRqrZg8oBD74lUpxoYrfVjMOAyWJ/6AZ0/w+myAAyZHDUtazFZFZZw== X-Received: by 2002:a05:690c:998c:b0:6e3:a7b:49b3 with SMTP id 00721157ae682-6e86632cf47mr33223247b3.41.1729790495415; Thu, 24 Oct 2024 10:21:35 -0700 (PDT) Received: from localhost (fwdproxy-nha-000.fbsv.net. [2a03:2880:25ff::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f59f5253sm20779387b3.2.2024.10.24.10.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:34 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 11/13] mm/writeback: add folio_mark_dirty_lock() Date: Thu, 24 Oct 2024 10:18:07 -0700 Message-ID: <20241024171809.3142801-12-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a new convenience helper folio_mark_dirty_lock() that grabs the folio lock before calling folio_mark_dirty(). Refactor set_page_dirty_lock() to directly use folio_mark_dirty_lock(). Signed-off-by: Joanne Koong --- include/linux/mm.h | 1 + mm/folio-compat.c | 6 ++++++ mm/page-writeback.c | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ecf63d2b0582..446d7096c48f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2539,6 +2539,7 @@ struct kvec; struct page *get_dump_page(unsigned long addr); bool folio_mark_dirty(struct folio *folio); +bool folio_mark_dirty_lock(struct folio *folio); bool set_page_dirty(struct page *page); int set_page_dirty_lock(struct page *page); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 80746182e9e8..1d1832e2a599 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -52,6 +52,12 @@ bool set_page_dirty(struct page *page) } EXPORT_SYMBOL(set_page_dirty); +int set_page_dirty_lock(struct page *page) +{ + return folio_mark_dirty_lock(page_folio(page)); +} +EXPORT_SYMBOL(set_page_dirty_lock); + bool clear_page_dirty_for_io(struct page *page) { return folio_clear_dirty_for_io(page_folio(page)); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index fcd4c1439cb9..db00a66d8b84 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2914,25 +2914,25 @@ bool folio_mark_dirty(struct folio *folio) EXPORT_SYMBOL(folio_mark_dirty); /* - * set_page_dirty() is racy if the caller has no reference against - * page->mapping->host, and if the page is unlocked. This is because another - * CPU could truncate the page off the mapping and then free the mapping. + * folio_mark_dirty() is racy if the caller has no reference against + * folio->mapping->host, and if the folio is unlocked. This is because another + * CPU could truncate the folio off the mapping and then free the mapping. * - * Usually, the page _is_ locked, or the caller is a user-space process which + * Usually, the folio _is_ locked, or the caller is a user-space process which * holds a reference on the inode by having an open file. * - * In other cases, the page should be locked before running set_page_dirty(). + * In other cases, the folio should be locked before running folio_mark_dirty(). */ -int set_page_dirty_lock(struct page *page) +bool folio_mark_dirty_lock(struct folio *folio) { - int ret; + bool ret; - lock_page(page); - ret = set_page_dirty(page); - unlock_page(page); + folio_lock(folio); + ret = folio_mark_dirty(folio); + folio_unlock(folio); return ret; } -EXPORT_SYMBOL(set_page_dirty_lock); +EXPORT_SYMBOL(folio_mark_dirty_lock); /* * This cancels just the dirty bit on the kernel page itself, it does NOT From patchwork Thu Oct 24 17:18:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849483 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8927D1FEFC2 for ; Thu, 24 Oct 2024 17:21:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790500; cv=none; b=odUN2WxSvn32Cf9+aj/AsMofw+3e6CMjCeIEVovTEbJhoT5DD9WbQ3g5aOYRZkj825OmzA68LV7Dg5sqG15/rE9VfFQdNsMEta6XuJTculg93OezJjYGnSD+RHqSEsJhMdpyZmiBOzV0Y9l9OsaIxuH6kQ1X2F3H4IqaQPZyXz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790500; c=relaxed/simple; bh=1fx4xorTc0SaJnZqDSSJwFVUP5boIwS3BOMlFmZESII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eJhHWcmlYgTeqiqlSv4e3WBWjdKH04qXlIELqxHTxqq1bOKYzjNde6IILc/lSGbt66F90yrnNwfT8tCMXZ64tGiF1g3bjJRfqjlvkqT8cBsQatLQJ7mrTtyCS9FmTCK71T1wgNLhQY/ceMglbVf4VQG1sgmho0Rk8lstLeu8C2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VkzywBSY; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VkzywBSY" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e29267b4dc4so1391426276.0 for ; Thu, 24 Oct 2024 10:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790496; x=1730395296; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S7DCoZ4SSyBWorpQRh2bKORgPIpYfwI01uLP4jAa5/k=; b=VkzywBSY1mcdOcocEmXvSXFOjgMtD9cLLrcHqko8S93hbcKQoKYcS1/rZm86uXxWcM n9b1hGAZ7w/XnOXQTxM0T7+FT3kmq0w5O6RYh0wyMXGuuSB97vIoyT4u/z+Tt3B8f2L8 cd4tqC8geaU1C8fOB0iUlkPt6Q0W6CyZmpREYx8x5n8ZrF9wNjmCgR8EpHVzUpm47LrK 2d6dV/xQLjUXgXcRTCRFZf6Fop3q4dVtOeBsq3GZ8y98ZkgUxBe+ZOQ4PEJDUdRu+OsV E69OoYMY/7nxL3iG6cy9iu4+dcNk2lH0kAERGlN29UMlwAktd3RhYymJERr/REycMx66 rfAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790496; x=1730395296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S7DCoZ4SSyBWorpQRh2bKORgPIpYfwI01uLP4jAa5/k=; b=oaqwqoJb7YjbswjpR1OK+mJegt32EghuTMjktnD5qdNmahCPCV6q/2GpMNCcc8wj+h NC/Lbhtj3B47PUb0cSEJCpprMEUWcr+6nIFb/2biJi8TqplqrIozrYCdCVyiCKF2HxWL vK0H2p6OYx9Hr5iUXLoHNysw4G84C2n4fIwfGl1BGlsASJz+AEZWQM6e3xCK5CdolmBi A3LoAYZkOVUTTvq8JpU6GSztJue9ezZOsHEkU7zFMkNOBaidVBpOxL0Y4GYLHE4RotlW IAFRy3eHoE7gkjOmxs/++nqIcvQBIt54AEBqMxKkLXKcfHZPXALf5efZgABFVwSSWs4l h9Wg== X-Forwarded-Encrypted: i=1; AJvYcCWetPyQYl3uHXgnewxTfLsPe/VwsST1uSPyfFpjTC7dmrHtGWfbGAi88XxpwIFV2zRiQG0z1qMWDi24T2NB@vger.kernel.org X-Gm-Message-State: AOJu0YxS6BNRHITbIOvUwGUX+bP1mv9VugyLyxgLF+fe/Us2mXduHiVE f287+/yW8iCn/7KMWI1tqpywxtE2o6dBPcNGs3uFlcRYNYDh6Mb8zgpnTw== X-Google-Smtp-Source: AGHT+IHZRJDsTNpLMedO62EHqxIReoWTeb2Qqbk7nZ9GO4YFtKjl4gqofq7FFBtkZ8vsdu7eBG2/lQ== X-Received: by 2002:a25:d650:0:b0:e2b:ade5:b925 with SMTP id 3f1490d57ef6-e2e3a6c65dbmr5653381276.43.1729790496315; Thu, 24 Oct 2024 10:21:36 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2bdcaebe52sm1933628276.41.2024.10.24.10.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:35 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 12/13] fuse: convert direct io to use folios Date: Thu, 24 Oct 2024 10:18:08 -0700 Message-ID: <20241024171809.3142801-13-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert direct io requests to use folios instead of pages. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 80 +++++++++++++++++++++--------------------------- fs/fuse/fuse_i.h | 22 ------------- 2 files changed, 35 insertions(+), 67 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 99af3c39e529..14af8c41fc83 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -665,11 +665,11 @@ static void fuse_release_user_pages(struct fuse_args_pages *ap, ssize_t nres, { unsigned int i; - for (i = 0; i < ap->num_pages; i++) { + for (i = 0; i < ap->num_folios; i++) { if (should_dirty) - set_page_dirty_lock(ap->pages[i]); + folio_mark_dirty_lock(ap->folios[i]); if (ap->args.is_pinned) - unpin_user_page(ap->pages[i]); + unpin_folio(ap->folios[i]); } if (nres > 0 && ap->args.invalidate_vmap) @@ -742,24 +742,6 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos) kref_put(&io->refcnt, fuse_io_release); } -static struct fuse_io_args *fuse_io_alloc(struct fuse_io_priv *io, - unsigned int npages) -{ - struct fuse_io_args *ia; - - ia = kzalloc(sizeof(*ia), GFP_KERNEL); - if (ia) { - ia->io = io; - ia->ap.pages = fuse_pages_alloc(npages, GFP_KERNEL, - &ia->ap.descs); - if (!ia->ap.pages) { - kfree(ia); - ia = NULL; - } - } - return ia; -} - static struct fuse_io_args *fuse_io_folios_alloc(struct fuse_io_priv *io, unsigned int nfolios) { @@ -779,12 +761,6 @@ static struct fuse_io_args *fuse_io_folios_alloc(struct fuse_io_priv *io, return ia; } -static void fuse_io_free(struct fuse_io_args *ia) -{ - kfree(ia->ap.pages); - kfree(ia); -} - static void fuse_io_folios_free(struct fuse_io_args *ia) { kfree(ia->ap.folios); @@ -821,7 +797,7 @@ static void fuse_aio_complete_req(struct fuse_mount *fm, struct fuse_args *args, fuse_release_user_pages(&ia->ap, err ?: nres, io->should_dirty); fuse_aio_complete(io, err, pos); - fuse_io_free(ia); + fuse_io_folios_free(ia); } static ssize_t fuse_async_req_send(struct fuse_mount *fm, @@ -1531,6 +1507,7 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, bool use_pages_for_kvec_io) { bool flush_or_invalidate = false; + unsigned int nr_pages = 0; size_t nbytes = 0; /* # bytes already packed in req */ ssize_t ret = 0; @@ -1560,15 +1537,23 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, } } - while (nbytes < *nbytesp && ap->num_pages < max_pages) { - unsigned npages; + /* + * Until there is support for iov_iter_extract_folios(), we have to + * manually extract pages using iov_iter_extract_pages() and then + * copy that to a folios array. + */ + struct page **pages = kzalloc(max_pages * sizeof(struct page *), + GFP_KERNEL); + if (!pages) + return -ENOMEM; + + while (nbytes < *nbytesp && nr_pages < max_pages) { + unsigned nfolios, i; size_t start; - struct page **pt_pages; - pt_pages = &ap->pages[ap->num_pages]; - ret = iov_iter_extract_pages(ii, &pt_pages, + ret = iov_iter_extract_pages(ii, &pages, *nbytesp - nbytes, - max_pages - ap->num_pages, + max_pages - nr_pages, 0, &start); if (ret < 0) break; @@ -1576,15 +1561,20 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, nbytes += ret; ret += start; - npages = DIV_ROUND_UP(ret, PAGE_SIZE); + /* Currently, all folios in FUSE are one page */ + nfolios = DIV_ROUND_UP(ret, PAGE_SIZE); - ap->descs[ap->num_pages].offset = start; - fuse_page_descs_length_init(ap->descs, ap->num_pages, npages); + ap->folio_descs[ap->num_folios].offset = start; + fuse_folio_descs_length_init(ap->folio_descs, ap->num_folios, nfolios); + for (i = 0; i < nfolios; i++) + ap->folios[i + ap->num_folios] = page_folio(pages[i]); - ap->num_pages += npages; - ap->descs[ap->num_pages - 1].length -= + ap->num_folios += nfolios; + ap->folio_descs[ap->num_folios - 1].length -= (PAGE_SIZE - ret) & (PAGE_SIZE - 1); + nr_pages += nfolios; } + kfree(pages); if (write && flush_or_invalidate) flush_kernel_vmap_range(ap->args.vmap_base, nbytes); @@ -1624,14 +1614,14 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, bool fopen_direct_io = ff->open_flags & FOPEN_DIRECT_IO; max_pages = iov_iter_npages(iter, fc->max_pages); - ia = fuse_io_alloc(io, max_pages); + ia = fuse_io_folios_alloc(io, max_pages); if (!ia) return -ENOMEM; if (fopen_direct_io && fc->direct_io_allow_mmap) { res = filemap_write_and_wait_range(mapping, pos, pos + count - 1); if (res) { - fuse_io_free(ia); + fuse_io_folios_free(ia); return res; } } @@ -1646,7 +1636,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, if (fopen_direct_io && write) { res = invalidate_inode_pages2_range(mapping, idx_from, idx_to); if (res) { - fuse_io_free(ia); + fuse_io_folios_free(ia); return res; } } @@ -1673,7 +1663,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, if (!io->async || nres < 0) { fuse_release_user_pages(&ia->ap, nres, io->should_dirty); - fuse_io_free(ia); + fuse_io_folios_free(ia); } ia = NULL; if (nres < 0) { @@ -1692,13 +1682,13 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, } if (count) { max_pages = iov_iter_npages(iter, fc->max_pages); - ia = fuse_io_alloc(io, max_pages); + ia = fuse_io_folios_alloc(io, max_pages); if (!ia) break; } } if (ia) - fuse_io_free(ia); + fuse_io_folios_free(ia); if (res > 0) *ppos = pos; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index c1c7def8ee4b..d26d278da886 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1017,18 +1017,6 @@ static inline bool fuse_is_bad(struct inode *inode) return unlikely(test_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state)); } -static inline struct page **fuse_pages_alloc(unsigned int npages, gfp_t flags, - struct fuse_page_desc **desc) -{ - struct page **pages; - - pages = kzalloc(npages * (sizeof(struct page *) + - sizeof(struct fuse_page_desc)), flags); - *desc = (void *) (pages + npages); - - return pages; -} - static inline struct folio **fuse_folios_alloc(unsigned int nfolios, gfp_t flags, struct fuse_folio_desc **desc) { @@ -1041,16 +1029,6 @@ static inline struct folio **fuse_folios_alloc(unsigned int nfolios, gfp_t flags return folios; } -static inline void fuse_page_descs_length_init(struct fuse_page_desc *descs, - unsigned int index, - unsigned int nr_pages) -{ - int i; - - for (i = index; i < index + nr_pages; i++) - descs[i].length = PAGE_SIZE - descs[i].offset; -} - static inline void fuse_folio_descs_length_init(struct fuse_folio_desc *descs, unsigned int index, unsigned int nr_folios) From patchwork Thu Oct 24 17:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13849484 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 413041FF02F for ; Thu, 24 Oct 2024 17:21:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790501; cv=none; b=klcSEFfBZmWI/NdsH2R5pZdijHY3jD3GgaQ3bL95/NwtkSmqpL3N6S8ZZnR/jpxtZ4Rq0BI2HNJOvfzPAEEoXcKj7lL2t3NPvVwNYbuSfxovjReuXMTUJN7ubcMvsKyGQmO4xN5HTomnath06w+OeClFTSVfZKi4+E/uZ+kEZl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729790501; c=relaxed/simple; bh=BFp33PvH1AHByIGlb/u8bJiihLQLKq4b5Fj8IXPxvF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WvGQIcPwbDFhiyK89HOJ0GqhKsm+qHoJo/zZXIaNUFDw72nhuAUcGDtq1msZK2yXpnaCOnf49v5gSgLiQFtTDzjD4IvrkaViLUGcZHufuFWbvTJLqUQQhWwX6uNzlB/Jvcno34O9UCyqs/7G0v/rkwG3kP6wvkuDT+sCl7x9eKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PbkWVJXX; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PbkWVJXX" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6e8063533b5so12615377b3.1 for ; Thu, 24 Oct 2024 10:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729790497; x=1730395297; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xYZwgSPRFPTiqo+NFL+9REXRMrpVMuOSZaJuhzSDcXs=; b=PbkWVJXX1VeF9NwVQskKplxtCoxoxfXYk3s2yBnO8BUs+6rYRagtyp7gf8ijBZfKBA w24cpABOaaAdIaIHCaIXZf/ZaMQzxqGy4N2yBXzQudILlwNIIm+UrzQ7gMnD56+Vj4WY jR1YG3KOgT8bvsU2jPwNmPxin/gstST9RwKB3rGXVbQ8PRUP8yX2ylourSdSwHuhW57W J63SHuUvO5GtIb2KOBWRw4P2EdCkDDjyIoYTHk9T5HndR8VRu1sAz6MaShHaLIdIneDY aU3Rv6ijRpqR6xPyQSlyrLPBnZ6UzpfTnaO0mg8OYpzRC2PqgmfsOUtsdu+/rJaEb37+ 2kDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729790497; x=1730395297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xYZwgSPRFPTiqo+NFL+9REXRMrpVMuOSZaJuhzSDcXs=; b=M49CW4lus5fhL95VV42ti8j/sHADPwH6fjgMD8tZBqIYt19KgamaeMlwmmYqwCLr5g rSSa+bx2t7d2vVmtaMuyKlL5pz0ZAYlXA4nElFCQzXzn/5LM/Ay03C/t7P2vNsVB8cBx qyCFq/1+7G+RtmxCiA+VUYStzvNTyjplNDjTKdfYnkXSIXAzf4sFYus8a2l0iRD5Y1oZ AjhSs8MxFvQGfp9o69XOJH1BPWLFfW3/E4eX73iDRMWQ360MLyreX5POLtSz0qYufU13 vDOeKRpX44kye+BMl4ITiEMLKq8TFXBT2H+ztDPmwwFfjevylZHnfbue5r18474xzflf vDig== X-Forwarded-Encrypted: i=1; AJvYcCWq3oCjF8d4ib1KZZB5pa81s7LY0e4LEwSppgzdhnAiOGcqyMaa6UUyD1WPcIC+4bDwRnPlN84zRA7T/AUL@vger.kernel.org X-Gm-Message-State: AOJu0Yz05ixCjODs3DANRn6KR+sSKl630lmbbLOpRDtqsxc/11lY0GEP JOWKAxJPZVkiX/AdfpuS8PnkXSv5z8JGZn06UUe/CXjmpV7++eXZ X-Google-Smtp-Source: AGHT+IFIiRP5wFo1QLpmbIQ68brd9+ZRz8TqXEFgQT7DOpA1/wYbP3nLMFEcEL5oW4iXvo6YYmsmAg== X-Received: by 2002:a05:690c:91:b0:6e3:1fbe:9aa8 with SMTP id 00721157ae682-6e7f0df060cmr72071647b3.15.1729790497112; Thu, 24 Oct 2024 10:21:37 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5ad5addsm20805207b3.72.2024.10.24.10.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 10:21:36 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH v3 13/13] fuse: remove pages for requests and exclusively use folios Date: Thu, 24 Oct 2024 10:18:09 -0700 Message-ID: <20241024171809.3142801-14-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241024171809.3142801-1-joannelkoong@gmail.com> References: <20241024171809.3142801-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All fuse requests use folios instead of pages for transferring data. Remove pages from the requests and exclusively use folios. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/cuse.c | 1 - fs/fuse/dev.c | 49 ++++++++--------------- fs/fuse/dir.c | 1 - fs/fuse/file.c | 4 -- fs/fuse/fuse_i.h | 16 ++------ fs/fuse/ioctl.c | 1 - fs/fuse/readdir.c | 1 - fs/fuse/virtio_fs.c | 95 +++++++++++++++++---------------------------- 8 files changed, 56 insertions(+), 112 deletions(-) diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index eed78e303139..ef9fb30b9bdc 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c @@ -460,7 +460,6 @@ static int cuse_send_init(struct cuse_conn *cc) ap->args.out_args[1].size = CUSE_INIT_INFO_MAX; ap->args.out_argvar = true; ap->args.out_pages = true; - ap->uses_folios = true; ap->num_folios = 1; ap->folios = &ia->folio; ap->folio_descs = &ia->desc; diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 9467b05d3d4a..ee698e3ea32f 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1028,41 +1028,27 @@ static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, struct fuse_req *req = cs->req; struct fuse_args_pages *ap = container_of(req->args, typeof(*ap), args); - if (ap->uses_folios) { - for (i = 0; i < ap->num_folios && (nbytes || zeroing); i++) { - int err; - unsigned int offset = ap->folio_descs[i].offset; - unsigned int count = min(nbytes, ap->folio_descs[i].length); - struct page *orig, *pagep; + for (i = 0; i < ap->num_folios && (nbytes || zeroing); i++) { + int err; + unsigned int offset = ap->folio_descs[i].offset; + unsigned int count = min(nbytes, ap->folio_descs[i].length); + struct page *orig, *pagep; - orig = pagep = &ap->folios[i]->page; + orig = pagep = &ap->folios[i]->page; - err = fuse_copy_page(cs, &pagep, offset, count, zeroing); - if (err) - return err; - - nbytes -= count; - - /* - * fuse_copy_page may have moved a page from a pipe - * instead of copying into our given page, so update - * the folios if it was replaced. - */ - if (pagep != orig) - ap->folios[i] = page_folio(pagep); - } - } else { - for (i = 0; i < ap->num_pages && (nbytes || zeroing); i++) { - int err; - unsigned int offset = ap->descs[i].offset; - unsigned int count = min(nbytes, ap->descs[i].length); + err = fuse_copy_page(cs, &pagep, offset, count, zeroing); + if (err) + return err; - err = fuse_copy_page(cs, &ap->pages[i], offset, count, zeroing); - if (err) - return err; + nbytes -= count; - nbytes -= count; - } + /* + * fuse_copy_page may have moved a page from a pipe instead of + * copying into our given page, so update the folios if it was + * replaced. + */ + if (pagep != orig) + ap->folios[i] = page_folio(pagep); } return 0; } @@ -1770,7 +1756,6 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, ap = &ra->ap; ap->folios = (void *) (ra + 1); ap->folio_descs = (void *) (ap->folios + num_pages); - ap->uses_folios = true; args = &ap->args; args->nodeid = outarg->nodeid; diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index a08c532068d0..2661f0cab349 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1590,7 +1590,6 @@ static int fuse_readlink_page(struct inode *inode, struct folio *folio) struct fuse_mount *fm = get_fuse_mount(inode); struct fuse_folio_desc desc = { .length = PAGE_SIZE - 1 }; struct fuse_args_pages ap = { - .uses_folios = true, .num_folios = 1, .folios = &folio, .folio_descs = &desc, diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 14af8c41fc83..070db159ba7b 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -750,7 +750,6 @@ static struct fuse_io_args *fuse_io_folios_alloc(struct fuse_io_priv *io, ia = kzalloc(sizeof(*ia), GFP_KERNEL); if (ia) { ia->io = io; - ia->ap.uses_folios = true; ia->ap.folios = fuse_folios_alloc(nfolios, GFP_KERNEL, &ia->ap.folio_descs); if (!ia->ap.folios) { @@ -880,7 +879,6 @@ static int fuse_do_readfolio(struct file *file, struct folio *folio) struct fuse_io_args ia = { .ap.args.page_zeroing = true, .ap.args.out_pages = true, - .ap.uses_folios = true, .ap.num_folios = 1, .ap.folios = &folio, .ap.folio_descs = &desc, @@ -1318,7 +1316,6 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) unsigned int nr_pages = fuse_wr_pages(pos, iov_iter_count(ii), fc->max_pages); - ap->uses_folios = true; ap->folios = fuse_folios_alloc(nr_pages, GFP_KERNEL, &ap->folio_descs); if (!ap->folios) { err = -ENOMEM; @@ -2093,7 +2090,6 @@ static struct fuse_writepage_args *fuse_writepage_args_alloc(void) if (wpa) { ap = &wpa->ia.ap; ap->num_folios = 0; - ap->uses_folios = true; ap->folios = fuse_folios_alloc(1, GFP_NOFS, &ap->folio_descs); if (!ap->folios) { kfree(wpa); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index d26d278da886..55d371016c97 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -325,19 +325,9 @@ struct fuse_args { struct fuse_args_pages { struct fuse_args args; - union { - struct { - struct page **pages; - struct fuse_page_desc *descs; - unsigned int num_pages; - }; - struct { - struct folio **folios; - struct fuse_folio_desc *folio_descs; - unsigned int num_folios; - }; - }; - bool uses_folios; + struct folio **folios; + unsigned int num_folios; + struct fuse_folio_desc *folio_descs; }; struct fuse_release_args { diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c index 1c77d8a27950..28138c838d49 100644 --- a/fs/fuse/ioctl.c +++ b/fs/fuse/ioctl.c @@ -306,7 +306,6 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, err = -ENOMEM; if (max_pages > fm->fc->max_pages) goto out; - ap.uses_folios = true; while (ap.num_folios < max_pages) { ap.folios[ap.num_folios] = folio_alloc(GFP_KERNEL | __GFP_HIGHMEM, 0); if (!ap.folios[ap.num_folios]) diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index fd0eff1b9f2d..aeb5ea534c96 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -346,7 +346,6 @@ static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx) plus = fuse_use_readdirplus(inode, ctx); ap->args.out_pages = true; - ap->uses_folios = true; ap->num_folios = 1; ap->folios = &folio; ap->folio_descs = &desc; diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 9f0d98cc20d3..b8d31a93f2d6 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -765,7 +765,6 @@ static void virtio_fs_request_complete(struct fuse_req *req, struct fuse_args *args; struct fuse_args_pages *ap; unsigned int len, i, thislen; - struct page *page; struct folio *folio; /* @@ -778,29 +777,15 @@ static void virtio_fs_request_complete(struct fuse_req *req, if (args->out_pages && args->page_zeroing) { len = args->out_args[args->out_numargs - 1].size; ap = container_of(args, typeof(*ap), args); - if (ap->uses_folios) { - for (i = 0; i < ap->num_folios; i++) { - thislen = ap->folio_descs[i].length; - if (len < thislen) { - WARN_ON(ap->folio_descs[i].offset); - folio = ap->folios[i]; - folio_zero_segment(folio, len, thislen); - len = 0; - } else { - len -= thislen; - } - } - } else { - for (i = 0; i < ap->num_pages; i++) { - thislen = ap->descs[i].length; - if (len < thislen) { - WARN_ON(ap->descs[i].offset); - page = ap->pages[i]; - zero_user_segment(page, len, thislen); - len = 0; - } else { - len -= thislen; - } + for (i = 0; i < ap->num_folios; i++) { + thislen = ap->folio_descs[i].length; + if (len < thislen) { + WARN_ON(ap->folio_descs[i].offset); + folio = ap->folios[i]; + folio_zero_segment(folio, len, thislen); + len = 0; + } else { + len -= thislen; } } } @@ -1287,22 +1272,16 @@ static void virtio_fs_send_interrupt(struct fuse_iqueue *fiq, struct fuse_req *r } /* Count number of scatter-gather elements required */ -static unsigned int sg_count_fuse_pages(struct fuse_args_pages *ap, - unsigned int total_len) +static unsigned int sg_count_fuse_folios(struct fuse_folio_desc *folio_descs, + unsigned int num_folios, + unsigned int total_len) { unsigned int i; unsigned int this_len; - if (ap->uses_folios) { - for (i = 0; i < ap->num_folios && total_len; i++) { - this_len = min(ap->folio_descs[i].length, total_len); - total_len -= this_len; - } - } else { - for (i = 0; i < ap->num_pages && total_len; i++) { - this_len = min(ap->descs[i].length, total_len); - total_len -= this_len; - } + for (i = 0; i < num_folios && total_len; i++) { + this_len = min(folio_descs[i].length, total_len); + total_len -= this_len; } return i; @@ -1320,7 +1299,8 @@ static unsigned int sg_count_fuse_req(struct fuse_req *req) if (args->in_pages) { size = args->in_args[args->in_numargs - 1].size; - total_sgs += sg_count_fuse_pages(ap, size); + total_sgs += sg_count_fuse_folios(ap->folio_descs, ap->num_folios, + size); } if (!test_bit(FR_ISREPLY, &req->flags)) @@ -1333,35 +1313,29 @@ static unsigned int sg_count_fuse_req(struct fuse_req *req) if (args->out_pages) { size = args->out_args[args->out_numargs - 1].size; - total_sgs += sg_count_fuse_pages(ap, size); + total_sgs += sg_count_fuse_folios(ap->folio_descs, ap->num_folios, + size); } return total_sgs; } -/* Add pages/folios to scatter-gather list and return number of elements used */ -static unsigned int sg_init_fuse_pages(struct scatterlist *sg, - struct fuse_args_pages *ap, - unsigned int total_len) +/* Add folios to scatter-gather list and return number of elements used */ +static unsigned int sg_init_fuse_folios(struct scatterlist *sg, + struct folio **folios, + struct fuse_folio_desc *folio_descs, + unsigned int num_folios, + unsigned int total_len) { unsigned int i; unsigned int this_len; - if (ap->uses_folios) { - for (i = 0; i < ap->num_folios && total_len; i++) { - sg_init_table(&sg[i], 1); - this_len = min(ap->folio_descs[i].length, total_len); - sg_set_folio(&sg[i], ap->folios[i], this_len, - ap->folio_descs[i].offset); - total_len -= this_len; - } - } else { - for (i = 0; i < ap->num_pages && total_len; i++) { - sg_init_table(&sg[i], 1); - this_len = min(ap->descs[i].length, total_len); - sg_set_page(&sg[i], ap->pages[i], this_len, ap->descs[i].offset); - total_len -= this_len; - } + for (i = 0; i < num_folios && total_len; i++) { + sg_init_table(&sg[i], 1); + this_len = min(folio_descs[i].length, total_len); + sg_set_folio(&sg[i], folios[i], this_len, + folio_descs[i].offset); + total_len -= this_len; } return i; @@ -1385,8 +1359,11 @@ static unsigned int sg_init_fuse_args(struct scatterlist *sg, sg_init_one(&sg[total_sgs++], argbuf, len); if (argpages) - total_sgs += sg_init_fuse_pages(&sg[total_sgs], ap, - args[numargs - 1].size); + total_sgs += sg_init_fuse_folios(&sg[total_sgs], + ap->folios, + ap->folio_descs, + ap->num_folios, + args[numargs - 1].size); if (len_used) *len_used = len;