From patchwork Thu Jan 23 01:24:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947764 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 7300D179A7 for ; Thu, 23 Jan 2025 01:28:07 +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=1737595689; cv=none; b=nmEbzgVIgU+K3d201gxxDEZY1V8Q78XyMzLzM0dbkLilaDY21m71sJgM3S6pP29kBRNBBhooFoz9sWUwXjucmAISWvc7vEZcUKvY9L6iH2JKUfJsQgT6mPtoLOjW7gHGwjxxQTzckDd28g9x9Nuk9oe5H467dNHdwHXbuea3ghE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595689; c=relaxed/simple; bh=OWe64HfZ2ftARSHz6BUT+hjwEWKQD61ygR5fkgMwFoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NkoW/7Ocz4I/d5lqitRXh1XOTnDX913TJQ6Q83oEWt0okMNaNwGWPSfzgFw/3Rb6MfM+32YzI+/BWsS5bQ0+StOrw8b2fTx3vGkhDkWevUKk5YoRj6GkF68uSNnv0rdYdEsWJFcoydLQKkn3Um8Q0JU3IOjItiPM1lC0hHPkv14= 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=YgOeweaj; 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="YgOeweaj" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e53ef7462b6so635349276.3 for ; Wed, 22 Jan 2025 17:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595686; x=1738200486; 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=CxCl8MojXvj3P2c4b2xfp90qWfRDrarz85KWuS2ZNCo=; b=YgOeweaji/DWU5mo/9SkgYsTbD0yoQOL+BSOn+Rq0WU1tGOB8LKqoN9tOaEseILWJK rGrb4DILznkGnK0ADrZUWNTwEpO+hfh6gfqE/Kj9io6eY0pGqLd1AyRIYxV9w4TJUYpY XjWT6qJof97z2kOg+Nk3LnUBE6lCkLxJHTaEHelC2l7b2uIcr5V91H7q3F9ZRKyjX/T3 x5Y5BOzisL8csitw1a0PwriWuMcZ2fBXE0YMrbBlmNEgB1hBpXwcbqwXvVQ/df/O8F41 vFZfQnlbCpybMUgsTgWun6VhwRxNcDVwiPRO3UVDJ3GJjbEB3ToMzvraIW5ZL60YwlbF 4gXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595686; x=1738200486; 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=CxCl8MojXvj3P2c4b2xfp90qWfRDrarz85KWuS2ZNCo=; b=Ko0y3e7mV/H3VdbYG2Hgu0GDhahaZqu5sVkgd9mLQgiLvUrhnGawFBvDZA5fLpRZAL 2FFpjFKjPKH9h9YowVddSo+eSPcsCQPkFINXu447B9s/hb8KqGGkVOGOeAz/wquULOuP 5vrqYvhEJECcqyzdb732a0MwGabZVhXknJaM/2zRBjF8jAm0qiZZfr5L7TgAEOGYJT6j VZ3JxEpVUQPQYxmdw8G6ukespz75q7oXoVWY/XJBriVdPtvGTMZMRJA6jBttmTl55l+s xAooK7We9FSkTlgtSVC+P8Y1O6Tjavmp/reVkIahk2ePryTwoYkin0JJiu3f9H1aFDd1 layA== X-Forwarded-Encrypted: i=1; AJvYcCWFD9R8xlRhKgc55s0Ft1pmgzA/t0gMCT/x1cggwkJJRrJFtkMm05GttrEiYlKLr4e8XG0kbGTuICpfTb6R@vger.kernel.org X-Gm-Message-State: AOJu0YwmdMTc4ugrrArg1brOUWquKDznnZnsVxnOh7/iM0oF3G2pRWa5 HsmLFVPayw6jae0OZYjg3lqXeQttgEXoU1vc0ep91XYCexW7QI+t X-Gm-Gg: ASbGncv3HVI9qyT4R9Gd3VS3CQEEh1SeWyuUy+bFzXch0MGJLX+zABAOs1dHCfHXsNu 7Riy1SFoq+526l4wtzzE4CxruofZjF7ZK/5Blc/AIqvIw+tCRa6ubrxtaH552YCiKp9t6WrQtEv rsBn6iqmm6hbodT85aTdZswUzhmUTildZNtjfpyh9C43Zadfs7MtJ4Y+iyRWjCxvJlU/jKIebMo PMkIyD43WZ0y21//IY0qhwF1C4mFYWK9YV+PhzM/D4d8Bbwmgv6Kj595V5xPwmZHeJEwVLyduZE tUE= X-Google-Smtp-Source: AGHT+IEpyJVr9RGfLSHSctyq1c0KojZx35UeVhe7rSuTqAieubngoqQn6aCBos9mfCEFbimFpAr44A== X-Received: by 2002:a05:690c:6383:b0:6f6:d01c:af1f with SMTP id 00721157ae682-6f6eb6645c6mr186005637b3.16.1737595686281; Wed, 22 Jan 2025 17:28:06 -0800 (PST) Received: from localhost ([2a03:2880:25ff:70::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f6e63fd35asm22943257b3.38.2025.01.22.17.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28:05 -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 v4 01/10] fuse: support copying large folios Date: Wed, 22 Jan 2025 17:24:39 -0800 Message-ID: <20250123012448.2479372-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- fs/fuse/dev.c | 84 +++++++++++++++++++------------------------- fs/fuse/fuse_dev_i.h | 2 +- 2 files changed, 37 insertions(+), 49 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 5b5f789b37eb..61f8e7d0b8b1 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -838,10 +838,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; @@ -862,7 +862,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)) @@ -908,7 +908,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) { @@ -941,8 +941,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; @@ -950,17 +950,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; @@ -972,20 +972,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. @@ -995,12 +996,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 { @@ -1009,22 +1010,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; @@ -1034,23 +1035,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; } @@ -1080,7 +1070,7 @@ 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); } @@ -1667,7 +1657,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); @@ -1675,9 +1664,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)); @@ -1905,8 +1893,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: @@ -2054,7 +2042,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; @@ -2173,7 +2161,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); diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h index 429661ae0654..1ddd109c2c0b 100644 --- a/fs/fuse/fuse_dev_i.h +++ b/fs/fuse/fuse_dev_i.h @@ -31,7 +31,7 @@ struct fuse_copy_state { struct page *pg; unsigned int len; unsigned int offset; - unsigned int move_pages:1; + unsigned int move_folios:1; unsigned int is_uring:1; struct { unsigned int copied_sz; /* copied size into the user buffer */ From patchwork Thu Jan 23 01:24:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947765 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 AFBB44A1D for ; Thu, 23 Jan 2025 01:28:08 +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=1737595690; cv=none; b=eiaMhBHYUjuAlNLV5D06VSodXWS0gNAQKp2eMoGQOFgwtdZlTLmZGRbO/tuGcqcX4tcFOcucMoM78jZUuYnMVv3aH7I3ux6hqrHszdxbc1vhfKQTg2y/7O9Hbx64W4izQ1eGPd1IeJ+C2oy1WzJGUPI9kU/wN+ZgT5pDD9GJI3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595690; c=relaxed/simple; bh=e6yijLXE38lcSqb8uBG2fjzWvxY+xlEUMdOAO8xoZQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cn33ZsvnFSRC/KQZY0HyIE7mrPBGfiOPbu7Gs9XEMeW4aO4XHVfcjqOmBpQaYrEIN5XAnpd9uPlYMtRfW366fWgqjgwY0OzEvHQSEYBBvNxFT3BgjSAndIsnV7kqFerTZKtfSQk+7bg8O0wsmagGqctCxBH4U4L2+aDPH4ZZqgs= 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=KD8BJzkC; 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="KD8BJzkC" Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e4a6b978283so2632208276.0 for ; Wed, 22 Jan 2025 17:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595687; x=1738200487; 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=1gwK3tDYTKkO1U1L0NwwfEQJqWq5lqpjU84GTsIZI7o=; b=KD8BJzkC2DR6tYb5YLNVhCurvWyps6+K0X3GDdCGC0ws2X4EcAOjUpMw5cNBuqRblq dWg9tkq9+H4f7w+0JVpCH6mF6qUNjjfdBPUJ5wHBHqTYzeqDsLpPG0o5TF5IBFQmJL7X zbxSAfHVshna+ZdHfjUaKgzlO5afjEAtsk0tYPLXUfJ9sEI2w9EBhCNs3JxoT+5/TZOz zkqgaPn5X1Md1rJlVpPOAsVifUNeePyk0tY8y6wNhW/gWpKwkWbQGmNvuaD5BN3JNYj+ F6DOSUYMlUMC2eOa37b0R850JHRF42LCne54wa5XAmaZYI9LYWoC53eA/IMKvLpNVn9J KOgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595687; x=1738200487; 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=1gwK3tDYTKkO1U1L0NwwfEQJqWq5lqpjU84GTsIZI7o=; b=vZMriz6NBeqsqDwmUxvsX+oh09jjeSm5ES/O9tJtuGSnFv5J3BLyCLR1F57XACmEr9 QTKW77lNVhUkYGz6E3vj9/tRRCGhsHh3/+UWuZGMrbaC00TGFd53svgMb4lr2JMP0Ect 3W5QvJ6yn2YGiUsqaR3qNYulsXzzIdN5XdgB2sxmW900pSy66T9YurTCuZnlxqtjHfi1 vP7nTJoKi48Oq0vjeVGB0ECQPSkHVyABxBZovMex9ijtJ2hM8JACn8CQIgZfxIdQKvUQ 8kqAgmaHIPkbB9wTTYP4cjknpzpnx2vXpNGKeeS80y2UPA9eI3NRxolhop2b/ojQ7/LA CeEg== X-Forwarded-Encrypted: i=1; AJvYcCXlGmhV3D+eLOG+rgiG8i5YXPGveh8yi6XlfAYo+eEkqCVgwqJRdq+UTaxV7fs1Ot41jwg80iE7Y0KTSUAu@vger.kernel.org X-Gm-Message-State: AOJu0YxOle07P+0V8Dxt4AwHc6JdcTsJoTsqCq+k4pCgYS6ACM0rQtyQ xRhWileGH/Z4XmuoyZQppYpahtzx3V8vD7hk7eCqWNs8VfC4B4pz51zkjA== X-Gm-Gg: ASbGncsjm1gFmh4xYG89YRjGb/ZXruoUsx7aodECT9lKmMUN0BDeowEWVay9X+pth1u jJQUQvLI7lEPOlCs83f/uU8rzqYPvZAtbrpUU57SWKmTFe83zopt/XSxidE63nCgRl1tPsxt+x7 kv4QEJWljhlzTGgcceD+6/zJgNWgCTbNDr9AsXR1+vALoztnsa8StuoDTSWQyEr8/xSXC5HglE0 3B327BspwWP6VgtOs9AktGg+8XeNNOte1NKLDnZGarxEaRQGDXr/4zVU1nBTGvaDecZH1/WSJpD /Q== X-Google-Smtp-Source: AGHT+IHPowTR4vEUpj9pLTQ1X07iwwTNy/u+9BTqXkmhIemhCrsUjDO+c03Yl15xiG3FqzGUo2r9Kg== X-Received: by 2002:a05:690c:6f83:b0:6f0:697:da5f with SMTP id 00721157ae682-6f748e290famr13459607b3.14.1737595687565; Wed, 22 Jan 2025 17:28:07 -0800 (PST) Received: from localhost ([2a03:2880:25ff:3::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f6e66d10f3sm22116067b3.69.2025.01.22.17.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28:07 -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 v4 02/10] fuse: support large folios for retrieves Date: Wed, 22 Jan 2025 17:24:40 -0800 Message-ID: <20250123012448.2479372-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 61f8e7d0b8b1..ded2caa4078d 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1718,7 +1718,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); @@ -1736,6 +1736,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])); @@ -1756,25 +1757,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 Thu Jan 23 01:24:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947766 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 DFCBD1E4A6 for ; Thu, 23 Jan 2025 01:28:09 +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=1737595691; cv=none; b=sfVpdP3KoZYFsLj2BGQAw4A1llPjnQv5NgARtDLZ2dR8sW2Fx+Vvfrtc7Su4EfhOfbLT0IIhvBer5SuZaRXEPvWeY+jHwszbs0PiF35T8akRohW5YCE6eihaD5uouvjj1BKhXewPKIskPshu/44qryx0BK7HBuJaw2O9EgoIT7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595691; c=relaxed/simple; bh=4Or1lduqRvyKs9TlgGhpc3YHaHcSPJlZUyere2Wzmoo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j2tORM8l86Oj9eEIr9vVEIHAljhzdLr6XJYQGhbrfRVWPaPb3rFfOICTuRCMbxO9J4BcFSD6l1hzB5/VfOC4IC6DrL4vsNzqNwI/CSh/lMVXrIlqJblMqr4tfConXXcrBkrofn9tGH59iNaWNtIhkOMZAftobmURdpPR3wJlQXs= 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=Ns0lgyG0; 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="Ns0lgyG0" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e461015fbd4so576250276.2 for ; Wed, 22 Jan 2025 17:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595689; x=1738200489; 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=3kB4b67jfZmlM8Rvsdn93TfXAGMq28D3tw1SIamV3Ug=; b=Ns0lgyG07ahctoSOGtJa8GppoY7Xx264MF28UR+7BYero1r3pfaORUYOL4aHCLWbLA ved7ILUakN74GeO2xCcwlJRK7WCr7M7OUSHP/TD0TSI1UZyz2aldqazXxda9Pw4t/A8y 3+55o0JYSmLlH0zZVHRuBnn0w3E78gC/Ucty8RLAxuSouFoQb4sSzkOABuMPEZsv2YQR mO7eCvtl08sg08vMKw06GoniJNTofNFmu8o20cbIz0qz9930RXm5M8ylt4Z2jEIK7n6Q 1k+6RxsOCxpTct4AVgkMEf1+Oy6OeBNXHp3nLg+5fsk4pxfjzXw/gDlpr7FX01qIY3Zp +Sng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595689; x=1738200489; 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=3kB4b67jfZmlM8Rvsdn93TfXAGMq28D3tw1SIamV3Ug=; b=tnPUnON/TVbVcursE0MzgxszLMLotlUedpzt9KF63Y1AI+Gk+t0qFqzGv4E+rSwJG/ TmWGSJnjoCwdoOyM+qT0QMqXJlco95Ou52Hnw+PoZxcsx3M51ClELDKAIVH+HZsRA3Qi Oq7LsXNkyoGBm8Cheys+t8Nq57/3cn1jaFVNWtoUy8wB+h6nJmVBrWrvTUGuJCDh9Eda nxNRK7ax3hZLpDtohoJ7zvEC9g0Af+eM7p1mGOXilEEaXZ5mia+hZjv3tHihGkUc5QP9 /Q+JlWWqebhPEPrdoiWc/RZDA5HZrnjigVcqEJ7vtf3HKh6pnXtT3Tu/NSpqdhUSBqMS +AVg== X-Forwarded-Encrypted: i=1; AJvYcCUGU9bswH27yJTQGhtq9BIfIe3/fBNGQQd3dB2n1/06PXhD36A9twhuj+ZhgyYRADlvyYAb903w50nUwNhF@vger.kernel.org X-Gm-Message-State: AOJu0YwLLAm95pQ5GrNX0iqGbMs0H5IKXfsx9fAIEWf3DrxKuB7FepKy 24ryCPHPtxmfnbEfrfbCmni3BjMrHnV5/hkt90LNY6fA4TUt8e2m X-Gm-Gg: ASbGncsbR9wK8PYh/+KTeEAx8yNSgg/7RFlSH1w8l2tXT4+HJKaFcFXQQVmio1RmWHA tu8poQXfiJwWgIgSurf/zT9qSCf55TU9G5nyK5AYhtKWNtyA+LM5fW/LK/79ggehF/E8yCre6Un O8Xy7p8hbkax4QbaYc03MjqzGGL7EIydWDnVS39ajpOkojEuWD7MJZta2wIBNPQfPh42v2EKRDI HycwbcP9kc8WCKTy3qatCCbzugbr+iT5H4VVPq89OfGUbGhIZL27faRpahIwvl/kxyN3+Hb+2zl WbA= X-Google-Smtp-Source: AGHT+IFbTCK+jUCC34el8Q4xH7M5zEnF1jmwiIPbsKeZMgFDkGntV2+y8l0aeA0BUUwbgxUMjfLQMg== X-Received: by 2002:a05:690c:9a07:b0:6ef:64e8:c708 with SMTP id 00721157ae682-6f6eb680cd2mr182986027b3.17.1737595688967; Wed, 22 Jan 2025 17:28:08 -0800 (PST) Received: from localhost ([2a03:2880:25ff:7f::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f6e63ab38fsm22486657b3.25.2025.01.22.17.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28: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 v4 03/10] fuse: refactor fuse_fill_write_pages() Date: Wed, 22 Jan 2025 17:24:41 -0800 Message-ID: <20250123012448.2479372-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 7d92a5479998..71b243b32f0a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1217,21 +1217,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; @@ -1261,10 +1261,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; @@ -1281,8 +1281,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 Thu Jan 23 01:24:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947767 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 39D261F61C for ; Thu, 23 Jan 2025 01:28:11 +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=1737595692; cv=none; b=tjhKAgaDuonubK3iJJj9jtSSwD1iuI+82V+TGzR93ywZhdxzHcbBAkiUZGIQNVWIg31SYYUQ7ee5/e5uHqPhM8tnoExlAWKWEGiuZHoqEMFvVHNOabAr8TXDq75OQE8vUEtyzK7ZL7l4dHZbt+3wOnf/F2NhkXPf1XrfQ/L2b3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595692; c=relaxed/simple; bh=jnDUwYZt3z0RysXLnufPs3iHlGXYv6ybm4LXoFybwA8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qbbPHDKi4HksiXF/5pH+Wgvoz0VtTc9naVpcrRPcBEB7kW4Q8LCqsY4ZCxrTTGkMFflvzvP9j8Q1b0uzazdam5/R5Wy5e6iltuYlxXFh4tB6DnQS5FSoesItrnEBmGZ+C10FbhrgqeZYfgM+UDGmPZpgyOeDAWD0U5y2nmlGM0I= 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=gbgolBJv; 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="gbgolBJv" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e53c9035003so613193276.2 for ; Wed, 22 Jan 2025 17:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595690; x=1738200490; 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=KPHhZPkkOh3rgsYlEz/Eu75drHyoU6Q136E2ITdwV88=; b=gbgolBJvO7Cv3+356fW6vEoqzsIFmEdpggKq0Ccrrm1JCYM2jjd3wSjFqoNkgChJsQ YlxHaMvNV2zOlnmqrTdr+k40YQdzVQuI0Dpu6QGphrprd9zK45QhZl3n2TImKa4GNBc4 0SUZwDnUN6o8D6OmgmNSk0tc03yodICYY8xRdnbsni9gzi/S2yxrnX/TyROoGEaFavc2 ngQ1SU27hTp4gc+uFNVVSoBINjsX12YmrS/oIxIPlV1AjHirMQdKrjBaoZ24pdAObBxS N9+XoHVjSND69KvxtRl0S5fF4NfhbmQ56xyEHjG4aaSROX65aRGDD7Jj9N6MgJyNg2Bu Z/2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595690; x=1738200490; 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=KPHhZPkkOh3rgsYlEz/Eu75drHyoU6Q136E2ITdwV88=; b=KVIWOwmQ1PPhGW9bisFa35TRqYg9CE/aumcKsaG/Ed5NI++0mzqILSq+S/wDBOdfvI eM1FwvrWgV79rx+CqnSMWTJg/u2bOnAVwCe4bUgA5OaY67xt5cqpgPJGdm5gtEsd3lKq u6RIxmKEw3N0zzig2CfzA6c6khyMCjTd6vPHTucIQ/LEduCnxZ9t+vik/OQwrYjnXbQR jfO5oR8ea/iGtrVIgTTPcHPJ5IjhjFBkqpq2FRz+QDD6+ZBw55hgPC6Z24v89JA9ZwrR Tg3FqwGVUbZf/eWDFQfPixeh46jma0JWgo6TGsDXwJq/xV2uDIJ79TSbXGkNgDs3V5uc 5QxA== X-Forwarded-Encrypted: i=1; AJvYcCX8FdWzI5YIcahvswkNpM5v45s9mdWksWnvhm6AD8G7JxtlNWoGPLzU9BlA+z8FMqp258qt0xkQocx09nON@vger.kernel.org X-Gm-Message-State: AOJu0YydHiZBVJCZzDdISkgPXiivMeiAzs5UMba51tY1fO5a0gkCr3jm 7DMriRcjZ8+Vzs6O1gnedVGG6KdVLyC7iKENVT4jGV89/6Rg5ac5 X-Gm-Gg: ASbGncs2uKPS+7y5Qa9gNWBAFbPExe7ho5YYbWdIk4bFKgH4kHtGytuagaeSau4j6G0 8+L7kBLe6f25bEsviVZTFjmLg7mfTN423p0SKDvpwdQ8IuOlRTyoGldWQ4AIz2xoWz96jwiS9y1 QAKD0S1/6CI3rQcBchwjQoCPOuK8Mnv7bNZUNEWwnCVzN0yRPYNt81oWjJGEA9qM+YLR0uHT4kl tNlwt7xwkZ5oVOxsB/xVdBE2XR9X95wob7rNhb+KdfQv768/bx4WbnG8cd4Dh3Oa3K4bRBYb6ET ig== X-Google-Smtp-Source: AGHT+IEbsCGdfzrhi1b9fN/6eJiA3Neto5dMmVgDbYwaeIQQNRv/avmolqOIeerfKpij6HAoda5iiw== X-Received: by 2002:a05:690c:6f8e:b0:6ef:7dde:bdef with SMTP id 00721157ae682-6f6eb9058b0mr182807647b3.23.1737595690249; Wed, 22 Jan 2025 17:28:10 -0800 (PST) Received: from localhost ([2a03:2880:25ff:2::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f745855530sm2614407b3.52.2025.01.22.17.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28: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 v4 04/10] fuse: support large folios for writethrough writes Date: Wed, 22 Jan 2025 17:24:42 -0800 Message-ID: <20250123012448.2479372-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 71b243b32f0a..aeed80bbf01c 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1214,6 +1214,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); @@ -1225,17 +1226,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, @@ -1248,7 +1249,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) { @@ -1259,6 +1263,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++; @@ -1266,11 +1271,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 Thu Jan 23 01:24:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947768 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 960F01E4A6 for ; Thu, 23 Jan 2025 01:28:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595694; cv=none; b=urPTnSOGJdVrFIRdVdqgQeXZO2ODVSJ0VkJrXsKwl73CYyIhBC9hl6nivU6Ii3vFrHLuLFUvugn/8ZG1agHs1VBBAQdWQ7T/ARjCb1Xh//bQfc2sSfK3vbIo5/mohKd/z3dsqujbql71MV3n53dfzfFZz3m8xVl4sZjCaL1Mvlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595694; c=relaxed/simple; bh=mvQwxrUibyVsExtkARfXA0/1+GN/KVCy4nAumcLVxY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iXCPavJ48ustpGYe6kFNb6NqCA4chk+WyfRQC1PX43q827OxljzME1UETRE2qDKnUzPxzRZSzHpJRNZrCvPqQtEa6PXNIJu0hvIQ+P1X5HpgM6OTwwTdmr+CnQfnlKlEHi2mPBQxhpt9vKv9fOhBJMoX+uOheqBv0Tnhx9G50Hc= 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=YZMtX/ET; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YZMtX/ET" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e5773c5901aso2564038276.1 for ; Wed, 22 Jan 2025 17:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595691; x=1738200491; 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=tHYMznGelv2FVMsnzqkI+3tl4jMW1kXv/aI/zPv0Htk=; b=YZMtX/ETeN20hlFw4FtiYIZLdVKB+1ZTcDWcFYci9+hsr6P7Khm9CkZ6D3zqEDyoOl iBMpTj8VJDZfhHYebzTTtnP1VYbDv/zqGXCTNRAYEDbQMkQYD4/eePbjBvXAZsQ8fW1o NUs+4OFe137jwGhQJ8zcVCIeu+PGQbwJYTkpcqihwW5+C1HW3wXbkKIpoJx3VK+JVg/i tT7ryOvNSp+Qi+yNI9uwUITwkW0lYkLBcVuzs+IyyKD+2KryKsikOsdy2ZHheHyrojNL 84U1FhWYf07ek0C9/5/2XKD2/VYggu/a5dJCmmfu+QpVGu0C71e5vmRnAzOq/p/b0DX1 5dgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595691; x=1738200491; 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=tHYMznGelv2FVMsnzqkI+3tl4jMW1kXv/aI/zPv0Htk=; b=ce7eOq26wOkrw17JfHAIODSbnqtIKHadJqERvBT2ygo14I1PXFJWsLCLpNNCnIeBEJ bzMV0pDJB8uKyHZ3xwDc5RfPWYTIkwRs0Ko3BSGzwlHkJC623mhGqrYJC7Y9Kst0rXTu dr6fuUiwY673bosanNPVJf8Z9TvAe5HGAAq3+p05ys/KrZ42W0NKdhzMwK+0ZNoMkLu/ 5DOxlM88NJsiNKj45A+OYzJzg5oCPsFruIKpFvY5ejCFe+U1LCoClyDOvKhWE8BEmOmD sBCziVpcQz+d08ioCJCG4sePEk70BxPST1am8w1GHpO+uAXXkgHmF/yRfgd7kLj9+Ab6 /2zg== X-Forwarded-Encrypted: i=1; AJvYcCX20jC/V1bFfKogRKrLMhX+1arJ6Mp1lGI/9wtqDN5D1IpzS9Jg0OOqyBc5lP/0Yd6IwBzvuc5Jpq+QO/J1@vger.kernel.org X-Gm-Message-State: AOJu0YyjB9EHYH54GYwkXXB9Ej03eRjFzwbdc+VmwEhFDbGwu/BZXyfW tnNH8Bip86vte6Rp/wVmbdbHJyP6f7Jjq3f9X5HDF7npNauRQOPU X-Gm-Gg: ASbGncs1QJlHZkt9QwDr1rZe3sfrLSUF4nNnDlc9qKx+0w9d50+/zMFFbobyIK45sNT uL+GNHSmtoqHi6cI4oe5SLUE7i/5ofga/TOpGf+FjBI9BzQ5HsIrsl0ZRcyVyyZO8GUcBsQpJ// d4RS+y3IYTfrgWQTWT5iMKZW+hbmR8+a3JtRF9tyaJDMLJ+KJKUmdPTIKbtTm43HjbqM8DLfz9u 2IFQ0I16NCYytiaCcSKVUgYrUlSgx7iD4Vm1jw1x0ZH6IVovtnjdQuDJ21rILtTp8l/rD9qDPaU dg== X-Google-Smtp-Source: AGHT+IGW3HLY+Ovq7bmzp+fU299Io+3F8+0tArQ2FHeWQCveOY7EWc7AhZnOpoGrsng/Es1h2kAljA== X-Received: by 2002:a05:6902:18c6:b0:e58:8eb:d703 with SMTP id 3f1490d57ef6-e58258b3e4bmr1150070276.22.1737595691461; Wed, 22 Jan 2025 17:28:11 -0800 (PST) Received: from localhost ([2a03:2880:25ff:b::]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e57ab2e5fe9sm2275265276.13.2025.01.22.17.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28: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 v4 05/10] fuse: support large folios for folio reads Date: Wed, 22 Jan 2025 17:24:43 -0800 Message-ID: <20250123012448.2479372-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 aeed80bbf01c..89ca6ac49187 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -875,7 +875,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 Thu Jan 23 01:24:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947769 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 D60821BC4E for ; Thu, 23 Jan 2025 01:28:13 +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=1737595695; cv=none; b=fykWceCdjdhKRnzIczk98KzVWzmQlZb+AUnoHujwZQ4YEURRUwXze+uo/mKHV+61A3PHEq4lcoUOGz0S7bD8af0QPf6gQxn0QLH9JMg6SG0uaZPbtqizGAxaUrmXxRgJhuYGiWvSsc8W3YXcMa2o9k826eAkHN+ORnJg0EaerUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595695; c=relaxed/simple; bh=xNOjj4765HHox3xnS4REXKWK8gtCszZrIIZV+3Fbo9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qjwk0i78UKP+OrDmRY1WGp1UZbv6IIzoSWEvPVhlNnabs3Wt5yy//n+20rQGQQm0Efk2+avxWM0lkYf/BGlMk2X4/iau3QaINDoLc6VfwwWIVnJGE6jRhORiwU/C2oLnsBKrDorxVSvq6slx3oZpde+l/HP+HPclmy1hiv9+yjI= 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=JBhF+CS0; 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="JBhF+CS0" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e549a71dd3dso723347276.0 for ; Wed, 22 Jan 2025 17:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595693; x=1738200493; 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=RHdvyTGLwlhQnHBF0Des0rmeoCfjlOs4jlwdSIFkjCQ=; b=JBhF+CS0QlYIY7EIsBJGOfchFMWxopETiD2qNiBu4F8660vckAOCPB/ok3g/8BB6NS 9bmDHSwhjddLEEMp/r2HOChRtQr+GCgBLbNMDH4nQ7Rza4tapGmCKSWjGptKxY+W1knV POZ6gZ+Yi3j9P9ggS7K1NlwPaOcEbOhbgaMlIS1+AZGfSUzb5Y1A07IGzJkvPG6Uk63P rtgUuXAbKUjHOMkiXLuO0Rc81TQ9wFb1FpB9fcdSd/bc2TFLc8nUz4PazOoFzdNvV1Wk 2rRLhxQVaSIRVDiNtz4P1BLsayA2SvBbI8H8U3d1t/q7B2fARAQy03RqnjnWnLrRrcYP Tutw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595693; x=1738200493; 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=RHdvyTGLwlhQnHBF0Des0rmeoCfjlOs4jlwdSIFkjCQ=; b=Ef/zVKDFM2Jq3vCgQf1hIn/M3px5DZqHNLKg5UGU8vfvEQKokm8obpTZQ9A5oVDWlv 3Jh6k5CA5XYyA5pM+vdKoywtN/rXst1wrfxmP8DDmtbUoBT1x9+smuP4kqUvie6y8lBq 8GrStUscJaDPC14LYQAjr62k673AU/ZR9tTsmkoXyzwPhTvONDcfGl4BPxftv2YBx/Dl rkdYJhmV4BSiWQnK7H6SA5W3WGL7rRxjfRdk3BnhMko+h+1ObsIkVeid0+Vys/HZRUPZ Fm/Niu7djLR5D/Ky+Xz5YszakI7GvYv1X+LfaaRceP1WjzVy+vIDl7NvqMKbYNEyPvor KUwA== X-Forwarded-Encrypted: i=1; AJvYcCVfxb4XiF7PIWQg5ogbhf4jZ3hOCgct0aUDQas6bfKb3aRsIHOaQxAW8sm5d4he1i3s2mHxsrekIJhwlrg/@vger.kernel.org X-Gm-Message-State: AOJu0YyWAo4eK+2VH5c3C0Avf+Fgpzb5UuMA2sHuh6budRgvDj+RWzH4 Lkw8iVQ2zSobVe2kKhL1Lp47su1QgVpczm1HTECVZndJbxTM5Rao X-Gm-Gg: ASbGncswq3zoAd3Zwpy8qrQSsSa+Zwy+Vd3vntO58J5FIj3Lp4s0Nj63tra9DQNLe0Y WzhgZ0hus40ILdYDtIKtCwBVKk4UiK7RSIsU1ArvnX0Kzl/osGroFs6IDQXWtoP4YuBKTyoS+zk hv8U5GcG3L8zShxgY9fOj6O5hnhXu+qxj0WUP4wnYeWrUgFNHKuWNav9XmK7XvbOVzYq7RHfqYR TKfpQSz35ix1Ni5JsmmRNJoUc4w3xa9lV4gZ4w5JeGlomZVhP80KUYJzjYtBl+2HFhPVKcZ9tSS WEs= X-Google-Smtp-Source: AGHT+IFyGC4LRvi1ZylMO4Uj8OREnnNOKqlfgLai19ncOKKXgP98N1O0jbbHdoCdAwsJF3vU//P3rQ== X-Received: by 2002:a05:6902:2b0e:b0:e47:f4e3:8802 with SMTP id 3f1490d57ef6-e57b1051e1bmr16936037276.12.1737595692697; Wed, 22 Jan 2025 17:28:12 -0800 (PST) Received: from localhost ([2a03:2880:25ff:74::]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e581633244asm402299276.29.2025.01.22.17.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28:12 -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 v4 06/10] fuse: support large folios for symlinks Date: Wed, 22 Jan 2025 17:24:44 -0800 Message-ID: <20250123012448.2479372-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 2ecdb8f14d46..95b516c664a3 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1590,10 +1590,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, @@ -1648,7 +1648,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; @@ -2238,7 +2238,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 Thu Jan 23 01:24:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947770 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 0289035959 for ; Thu, 23 Jan 2025 01:28:14 +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=1737595696; cv=none; b=OI63xJAlzRzTq9DHsco3chmhlhRq7ccG7FiJJlo5iB3MD6zyGbRI469YKhJXr20SzExCPRYc58KZJBdgVrcnniGufVvxnmIwmazoSwHlTkMcsA9hMWVM4kUSvoH9IzFCNpnbUU7WF5Uph9YkXWe71nFMq5AuI8oS0cwfmXzabZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595696; c=relaxed/simple; bh=YppN6EpQPqzebsgsTU9ih5N6Sj1iqHcjLOl8HDupkDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CI9HkxQruKErHS55QwO4MM6T5agqTPKqupCtMyEIw1b4tLKti1pjHu24HtbxidytXghhsU/pNiWArYZn2FGT0xH2NVvyEvWtn2FUhz3/8fPcsgGJXXLoNKkQd9gjxgNoNGh1TFI4E2UdJ/RCLgGsVKNg/n410rBYnaf5JMWDVQQ= 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=EC26jmta; 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="EC26jmta" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e3a26de697fso573118276.3 for ; Wed, 22 Jan 2025 17:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595694; x=1738200494; 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=oVEwBq2psPdFr56uT9dP0HbI4MOFGq/OoRMc6b8lH3s=; b=EC26jmta2pxe7RTkjc4OId/BFVUprAGF8DxjbPBrV8hvc8td9gvWvJKEYejcA7UeY5 aKth1QAhn5TXp737v/MPcd3WV1cVT8DcBbp/iEsUCas4b9NdCb2M5pmwFxrg/iPUZNdj Py/06/KBaCyteWU7G6lOZQvqatrcN0nrVYF9DC2iXjXn3nrZVUREFR2WyozIZ7SOAevJ Z+vVhnlR/LTp1wE2BsmiazknORdeqPoduQSTw6bMYPPI1oGp3liSJLMaxjyNpRJLvKir t0FwUrAZTtVeEXY11U/hBg2UxpagHRQFgPmG8+jNLHe6Lzk2vaI1IJIH9CdTa3H0YMtP 0JHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595694; x=1738200494; 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=oVEwBq2psPdFr56uT9dP0HbI4MOFGq/OoRMc6b8lH3s=; b=QaRsK6kF90Fe0WBWKlGp6wAd7Gd0klGSfH0SeCZoS3xfW2Mh7ksiH9lSPu3HLmSwg3 VY/WfBQ1CsUF7Ja0kUCx2MURO/Nf7qydVS4kPHasscGp/K1jPkKWHk6Iu96mSnUSC+0J GCKAEdqyM4Xvtp/D8ArjQAJzVL/xvrHfN0siZ6u+EEnPT0onag1OmQYdbdEDIPbxXVrj +xs+V2hgQCFrS4+JTnxl2C8U+C8urvYCeyaY6vAwHrauPj2fJqEc9ov9seWPmPx5Tf8x ldGvd6qlqNEEZMWA4V+9cIgW9/2wd+mydWW5kMM9X0O4f+QPaO0Alsp4c+BnmYqzIJYD QkiA== X-Forwarded-Encrypted: i=1; AJvYcCWoYhBPhGpp2xUQk5rgTDHstBGa228CXj+46CQsQuHgP8umKVxdKXNb6qtAXgBY1Up7rvmwh8Vo9WUTORHI@vger.kernel.org X-Gm-Message-State: AOJu0Yy1VQrAHqECMBmVRAcXFPgum2s4KC0Rrrj5H1HqC/4VjsFWt3sI 8RdfFOtlkcIj/TU3+CcIksfb1fbbvZ3DyCWzN8rbRul3AD7UmDpJ X-Gm-Gg: ASbGncvBHFOAxZ5V7TwB8Ri/nkgkTbqu3JFQ3pHIOewkpQjKB4P5yu2hMK8TJ90K4dY 4WYM+0swRoHOrCVxOcQFYHorPzsjpX5clHHaprUIp/tWSM+Pw86OUOlxWULARlhf6nx+rD52Tpd RXZOc2MnQlZLS3aj4EHs3sCb2cLTeOKZmbzUrv3cL7YDbXTm9h/LloQ4l/l5/kZTXNpRncTGWeC uUd7MHoJnRFUPJjy2MqLqHWSOHurTxvNVvxGDhYYBarj34JogEiFZiCeYjuDsogQDur2cGQ5dnA o8o= X-Google-Smtp-Source: AGHT+IEZI/3EYSxsqLiphu8pyEF/NweTMnHaqBHbO2P3T4QI1I3B2B5NRGx4CTToInXL+gqwW13jPw== X-Received: by 2002:a05:690c:6812:b0:6ef:e39f:bb1 with SMTP id 00721157ae682-6f6eb905af5mr199947457b3.27.1737595693897; Wed, 22 Jan 2025 17:28:13 -0800 (PST) Received: from localhost ([2a03:2880:25ff:70::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f6e66d1110sm22180667b3.86.2025.01.22.17.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28: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 v4 07/10] fuse: support large folios for stores Date: Wed, 22 Jan 2025 17:24:45 -0800 Message-ID: <20250123012448.2479372-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 ded2caa4078d..500224921336 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1657,18 +1657,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); @@ -1677,9 +1682,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 Thu Jan 23 01:24:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947771 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 395F735965 for ; Thu, 23 Jan 2025 01:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595697; cv=none; b=PUOFHsvF+Dt7pkI3YZ4jJTBO91sdEuJ22m31RngoZY2XydRYSHObx2fsn/XZtAw5xfRE6dzYixKTnSlq6FI1oV7oaawuafJq7WDapATQzV+1sdL/R7CJDolDFZvprP0UHzTQMj9Tr3uRAqlImEsqKEJNcMO5S30RS3gIfy9h2pI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595697; c=relaxed/simple; bh=OC1GiSYAhZrmdt1mSJtRgFpEf8qJsyucTFbQC12omhg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VhEC77oYBfuVhILbJsvIIgankYPqMHnRIfOEkR6mxW82wE4RnErsAXBqsWxHQCahcyDze/fb6y27VdfSJdOGmW18/dAopX5lZyDYYDSPzkTATaYjDjQlj+SL3bJuLv0CJGFVi2TivGNb4v/Qe9ZTF5YgC1JgbNpuS2MVVv1LHCc= 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=Bci4Lhnh; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bci4Lhnh" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e545c1e8a15so637220276.1 for ; Wed, 22 Jan 2025 17:28:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595695; x=1738200495; 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=oAl903GvphXE8ZPhGxZFfsYEx8X+yFUAB23raLOcIek=; b=Bci4LhnhTvUEZVcP/SYfUQGMr2xJwLIWqnqbq9klTz2SA4sqydIQIaNAZc+uRrtq4j 1eZTijEV3opS0k12KWOL/vusDGoA3k0LFGaxbuL7+j5tF4I421hWpCSjgqwJKHKp2afg WRSmizI2BfdgjQLZdE+7LCzAWq2rQZ1a2LGXwULt7iAkXlbBEn6t/CfmEwPuNlcokhB8 a6sU1FXYsjDKHn5J7orjPTJLAxiWxIQ4BqCK+Kr8/IMo9QOpz3XAHvD3g2iYGRsdAWpi xOakoZm39qLud/cr81YEQ0MfqJHotwHHvbDIl7GhPnHrSV6MckF7RIldeFwbY6rsQ5Nv 0StA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595695; x=1738200495; 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=oAl903GvphXE8ZPhGxZFfsYEx8X+yFUAB23raLOcIek=; b=bh0bw1zav0QFszaqjtKfTKhRmoU7JLVZXUfHYSn27A6U5jeocNqvYRzQ7/cLWGWm+c mULqqiZiYARYKRwmT2V9AcfX87xPigb7ZzTUFJfehfmprVYKi1GUq0OCZJ8tgrUJPsmO e98ebpciDjP7v6J3SKhfvKvs9vLFXXWDkAf2vOq/RYdKws1gIN0d/FfyyGWm3/pQcBoY FCkaD0K2luc5XegyR20q0Ww5psQlOw5reJZdbcq+VU+fh5bYrawj7OobwyD+euIy5JMb KdHo5XRBQuAvxCoOlVm905//Aif/2HSVT7PZQcLvwwoz06XMUhxDit6Utt3j/x/uvgan iSgA== X-Forwarded-Encrypted: i=1; AJvYcCW9T8FHedk33YDWsz2L1xUKpJMQ0YO3Lk7Zi6+ILw7lanFu6LExrtYZuz4Ea1MJCwtbYpvvBFKbFR+96t8A@vger.kernel.org X-Gm-Message-State: AOJu0Yy5Gp4Xer978O8YCaJIBDdTB8e3QShUr9imYmkNbDdzSUgknlMv m4uOIjnf1Xq0eE0OAKpQLdu9dBWAkGLWDZRr/bTaSvgq/LqXjSm6 X-Gm-Gg: ASbGnctVG3MO2s1qhX84CavCdG5vOmTqFgJpjHWNPDkLsJO4fNxtrjZWik7fB2+bXtd NEBZwteBmUbRi4i0XCzhWM5Y8Gt4LflJ8ggXty3RUFmUtA/nSTWm46kefe4++3TxGxEqTVuRmlb pFr2UUGAyyAgUk5ZD0weBKaC5xw4NzyYV0UexGqkKZHTFx9OHHR/I4jjJmryuD3+cJl1qa2htSO n42jpbuDAAqz6LyYh4DmZkzww7BEsTECaS2/igTLXB3I7omiY8PsHSpWsyGHAfFZ1VDkU43E7on ics= X-Google-Smtp-Source: AGHT+IGBVYXlE5eM/qcOklOHgbbbf1RCNia97cDi/1CrxVbNar5at6TKKb+z49JGG+1P+zwW8E3ttg== X-Received: by 2002:a05:690c:680a:b0:6ef:6ba2:e851 with SMTP id 00721157ae682-6f6eb671d77mr183555737b3.12.1737595695127; Wed, 22 Jan 2025 17:28:15 -0800 (PST) Received: from localhost ([2a03:2880:25ff:74::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f6e66fa22bsm22194397b3.110.2025.01.22.17.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28:14 -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 v4 08/10] fuse: support large folios for queued writes Date: Wed, 22 Jan 2025 17:24:46 -0800 Message-ID: <20250123012448.2479372-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 89ca6ac49187..a178aee87e74 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1876,11 +1876,14 @@ __acquires(fi->lock) { struct fuse_writepage_args *aux, *next; 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 Thu Jan 23 01:24:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947772 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 437F735972 for ; Thu, 23 Jan 2025 01:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595698; cv=none; b=iE94DcPT1MAhpAD74Q4KRtN4BVEm1lxxYPLddTGr387nY6f+4aNP/Wmffo8PiZh304YrY9X0mLf8mertDPEBwO1kSbiHpTGLTYDxGkMk6yxjCAC2vMfEsSeWfllcFO3q4eYE4GzkgIw3/hpokNaik0oKiaqNiYvJFzdCtoqtMrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595698; c=relaxed/simple; bh=JVnBbdhW5IEvdzifZb7VHJ8cUODCFbZaV83Ier64qbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DmfhDa0QD4/u+U/+EqVMQJd5kuKY9hesX5TcM+Kt1P0Q3viji4V8JE7Hu1URjOw9l/YZHzLu6ywkhxLSymAJvS/Mc6R4izpLoJsY0zoZFQ/T7pp3VL25jTRy5PimU/7rDslWEP/1sijucyrU8Kjt9gDXTt8A1POR6rVn/YDM16E= 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=VF5tRjIf; arc=none smtp.client-ip=209.85.219.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VF5tRjIf" Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e455bf1f4d3so529537276.2 for ; Wed, 22 Jan 2025 17:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595696; x=1738200496; 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=e59gm+n1MlmMwsVC6vAnT4shX5z2tDH3wMJva9Pwb5Q=; b=VF5tRjIfEP88/X2khIaGxNveO/ZmyKIZUKSlKSR8Uv4Av8QOIs1AXgJJM8jCJpmsa6 NOdGQXL5klsM1R0wzT5XJnsLP1PUwVAttH5nwSTXWEvAQiQSS9C50GH60AnQbc6hxIFY +i4IDyJr0pGEjdr3izwDZqqDxNL257oBdy5QO5VhwMluR0fV29UiMtLj7PxPAIDNIAhT BpaivJmGxTnIuYrw+HGmwa3zNltL3IkAnNdiI/JVH7q9Ok67FOUOLs5wA6PKd9kDRi/q m0kvNYHTln+zZ11Qs4BDjj4L92+SB+VyIOs9vLJV4red1ePw1dS9uCcmO6lUnLu9mRTm kFvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595696; x=1738200496; 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=e59gm+n1MlmMwsVC6vAnT4shX5z2tDH3wMJva9Pwb5Q=; b=D2PM9++kQqjSQXZ/7S23qAz0AxDBXyBPSGJG+WJTF+GpuB1B1j4mPuN5d3wRyCmyRY qoWCQqVX2Krpd7S1MYoiQNrmQbJoM+C1IiiHPsvP4um0RdthMQJA2CmXgO+G72QKHoGP 74py9DO13r/KTaZIxm1m6XVfh63htrEi+mrDpdgemZxiObIpBcld0OTQcCNMc6ootHIX KfiRSabGuPQEN9nKXmBEeBW/CZwPc7qNqMzm3GxCBMiUmSRSqkC6RLtgH7quMqnrZINq ppWn14G7Q5/r1U9mtlbz+mr2XTIRRT8jZrgzcEZDDwUZD6DNO9KnKHeAVo2FqRlp+7yJ E8dw== X-Forwarded-Encrypted: i=1; AJvYcCUGoiL6cSn9tNPF2GGii7stoJd4Qwe760vlX5TV7/rjrWxhVCBNViJhytob5kZg+IVcWkd6zNZ27IPYpN8F@vger.kernel.org X-Gm-Message-State: AOJu0YwUn1qLEz3/KMUmVb2qxvAcw5UoH/OQGmGuBRGoVqCBr/q7D25K SZdKfAkETrAsAlZaJfX61PMcy/+r+Gc8QTFoyxnimP5j2Ivg0cel X-Gm-Gg: ASbGncsXFFRDnzs1ooM4v1WsA1aS1e9vdqq7dCNaQHVSUW3CSuySolViSAALlF8Ys+F sOR6lmR0D4xrzoWpXnUSco14dkWGwXu1CRbP+4yL9lo6EGldJbJy9D3azgSjbyoJPYujdSm5oXE zCVRC3Zr9xY7c2QUdz21CxxqfxrVCItLpys+7i6ySDRU19flTQ2nf/VJK7NVVS2dg4SGv9tjM2r LvSunsGWA4nRvcV29tampVyE0gimn5m2YWl7GKHcny4kYb74jQXtvZAiZCCtVBE3FlZnYRHzJPI GQ== X-Google-Smtp-Source: AGHT+IEx6aXle53+s69YXSTd6ZND34pzfKiUNA4jINVH+m55C/6UmV40C+FmhSiJC+P/PzY6lPDQLA== X-Received: by 2002:a05:690c:6e03:b0:6e9:e097:718c with SMTP id 00721157ae682-6f6eb658a4emr200809807b3.6.1737595696299; Wed, 22 Jan 2025 17:28:16 -0800 (PST) Received: from localhost ([2a03:2880:25ff:b::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6f6e66d1fa2sm22618927b3.75.2025.01.22.17.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28: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 v4 09/10] fuse: support large folios for readahead Date: Wed, 22 Jan 2025 17:24:47 -0800 Message-ID: <20250123012448.2479372-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- fs/fuse/file.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a178aee87e74..5c98dcc337d4 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -963,14 +963,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; @@ -1008,6 +1007,7 @@ static void fuse_readahead(struct readahead_control *rac) unsigned int max_pages, nr_pages; pgoff_t first = readahead_index(rac); pgoff_t last = first + readahead_count(rac) - 1; + struct folio *folio = NULL; if (fuse_is_bad(inode)) return; @@ -1031,8 +1031,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)) @@ -1047,14 +1047,27 @@ 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) { + if (!pages) + return; + 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 Thu Jan 23 01:24:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13947773 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 326353A8D0 for ; Thu, 23 Jan 2025 01:28:19 +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=1737595700; cv=none; b=bNdvTiC58vxPs7IIUqFKepILkIQyN9uvWh2yqe27gaYQVWWvwwDYJ3O6INQ/TtekIwkN5RxyGDtDcVSFBuSfMnpTCELA/3nFkgCbChODMxL60KG3V4lF+bGFCZflmThX0Emdagjavc7fTVWUB2dVJz2eo0HM48C2/ZXIaKVT1nI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737595700; c=relaxed/simple; bh=w6y1oAzDDWQkJFzcWqlCoUhEtiG+SBY2QmdHUhlZ8dU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PXtEyx+7u0lC4GGW4IzOpnKEXs86nfMv7d4uXxMB1EU7yZgSb71aIgERTyHfPzjdxfvuG5Hb2d34oLohKzvnz+ddNHDiE+DJw5tou1+pVKNE2I5FLyNt6nm1U01AbwZkj3cTyTOkkKZdSWNDbXbD+nzAf69drVi3ixYSx3c2Lck= 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=V1YTqJYl; 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="V1YTqJYl" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e5447fae695so670976276.2 for ; Wed, 22 Jan 2025 17:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737595698; x=1738200498; 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=dLtMHv5hhZnPwkxgLGZh9zHGDqqn6F5OwQ80wc70wtQ=; b=V1YTqJYl7YEsruXfG99gbRsINXgI/HGtsibdo1bXYSJmcvpuZKsjW09ii0XLH8juIx xYgpjF05q/v4o1OO9qPhin3tidY5orpwHUO11CCTSbV1tnkyasiYzadosQSWkk3aBEmF YUanhrneBUmbUETZV/lqoQ//XNuwe+0IF6T9+GaHzrHQTi3YX+v7QY6s9vI6sIDv/MU8 lF+sYZ8xPldQaysyGV4gJlQE+1hwqWmfg4P04jRSgcXF0J5LSoqxAhFYQjTlxKEoMDyv RsYROdXtPOqCPGsczpcCMUX8/B+fZRgw0gunw9S0Vs9udSuWn2WCQluN7VG3nK4IE28l BGZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737595698; x=1738200498; 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=dLtMHv5hhZnPwkxgLGZh9zHGDqqn6F5OwQ80wc70wtQ=; b=j472uXhdc63MytSU7sJpHbwWJxGlblSzf/C56zvMXPQ8CzBmK5Uq+uzBGihU2JbpzF tLGwHJ3dWBeP7fbhWjwxjNn9pcB96+pNNEuHWBGh98egyxuzaD7HQ3SMQAariap35/uE 8lilcn1QqGrm4QIyPAV7IVHhvXNgLrNR+ZcnJN8qJlnb1AjmCKIMZR283GadC3Jr3Itd 3zLAbgWSFdqvo4MwN4pAu88vScTO+oA9Z+jiroF46IOlDoWmaHPSyGOyqko18yTltrDs vdgVecOXJwt+1dDPpKMD92kb4xdNeEuEWhMNcShnf9wv9fniQ8jaBP6tk8/Rmc9u9e1E VYyw== X-Forwarded-Encrypted: i=1; AJvYcCVDdSuurALqDHRdT7tApnrSC38FFNHLLem1X0mnPcnTmaLJjsJV3VQogxdlz5Z36b3lkqspQ4CpmDbPPvsM@vger.kernel.org X-Gm-Message-State: AOJu0Yw2FwuSdtgIYGH/2w+JRXapS+Plf2SE782W3lwIsblFllsx61QH 2DP/fkY1+jmmcZRUcNyXTCWVWA9sC2Ei7gKsMdTV68ngNDa/F8JK X-Gm-Gg: ASbGncuFI/UL7ZKBsrAd9ig4vGdzRHRs0pcyQ324CPwBrLajbThMHwVsEHfsYul6nHy H66cw+NV1Uz5fCM80+BG8nZXacrIR5K6jCIJ5adnL7A/osqCw7GfBRLTfur4I7opy30VbKqEAoQ 4AAeIj3xNm5DMqf3ZudhVOSmwvQ7HpOXIScsFrkD9NmqQj1+JFdObsSv6J7b6VoxGHU2EiTPXMI jfxO9WASYFx7nKl9qBLZh6s6lTV0yEapDruWyI8zn2jYWc02pmLyIxUE6jNFqLOYmx5VFEujXtx Lg== X-Google-Smtp-Source: AGHT+IEvdBMzNuYvaKIBGFpzlCjxgwREfReVmz73bTdSHqx0msrsLejoLg2715Eb9R52I10gyjZt6A== X-Received: by 2002:a05:6902:1144:b0:e2b:dbe5:851d with SMTP id 3f1490d57ef6-e57b107b025mr16956311276.28.1737595698176; Wed, 22 Jan 2025 17:28:18 -0800 (PST) Received: from localhost ([2a03:2880:25ff:a::]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e57ab2e6ed8sm2373428276.20.2025.01.22.17.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 17:28:17 -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 v4 10/10] fuse: optimize direct io large folios processing Date: Wed, 22 Jan 2025 17:24:48 -0800 Message-ID: <20250123012448.2479372-11-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250123012448.2479372-1-joannelkoong@gmail.com> References: <20250123012448.2479372-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 Reviewed-by: Jeff Layton --- 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 5c98dcc337d4..1e49589c8928 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1566,7 +1566,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, @@ -1578,23 +1579,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);