From patchwork Wed Oct 2 16:52: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: 13820088 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.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 2D9861D0F6F for ; Wed, 2 Oct 2024 16:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888117; cv=none; b=E6cP0ngf6hNNqK6s4WhtT9D14n3VDPLnd4d2Ai0uSORglIYqtE3K9v3kVRYGmGDat3To0BEKpIbEAkK71env5oZPVpE7Zyv2JKSOET/sSO8Zr+/k6R+lMKkOd3qPs6a1+YugYiAOdx3BrYNoK3/CsMuss0n6J/HMkJJGd/jALVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888117; c=relaxed/simple; bh=GVmbCVtfZnjYqSYEejfzaURXqzMI4CvteqR+q+WZbHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BlddWkpgbbdKlM3LVKs1WKD3TUyj7pW8ooSd8BkMGljYf3XUvD4bJF/rej1G5Ewckeb8RFnG65ufIGINBdsniNAgs3mD7b21l/Bz3B4+w/I2M1uD7Mhr7v+pvzl8XI8UaRN+05muTu+4oIVv9SEfuqUEfLN8llBgkfwzUT8d9TE= 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=ZsDtcZrK; arc=none smtp.client-ip=209.85.219.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="ZsDtcZrK" Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e25d164854dso5977471276.2 for ; Wed, 02 Oct 2024 09:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888115; x=1728492915; 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=ayYt8HUs11at+3z73eOh+NfMxShVgyFsh4X25CI12eM=; b=ZsDtcZrKWbgQA3A94YsyOlOMvoDpJoS7eO+ii550jnGJVnTK/mIkLHmYLBLrDYs9sE MjMu3XF7s/hBID2ldDgB2tu7Qvfmi+wAvVSgVlKJ2JY9iJgmU28lkFx/f7pOP2OEUWn8 2qBtjjiQeTT6VQSyDB/K4Y7jj8D3UewQQwXr0ugPmDU6oE+fP8hLKoLMGEhyDAu3rTxD dYLW9i9+8qfdkOl/OYO0FHQzqE5VnhpDjI43IeqKtoPzMAhwzD8U3MgW8bcCnwGi17LR DpdL29dVjuEk8qHLzCMBBc1dNbozgCYFE8APisbz9X5nBoG1sILZO9jy8dvutRbHlpX4 aPmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888115; x=1728492915; 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=ayYt8HUs11at+3z73eOh+NfMxShVgyFsh4X25CI12eM=; b=LoXWTqzvsrjvsBf8c56dwju0sVYrp/dgA/Ft+QPXg3mZWHkjnxZJBT9tuUcRhG8Jqj qRxtoejR9vmgINxtpNUiSe0vUG9yBRnGTUQLwNptuOz6pNE1F12lgUIBvleX0vn2VdnW Gp0wX375HGqM1NVdm+RNS9MTSCcSy4WnDV/Pbt/9L0f7JjXQNN9lJcNRmI2ewbVvPfEG XBT5j+E+8cVWOroqEHmreEHUi+RHZGHB37JupGHRFT5x2O3U9X0bYts2lKFReajWcxWD 39QvHeLFpmcByGZkDeuAJMPPeRgUEhYtUwxnhvttbS/07FODArgbLlbT/S8GAk2+CLJo 7yhA== X-Forwarded-Encrypted: i=1; AJvYcCX0yG8AQscMxb6s4nSTzmGozj3U+ak/IKt+4yGs+PkHzh/GlQPWbYiN0bzu4ZMOKF/I+FE5fI5jVruYYYqu@vger.kernel.org X-Gm-Message-State: AOJu0Yzklz0ZpJ5217pGGqg8kcSzN0LV3oirMsN+2lFgIdRmI0qjL/3h EfplHBKasLzMGlIqn1Rup+1Jp9Gz7WPSwlHsuXo+eYMfcJljyYtb X-Google-Smtp-Source: AGHT+IH1qiAUfpE/+bVfMhhEatU8c4gDi/yaWzaQtR/fvKL06J+MYmB/NV5+3Xi4ga/ecqwJTaWq/w== X-Received: by 2002:a05:6902:100b:b0:e20:805b:9678 with SMTP id 3f1490d57ef6-e2638434281mr3429055276.48.1727888115008; Wed, 02 Oct 2024 09:55:15 -0700 (PDT) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e25e400f009sm3993772276.17.2024.10.02.09.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:14 -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 01/13] fuse: support folios in struct fuse_args_pages and fuse_copy_pages() Date: Wed, 2 Oct 2024 09:52:41 -0700 Message-ID: <20241002165253.3872513-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- fs/fuse/dev.c | 36 ++++++++++++++++++++++++++++-------- fs/fuse/fuse_i.h | 22 +++++++++++++++++++--- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 7e4c5be45aec..cd9c5e0eefca 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1028,17 +1028,37 @@ 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; + + /* Check if the folio was replaced in the page cache */ + 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, &ap->pages[i], offset, count, zeroing); + if (err) + return err; - nbytes -= count; + nbytes -= count; + } } return 0; } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 7ff00bae4a84..dcc0ab4bea78 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; @@ -316,9 +322,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 Wed Oct 2 16:52: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: 13820089 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92A1B1D1301 for ; Wed, 2 Oct 2024 16:55:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888119; cv=none; b=fFNMrJWZpL4Fgo/Psf5yqwU/4uiD4I78pKAkrmvwH1RVSSmOOfdxV4JWELhWk70CHFOz0TGqOx91szqVe2gw3jFh5JgMtpqzA2GMi4Qj2m/6LpI2n35y7A9ndLpOnTZPmMP3AHTX8xsvyeJ2wxQgnNWf7A4TIYq1fCuK90GDxKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888119; c=relaxed/simple; bh=l9SQoCnqugBgtH/PEt+VJ1NiVP7UHeztDZw3D/QVpq8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QUxK58Vm5BJRoMQU3a84M2YWW+1dqFDBfOlfvCxK4QJKlrd8P1JoqkTgrb8nvsNDtjq0TlPtsogpas0AW2T1oHxY0u8IFksRG6uZcb+U5GuQOjYjFmKNVijRSh4aLjm1/5t2zXLxy66OU2KGZtPSEpIDOK5y+K7iLydYoaYUWLg= 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=Ia9V4N9o; arc=none smtp.client-ip=209.85.128.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ia9V4N9o" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6d9f65f9e3eso3617b3.3 for ; Wed, 02 Oct 2024 09:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888116; x=1728492916; 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=n4avwJEXSEhYWk8UCdqe98s7a8vD3BhZ3iPofebhRy8=; b=Ia9V4N9oBRkRTf90sgdqjqYGRxiXAx2bpm2O5tmO+MQ6YG+UTAcQKFuzCNeZTx4u0g 2MUG5hhg7pwRnpJAfnYQHohNy1trK/c+/0lVnLZytl829PeHRlr/p7A76JVq2S0VnCvW r8rw6tChvzLZy5KczQJyJiIwdyfvl0QXbyjYE/AL4+VFAPogM9XO4RS+Uo34QWGpaLB3 7XpICatnSudj4QMdwJw4vn0xMF6+JUncNYR0V8qwrdEy4RJrvy4PxK2TH37mCeBvG2WM bhXY46rL0SFiBrUeh7TuzhJxpSQDbde7YHUMwMfqeEvbf8es8BNQ8Q1iVjcNYAFf+Ked GFwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888116; x=1728492916; 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=n4avwJEXSEhYWk8UCdqe98s7a8vD3BhZ3iPofebhRy8=; b=EBZ07PaI+uE+Ef1XaijrrtKPpcmsMhDDaYPWDO1wkPKzVewrokFP3M2r3GUsp57c0E Ijzo574nO+HX2rfIRty8PYJ4wtTbTAWu2/i7rcAE4UNv/zqjZpILyQZf5cimyayvk7Kn +1oGPWBlv0xy4h7Pzwxd4knmCrnYFzVdgnCxb8ixG7AFtlTy2Fij/KFj/8lLrNr+nvbe yAWNeDV4ZV4VKDt2UPiLs5nKQqbkcy7hKzd+hHQfEqWQNFKdzEQzAbAhbIIujhlRmxr9 jWV6Le9oqPR3/se/ayw/hKU4Gqb5CCOrfJiDoS8ARXdoR4Iy7zZd4aDz+oh6ZMVbwxBk ZO3A== X-Forwarded-Encrypted: i=1; AJvYcCWdSXuRhtzCHZJgPjW6vthjCo0IChE7rw/0WjxnBOOi+3lGSsIN8fk/gbsFeG4oCusk4pdvsXrWXBYkJMUc@vger.kernel.org X-Gm-Message-State: AOJu0YzX9LJX3ftxHIBNjz5fqHaO9VLTwLXWBvbL7SB+NB2jP4yfCr1e XYLm6WPzO7GeO4LbNl1JmJ0YFIeTx7aMsQl8MnrVXDQiLrO7VRzQ X-Google-Smtp-Source: AGHT+IGcbtA7gjI1SrFPUARFfIG7ikRljNnNHbdWXIfc0Icutx/srZ7+q1Dw2e1aRdja4AkDri4c3A== X-Received: by 2002:a05:690c:5c06:b0:6db:e280:a3ae with SMTP id 00721157ae682-6e2a2e3f65amr34326927b3.23.1727888116326; Wed, 02 Oct 2024 09:55:16 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e24536d075sm25691387b3.82.2024.10.02.09.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:16 -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 02/13] fuse: add support in virtio for requests using folios Date: Wed, 2 Oct 2024 09:52:42 -0700 Message-ID: <20241002165253.3872513-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- 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 6404a189e989..5e7262c93590 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -761,6 +761,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 @@ -772,15 +773,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; + } } } } @@ -1267,16 +1282,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; @@ -1294,8 +1315,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)) @@ -1308,28 +1328,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; @@ -1353,9 +1380,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 Wed Oct 2 16:52: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: 13820090 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 958161D1314 for ; Wed, 2 Oct 2024 16:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888120; cv=none; b=Gw8j4gbVTMlLOqjJb2ErALw1qYGmjjfYg32ACfGHRxpT7xZV5PAa+bE5gDGe/FN28YPM5H4YkIMnO/42zIhF+TBpAex3cf0dgRRAleImTJZt2HufZIhh6mWyRwXCeV43gS/I3yNVsWb+nS3UMVHcLVo6D/3Pk1lwgXCQdpRnW1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888120; c=relaxed/simple; bh=wkXRmudIC1GICRJTsQyhX+cdfkDe+Wldt+fgZTQpVXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pLLFi3bRnHj6Jv//cmMVc4MzTXnrjV6BO7vb6WwEdNL2Y0hsycKeMscTFMnNkTEW+gzg/jPQXOD1cNJSUqUWnMCoo0wqc1HVliQbsPpHzLpZsbnMQY3CcMql8dNARhO+mjNkAke+0EK/RmY5Idvb0RWlPA49D7unS7Ir4/pXUVA= 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=LJ5h//Wh; arc=none smtp.client-ip=209.85.128.173 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="LJ5h//Wh" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-6e2598a0070so101527b3.1 for ; Wed, 02 Oct 2024 09:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888117; x=1728492917; 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=/RVhtoiIRcNEXtPCMAdwi/GkhOsFV4DoAkyx+bW+g1A=; b=LJ5h//WhWE6wtPlB1Wwa82dAFQfOQd5yBWqNBosfiSs91giXxi18UFlrdyNKgxhzEe lzLceQCa3ofyFvO6w5LjRtPfWtMJRrTIviHuS7YcU3xGg5IYT7xPFZh+NACY8+GUeiXu 5Y9B/E2RJWklO9uLWmC1xlfg9rVRmQDjexOKdzloMsTEjlsA9x8Ua7DctE9cikhKJptQ erLyBHUAXE3FGy31/iFdSYZjQ6Fxs8ucZ6XupoGib4r0BgUc5Nr507+Zho/R4x2G3iUY +NFcgwpNHGHAo4tnCcqxuvOYAw7o05lAsXGfBlMvEioiECovNf9Vff7sWKXlllSQWbtz di/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888117; x=1728492917; 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=/RVhtoiIRcNEXtPCMAdwi/GkhOsFV4DoAkyx+bW+g1A=; b=niPxGjAGnPbT9tkIH58Rs9FeoSLqvoZpyYj11ouWDW460dbk8Xj7FUALs/xnH7gYh+ FxlaPeYb6xquvNZ8TWCKemkrl30C7Vm0YQjAGjfHtHkaDibFtItsntATkY0tGe4VLqEm q8rL3i5UYYpEZc6IlJGzL8tETPF7iMX5ywaPpG/M3VsCNveWpI53exjmF7NTQRiy++JS 1mnBAogOUE5bo7wT1kqRNEvgoVVk8z7Vq7vYRBP+K9wP1+3HxzvIduUAC2w75WUO6NLl h64Wrn3tsvfMzEKSs9z2vox2gxZpqA5zvk+vZ1kuh9kBRPCQQ1l+5AxN8i6WUQjaxx8t RbRg== X-Forwarded-Encrypted: i=1; AJvYcCUEIrzeo7GHdx71v02DAHq7TE4zQRO+yIYrZNOd6pHwsqs2d8i19GQsb4bjQH0bRawlrnUvJ/FnLAMAS1od@vger.kernel.org X-Gm-Message-State: AOJu0YzvSg+Tt2M/Bqo4A+sAauigb75KuU+SR17zDVq3YX3KoaXlPq3g msW6pUK8K4Zs9MecFWY1AjpiZ5e/mOjExaMX2Fv06GokE4hp0TOa X-Google-Smtp-Source: AGHT+IEDt9kPf9zIRjMyx6URMXZqPqBbFUI/UhOYg3EsDPbUD2b9DadNHzxzWD8rlpEArDjMXUrOvw== X-Received: by 2002:a05:690c:ed6:b0:6de:c0e:20ef with SMTP id 00721157ae682-6e2a2ad9c71mr37058537b3.7.1727888117504; Wed, 02 Oct 2024 09:55:17 -0700 (PDT) Received: from localhost (fwdproxy-nha-004.fbsv.net. [2a03:2880:25ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e2452f7c26sm25352817b3.11.2024.10.02.09.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:17 -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 03/13] fuse: convert cuse to use folios Date: Wed, 2 Oct 2024 09:52:43 -0700 Message-ID: <20241002165253.3872513-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- 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 Wed Oct 2 16:52:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820091 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (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 C9FB51D131E for ; Wed, 2 Oct 2024 16:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888121; cv=none; b=DyHpyO8cw8mIXYuU2gYdNsDPfzCjrNs93/UNo965F05m7bRDqRIyL4nzpKXq6i/je4Rk868+5E7DlsRtVk9vD4PMbOHyoGEZM5xzfr/W80MGpvj10pLQy2kUGvygncK9s4fMHjYs6f/lFh1cIvXQYorGIhFitmkJg0UTrDBLpcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888121; c=relaxed/simple; bh=0trQRNfSkzGb0zygXt4NuVBZf90HVgPVS7hOaof4cwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GbYwaJE+eRMI/u0YInbTETSVe023V5fDdpOayDoVzxZdAhxnliLDBgLN1fS8T1LSgNXufEQUPdaicBx0pGQZUQXOPEWmj+AjWhBHPnXNIWrhERKwOHbklmlCq88h9FPsUBy4LauaiqY4kGDK3Y5Y7Qs212drIAATBczGANskRno= 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=h/80MXj4; arc=none smtp.client-ip=209.85.128.171 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="h/80MXj4" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-6e23aa29408so10618917b3.0 for ; Wed, 02 Oct 2024 09:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888119; x=1728492919; 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=94DvA0n4goqk55piTLGckL+WHzzHeBS31St4r7i/fts=; b=h/80MXj4ItSPH0gXq1AQ4fFt8YECBLhYezdwDEE/X/pJIfRpTw5fNo3shhPpDAGY1d NLdStg3yOo/54KVcjMCxuGlXmJQOB5ZY6cmESt2S8uppmMv8MEJ1XjfIke6nPRPMsWVU PvJ4zY+t7QYBfLIKWZeNJUzv1U/pBamV3ZocCHzv1Ck1y7HZ7j5xrHt5+sFzNDPJJWyW JLNO3x0imFw/8umY5/QHlU6aRk3blSnTbJcYVfZrpktqOiWxGK+03OslxV1qITrNaTpv mIk/GUi4bMFBb6GdGCVlK1G4Brg4O+hoKiUO+v7zmHPNJeNwt170DNbmX6wSXUKcUf6z yM3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888119; x=1728492919; 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=94DvA0n4goqk55piTLGckL+WHzzHeBS31St4r7i/fts=; b=NbDKN9AuBvL9ZmXa7Cl4mqrNTcHJ/qO1+eqDg4J1rsckwki1VsBQTrFq26NMTPUZ4y q4Rfv7dZu4u5yQpvkgydyvBZI95Wns+CC1VgocB7C73s7Wak50YK0pAOPQCTIBwGPU4z jAoknXaqCkAqHsjQBR1uC4h+2AtH6u9J3a0qRku9w7MFjDFmIQ1r5Cr1b1AcdfyM0gxZ rWAwKvZAc5ThqAzpKpmsJSOduTHmubVAntmIHz1tAeBSM1aUIGRBX+nxx0nuxXhxOgJv BJNTX4jxu19kfabNVzZdI1jspBTKLsUdBNBgEMSg1/jwTHz9glp8mPDZY8BiNeIP16fA tJjQ== X-Forwarded-Encrypted: i=1; AJvYcCVw5hfdpaNl3pk8CMYIvL6v3TqKmQT0zyqramPeOwaSaa5rj9C6ELG2OkY29BFExO/pquWA3bY2nFZLA55B@vger.kernel.org X-Gm-Message-State: AOJu0Yz290q+WjA923AFyKoGowMCGMlGLJtaaFsbsLIa7aVrSnINnbbB X4wlPctynrASS49Hji9XwxiRVMD92QGCifM5Z0A5/V6BWWwk/wQn X-Google-Smtp-Source: AGHT+IEPgFJq7maG+YYcBxjWOhkkD+GTsDzUEGy9j/dvjHAtDZb49Jbghy+TzJloGtU7P0/r7Jcr5Q== X-Received: by 2002:a05:690c:63c2:b0:6db:d02f:b2c4 with SMTP id 00721157ae682-6e2b534c570mr3027307b3.7.1727888118670; Wed, 02 Oct 2024 09:55:18 -0700 (PDT) Received: from localhost (fwdproxy-nha-002.fbsv.net. [2a03:2880:25ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e24538880esm25636717b3.119.2024.10.02.09.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:18 -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 04/13] fuse: convert readlink to use folios Date: Wed, 2 Oct 2024 09:52:44 -0700 Message-ID: <20241002165253.3872513-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- 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 Wed Oct 2 16:52:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820092 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05D041D14EC for ; Wed, 2 Oct 2024 16:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888122; cv=none; b=B55Y1aHyGVBEaea2dzbcuNluAhHkDZGuIQxRMkMB1aYlcQjCn+nFGY9HPiLhrt9yaGYkkPmaaeLJKs/CuaC+pAvP0ldeYfNeJFk5IQtYPJpE5UAZoOSorlHcxby6JbdDVutcLx/DFJS8OSgMlq+YAgZ1FqH1lGXCMsRdgTjGvcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888122; c=relaxed/simple; bh=JRHHuQwRXz2+Hnu0WUfI9TyImdvFrjKQGCg3+LxWgaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lcCuoic9V/RRgPxYLiDxxVO1DrGj8tdEsvhXR9fqCQPhJ8AWkW+qnV9BHxHFos3EE87CT2ANDLMt2y8mNVKKtUbfWcQkGygSHb0VY9PYn0/DGBjQ2EVw+ZjU4LGyqXx28Ahj1FVb3uSZIpyPsJSGrCIXGaYC90zRE13MNGLuTvA= 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=FmpLr+Uk; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FmpLr+Uk" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6e20a8141c7so27547b3.0 for ; Wed, 02 Oct 2024 09:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888120; x=1728492920; 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=EKfaqlC2fsT58zvg1HYS/en3/jjO564B4xjmIMOU3EY=; b=FmpLr+Uk7B9FY0Fc+bLNa12y8DPfLRcNZhxKBKyHOA6hXEWA8IXnvGpXyg5hE8ZT0T KCOQGokIQZCCHrDlb4KroxAlPT/JNMjisQL8qmoRGXuyKrUt0lOzYUwpv5CWzb0nQmup skzKW/X6tyFrsXbg6e1/hCGgPjDAitFAOJReti7UXr70eEjLn12QjqCITUEP/joIFt9t L68Agk0gjVQuQtAYSdhmIzTiGZizQjAWUt5/zbNEy5qzNLLcAxbF2PWlaBu5tFB/apim AZkymPjNxt0HaS7ZQZ+yz8U1HbxR6cPTi6xgIsfwpV+JC8PTmN3TmfzEbK4lhz2Tu6eT nyYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888120; x=1728492920; 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=EKfaqlC2fsT58zvg1HYS/en3/jjO564B4xjmIMOU3EY=; b=JE79PrLtSU7EN91FdOe2cpNeX9yh/ahL1K4S6hfzB/pO9yBjC7HwVGxwMxkJLDWGf0 qjrFHWebrwZ09kE7YdkjxyAkyEcPt5uV6cXKRB6yqHzPEm5hEMtEtZCPj9jDK11AxrEG 3Mh1N2pFeKFA0/+P0xEf3fpxCgBByekhT1N3arQ2CV9168Q+ZpFjkIB0MuN5as+36nri tfdncQd7b+JlX7ybjkIR66nWt1Vgehping8xYfjAYS95FnUcUsuvzCZajNf41oWgzer5 vxMteh1+rbsfQ3T7m3L4X8eIcy+iPHw2g25sCnrb7PwhX663+UwlXT5YMjMazSlVgT29 LI+g== X-Forwarded-Encrypted: i=1; AJvYcCWtHaDAJx1hf/feJhyMRou0jGRy/aRLTAFXLKuCihoPEFs6+M6PIToCI9XI6zEbj8nGbiWAUScR4J3abOge@vger.kernel.org X-Gm-Message-State: AOJu0YwG3xvjnqp5Hj7yhR8Js//kCHK/e46VdRgTtGQl24uzpls0sapB r6MGHsraWMQKCK92Ffgy7b+POhR0byccvU8ryPs18Uzw4aviaWKTQcEmhw== X-Google-Smtp-Source: AGHT+IG0tB0qIZ6O8laQn5yErKfK5VjdOPig/HBbd6ukse4huUa669x/hy2ZdNzGdrAPd5tziH66YA== X-Received: by 2002:a05:690c:660b:b0:6dd:cdb9:cf2a with SMTP id 00721157ae682-6e2a2ae925cmr32671447b3.1.1727888119787; Wed, 02 Oct 2024 09:55:19 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e245369a15sm25226227b3.75.2024.10.02.09.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:19 -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 05/13] fuse: convert readdir to use folios Date: Wed, 2 Oct 2024 09:52:45 -0700 Message-ID: <20241002165253.3872513-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- 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 Wed Oct 2 16:52:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820093 Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.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 5449A1D131E for ; Wed, 2 Oct 2024 16:55:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888124; cv=none; b=W59S/NYhCJYI/R1LiRuhcgt4pjSNY6Tjk8YiYT68o6FU4vtaMwVEaBJJQc0iQRh5hw2LT1mBsRsnrIyOICvzMv5fPYvL/Wp4JfvGl6EHs1BWwyw5SjsOoyyVYPd9qFcEnRL/btfhc5NfGD09jlNNNG3ZkBbIomeMOsRx3aug83U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888124; c=relaxed/simple; bh=eN0rhtgVv7C7GuC4XxHR1gXtGFCimqLE80XFinNEwDM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qZVL0Nw/HcKxYAX2gPFoqwsNvDSBrYRtxR741WDY1XPZwDQeFwkYgYHuoj/WJintxXahhBQ2Xns0UPlO0rDfDGCGgywsH57BGIXg3TDNbyofXIsQ3GJeBPj7qd418ivC3LgcakgWpKjfkYbt/0tfZq9j68DClv3cKygcooJrE6k= 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=jw/vIq7S; arc=none smtp.client-ip=209.85.219.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="jw/vIq7S" Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e03caab48a2so54229276.1 for ; Wed, 02 Oct 2024 09:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888121; x=1728492921; 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=wIde6yOsCwAUMHUcgWr+HW/rlfP3c104DpK/nsufetg=; b=jw/vIq7ScjO+keVtJNVZBTPkjVxXEoSh/Vj6rxTGBOf4eP2kIWD+PnSErWMrG3p3PT 3ROwKylrc1m1nw+WxHWn9HvYH7FlwPWvQo1/t4nPAGR0dYS0ZDQDUNVByNYu/slnePoU n+fsS0v64QVXblqMc2SK3qZOxIphTQSHjCYbAjmBRHZWnowDLmsxtvxT4p8u+794CMi8 1mKIK0Dzf6QiJxV7zTW73cG/6X8OorFoEHfI2IctUC6evsLGqsSXxdPU8dNmLOG4yKBV alE2mHvM1qceaIqMANFQxDmB2dT8cMWq4/xDv3otoWkkzNnEPFbo2NkShe0sXXK846pv ri+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888121; x=1728492921; 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=wIde6yOsCwAUMHUcgWr+HW/rlfP3c104DpK/nsufetg=; b=c0gp+aendFJZS/8X47Jk2LObhVTyxS3ctduSJ24ugOipKmrM2F88dBT2YKNWXKnKqt UpO72eqNIcxNEXkImoFPfGnJecLDL0dDiOdUET9l8f5FpvLsXQACzypjy/KttqyLofg6 /u8r2+aIqC7sZZzf5bT6XKEN4SW9W0zBnHpAVZjvtvgrdtimw+6PFYwwcX/IQd7eIKp8 4ZqDUPNGZhL71tdXF73Zngm9VHqJE+95Fe0OtbssaQrL8/KCfdfVnt7F8zuAkh5HbVZh BP2NAQhW9XGEWaUopWODuhAp1m4nWUl8GCszvvd1PE+XiyCSvYIkWNasMq7EPesGCg1v f4qg== X-Forwarded-Encrypted: i=1; AJvYcCWFum00EuQl6dfwNU3wwQKb1ECvm0bT5ftl2gVhUbWqUw7KNBuy7SoGjXIUV+6nT5Bt2ywK1nqxi//xsX6g@vger.kernel.org X-Gm-Message-State: AOJu0Yz6wO4Y92yYVDfrtCoXlclam8FuZ230e/a7JTELYtjdrfPEh7Q3 uBa8gBsYtTujGI0GHYdyd2eBT6HSXQTFANBCqdQOsfojQmrFIjZH X-Google-Smtp-Source: AGHT+IFKgoroPgGATCu1wxW2wZPDjb4LW9rH8NCdL5lOYH11Uor9VrQfHMW1nVFTBPKS5Ic3DdaIxg== X-Received: by 2002:a05:6902:188f:b0:e03:5505:5b5b with SMTP id 3f1490d57ef6-e286f5d86f8mr344170276.0.1727888120953; Wed, 02 Oct 2024 09:55:20 -0700 (PDT) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e25e401b436sm3976189276.24.2024.10.02.09.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:20 -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 06/13] fuse: convert reads to use folios Date: Wed, 2 Oct 2024 09:52:46 -0700 Message-ID: <20241002165253.3872513-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- 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 dc701fa94c58..ad419fafbd5d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -757,12 +757,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) { @@ -858,7 +883,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); } } @@ -868,14 +893,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; @@ -934,8 +959,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; @@ -949,15 +974,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) @@ -965,8 +987,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; @@ -977,7 +1000,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); @@ -1038,16 +1061,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)) != NULL) { - 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 dcc0ab4bea78..2533313502de 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1023,6 +1023,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 Wed Oct 2 16:52:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820094 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 397F01D14EE for ; Wed, 2 Oct 2024 16:55:23 +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=1727888124; cv=none; b=qZiFnz5l57HCsJzQJOx/S6cTc0l/VvWsPO9cJAStz3y5ggnSSjhFrf8QeES0XENnRjykfXga+ZVC9Smk0Xw0py/L8Nuo0Jp43v8s/uEj4jti35O7O3gQXUdSxO3drBJFgkBGsO3wORsOL6Tvhhh3Sh3HugrWVVm/pVqESHldZfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888124; c=relaxed/simple; bh=ssN7tBE8lYbB+5aGnRMVsR8M6WaI6EOggCrrcQBOdtc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y6CRAPJQ70ZPgeNvQS6f5eRvrZovc1yPmpcfA8A+MMjKKWFuc6bky3BHt9803ZEMSDrHftb7NyU4P+JbbfTCGZJYPSfQkxajxw0IOwjP2A4IthcrO9Z54w7QJe41tP9aVHocMPpvDAWRYepR/p1/YnRJtWTe971o9vP1GtTabX4= 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=SEXy3jKh; 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="SEXy3jKh" Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e25cf3c7278so6561546276.3 for ; Wed, 02 Oct 2024 09:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888122; x=1728492922; 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=C2Q3GPbgR3UjdeQnqUixUH/X5MDsikJgv+rC31/FUNg=; b=SEXy3jKhed1Kkt4qaGowTIBAMp8s/pHPpSDaHv3zosPEdpbiyl/xhfch6MtC+NaWkl 2tc2KXOVS+4qZSIWD9QqUAgDh66nIwTRFK14m87DRlC85jy2034ReVXSVS7AR7gQPW+S 4307HLgm0YrdIyDJ4VpCbYwn1LXRiq12xoa0IyXWo6ub3uxXM6H1n6KgORfo67xlwZ+K rHwU9jdDcYOM6p9dF699O8qRv5KmTQEackxZXA2ChXH1tFSx7jVY/HZofba4pvCY4+0y 9A6KOahbgYzwRJXKTtr3U9aC5akDMun8WPVWMw76H696crQXEGaeZMDhFS2jnRxiswYz Oblg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888122; x=1728492922; 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=C2Q3GPbgR3UjdeQnqUixUH/X5MDsikJgv+rC31/FUNg=; b=WVFAkrOB3KMmCMHC6Lo6ywuuKz+cP2C4MJxCXVQb4IRAuPU04ZntGE9QRzRKR2IkoL Q0DQyHC0KkyO/eiPyg+tNeeM8rrbSCzyyyew02433JUHVH5v8AvGZyxgy1I1akuPWJ/Y /HwsMx0qDTuo4Ys58HWrc5XyH7cBcFbkqpU3dGMd7SQIlwBc/ImdnAKJltqJtSLllF9B 5qLniDU1d3BAXgI1SPLurP0WIQ/KcaYO487RdmUiljipM5H1G//Zsk0HrPpxTDzmfue2 7iLB7fkx9psNvDEWx79KSHd126BIwJi9PD5ov/cb5DWFntBij1MWRkTr3fbnsQGwHldm +gUA== X-Forwarded-Encrypted: i=1; AJvYcCVMveZUgi2Zr+a1UHSh1tKZWgZbIrLzV1s1u+8Hln4WeQbT27RYmv/60sMiy+/qMRb3iQw72tTnd3dNCqje@vger.kernel.org X-Gm-Message-State: AOJu0Yx2RzllaippfL0AyMSGMQNdUlFeIP5qIKR5WJUC1IW+Lvmc03HM KXJNpjB7o15s/dm2oFsHeR+TLzfQlho8DNrQhiVj2Qgd//Lnk7ow X-Google-Smtp-Source: AGHT+IEeO9DTfllnXAI4QYhhcSnZgXZ0VEqDQ3zuVsqim0iA2j62cPAvIWSg8AzrtWwwBQW7pW22iA== X-Received: by 2002:a05:6902:a81:b0:e1d:2fce:1612 with SMTP id 3f1490d57ef6-e26383b0f78mr3366829276.22.1727888122215; Wed, 02 Oct 2024 09:55:22 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e25e6c32b25sm3837085276.60.2024.10.02.09.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:22 -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 07/13] fuse: convert writes (non-writeback) to use folios Date: Wed, 2 Oct 2024 09:52:47 -0700 Message-ID: <20241002165253.3872513-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- fs/fuse/file.c | 49 ++++++++++++++++++++++++------------------------ fs/fuse/fuse_i.h | 2 +- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ad419fafbd5d..0f01b4fa324c 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1190,8 +1190,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); @@ -1203,10 +1203,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); @@ -1220,7 +1220,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); } @@ -1228,10 +1228,10 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia, return err; } -static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, - struct address_space *mapping, - struct iov_iter *ii, loff_t pos, - unsigned int max_pages) +static ssize_t fuse_fill_write_folios(struct fuse_io_args *ia, + struct address_space *mapping, + struct iov_iter *ii, loff_t pos, + unsigned int max_folios) { struct fuse_args_pages *ap = &ia->ap; struct fuse_conn *fc = get_fuse_conn(mapping->host); @@ -1240,7 +1240,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, int err; ap->args.in_pages = true; - ap->descs[0].offset = offset; + ap->folio_descs[0].offset = offset; do { size_t tmp; @@ -1276,9 +1276,9 @@ 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++; count += tmp; pos += tmp; @@ -1293,19 +1293,19 @@ 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); + ap->num_folios < max_folios && offset == 0); return count > 0 ? count : err; } -static inline unsigned int fuse_wr_pages(loff_t pos, size_t len, - unsigned int max_pages) +static inline unsigned int fuse_wr_folios(loff_t pos, size_t len, + unsigned int max_pages) { return min_t(unsigned int, ((pos + len - 1) >> PAGE_SHIFT) - @@ -1330,16 +1330,17 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) ssize_t count; struct fuse_io_args ia = {}; struct fuse_args_pages *ap = &ia.ap; - unsigned int nr_pages = fuse_wr_pages(pos, iov_iter_count(ii), - fc->max_pages); + unsigned int nr_folios = fuse_wr_folios(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_folios, GFP_KERNEL, &ap->folio_descs); + if (!ap->folios) { err = -ENOMEM; break; } - count = fuse_fill_write_pages(&ia, mapping, ii, pos, nr_pages); + count = fuse_fill_write_folios(&ia, mapping, ii, pos, nr_folios); if (count <= 0) { err = count; } else { @@ -1356,7 +1357,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 2533313502de..52492c9bb264 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1090,7 +1090,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 Wed Oct 2 16:52:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820095 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 A221C1D14FC for ; Wed, 2 Oct 2024 16:55:24 +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=1727888126; cv=none; b=NbuHme5xURSBkyBctcNq8V6O13nijC/l3DLmfk+7D8eAxrXAXPOB4tRfrNR6J8tpMGxi9sv0oiUdm8rud4ofBWv40D92VWBn71+r4SQ81kITMM5Ly0SP0AtKRTFVwNX4lZM0bd6HdJp2stjJLr5F83pb2BTGaWWKigWfK45fKOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888126; c=relaxed/simple; bh=VUALdsOChm/UH/6xww+Lg2kfoHu3w/qCV+qNhUKP7TA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HKYHf5iy19o4vw+ZQ84T1T3f0gskg560ALVv70HA4qoNg5Bv3EVBxKbP3dnblgdsB/RxOEznoj2/kFLrdNgvMjDBlZHyNbLgYrl0i0vUuskR40zbCji5EVDbNoqjT0CdOC+Hyt0yYtUu1ddnyAW3C9g85IYs4wd2+gs5O6IHSmA= 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=KdpL4tgQ; 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="KdpL4tgQ" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6e214c3d045so178117b3.0 for ; Wed, 02 Oct 2024 09:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888123; x=1728492923; 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=7cJzDyKn+uNfg5WYDJfs1LslS4wz8yVX2GO7J0Zcue0=; b=KdpL4tgQf97/qPm6tGvWNfBcCjdLS1r2/ZMPzU69pt2vyhfGo4Scz4ksItekw4KJam VWJB5N6M8fds6zDnm0rk83yB3S1HJAcCTb1xQtVsumwUL89DLTdg59iXvFfjQXMVbbmY kONMYgo706PqTeKKiuZwlK2XfLC3v4evRVmOqCfTcfw4WxXPOK1fKeskJ9/NuPtMFVTY 5beW0kkC9nnCGrIvzfjf8lV5uKcm/0N85c1SIQCOEJHs2dIh3wbWJpssg3+UG+awpw8P j3hfhkQAPiZKI2JDwHfrhW/UojFyvVGMEvKFG7xqRimSY/dD2vEmYenH4E+kzTjMSb9H +Fpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888123; x=1728492923; 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=7cJzDyKn+uNfg5WYDJfs1LslS4wz8yVX2GO7J0Zcue0=; b=CxBbiAeUX/7NU9XlMvwkVoybJGnfDBW3fyDZbrMJHghUQVNbuR62qmdRuK8RVqK5ai 1HcvTiCQTS7TSWqdEP0mE+6ou144Xk/9zsidlwN143Ve2o5wIloNoQf2K4yvPI6trwK0 hVx7yKeknVxoOjP1eEPVraRKI29LfzV7utRGMAITrgHlomhMgoeZOBaOX3HeyJrABOWJ QQ5o3oUabDfF8njMfklpf15jZECdFEf5SLu/4VUkkCZ0BeoguAgy8Q4AMJJEU3JnBH+j X0Y/o0erlkn+u69dKq0Ee50F8obLJdzvGmiIm5XB4/MmEe8Mj/15W5bRnxFubcDNh2ds BwUw== X-Forwarded-Encrypted: i=1; AJvYcCX3dVUGZVQPbULB9S6t3bcX1aAPotG4wmCK2i1XVUuLgslyf6JuOadNzpx7OcwOhYW7QDMHHZkdJDyihp7+@vger.kernel.org X-Gm-Message-State: AOJu0YwJn6uQJaGyqMPiL+k4Dt38UEd/RFhlYRjEmeeLqN9/W6hHUNpa GkqhJrT1+sBWz7Xx9PbzWJrSGbCMBKuQBNKRoFXwHQnKRoEBBKde X-Google-Smtp-Source: AGHT+IELgxFaSJdIeJAzIlW+xQ09HZDPpr6mdghKGEc/BeKgUpljKURCOjh1enkY7HAwLWwEP22ojw== X-Received: by 2002:a05:690c:2e93:b0:6dd:bb05:3137 with SMTP id 00721157ae682-6e2a2aedfe8mr30581327b3.12.1727888123412; Wed, 02 Oct 2024 09:55:23 -0700 (PDT) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e24538880esm25636977b3.119.2024.10.02.09.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:23 -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 08/13] fuse: convert ioctls to use folios Date: Wed, 2 Oct 2024 09:52:48 -0700 Message-ID: <20241002165253.3872513-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- 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 52492c9bb264..d9fa12aee07d 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1045,6 +1045,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 Wed Oct 2 16:52:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820096 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA4381D1511 for ; Wed, 2 Oct 2024 16:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888127; cv=none; b=EQJWaJLzaRzeskjw60yfsHxRwn+WUTfQH3Xrn1o8YC2LyHddKa1xvTlBriq/IgqYiwFwgvaWLzZyx5cMZHcnh8yozec/3+HjkZYxEEgRttxmL8bvXo8s1CNv8qOQFaobYG+pRu94i7sD+GgL1JICjuBoi94Dxaib6KkGtbAFkVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888127; c=relaxed/simple; bh=LlxygvPb64LbLRGdesH0o8BMqn9NhYcJuYCOJeo7h4A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hj2c/COdYMrwTPt8/7RBm0NvMWf7b8OGxsRg4AqqSPbOy+cIb+liiTON9Glw2F20nsC/gleCzovzGwwB+1LX4LbgmPKp06EXwmvzBzwXkRt6+CMsKmPK3Uzcz6hok7RFN6z/EQSsiBVT1idDR4jBdWXo9FywH87T30FEenlkysQ= 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=Bnko0o0W; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bnko0o0W" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6e22f10cc11so54580257b3.1 for ; Wed, 02 Oct 2024 09:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888124; x=1728492924; 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=Ldm77ralTngvKGT9ivHSp4XcFmcs7y3I7OPXiXbAQXk=; b=Bnko0o0WWjPkmw4WMlLaqXqdphs12CuNLzd7ESGFYrbNZOToheeAj5JX+fGjHrXGYE amwPj363jqhO5jUGlU3qMP0VdKWP6fBTd2kEJpSICmqX5dGs7ET9baIUxj98y1ZCePQP 6czs1rhYcI0AldqOpJ4cYSCP4t0nHo/ZdcWE5JY0g0H7kQnSowgOjIwMTxZ5NTFmGK+/ 6kRq8ZuWGS6TLr2tuvam46X8TRFe405C+Vkv1MYqVp5VYvNWj1y/NI1yMdLmHt6/mrku ZeSqOk3BFuLaEeFnX+tyEHlTzPSysp0/AeA1yBtSnlysZjGLiutlpreOpbXwOzpOJLiX bDMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888124; x=1728492924; 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=Ldm77ralTngvKGT9ivHSp4XcFmcs7y3I7OPXiXbAQXk=; b=Ye/GMGv22iN/qNJ3nWHMLUS1yl4CKbaGuu7AG6sF6q7gOzMv90ZPa2dSaQyhsy+vfp pgsxA6PmIwDayUaq45YjS/zk3gnDdDA8fk1Cu2YltLE+7OTg+i14F05LilkYi7WFlaMM d6Iwbx9SoycMBTzY4fd82tUdDhzzpl3pVfjw113/pncrdK2lvNnQ2i+8ZTvjfbOqSClK +cNGSFctJobU2K13B2hc2JfGEZk+wQGgjDhYu/z+4NxyRlotdLnpev1RoTDCEPhrqMSg 2E6TZLoCnOeZmvKmjXLtwxWoGk8HEDy+wkwa7GQvvcZLTBlvlhsiJRk/9HZJkbbP2nJx 8zCg== X-Forwarded-Encrypted: i=1; AJvYcCXOAz24aH+bdfQI93RRr336MjBqQq5jMqTcl8UU8fgRqQUXdwGA+pokWWsKaTssJFM0GeCuW8gTGYxMr+Iz@vger.kernel.org X-Gm-Message-State: AOJu0YwiRAyasm32ICuLLWUDIuxShpTb6QMk+rDvJyuwvC/GgfmlVPBf mhtGVahrYeDIrp2VJzhwOaUjSBo6Xa2CP4mad131iPDzf+r3ee7xMOb7xg== X-Google-Smtp-Source: AGHT+IFzh/OBNYITHbx6X+HX5Fv+w99tuzV0sdrtxXccYWMjY6C0D36xseslW1g3AHGQB57721Hkcg== X-Received: by 2002:a05:690c:f95:b0:6e2:b263:1054 with SMTP id 00721157ae682-6e2b26365cemr12538017b3.4.1727888124666; Wed, 02 Oct 2024 09:55:24 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e28823a73esm12870227b3.100.2024.10.02.09.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:24 -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 09/13] fuse: convert retrieves to use folios Date: Wed, 2 Oct 2024 09:52:49 -0700 Message-ID: <20241002165253.3872513-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- fs/fuse/dev.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index cd9c5e0eefca..2f59af6a8c22 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1727,7 +1727,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); } @@ -1741,7 +1741,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, unsigned int num; unsigned int offset; size_t total_len = 0; - unsigned int num_pages; + unsigned int num_folios; struct fuse_conn *fc = fm->fc; struct fuse_retrieve_args *ra; size_t args_size = sizeof(*ra); @@ -1757,18 +1757,19 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, else if (outarg->offset + num > file_size) num = file_size - outarg->offset; - num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; - num_pages = min(num_pages, fc->max_pages); + num_folios = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; + num_folios = min(num_folios, fc->max_pages); - args_size += num_pages * (sizeof(ap->pages[0]) + sizeof(ap->descs[0])); + args_size += num_folios * (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; @@ -1779,7 +1780,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 && ap->num_folios < num_folios) { struct folio *folio; unsigned int this_num; @@ -1788,10 +1789,10 @@ 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++; offset = 0; num -= this_num; From patchwork Wed Oct 2 16:52:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820097 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37A811D1516 for ; Wed, 2 Oct 2024 16:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888129; cv=none; b=G0NR8y2AZElMKJ+arPaLa3PAujH8Xn1eslLTFUCzUT3FM+3qLEvF79GoGVtrNvJOkplmgPr/Z1q7mkhZFPUUlOB3S6oVC7sFVNtpfKlzditAiQ/1Cf1vBC2LM6tVZ39Tjis30tZIpMBLc0IeKXq/TICQ3Hg3EvnB6fU+QFCLYHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888129; c=relaxed/simple; bh=LUJtOKlcilbXuWZjYNWpigAGbUM8R7OG47/fEwXimhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CSUm5ezkfYu6vxnsQvr1iRif6f4W54P8XSadDyZxe42+BqS5fG7ysqdbEGo97XkRUQWvtmwqKiAArs8QqP10cNFw7Dpl/mov4aO7UYIiDUfiBkSUIaZdUJPymUJNVwkpRpfk/FKx4uUziB1VLUfw/O2i/P7lKgJnzKj+zFecwr4= 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=C7sIOykg; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C7sIOykg" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e03caab48a2so54289276.1 for ; Wed, 02 Oct 2024 09:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888126; x=1728492926; 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=gL35HsWRDGuvaw69PJO3TKy1VSEypS+VWs7KCQHy+8Q=; b=C7sIOykga7HwUWeVLGdYIjeXqcSztuJhA9EFPPsf8FDt+ZO0UtCuhLAfEXQmbFmkWR CwSSLe/zCJA2NWpLL+3llyjgOYYXimSHOgWcm6PSyc721obyWKGTjx4IZDUo9TiGpW8Q kbjVdmpZenV+bwWIt8rq1XPdKeaYHdjCQLjHx22unLAboCNFTxpML3uzlhpnjaQWPvRR 9LTSwNP5d1CNJWuJaVu9PY/EshzB4mEzeg6goFHgrbykL4AUqkRWUU9isWc+BDrueEzs hh9ah9/u8AjPIQhtFJ+m06sHYvmL2S3fbwVWvOSgIDaPfkUDZzmaueJga/DAlhd0+yPf ZDjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888126; x=1728492926; 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=gL35HsWRDGuvaw69PJO3TKy1VSEypS+VWs7KCQHy+8Q=; b=eOmt3VuHif4hudaSdkpg0dnJG10pU05OvHxTxHfCBDFbTkf0Z+HttntCM4jNBJ/HFz uhfJ7oOu9woyoXLiIqN0HhqaL0FREZIn9iGZbkN9XbSw2dTpvcN7XI1sEWYVmFzld9UZ He8i+uqluWTQ8jxgjx5+1eLkpxvDnfdNVGrWdu1jCJoBUq71uyqArVuGVqtnYJzuS7EE Zo0oHo/CwdEbWX2DW5ILcb0UYbnflQL/3PGx7AIAEhDnsO7n/yf1qffMKdpAIzHjoq8B reRALwIqjJuvUkWgXU6X0jD8pLILiegx6BPUnRNuq3KX5SLv4XlboWVyeuvaSAIXPmKp Mi5A== X-Forwarded-Encrypted: i=1; AJvYcCWV48wcBRTKjUMuI0CNz/ccj+4vkdG7fSRuMeihiCH7QrNgSEJyHR8OtjMzZTfpF7Yng+VQSMscvM94gStm@vger.kernel.org X-Gm-Message-State: AOJu0YzZOioTrvsdwlOg04eTYGtxN56BnbuKclEEDpV2tSe/v5CvlWwJ ZzPW25zxEaBkVA1Yh9d1B3J1025ok7KeExJKFkFmbWkAYbvVuhwY X-Google-Smtp-Source: AGHT+IEU3VC2l29iOqRZEd+JCojra8GynTqMIXtQEJiYMHyU63DTBgYjz/gStu+sTnbQG/H8mUx5lg== X-Received: by 2002:a05:6902:140e:b0:e25:ced5:34e3 with SMTP id 3f1490d57ef6-e286fab7742mr249770276.27.1727888126028; Wed, 02 Oct 2024 09:55:26 -0700 (PDT) Received: from localhost (fwdproxy-nha-004.fbsv.net. [2a03:2880:25ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e25e3efab1dsm3984150276.6.2024.10.02.09.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:25 -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 10/13] fuse: convert writebacks to use folios Date: Wed, 2 Oct 2024 09:52:50 -0700 Message-ID: <20241002165253.3872513-11-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- fs/fuse/file.c | 125 +++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 0f01b4fa324c..1fa870fb3cc4 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; @@ -1810,12 +1810,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); } @@ -1835,8 +1835,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); } @@ -1851,7 +1851,7 @@ __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; + __u64 data_size = wpa->ia.ap.num_folios * PAGE_SIZE; int err; fi->writectr++; @@ -1892,7 +1892,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); } @@ -1927,11 +1927,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; @@ -1942,7 +1942,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; @@ -2074,9 +2074,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; } @@ -2100,16 +2101,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); @@ -2166,7 +2167,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); @@ -2194,32 +2195,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; } @@ -2229,7 +2230,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); @@ -2237,8 +2238,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]); } /* @@ -2249,15 +2250,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); @@ -2271,9 +2272,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; } } @@ -2287,7 +2288,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); } @@ -2298,7 +2299,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 @@ -2310,19 +2311,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; @@ -2359,7 +2360,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. */ @@ -2371,13 +2372,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) { @@ -2386,9 +2387,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); @@ -2422,19 +2423,19 @@ static int fuse_writepages(struct address_space *mapping, return -EIO; 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); } - kfree(data.orig_pages); + kfree(data.orig_folios); out: fuse_file_put(data.ff, false); return err; From patchwork Wed Oct 2 16:52:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820098 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DDDB1D1728 for ; Wed, 2 Oct 2024 16:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888129; cv=none; b=mpMdTD/RQGT6T7phK8Jci9EBp112AG3N6byF2kaHQmT4ls9xKPcB6KXHhBjOZrFGt82pSiyqmF3NF+UdmOcmll0SfiD687Oow00B2g90rdyUNRDx3pSEB7dxHD/Qs8YUBN5Va+EoavtbIelPBzdeKPvog5IFMAqEZSCage6diQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888129; c=relaxed/simple; bh=z0jzrAVwUj+wlUqi10T4RxWMvzfAFR82rl0RHi13/3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gXfe/pT/MUJ1EmOVfdpcISyLnVxGwIjxERSjaTch0IysU9mIKrMmbjWs3xrHg+L76jCbr/aWiWtL7Gqt10FwbHlFRl76GPyzUIZnImqrHzdRCjcz+Xhx/um+sT0+WoEGePRi8rS4MyIg0SbPad+Uo6Xvz9sY+KTKIFgTfHBldVc= 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=jhS833p/; arc=none smtp.client-ip=209.85.219.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jhS833p/" Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e25d57072dcso29025276.0 for ; Wed, 02 Oct 2024 09:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888127; x=1728492927; 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=HNsfIkoLfAyupuPYO+kOiKo/vH/CGwDLTjW09giv0OA=; b=jhS833p/9xtLXe+wuew3TOWm46r4ixXec4PzWFmXOpzMBlwkr5fiKE0T6gf+wKkoza 3gVQN/vBqoAJfTcqVCu2VjUkNAdkBmnYg/a839qMbWGTmzuGtC6XIPWGeL+UFFaOq5VB iuBxXdLK9wiHt5IqoY8ISqKphTtrOBW07aX/+yr1G0sP8su3s4do6m8hoe47A6AhvTPr 9FYVLoNhiXScdiijyMCZaN8qTeIVMf/zT98NEvZ8NylCvO8bviH4FyDP4HI5BTXtU0kE MGilE0Fvaf7FcBnPJpH1dzGwlwlOxv5l/KzUM41TntCSsI84hGwkiz5KhndfC831lDPn Dbhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888127; x=1728492927; 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=HNsfIkoLfAyupuPYO+kOiKo/vH/CGwDLTjW09giv0OA=; b=NUaEoW02YpTyRbUjhW7UkVzTLIl99cuqyI7BqOBuq5H6dbUdgizU0QtcFevgQzrvz9 CCgg9OOxBOrJM7SO9NORynCaV2Rj/caS8AYshOwehC4a6msq8kz1RqoawvzqmaGWM5aV VC0CxvyQb+qn/Qkbfq67AapZaV7BbFl2nqa3BjxAz4/x482NcR99NX8jv47qG0yh56nt YuRFqJnpXpV7LVZlPIq+T5aDWjAYDiYJjQV1EvFjoka6AE9yqvhXJLLCYTSTgmmL1lOP b1pqeEepzeO8jDRqEpVdsG3Y6g5Zs26+8JkfC6vQ8N/iXrKotD1x/VTCnOr5PwrOMZVO o6kw== X-Forwarded-Encrypted: i=1; AJvYcCWBuSC83nktDLN+A6882DBbYNFCh/G3vwhV23WQKB74cRMiyO1DcrsDrvVxizUODS86O7ah+X5ihneqeJUW@vger.kernel.org X-Gm-Message-State: AOJu0Yzmz/iUzEGYpCAECwIff5SaNqdx5dbY0Isvl+w9O5Bl/4cTl6dp Jgy/Dk4ho1YpRp4pFCdlVaRR81N+gDKe+r7z+avOtX66hDjR34P2 X-Google-Smtp-Source: AGHT+IE0nQq+u2gpgqB+qOoyMqjAoFCBEmdL3ctRS173F4/W5nal4mvzgPEwhYAR/pq14lvVCxAmLg== X-Received: by 2002:a05:6902:2291:b0:e20:296e:48bd with SMTP id 3f1490d57ef6-e2638382edfmr3579349276.2.1727888126952; Wed, 02 Oct 2024 09:55:26 -0700 (PDT) Received: from localhost (fwdproxy-nha-002.fbsv.net. [2a03:2880:25ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e286d233373sm204436276.36.2024.10.02.09.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:26 -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 11/13] mm/writeback: add folio_mark_dirty_lock() Date: Wed, 2 Oct 2024 09:52:51 -0700 Message-ID: <20241002165253.3872513-12-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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(). Signed-off-by: Joanne Koong --- include/linux/mm.h | 1 + mm/page-writeback.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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/page-writeback.c b/mm/page-writeback.c index fcd4c1439cb9..9b1c95dd219c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2913,6 +2913,18 @@ bool folio_mark_dirty(struct folio *folio) } EXPORT_SYMBOL(folio_mark_dirty); +bool folio_mark_dirty_lock(struct folio *folio) +{ + bool ret; + + folio_lock(folio); + ret = folio_mark_dirty(folio); + folio_unlock(folio); + + return ret; +} +EXPORT_SYMBOL(folio_mark_dirty_lock); + /* * 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 From patchwork Wed Oct 2 16:52:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820099 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 4B70C1D150B for ; Wed, 2 Oct 2024 16:55:29 +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=1727888130; cv=none; b=c6xhAQYrM/+OiiRSVOJvzaqGJtp3EtJSOK5RH54Xqfc7KvCL0+IP3ngjnaIebicuLw0TRD4URQlGd8pC+mf12Dq5eufeos++Wgg2B8s4Zr9vSq8Jq83UxhoguEZrLoc133MIK2cEXBl7Kyl9RPYPTA8NiTwY7TlVRWLX0c0hXsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888130; c=relaxed/simple; bh=xR4UM9oCmE02frXQu0xHjIGkQQxVZBd1GpKxHYD05O4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nf90KUkVjIm4QctpCXPNxGNg43Y3DWigk0oUgOG8n6a3fOHyJRgSAGxtPA3Nw+yWe25ap4XMLxGnUhJEwIml96I8TYf0ax6WjemW2FBq/1MWqyZ+p/1iFbJJOxVqR7MTasXhhC2kTz2bm64kq0zaE29zSn7FjSVTtJARKdcQPdw= 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=mgY3wIPk; 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="mgY3wIPk" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6e214c3d045so179217b3.0 for ; Wed, 02 Oct 2024 09:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888128; x=1728492928; 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=g8DsfLSr/NMs5kxUIKVam3/UNO7YeIGWQF4+6qkmNtU=; b=mgY3wIPkAqAyYMx4SQk2hiL7PZO9SqGzJlbZIt+Nm9o6vXKDWaxhSdME6G6xkh8aoU 5ZuDVTjqvxuz21cuPCUNI8jbrXQn99AGD4xrvwh51BOMB6IpFx7whLB2MibNj/HCwP49 9Jl2z3+3iKw/GCs9M+VgM/uY+mFPCeckUZOwUV0xG49gBjkqEf//zE0X5lBdXuJHzb8c mieKe/6f+SitWcCWjBcBxRnJ/TdaAxoj1oATaMlmW1xUpK43ixHG40Jr8kfhvWEas4VL GQSVsxDJos5B8LX6aFep2cP2i5QDJFuCFcC1yZjaryw0aY3A7x6GaTALdwJsJiEcxabH uoEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888128; x=1728492928; 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=g8DsfLSr/NMs5kxUIKVam3/UNO7YeIGWQF4+6qkmNtU=; b=BfHsHPfHcGTauEsRsfuzqNIUb4XX3KhoB3+vhZE837KCOA+ZNi4LsLgFpoDQ7MBwFV AJsUBKCBGSGdxI7MyqbNtgImKt+qCpgJvd2N9TRcYeWX20dI3KN9Rynh6rlG+5Djz7Ug YViuHJFTe27D8nnxKvERuA87/A2ic9rAlRQERjThFlIPRtHIjSQI68dP0xyv/fEhiB+n HCs7jAvtQtYYCI4AfxWh46KfrNoPk7swosyzMOoW4Laue9Ro/voHxPe3Zzv4LhfVFDZa paeqeLrRakZDOD/iUQyKvFe/GiynOFoaeoA9JcdXEzXRCnpMFYFIrJpKHT4Tqd/aOFRE nDBA== X-Forwarded-Encrypted: i=1; AJvYcCUqVAraE81ZbAycvFst4ageiTYCUNRc8pKCLSkJToSbbEEspGYOGwOnwb8zmbnVE6nZu/uJieRhepqIKkRe@vger.kernel.org X-Gm-Message-State: AOJu0Yw7SCFxmGNZ03hzZdC32P/vzBvbnoKh2wbtHig0Xd41g/OzK8Az JM2D2Kozhlt1+MfP+j/UURRnOETlmkdhPVTdPfm9lDdoOAl429FXnOg4PA== X-Google-Smtp-Source: AGHT+IHSZ2ZX7syUPfv+xRNyUZzatNDwceTVTq7Kbauf5XE4hVvvY/IjdwoserXCMFgaWVfjzKLTiA== X-Received: by 2002:a05:690c:508a:b0:6af:8662:ff37 with SMTP id 00721157ae682-6e2a2b112d6mr26779037b3.21.1727888128245; Wed, 02 Oct 2024 09:55:28 -0700 (PDT) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e2452f9ed3sm25329017b3.12.2024.10.02.09.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:28 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH 12/13] fuse: convert direct io to use folios Date: Wed, 2 Oct 2024 09:52:52 -0700 Message-ID: <20241002165253.3872513-13-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- fs/fuse/file.c | 88 ++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 50 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1fa870fb3cc4..38ed9026f286 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, { 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]); } } @@ -739,24 +739,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) { @@ -776,12 +758,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); @@ -814,7 +790,7 @@ static void fuse_aio_complete_req(struct fuse_mount *fm, struct fuse_args *args, } 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, @@ -1518,10 +1494,11 @@ static inline size_t fuse_get_frag_size(const struct iov_iter *ii, static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, size_t *nbytesp, int write, - unsigned int max_pages) + unsigned int max_folios) { size_t nbytes = 0; /* # bytes already packed in req */ ssize_t ret = 0; + ssize_t i = 0; /* Special case for kernel I/O: can copy directly into the buffer */ if (iov_iter_is_kvec(ii)) { @@ -1538,15 +1515,23 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, return 0; } - 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_folios - ap->num_folios) * sizeof(struct page *), + GFP_KERNEL); + if (!pages) + return -ENOMEM; + + while (nbytes < *nbytesp && ap->num_folios < max_folios) { + unsigned nfolios; 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_folios - ap->num_folios, 0, &start); if (ret < 0) break; @@ -1554,15 +1539,18 @@ 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); + 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); } + kfree(pages); ap->args.is_pinned = iov_iter_extract_will_pin(ii); ap->args.user_pages = true; @@ -1594,18 +1582,18 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, ssize_t res = 0; int err = 0; struct fuse_io_args *ia; - unsigned int max_pages; + unsigned int max_folios; 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); + max_folios = iov_iter_npages(iter, fc->max_pages); + ia = fuse_io_folios_alloc(io, max_folios); 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; } } @@ -1620,7 +1608,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; } } @@ -1632,7 +1620,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, size_t nbytes = min(count, nmax); err = fuse_get_user_pages(&ia->ap, iter, &nbytes, write, - max_pages); + max_folios); if (err && !nbytes) break; @@ -1647,7 +1635,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, io->should_dirty); - fuse_io_free(ia); + fuse_io_folios_free(ia); } ia = NULL; if (nres < 0) { @@ -1665,14 +1653,14 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, break; } if (count) { - max_pages = iov_iter_npages(iter, fc->max_pages); - ia = fuse_io_alloc(io, max_pages); + max_folios = iov_iter_npages(iter, fc->max_pages); + ia = fuse_io_folios_alloc(io, max_folios); if (!ia) break; } } if (ia) - fuse_io_free(ia); + fuse_io_folios_free(ia); if (res > 0) *ppos = pos; From patchwork Wed Oct 2 16:52:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13820100 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 B7BF71D1730 for ; Wed, 2 Oct 2024 16:55:30 +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=1727888134; cv=none; b=s9/KaFKXdCvWYQo4R+I5IwC6TOXWoBOhBYHMdJClhC9oJ4AFn9GmAotrJyE9eIv8UM/s77wR/rSYQht2F5rjVP46bsfGRMGujTkBN7E7u4XLpU5qk0g9NHf4XC1BW/n1nvLZ+tmw7ZUwCN/OB1R4CtkobjDVzzDv+BHMeiWuOzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727888134; c=relaxed/simple; bh=yR0hW+KLcHj9ItOah3WSaKvMNerGJnqsZiYR4YSNNsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EbXtItagD0qKAW3xiP+eDUrMcrlicv+DxdEUO15OIoQ4i2DTeUSgzOOmlmn7Za8mfHieu1gQs1npEy7MnT/JWwZjSR9MB9eHZ/73AqbVYqXA6KHkMFowy6StqT6jRg9K+Kfd44s/pxVmdZzngigRg2gY60e9/Yj9LVXGCiDlCrc= 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=X3fR2Mv+; 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="X3fR2Mv+" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e026a2238d8so13671276.0 for ; Wed, 02 Oct 2024 09:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727888129; x=1728492929; 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=WThkpNSzkhzcwAbyMZ7NvGW3nEKriK7cOfyXAk/GufQ=; b=X3fR2Mv+C7MO5iT3++zXbEFHnjsmbC3mhsZqMmpMff8HbnNUKBAK2uVWhaEr1NnWAi FfIMKCNQa8dCEiJFe6l6yeJN6A6bvAokf7geccwohModZz5cPNV5aFPBtOKIxbAOgxMm jpd+EvMhU6kHaJmW4dLxuhgh95YewKDe2l0xcZkHWsPc7gOCm+Y0TbOgh6bDdbN6K+pL +Tx5tMKtT/PLJd/MPl8K8dIs4idgGPx9RqWs1d24sEbeCgCpJoG8qZmQsJ5AkpS9gM24 VqHd6lS+6WQFZ32mlqAK/3hdjgNbt4eIQckoy/dJD7R+AuC08DsN+INREEEO19eTbjze Dh1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888129; x=1728492929; 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=WThkpNSzkhzcwAbyMZ7NvGW3nEKriK7cOfyXAk/GufQ=; b=O2NQ2Gn/K3aGTrV5bJfr232AqAM3xDg5PUeh8QBfSdumuNNP6LJtW9LGoGcUyoRYSy J+x+OnIP+FvsD0OrQ3NEiLRRhidDdAIGMvYMoXbAWC7qgkyDk5AmQyXdbd9m+RCPGL/3 Khhs9zqSw1ZYGK4WtpOZBK4YRxsYdb0WiYa66tx0TUHjOfeVOBsE3tPyrD/Yb9ifhdoV 7fQzwFo4ePNC3GfZwOqcj+t2CZasAc/hd49q/BXL7LcTRm+ozXNFCyx2a85dodXfMDsk PBgxex/nLheuJPJLp6XzJj65v38tf0sEZ/UDtNwHNJGBiJkKkQgczLN4Rk6WhRSmreCh FNkQ== X-Forwarded-Encrypted: i=1; AJvYcCVE2Gv1wLh6DXgUsWD27HDGvQoE/qJXJMHeVZcLQuCLywbSJi6eJ6k4Hze10IRnwNwwQQbNU0cMmzPc3n8a@vger.kernel.org X-Gm-Message-State: AOJu0YwGrPMW0JpwZZ04WRq0zalvVVXkL2Edfg6ceH9drIj7YtXSfWYI OHGr+lWKhD7Ay7ERIJKJ3T2er+tQmUVcWo9pudNgIwwHKnwCgy9P X-Google-Smtp-Source: AGHT+IFWrIFV/zfiWpVVZxOJrTVYtO+U7NT7D1G5B5s06UfWh3ApVBUAgVb14gsPDHCS1qu6eeIkTw== X-Received: by 2002:a05:6902:1546:b0:e20:2bd7:14f1 with SMTP id 3f1490d57ef6-e2638439fcamr2948938276.56.1727888129465; Wed, 02 Oct 2024 09:55:29 -0700 (PDT) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e25e6c3067asm3864708276.53.2024.10.02.09.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:29 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, kernel-team@meta.com Subject: [PATCH 13/13] fuse: remove pages for requests and exclusively use folios Date: Wed, 2 Oct 2024 09:52:53 -0700 Message-ID: <20241002165253.3872513-14-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241002165253.3872513-1-joannelkoong@gmail.com> References: <20241002165253.3872513-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 --- fs/fuse/cuse.c | 1 - fs/fuse/dev.c | 41 +++++++------------- 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 | 94 +++++++++++++++++---------------------------- 8 files changed, 52 insertions(+), 107 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 2f59af6a8c22..00390a0cd010 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1028,37 +1028,23 @@ 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; - - /* Check if the folio was replaced in the page cache */ - 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; - } + /* Check if the folio was replaced in the page cache */ + if (pagep != orig) + ap->folios[i] = page_folio(pagep); } return 0; } @@ -1769,7 +1755,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 38ed9026f286..2bc860bd3ca3 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -747,7 +747,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) { @@ -873,7 +872,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, @@ -1309,7 +1307,6 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii) unsigned int nr_folios = fuse_wr_folios(pos, iov_iter_count(ii), fc->max_pages); - ap->uses_folios = true; ap->folios = fuse_folios_alloc(nr_folios, GFP_KERNEL, &ap->folio_descs); if (!ap->folios) { err = -ENOMEM; @@ -2063,7 +2060,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 d9fa12aee07d..60c76f8afb9e 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -322,19 +322,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 5e7262c93590..9c09ee22caaa 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -773,29 +773,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; } } } @@ -1282,22 +1268,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; @@ -1315,7 +1295,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)) @@ -1328,35 +1309,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; @@ -1380,8 +1355,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;