From patchwork Fri Dec 13 22:18:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907977 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 669E81953A1 for ; Fri, 13 Dec 2024 22:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128590; cv=none; b=A1EqbvhW/fd9aGF9KKP/naxnFxrBjI9egswDc3c4NuZ3qyesjGgTuyzhzdmzWuVkniZ4fdXNDAmZDtHh0gUYmRldgxRY/nkYPFi9ogQbU5nuwbDQgP6lo+7Z9qbvjwUzUSK9V5OQECAj+x/iO9NVf0PKsxgZvv5yf2b/S2bEwRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128590; c=relaxed/simple; bh=zx45BIQkVQk1/O6TCm1Jpk8CRdeiY8MoRxjJ+OEqvrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OKNabzGzvnIe7qVf9HiyXoJs1UVhqPlM5B3HIMfIZUU+uRCcdVmXEzDvsN6jCfj63XrfOSq7UVkg0oZRXepERuYH6JC6YFvKWqAVNKnBUUB0OqJy8CGTDBwVt/thplezYNOoYlQI+rzS8eCZbMyVo+AycVvzpvRh4qW3iUaV0nM= 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=jd1HiKHg; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jd1HiKHg" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e396c98af22so1587478276.1 for ; Fri, 13 Dec 2024 14:23:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128587; x=1734733387; 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=bXxkqFnHJKbRSPssBl9tJpEWCP0BewvqeZs2upPjeWs=; b=jd1HiKHgWhBXG2ad8yQ+2WjnpGefH3P8HTP+St11USlCV4FjWXDey7FkvlqhBHeVsb mPQiJ0Uc6WirUMkt9l0Tsdgm5Pk1Sn1ZWI3udV1W9pvew+j6MG2AFGrlubQ5eTkBTsCP hrtdJ8gt3VG2BzD+n1xSiOIqbcElSMfndbH20o6vSuZ/9nfTfxWujrSpmsQ+MFT3kcZw fI2/pC5ryj+oL7jTBTL1tNtGvw5lHNE8vsW89B6lwVcPrysZiPN1nzXsMylm+av3r3BI kemE4PF8EWevzsEEPUscjbHWCY+874XK1AjkMdBNFsUya09CUOrvtMLF6/+tXY8AeTCN ieGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128587; x=1734733387; 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=bXxkqFnHJKbRSPssBl9tJpEWCP0BewvqeZs2upPjeWs=; b=Uj/+ikZAkv6EVHf0xJ+IxbDdkiUs43h2lh60jXmGwcGpokGA6GVkpm3N1W6Tkr6a+W 31ewLvrk4iTiWMURHONfG3bbq0o4pPjvIK5uRWWPQ+Du5Qlsj75EBOHjB+WHyNPEWztt gm9vgKNhvdfD939Z388VQati/KxDByJdpet4hAbyBC2KX7rcKZWzCrb+d563H0iq9DIJ IGAZ7uaIf9kngS78cm8xIVBrW9orFI7n5lTXL/+TNe7nUBfii7X2Eu3SxDVHhdAcPE+F O1AW1dxB9K9A1hPChJIAU+xHaiLaon2X83tJi5yiUBsuceXKVF5Wr3M2dTwvNVbwmfht JuDQ== X-Forwarded-Encrypted: i=1; AJvYcCWlaURRp2yC5AbaUIBf5KARrcWe4ubdgzHsC3bCrssS0pb3k4xFrAs02gn2SMmtPq4tIomTiWbGgzhBsoxx@vger.kernel.org X-Gm-Message-State: AOJu0YwQn+BRJfxGUYCxdGrJcZ9cZSedeaDi+xE0RMi3Vd71ZvHolG7T UClnp4n7uZFVi3v2Llh4Mu3803Xo56u4YPvPWUxlXeRWULDx/mHt X-Gm-Gg: ASbGncvTo7xL+0XMcolZ4pFl4336QdozeJyg80G61GvDFmynPYYFfulJHLgbmvICDxN C/dErDkfw8QTxf2Con03dKbySBMC1giay+CMVfJn6yTh+wD8p9S3hLnN9FAsXbbER9fzzHX/3p3 JhWaU19/3qWV5Zwu4Hp9NRJBKtyOCRGBunPJ63OS+e0duSD0yftiNAucD7Ol///xiprCQuFqu7N 2GU0f2tQmhYqp59XPMG3QgIGqypBKda+l/Q3sUj9yYXPggnto+ZmEnpSQw0of8PBUys5pFbJ4Hx C9pe3YwGxFOW08M= X-Google-Smtp-Source: AGHT+IFpWPLSCCmjtyU0TK4DVO2VaSPGTqM7Tn3hopD/lmXQnvgw7Ki/rTD6jojv+OLGWU/7Y/AVXg== X-Received: by 2002:a05:6902:1ac3:b0:e38:9eca:e5d8 with SMTP id 3f1490d57ef6-e4351d10058mr3874211276.47.1734128587201; Fri, 13 Dec 2024 14:23:07 -0800 (PST) Received: from localhost (fwdproxy-nha-005.fbsv.net. [2a03:2880:25ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e470e54d35esm106007276.54.2024.12.13.14.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:06 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 01/12] fuse: support copying large folios Date: Fri, 13 Dec 2024 14:18:07 -0800 Message-ID: <20241213221818.322371-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, all folios associated with fuse are one page size. As part of the work to enable large folios, this commit adds support for copying to/from folios larger than one page size. Signed-off-by: Joanne Koong --- fs/fuse/dev.c | 86 ++++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 49 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 27ccae63495d..0a3dfb66c7cd 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -703,7 +703,7 @@ struct fuse_copy_state { struct page *pg; unsigned len; unsigned offset; - unsigned move_pages:1; + unsigned move_folios:1; }; static void fuse_copy_init(struct fuse_copy_state *cs, int write, @@ -836,10 +836,10 @@ static int fuse_check_folio(struct folio *folio) return 0; } -static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) +static int fuse_try_move_folio(struct fuse_copy_state *cs, struct folio **foliop) { int err; - struct folio *oldfolio = page_folio(*pagep); + struct folio *oldfolio = *foliop; struct folio *newfolio; struct pipe_buffer *buf = cs->pipebufs; @@ -860,7 +860,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) cs->pipebufs++; cs->nr_segs--; - if (cs->len != PAGE_SIZE) + if (cs->len != folio_size(oldfolio)) goto out_fallback; if (!pipe_buf_try_steal(cs->pipe, buf)) @@ -906,7 +906,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) if (test_bit(FR_ABORTED, &cs->req->flags)) err = -ENOENT; else - *pagep = &newfolio->page; + *foliop = newfolio; spin_unlock(&cs->req->waitq.lock); if (err) { @@ -939,8 +939,8 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) goto out_put_old; } -static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, - unsigned offset, unsigned count) +static int fuse_ref_folio(struct fuse_copy_state *cs, struct folio *folio, + unsigned offset, unsigned count) { struct pipe_buffer *buf; int err; @@ -948,17 +948,17 @@ static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, if (cs->nr_segs >= cs->pipe->max_usage) return -EIO; - get_page(page); + folio_get(folio); err = unlock_request(cs->req); if (err) { - put_page(page); + folio_put(folio); return err; } fuse_copy_finish(cs); buf = cs->pipebufs; - buf->page = page; + buf->page = &folio->page; buf->offset = offset; buf->len = count; @@ -970,20 +970,21 @@ static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, } /* - * Copy a page in the request to/from the userspace buffer. Must be + * Copy a folio in the request to/from the userspace buffer. Must be * done atomically */ -static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, - unsigned offset, unsigned count, int zeroing) +static int fuse_copy_folio(struct fuse_copy_state *cs, struct folio **foliop, + unsigned offset, unsigned count, int zeroing) { int err; - struct page *page = *pagep; + struct folio *folio = *foliop; + size_t size = folio_size(folio); - if (page && zeroing && count < PAGE_SIZE) - clear_highpage(page); + if (folio && zeroing && count < size) + folio_zero_range(folio, 0, size); while (count) { - if (cs->write && cs->pipebufs && page) { + if (cs->write && cs->pipebufs && folio) { /* * Can't control lifetime of pipe buffers, so always * copy user pages. @@ -993,12 +994,12 @@ static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, if (err) return err; } else { - return fuse_ref_page(cs, page, offset, count); + return fuse_ref_folio(cs, folio, offset, count); } } else if (!cs->len) { - if (cs->move_pages && page && - offset == 0 && count == PAGE_SIZE) { - err = fuse_try_move_page(cs, pagep); + if (cs->move_folios && folio && + offset == 0 && count == folio_size(folio)) { + err = fuse_try_move_folio(cs, foliop); if (err <= 0) return err; } else { @@ -1007,22 +1008,22 @@ static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, return err; } } - if (page) { - void *mapaddr = kmap_local_page(page); - void *buf = mapaddr + offset; + if (folio) { + void *mapaddr = kmap_local_folio(folio, offset); + void *buf = mapaddr; offset += fuse_copy_do(cs, &buf, &count); kunmap_local(mapaddr); } else offset += fuse_copy_do(cs, NULL, &count); } - if (page && !cs->write) - flush_dcache_page(page); + if (folio && !cs->write) + flush_dcache_folio(folio); return 0; } -/* Copy pages in the request to/from userspace buffer */ -static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, - int zeroing) +/* Copy folios in the request to/from userspace buffer */ +static int fuse_copy_folios(struct fuse_copy_state *cs, unsigned nbytes, + int zeroing) { unsigned i; struct fuse_req *req = cs->req; @@ -1032,23 +1033,12 @@ static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, int err; unsigned int offset = ap->descs[i].offset; unsigned int count = min(nbytes, ap->descs[i].length); - struct page *orig, *pagep; - - orig = pagep = &ap->folios[i]->page; - err = fuse_copy_page(cs, &pagep, offset, count, zeroing); + err = fuse_copy_folio(cs, &ap->folios[i], offset, count, zeroing); if (err) return err; nbytes -= count; - - /* - * fuse_copy_page may have moved a page from a pipe instead of - * copying into our given page, so update the folios if it was - * replaced. - */ - if (pagep != orig) - ap->folios[i] = page_folio(pagep); } return 0; } @@ -1078,7 +1068,7 @@ static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, for (i = 0; !err && i < numargs; i++) { struct fuse_arg *arg = &args[i]; if (i == numargs - 1 && argpages) - err = fuse_copy_pages(cs, arg->size, zeroing); + err = fuse_copy_folios(cs, arg->size, zeroing); else err = fuse_copy_one(cs, arg->value, arg->size); } @@ -1665,7 +1655,6 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, num = outarg.size; while (num) { struct folio *folio; - struct page *page; unsigned int this_num; folio = filemap_grab_folio(mapping, index); @@ -1673,9 +1662,8 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, if (IS_ERR(folio)) goto out_iput; - page = &folio->page; this_num = min_t(unsigned, num, folio_size(folio) - offset); - err = fuse_copy_page(cs, &page, offset, this_num, 0); + err = fuse_copy_folio(cs, &folio, offset, this_num, 0); if (!folio_test_uptodate(folio) && !err && offset == 0 && (this_num == folio_size(folio) || file_size == end)) { folio_zero_segment(folio, this_num, folio_size(folio)); @@ -1902,8 +1890,8 @@ static int fuse_notify_resend(struct fuse_conn *fc) static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code, unsigned int size, struct fuse_copy_state *cs) { - /* Don't try to move pages (yet) */ - cs->move_pages = 0; + /* Don't try to move folios (yet) */ + cs->move_folios = 0; switch (code) { case FUSE_NOTIFY_POLL: @@ -2044,7 +2032,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, spin_unlock(&fpq->lock); cs->req = req; if (!req->args->page_replace) - cs->move_pages = 0; + cs->move_folios = 0; if (oh.error) err = nbytes != sizeof(oh) ? -EINVAL : 0; @@ -2163,7 +2151,7 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, cs.pipe = pipe; if (flags & SPLICE_F_MOVE) - cs.move_pages = 1; + cs.move_folios = 1; ret = fuse_dev_do_write(fud, &cs, len); From patchwork Fri Dec 13 22:18:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907978 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 956271AF0B8 for ; Fri, 13 Dec 2024 22:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128591; cv=none; b=QtRjDN45clXPYv/h0ZxiwT/JDI99Z+cQa+dFwQTFIi/nCZHEN3zI41Hvxge7BWXzubw+xtBTPfxaoU8Vc+pM48KTl2+R4iV8V6bl5jN5oVXfDh6J1Xo33UND14MTnstm3fnTjUMZXGSs/+YhyYuJHNrijPJ789yjkjQ4PHpATS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128591; c=relaxed/simple; bh=pgoxoMavFBK/kOBZMzPwVd11ogo0sCDvez7C9DM47kU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b4Q+6J5GzcGdFqIh5xru19S640IOCvBX/t51B8GDfARoKmf1bKmf+ZPDIjQ4Qy7dw5d7cEb+ktEUoBPfAH5BriLFBvTrw4fQDj9qrGsSXx0upv9TJvlTB9PGxalh3l5PrPmyGOnOJhskUdZ+aq/DOZJQdqVzSaBZZSbCpdrwMcY= 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=MvH/qQqh; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MvH/qQqh" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e39841c8fd6so1729301276.3 for ; Fri, 13 Dec 2024 14:23:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128588; x=1734733388; 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=tpHWRjVwKAY5R+ea2581JyCF/Io/I+I7TrLjNfwKeP0=; b=MvH/qQqhx9cwcoL/pVrlcTZB0MP796dBNj5mpOdVT+kq1dI7qjNl5IuVillP8tb8XS F2Z2J3l27m+JN7I8xlgpWvpDWLItODUwlYBknD3SnH4QUwnp1/kGUjTNZ1AX3P1EI9io 7IdOMJlVC1RBcyaA2P5M6ogmouTVD3hhB0OfIuUm4wG0f27xOTxJQXMmY2GcowcryJEk cu9UF2SmX/FqgMj4mMRTe4OKf8eQDBk7LqKzYvM100mQsSOzqKX93GOjpGSaBkCHgWvH hpG9oo3DIiUSVuYCLJieZ9jDk0uBRd5E42adHOUVCIRocUTdagXHd169VJd5tRx+8PhK hDQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128588; x=1734733388; 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=tpHWRjVwKAY5R+ea2581JyCF/Io/I+I7TrLjNfwKeP0=; b=AR9VjTrexc8Uzoz1EYNll1Wq4zry4znlHKmUXNQRYlnC9F4VKePBHuMdFDBk3kepHp df7qGTSSYE4E9aE+Q2Uxj8BQhoqrLsw9iDb0k72qO9VeXpQfKXPbDpZ2ZWU17UnsBZnB xjShsxQ1bfpaC8HgpBECz4rwkz8++vi4CpK76MvSxv2zPuaqNE+WlkHO3aBnRIR8tuoi bITIVb9HmFIjWU1XTQg+6h+mOJv5F5sqjXGnfPOakIZuxMEwgjw3FHpwDLBwb4AvVQND l6XMlBSgMuL7qOcR8o6hKN+/xOi76jX66tJH3YEdQThGKbJpE4cQztN8h3cYVue+8gd5 bQng== X-Forwarded-Encrypted: i=1; AJvYcCU6kTw9A7BKeUOadL+HO4rYq7CNSJyb/OgnVipmwXIJVtkEZ4VpZ8rJ0lpIbMGlRRxGTpsIaRQrtbVyq975@vger.kernel.org X-Gm-Message-State: AOJu0YxAxKZhLaBGU66Es6b1JgCKhvQTYH842IclvuKfmsxey2J/Inii gqoh/f8liw4nL5entDUOcQweQzDPIz9upGWNaUQqFl18gCo5tWKyHZY7+g== X-Gm-Gg: ASbGncuw4n96+e6Hjvzkv+lGR7QIkqxie0cgLwT8aJr+3OyI6PMrW8P0uFX02QQrOu+ ygURXRQksDE9IquCsjvaTgfIwQPRkrp4wu9wTzFVlMrigGsRZT8u9CsMbs0M2YBGNioi4MA7311 zN3Htb0udRov7KUR9vI6yMgC+hmgMVcQ4yyI2pnAWIOvYmrE8QwwABvtFIlLQYhD4Z3LUAsznXk vthkRKnkc6KqOtrI2bpTYpUZ1aWFlm1gfuZwgMfoeXLMhhFSEL7j0BnP7aetDOLwtpfXrLmOAh9 QbN/x5zK1a7j6RI= X-Google-Smtp-Source: AGHT+IEX5G38sTEzu+EAaGdhwfNJRtL2wFyz6daf9Tn74EUuu6dws5muE0TjqHwc5615qYuRVfBXFw== X-Received: by 2002:a05:6902:72c:b0:e2b:da6e:7100 with SMTP id 3f1490d57ef6-e434bf3dbf3mr3856102276.31.1734128588555; Fri, 13 Dec 2024 14:23:08 -0800 (PST) Received: from localhost (fwdproxy-nha-009.fbsv.net. [2a03:2880:25ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e470d4f6ddbsm105585276.44.2024.12.13.14.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:08 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 02/12] fuse: support large folios for retrieves Date: Fri, 13 Dec 2024 14:18:08 -0800 Message-ID: <20241213221818.322371-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-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 support for folios larger than one page size for retrieves. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 0a3dfb66c7cd..2a2a5e66412f 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1716,7 +1716,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, cur_pages = 0; + unsigned int num_pages; struct fuse_conn *fc = fm->fc; struct fuse_retrieve_args *ra; size_t args_size = sizeof(*ra); @@ -1734,6 +1734,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; num_pages = min(num_pages, fc->max_pages); + num = min(num, num_pages << PAGE_SHIFT); args_size += num_pages * (sizeof(ap->folios[0]) + sizeof(ap->descs[0])); @@ -1754,25 +1755,29 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, index = outarg->offset >> PAGE_SHIFT; - while (num && cur_pages < num_pages) { + while (num) { struct folio *folio; - unsigned int this_num; + unsigned int folio_offset; + unsigned int nr_bytes; + unsigned int nr_pages; folio = filemap_get_folio(mapping, index); if (IS_ERR(folio)) break; - this_num = min_t(unsigned, num, PAGE_SIZE - offset); + folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset; + nr_bytes = min(folio_size(folio) - folio_offset, num); + nr_pages = (offset + nr_bytes + PAGE_SIZE - 1) >> PAGE_SHIFT; + ap->folios[ap->num_folios] = folio; - ap->descs[ap->num_folios].offset = offset; - ap->descs[ap->num_folios].length = this_num; + ap->descs[ap->num_folios].offset = folio_offset; + ap->descs[ap->num_folios].length = nr_bytes; ap->num_folios++; - cur_pages++; offset = 0; - num -= this_num; - total_len += this_num; - index++; + num -= nr_bytes; + total_len += nr_bytes; + index += nr_pages; } ra->inarg.offset = outarg->offset; ra->inarg.size = total_len; From patchwork Fri Dec 13 22:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907979 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.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 AECD01ADFF7 for ; Fri, 13 Dec 2024 22:23:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128592; cv=none; b=YyGZJM3B76jX/2CnMH4tg+lxg5fY39cyVaDBiB6pk6cVvc5jWPOIunUIOlSW8RcAT8grsuHYkGEGw8xeIh1JMS/OKz3ZJJRiz3YcErIcUX9uDLfa60GpK/+oK7WoP97rkBC4x6GkLoaCkfr+240FdAgEWr/rZXxoFi0D6t/N9R4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128592; c=relaxed/simple; bh=mk6rCrx59q7vBC5Vo888Mxa+Mr84iiyM0j9B/0t9j04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h89SUr/LpDbVInu+drMU2DpVllmE85rlXVGRTFRrIHqfaMV5R+EN5m1FfdBXwah9lofNxCs9KfBXC1SE6jGK+Va92LfoAGeNsacOc5c6Hont1Mq4+vd/CTGtLasgqQfMTh1vOkJJI9NOEr0o3Oox4Yr69PG710vlJSAT+mBpe3U= 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=Ieq/zqEi; arc=none smtp.client-ip=209.85.128.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="Ieq/zqEi" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6efeb120f4dso17700067b3.0 for ; Fri, 13 Dec 2024 14:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128590; x=1734733390; 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=feYkz8bm7s5B1BPB1BvqWGwK7+Xa4Julj9CPdiMmpt0=; b=Ieq/zqEiRzJqpXddfy+14PuZVQgPXToAi/7LjKARHcQ9Tmuhq2vlWnEoMJft3kmrGy suQjkwadjqG3hN5yEeYKDjpXrkItjut4r5xPI247zTTu1OqKss5GGd6G7J/eQtG/lbr3 vpBW7o0pwJRA/S82eBakKBzspsX9LMogiR0qDG40YpI+5zyZsFYUwXwdipAwaV2e2fEd Ie2yE2vPv4N1Kj3CHg8ynlVIOTxGl1QBYTjx8sKyl/7ZjHxywC64K7zcVZk4tHBrU382 hyiaKpUBVGh3KKNxrmzX+sCDeNGqGSD8y4gHUbb1M4LbO34hIibwNyZFBDnP4n6u08QU 8D2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128590; x=1734733390; 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=feYkz8bm7s5B1BPB1BvqWGwK7+Xa4Julj9CPdiMmpt0=; b=gh74/5JAwEcCmo/MAJwUHZGxtKEWws/Ers1fLhQul5SEPlgbYYT9hg9Qs3mE3fspfv yiCizpNmcfhSC/lT4Sn8Mn2E/iy4lzLwvDSMyuCiNVnrSht2zJF76vhbBTquERUyHkN8 lHWazoFD0845ETjqNEhi0si4t7/IxAuVuFdHhn5zc5QzOYjIt3CMhyFhleSEZhGvx+lL 2mYNWMRYnheYqSHA4I7Mw8KgY+O2lXcMM9Y00/LMMG09xc8TVmY9OrgoqRgqNsyAitLh 89B0OjolJz4stgjhuSHGFzqq862InwOfbfb1T2BPphtNWs7Ke7aZdZlI/tIwIb409+oN OmTg== X-Forwarded-Encrypted: i=1; AJvYcCU4WiSmIbwiHkyRIehf9qd2OE3uc2IMulT5pfu7VXCFTWiqoUgCm4RmzZdiU1nWY+k85NbZXzg94jWlFGll@vger.kernel.org X-Gm-Message-State: AOJu0YySKzhORQr+HJVtV2cu8oKbJ4X/dl1me5iH4ywoijgRtjvf2smg W6Yj4m0cs23fE61xREaC4DSI7YZZUzf9SV74Qeo+QScso0OwGI9+ X-Gm-Gg: ASbGnculbzoXJoz1RKaM6UOLtNhTUv0m/zy6A2EVMwabjnh7acvHF94FFw9IJ/QfwaJ N4rkJ2czYR92S0BWh15RgbsfsmC+dpm0sGtsvOoTuZqDzKSNKnGrvFMdatl7Js159g/iAQuv2l5 Vs/G0811JfcIAQG0bKfSAM9HV3nTr8/0DKtuVnywXXTdAiEQ4QteI3T8sE3zWxRE0gVeKaRMTSE pioHU5hqQnINzCB+5NeBR1RJb509bT7as0WJHg8N/YeufFv59gocodJc/bmUHDsL4zR515bhjcO a3PZHsvp/wlj X-Google-Smtp-Source: AGHT+IEMraPr7m+mgt4PJBsBxatnFSii2/ZbpnEXUgc6Lnzi1upSsrchAUrcxPELq8Y6VDWX7Yn6Qg== X-Received: by 2002:a05:690c:4513:b0:6ef:5973:8273 with SMTP id 00721157ae682-6f279b88522mr43779617b3.34.1734128589690; Fri, 13 Dec 2024 14:23:09 -0800 (PST) Received: from localhost (fwdproxy-nha-000.fbsv.net. [2a03:2880:25ff::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f288ff2ea9sm1230087b3.42.2024.12.13.14.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:09 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 03/12] fuse: refactor fuse_fill_write_pages() Date: Fri, 13 Dec 2024 14:18:09 -0800 Message-ID: <20241213221818.322371-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor the logic in fuse_fill_write_pages() for copying out write data. This will make the future change for supporting large folios for writes easier. No functional changes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 49cb9e84bd2e..c041bb328203 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1138,21 +1138,21 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, struct fuse_args_pages *ap = &ia->ap; struct fuse_conn *fc = get_fuse_conn(mapping->host); unsigned offset = pos & (PAGE_SIZE - 1); - unsigned int nr_pages = 0; size_t count = 0; + unsigned int num; int err; + num = min(iov_iter_count(ii), fc->max_write); + num = min(num, max_pages << PAGE_SHIFT); + ap->args.in_pages = true; ap->descs[0].offset = offset; - do { + while (num) { size_t tmp; struct folio *folio; pgoff_t index = pos >> PAGE_SHIFT; - size_t bytes = min_t(size_t, PAGE_SIZE - offset, - iov_iter_count(ii)); - - bytes = min_t(size_t, bytes, fc->max_write - count); + unsigned int bytes = min(PAGE_SIZE - offset, num); again: err = -EFAULT; @@ -1182,10 +1182,10 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, ap->folios[ap->num_folios] = folio; ap->descs[ap->num_folios].length = tmp; ap->num_folios++; - nr_pages++; count += tmp; pos += tmp; + num -= tmp; offset += tmp; if (offset == PAGE_SIZE) offset = 0; @@ -1202,8 +1202,9 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, } if (!fc->big_writes) break; - } while (iov_iter_count(ii) && count < fc->max_write && - nr_pages < max_pages && offset == 0); + if (offset != 0) + break; + } return count > 0 ? count : err; } From patchwork Fri Dec 13 22:18:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907980 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB7E61EE02F for ; Fri, 13 Dec 2024 22:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128593; cv=none; b=eRlM5Q7irndK9DLUakWdP5r961/L03V7Fhu9VJelshOXwOQZzV/3tmBSFuyh2Zr5BLr+91iGe4q6tAF1JMFTEKGtpdY5w56DVV8HZLZqiYXGhgVhz8Tvt0nJ+fp9f/zbr5jjSXH0rcue65fXDUE/lloX6wv8il4tmjjXJUC3Quc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128593; c=relaxed/simple; bh=WS/I5U2KbI+S5kf0q8JN4Ub6Aci1t5cdfMuK8Nsthn4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mPJHbJ9soU67Cb5g2kktQ5Mj8AinEUShz2a+CsRxhf9/KGKcl4jYbvxIiFx/bYx/atOw9gMrOHaG8oJFgxs6mkmRn2WFosPbpb862IwkEmoFxJg/M6Zcq2BsYKNV7Kj20j9lq+fPsQgcFAbtbJsJI/hZbv98YcK7Nx0eh6J+Er8= 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=U0ZpW6rS; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U0ZpW6rS" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-6efe5c1dea4so18267877b3.3 for ; Fri, 13 Dec 2024 14:23:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128591; x=1734733391; 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=DZEX878eEpMaAmNzCivXQiiOy62n1KQMbXhhtKas1sQ=; b=U0ZpW6rSKxNIR2g9rHiB8fSLa1NoPWOrzFY6WOnJC48AqJKF0TUumnPUZy5943/SGi xusV9C6q1m+ERGRDmg23v4UcUnQSKieEGQXOYIjw7y4KFIdsxMltDmqSRZber8jltLsg bj6ct1uRAIQ8lIGz1FI1Z3+WwDzf1re0U5S2pPFJth3OK3Ti6j/9hUwJlvWrm5bUul7z Yuqi28zBEZ/QKZyk6fjC+m6cRAUrvHNKUKkdFfZAU/+aBVoUpBsd6CdmaK9m+JB3SuRI duNAZObSS8W5HknyoKaZYc4ivCqRSR75qQolT/Lewl37k+zqvaNtKlkTBC/189bBrX34 zqWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128591; x=1734733391; 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=DZEX878eEpMaAmNzCivXQiiOy62n1KQMbXhhtKas1sQ=; b=u14Cr+KhCHIVhTUnqs6DYjsdm7nvBMURrs5eePbdA/HWwkLDEuJos86mF0RA6nye3u hNe66r2+X3NI/2+hkyb74ejj89Z3yASrydJF0K7OrYLpJxDQIcxTLCwEX330rC3EYILf PiGsXzbDYzKNL7v/w38quyiaiHwgQR79qhrajRaAwSnjeut7g0c48oAgAKq7BcmoW7MN HgE4KyJDP0XE2g2rdJ7/L7yyYAjec3QLmcNo///AP7Cz9JBcdRTvjr0AnqvgaqaA1gHq Y+9UF2cGvB/ZVXI/mvGrKELLXD2vdOKRmT+WBRsCSksTAuGaeyq/iTsujZmhgU40erat MuNA== X-Forwarded-Encrypted: i=1; AJvYcCWuxySbKkiriYooSH4NoWIzEgvJTQG5pClyo6lVeeBC8jSzrBvEZXN/SsZiM+zJLmlkWpoRpJgerdEd2PDE@vger.kernel.org X-Gm-Message-State: AOJu0Yz5vm/evXJ0OUwl6+lEPicsu9v1MjbefnF0BXpDPSWhocqYY7nQ EK6GV8VNoGsiiJNgl8X3BxPr6pkwwKepY/Z4nHOc9lhbqQNyK+HSRMv7Dg== X-Gm-Gg: ASbGncuGsIyzEDMRt1BACVaqBuIIhuM2z/BJgXXgxair2iAbtp2/1pb7XKoXAIcML+/ GXjNj4gZ3botPoXRv3WaFzenUYerwbQ9zCo6qr58ULLcJ9HLh1ABQM89KN1wQHCXVA3E481ahgh aX2Sh5jHPy8N3CymaFy9UuHTm9ubANpUveSKq3ef847inCjmtsXT3/GCl5wpaSxHhaYyf3CC1w3 eQP1pQgZfhMc26q7H9hjXYbZ3QId6ZjS/+IAoP8oCON8Z/RY6fP3J/XQBGAjZi8GHImLBkWI0FA db+Cxyi9eMxfT1Y= X-Google-Smtp-Source: AGHT+IHvRzTQ661Zf73bgS5CsEoebjBHIhNdBW1/VicyKsajnXdFuIxD5DxAbxo47iBViyj+GNxPNQ== X-Received: by 2002:a05:690c:25c6:b0:6ee:b6b6:dcac with SMTP id 00721157ae682-6f279b2244bmr38936887b3.23.1734128590829; Fri, 13 Dec 2024 14:23:10 -0800 (PST) Received: from localhost (fwdproxy-nha-003.fbsv.net. [2a03:2880:25ff:3::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f288ff3a6dsm1221867b3.44.2024.12.13.14.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:10 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 04/12] fuse: support large folios for writethrough writes Date: Fri, 13 Dec 2024 14:18:10 -0800 Message-ID: <20241213221818.322371-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-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 support for folios larger than one page size for writethrough writes. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c041bb328203..84e39426862a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1135,6 +1135,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, struct iov_iter *ii, loff_t pos, unsigned int max_pages) { + size_t max_folio_size = mapping_max_folio_size(mapping); struct fuse_args_pages *ap = &ia->ap; struct fuse_conn *fc = get_fuse_conn(mapping->host); unsigned offset = pos & (PAGE_SIZE - 1); @@ -1146,17 +1147,17 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, num = min(num, max_pages << PAGE_SHIFT); ap->args.in_pages = true; - ap->descs[0].offset = offset; while (num) { size_t tmp; struct folio *folio; pgoff_t index = pos >> PAGE_SHIFT; - unsigned int bytes = min(PAGE_SIZE - offset, num); + unsigned int bytes; + unsigned int folio_offset; again: err = -EFAULT; - if (fault_in_iov_iter_readable(ii, bytes)) + if (fault_in_iov_iter_readable(ii, max_folio_size) == max_folio_size) break; folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, @@ -1169,7 +1170,10 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, if (mapping_writably_mapped(mapping)) flush_dcache_folio(folio); - tmp = copy_folio_from_iter_atomic(folio, offset, bytes, ii); + folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset; + bytes = min(folio_size(folio) - folio_offset, num); + + tmp = copy_folio_from_iter_atomic(folio, folio_offset, bytes, ii); flush_dcache_folio(folio); if (!tmp) { @@ -1180,6 +1184,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, err = 0; ap->folios[ap->num_folios] = folio; + ap->descs[ap->num_folios].offset = folio_offset; ap->descs[ap->num_folios].length = tmp; ap->num_folios++; @@ -1187,11 +1192,11 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, pos += tmp; num -= tmp; offset += tmp; - if (offset == PAGE_SIZE) + if (offset == folio_size(folio)) offset = 0; - /* If we copied full page, mark it uptodate */ - if (tmp == PAGE_SIZE) + /* If we copied full folio, mark it uptodate */ + if (tmp == folio_size(folio)) folio_mark_uptodate(folio); if (folio_test_uptodate(folio)) { From patchwork Fri Dec 13 22:18:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907981 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 436231ADFF7 for ; Fri, 13 Dec 2024 22:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128594; cv=none; b=PL1OqqTAyC+d+Xi2u8rAPoLPKzR3rvRsN4E80L2NI0+zCft4G+bI4h6m+jUj3dRlOWnCx182KMFlh81QmEITQXcfvwnJcNW3VwtUc8b8MpZkW5x63rpw7A/S2DBJ3qjUK7St15zpucJFcPBLjnCIxsOQZ8TCdOOKzgegx/KGYCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128594; c=relaxed/simple; bh=y4IUyWw5ByiaCtOzYA7dWGyCd0TAauGsNCkei9fETmY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pycW3kSiJRYP+K7CC7wQWu77O3fdHVzPXX5sGOeufw5YdL+uspwi/dkhfYbrTYmHRc5LkbYjRrS2+kWqKGbGCPjkOXM9n1KekiyTr80xA0+3keSQeUL1kbD0lXrSkhFQ2Pe5X4BGrsFtwLv859/y+FGzd1rPra8NYDRbUI3QP2E= 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=A1K5DIxM; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A1K5DIxM" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-6f00da6232bso21558037b3.2 for ; Fri, 13 Dec 2024 14:23:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128592; x=1734733392; 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=FVG2h1mzHc6NlXH+G68nOAQKK5O5FHaevI4RaKIS6rk=; b=A1K5DIxMPvlAAkUTxu59TS7opa2vb8LMkzubxF7UvzUdZO61DXRfcKJ1w0HS/W0NXJ WB8JPrCmwJyvaM+TmNey7gHWoXyJCqjzoVrRoAUozZbTQbggp0Ysn6/7ySA98+hghMlE jtgfgSFJTax4SkZ36o41wQmMreZdx6c7FwWgodI//DkoRNBNHVflJ6vpiTurHPrb88J/ mMpLGCGDSvwNMdDEXWwrtQFmsrSwcQ+Gye1x/rUR8PyEUD38WI+KXieb1uncWXU//Ghi Iljln4oHYjbNnpfzQ4s7J+ICo03yQNH/5zgrHm11oZ9VorJ/fTh62nc/4sO6ciix80E0 FHHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128592; x=1734733392; 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=FVG2h1mzHc6NlXH+G68nOAQKK5O5FHaevI4RaKIS6rk=; b=uALO6zjGEOnZXHtB1wQx+vLzN7q3f9dencOlLiWNmRyUW3kkiRqJVv1BQKLI88yhiu Q/q/XcmAT+r5BV3xYJ7SDHMiMhPwXaGrCKoLWPYUbfwjMUEo97L1wsXDaSRvbYTVl6oj qyNM6CMGUGzugrnuhhL2Qg6+3UWQVhySZhuWwLGW1eKo7BBaVyosMQNe7B/luoefCb6V G02iTzqQ+eqU+EMz4PT8NTmZFZB2xEmOjYYXcLRLwH9Uj1EmirkayPat4xt3oDiTTUC5 vm2u005deaAhIa3zBPvHV6ALPfkBAmXX/JTmW2ohSz6Fs0QgubO+ZlkAkWHbBDNrZNkx ztoQ== X-Forwarded-Encrypted: i=1; AJvYcCU6n/Ah1sHQZnLL6NEuCXD7uE/l6O2ioN2ftuCOj/ZhFNYVXZu/K6Yc+ZJ8Rcwa4MPMBQdDdlArkDjZEJKC@vger.kernel.org X-Gm-Message-State: AOJu0YyehMS8yiS52UmN200vx26YXMVSgRXffjzZ2w6AJLcJqnRm1TU6 zEpSFh4Gk+uxbfy4LQG0HJLSMRLavqFUWOy63ib1L5derKhnE2iw X-Gm-Gg: ASbGncuut05SalTTBHWdUgPeOoEOb0nbm36bLF7HUn5Ka/LZHNcxGKtXuZJMprx3Ujw cVXffQp2iQiL5uGyKuvA/5AvjU8AvkpaGt3CRUfdMRy4M3wrk5u9rzGy74aNlTmQg2rDA+5aiV9 EQP3moVynUT602RY/ZxRWYXjPZ6fV4ufIHJpk1hd/kGjLGs5T7HOIR7gkQgxXhxz/b1lza1A5O6 IQ5V3xGZcquUsZiGIXNEp4wJlCxNt+TzJsLUYhb1dL0zihGJiELi9sTd7DeQpES1X84Igwv6t5f EPAARB0ML2CZcEg= X-Google-Smtp-Source: AGHT+IGe+dFlduHLiN0xEB5RIPddDCQG8ACBYsC6x68iqcnsx1OH0dPTC6oLpnFrg4Ip4zR0S+ID2g== X-Received: by 2002:a05:690c:f95:b0:6ef:838b:5cb4 with SMTP id 00721157ae682-6f279b90056mr40089107b3.29.1734128592123; Fri, 13 Dec 2024 14:23:12 -0800 (PST) Received: from localhost (fwdproxy-nha-005.fbsv.net. [2a03:2880:25ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f288ec62d4sm1287117b3.0.2024.12.13.14.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:11 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 05/12] fuse: support large folios for folio reads Date: Fri, 13 Dec 2024 14:18:11 -0800 Message-ID: <20241213221818.322371-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-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 support for folios larger than one page size for folio reads into the page cache. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 84e39426862a..2f704f522b00 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -797,7 +797,7 @@ 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_folio_desc desc = { .length = PAGE_SIZE }; + struct fuse_folio_desc desc = { .length = folio_size(folio) }; struct fuse_io_args ia = { .ap.args.page_zeroing = true, .ap.args.out_pages = true, From patchwork Fri Dec 13 22:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907982 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5615A1EF092 for ; Fri, 13 Dec 2024 22:23:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128595; cv=none; b=Kafy6pKNOQu8+kuMmoM3OiPI3JF/0pqo/7l1lSqXZRd+1J3HGxPweD8/3ZEHTUa4ZMOSoFKtH6cSrRElebJ2r23hI5dqXsvo5l2NzJ6RMUbCJwIxdrVZZtNjY15K58qRzgFyrFik4gN6AwzFcJTi+stwYjlBUVh654i/Kk434uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128595; c=relaxed/simple; bh=STJ+jTB0ysjQG5eWsG6JorBQSFlBaZXHczWK0kQl2yU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uJPSBX49l4yqZAWlu4PzA3k/Zd4JchL+e47ksdF8uhUYtFF+E91WZkVb98Uca7f2jiGOn5cDijQwVSZlneA/EFVd0N0SdsCh1sOgUWhMU2YigfRaHJI3dt+KIoji2czrJO7hJ9UJiz3QKr7vCVJ/cr+9owoS+1XUyYJBiSM1j9w= 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=nb+HXd4h; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nb+HXd4h" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-6eeca49d8baso20324187b3.0 for ; Fri, 13 Dec 2024 14:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128593; x=1734733393; 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=HAx0HnRh9J+SpBKh01owxiPClsQFKRjtGFqFV4FHKJk=; b=nb+HXd4h+MbRib3FHyfrY+7JBNDuvHsUDmVdFzGJiy6r6+4QRKaxDmC5yP5Y1PXUVM IxYHye1eBgVyHb+Xm71CcEYqnrAn8x33SxSxvqvxdMmwQ5xg8k291SdpbfVvycr6VKry PsMTFd8s0zAQZc7pPI4dZixbDk9PqmuqEXSso7L2smnMUUvwtrscOyez1YPJtyBW2X2H OQlAdYvGJeHeekFFGhU4BamcAD5ef1sxfXFRFYKTOxYrAE5XIw9O1EoKczo3Bi3iouoT eDAuMvCcsyRnDfQv8AGca2hscgPtODVmVn2oxnpFU7jsyDJYi1L0f3kdRA+KqPQAVG+8 QVLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128593; x=1734733393; 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=HAx0HnRh9J+SpBKh01owxiPClsQFKRjtGFqFV4FHKJk=; b=hn/Kr4Zyrxn9GDULNrOxgUNpHWu+kxfgOmoR5DhW8lX6Bz/tkjEL1FBLbPEJbrySdH SHtzFeJNaiJfMcRK9GB1OWOTlWjpejAljJ9oC9vBvCjo05ghF7ZwiV5dAocCdctucmGh EmXT68UWmutRsDDlBQuLTwOuMgj7tsKhh+fCcPFcfWExGVkaAF+QPGh6qlnFBAewvi6d 32XGb3wmH02OZfevs5VYULNK2FjL1d0qLMpJUNz1VTBsiaj0lidj5duDe9243ba33Tl0 ZFnL15HEAOgtxaFjyXBTFHQMjpiffFt3Sk4SBOP+xBAZIsIBgV5PnUGdajkIh0Sk6Vjq /IPA== X-Forwarded-Encrypted: i=1; AJvYcCUq60msN19CEEEKa1Ctbu7p8bPbYyo1TRtyLiVn7+h8WensH+0JK5KUTsOYgepwMnOt4Tbw2ND2mRBVZ+v9@vger.kernel.org X-Gm-Message-State: AOJu0YyuTQsHCtW2RfMfoBpsigcp5abvwo/fx+LRRHrTWlzfUCLL/9vj /eAm/JWAskuDC0weR9gHy4RMjzE0BAuz7pUbPK3rtGp7LcIzXayW X-Gm-Gg: ASbGncuY0ycTAAKG9FgItSUJj3bgY/n/WhwZQV3fem3rvgL/8m7lgCI19F5FV+9X8v0 dqVPaZ5PKhm0lq2iLFHOlGQ1P7anVMxa8vmBcLP0l/N/fLxZplbjU4dThqJdQ09jzFNEOopFR07 SksXj6vx9qWRdnNfp+/0lCRwVbl5SWpGPSoue8yBvNCQxiWAERzc3OQ9TY9SX9a8PATcm++YiUz T83n9WdpxF0Y2ds3AWLn4ukIS1rQ+3az5N2nMn25xhT+RvWnaFSS9fB451+iX2+qO37Dn2t6rnl GUohA0A4DLJ70mnk X-Google-Smtp-Source: AGHT+IHQEx2qyFTjXb5/qkENVZL+0YFeUpWJnAdCGZxi2Tes7+f8jEmQRiz6/f9CjGfdqoCKdhyzTA== X-Received: by 2002:a05:690c:448c:b0:6ee:5104:f43a with SMTP id 00721157ae682-6f275efcd73mr63298397b3.20.1734128593233; Fri, 13 Dec 2024 14:23:13 -0800 (PST) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f288fc5111sm1238667b3.4.2024.12.13.14.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:13 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 06/12] fuse: support large folios for symlinks Date: Fri, 13 Dec 2024 14:18:12 -0800 Message-ID: <20241213221818.322371-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support large folios for symlinks and change the name from fuse_getlink_page() to fuse_getlink_folio(). Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/dir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 494ac372ace0..65f31bd3a8bb 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1586,10 +1586,10 @@ static int fuse_permission(struct mnt_idmap *idmap, return err; } -static int fuse_readlink_page(struct inode *inode, struct folio *folio) +static int fuse_readlink_folio(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_folio_desc desc = { .length = folio_size(folio) - 1 }; struct fuse_args_pages ap = { .num_folios = 1, .folios = &folio, @@ -1644,7 +1644,7 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode, if (!folio) goto out_err; - err = fuse_readlink_page(inode, folio); + err = fuse_readlink_folio(inode, folio); if (err) { folio_put(folio); goto out_err; @@ -2232,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); + int err = fuse_readlink_folio(folio->mapping->host, folio); if (!err) folio_mark_uptodate(folio); From patchwork Fri Dec 13 22:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907983 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 B83A81EF092 for ; Fri, 13 Dec 2024 22:23:16 +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=1734128599; cv=none; b=QnNl8nh73PS5lQY2/C0/8Y72uKnZmEXNmKhBWQvnQM4/xR3RXjEP4G3dX7hPuj6F3MEN8S7CxshhW3wGEwrzpUm7v3mOx/PkGqCCE605cqsaqRAiPAyJLSTWWkxkazyc5/JdvIV4BJNcLOj/kwxUokKj+QkhCJnH/YnAbl3nrn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128599; c=relaxed/simple; bh=vGuWNMd9Ib/cFZq80jhsH60FNBeXmQMhp6UNul6DSzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b4KRYXwxNf6XWqbc3cT2r5frfux/9SJMGfjwlxrbuwu8d8Sm08zuBuh0UF9BVz48BnCL4PaG3ye+rHw1hp9ybycRNtQ3ZIpTZvVD/0Lsd5VomtDz0s7z4mNbGL4iQ7IJWGlIR+9MngzaUmb+/V38X3tOr0UecC+fo40WzdIqJeY= 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=jjDoXQCH; 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="jjDoXQCH" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e479e529ebcso55944276.3 for ; Fri, 13 Dec 2024 14:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128596; x=1734733396; 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=1MsqCNiS2Av0AT1F8h41t1E+yEYBskSEeM8QNXjZ6xU=; b=jjDoXQCHFULretiK9+czNJT/acEnB9pXG3fMUpgdQr/AeWUEbCo3gUGkzZzquF7yem O+fx93ZC/G5ywlShAq/5153IGThgmBnMh/Ds5jkrz4rQqJaqsJz08VcLvAKIFYG7pjoV Tc3K/rD4p2uG4ynB7ku3QB4qrOwuqUZB9lhrdRTdEVwpazmAa/8f+A9TOQw3cPxZs4nD 1SWgoxH3aD5NmlBChsRUMGHDE6+0NmIjhRCnhpOYN3FHqWh2r89WPJA4EXwG5ntPIBcV +XnY3NzbxeBNyhbGpwBPtRZGRVlP1qrX5WxjyhzcKE4xtrKRWoYnB7OrOY7ksDXLXKBS grJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128596; x=1734733396; 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=1MsqCNiS2Av0AT1F8h41t1E+yEYBskSEeM8QNXjZ6xU=; b=I6fbTbAZboBixW15aHX/Sy4rSIxDvCr87h8pRfZybTmLVmlcIjLtKdm83xbm9vWfWC iTy4ja+Om6LujW8+UP7e6WTE8OQP+GhC814vOW25t9g8weDJrsBMAGNBEEkN5lsJiP2i yWyeHFOulaC602uGPDw8TWV8rPycnrXGIuLWmaTMHXYaOMVMjxzWuqXTJPaFGFfJxCw8 RGrUhEzw0w1rNNOP41voOnnQu0yraz4OVMMe4gtIIwaMg3LbdhvBpm7dzKJOXr/TUYos 7TrFjxAI7laB1eHF4v08wlN6fiI46uOZ6Ozh2zQVH8qNpAX4670lFXwOmhrx08HQA8A0 5lQQ== X-Forwarded-Encrypted: i=1; AJvYcCVKUJiJWHyVRM9B9Gd1AOITjchZg1P0TYKmmQZMfedd64IitlFzc7Pp9eLFLS/HM0XqMvYnTob5Go0c/sWv@vger.kernel.org X-Gm-Message-State: AOJu0YyGjmqVJHT5HKSttuCxr1YUJaQuqsvtQuIQHfxNcNTWmGElv+eM DeWaW5gRLjDGqeFup13Bbx8vi13OtULtECR1d2D3Lltn8qHR7Zxeu2pQvA== X-Gm-Gg: ASbGncuyi7x0DG+fjLs0k1LTce2oVId3mVZ2Q67iZtTujaycmZ+FGYNEaiDWkVWfy8W rVSPGdQLF5iU19E/01EilBu17swn2HrzqgiJonMVte9sRgFXmczpLHiGSx6noNivWfcE3FcqfVI LbKybMLe6zL89W7BrljHyjdUkMPzA7fzRBl4DJMXx3jq7SdjQR/eCEcE0FgJuZZsyl1bDNpdViv 1XdUCsbkMJ0eg/pD93GOteOBTOmL6/OKUkUgTi+7HXxg33/hgukQ+CPcMKU1paWHY3E3ggLZqvO BpjlBaExgcl50YJC X-Google-Smtp-Source: AGHT+IGSYwVJaHvCGLatrC96YAV0XveT6KpNtTsqkXNH1d3P555qwSW1ANOBfV0TNnMpWUcrXGjUkw== X-Received: by 2002:a05:6902:1893:b0:e39:8b24:65ee with SMTP id 3f1490d57ef6-e434e5e390dmr4024599276.40.1734128595749; Fri, 13 Dec 2024 14:23:15 -0800 (PST) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e470e54becfsm106386276.52.2024.12.13.14.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:15 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 07/12] fuse: support large folios for stores Date: Fri, 13 Dec 2024 14:18:13 -0800 Message-ID: <20241213221818.322371-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-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 support for folios larger than one page size for stores. Also change variable naming from "this_num" to "nr_bytes". Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/dev.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 2a2a5e66412f..791688750caf 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1655,18 +1655,23 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, num = outarg.size; while (num) { struct folio *folio; - unsigned int this_num; + unsigned int folio_offset; + unsigned int nr_bytes; + unsigned int nr_pages; folio = filemap_grab_folio(mapping, index); err = PTR_ERR(folio); if (IS_ERR(folio)) goto out_iput; - this_num = min_t(unsigned, num, folio_size(folio) - offset); - err = fuse_copy_folio(cs, &folio, offset, this_num, 0); + folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset; + nr_bytes = min_t(unsigned, num, folio_size(folio) - folio_offset); + nr_pages = (offset + nr_bytes + PAGE_SIZE - 1) >> PAGE_SHIFT; + + err = fuse_copy_folio(cs, &folio, folio_offset, nr_bytes, 0); if (!folio_test_uptodate(folio) && !err && offset == 0 && - (this_num == folio_size(folio) || file_size == end)) { - folio_zero_segment(folio, this_num, folio_size(folio)); + (nr_bytes == folio_size(folio) || file_size == end)) { + folio_zero_segment(folio, nr_bytes, folio_size(folio)); folio_mark_uptodate(folio); } folio_unlock(folio); @@ -1675,9 +1680,9 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, if (err) goto out_iput; - num -= this_num; + num -= nr_bytes; offset = 0; - index++; + index += nr_pages; } err = 0; From patchwork Fri Dec 13 22:18:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907984 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 138491F03CE for ; Fri, 13 Dec 2024 22:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128601; cv=none; b=PQ5uHo0l9MtT51dNiZAR2ixWJv6rSpZ1Jx+4YjaFGZd2lN2UhrdBBvzgcqL2K6MdkdWAgyFRMZZ4ULXQkBU4UQPl1hp6NMx/sG/h+2jeA9bBPo9u2SYAdxVRQezB+kifvzaem57s9fqnGswHaeRyH//QML/FAmS1GHruFBHmsg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128601; c=relaxed/simple; bh=6ZrRjb/e8440rM5YaPrAJpfXe1s8MA1WaHYrkuIGN3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BsJQfHnrlaVIzljQ1f/Yt2Z0v6DEe+Uxb70b+C1jitL4sDw38bGmMJOBdz878D14ooWq66wr7XFrQpp5lb6lHDsH4toblX5zryn9BuF/VZwXeFO7QroB5bSfR8Rxyp6tGlTSKPww0Zxerds0qPplExC/JJ6gGrFvYnsELGzC+xE= 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=C7rAwFrO; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C7rAwFrO" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-6eff5f99de4so24537037b3.1 for ; Fri, 13 Dec 2024 14:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128597; x=1734733397; 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=I0tiYQZ2Nk5Me6EurDZ8+B71ViyLwJM5cmZFljbkfGE=; b=C7rAwFrOwNM70vdFS1yW9Y89EyZewrfdxlN6WnO4ZifwZ0xgQOrWQ2n4yoBfvp501Y TT+rPLw+V/M4AmPWLNhSAah2mI2hoXkSiNIVGAXR7bqZ4bgvahsWYtuDisvEWxtZWYnZ e0/RRKDkYOfSrircku0i06XUUXJ4khBauvGTueyM0eWeViuF5OUeOPi4JfkTnygXGjdl qgFXQA2YDMxtxjS+8gNzUhlG5U95xWh1GDxneGtFfgEspqPbsJUEipXA3P/H4X5iUy+q hFgFKpBFhkmZ1wfMA8JNgijABrUYugpEjmYO4gV3IhT0DdMY+wiLiJ0q93XYmqlTSf2w ms0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128597; x=1734733397; 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=I0tiYQZ2Nk5Me6EurDZ8+B71ViyLwJM5cmZFljbkfGE=; b=AkW/R/KNimdnxdK7qgnlDeVnHj/3pwTvsG7CV9amLBGrUnI8X9Tej5EPKgxEhG2nK4 w2Vgi6xF2KqzzjZqa4ZAexh8XGbKhfyRyUN3crgLubgeMe8R6FpjbU5oZPH3WiJl/xh7 TDRRmydH1k/KVmfKsOSU04thSx/GxGFSzuKtY1Jtdm4vA//9sd+isHyhQBtT0kj4C3Wz TxIhzIl3cca3WME48c19UpHa9w2x0y3ssik+jLuVTfzSfipTYHZ4eK4p2Az/g5/YTP7F 8teQAdDqz5C1qVV1+53w8MJhxI0RTwZhH31XwRpzpiJ33wuITsFt6QQx2umOS9rFVWmg VYxw== X-Forwarded-Encrypted: i=1; AJvYcCVnhTHz6BfZtqCwu74YVRCNmJ1A9U76TDdBDnHyqG0KmlQKPhfVUfoQ6+3ZALzA9ClffwhQD+dDcmz3ECyL@vger.kernel.org X-Gm-Message-State: AOJu0YwVbHSetdN3vyDQ+0tjGN90soNYaUePkTjcd82jGo3Piw1ecp3W 97TBKP5MHS1a84ugINNOhtlUot/jMPwIG5pX9vR9gw0T5jDnJOT6drKrvw== X-Gm-Gg: ASbGncubfrcz4D9HFMi4q5DhimOjCdUBOiwJGtBcgX4GhOVoxEllp74CaEzzQduCuST zr+DrmFLdVCeY+dTgeYJEr/yPym3G8wPE7tapW/fTt8tHS1Lzffv7u5MNBVsidfWluxAReKOzTA 34PYdmuoi86s7EdvPIg6lWCmX4h9rAak7g+GhdG7P6ysS7IgYWnsxnKcYBQO8bKf/P43IsF+Cv9 RceGx4T5vDN2GXK8OVegti8x7VlCLUvkEuUTBhjqUxTA+he/U4IGrhWPefVbh7MrxHN5yNRnUkn Yk2jJKp6DxoyJgw= X-Google-Smtp-Source: AGHT+IGrd9/GvUJfQmkURD6JT59C9dXxYVNSsg4s8vcWL4A9fiYlg7K5JDQ7/WJR6xgH4UjotEgfDA== X-Received: by 2002:a05:690c:d8c:b0:6ee:6e71:e6d6 with SMTP id 00721157ae682-6f279b16651mr43741477b3.23.1734128597129; Fri, 13 Dec 2024 14:23:17 -0800 (PST) Received: from localhost (fwdproxy-nha-010.fbsv.net. [2a03:2880:25ff:a::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f288fc55e8sm1242067b3.19.2024.12.13.14.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:16 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 08/12] fuse: support large folios for queued writes Date: Fri, 13 Dec 2024 14:18:14 -0800 Message-ID: <20241213221818.322371-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-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 support for folios larger than one page size for queued writes. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 2f704f522b00..94e304a63f9d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1798,11 +1798,14 @@ __releases(fi->lock) __acquires(fi->lock) { struct fuse_inode *fi = get_fuse_inode(wpa->inode); + struct fuse_args_pages *ap = &wpa->ia.ap; struct fuse_write_in *inarg = &wpa->ia.write.in; - struct fuse_args *args = &wpa->ia.ap.args; - /* Currently, all folios in FUSE are one page */ - __u64 data_size = wpa->ia.ap.num_folios * PAGE_SIZE; - int err; + struct fuse_args *args = &ap->args; + __u64 data_size = 0; + int err, i; + + for (i = 0; i < ap->num_folios; i++) + data_size += ap->descs[i].length; fi->writectr++; if (inarg->offset + data_size <= size) { From patchwork Fri Dec 13 22:18:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907985 Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.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 5F42E1EF092 for ; Fri, 13 Dec 2024 22:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128601; cv=none; b=GOkHkDAZGRidnBjCbNRFUDq827noqUDFOcZKkPnPeBlGOG8CgOVRWnKeqLvjuptP1q3/pss78gX2WjuAYXNUY+2I9vrCBxgoF4mK5ftpTTQJxH2s4F1VXOpgFqftfW8bpNJAoRmrIlxdQGg4rMvVclgBxb/3AtS+hlsxXofBsM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128601; c=relaxed/simple; bh=0Zvj+ySnMUIReLWVh/5PQ0zXytuL1VW9GMCIkqgX2cM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iJr4X2cGEpGO5GJ6JdK9oxx6Rj0qq+UXzT9LkEBJ4zSj4buWqc/BTXj8tuPjgEw7y3+kqMICvZ1h3+eB6UWU9htJAiOEFIpNiUN8v7lBFQc0kx77p09k2xTXClqDGAmgoFTd+cgzjwPlog/V8yLK+cGxLxhmG9HozT6XZXHPbqI= 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=B5L7xbJ5; arc=none smtp.client-ip=209.85.219.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="B5L7xbJ5" Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-e460717039fso494056276.0 for ; Fri, 13 Dec 2024 14:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128598; x=1734733398; 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=6w76K9YeaXpnU4/sQG9t66TH+CfDvGBOfAKZrQMVHII=; b=B5L7xbJ5jc4DmtOaqIB0Tda5iCpri1NeIaDbXoaSwcnYC5BmUFXymiYfqjBEkQ3VW9 iiDTOS/gKFTT/Eki2W75l7aG8A20tZDHuRVTshRgCRI4R076u2tDpgmIR4RUKyL8T3fw N3I+8foF+EPgx01vlP5CTVkx5zqnmzeXfeza/oaArlhNk8E0SH2s/vq4RLdfVbCHIr9G sDPnpnTE0227vomKYvmqKEd4VXfZERox1+oF8q0tZiq7kCuSwxo+CHzfMml5x1YDOmRw dTKA1qeemNG3yA2XdntsCH6BcSoH7qKnkMqE4lOZd2gBZIpHJTIkFsDknSC2sJBd83W6 VcGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128598; x=1734733398; 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=6w76K9YeaXpnU4/sQG9t66TH+CfDvGBOfAKZrQMVHII=; b=vriHpGXuss739wqT31gSeMALit7wif9XCJ6EXj2L3ZsWyIodVzb6Mp/kll+6Zezlsl obdSrKwy0Gqj1W7WK2nQkw+EwtOGM8Kh5AtIRl39q2YadbxuZXu7CSvyFxIK2uPuVgzg 7fOirOQNCmVr9NMxeZ4zMUb+3QKOeh7GNDPt1DkrhHSQjuKTIb6Jro1/ARljS3es8mKY eOPMDfORyFTscaeG3hVkkwS8jKeI+R+lQiIfsN2+wzOnqIwcKrR8nE+x1q7fLtsXl4qz ulJFzwV5WtvsvpwWHdLBs4SajB6gFew4CfH4F3iTqoZXLovCFk2B3tjPSm+AlCcwzf4z CA6A== X-Forwarded-Encrypted: i=1; AJvYcCXtPf9utz9Q3cFnRWfkNjz2UycECAjllKE+xhjwVo+OHOj+byC1UUFiy/g74xNtfPX8b/8ZHWXryVagPtQ9@vger.kernel.org X-Gm-Message-State: AOJu0YzXyj+KpRkfVMM5+MGB700Rlr9qJ3RqfHilltC5r934n/SkypgO Pn8G+LNQeB4RdTgYIdBw9sDAtXZDk0AlktCzJjBkj10ykLLe99se2q2/+A== X-Gm-Gg: ASbGnctZ62GHIK614NvNWgVb+okypu0OGaxed2wTon377dsl6SNVJVoddO6J8/TXjrC lmgCvc0fTB98RhcZDEL4iygu+eVlLpbzN1Z2ppoiKAVRwu1k2oE0H1bD5UnsHGJILJYU009gJaB 9fuMJR7rTcgx6FrnvRmO0kGJBl3f4opeTcStHO3C8rlzNgpuQqmi1jz8Y3fGbsPaWjJqh7Gvx7Y 078kAXCCJOlmC39bV+NbtM7pPLermDzucE7ZPseHwQkJgPF4yd2inQBGvFmjmGm3tw6C8dvr/iV GGQ2o/pZo/RhRIGf X-Google-Smtp-Source: AGHT+IHycN0NWUe0CEF1vA+jHP4uR18d01jpRZgsostOHxkZ2nR/gVJuH6TE9h2AiC7/d65+etuH9Q== X-Received: by 2002:a05:690c:8b1a:b0:6ef:641a:2a76 with SMTP id 00721157ae682-6f279b01889mr28475717b3.15.1734128598391; Fri, 13 Dec 2024 14:23:18 -0800 (PST) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f288ff26cfsm1234397b3.36.2024.12.13.14.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:18 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 09/12] fuse: support large folios for readahead Date: Fri, 13 Dec 2024 14:18:15 -0800 Message-ID: <20241213221818.322371-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-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 support for folios larger than one page size for readahead. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 94e304a63f9d..971624557810 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -885,14 +885,13 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args, fuse_io_free(ia); } -static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) +static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file, + unsigned int count) { struct fuse_file *ff = file->private_data; struct fuse_mount *fm = ff->fm; struct fuse_args_pages *ap = &ia->ap; 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; @@ -929,6 +928,7 @@ static void fuse_readahead(struct readahead_control *rac) unsigned int max_pages, nr_pages; loff_t first = readahead_pos(rac); loff_t last = first + readahead_length(rac) - 1; + struct folio *folio = NULL; if (fuse_is_bad(inode)) return; @@ -952,8 +952,8 @@ static void fuse_readahead(struct readahead_control *rac) while (nr_pages) { struct fuse_io_args *ia; struct fuse_args_pages *ap; - struct folio *folio; unsigned cur_pages = min(max_pages, nr_pages); + unsigned int pages = 0; if (fc->num_background >= fc->congestion_threshold && rac->ra->async_size >= readahead_count(rac)) @@ -968,14 +968,24 @@ static void fuse_readahead(struct readahead_control *rac) return; ap = &ia->ap; - while (ap->num_folios < cur_pages) { - folio = readahead_folio(rac); + while (pages < cur_pages) { + unsigned int folio_pages; + + if (!folio) + folio = readahead_folio(rac); + + folio_pages = folio_nr_pages(folio); + if (folio_pages > cur_pages - pages) + break; + ap->folios[ap->num_folios] = folio; ap->descs[ap->num_folios].length = folio_size(folio); ap->num_folios++; + pages += folio_pages; + folio = NULL; } - fuse_send_readpages(ia, rac->file); - nr_pages -= cur_pages; + fuse_send_readpages(ia, rac->file, pages << PAGE_SHIFT); + nr_pages -= pages; } } From patchwork Fri Dec 13 22:18:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907986 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 DA1511F03D1 for ; Fri, 13 Dec 2024 22:23:20 +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=1734128602; cv=none; b=LEIx8PkLrQBPSuVX0MyeYBXaIecS0y0xFHa5JmQdf0+F3lzdjUuG0KqvsosGXgv4czmy+aD96DBWS+HjsQFK4vjQv+Irp/JA4WZ5TkktoW7cilB/7n2vcmQngr6gyNCLkVKuAqPVJpkYUnlm2iwkkWDPqyWE+5VrwAPo2xBXVUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128602; c=relaxed/simple; bh=tGaWQLVlPWCnNy7xQeYNyj6KemM4AVuEiF8enHQE8UM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mDv3g/F2zE/mzfc28iRhDQti6lzVVmY6srZnsXz9rb111WjMX2Be26Eb9M5eC9Y6yttt1aMz6hiUDZygtJ2nksvl6TmjbrxGD77AjxMiRHkw9KHRwITnrZ6rH0sI+YfuazrwW8lziVhusQNZOllXo/fpKuXoVjh6YMTdTfKiNAU= 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=WYXrAq1h; 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="WYXrAq1h" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-6f145e5cd83so20358257b3.1 for ; Fri, 13 Dec 2024 14:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128599; x=1734733399; 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=wbdOnre4tcEgjC5l17NJYFK2NhHpto3wV/mVLhyi1bk=; b=WYXrAq1hoNxrD9GfDYXXzasoNEQflwIjfs+FXjB3QkOVr2NENIdwQAeFCts4SJDYZL M1SZ6F/qzLSAxcbcKXJOk3sDRHJV0TzT5fxL0JDBH2N3RJX2JJrVSlkmAG4YbSNfA4up I2lqXfA/B0TqBhsqeHUA1t5IworeljvWmDwOapGmuEoFPAp/nWAL8jqv5zXLjIvx0Spm dhT8bmWaUqk60EqfS6k+RND+fPsGgjWV1wDcGlj4yMRdVzkraF/fe2BOrguOzeP1ahJv YED5dRzUHfWGvaEBJ36JLRf2x1H6hfzSAwwsSperyxvn8AKNhmFYweN8a/VPMl5uWhnu Bzyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128599; x=1734733399; 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=wbdOnre4tcEgjC5l17NJYFK2NhHpto3wV/mVLhyi1bk=; b=Ou4svFpOtuEXXV9gGYhlBtmHJxHoaIqr4yiuFA15NT82DV5X809uXuQ8qjfBcgKDMa LLZQiHB7kvnEM4u5WSG4T1xzT2mF8Kvm20ETTH4GspoE3sLjVY/aOpglCx9tf7s7J+ay bnzmHwjp4zb8uyvE6gTuZ8SPAvjSdG+czUyY9ePTDqX7bk1/9+53hOARs4Afw+WEf+LA VJ55m0vJWpza6JQ49XsghVoqC7Y7u6MPZUKFDC7T2jRYsX5E4sFez2t1ezzjO1Dkeai5 sfM48BGcNpqdR8rrw9v64DI3ZDzv46EdW3HRLBSNivOoaljL8olS9LC9iShJjZu6raKY 2M3Q== X-Forwarded-Encrypted: i=1; AJvYcCVQ15U//aVQ5ymJuHA2At+eMHyR7wPEMd4si7gClaKpFtcsNAYKjKARyEe0yB0war5r28+q2yc0xcUAWxny@vger.kernel.org X-Gm-Message-State: AOJu0Yy1eW1nGpJ4Sh5Hid8tjK/U+XZY/nqBTpdKqZfmtz5H8YdMNAVZ aHYIIXuQiHRfzRo0unedE8z4A1gAGkzQ0Ny7PZPvVQGt4Ot6dFX0 X-Gm-Gg: ASbGncs3kxOXlLrsPzA9/6sGYeQ27k6pY0jQ+y6VNFRyOdnjd72ItH2TIoVAM5j5Ejf aNzygbLwljWj2VmTZkSBaXv4PIhYNAc18v0APyiMpQBv/kqQS+4JHTXtTNrqrOLdhsFnAz5IX7h BhVkEO6qp2L+4GwANL3+Y3qBAz+5kaRK7/j5IK3LNvu9UpAd23V+C3jj0BYjuSxOlVEPmAP7PVr 4nkUhz33LfmAgAJPo/6slPPs/nKjs4a10YxCMNcEXNKUHDfTBVwFiUU1wOjHhMIFDGeUG/59tmc gIDsUh3LYi246VU= X-Google-Smtp-Source: AGHT+IEeXl+7N5Pcx2BytUUu4W70lIdiX0BBJ+RV3PdfFd7ZiXgcGxRwyJ2p07JqTDmQ2ANnfJeNuQ== X-Received: by 2002:a05:690c:6505:b0:6ef:4ed2:7dfe with SMTP id 00721157ae682-6f279b8d668mr48653977b3.31.1734128599570; Fri, 13 Dec 2024 14:23:19 -0800 (PST) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f288ff3a6dsm1222467b3.44.2024.12.13.14.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:19 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 10/12] fuse: optimize direct io large folios processing Date: Fri, 13 Dec 2024 14:18:16 -0800 Message-ID: <20241213221818.322371-11-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Optimize processing folios larger than one page size for the direct io case. If contiguous pages are part of the same folio, collate the processing instead of processing each page in the folio separately. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 52 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 971624557810..bbc862c1b3fa 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1484,7 +1484,8 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, } while (nbytes < *nbytesp && nr_pages < max_pages) { - unsigned nfolios, i; + struct folio *prev_folio = NULL; + unsigned npages, i; size_t start; ret = iov_iter_extract_pages(ii, &pages, @@ -1496,23 +1497,48 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, nbytes += ret; - nfolios = DIV_ROUND_UP(ret + start, PAGE_SIZE); + npages = DIV_ROUND_UP(ret + start, PAGE_SIZE); - for (i = 0; i < nfolios; i++) { + /* + * We must check each extracted page. We can't assume every page + * in a large folio is used. For example, userspace may mmap() a + * file PROT_WRITE, MAP_PRIVATE, and then store to the middle of + * a large folio, in which case the extracted pages could be + * + * folio A page 0 + * folio A page 1 + * folio B page 0 + * folio A page 3 + * + * where folio A belongs to the file and folio B is an anonymous + * COW page. + */ + for (i = 0; i < npages && ret; i++) { struct folio *folio = page_folio(pages[i]); - unsigned int offset = start + - (folio_page_idx(folio, pages[i]) << PAGE_SHIFT); - unsigned int len = min_t(unsigned int, ret, PAGE_SIZE - start); + unsigned int offset; + unsigned int len; + + WARN_ON(!folio); + + len = min_t(unsigned int, ret, PAGE_SIZE - start); + + if (folio == prev_folio && pages[i] != pages[i - 1]) { + WARN_ON(ap->folios[ap->num_folios - 1] != folio); + ap->descs[ap->num_folios - 1].length += len; + WARN_ON(ap->descs[ap->num_folios - 1].length > folio_size(folio)); + } else { + offset = start + (folio_page_idx(folio, pages[i]) << PAGE_SHIFT); + ap->descs[ap->num_folios].offset = offset; + ap->descs[ap->num_folios].length = len; + ap->folios[ap->num_folios] = folio; + start = 0; + ap->num_folios++; + prev_folio = folio; + } - ap->descs[ap->num_folios].offset = offset; - ap->descs[ap->num_folios].length = len; - ap->folios[ap->num_folios] = folio; - start = 0; ret -= len; - ap->num_folios++; } - - nr_pages += nfolios; + nr_pages += npages; } kfree(pages); From patchwork Fri Dec 13 22:18:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907987 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 F133D1F03D9 for ; Fri, 13 Dec 2024 22:23:21 +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=1734128603; cv=none; b=T6E4mwzhIw+8ah1a/ceUrGMFlliLEFpPhtmVgb9KnenN2K/YFvjvDIgdJbDWV/0DnAuvYI8txdjtquwlyPgavbAw1La8unqcem/c/5XzaHeyk84k4ObfnFchH4XuuKyLzGS9PqQw9Lhje2pvGFEGZU8z5R3nRFI9wz9exXlAzlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128603; c=relaxed/simple; bh=4RHUZlPXsmuNDwULpNnYMJp1ZfhKI4sVd5OiHTgbyh4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nS+7zRmhOgVTxm6YazqNfjReCoALQsZT+QVmuRGIHAbUkRvUP8q6i9LJ9rGuI6BiXuIpEnL+IdeETrM6H/qGdL9L0ZjUxwkaekTc8nCPHJFBcwiha0hEbFJOVjfgJPVSAnSNPZjlIt2NCuBeC/E6gbd0+G/laHXFsjrIhQjP4WI= 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=KFP6VYEK; 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="KFP6VYEK" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6ef7640e484so25247927b3.3 for ; Fri, 13 Dec 2024 14:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128601; x=1734733401; 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=63LnTO7AfAjpGcQ2L5G8qf3TiWglZpVrBL35IcqMmV0=; b=KFP6VYEKDKtniLreac0ZuVY8cOKxaUf0zpKdIMfRrEq7U5JhmWQMsfgwMDlgBTNYy0 P7Jlztnvz7QE9maaxBpllpGmaDHQD7z+tKupEWRtq+AEVlzbtrI/yKxOdlsax46xzh9Q 4nQtp+tTJVlDHSUYzDqmVG4giW1PSMD0FFy0n/Gk1cwHAZWfPM0PL79wN7iA63apuvPF ijZSubB2M+0DEfKznJuKG7HHgFcCsoNZjC++jvVYjJ8cY0vgjrhyrKU/7KjG0LTcvY0W 9vDSt5FUVeqqDRWeAsK2FHPX58DBVOvgyYY3sDVB8onLQzdNaG8T1eCQAdnk7ahlpyc9 k0Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128601; x=1734733401; 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=63LnTO7AfAjpGcQ2L5G8qf3TiWglZpVrBL35IcqMmV0=; b=WI2VhIF7ig5XL4Wsk85bNyqz3BhxFXqjrr2F+HmC7OYNHYiD37FpIzyn41Zs+n6jdK jToBwaL+DXAcB6T6LIwBgvjMvsrjJC5b2usSS/fTI3yWbKmeFOwkfupaiGC8KLvbDSDZ P1gdmCYQVR+KHe8Rl1UCzu8Gs7XRU1WOAJBQtIXbasOEOKCP7UxXT5r2A/jGQeodJPrs zAEEzWAmMZuufAiZfxCJPZPJNpk+o11pP3lmnQyUTIv0ikzkD11FIqvI1cdHDOA3TDNF cNMzG359OMkIbjDWpLSGXM2Rb2jWNQU/cYIW+2iZnvE7+oYlQUTPzovab5r8vcXLuJRp otKg== X-Forwarded-Encrypted: i=1; AJvYcCWQcvkjXAy2ebj+sidQSzBGTX9Y6so2vf9Dyd3VC9duzx8pdhe2MdsJwybcBqeHA2Mx+D+vFoWg31XFwY1D@vger.kernel.org X-Gm-Message-State: AOJu0Yw18WEoVEgTepS9gjOBDXDGBsqzdyleFDDL52gQ9copDDM2Yxo2 27sAXPPDcA6Cn41z1jRMXjY12A7DBFxTG01yfCAYlQ2Tr9RI1rgazpqHsQ== X-Gm-Gg: ASbGnctYhKo6UZB8n9xtanAGf685qVC04ldsbMv747ZVhthkgfS3fFg/D36HcN2eW0K pW7RG6Ej7M/1Sd30nByhyj4gkRqUd6icuAl+JIbsiY3ZB7zL18D2lj/U9WOhwlbIGsOHmwhUr6m FNfJpZc7/LUCT/crKNRkCorZb7pJsCCrSAsNuCpH8rfh1BfZj2clXYFESawpRWnLs4iz2Zn8WFy B5/FXQxzIaHZMOGOPeCBQtLoRpfBMGE/AMQ8NEIgsD/CFRKdMYNt8+l1jZKWyw3ofOMJzQaxhMp VHBO0ima00bnVag= X-Google-Smtp-Source: AGHT+IH3vQ+ZIGEicps04/POExuN3AIVahHBkPAfv9OHg5LP50Hw3n2exUOVu4IiFzTdTZoNy6INEQ== X-Received: by 2002:a05:690c:48c1:b0:6ef:993a:29b4 with SMTP id 00721157ae682-6f2798e22femr42678857b3.0.1734128600865; Fri, 13 Dec 2024 14:23:20 -0800 (PST) Received: from localhost (fwdproxy-nha-005.fbsv.net. [2a03:2880:25ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f2890c86b2sm1202017b3.87.2024.12.13.14.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:20 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 11/12] fuse: support large folios for writeback Date: Fri, 13 Dec 2024 14:18:17 -0800 Message-ID: <20241213221818.322371-12-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-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 support for folios larger than one page size for writeback. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index bbc862c1b3fa..6a7141e73606 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2014,7 +2014,7 @@ static void fuse_writepage_args_page_fill(struct fuse_writepage_args *wpa, struc folio_get(folio); ap->folios[folio_index] = folio; ap->descs[folio_index].offset = 0; - ap->descs[folio_index].length = PAGE_SIZE; + ap->descs[folio_index].length = folio_size(folio); inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); node_stat_add_folio(folio, NR_WRITEBACK); @@ -2089,6 +2089,7 @@ struct fuse_fill_wb_data { struct fuse_file *ff; struct inode *inode; unsigned int max_folios; + unsigned int nr_pages; }; static bool fuse_pages_realloc(struct fuse_fill_wb_data *data) @@ -2136,15 +2137,15 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio, WARN_ON(!ap->num_folios); /* Reached max pages */ - if (ap->num_folios == fc->max_pages) + if (data->nr_pages + folio_nr_pages(folio) > fc->max_pages) return true; /* Reached max write bytes */ - if ((ap->num_folios + 1) * PAGE_SIZE > fc->max_write) + if ((data->nr_pages * PAGE_SIZE) + folio_size(folio) > fc->max_write) return true; /* Discontinuity */ - if (ap->folios[ap->num_folios - 1]->index + 1 != folio_index(folio)) + if (folio_next_index(ap->folios[ap->num_folios - 1]) != folio_index(folio)) return true; /* Need to grow the pages array? If so, did the expansion fail? */ @@ -2175,6 +2176,7 @@ static int fuse_writepages_fill(struct folio *folio, if (wpa && fuse_writepage_need_send(fc, folio, ap, data)) { fuse_writepages_send(data); data->wpa = NULL; + data->nr_pages = 0; } if (data->wpa == NULL) { @@ -2189,6 +2191,7 @@ static int fuse_writepages_fill(struct folio *folio, folio_start_writeback(folio); fuse_writepage_args_page_fill(wpa, folio, ap->num_folios); + data->nr_pages += folio_nr_pages(folio); err = 0; ap->num_folios++; @@ -2219,6 +2222,7 @@ static int fuse_writepages(struct address_space *mapping, data.inode = inode; data.wpa = NULL; data.ff = NULL; + data.nr_pages = 0; err = write_cache_pages(mapping, wbc, fuse_writepages_fill, &data); if (data.wpa) { From patchwork Fri Dec 13 22:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13907988 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07B9C1F0E2E for ; Fri, 13 Dec 2024 22:23:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128605; cv=none; b=Y+jvEh4tGp7n4V622fNq51w1J186/lO8LKrgDVbdskBCzWeOxHR16YtEWumQ/CHg7pNcRJKIwvRxac9g5EQUevCoaFtl2NHCvdUBeR5A57VVtPkeaf6Emkg+bqcMPkEoDOHROEU+IYrZmeegyJCVrlsx0j+rCaj703cKsn0NheU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128605; c=relaxed/simple; bh=3BNbFm5jNBG6QEuzUOjwPNlY5z77HfjfRWherkDukMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ijfAarZT4aJJZRa4UWUYcPPVD+S7lsb7rh4QGIQ8Ab8U+MetxROR28rg1pNHF08sbbbyQzRIcmGTJQswpQKO9LUdaKQFjehX6Hj7lxAJGBsY9P3MEs/No8+qSCXova5cJsS12WkD4P7HdhBk5wTpDpN4EVUoJbsxmIcioLvN+yo= 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=ItWDnVb6; arc=none smtp.client-ip=209.85.219.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ItWDnVb6" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e3fd6cd9ef7so1722799276.1 for ; Fri, 13 Dec 2024 14:23:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734128603; x=1734733403; 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=6/rkiTJp2FwPBEaVH+i5vrwjhP0Gq4YPeew8BSrv5bU=; b=ItWDnVb6Nq9AxINsNKYlqbjVLzHIiaLz2/jzkmeM+duvO4bC10dKFb+RatUJIVdhbg NrJWpjT+Yvz8y3FRYtM4YRsxC5cPDjn+HTCX6U7qswoZdCTO+OrMi3cqGNgFnqj7L608 D4hVexyTExOKprzAA99oUOrzENIdgtkLqXnlgpwOtFoyk4sWIWKr9cScXCkQZr+EqPi9 cUQ7//j5YmQ2hBnJSKqm93sbiiehQfABJ2JBOOwIjU+MmA9I/P8poBBRmOwmpptt5MMd w0Ta8LMKJUqbq6Mu4lNdZH62e1luVGL22a4jdYWaauH137723bCQxMQowZXPbnJVTLFh g+UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734128603; x=1734733403; 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=6/rkiTJp2FwPBEaVH+i5vrwjhP0Gq4YPeew8BSrv5bU=; b=NnRhfcpOJ6TvqlJtM0f4JaV4DGrA870wgT0+kRzLnEEs+dgOOKec7/62RXDfGt6XMt OPru3Q2YhEcjDaDIjI9AoyaW1Qlx3sI9lPTAHG0XTm1rkcUMeqNMRoWx0g3KuD6i3h3g ySHTtot82aZMvKCaKzyiVGkScaRF0dps4SrRZR3yqHZ9croChRf/WPygiBrK8SHlCFfg h2OpMNalo8NK0vcDli+YJr0tNU+UKIynX80z2RXg/fBJagc1cPUa3/0UDZnaa+3mDquE iGJhfZ+YNJ4cAIlkCUnWZ4P0EsrB76CckMlP1Vw5h0SlGunPk17bKtuXebYGErRrOChx qLhA== X-Forwarded-Encrypted: i=1; AJvYcCUWQS6uvNzlm32OiULFVPXDFSBhjdlvKfFNTPn+I0kbSW0i1zwnMub29N3ksgf8eJ3oWfdK+qkYwovRSMk3@vger.kernel.org X-Gm-Message-State: AOJu0Yw8zqrMdX2zxDu30BQphroUb66VLnlLyNoKQvpnlopNhtaiTPZi /FBTY4VtrkHG6TBGSsGffs8HyA4kzexGO0TBuCp3uWRlD4k27Waq X-Gm-Gg: ASbGncvu9hH6M2M/tN2DMocob7KxhSita71uuvGbKvhvwX2F/5FuTUWRqnq9IAnEvRT f5fvB0zaEHE0slczHCHQmy/wwFFOSWSwdC2iramQRGHhitSyZ2IzxrKPHRV4XQnp6BsqGqiwQAX xbNwoASPwOEdXDM/2NLHbzvrVkPu16ph92rHUiCF2ATxKg9IzkutmNXpjOsK31BoW7CZcGeSQA9 jE/5ER309qKhgg1l+gbTkIqGI5MCPjzyKBxuIrWi2vdag0MaUoAMtIaLAKe4g7duc5A5QUpvCie /bW+V6+0HJoG1JY= X-Google-Smtp-Source: AGHT+IGT2kcafMP4OXwKhV0bMgJYo/omINH1kMlRcqKMIZMd+EGN9XbhJruAzQAK/Mj1Y21tcOaSFw== X-Received: by 2002:a05:690c:6ac3:b0:6ee:4855:45de with SMTP id 00721157ae682-6f275c4ed77mr57024957b3.9.1734128603133; Fri, 13 Dec 2024 14:23:23 -0800 (PST) Received: from localhost (fwdproxy-nha-011.fbsv.net. [2a03:2880:25ff:b::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f289031306sm1224767b3.56.2024.12.13.14.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 14:23:22 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, willy@infradead.org, jefflexu@linux.alibaba.com, shakeel.butt@linux.dev, jlayton@kernel.org, kernel-team@meta.com Subject: [PATCH v3 12/12] fuse: enable large folios Date: Fri, 13 Dec 2024 14:18:18 -0800 Message-ID: <20241213221818.322371-13-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241213221818.322371-1-joannelkoong@gmail.com> References: <20241213221818.322371-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Enable folios larger than one page size. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 6a7141e73606..e313ded276a9 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3187,12 +3187,17 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags) { struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); + unsigned int max_pages, max_order; inode->i_fop = &fuse_file_operations; inode->i_data.a_ops = &fuse_file_aops; if (fc->writeback_cache) mapping_set_writeback_may_block(&inode->i_data); + max_pages = min(fc->max_write >> PAGE_SHIFT, fc->max_pages); + max_order = ilog2(max_pages); + mapping_set_folio_order_range(inode->i_mapping, 0, max_order); + INIT_LIST_HEAD(&fi->write_files); INIT_LIST_HEAD(&fi->queued_writes); fi->writectr = 0;