From patchwork Tue Oct 22 18:54:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846036 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.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 7AC441CC156 for ; Tue, 22 Oct 2024 18:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623292; cv=none; b=U+o9uqIdUKsQWu8FCOs09Bp9onxwqSTzpqX01J4oh20xeuajBcnEPekJz5XxmhWE+3fGVYnkBtmICP6iaZ67BT2sLAvCF253/C0VCy2DMXWt8XN+xbbVyj8TpnQwD6ry7aHNGGfGNHeX6j+IvjFUDowQF9vJFFq3q13a1Xhbvnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623292; c=relaxed/simple; bh=F+ufyoJY3zog6/A38PhsTPOv6+lHASYgyIXe4rfC0b8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JHYs1FOMle7e8YpJDFWTCKRiBqRYty8npxHOeaWMbbrSgdClIgGlDJom4plYuIZyOws2/FSPoQvqZVfAAg+nOoRJY0wy7xQgBFV3Rn8oGo/Jm/bfJJdv0fZwBGZ4vj8SzmkBO2dR4iGnZ0flH2cq9jABgWOZYEVTJa+3Uq/xoKY= 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=S0oOjBe7; arc=none smtp.client-ip=209.85.219.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="S0oOjBe7" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e29687f4cc6so5994170276.2 for ; Tue, 22 Oct 2024 11:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623289; x=1730228089; 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=S0oOjBe7nGyJkJ7zCWgx4WUT5j1i/BqLx+JIBj1qq0i1oiAyh+AlnG+diymUzFxbHX Yp3k0fP+LpnRcBVvVtdpyOBthIifta4wO4C/ii2h01SfisLnsCsiopF11NmwqTk7eO42 51UF4yFR3NsYVXexeZVwFrbuWwnFsC1xv2IzY1dCmlYFEmMzvkKqEmPgRbaxjsKqUkkG MBdrgBhz3c8XnW7enSq5yNJ38ADGOay8hEKMUPfhuU+Jbk55pRIhU5vMAVJk4UyAaoYG PhsLFlQBDAnKkicsnaZSzNLHuOWWr4OJ/D1YE9F+qikdtizrmpIahLq+B/g08dxby39Z pDUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623289; x=1730228089; 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=ZLLQig3Kp3mENWXSM8/4jyFbgFOlcP5erU/sKQm6Z6VCoarh9smxAl9l5wmAvgvGDs 5Zjdd1gqKE3tX0ti7YktbC50uOQg7vzYfua1yRveuhW5LxqSSgp0Nukj3/Q6/Z6qyZGx JcZUqO9Yrg3FZ21NgFNS7rdroLIiX5xQM7z6er7OMuCI0cn4LROnaTQe4CSJEKNgTvLq N3Bi2v3+Jpy7euX5gnWallKIkRUXQt3ESvHOgdmHERnWR8kJeFalYfB7h/G90yna5Uq7 amLu5KLoNDW5s0ylP+TzAoQEPjlm4Ww6K0nrfOSohygxcSceTbkAdqim2YS7NmkZTC7v N/6g== X-Forwarded-Encrypted: i=1; AJvYcCUHqLUfE9bAIbFCv9k2cy48Hja2Yxk5Rlj8YyXwTgDZvhTys3fRI6Aeed5kfxxbaG0gj36RfF6Cp7ShZ9aK@vger.kernel.org X-Gm-Message-State: AOJu0YywEyUos2cQ/+RexmiNNLqeSEmAKU0yFpx/+Cb4EyOj4o9YNVTG xUOLDVB94KMHXeQUoeWxeFKWcNOmS0iq7c6L/TjNyzCd3UG9ag+N X-Google-Smtp-Source: AGHT+IGlE8CaOqpzvTqpapoVslrX/xw+jMhcqaZ6FMqg8l7S4HBKizryv/wDNe9Qw58FijoHO72xRQ== X-Received: by 2002:a05:6902:1b8e:b0:e29:6c21:20b2 with SMTP id 3f1490d57ef6-e2e3941b098mr424726276.47.1729623289565; Tue, 22 Oct 2024 11:54:49 -0700 (PDT) Received: from localhost (fwdproxy-nha-013.fbsv.net. [2a03:2880:25ff:d::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2e312b9971sm260717276.34.2024.10.22.11.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:49 -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 v2 01/13] fuse: support folios in struct fuse_args_pages and fuse_copy_pages() Date: Tue, 22 Oct 2024 11:54:31 -0700 Message-ID: <20241022185443.1891563-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846037 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 5D3171CC164 for ; Tue, 22 Oct 2024 18:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623293; cv=none; b=IlOmfZpP8ppIMcl1WFWkp8zWI4BwnhDSdYWt0W7BS9S0MVSBkuf7WvuXixCoyfOj9USpLqQDfMExxOgGNZ9LQDQ4KoAnRmwIg/9WhnbjoOO212cKgMrrGNKToFdLqunHYrB8lxnXTpeYrZaWUCBV/3N1Xb72G3F/rtvI5nrxODs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623293; c=relaxed/simple; bh=aCBS0E8uI/g2bfKdlxec+OEaLI9quKfamNOOdj4G1rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O5XTIJXbNavY+As3NBW4ufXuycTLMz75zY9KYH7y4ZDo6WwcBKde0Nw/0tNw8E0j7ZgJeJ9KLWhjqoEgLls7pEE5omkM3pfRmwDU8+jyF6YT6QT6EW76Y60IHrYak4VqS/eTcUCVaeamnb+jw5GGIXjKND2tuKZWizEJToZ6dnM= 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=ckwSqXmG; arc=none smtp.client-ip=209.85.128.177 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="ckwSqXmG" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-6e34339d41bso53021027b3.0 for ; Tue, 22 Oct 2024 11:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623290; x=1730228090; 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=ckwSqXmG8iVZGQnoYVvct4XAXkIm85o5bM8vP4GHPr1QewLNJFE/Qt8Wz8zTLFz0WT /6Iz/0Eh/xxKlc51dNw7oVlC6Eh/IFS3/Ya9XVRTMTucIcG36QjSrcT+O/heBNGQ5e+L tWSCXObxevEpo07rSwf3vMADpmx9YtdA+0Qn3BkZy2iFHh6PrkN0GxxfW22aPDuldp6F 0zjOvxqLSZvZsIkuU21JIwoYjYNPaC0exCrK2n4QzrIZEreY84dEydtTN6VjbIvczcek 374MKXOe53Y5z/kl8AF2c4uPjYVKzdWFoIaAmPB6TJtQYmbZghZsfIOafIS1FfmWc8E+ WU/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623290; x=1730228090; 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=PVKaZzy02nubV2OmzHkhKaabunTq0fKrxQz3sY3wem6Xnrab05azxRR/sJI+oxxldx 5rytiXCEvlTWQMYpsfSB3Psm+Mz6pLWLZbGjl6SOl8rmUjyyTrywXd+0qfBjcZWWWTHP YDo89veg39yssJFk2aeFZQyTGss0SR/C4eCKSqOjg8xc/G5CA7nTVs6AaG/oxd5vobvK 0u8wZoCW4saUWQDFd6SqowZhwmyEFDduVrgAJYgZfyTq3jNfv5V+VFs7auh8tj5pCHWc p5qJzhyL2t2xizKlng10w+J8zn9FifYAFJV82Mtx+L3mX5CRJgmx1NJq2wEC3LxQ32dp 77zw== X-Forwarded-Encrypted: i=1; AJvYcCUO+dFXKbmPXeoWkgP1nCNa5JDnFv2I6vePyHKXKIFFM0v4cj7jtDZyDcZUQ4WHMgGIciicx/vwvyB1rxnL@vger.kernel.org X-Gm-Message-State: AOJu0YxNWMa7gFoxmKyRbAwdM7OqcBZtEOIZ0MaRtRWZWRlpcya8sscu zMgNIjvDAzmB/lmisKDX2SkiPPQm6Y/yNmW01I3EZenEh6YJlN9S X-Google-Smtp-Source: AGHT+IF5LXW4xHNU3PRuNVFjdFWJZcu9Fkq+OcytC94wHPYg19OgOXAo4NhbAuBl4II/C/vw184k+Q== X-Received: by 2002:a05:690c:d91:b0:6e2:ef1:2558 with SMTP id 00721157ae682-6e7f0dafa1amr68597b3.8.1729623290308; Tue, 22 Oct 2024 11:54:50 -0700 (PDT) Received: from localhost (fwdproxy-nha-004.fbsv.net. [2a03:2880:25ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5ad5a1asm11769207b3.69.2024.10.22.11.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:49 -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 v2 02/13] fuse: add support in virtio for requests using folios Date: Tue, 22 Oct 2024 11:54:32 -0700 Message-ID: <20241022185443.1891563-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846038 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 1674A1CB312 for ; Tue, 22 Oct 2024 18:54:51 +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=1729623293; cv=none; b=u4BLXUDk7oPUUSO1zoOmpOsbnaOkoUBfFcmngyOFPKPZ4dPZJPkcz2Ut3dEAJFe61jXHYloPGa2+LX0bgONQwWx9wMuOr+wqfzOJThjYsv4JPTzX6QQxDdo5mGDIQZM9WNuaM9tfKgkKPM2kEaVsdF9OZrz15Mypizvxq9Tyryc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623293; c=relaxed/simple; bh=ioEojwyjzo508/cf3Oxu/mg0XMx+FgQ2Ivxxr+uviBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fb2PDRnHGRQIP3HVanpMqdL6KpVYqdHpJGvX6jrbbwnKFFGB7oUQwFU2T3+jmsGqwD8rh96otIMaDBeOjHCkif+VocdCeWbVS08D/kyu+jrwpxpBwn/kGyLthWtnTPtmFYqDJhvdBiK0bhB5tOnqFDFB7Tn1twgbfYaPJHlXnAM= 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=a0OwIpit; 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="a0OwIpit" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6e3c3da5bcdso62068087b3.2 for ; Tue, 22 Oct 2024 11:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623291; x=1730228091; 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=a0OwIpitpWVL5+a/RcMpTcaXMNzUz7UbB5SA/XWI2d6jiFHFoba9IwykkdbtoLgws1 h5FAx9r+uJPeJQhxG6eVaJLNhgTVFgTOHFH8yhh57iYE24stzs1V/LhU4oIdfaNMeWmL nfAtCFVaGu/x9R0bbgdWDNqnBucdWyFaK2F1fgqBh3ryIUke53+GeSFh4OyTARXNOhsh RhaBWeCf+PFhAzn8j4fNLjzCC18ki45JbE2YQB3g8iLBQaa3vBLw5kD2mLfakhROX2C7 SVqqQBzAjEC1NFJlNRagEhsBKlNogsU3Rwa/QfFo8YHfhviBp11ZmO5gTz3Jn7W4drOW SIIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623291; x=1730228091; 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=UzCL/E68Eth/mv9zQ/gJN8LvaXnHb+67dRaZY2WSoOXdWQGiOyO9e47iPUwLgSF72E 9kDdrn0xrXL4TSwBM6eVdKkkOlfJAkM500T7DeBeYk9ok+8vIHpE3iQKEqsJd/F9t2Ps FxK4DvH0g+4+efXOVBkbrX5cUp6bbPw/pQsZSAUVnBiolibL/BVJD3nRjWNlQAzZoxFM xKLCUkSjPzGG/UvfZVFqSMSuB+xTND3gZbOFYqG4ZGw7lq9cB15Xq43I64y56pYm+R+I x0hw29ITZ11Eowf+4cQGaF0XzXGU7ow6PYrCNFpqbH7Zreh66Qysn+vc4j1MC0LgaRh9 Cp1Q== X-Forwarded-Encrypted: i=1; AJvYcCWe4EprIJrCTEHlR6rLZHhNMgcNmy7egKH4v8zyqRJ9nHsuSLMC2zoof291vM52ofcSy7FKc7g6lEEvm65i@vger.kernel.org X-Gm-Message-State: AOJu0Yzhe4sugebtA4jHJeVRHy6irXr5dND57xFpaKva7DwsLB83U/Ee TXTRFWqNQz2fdcsWzhZJrwUDmEHRhNWfH6Bm0t64xwnOGf7uLTCO X-Google-Smtp-Source: AGHT+IHoE6Ik16UyhS67czcAR6kSjqAFuwdYbLlmUFuj78r8HwbzvQI0EeWnoGKHsZyjPrCs3nQJRQ== X-Received: by 2002:a05:690c:91:b0:6e3:d4e3:b9b7 with SMTP id 00721157ae682-6e7d3b8455bmr40723897b3.35.1729623291025; Tue, 22 Oct 2024 11:54:51 -0700 (PDT) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5a4f403sm11938047b3.41.2024.10.22.11.54.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:50 -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 v2 03/13] fuse: convert cuse to use folios Date: Tue, 22 Oct 2024 11:54:33 -0700 Message-ID: <20241022185443.1891563-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846039 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (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 B584E1CB314 for ; Tue, 22 Oct 2024 18:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623294; cv=none; b=gzIOiUCxhfGLANo0qQWXkt/T6NEAr8RHqoO+LMFoWAucXjVH1NqItBC5GWbixFYxl0ivzhBgsYWzvG59Bh8XOgXipd3obLKrhECbCa+jrw/Me/Zk/I9YXvbag3tm3UtaaH46lx2AZEeA4xVNrDvtBit7fbjuVvWVdI1ad8lK4HI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623294; c=relaxed/simple; bh=C+ZFmBhkWJBEUf+QVYPJlux2aWYUCRl3Cvoa6yedOko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i83BPxWuBDRz5JF+UI6Eq9yD0iwD6Qgq0HnSQVNBqqi5pctI5jUrz64S8EEzIZngpAh3ckA3jJ7XpuTXzi9Y4WUX9sEhhOkXiA8pAFz4R6tRKgghwq7amZnnXwoakueQfU5lzf+8TWevjGH1+sMZYSSUrgrIs5Lw+1p5Lp5/gUU= 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=PAVRwRJT; arc=none smtp.client-ip=209.85.219.175 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="PAVRwRJT" Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e0875f1e9edso5598178276.1 for ; Tue, 22 Oct 2024 11:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623292; x=1730228092; 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=PAVRwRJTKA1wT2hXBbNDAsI6rkzLbAIY4zGRkzmD5ZyDqk7oIDE7cOhixZ7sDIpSDF Nkd0E1JGNlxgnieg2MQzeK3PQNheBGetSmpcvMVtcb/iSoNgA3HzJLmviN9B26CpvBM2 EMEgQD1V2dabr+h8i0BHuo1UQtIYRtJiGnlu7ecuZsRKO4DZHy5cDePBWw2EEYYUeOpK llDIzlV37/qGAE5pWuAMutWomVoTWprxXrptqkNLGx3wMXqONiHl6/RTwilVMuL+6QDt qpVPt0KPkQnXZ9TOlbGGiFxFcCDLpGMjYxz6iizbv96uziITr16XoqfqQ99qd14/V1oU sCvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623292; x=1730228092; 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=kDfULeMeMP9HexMr/62TpC0Y+SKKai4DGlR6a4Epgzcxy7R4V90cr7cCDSPndSEZQh 7FUSlc7e9kvimsrqVkOAgYncsgHpC3X0tKpKU8Ob/tzznJ8MM7+CccnUq6ZY1WP7nqK2 kISDvXrl63Yl6eN1m9skp4X2ST4ZJg6MHmXmGrP4MrHVF0rPOnM9FjXQWqn/o1qHhrsV R4BLN45O28iz3zPGPCPou2aDD4fSTAPoHg9JP0L8EZStMrFC6CiexSLvObgKP38RaF4h 2vEl1I8cF6NWNcPmqGoE9X3pzQvC8UB++8iRRZvldajZTtkBB84Tr35i2tPcI+Zs9cPS DGPA== X-Forwarded-Encrypted: i=1; AJvYcCVlm4xlq8c7L6RMSwA0egYlqpRBxzEZnvjStTarH+DTjIu2Xtem7+nS02U3ZEmQUf86zJnfWXpJRqRo2/xn@vger.kernel.org X-Gm-Message-State: AOJu0YwjpJqqXA66novF5585FMhMRYQ2TyTc5ZwBSVMfXLpkLu6zwAQk NR2po3F9ATY2Pbi7yECgktcG3wl07RxfCquv3RwrC4HubxmhU8wA X-Google-Smtp-Source: AGHT+IG+7gSMFOK9CQ/jO3/Pibyz7Yob/FT/njYkIS/TedfRR9WjtlE7VkNGzyQkp3i7pHosha41gw== X-Received: by 2002:a05:6902:154b:b0:e28:fc3f:b818 with SMTP id 3f1490d57ef6-e2bb12efd0amr14833443276.18.1729623291726; Tue, 22 Oct 2024 11:54:51 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2bdc9b61b4sm1154345276.37.2024.10.22.11.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:51 -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 v2 04/13] fuse: convert readlink to use folios Date: Tue, 22 Oct 2024 11:54:34 -0700 Message-ID: <20241022185443.1891563-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846040 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 5CDD71CC89B for ; Tue, 22 Oct 2024 18:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623294; cv=none; b=RKf54RYVNSDC0nWgbfMFoMOrFnIBuXs8ZK+8JsfqEeFscNuMcCqOJLnyFZxe7nBYdAzr0a9FeOF3pZOPfbxZRLc04sivTtq/SukfNQ9DYLXte3ddPZJHim7KyL2fi60x9Ntxiz7/4pKJDwZlgvP4qd2NfMg346Pv0TEFIU/T+yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623294; c=relaxed/simple; bh=mXnBpqKiRVmhwxcDZZR85Sp7SEzxNvCFukeXW0p4gvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eJ5WlqLhBKILQ1058b+i6Jih4JV8LGnk3Z6fMB8uDxzdiqq0vE2F2ZsWiz9ltfMSqvZ9ot5nloz1KjYe2jl3DedkIlL4U3RDloUdjSgTrCmDQCthv/qg+kWmmWpTDAwDbsW8msvA01a24Z6bdRSOOuwyoFJb0SNtM9dEdRUbZbE= 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=ZfpnnO9W; arc=none smtp.client-ip=209.85.128.179 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="ZfpnnO9W" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6e35fb3792eso59921507b3.3 for ; Tue, 22 Oct 2024 11:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623292; x=1730228092; 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=ZfpnnO9W2CswWEg7EgV378e0fHwgI3NlRXbEljqpgG0lLt8jV/xeCVH51SS323LS1I jGqryk2ALCbmhIHAQDwj4GIks6k2FUnS0OQ1dEYyyIx/Rpvkdwdwe2FIe9JRk0FEcObe Ifye7Nyw4k2O/i3YtNmgMUfyfOIQ7FaF7UcMwY54uNC02QXSq84tn/X1GgWLNeVRFWOI nV5RZ4ZvIOuEI0v3bI7nAzm5XfMENub4ilaor2G6OcR+85xV5M0hYVC7xNXOQBV8/mxa NsEuiWnBkOyr6pMt14AarY3WXjPsDp/gJQg5Ccpwdjnf+taIFJgRIMNCO3oTLkT8qWSh Ef5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623292; x=1730228092; 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=OPndBTJ9I5eOIoS3b80ldlgL3dUS0idDrTCNr4d1cZ6CvaJOi+NNcOPGEipuunjL8M 3l6jKNq0QhfLr4MtX4bgAYzN5lsPBNoava1oFDruBXO3M0dFh2WIvUahg0tQrkD8jEEe mkjIll24lGBDO4VeO7aaLiNBtEjbtqw/xrz8IYdxBP+FprZRgpEzgnkG2O9v0wDh8/9f yiZAD95yZQ+d2Zyx66GQq1yo3zyGRhsDpuHuMUWP1uNaOGddSxj67uE/OkoOWVs4Uyqm J+nnq+Schi+hkcAf3PKZTtZCf8pVxMuDoWZYUSy/fRwukMnvVDuWR+Ayr0OYaWb8XBAV 6kIg== X-Forwarded-Encrypted: i=1; AJvYcCVPNkVhLZ4vr+5aaWKkiOOp8xZYTDd/rS7Y6UuliYFDEvld6oMCH5LmYcNeW9fP0j84bI0FVipqS7LrlLip@vger.kernel.org X-Gm-Message-State: AOJu0YxjOEqKBPkyYUdx3uNtW9dKa7mc5KpgqeIF6taTIm5FDPQJaTh8 fed7vWpYxWaHvbf0cB+Wh+bvyQL1Ke60kiUk+472Z07K2atzJmMq X-Google-Smtp-Source: AGHT+IGV1qIMbsGFxDVCESmRaqZCUr211s2OD6byOXEHMtcMWha6rmFEpfUCQL1laIDIUJyDTK53mA== X-Received: by 2002:a05:690c:6a02:b0:6db:c847:c8c5 with SMTP id 00721157ae682-6e7f0e3ea38mr34867b3.16.1729623292310; Tue, 22 Oct 2024 11:54:52 -0700 (PDT) Received: from localhost (fwdproxy-nha-000.fbsv.net. [2a03:2880:25ff::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e7e06fe05esm3309177b3.12.2024.10.22.11.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:52 -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 v2 05/13] fuse: convert readdir to use folios Date: Tue, 22 Oct 2024 11:54:35 -0700 Message-ID: <20241022185443.1891563-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846041 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.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 3056A1CCB27 for ; Tue, 22 Oct 2024 18:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623295; cv=none; b=myl4qmrQmhT+k+KJJW9MetzlGWCDzi0wm5SiEEj4EQuLP5KGyU7DQHPKBucE9qZn6oXIPUQQ6XnN+b+VA0AYTNd0CkwypKmjF/aMwxnqqQNcw5NuUnNX+GRjiH3vnW4TmCIydTURSnxAzUgdeYYEOvjPJZWjjQqYPhnfUSak2XY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623295; c=relaxed/simple; bh=+GvzxVcw3NR96WLeKClotYmjGsPHcyFUD/PGVHN4+aM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNMGXrNwefqOFMC375oFIPA0JMEPJHAXYQ3ET3wDiXrE0I/qvSwhFVpDsjVRC36LX89U6W2EvT+TiIQH71DPUVlZHtDXiCy7QPl0fUT/f9x0xO8NtmWQNJz4f++PNGvVu0jmJ1umZ2fJz5Nqgu4jST8/sr/4M1By3nOoFUHWgBU= 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=Jzpb6eGr; arc=none smtp.client-ip=209.85.128.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="Jzpb6eGr" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6e35fb3792eso59921687b3.3 for ; Tue, 22 Oct 2024 11:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623293; x=1730228093; 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=Jzpb6eGrR8GARQjbqCe3OVm76+W5vRu7RlU13rSywRfZPK3JWHui+LN3P6QV9C+ERZ Eyc2NilERxD4EcM4QLLvMOY/A7gYRDzyPaxJ3v/JM7QwrCX4Wc8Ui9t+3o2vJ3JdBj2N l5uXdVYWB9KM9FZv4lLdcbakty3KXUyxAj/h4DuS7lsYeLZPQ3OTJU//d4+/Bzts5G33 NmI/SjkEBpILi5TaD8Z2RSSQ6w8W9IPK6WFoussXIe05keZB7w9RXVq7NhFBfPQgg/lY NgxSoJLSPZmk4Djy8qNFUR/s8ps8Ti8Z9HSJpL2BOheZK/wU53Ad1Bnx1yY5lrKgQo7J 7f4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623293; x=1730228093; 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=C3j6zvsd1jqk38X7pZ/Zi58q9FHaZI7bK4w3ZOgIK9pVe6mRK5nNtJqPtZWuoHMxxi F2E4VnSF84CgWUToSl8ZH5YoIVBRDY/5vcSvqqDR7qZLzUwNmDFgPd+cSA3pmz5KrBFp DipnjGSLIx0E7jrfotL+iVz4pUdGNqMI6ooca5L8Udzss8R5B6IZqDCD4ZuqBvlNd4BN VKK2ujNa1tRLtwaR0HogdMJcBCgYecyjwQRfMQs8zRsMK8QLvGP1Q9fSIXkTWyXu4cqw 6199U3pHECi4Ja2T5nXzpxeByyE8SAowM79XTEJ76aNjrDhrwDSOBsqe/whveytp+TyA /mng== X-Forwarded-Encrypted: i=1; AJvYcCVXbnNRgya4zDh35II/ERcBYXyKf/KIpe0iEtyvbg02K0vlAX4aq8npKVY5DXhy6QNmSVrVJ2vpe8iHbMFu@vger.kernel.org X-Gm-Message-State: AOJu0YzprmV1tqYEsE9NLklzrOSVXrHoJJMB9zvUgZqN0iiLNOsYrsqR At9ZBFCsqs8RkCktodqfaZGI3O1YJF3YsrXPvFQZ8WD55rCajm1n X-Google-Smtp-Source: AGHT+IFXoj6baa3pwEncAmMRhxRhXyRQxc6cxP/4y2TRGRBge3Vn+a86u/KZ0URtSSDoDzpC4sKMUg== X-Received: by 2002:a05:690c:39b:b0:6e2:83d:dfb4 with SMTP id 00721157ae682-6e7d3b845a8mr38595567b3.34.1729623293104; Tue, 22 Oct 2024 11:54:53 -0700 (PDT) Received: from localhost (fwdproxy-nha-001.fbsv.net. [2a03:2880:25ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5ccb641sm11920837b3.83.2024.10.22.11.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:52 -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 v2 06/13] fuse: convert reads to use folios Date: Tue, 22 Oct 2024 11:54:36 -0700 Message-ID: <20241022185443.1891563-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846042 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 0C6A81CB31C for ; Tue, 22 Oct 2024 18:54:54 +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=1729623296; cv=none; b=EZW4kgVsov5Dl+u4y75qgIz4AeAradRO4Eq2tAna1Bb+AuekYq06yobPCu8NMwhjPhhIuQOe3f9I51DoqZrU6+kedEeEFq8pmz+pv6+i/5d8EE5CIc/jkFA6vt+dhor6mv/vaOcyeheNE+K2nsSsGISpAeX7ho+Prw0LkLK19sY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623296; c=relaxed/simple; bh=4MEV22g4XjsggbYOYj2TugUOdvoBUWfpcLG9LT8sZss=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ssYqIgA4K5pUc5K0Tuiw4ROqnxMm8yE5Tm8cUzzENRFf2/+hxzUe38HpG1JVU8FpFzHep/4LLZ7RX4aRzhLTI4QTVJByg23Pk7B9k3AXayDz19vQXAYOHPtAx160SaOvrs8Aq8LzLefaooXMX9G2PSwYl6JdlXm6SLxgYI2ZDk0= 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=RLWq3Ods; 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="RLWq3Ods" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-6e3a97a6010so69923687b3.1 for ; Tue, 22 Oct 2024 11:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623294; x=1730228094; 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=RLWq3OdsDGqK9B2NI17QJ4yIOnUx8uXsv7ORpvNwO6OMxR8lwlkkweCYjNo/tpaMiW F8A8u6W7UVGgQUHsv+0ZzR9VTHtP3ZTxqr1r/jvZ7M23QvhfUbnn+EOrZWHHsmG9SoW2 8jH9JfMT6vOczV7qvd4I7zwvaIpLuZZc5VLdO7UmS0o4k6AETTMFwNM7oJpxi+yGekhR cXZ7AcVxXbt/jirsMZD81gugEs0KVjAFGMUdxEtejbKmLtdIF9ONWbCsrRScMROCgKsx KmkYiyocqXRlHy9BlK+qYkordR47NPXj9agEaodCbKrS7vWgPEQd31RDmn1idDOE1L66 i9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623294; x=1730228094; 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=Wynj7uE9ZhocuOl6EDpKosUefngnxhgu+wNWdY5bqJGPE0ZkM//C6kvieMDEi+8TsW rbHy921G/c0dBhyGAXBoWWGINGCHa5sm+irjO0oVSW/2F6ZKf9quoo9hzq6PG72/skCz SmbkW6N/auOc6+2BRn05t533Qx2awmH6m/kF0jvglfQexVx9k87NJFV4IYa5syRRR38s 6qkYOBekA8sm9BSTwA27A53uUCcl1pSBT8dtAu8LZ+HRQljijAK+fDNeVHr8NKdi/Kpa +ASHb73x6qx2sk58KpK90vMP7MDe8NUqr29aRo2pdVruPsZJmV3l8STn6wZdGTRic2re QEZw== X-Forwarded-Encrypted: i=1; AJvYcCUq95Rg3ixKopzOQZnYzoXkSzePh2Xwq5hGuAem4Qn0e5VwqGWBgTb4KfddBS/CBIYTPc1lZRvKeiez+Hdu@vger.kernel.org X-Gm-Message-State: AOJu0YzxK60O7OiFNJZ14dPbIXF0oh2zSqJjRSHKkolWg+amIZ5eq0RU pfRfBSkI2mcTrHpP2HLy+RTu4jOBwCXOVTxEs7SzuGbdV7X4JAzE X-Google-Smtp-Source: AGHT+IE17RxujGV4wWJOZ054N/B1M2F5cL2ZD8WOUSGvQI4WP2M4v8eO8pMq+eVle1PDf17QuZ/7Aw== X-Received: by 2002:a05:690c:93:b0:6e3:5c5c:215 with SMTP id 00721157ae682-6e5bfd7d109mr141864167b3.37.1729623293910; Tue, 22 Oct 2024 11:54:53 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5ccb754sm11959287b3.89.2024.10.22.11.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:53 -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 v2 07/13] fuse: convert writes (non-writeback) to use folios Date: Tue, 22 Oct 2024 11:54:37 -0700 Message-ID: <20241022185443.1891563-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846043 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 B93FB1CCB58 for ; Tue, 22 Oct 2024 18:54:55 +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=1729623297; cv=none; b=QZpvFajQtEVbirf5v29TylF7zYcIH7a56d6e1T2sBWjMYlAqNlfqsHwN2H1sbI2xjzA/uo90FMDTGn7q3FYe9Uhd+IpWrLjLOMfbuehdQOaSb7SGZ4DVDS7ErCpXR3lJ7RD+BhKJvnM91pAyOtYeSI8r/fh/0JqM44c2DtZzFLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623297; c=relaxed/simple; bh=Husv96TOMO2qIvKRZvj2W7AV+kR/pj194D/faJu/Lkk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IvV/AmBVy/0HcVG8qcH0awS57mQThX3XP9o2WkK56a4R/gNmTO4ocHCtNaeTDR2K+MjxXtDS7PKuyDFWW/hZBjWk4eQoCEwsNYLSr4PBcHbtNXMc1+mumP2Fk2BZmHweYw4Xl7JuokmzM6VouXLny8GRbcTX0Opx1peA4qrPc8o= 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=nkp4T2jc; 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="nkp4T2jc" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e2903a48ef7so5822995276.2 for ; Tue, 22 Oct 2024 11:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623295; x=1730228095; 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=nkp4T2jcaKwcK0C1cjHXW9I20O8pH8kCK2LEGU4PIxxfshwaS3XxK1ZIW4EHvr3ZnQ BrGhHabv1sC/ZakSXYx0YDUxr9x3m4D2tnggFhh4xdPe31J5ZROi1xxu8yUIPJU7b1Hz QnyY/l6PTz+RTglaQCdi+zoKxNi9RxXl6jALJqjs2tNMltNCtiCjpUgl/6ud1MRlc9Oo I9g7cjLmsvsqCFKCKnOW8gW6w242IbpTmJ26rxWJpa1pZd46URxWrUI5DjjMcbNYG2Qd AGaBg16u17wVOjTjyTmN8K7Z3uZtNUcMIlpcew6UAj5YukZRyCdBFCGcyplmSFuj+ddZ 0GIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623295; x=1730228095; 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=Ug6oF0VKJGDGdf7xGAVZ9ahEMrH99BBDDddLzkl5wvEXORLYbjP/OaP091//oebSR8 g3Q+K2b8otWa1MHCsMnO83EUunX+ANPXqXxhsLVlWe/MP+SINqYxNZFSKHjrhq4HAIwp C2GDU0PgL59Dzuv+0C7xdmmkoqn1ComWMwB61CNujdkwakjt9fPCs08Bv5fr5nJhYBWE /GeGmXtSWcy28P0LlTYwcBCnBh/xDJoP6nMwu1FBQM8IdjNufcu+N67Ck6rHNEjCx9b2 53DMwM8niKm9yyqR2mNGLo298XaC4WIfiaI/IQbtLBLVsHvyYbge/kP8Y1+/nwnfh180 ga4w== X-Forwarded-Encrypted: i=1; AJvYcCURYDbqU6b6Qbw3BYiKdOlkBSxQIf7/evNjZ+sdL12BhpZy1wdqiKPdroX0fRowbkckvbkUfyjyf/IBEaaZ@vger.kernel.org X-Gm-Message-State: AOJu0YyNL2UDzE9JSJz2Yk+xDpjZ4laZl5oGvJlB03edkV4qk3ZKF3jp Dca7al3mAskqQic4plVbvdyprsBjn0M3+t8b2RzRCPka4/Pi7Eo6 X-Google-Smtp-Source: AGHT+IFIGcsiGd1/M1enXkV1i26m6ckvZGCknuhnPFPEjXYN70RwAHOM8Hp/wSuBMyB5fvdBihDLEg== X-Received: by 2002:a05:690c:ecd:b0:6e5:e571:108b with SMTP id 00721157ae682-6e7f0db9871mr97467b3.8.1729623294717; Tue, 22 Oct 2024 11:54:54 -0700 (PDT) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5a502d9sm11859597b3.47.2024.10.22.11.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:54 -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 v2 08/13] fuse: convert ioctls to use folios Date: Tue, 22 Oct 2024 11:54:38 -0700 Message-ID: <20241022185443.1891563-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846044 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.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 C13731CB322 for ; Tue, 22 Oct 2024 18:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623298; cv=none; b=CSJeaqLBmDY3NlBuxS3qay2O/tHDWF1pJYZPXm5di+7sNf3qFfJ8abTfgpAKiFB+dEwsTbthR4cXSU7iXFFBiAkaIuY0SMcP3LkNl1iGNs0y9/uCJDeetiBWupoM1CnBNwIIdyDldz7v8Rd5/1gI5hormFn5ZTIesOZOtQ76RmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623298; c=relaxed/simple; bh=hcL3+0RhcVI43HbxnLht5hou1eV5UtTxkn+gysx5l8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCLj1XudqR5BHrEXQT87aPGYD+ZajIg3Ym2hmSTMzsbwDwXVxcL3mT4Znu8r3n07HcBo6nEYvqphwuT6ZFin96NzBt+bIN6lMRC//9I5UkVjY3j/uYnrY/PSV25/4bdewHJfmuQgn+OmpSL2SHlU4tZtJsANNwWsjk5gbc5J/UY= 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=cbyKE+ds; arc=none smtp.client-ip=209.85.219.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="cbyKE+ds" Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e2972abc807so5513336276.3 for ; Tue, 22 Oct 2024 11:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623296; x=1730228096; 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=NgxWYiUYA9GbSWvPK49YvUVeUso8Jap551AxuZHlbSw=; b=cbyKE+dsY/52g2CmQt8YPA/Yy4xV01GjBFCvqKrWD2DSSZ/gtntCxSQK7VYyaUUReY ghCpgjiAayuFg4x4TJpqWONGuJlvaclYlciklsp1tGdZcAsbocpWww10k1Pl0w3AeeGl pcK0wjqs9BGBmvRqpErYJjzJRrtcSfEpE4nl8EdLICc1n136dOMbOBD3AmfLItexJw9l FWopvKKNa8o3AoOnvRvp7csoWpGPd1OMQkqtI00UW4f3WYQ/RjEA17tNACxokAnOfEyq h0y+M3OAUNdlRgl5ELrYeHbZRrAlvI/qanAfZit7Im9N9slPGFgzUcuN1OnDaPDvF9Kq XWZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623296; x=1730228096; 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=NgxWYiUYA9GbSWvPK49YvUVeUso8Jap551AxuZHlbSw=; b=R8BRs88l3952vh/arDE3Qc84cek7vR/gp0sN4kebJyM4vBSesYHsYeUPnEbTFeFg1I Daa6pHUZIMqPhbXtQ4Fxvv/dxrpb0drm+W7K4JHovDn5YBVKewSn/s3fei1njJWRuDAE 22ZTA+s+gUu7u2vTeyd5BNOBhxOWmUQKj5mwZINKBECjuXW9zcXPeHF4LAp6W+6Q+y4T p5zpMrAk36DXDBthnseZpwnw1ZYYH4odT/Ptx9M3sfqrK4QPuCMDefMknxNvNJ+xNsII UeHxEWTb9mOmo8b2dMuPnmpYDmCAISd0cW4yVetkrpKv9IZohYjN4w5gRR7W/FanOdOe Z3nQ== X-Forwarded-Encrypted: i=1; AJvYcCUAkiceT/9LuqPy6pTQcj4tMnXwuct89PcdGP3lJ9nOQsrPYunXUIb4qUefKWB6sNlznCn81PgXpdbYsEWa@vger.kernel.org X-Gm-Message-State: AOJu0Ywt9Byk7Utix84pwQ1SUTEjkKxhhPkXzkhiISwK2Xv0niTfGhE/ MtF+lLnugTCHqHj4IxleO16JKnWgMbYBciJ4t09HlGoEizBn9kry X-Google-Smtp-Source: AGHT+IHuh8ORBADRgQ1nyC3IEMPOK1NCvJLswVgLyqZ3kXrsx5Pi1uN/k4h2SEu9hoIDACFe5Qg+aQ== X-Received: by 2002:a05:6902:2b0e:b0:e29:32fb:b4c with SMTP id 3f1490d57ef6-e2bb1440df9mr14687267276.32.1729623295622; Tue, 22 Oct 2024 11:54:55 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e2bdcb0358csm1159572276.59.2024.10.22.11.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:55 -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 v2 09/13] fuse: convert retrieves to use folios Date: Tue, 22 Oct 2024 11:54:39 -0700 Message-ID: <20241022185443.1891563-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 9f860bd655a4..220b1bddb74e 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,8 @@ 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_folios; + 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 +1762,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_folios); + ap->uses_folios = true; args = &ap->args; args->nodeid = outarg->nodeid; @@ -1780,7 +1782,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 +1791,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 Tue Oct 22 18:54:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846045 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 72EEF1CCEE0 for ; Tue, 22 Oct 2024 18:54:57 +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=1729623299; cv=none; b=WwX3eLLis1uYR+MvZkwIQ/rJU9Sw3IyfP2xW0wWrJAUWMXQkNViebJpZy+YVjfgdHsUP0cX1wG1U1PvMneIbCvSyMDFjMvsjJOL4YW3ficYAJdPuwH9GRvBd6e/b3WOKoIWxQnfWHpyizF70Ck4y0p2B5mc2XB/q5qPe5G7vp1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623299; c=relaxed/simple; bh=1HaPk6EzjG7VdCSKTLuQIOpXFdsINrd32PweVP9Fvd4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EhuTHYVYrx4E6IY+pi2GATfg3+xMSh3dNDDCg/6OITzEhE+MGKVhNAQdLSoTABzFnvjscTnaQCGM7TqDpPAltMAJZIx8g6L6Ug6IUXZFm14+HDp5Mj9U1OLYMj15b0asuvYi56v1aDWv9zaV/6Z10bksu0lMlo2pYAh/5q4vY1o= 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=bcL0180M; 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="bcL0180M" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e28833f1c31so122489276.1 for ; Tue, 22 Oct 2024 11:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623296; x=1730228096; 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=bcL0180MZj6fVfiZtRbKluyNlSN6WcruUy7tmF4mcNP1aBWcLi7/1KDZ+Vxok5GETl +JFrxuzFb8u22bYIyL+04hBIE7OeAiziR2l1lUTrE0AyZRmsKERPuQkzaPCcD/GwSTRZ mo+KAVlJyc55U2DpdpqHsIWZmmbmGSpjQiK4BYpHZfdKJ2VXTIe3P9Y+PA5G70SmFBb2 HeXLp2/WxwJXs6EFa37XJ3l/BBzHSTdGpN4A4NpiFLpje+v2yEt7r9zEzK+AFpza7aGQ CKKiyFW0bRlSYN3kyIaMllhL0e3hizfklDckUHO8jcvTkbWd7Rb5aK6vzJydYphzfa6l QhXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623296; x=1730228096; 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=Y3DR84vZUW9OOyOqmNzZVgyicje6LDA6TetuGpZBLj0vk42wDXkPdHukm2jIxjDg3N l5u5q0h4B20GYiyd/bitlsZ+6rD46XCOZD9eN+fFL4EJtS6bZDTJ0i5h1ctdvBKjLb5B nb+pmmvWYl/J22jdHmXi7S7B85my6YueFMrNZpXdVezFA4dwOc+L+rza8uihRI9dDHw4 p72xvjxLp4m0Snx3TvakoxX9G6fEzVSJCsFc73cgIHLhd3HO153s7EgIpOyccry++ryx f0u/hysBjcx2W/Uf/70Zn+bTC7I5lra3Fd1obRPlwkOidrJ6K7yMKIcxf7QoL2GRwJZz gGTg== X-Forwarded-Encrypted: i=1; AJvYcCXrYwdDAdo3iw3yTU8VxPUvInasHn1NAKm+2w9X8GohfFuGvJcDNOeC0qdqNGkFA7qB/3b1ryQxz5rOVuVo@vger.kernel.org X-Gm-Message-State: AOJu0YyoGuWJ+Meo2R4pcQw3As36GqfvBHMUXvm2Qcp6Ezk4mOvqbVku zif9JgJFDaoLjt/gQVeg3rV3eZefD9PNn64hI8C0ufPxYG/UQxhl X-Google-Smtp-Source: AGHT+IHQI/fuwQt0ZneB9es37d1QrD+Zj1irxRhXOlmJBk/BoUZy9pXQKM0N5tJBhmZygwdgUWsdhw== X-Received: by 2002:a25:8388:0:b0:e29:11c6:3c16 with SMTP id 3f1490d57ef6-e2e2458460amr4324685276.11.1729623296419; Tue, 22 Oct 2024 11:54:56 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5a4d16dsm11839157b3.35.2024.10.22.11.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:56 -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 v2 10/13] fuse: convert writebacks to use folios Date: Tue, 22 Oct 2024 11:54:40 -0700 Message-ID: <20241022185443.1891563-11-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846046 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 485781CB328 for ; Tue, 22 Oct 2024 18:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623299; cv=none; b=PlLfB0Z+KyJRx1ZnYi/Enmy9uzGPPNIVBXFfsick4h4ZjTyhR/BW1LrDce5w5npIQ7G7Ztb1phsaSukorELW7Vm5paAZ5QMSYp3yJ8M+YhFaykYupX+dWqnkETawm3rkvJ672lknVYZXE3MQOq6N7iMrjBn4aeQqccPje8um1Ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623299; c=relaxed/simple; bh=Gu2YSvK2+EbyNYnxZcb7N27GGbib1KlhygWAxajgM9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RqnlP6W/Moxo/J3HgkZWClRlNX4TaPHshIfsesXiuVPIufCZZWUZ9VNolP4iU7JCOf13/nJEN/DU31JnscCrAp4McbqPYxv83Dw8oXUwZgeRd1NEbMYeIBa5HmB7J8m0mjGuas0govQ7/x0NHFW2r8CxoIJD3CeG0XeC3ogMH1M= 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=AiK3LNKr; arc=none smtp.client-ip=209.85.128.179 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="AiK3LNKr" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6e2e3e4f65dso66077767b3.3 for ; Tue, 22 Oct 2024 11:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623297; x=1730228097; 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=AiK3LNKr5B4ZcS/loQhWUxTa2KiSqyaOGQIO8U0g8iMPiFJRFf/qK+gMczOaSXYgP+ Nv9RNsLKKSD5l0403zFOwQOUQJKHTqM5TdscOtYi7HdJpb4UCOt8ZaOEP1Ymsq9SgL0e 12oMnXI8u9BarPNXnm67L64W6jO4iQBKDenNZ0rmCVxYTJRCICp5YaHGJfhyWlqkoxwL BdBZLUm+W8uTHy6HERkliMmjgNS0gab1h2MXH29fPSJGWk93YoI685+rkhowChWJ6tJF zvIPXvgSo8yabnEq5pS1qVUi5Pn3BDJyYdymhecIiY38KD5Opxoikb+Wq09YBnXBIWY7 lQlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623297; x=1730228097; 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=J4NTpfb3phgk0glVRC4KXvVwGmn8bDySDZaf8hGWNde0i44EVMYbNVm/1LLaKttq7m dMWBnSC6akpLq15wcqt6l2Gq7ikAWcZ9q9xnBalZPJPAUXV5bo5d0uzprK+iXDAkH71E yEMofZBaWnnnoSWl7TZZtjUNbv5609pHv/XFR1WAFayPKSd/hs9LGA8cPGXP//bBti1U LA+E6BxUDuI3NpRp36Ne1Sxxq3J7mOvVpCX+ITTuUA/8hUEfd/YRzaYz+uMX5MTgETiT U1vCuoqSmWWH9WYY4ct+p743MqgNhzmRXFJvK0Whn5E3TCccBLEUxoUGjqdV5HG/G6M6 phaw== X-Forwarded-Encrypted: i=1; AJvYcCUmulYQRteSP9Scy4oI78HP+V/H+tkzYBxBx13ZPqKTsnV070jgg8ii0bdn7u3+ZZsPk66NjViZOMO1B0AS@vger.kernel.org X-Gm-Message-State: AOJu0YwGu4YSgydCIWVpuoyeCh18lKedj5d5wZToTOPzv+7I6rP2hNkH i84K7QDaICvdSObU4Rny9JiMrRfqKeGrcB8hYPae46EMarb/WTs3 X-Google-Smtp-Source: AGHT+IEHMn2QAHwEJNj0Pjj/vTCwiZUq5sdR3j2aKasb2Q+ETG8v+k9pVCrfFsA8EUKTsTZDVb+UoQ== X-Received: by 2002:a05:690c:dc8:b0:6e2:f61e:8c9 with SMTP id 00721157ae682-6e5bfd4ca84mr165062897b3.30.1729623297205; Tue, 22 Oct 2024 11:54:57 -0700 (PDT) Received: from localhost (fwdproxy-nha-002.fbsv.net. [2a03:2880:25ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5ccbae5sm11957477b3.81.2024.10.22.11.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:56 -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 v2 11/13] mm/writeback: add folio_mark_dirty_lock() Date: Tue, 22 Oct 2024 11:54:41 -0700 Message-ID: <20241022185443.1891563-12-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846047 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.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 073931CCEE2 for ; Tue, 22 Oct 2024 18:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623300; cv=none; b=rOj3V5JhVSHvAGikh0EYmfRKv22xd7S9eJKWRrJlKDkNhRtj5f9V4Un8CKTsUvtLmonptgrmiWtMZLpj+PqDb6fmP4M2wCZizqGg6In2BUDa32nOfcs/a3oqss2qPRDoCGB1zgXeNr8IIJgwf92BfxP/XkIXNbqcmnSPCWcU5vE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623300; c=relaxed/simple; bh=1fx4xorTc0SaJnZqDSSJwFVUP5boIwS3BOMlFmZESII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NEZQOJHGOG5k5ynnk8tz7RzM7ooB54YGF0ZaybqewZofZUY7y8/oFZIf1+J4OmRa9vydFjg93iGazrzW9N2948K6EA0NCWA63ZsEap2yhnH2Wk3/fNKDwc7cUcJx5TkvJxjdmji5IvPzNT1YmpkWnsbmi30X2Lh370Iimg4vH3Q= 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=BZkIY7Tk; arc=none smtp.client-ip=209.85.128.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="BZkIY7Tk" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6e59a9496f9so67653567b3.0 for ; Tue, 22 Oct 2024 11:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623298; x=1730228098; 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=BZkIY7Tk+G9EocG14Hp2Y7bEocMIgZaxsUWDPBm6q6cxovYz9p0xfgfS8OJAZUAshE xa5judG8Xbk6XQwWdOw3nsd+0U6xIQW9EJdB4SuQrs/cBJp1LxwOZkmMq/66k/uw9mLk s1CjSSiWh/Ezh7gULBJZvpWuaY5CAuuqhi+LAjpbucUsRPded/r2phhQYS3yGRdSpq0D hWi9PwD3dh2WYACMQTUqFZVq9bsL6sRhPNS3cbp5som09p1v8prNGYb5qiw23y2hgtT2 cL7nE3KPowMXC1GGgfE20YaHnX6BuhzBXa99VKlc0EmD79h7IaI/27kqSbwSBY2rZ6XJ fuMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623298; x=1730228098; 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=iXGszCovh4bhfwUHcBOjJjRxX5UPpEep45r3JbafpRmhe4nc+43PJD7FskflSjJWwt grzroREjrI8fq3hOyCx/a1shbPg4nIqz3YejwTVNmztlRcEOq4PixPNrtxMqImEPXdWI KphyOgR7XWl90xw71SGHOjM4LRxyxw3Y9XX6KHA7k88tu4EE+y/DzSftZJnK2FIY2Lsx rr3sKizHWLsIjUkceoXcNA3nQ++2pnt3YPOAm42W3IUslqe0hXy/T3fVZ9Oz9HwC9SAf IPyNdyPy/y5Me8LxTD1XpxUBR/8hMsubfotp1JK1uBVUggW5a981VOhisbYaeyL1c3gz W0Wg== X-Forwarded-Encrypted: i=1; AJvYcCWvlVsYNcka/g0d7p0ON6BQJ3ABsQmDoCh1FYvwYhFXff074z42FrJ1KXs4EVDf9JEoJdG9wnnjFX7grBs3@vger.kernel.org X-Gm-Message-State: AOJu0YypxDLsXnpl62VtrKPuaFhHcih2TBR1vuEeN4lHyPzr7Ykcvui5 +hDs8nFlAxWOKM11s4LygeQXAeaDPYAxjwB3FINX3gyITUwXhDqF3N0T/g== X-Google-Smtp-Source: AGHT+IGB/RDx7Rr40rI2Vwzimnue8WKiqoCTvQFophqSeHOWQ3grugkvALSdTpmjretp5sqLCUZBQA== X-Received: by 2002:a05:690c:2892:b0:6d6:aa50:9267 with SMTP id 00721157ae682-6e7d82d7110mr31966837b3.39.1729623297896; Tue, 22 Oct 2024 11:54:57 -0700 (PDT) Received: from localhost (fwdproxy-nha-004.fbsv.net. [2a03:2880:25ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5d2d311sm11913007b3.132.2024.10.22.11.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:57 -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 v2 12/13] fuse: convert direct io to use folios Date: Tue, 22 Oct 2024 11:54:42 -0700 Message-ID: <20241022185443.1891563-13-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 Tue Oct 22 18:54:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13846048 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 9702A1CB32A for ; Tue, 22 Oct 2024 18:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623301; cv=none; b=sO3AwxQHtap5YVUkKBtvB/gl+d1466v+ecgy9Lv+13zKgbKKhhCgfJKvmSBCjPssU2xgqiWbAxlT7l2gg0e74H2XeW+0Oa2iUdq2WFmyNMugumko9b45cnweXsipxWUAzx51G+8COk6ZGSAKjd0LOA1gL729y2J10F2LssVcYqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729623301; c=relaxed/simple; bh=pcbIhhovJXO6lkm1QKv8ZzPZgmlGGXF2/5gCxDUbzGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t+6wBk3F6m+wn9HXNhLf66Qcz36wmY/kLdd5+cQ3F6GjBJ2630yZx3qBDvJgNZTXMSq3lGgVxnPs7qozn8Nj9GJyVUbQ8DOChAafdNYZ/xk+xM0NW4Yb3giaZf7ghvCEqSphvr3If38PwgxA0C+RuKvq5tMbZbqmqXI9HDcis34= 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=R40hZb9B; arc=none smtp.client-ip=209.85.128.180 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="R40hZb9B" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6e38ebcc0abso66406627b3.2 for ; Tue, 22 Oct 2024 11:54:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729623298; x=1730228098; 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=dkJn/niLy1hi3yWct/J40MYgXueUBJiPPMHopaFhu8M=; b=R40hZb9BQbPqXo26xDjL/4tyYOAqGdiuCE6tajqpoWl4UOLnqc7MZh5yJ0bRlfOSks Pu30slnAGA+bU0hcDcd18nWlY3y9wn7rn1qd9v/CtRQlv3OQ/9cbApDKTuJdZyU7fvR0 LjgnilS5YKKBy3grXPI0D7PjnimKnu+fNk+7HKL5BaFXQQ1KmYnqfok26sScJl3/KFue v21xx+6H3NQ2oLGMj5yacsqK/alZTQFx55yU/MeJg6kf7FONrFXNker6yuUjgGpU2oeS R/+nS1y83EHM1VX4PkoMxuP1Tv72psADDgJfjVCmfq1Jc8a1T3dErHnnGrAzu6bfOrFe I+bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729623298; x=1730228098; 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=dkJn/niLy1hi3yWct/J40MYgXueUBJiPPMHopaFhu8M=; b=g75VWEmVQa9Ddl2XJtix6BhuIaWf84H7SGX2l7kguqXaAB0gkS/QM/VOnUqGPHjG4L mA4etj64AzZMKNdhokArf7vlprgWinpf7YjAl60m64Mpcm90W4T67bPxUNaMXqNVJmF0 ZB7n9eUIiRoIcWFFvrB75d/PepU4dLXR64v3XtdeFuQM7MFEoC7zDDIQF1Jll5CIDxTE ofp0t+2ALRAG5S4R04npQTE5uNHaz7ijnk+Lk9ImS7CeEfVz8h6ul88yjEnSwX/44SW0 Kq0AGTr0d+IeVOpJaB4MOt3Vovsy6hwI1+cpa9FmNnj6bQ/J8nhD38mDDEhurgG2+HNO V72A== X-Forwarded-Encrypted: i=1; AJvYcCUFv6tDkSjj284VXqoR8mYeC0hF9YNE/4VMbHvzHWKyUNBMohH7tXh7JGmCiUHsCp+UlNBT1S76siGUakQk@vger.kernel.org X-Gm-Message-State: AOJu0YxA6sU98JSZPeBjsuw3D4hnR86UAEaT8FUOHdFEpM5dzuHjMprn 0kFeSjL+bqOU6N6vnpwPgsSICuKIMC2ghq0uOw6vQuis+hjQEink X-Google-Smtp-Source: AGHT+IFbmVNHrEgXs/j7zzYzYfsqZf1JdulgVG3tjUh4YxxiruZ75rznDWKdunhic570DCMu548vEg== X-Received: by 2002:a05:690c:39b:b0:6e2:70e:e82a with SMTP id 00721157ae682-6e5bfc0c7e7mr145867637b3.31.1729623298580; Tue, 22 Oct 2024 11:54:58 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5a4d30esm12003477b3.54.2024.10.22.11.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 11:54:58 -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 v2 13/13] fuse: remove pages for requests and exclusively use folios Date: Tue, 22 Oct 2024 11:54:43 -0700 Message-ID: <20241022185443.1891563-14-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241022185443.1891563-1-joannelkoong@gmail.com> References: <20241022185443.1891563-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 220b1bddb74e..faf083f27739 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; } @@ -1771,7 +1757,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_folios); - 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;