From patchwork Mon Nov 25 22:05:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885319 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8FB21CB53D for ; Mon, 25 Nov 2024 22:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572361; cv=none; b=SujD3z2a4BLsoIYbHMlyFG/g0iBTHGsTqLEvHldkv05jEQwigJb/s7t8tvNxcU5IgSM2JAA4coVbiSQ73jcfnOiAI2Fshg0VMbJ9jmmHaZY+jwCrP2izLhMWICCOKx2JzWJr/2sWwQGu6i0XyLqQRGVd67RtbRbRnWzxw06g6Uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572361; c=relaxed/simple; bh=gkXf2rxAgUWgLpG9YtYvwwSiwksZJPdaaUCjkT/OSX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eXoDO3GE1+xw5C1sb0riT5k2+A5u/g1g+/uHYuL7TnhtCnBcK8hGQ5uSABDom6O95Wf5E5IO6rJMc+wLrSbY18css/xO/1WPvW3+04eFAfNG3Bib70A5xq03SIzWwyqe6ujt22ivsNq0OPfytk/3rbCy0m5ZO/IhtVJ7/xB1+eU= 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=iSaup8nv; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iSaup8nv" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6eebc318242so46545387b3.3 for ; Mon, 25 Nov 2024 14:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572358; x=1733177158; 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=GcqeZbj2IHRrLamWOAuVt7wG7NS7XnKDaZ6q5yDmoqQ=; b=iSaup8nvQZgHx9RqMJUyZZZNNKrC9MuJA8xlZBRzEFyBP26uS/p/E5vLR5E0n+ein2 bGncIYGB0Jzy6tG3jgP6pd/xo7eLlMoAR4ehShvATCjw+pgS/v5Ysb8G75tX/8pnwDWe 2w3gTOk3zO8vK6nUjNti/FXJb+JPt7aQNXLxbURukO0vJiSHNDdzxWL6WgwFPcPziIEW oK35DnVlSYHM89mPWdfh/g4YR73AXHOkHR62Hovlo+/MMp4H1+QycTInaYBvfdSjiwTk w1ROjSAVykqRdBuPnRAPcrSVkobLtTXyfR9ig3SGQjAURYAOtQ/R4U0mfzskcsyXKal1 xyHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572358; x=1733177158; 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=GcqeZbj2IHRrLamWOAuVt7wG7NS7XnKDaZ6q5yDmoqQ=; b=X9YepFs7BiCle5bapUcCRLaNMEEXLdwf+dvVLsqG9uQEDTEI80OZN9wBdkG6KsCb5k plSv89E5BRkb0HHew+NBa+F6AfTz1C+yPw4KKNXDwdPaBUtcsCojPCBLK9mlMdP/edbV ftaHZI7icMniHwiVge7/ZYdvinDViueZiSDKa7d//LG++kDZbU5E/CvbLAAMhQAX4VnG smcaz/+5SUq3kptaKoBqO5ygMOJfdJT6EWsA4W7aCi/I65NYj8q+qcE3aCuFWP7F23s5 KS6XaaGb7vWDg030DGw8qL2miMNvtyXjfJWrOlM5CCnTV+R8EcXU+gU7v0r0otxxqPjH LjCQ== X-Forwarded-Encrypted: i=1; AJvYcCXbIWBs2eKP1vRXgoi7hCLQPYdC5Ju0Qiy3FIHgHlLeG0QOQ1EsOJjQPbZgDJrsRu6bKqLD8JMfZQtocjCL@vger.kernel.org X-Gm-Message-State: AOJu0Yx6KvYLWENgkl9bgD71mgYb419XESbBT/f0PjofpwDHsH228U0E Kya8/uxuZ7Zt//wXc9evVx7d+UyIUHxRO5mMtrYSaSRHtR/e6wwJ X-Gm-Gg: ASbGnct5LAVecHHhMtZUV2TeaLMCRkDDgUp5gmIRVYXYz2cs2zDvL5+B5P+7E5MCLuZ LUV9hV8RSiSy6nm/lbz18w+aVyaGVu775SzrxvDy+FWhmjoPjyN+/BKWaONjxyoSO+4K9XbFr0K 33gb07g5JfXMTxYMFEOgeLOpJAbuZhfLuUN3D1njysF1aBQkRwgu7UdJaD+KB7ooX98HFUWJBPY i+l7rs0NncQY4TwnhtD/2fnvSOuRLQsL0p7uvhEA3Mha0BNVS/oPSdRK7EuUYOQy+wp9SHWs8i5 eKYAvDGY X-Google-Smtp-Source: AGHT+IEyBCNjY1o6WqaXfsN5POdEvlhmCojp0inhS/BnfP5dA0Xl19YaDhEFDavFsgpm+u4mHIYkpw== X-Received: by 2002:a05:690c:45c6:b0:6e5:cb46:4641 with SMTP id 00721157ae682-6eee08d1dacmr131740587b3.13.1732572357888; Mon, 25 Nov 2024 14:05:57 -0800 (PST) Received: from localhost (fwdproxy-nha-009.fbsv.net. [2a03:2880:25ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eee308a25bsm19097397b3.110.2024.11.25.14.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:05:57 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 01/12] fuse: support copying large folios Date: Mon, 25 Nov 2024 14:05:26 -0800 Message-ID: <20241125220537.3663725-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 29fc61a072ba..4a09c41910d7 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 Mon Nov 25 22:05:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885320 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 3443D1CBE8B for ; Mon, 25 Nov 2024 22:05:59 +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=1732572362; cv=none; b=GxQTH1Mlv8dXE04++M3pO+faJKt9cQUUuQ3UQE6O5HmjSwjABsugotbtHy8TRoI/ZtBWrW16T6RRBFRDzD+y2FV3cr3rDctjdFxNklo+xNdWQcleU67g4AzNMd9Jnw8EPb0sUFqEGys3wQ+5d+jQXTY6jQNy8SYpnkR0lo6jMx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572362; c=relaxed/simple; bh=GdAn7v7Hx5GXrwmyld6KDS/W0WHxQ6/VXwwmv8Ab4+M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tqyYjg16HKjldvACCm+JExF1Y/v+9JXlK0I3ynRYgybZySkEXAZewhK+60LhwGZdOYst8YzLdcWguBiGK7GUZUCKkgDb0JrhJ+eIBH+MJXfsutVEXsO6L7HCUhg6LhdCieUo0z3/IrCcrHzPm1v8QhHr2DIMsjCUL6VB8LlDAJI= 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=laQ/n9tq; 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="laQ/n9tq" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-6eeafd42dd8so51759237b3.0 for ; Mon, 25 Nov 2024 14:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572359; x=1733177159; 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=5JlHLhlBCg7PkXL6On8ehHEY3Iplfl2NNRUfXG6PYTo=; b=laQ/n9tqUPesQ9sJv7e1m5I9FKdIh+EO/ZiPsKcttvAwSNATyvTb48hvv2yinnBLyY cIM3tfv43AHmVRaL29+nWNmMgGvrdmt506xgJn9WcnjR9/UILIWcHn+OlHM0DHm+EgUi NmQEwkDwE0dhElSnKu3oCpI4JhEP+2rODacb4J47onYkUk5/OdBqPzWyP4aLjkms+cCA h0zW7P2kcdY68CK5lZGv3iTXuLuKa33gp+9n4/D2JqGgb4WJWsrtEc7yDGZimjbS5w/K l8oXADRzTD5A1tKK878UXorxPoPp4FdMaWjSUkckTjVV69d+AXB0J7vGXGZeSO992ztC 2+Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572359; x=1733177159; 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=5JlHLhlBCg7PkXL6On8ehHEY3Iplfl2NNRUfXG6PYTo=; b=O8vgO4dQcAf1/CxbhXi5fmNP2JP2C4YeDGL4HX2vOUqRpHtdRXqdc6gaewAhKYQwrR ZwFhGd9lU83eIr4G4Y4EbJEdGpNDQdPpGvobzVL19Yt3MDb9IGIpS70X6tutau/hXCUc ZuO+ygpTwqPNe44De2w7aCz8GjQWi6OFhWb7Dui+2NVdPqaACYFRDKu8k8P2mTIHUeXL EewneIydp3EBa2AaKmQmRI4WyrTc9RzAT7iZ8QdYa5h7zal65Q09FGYyBqZUMlNA+0jB z5ulo8bGffLlSh7tUs6/GZqcGh5ytpio3yOdBCRgW7UyXkjIMS901L8SNYk9sOWUK5y1 GrYQ== X-Forwarded-Encrypted: i=1; AJvYcCWTw2M/MbqhjzWgRUeM38dSCmFMIqxky9ckegAEY5SGTI1sVSysS/jzGwhiwNXVBzq2/xIAPvqAy7z9Lr4T@vger.kernel.org X-Gm-Message-State: AOJu0YwpNrCztfPpThFKGi0PGzuxlUNZ2n6AModaehJqrju90GuFAOjO 6Di72hPjysI8A4klvPTWzggXW8ZDVhHNRBdKZhdxOqW4+BYpbH7m X-Gm-Gg: ASbGncvTO394l0S9B/rPHG3AsKqvzDfqeY3sTywwYi/oRK73VVmldGZw02YvYj/+ztf SVD4x8DSP/tEVy8hRn6r7MHhurzTgEOFUR94pujh+6bZKSyKIPhhZbtZCRrP4raCkgC0Hh36QNL Wonoa1K9Z1/Vsnwg5CqTSqSieYz11SF532QhghXosWMjgiMKoPufTCKlbS+6VlWJuNfBXf7ms4x Y5OMVSinOOKEnLs6cWwGVwMwQmN0rr0VxGyMIWRDktwD0wz03GoxhXszvyqqhRWRYmj8Dg4QLXi 3/UUVlMF X-Google-Smtp-Source: AGHT+IEKDVuGUGYiAVPP+n7Sl39AeW/UuPhZawAUzY4HgAIyS0DUcsOBeaTIssdYoxb4bV2dZ9+EOw== X-Received: by 2002:a05:690c:4b09:b0:6e3:2e50:8c0c with SMTP id 00721157ae682-6eee0a6fe4bmr162261607b3.41.1732572359209; Mon, 25 Nov 2024 14:05:59 -0800 (PST) Received: from localhost (fwdproxy-nha-008.fbsv.net. [2a03:2880:25ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eee00afb94sm19489707b3.130.2024.11.25.14.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:05:59 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 02/12] fuse: support large folios for retrieves Date: Mon, 25 Nov 2024 14:05:27 -0800 Message-ID: <20241125220537.3663725-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 4a09c41910d7..8d6418972fe5 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 Mon Nov 25 22:05:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885321 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 9F9C9190059 for ; Mon, 25 Nov 2024 22:06:01 +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=1732572363; cv=none; b=JW5uIep2UdgfcBGNWwY3Aoax4LD4IJujXqjZwG1dMG2CFTMXK8EBIInCMSkhS7b3zM1LZq0R2SGPEX8qElFOELGTMU5Li1wPyP5tZrvCbiicEAxqnPob6LPzNFixPu5dULc4V4DPdEFoN+n56XuyNZMkAlICr31IiuFrI0OpryU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572363; c=relaxed/simple; bh=+YeM8iIH5NcPdHeetGQIssou9QsdaFbvELU6yK5BWGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WCIz5fEcyZpezalgfTgR7Q+kTtqI7EzKUJY+I7eMF61qqC4gOKNtJwJy+bnfiG3oqgWD80aCwQ0/dTdXKkCOkYKXLiVyYNKUHSUoe8WlNOgs1haUH62ZWcOnYZJxy7kp01Zk3nGDzSksO7tLWcfaq0pR2nSmc5m1krXpJOcYzoA= 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=KCiZjRi4; 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="KCiZjRi4" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6ee55cfa88cso44401847b3.3 for ; Mon, 25 Nov 2024 14:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572360; x=1733177160; 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=hosLWJYYCE7hLbltZCDIBtow2n3th4dqtPi982FR+nk=; b=KCiZjRi4JARR35S7lTBK3VX59sjc8ro2zBCShZqmWG1Q0y+YZ7M7EID8G8v3mdq1xA yEjbdxHpry24LzQqXSX7uNjXkzZEm6LDMv1Q93PkbCzkX45GNu5DZ2Iw9GNqyhE6Hd16 iESydbspz8+rVKEjnR+o85NLR+34KrDC/FvKDghebyA6lWkBPHVZGdT7puTC46+o2Gqw Y4/ICmyzEIjjPbVOXDKAlsUxPDVHdAlzw7g4yTfNxRSZQ12USaxk8zelDKICcFhgz927 etp8p42RHfSZjXOYmAgqI0Xr0mku4WpWsIhL+He3PuNDxUHAxQEYhOAsXiJ234/NrkHa 2rxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572360; x=1733177160; 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=hosLWJYYCE7hLbltZCDIBtow2n3th4dqtPi982FR+nk=; b=GdIZ0111mh6/Mxhm/CnrPV/kqF5LgmTrw/Uv1sA2MCDzLCZLc7ljrRvYM1Vv2rQown t7pf0vqD3KJHTOV3k+1c29MfGXaAZcc6ESK8H9GjkZaSBZu8V4TgM4tPvERVK2xYCBqS r1TeTRrX/MWHUpaNO2GHGRUlXZ9rAxsvqSWmDqlKy3OwIzHXcUUGLbBTSB8UMqKfqhRp +Kvwg0PkKvhG7q7avBaR1CkMJIYAQf6k7689xmv/6mdWqlJ5QNuCLl61g81l0PfpNyGE ovnGvFqpm/pGuoGcRDXc6w1BG2DoWzU2AmzNs4HyDKwZw73OIBiMY2OVQYTb6nOlZa7b wHpw== X-Forwarded-Encrypted: i=1; AJvYcCWiLDA8DWjG8sOzkWFqN0I8qYQyA0Ky3jQOIO8nZp2T/GD9+HUF3Df8rnG4xZazTzjcFcciigYxqY23tXxI@vger.kernel.org X-Gm-Message-State: AOJu0YwnK2BiKZMNi1ts7ketBgpMOUe/Obg6UnBshmO6NYV3LWw7J0Le Em94Bwoh/R5SWC25i6gj4Bxuy33LhmW81OM2C7OdgaJ9BxKmiJ60 X-Gm-Gg: ASbGncsMFSCqu4A0KUBA9jN28+au46bYk5WbOob59T7Jsd146/l2XIUPSA431nyNG+f ytcuvAVnNlRo7juvZansRI3bhyZCBFW207u6w2FaAQyvNpBJ5yzMu3b8Ov1IokTllDSty/eKr36 2PSACxGAe5Q8FljfdEt3/9/F/5deazBnWzo+9iCTXabO/Co23ensQvTpaZbGhs+fr+Q1sjF2exZ sCnKMmKgDl5VydHV3efpmojq+BS/yiQaAFCLtWa9DddqzG8pSLBZxZqoEOD0PMQ8LnFT7ny+WZs Yroq+4HO X-Google-Smtp-Source: AGHT+IHK4flbJSWoODx+lb2nOyg3BAg3wd0lkm8mIIZbHsaGJPnf47SBc8jjq5p695qCVZJilK8mtQ== X-Received: by 2002:a05:690c:700a:b0:6e5:bf26:574 with SMTP id 00721157ae682-6eee0a49959mr141292297b3.27.1732572360447; Mon, 25 Nov 2024 14:06:00 -0800 (PST) Received: from localhost (fwdproxy-nha-013.fbsv.net. [2a03:2880:25ff:d::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eedfe15295sm19992027b3.18.2024.11.25.14.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:00 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 03/12] fuse: refactor fuse_fill_write_pages() Date: Mon, 25 Nov 2024 14:05:28 -0800 Message-ID: <20241125220537.3663725-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 f8719d8c56ca..a89fdc55a40b 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 Mon Nov 25 22:05:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885322 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B40CD1C3F36 for ; Mon, 25 Nov 2024 22:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572364; cv=none; b=VzfeTRXf9x/msgzhj5DVs6l1aguuU67UVX5ol3BcgUDD8uiMm6SgfkNUra+t6UhXXYln4VXbnZ3nlRfq0IgnO6MKg0YqQUjzWPIS+Y5hPgZjFEMQME5LvrVYEDXxDeMduw3DYF924i4CbOubDcqqywDnzPhUc7uhPyi6ZY2yg5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572364; c=relaxed/simple; bh=55qbSnrj4JkB2375Qk2GnwsuvJJj9SWJ5VUBMZ5acLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BKgUi2CIPBPu5Ynjqx56ntEStGncyfabuxFfWIGdSVOkzLNORbd1dQ77Gi/Kfh17l/bTQDvUobiSYTxWNTiJUADXov+Wiaeg4sxX7zLJoJy12CSD8aGjaL1ZRskPk30m9N9nMjbqFwX6J5Lo1pajXXbY9zlqeiZ8OAQDxzmv56c= 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=lenRvBsd; arc=none smtp.client-ip=209.85.128.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lenRvBsd" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6ef1921383bso11350477b3.3 for ; Mon, 25 Nov 2024 14:06:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572362; x=1733177162; 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=5X+/GBIJEUOwrM2hRDnk+nYnGxoZZRK51MgHbAmHqrs=; b=lenRvBsd+WgbFUxiRr0Ua0nxOzfW0/wvWmlvFzkWMdSmcA5O4gsCPUizOduyCAKuuK tdZPnLrp2AazYchdRHy5Pq4lM/ShQ9YsQwOGRlLsd9eXz0ADqrA4owff6RTUCRlWsH5i 8tEvyl0W6mBOcCPuWBr6SfP99J0Re68T5v5Qs/NX9kEz/GRxyb8/LkXMCyvxQtX4l+08 GglmxrzCV4Hln79eH7QO1plwEpnH4IirAXGSuvGm5Ok4i6GdOU+nNXKJmwzTjzJ3QB/y i8m3XvB3YVmT/6aYhgyhdWXYaBuCivPAQ3y6IwdvXpbL3tbH6W+IyhrQavE76QISbYhy A3Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572362; x=1733177162; 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=5X+/GBIJEUOwrM2hRDnk+nYnGxoZZRK51MgHbAmHqrs=; b=Vjo1FnpNJsWy2zhhlWGGMv4VFv/HMjR5N5XhlIbhjdkJbXNe9ofMI9oJho1bbbNpzC QzWKsJdO01bkhfPflEXbZsRRM/PbcalNDBgz8p2hmHbhuxuYpflb/HVR24k0lJqLw2eb KxpN/9sV/UQbgtEV9BNxjsGaA1/FADy/AW8tUH4YpQJQ1fGEDajz18PtZgP5yCsooFZy EbXsPYGIJOcJwjWvBUl8WsMQFJlCClwCtWGiL+ES+HQS3cIg/xklr4nGoDlhuAvy8Q5p 68krK+DO7dRoJ8+9SEgzeCSLIwUWJC9sR6AGSQ2TXTjUR5Ivu3HMBPx3FosDJ+4ypBUe zi/Q== X-Forwarded-Encrypted: i=1; AJvYcCWAofnkgFoaC6aDZhECaE4IJ/liO3MCc7jpPWxEaID0GqzYCSrcleowQuCHVdi6Ze7sJJ0eROkUyIzl5kr4@vger.kernel.org X-Gm-Message-State: AOJu0Ywi1P7ktNg0eNzHZOCbvNcW2EWPyt0aBqDuh5/6Ch3Jp74v7fTz HwCatHO+ywkxpipkuoJ1ZeJNRHhH0Rxinbj+dx21T4jrf7T4o5/3 X-Gm-Gg: ASbGncuxnHZHWdTCnDOOmudjsdlJgoyBtCaqDxBwXYJgZDUXTg/5HoOmZquJtoPxz29 WGCHhaAmvuOwGzjifXbCFsjkH1pyfTsTLUMHoNlLrzRz0SwurcolxHwdskHDDU4OhrGFXGTVpc2 NfvGV+xOZy3w9nZ58thCIWjQpT0L0MCM7gAq1pJ7X3IuMp3SHf8D8cY9OXcNsTM+l3WxfbkjqV8 BZ0l7uRDk33POYRugx2jAiVcMNLgPlt+D6O36kB+q3k2A8DqBxJ/OenDdpKgY5se3JHAp0Gb+QL 46RZA4U+Mw== X-Google-Smtp-Source: AGHT+IHse5uyxbDrUO7SoYD5ahNcValj2iv94zpJxk/7iX0uT5QxbNDnzYWqfhylHfTou0gNokTs1g== X-Received: by 2002:a05:690c:5a16:b0:6ee:8363:96ee with SMTP id 00721157ae682-6eee0a4ec91mr106596247b3.41.1732572361808; Mon, 25 Nov 2024 14:06:01 -0800 (PST) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eee009b85esm20023277b3.115.2024.11.25.14.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:01 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 04/12] fuse: support large folios for writethrough writes Date: Mon, 25 Nov 2024 14:05:29 -0800 Message-ID: <20241125220537.3663725-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 a89fdc55a40b..fab7cfa8700b 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 Mon Nov 25 22:05:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885323 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.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 2CDA9190059 for ; Mon, 25 Nov 2024 22:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572365; cv=none; b=PSpEshnlkX2ARKf3994d3avn+np1JdCe4iqlVQff85c8PhJ4s0ahr4ttvkqzZLsR5+3gIALIC7igOBnkL4mURAIfzt3irQMLzRBKmPcoYW2m/XlvpmdHSjGpymNtS/k18EzlBa+8YcWNHESJF46qA+26Orl4VIunlhVQUt4Abqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572365; c=relaxed/simple; bh=TlWx8pPe3VMieBiipZvUswFTK+zsLNBNts60fUq8aBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TsNxfuq76HnPrtB2hbCQUrcx+h0WfFv5BTSR4QcYYOUIIX7piOOp2DeWAoZquOX9YCsbzgRvdzmP7tVQhqv2xKuwwUl3v244SFv5L8XAeMUFXNXbu+nI/y8xT2zeHMdG/I7PJH526uF9Hs52Etes4G+SePJt5MyozpUiHiSE6eI= 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=WayxfO+E; arc=none smtp.client-ip=209.85.128.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="WayxfO+E" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-6eeafd42dd8so51759887b3.0 for ; Mon, 25 Nov 2024 14:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572363; x=1733177163; 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=tk6k1EjolX1nbz1/ZuRAGyGHURCB48ZYiPJbglQ4bAo=; b=WayxfO+EV7WuqCI43paeG1lx02ifSd58PiMNYfdhuvHOjBjrfa4Jf/QwzcnalmGE2E afR2jfdsBArr8hcMb+NI3QpmFedZ17XtgQOUYwgNv4eBAWvTSI7ftGUphXoGw0asgbYs jFnsQ1BKUndXGHuBb71+dspTi5jvRDzUreh4QMk+DUFby/RX3MjmEVwJgfAdsDvpbt9+ NtP22HzD8O/2Ah5gK4caj/+TJ3RZj9LgotVZktz3quIxXhd2gQPeKBlbOflGzDJsSb+v SGOhXw1WbQQbRfQ/TPwCfi0NZBnqf/IPfL8o7K8q0JNLh3JEofR3zrXXGBSfKDQs/0HQ FBcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572363; x=1733177163; 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=tk6k1EjolX1nbz1/ZuRAGyGHURCB48ZYiPJbglQ4bAo=; b=PGNiuNhdKibBDRZ9/DMR/T4bxgvo9ArQe1YI7Z8ESrgQWus0n20yEbJCRNnMsXEjF5 OLChwh3XBaCUqYaEjcnxsuTaSRn1MB6Xi1CSPs7I2r0sHWP98W9aElwzAV+mUVVCULNt TGcxpQ9kFez4QNQi0UklReA9n19rnPW9HJ8KiRoWUqWpkZbYBSXXK5e5QfSOlfTNrWoE Lc0OX+gFxSzZLwQyXFqui7FHTGDsuMBePwszc2J1FzyW24D5DKJc2MWWgWBGgkYAK5ZC uTYvbPwfBNNProxXUHdqnOiR8x6H+KxtsY5aVDj30ooQVv0EpAFWV8coss1ObppM6Unx X/UQ== X-Forwarded-Encrypted: i=1; AJvYcCVh2PFIDdpEK08uuW6glgCFjooiuAjoSTCVAPtPg9e6wccNQuqhYog78e/EsfSpU8wHr1jBqfqc06Z7AOHf@vger.kernel.org X-Gm-Message-State: AOJu0YxO27Y1O9HslKSZYRzYYFCkGJ1CoJk9OHu+7BjBlhBacG2UHwEt 5XvTQ/nS1NkhBoYrqNx/3qCJfL7UHHRbpj9Gm7ZKUWkVzXG5Nd1l4cVB6A== X-Gm-Gg: ASbGncvZ7ELbSsLWUGqkhsgQuvSVeIi7OmlvfblNxIbFVH1FUKpz0V0S9tzMKXWTgf/ RmszjosSX4u/wIJ89A+kXmRmtxhikmO1Cbzc8RegVxDQ1FLoDSAnqllabA41VUOLtEdhcovTb9W G/JOGLIiUlQPUcDa8XvL2MTn9MUMczg++6Dfb8GaWQU2w8OobSyODMqTCUSP1zBxAZkK7lHZWcU tiXv7+t1rl+PMA+N037kqk37lw4w4NR4H80x295Tvmq8vV83NDt6TzRub2aery3oshOqJ8XToWO tW+lvfzk X-Google-Smtp-Source: AGHT+IH2Vs5RxaOnGcYlODJfn7hsxU4DOG0twCtFjOFjnuBSu2ZCXQxZSbhayJORyLuEjWhDa5c/aw== X-Received: by 2002:a05:690c:6d0e:b0:6e3:29ae:a3a5 with SMTP id 00721157ae682-6eee0a491d9mr160329197b3.34.1732572363048; Mon, 25 Nov 2024 14:06:03 -0800 (PST) Received: from localhost (fwdproxy-nha-009.fbsv.net. [2a03:2880:25ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eee008042dsm20000207b3.80.2024.11.25.14.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:02 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 05/12] fuse: support large folios for folio reads Date: Mon, 25 Nov 2024 14:05:30 -0800 Message-ID: <20241125220537.3663725-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 fab7cfa8700b..b12b3cb96450 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 Mon Nov 25 22:05:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885324 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 614CD18F2D8 for ; Mon, 25 Nov 2024 22:06:05 +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=1732572366; cv=none; b=KNrVgt7bZmlYRw4GeDY8Zz2s1f+E8f8O4jEAs+WclJpTFnx0fEdHKZUs5cHqLhDUN72Qyhz4I4V3JIkIbMb1rH6TP4l9wMK/VLNYRmAqzwKz5M4Y4ACO4AbXQJpwN9deNy+gzdUdqrfq6195Ywni6FEPzQy9ClQEKeEzLKG1xPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572366; c=relaxed/simple; bh=bhqSvXPWxQPhzTCIRae/TCxlpI+rBab8NmnwLR6q1AU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O8z+Cxcp2q8DJo+PMQzVCNpN/aNkbG1DwaXmOjrD++6j1VeC1HvMiP5eYXzM7tL5/fDluae8t0IPIC/K8WIbJ2ZF5G0YqV3GXKLrWaF2sv4TKlC+2OIBhCNcxCnpYxEikz6v3t+Dd6+XWgS4zkwqWNbw3/5hFZGh6Io2qYsYxpU= 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=TJbFQXzj; 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="TJbFQXzj" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e2bd7d8aaf8so4661089276.3 for ; Mon, 25 Nov 2024 14:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572364; x=1733177164; 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=PwMzRvhCZM3dkWOAz2qoJr7DwJWBiqujZyVJZp2UJm8=; b=TJbFQXzjKLR+4f2j3XoOHtN8ETPtKvrV588srYJYg0mMnQrvo2q8hInFIJsK2Ve7VJ 2+ZYn+ddsIERcYuLEneyxuUuMctcV2V3ODFlwt5LpYquf21ngBNtPcDqa8GEJ9Bt+IYA WKQVjXBgw3EUwSBKH41y7FjvUm6hq8HkitjHSJ6PSYvS0Rpjtt4xS02O6Cmech2Wc1nc TX0VUKSNOP9QzxJFXQn7+fz1bhB9oBxfu9RtbY15Eeem+jaiN9/njzbhXG34Rpt0WdDT yeVBx4HK6WTKFYBDyzkopLg6hrkpBpmQOCXG7v4I313wT4IlxYSKS03mE9nyUsAugvv+ TZfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572364; x=1733177164; 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=PwMzRvhCZM3dkWOAz2qoJr7DwJWBiqujZyVJZp2UJm8=; b=HkxF4vTqG8xJGUXBGh7mC6M49FzGv3v+4hWFwMI24KPp0vXKDF8a7kZXHmdziGghjn YcB6RUyRWOsFkzKqXYHO66K1mzihZgZhaDOxMsMjtpnpJwLN7J3RnFuiPO26C2TR9ngn SCzAsT7LOoDylAs4HzN9d+J16ynyn/iIQV4MdvjziOJWzfxcavaA5nzeWWW99na+Ua8b plblwfYYNr77UgMAY1MsDG2USoxJy+m628e47mkbZl9kdD+uxhWZG6j+tfk1LcdBo1AP U1wUf3I42p3Inc7hgQ8q0bB0Foj/KhptPVs90yUG4uf3v++bSmgXnz2IFoZkIwe5wmIF 2KBg== X-Forwarded-Encrypted: i=1; AJvYcCU1DuV00g7Zk1ylesgOTeJzJIZzGQ3EkQoASy9oYcI7YYMU+D6d79CNnhCoF61TWG58V14H35f1qKY/7ztf@vger.kernel.org X-Gm-Message-State: AOJu0YyGt2EF2O24sdrpFBZbF2smmzf/93dTKP23a6j2YC7mprPrr42F aBCER97aX3v+JFHbFORbLe+eb7S9KsO+UIZdQEIaqJwzqTywgDcK X-Gm-Gg: ASbGncs05Q207AhjS9u9Lw+VqqnhTWUpnux8csQtPWL5+Jz151OBHevFOSMBMhR6TwW fFchD366aVduCjAU9uWiFkcJvGNIzymCh1CTLpe3TmzVTRm5Kx7PBjQlps1y0UKSj0EyUnhpZMm SRGUIFZjhyWD6Xltdz1fUryIzN4266NkxFjSL4YB7yAS1PXCMX+1KHZNNHGjrxQURZ10v6Q41FG HqO9ekwjQEuiJhIV+3dwY/3qQvlYH+saKSUvm7sMuJC3r68B+aMT52bLcLw3otGP3Zz2LMRG69q vXRn9ZNb X-Google-Smtp-Source: AGHT+IH08CtbO+qNwNsJy8cpzah8zzDgaS2tS234vz+MeXeHq0A5xz/UGN0OdArgfdZmJ+mQEX6WQA== X-Received: by 2002:a05:6902:2c08:b0:e33:2e:eac1 with SMTP id 3f1490d57ef6-e38f8b5a38fmr8261255276.30.1732572364323; Mon, 25 Nov 2024 14:06:04 -0800 (PST) Received: from localhost (fwdproxy-nha-012.fbsv.net. [2a03:2880:25ff:c::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e38f604b594sm2743666276.18.2024.11.25.14.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:04 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 06/12] fuse: support large folios for symlinks Date: Mon, 25 Nov 2024 14:05:31 -0800 Message-ID: <20241125220537.3663725-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 b8a4608e31af..37c1e194909b 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1585,10 +1585,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, @@ -1643,7 +1643,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; @@ -2231,7 +2231,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 Mon Nov 25 22:05:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885325 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 7C33E1CCEDB for ; Mon, 25 Nov 2024 22:06:06 +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=1732572368; cv=none; b=hdEi8p5GjUzqDsTyJCIJpAId1eYOBhTTwNK/kj78F79pGyIWU/nkwT3WeKFaQVbxAHpCAiXDx2qju2i8rlsCw3RhnTbkqgLJLVAdMZ5ThCAJ/pFhrpjDoqueZErfRo2De8/hhC2crWy+VHJqTaEorIKq/NVxw2kBE+OZjVOa4+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572368; c=relaxed/simple; bh=SVDywT/j47e6gthHPLPPIN8NX1ME+LUIo1K0oGoKyeU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hjn8bN6F33TAEnnrtrYbAPH8EZzDSapCQgouNVNBD5p8FTu4ih5v/uIDIYJvcVJEpFYo7JDPw53ienSe7aojxAFjEFcL8Hdufz1yyOqn4FQX4bmgQDKOBorrr/l1jZ+CsgS4vc6WIrm/2YxYDIZPe18oFkP6hoPlFGZxFnWDFpw= 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=Axy66u5h; 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="Axy66u5h" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e3839177651so3975473276.3 for ; Mon, 25 Nov 2024 14:06:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572365; x=1733177165; 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=dxPIDlHDK7HE4w3vT3kctEuNkH7jrQTEdOwBsbFisTU=; b=Axy66u5hayEQ6PWh2vdZg/1bvQf7duojGuozZtKBvW8UDiQ0TlnTr3Ttbz3LaD2lU9 djHKK7rByNe4olOeIoP8B5zVwlesgq6BY7T/BJxtKQHA+c5eSK5Y3zbyoBLfy0qQnL2F V1Q9h8WMW1srU8OTTfOlQ3tQ+AJ4ujC81lAT2It5xUSOdk4mD0TkVbNWY4fLyR5S7y+E tLCsIyzuL7ie59m27WsomeAqMseoLpXJhkKjEOxX/DpiIcDDZxzaFzaWn5kPx9m/5h05 rveIiISbgwo3afSJwoh08oZewmnirkKHW0PFJuJ72Ko5NgWFTB/3uRYfkc7Ee2rhmjrL RzVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572365; x=1733177165; 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=dxPIDlHDK7HE4w3vT3kctEuNkH7jrQTEdOwBsbFisTU=; b=djLMqh63KbACzvFUgQ/kkuM8IBkhy9/sv/VRnIKT9AfGmSbJeo+cC4f2mvET2Bz+9I k+ZpFLdxDs01JbMn00iB4eK7UcISss+dAkXxO3+qVSZp3oNfePwsyFoWxXJSUaGPiboy 97+Re8QOTxCCWrZE7EGb3SXxjPeWF8kNECmU80zA4txIX6W03cxN4ckIRkzIteTao6y4 FQ77WCCdMy3o9U62JIj09KlNGZnuBS1WJ9CvpYsw5EW6S76P7Yk9+87GlPgjqaD1Lr9Y UiEKwuaI0iSOnIN36HyrXdOrWzMtCFEHqx0oEzUUWi30gYN4/izbRfMP8xmaG7D//DDS FPEg== X-Forwarded-Encrypted: i=1; AJvYcCU6X3uH0LEKv+5ZfwEjHcoT+nhJFrhdWRETq0PLXeQda/Q8I5pfLO0gtCahYFBzWf89wRVkH57F0Z/uXe4u@vger.kernel.org X-Gm-Message-State: AOJu0YzKdOmrdopAhb/PKulCjgUAipmg3kyUgNCE+M4RHE6ADyQAqcPl CCNQhBZFFrFsbNi+96F2Jf4aPsEUKyI4vAGiLtx5B4+HFGVfrZPL X-Gm-Gg: ASbGncsvyYWFmC3AnBaCYaUiWd5uFW1FuGCTKc2wPnGUQcheODMeuleaU0EOJzdDXxo b/JsxOq69X5Ljbb229Q9WVva9VajjodD/LlpMtCCrWAzffIFo6RxL3Dq14gqfcF20SSN4HE47e0 g/hrW4x3UNSukvpPraEL4Rf0FRDlt+KOTNEiul1Rb1aTciTIJNFtEEb2+LRzuIrdEMFWMv9wqF2 7Aa4OT0ajLs+N20s7XHk/B2Vpg6RRuymQaBnuMYJG7jb0Y9T6jWsABNSPXaIYBaTuKjn78mj9Q/ 6S5HLP7UGA== X-Google-Smtp-Source: AGHT+IGsxzMBbTEX+jLvUsV+cXeEgwSPAMxKVTRgs3m0bUuelH5gc1YbIbEECHplZ8a+NsPBfqWI8g== X-Received: by 2002:a05:6902:2402:b0:e38:8a7d:d292 with SMTP id 3f1490d57ef6-e38f8c079f5mr11679999276.50.1732572365544; Mon, 25 Nov 2024 14:06:05 -0800 (PST) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e38f601b9a5sm2684307276.2.2024.11.25.14.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:05 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 07/12] fuse: support large folios for stores Date: Mon, 25 Nov 2024 14:05:32 -0800 Message-ID: <20241125220537.3663725-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 8d6418972fe5..bbb8a8a3cf8b 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 Mon Nov 25 22:05:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885326 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 C7B0E1CDA2E for ; Mon, 25 Nov 2024 22:06:07 +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=1732572370; cv=none; b=gbvLD0wTA0/BTr2zglckxY52KMad2ev2mbLNt6wRn17ezmn2+0f0GW9tJcJndR9+G1l0j+vw11U6VSQkEyh5p3ZtHsvkVGK6/Ww7CQI8UKxtegdl204FHRwFY5se1LT3l7fHVORqS3lF93lkyZiL+/NAVmDT3k1WxJYR9bWI25k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572370; c=relaxed/simple; bh=8ytq8AOm7aoQB4MLaaPubElK8U/fCzNiMimPIgt84v4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PtECkx05GGg19WcS+YNN7yLL+AjaO9/sLj42P677YMnfguFXdyWq0uDxos4ApRgZv7jTxzqrXNICiu8JVbHP21R22smCgw0VkDQnTSGQT6BYub7DUAlXbAqFxxiK/eRoJwrRZb4DjD/GyLg7zRjgursJ9iRWQpaDqfspzbXFfCU= 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=PG9CXEgM; 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="PG9CXEgM" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e388e1fd582so4972928276.2 for ; Mon, 25 Nov 2024 14:06:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572367; x=1733177167; 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=75koXwbdSoG3gCLmkutCS3FJrNxaCzCuH3eaPPnbUw8=; b=PG9CXEgMhnDtWhOwK3exl8L+Gu7mthLRDraKZetgtZlxT1Q4UqYrQXqyWHIMphQmS1 J5PjZuBpxRXzHbdkuKEjfnO0orxB6u/RX4iAV9jYgT5fgUYvMHgKbyGAKKgtsbIAY4A+ bDytmCe1QKkDBmOI59oYRLSGLXHQorYsMibnTBV0vjNzIL3D+70zU3SkiN+V+n3bSwNH XwDxtLSsZIqw7SYVVJ9EEVlfKU07rwft9pjrxl9Kdx3Df9+GYbunO+U+pTLre4dxBsLY CN8XSYOTpKRTJmJfY3LNnTOrDtDM/Zd2Qu+lQmfJEliw+QtpabJXfAtT2C/deUEK1SWG u25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572367; x=1733177167; 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=75koXwbdSoG3gCLmkutCS3FJrNxaCzCuH3eaPPnbUw8=; b=M2x//4ZzineXJ/JslIPkgU85DYH7p8JcNKztrmVTjNsZHURiHYHq+ghE30MT6sKI9Y XCNrqx01YJb1hPHKfiOuJCcn8OFu1Hsiz/meORHEPvqvyTlnNy7Ij0XpTyLMWJCwHrba +wsyVY5PiztInFljNM/mzRLG1YsigoJruuSY77lPGQB+7yArTCofeDi/6MmSoP+7oqfZ Ur4qvmBdYCNwS9pJ92zfceqAd6DwIvFB9++zvsC0m+bSfh4d0MWYUYYax8baxWZdM8rO UVmyewoNmI45+fBGOjyvnPUOfUmDsd4EnKmpji1lbWrQ/YWTj/tXhHIXEJCXSqzf1qyV RlRg== X-Forwarded-Encrypted: i=1; AJvYcCXaUsFmyLd8rJWAaezptdq6r7mkexNMXIMO9E3sQVKBgw5lWuHSKKriwQg2wgq81Oxto3XM5YnMp0b6Exed@vger.kernel.org X-Gm-Message-State: AOJu0Yxec0WoImU3LJ5CXlW9bDRbD37gAE+GdP850EPkx94SRV5cqjl5 pNWK+BpwFok4Qo35dVDFpsB/lzshrXzU4GwXjmzgjKxwXCeou98i X-Gm-Gg: ASbGncspzpMZevwT+h+7NyPV/IE6b5BN3M48kRUvZkzQQkcAfEXo2SqQu0kISVZTJVu csIxt1QEygXT7HlJRDVWEeee/0H9lDzkauWl7+RHQLCtQazK7+cIIsylWGafZFMLNozVwRO5HFa C3Qj1l5voOzfKuJRBs6VcKpW2HznubyE/YRqusn4AaTMWauMBZzxcZwH7etVIjGW+TiA2zKytS3 MSmyVnKxuiw68pBddMmqR8Iph7mX7nwW5x+DgpLi6mjPT+NpYh0eWspYqvhgvMRR9kwE36R+BP+ 40yKZajz X-Google-Smtp-Source: AGHT+IFqZUiniyw3XUwSQmwh/7z8hBU9vw5M3kTr2NvNzt9UOfH1Vvu0a6vqj9PZ956uCILRFpTgNQ== X-Received: by 2002:a05:6902:1b81:b0:e30:c78e:33c8 with SMTP id 3f1490d57ef6-e38f8c07a00mr12658751276.45.1732572366800; Mon, 25 Nov 2024 14:06:06 -0800 (PST) Received: from localhost (fwdproxy-nha-014.fbsv.net. [2a03:2880:25ff:e::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e38f604d36bsm2625306276.22.2024.11.25.14.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:06 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 08/12] fuse: support large folios for queued writes Date: Mon, 25 Nov 2024 14:05:33 -0800 Message-ID: <20241125220537.3663725-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 b12b3cb96450..1cf11ba556f9 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1791,11 +1791,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 Mon Nov 25 22:05:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885327 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F38BA1CDA3F for ; Mon, 25 Nov 2024 22:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572370; cv=none; b=JlkUIDiP3Ss2lvGAxT0q9e+lIL4bJTsA2S8EP7+V94FxA+oWY1+fDQISX7VJHGGEuU9+/j31Xyh5jc4eOcAEOLLo8KmIxqQ9J94oClaWzRGNdNr4+WAWlPXZEzzwOflsCH21EBbL4w8eQK5n2XkVa9WZHPCKuw/Mb+FcgqrGSpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572370; c=relaxed/simple; bh=pRMK5jPBmYa5dAxCjuvMrBsm6qEiOBch9n/UO+swXGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HjAPPiDJrjqpw1XlDyTa56vLl9AX6uZAo29Bhp2rne9sljm5iN/jQG8yeTllfzVkEs7BDVeL7n5wAw5NixFZJt1qkwuoeBsy/9oqo9UdLoTL1eNqKNK/9+u4xwbf5zS/2mDB2/kZm29Bmsvanpef7s0g0G/Dx+UlLdnDUPEO48U= 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=f9vzX3mC; arc=none smtp.client-ip=209.85.128.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f9vzX3mC" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6ef15421050so14131077b3.2 for ; Mon, 25 Nov 2024 14:06:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572368; x=1733177168; 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=BR4fVVGwclW4cNNwREOlT33PH/34vfDJNkSzGDsQ5QM=; b=f9vzX3mCnGRbnvz9AmI0lshENX3AWQfNkDBA628UaSQ+WgaejZTVGqySC7e/YeE2tR vQ6fgh/MOLzPGUVLYg8TsWgBMjfX6ZA41aFkYsM6YD6pnnvwcHo6ENkVyEc3yCjpdaoh 66kcs93ZhEDKSxktDsmeIoNap0yY4hGAP5ZT61uL8B74wei6Js5mLJ6wmPbVvbxzY7/U k6SimjfoFCMuJyd1Fp8ashLnQXmN1dQTGEdI1T/dnRtEu9qc/RgXyIaVX/kSNkXc9DF7 0AhLmyB4EBQ4sBabtaEpiLe1HVixOAc6yOdY9m7FnIa0Hvziyoh0e2ViZvxnwhkifLia aRLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572368; x=1733177168; 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=BR4fVVGwclW4cNNwREOlT33PH/34vfDJNkSzGDsQ5QM=; b=G3EvzjXgB1KGxve+1e5cALShZpuBDjRi2vlH272CIzWViToIRiE/gA50BOYsSZxGoX sDKn83hVjD0Q8unIhgFVVTuBdTLLSD60jLzMZ5PX92c+m7tEThxES7P+kwhR/23zFphN 8DJ5tV4O1lQ+/2cCaJNLEOkVdKVXREb6gT1pOdHsJjXGJpI2b0eBoLJYf7YDMwDrqbz/ 22v91JkqG/J7/X76woptEOXqC6oZIQvOgioR6x4lQvLjkXoViqsMD13/6kpUxuB5DJSm f12anhCBTbg2DyqGns+tbmqAWddZn6kyAybaMkg+WeXP5wpNnuO2q6/ik4AsQCUbmtFv tVHg== X-Forwarded-Encrypted: i=1; AJvYcCXvRMMobvRrz6ZK+OxVsmzbqA+adPCuvXKZm/t+DB0z6l9L0jwdNekwzPz0I+Z56mgXupNW1o6ZML4JeCWy@vger.kernel.org X-Gm-Message-State: AOJu0Yw5xqGAYTukQRhcyT7c3aQsYu0coUzf7DxZP01BfLYD9yMZdDmM OgVYBoxP5M0o2Y4j7DcLa9Cx+M6/RfAgozacXhho75NvhWjkUAppc3nmyw== X-Gm-Gg: ASbGnctzdrbOsz1cWkfGcVD2g/uPt9FiGiLhwMjinqtmXU8LVbraBWdS3LeqT8xOTTF 5HAv4faaHJEBLCJoPLEP7LwwXqj3IvvgCWw7Rf6jOGwshRHqWGwORgujsyzYpmG/TZ5tdQiD5IV UPsm9gAMY+lGH9ckJKzX9BKD9Gt5TXAOx+OZTzIEQuN0dp4aJRKYa9/gXy7VELaIQP4+T5KKLzb NCc0oKWdNgFau63S6z3dSUsdviV4iBLWJyAQeYGgusdS1+nnxxBe5h/utchCJ6wGuTOwKjQ/197 3Gz9gluNbg== X-Google-Smtp-Source: AGHT+IGl7Ps0PAWQSveraSUUcTdip6uhB7v6JqVrbdeML/8QsSCUxYUCWFaFmi4BHLTKL9hIZlZ8aA== X-Received: by 2002:a05:690c:2506:b0:6be:523:af4d with SMTP id 00721157ae682-6eee08c2b80mr137071507b3.11.1732572367983; Mon, 25 Nov 2024 14:06:07 -0800 (PST) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eedfe480dcsm19912457b3.60.2024.11.25.14.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:07 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 09/12] fuse: support large folios for readahead Date: Mon, 25 Nov 2024 14:05:34 -0800 Message-ID: <20241125220537.3663725-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 1cf11ba556f9..590a3f2fa310 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 Mon Nov 25 22:05:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885328 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 F05931C8FA8 for ; Mon, 25 Nov 2024 22:06:09 +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=1732572371; cv=none; b=Q88vMUVkiMnPoZIQPj43sNFZDOXQXPr9xq0DEO1WWjOBeQVAmNn7KkNg72gn2rKRiOP7IIjae1z0D4koYYLv2nsNQqyGAirdG6lVht8U4NHBl9awt4NOCRWr+MVWRLHKvEz9y6SZJRUDQnrHU5/NqA8FAwLBPI9Ru7dBlD+tZcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572371; c=relaxed/simple; bh=+xbPSGby03WtiL3HlRFTnPezCXKa60W2op1hYxJUo/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fUMSrN+bc53BgRYBjpHTmbBnXdLjBh0ug+28SbySEoKit4g6muEIM9YVbuokDnxkZyGaQ2kb/TUZy/V/Sv41CD9TGv2XmvkAx0fefN3kUiBQg2kOq+qg7RLZCYturcHCdqxCBMFkHaCnQlKV2Q3doxozW5FB1Fuqg1accIWmqnE= 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=mMU5MC08; 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="mMU5MC08" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6eeb66727e7so48354617b3.2 for ; Mon, 25 Nov 2024 14:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572369; x=1733177169; 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=oNQ9FkwB67Ctz/Hj06wigDjs85MxWSsQ2VipnP/l41Q=; b=mMU5MC08dR1A/lMibw7DtIiDAGdhGR8Z+HIyNUlVyiMKFHg+QgCwoWkMEUflAVdwI6 3sKxSUw20ny2MDH4MQD4HXUjU5kyCkAl+cflOmlGFV2w5LT3QuRrNU9AvQlnYYKy4aSw DaII/LG+q7/U6GX5PP2qb17oYEuqHR3IgLFi8WCEvUtHqjJd4J788o1pHwA5YgmV6g2/ vFvHlllcO2VLvngSVCLIQtXk65t3IF0TFCrYUeln2v7In1MpoBEZCnKI8yIgb5KcVeQr QccFbOjFfcprViQPJ7xrpUpnlWuFu+QBcA3DWLXRgnvpVmKoKWprw31nBr+gBu/tqDMy soww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572369; x=1733177169; 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=oNQ9FkwB67Ctz/Hj06wigDjs85MxWSsQ2VipnP/l41Q=; b=X2N1lwXVJrmh+Bsuh6KBoklvtsF4CvPm2IP9zjVlEqrCX1c9eMT7n0o1Y8nSFCcOC4 +jIfjwuwEgyHXwMW1Kdfql8V6tfI/PRDqjkwkpUGs/hEokfmjJyt+IjA7da4+PORXlz0 YaL9y9Z8Tze7xvYA63dbG8jXmc1ssW0hb+7LyQ+uGAwww93EexNUOg2zM5Bc5emGhY2Q HVIJE/vEt8+MSSGSbNTru4OPCGhHU5DY+HTa1klg9x9EiS0E6y8r+m6auRz31dg8aJCF adtHSsjpCD+ba0xC0g9fSLMV51Wk5dp5fWExtVSrrYMdikLNayy1Maj4URSOX3348A7q pL6Q== X-Forwarded-Encrypted: i=1; AJvYcCXLg6lCr0hivBmcuNSMQhV3YpO+tU5lb800Dv/v0j3N/OawqTVpe91i4dg1ZCZcFMjJe5tizdRJ51yurd1E@vger.kernel.org X-Gm-Message-State: AOJu0YziffwJfY4s/YEQk15TMMCIZO6Yjya1VjQfF96PM1IDzh1r9IE0 Ov3qXiMXkQ2UZdsYD3v4pAPwicPC6CjUYJ8SjkQPho8G/omn2fMdbjfTLw== X-Gm-Gg: ASbGncv0wKJTbva6sQSJcIiuzg03VLvOPRYiF6s7b43GQ6xGaI9w+OxtA4i141zNvWe pYHEtJPnpjm8428ARymJyq7cx9G42Ngv3tLl/uYDa5tUs5aSiqzHL1C3I2l5yoZspfVqLEcuPnk gQf60hWX0Kkci+4Rg6BqC97nE6y1l6HqZVFShlblXU7duTJEp6OUdxRzFxsh8MBcAYysmuA3DFG jMKkmcWQSs+K95QjJnBuy8ZIIii94srdY17aXpfoiSrZERusFt4ApRWJZRyC3yh/FUVgFWT/n0b uwb6YAMA X-Google-Smtp-Source: AGHT+IHak7g+Fg+SX/RMWyegnQirebba96cEiah6ddfK/GA4qibQUBA6FH2OkabjKiXJiTO7GzIHHw== X-Received: by 2002:a05:690c:7085:b0:6ea:8a73:c0b with SMTP id 00721157ae682-6eee08a9ae9mr142944117b3.7.1732572369177; Mon, 25 Nov 2024 14:06:09 -0800 (PST) Received: from localhost (fwdproxy-nha-012.fbsv.net. [2a03:2880:25ff:c::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eee00800e1sm20138377b3.83.2024.11.25.14.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:09 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 10/12] fuse: support large folios for direct io Date: Mon, 25 Nov 2024 14:05:35 -0800 Message-ID: <20241125220537.3663725-11-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 direct io. Signed-off-by: Joanne Koong Reviewed-by: Josef Bacik --- fs/fuse/file.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 590a3f2fa310..a907848f387a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1482,7 +1482,8 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, return -ENOMEM; while (nbytes < *nbytesp && nr_pages < max_pages) { - unsigned nfolios, i; + unsigned npages; + unsigned i = 0; size_t start; ret = iov_iter_extract_pages(ii, &pages, @@ -1494,19 +1495,28 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, nbytes += ret; - ret += start; - /* Currently, all folios in FUSE are one page */ - nfolios = DIV_ROUND_UP(ret, PAGE_SIZE); + npages = DIV_ROUND_UP(ret + start, PAGE_SIZE); - ap->descs[ap->num_folios].offset = start; - fuse_folio_descs_length_init(ap->descs, ap->num_folios, nfolios); - for (i = 0; i < nfolios; i++) - ap->folios[i + ap->num_folios] = page_folio(pages[i]); + while (ret && i < npages) { + struct folio *folio; + unsigned int folio_offset; + unsigned int len; - ap->num_folios += nfolios; - ap->descs[ap->num_folios - 1].length -= - (PAGE_SIZE - ret) & (PAGE_SIZE - 1); - nr_pages += nfolios; + folio = page_folio(pages[i]); + folio_offset = ((size_t)folio_page_idx(folio, pages[i]) << + PAGE_SHIFT) + start; + len = min_t(ssize_t, ret, folio_size(folio) - folio_offset); + + ap->folios[ap->num_folios] = folio; + ap->descs[ap->num_folios].offset = folio_offset; + ap->descs[ap->num_folios].length = len; + ap->num_folios++; + + ret -= len; + i += DIV_ROUND_UP(start + len, PAGE_SIZE); + start = 0; + } + nr_pages += npages; } kfree(pages); From patchwork Mon Nov 25 22:05:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885329 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 5D3AA1CDA2E for ; Mon, 25 Nov 2024 22:06: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=1732572372; cv=none; b=Le7qNiZZrVnvFrfBg2VKi7Nduv78G/seZ2O9giw40WnVvNVvOC/IeAIpMWTgukGznVwXZ5MGuV9D6XUOMJsr2PqrkQN1rkzXfEF+KCyREX1tB9cXrP3tG8HFMFtrm/LIQgd5RaYMggxSURIG5iuf5iXk4lyjh6YjQFd0lgoUaP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572372; c=relaxed/simple; bh=uGadmU71ezOXX+APshoRWLPoSpUb4f78MrogvK1o5q4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ggKMizF1/HPXEIR/JuR/sadm2XSrYal0b2WywJQFhfQrEN3SPczFj6nsXB0qdonm84vOWagMnMMo3jE8SGEoPlvNfhP7zsI0lHb+yze/0swOL1a/DK4D8+0x6b2eLMlWhzy2jz4PQQKc5lBmfi/HhuvVUMfw/yIaJIYG2kDWHeY= 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=WL/Ne2y5; 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="WL/Ne2y5" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e387e50d98eso3956909276.2 for ; Mon, 25 Nov 2024 14:06:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572370; x=1733177170; 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=VfCSBpznMAK6j3q01cs9xGyQFYsoUP8X0DJraJrblDQ=; b=WL/Ne2y5c6KcjMYE+UEaVv5yKylUf0xxYezdbmbM/HoNdX4aEEHqb9BZvm9XMuMV4J +jxX47t5kmTnHEhhqoeYYf9wOdNXBwmWYLIqEaRwFoAoeY/RsMPX+MilJthPArc4SSfO Ck+2Nwlzd23Q+Wxm98uAGglAKyUUkjmQndEPp3pvbKFu1vTFc8+sSfV/lASytB9rtt5D s+D4bROvC4HdydFieRVJZqhRykd4rlvN9ZoXsV4Dq2NjT51YgJEO3SDtgALqUBeng7hy 9/hW0QxFmDrowOx+w2gXTR4Lb3H4Q/QnnryQXYd5QTfP+9LmM4faMwFV4J3lEFeYQBat Y4oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572370; x=1733177170; 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=VfCSBpznMAK6j3q01cs9xGyQFYsoUP8X0DJraJrblDQ=; b=gcZd3rAfPRQa8vHWIymUkzLKA0FSknM4cyNsOBum2q6/zR5wQV6l+mbSn0sUcAODDx XUnGRKgl73NJbNmR4oRFBtwAU0wadbPPSK1MXuFoHEPxLWUCZdvAWfOfUbV9tTmJmVHf umqTQW5JjTZVH1jcIkwj/8sRFyAMNHC2NmXopvjqZcfT/xZgONRX7bhPlDsyETCdGfHZ w8LDO630H/TOuFUWD9MGhIX9laS95JPDDMmWxlmJWGFmI4R/A2wEmNwqnBMDBtRwOw4h 6k4Qg4xqEqng/XAzJVMnqvTnLCTEWjjpmPhwWXVyVh2Unqg32xL/gqZAR9OoIwMCFObe XvLg== X-Forwarded-Encrypted: i=1; AJvYcCX3Ila3yHfDXOLhQY00olk6cQ2n3DHUEn6YKYa4GlspI0SUcRAYjdsmbDJQ8Q5IsuqkI3jzFzVhBC1VyBmT@vger.kernel.org X-Gm-Message-State: AOJu0YzNIOfnGM30NgEe/teh5P1uDjd/6cS5MZcWBQfGzvpvkkbUckoG kK6AZGM8mkEyzx6nSJU/+DYCagLkh5WqjyQK/T0PTpbD8VlvN/H6 X-Gm-Gg: ASbGncvFPxS+1MEQ8gPxHombi2AWO3wx8c5df73SCJwVPo/3uq9l/FkUyWpp+Lkyvmp MEsMxBNTEcBRz8cwL/OiI71izB56poDhiDRQVE8uZyAMCE8T0lCLvbzXZB9xD+IUQ9TAsNbTBJ4 BRAB53qKVIvsRS9BGuazD8aplaKixOUI2n42zPwuZAfeUj6WwAmSy0wHDXnaBHmfjRgbKX9sC0m tyk4DIFMSs16QhXgjDGleRwnp7vLHgapyLSKaLC8Lit63KbD6SrO21k8njeJvuKeVH/sYLpfK22 KI0Zo1Cb3w== X-Google-Smtp-Source: AGHT+IHEo4v/VvOi5+q1aAXzccXZ6KBYOTvYzUQpRzVQ1at4dxUs0M4yo9vThAt839+iVlDBbg5FQQ== X-Received: by 2002:a05:6902:140f:b0:e38:a15d:409d with SMTP id 3f1490d57ef6-e38f8b0b7bbmr14295959276.13.1732572370385; Mon, 25 Nov 2024 14:06:10 -0800 (PST) Received: from localhost (fwdproxy-nha-116.fbsv.net. [2a03:2880:25ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e38f604b594sm2743707276.18.2024.11.25.14.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:10 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 11/12] fuse: support large folios for writeback Date: Mon, 25 Nov 2024 14:05:36 -0800 Message-ID: <20241125220537.3663725-12-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 a907848f387a..487e68b59e1a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1991,7 +1991,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); @@ -2066,6 +2066,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) @@ -2113,15 +2114,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? */ @@ -2152,6 +2153,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) { @@ -2166,6 +2168,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++; @@ -2196,6 +2199,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 Mon Nov 25 22:05:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13885330 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91A5A1CEAB4 for ; Mon, 25 Nov 2024 22:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572375; cv=none; b=l5iWLd5sEOmrOCThWhy9Oe0KO/yRVqc0OOzETSU2RPjpNbvLY9AkzZAppREbeLKb2dBFBU7PeLjEkLpDP5ebzqcHTBKyiyg88TmHzo4SOc8NJvfbZNhFcdHRKrx9ffdYe1sWoAp3dPIivJMUGlLS7fWy0d3kJzc2LGTMylmt5L8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732572375; c=relaxed/simple; bh=mU2yOWacqm4aochUABwzvevW+gPKN7vO7SaINU3bDQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lMENw7UcIEHG0tE7TuVSJPsTfKa4wHVaoc7LNf5p92L7h+JuEpuk7xo5lCdW4Txu5pFIlkSRomHf14pp+Llp1ibkcXyB/75+WiT82JuBg0if9ZGtCNYiSAsMq/fRegK2fKd+UJq1fKGl7RjD2txVEs7ZlJXMGBl7ZgMcJ/xmayU= 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=f7giM3nf; arc=none smtp.client-ip=209.85.219.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f7giM3nf" Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e0875f1e9edso4090216276.1 for ; Mon, 25 Nov 2024 14:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732572372; x=1733177172; 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=h3flqs/1oGaqZeRwYKdCfmq0tSLx0cLwL6PDx3Ge2z4=; b=f7giM3nfkUE77skYUxU/Hxsit2oFw8rCSpPvzXH3pdVm/xT0W6H64ZAlCFv2Dk6aXu s1cVOb6Ep7DbIDK6caCNgBqYlj9WlNQuChMwX/+WnvpcmA2dkLjJUTEFKjgD9dBGswx1 pNbGevKwvu6EdqXxJFV4cpEGEGfbQUr7vMGc150qTBFR/wq7p4SfvDFQRSqYYHSqV8B2 iRWiGLRMtLO/0abGYIzXDu5If5N45gw4u+ii2656mf1Eael0EvLBzZ4ovZQa3PH0zcyZ Y54rRqKPnP08uGDTGTbI8hvtVWSisrZyfAs9WuQ5EjbB0+bi99Kt8k1lubMjXguIsHS8 U4IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732572372; x=1733177172; 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=h3flqs/1oGaqZeRwYKdCfmq0tSLx0cLwL6PDx3Ge2z4=; b=Dp6j85MX3/6bX78RSF/E1SI3BPHvEPqgeRYqL3Cjy9wWPWswAjQe+W+q6of1+jHiYk C8wxjteNx29bpxFIsDlJ4Vqb3olwlJgWhVdZcPHNRkTeSHtxS2aiEQABK/+ZQfsHqhMI 4o4LisF4PCg+MhwyvJMmsRcR8TQQOnD6GnMrVN9/j2jBZ8LccRpHkTKhIc4Q/sgOqRLk op3jy7K9vvV4vYydgVt49eTnUcqkmRbkLTwZz4PAphV8vnIT52kkdH5LR3HYHbFQdUhF EhYLxl0fQF2UwiUPbgMez8rpgSdvnYLC6pPvD11N/iNVGLC7LQ2H0Jtzzgt37lf8psNX FNrQ== X-Forwarded-Encrypted: i=1; AJvYcCUKYh++IdxcYkEsxZd0+oj/jY7rTX0lG9R3MdqFvdftmvnmpRhxTB5WPSnHO+ImUV9/gXo12bc73hyDs4zW@vger.kernel.org X-Gm-Message-State: AOJu0YxH4jnsYZmnfWi1rFLL6hyWMVDAXg6rIJrNCTlX1NwB2rfVLR0r HQjlwwglAIGdeEljHTpSdTLzaBtcQX7k9+3aHDeXqud+34oTCwZj X-Gm-Gg: ASbGncsuNv23bbzI5TIpcmEvB9L4prLX9ydsG0gCHajU2F9pQ4XAxARyr27ER4Af4EO loczjZjlrtC4p0ypySAmX1cNIZpi51Q98zCFLwpNniJW2qGZ7SnF9wNP2W3jQ8mYTd3RwHYITWP DryHXCcg+7gac63FSN4cHE59ShGt4vEYTEdhEfplCpMzNTCtEEVU1p5y67GPoWpzS21jX7DHlIs q16cjK4yJCR/QK39KD/zSL5KWHsfbVy8ZYhRjrdU5k4PW5jiIM8t1OVHK76iVlkYAyqAuMHLb34 SDqqof1pxw== X-Google-Smtp-Source: AGHT+IF1b59dEmsjXTtNsQAB02ulejfbryC79U5BfCVpaurDeQl6h4TUAAEs6t1E3vMJX8+LT056Kw== X-Received: by 2002:a05:6902:2303:b0:e38:d1e5:c247 with SMTP id 3f1490d57ef6-e38f8b0c24fmr12574929276.19.1732572372541; Mon, 25 Nov 2024 14:06:12 -0800 (PST) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e38f6378034sm2638618276.60.2024.11.25.14.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 14:06:12 -0800 (PST) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, willy@infradead.org, shakeel.butt@linux.dev, kernel-team@meta.com Subject: [PATCH v2 12/12] fuse: enable large folios Date: Mon, 25 Nov 2024 14:05:37 -0800 Message-ID: <20241125220537.3663725-13-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241125220537.3663725-1-joannelkoong@gmail.com> References: <20241125220537.3663725-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 Reviewed-by: Josef Bacik --- fs/fuse/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 487e68b59e1a..b4c4f3575c42 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3164,12 +3164,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;