From patchwork Sat Nov 9 00:12:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869095 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.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 98BE638B for ; Sat, 9 Nov 2024 00:13:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111222; cv=none; b=P0DElMiDRk8bpkAMQqstXa9++yU+9J7IU5q3bx4AVwbborcmVJpYDDtdyRq2nkWqo/yMCpv5UbUjeUkDJblT+kgLlYjAzEdc4mBmvEJIKVzjLDgbweJtOmNHarO5mPMpqBV86hMSufpH6WkqzbMNIFnMzPsUaaLJR2y3C/rg/UY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111222; c=relaxed/simple; bh=oxBI96owzL+k/QWvEJZEpXpBIy1zja9uta3bFBBTYU0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kFMQBPlQ/6E6dxKP9gD9ZzYVqj6sW1Er8qMwtF479J3WPLIxwvQS4QIIw1G5zsCjY0iUAoxMslUyI9iH4gCebiJoj3i/FKqhEsZbqgGIPm6CpNpNk/y8qSsreRj4V3ryX3jEuM0iLQzMMnx+TsrzWg4FG/p1raoylcOlb06Pzjc= 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=GX602dtT; arc=none smtp.client-ip=209.85.128.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="GX602dtT" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-6ea339a41f1so24152537b3.2 for ; Fri, 08 Nov 2024 16:13:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111219; x=1731716019; 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=Xt8nHgDHQU+phYtX3o2SlCzMkHLlcfv+3OOmwThp2JY=; b=GX602dtT7Fai9BM3WXOs9heoyChJ6y73oX6rI2XVJvF83TTkspNyrl1Ac5M/jht1yH WN15iM0VxvIBolMF2b3hTRzTL8e3bbWR+C2ogT5kXSSTxpCsBDjjUpXx3Poq7hQ0QT7M UCcxIRmsFmBYusZgAAbknGbZ2GcR5Xm8IZazGFDw44EI1Xs3JggorGwmowfsD3cmqNZO /Xe1x0EBGxenz/76JuUn8R/W516+mwenXkBYcvoFhdDiNnsQ5ImRJMafGdWhldH9RLb8 7aNo0jHMairvnajBiWx614vP/4+89/GBBMWTS3gtkSyYVgLuTVWlcET3seZI+e/kDx1k FAKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111219; x=1731716019; 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=Xt8nHgDHQU+phYtX3o2SlCzMkHLlcfv+3OOmwThp2JY=; b=ibQRZB3sGqehllbIz496pu3aCMfqTcB3ZUi8GBTbF0lDZqdb27hQ4GFhp40dCJv+E+ PYzkPS/wFUEBdu6HtLTbdGFOAhMu+gzOy2a4z5dLXVdhbTV6fE3+hfzYeX1h5P6VrGmq IcgdGbt3xq+jq++x2khRyrEL+/a/cZp/+4/T3PPhPaezOmX9dTZSpnUT3gjFEMHmoMfz ROEL8n3M3bvuC1JhA/kLyxHyw5dTbU71xwndun8+Lb5wqaUqYaesI0LsLl+EUNy74NDp eT+7IInpajd8rEkJEQyl4+9wCTjwuoAM31jKhjHNxQM5DmNAG1BOUe9txOZ2lv5fYZzy LJpA== X-Forwarded-Encrypted: i=1; AJvYcCUxMsjaab5ILF/gIQCtEmrXSmQclv8LxEI5QvsOVKGS1SCWYeX+GyJmfqf5JHuYhSMi0GwkEHuTCw4Lyrfk@vger.kernel.org X-Gm-Message-State: AOJu0Yymu8wZIc3XJDXhkcGXxFSrGA/VTzdHWcBgbP3GIAsHgQP5lwVf wgzVZbdx07ul6K4mZXSKSdmUZfEngJpY+NhQkYd7C39fHrvXfX0h X-Google-Smtp-Source: AGHT+IGFE/xglsDC0ucoGMdjR9osAIj39uPXMY5loRfUPwNaRMWFzo4rf3p0viY7zrqs+qionM/lOQ== X-Received: by 2002:a05:690c:6902:b0:6e9:beda:5db6 with SMTP id 00721157ae682-6eadde50efamr61158887b3.29.1731111219394; Fri, 08 Nov 2024 16:13:39 -0800 (PST) Received: from localhost (fwdproxy-nha-011.fbsv.net. [2a03:2880:25ff:b::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8f0c5dsm9474627b3.41.2024.11.08.16.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:39 -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 01/12] fuse: support copying large folios Date: Fri, 8 Nov 2024 16:12:47 -0800 Message-ID: <20241109001258.2216604-2-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 | 89 +++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 49 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 29fc61a072ba..9914cc1243f4 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,24 @@ 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) { + void *kaddr = kmap_local_folio(folio, 0); + memset(kaddr, 0, size); + kunmap_local(kaddr); + } 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 +997,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 +1011,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 +1036,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 +1071,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 +1658,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 +1665,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 +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: @@ -2044,7 +2035,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 +2154,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 Sat Nov 9 00:12:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869096 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 40A8817FE for ; Sat, 9 Nov 2024 00:13:42 +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=1731111223; cv=none; b=YRnBGLLMoSRhN6E3rVYpm+xCbMH1e2hiPqLPUCeUKNy0YJXObFTsDl+G0+JMH3/ayuLHKfCu8f3mfJMSybFpxzIyN28QZfrgtcyoSAnyf6JgP454q5Img4A8lxce5ohSpNYtqnRFvoVK5sxMeTGswmyT8sAtA78NSSLs9vanf+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111223; c=relaxed/simple; bh=+xKp3CYBPlrr1NwWlw8hM9QKftbbN3hxcqGKB0upoUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dq0/YvnBd52Ql0NUrFhsnX3IvUDv+llr3wH31cUGH6kU0dDtlFgNuBHV9Bal3v9Wqg4cUUvkRGmDntRA3k/ftLLep2IljgjCXTTjDXfX+xDgZghetJO7pMk2OdxINT9xezZim8oQNIpgRF6zbVqvU0pF711FNkP9AThVznyKcy0= 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=UMU5aiw9; 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="UMU5aiw9" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e29687f4cc6so2689213276.2 for ; Fri, 08 Nov 2024 16:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111221; x=1731716021; 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=1zq2JHnawxKVzMEkxsATEgh7nnGTddz5f9xYMm7Tygw=; b=UMU5aiw9tQGryP2Tl1O1k1K7i1+jHgugE3EYcrZGAN+3cf+vCVThR/VPBZIxp6KJJF x73UWhxC/9MAeMHOy05RiwG0JPT6DJ/9HmWHvTGmHl7LvzWutHCkJPozo9eefANA5wHb plMaCGgBfsKsgjSb5u1+ieSMC03QQyryx70k7MLU8Rzbilw8qUazkUh4UI/YE64kwRo5 xyWtgxjGcFRurFA5glk35GrnhvEssiKDVqer4ptBQP2nA2f0IZg+iJSli/2Mz3F7my2H WIoaGljShc65YD7h/GRl5OVZJ1ojaqFDOHBaq+lR8QtnPuNaLGgmwOO0QjmencZ11qLt QWCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111221; x=1731716021; 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=1zq2JHnawxKVzMEkxsATEgh7nnGTddz5f9xYMm7Tygw=; b=YauD3/f1rPCqFjg2nh//9Ek0mKi1ueebDC7zk8uAMLGLeA6H412otkAHCBBkoGRmkw xz9Nv0uRy4upQeSKBsYniEWF1m20VzEG4rTs88awpaO8+3pyj0rK+R8srlbmPiOR0jet IfDgTH+4r0QmQUutNZb4kNTOiqPlZltLCg/5kd92aNgFzVheCbg69io15krMkfQpHLhT qi1CPwwcgBWHOZ3E3axO05ZJjE8LRNe0z7di4F4mb7D1Rgvh1rSPLMsPuFK4Z2Pgspna T9haqXHbpkbulV5dHOkgL06tF+gD7i58xn4+Lia1a6xKB0n/Zf44tnrqoANOqPpjj8T2 GSLw== X-Forwarded-Encrypted: i=1; AJvYcCW0AM++Wo320PJaWX1xdmLE7g3TN2FMolRo50+zVwp69r89qAiQ/Dz9Y9tAw+dxkwCbTQVz5mJHiP68PBdv@vger.kernel.org X-Gm-Message-State: AOJu0Yz9sw1J+0w6DCO4hxuWQSqKcRBPhIPCDyHR3rOjo8PxOkbJL5HB rbz2QbtGFsFCZcwg+xhwUeIhf7ko4KQq7hpaBhKaaVlOb06egMjd X-Google-Smtp-Source: AGHT+IHt3CECjc0LvtErN+zNsDWUlnT2nINWdkDh2DI0sc2U1xUk6pEKLRjlwIMDsVLz9YrA0ApDsw== X-Received: by 2002:a05:6902:a0a:b0:e33:2605:f826 with SMTP id 3f1490d57ef6-e337f873c8bmr4561170276.23.1731111221150; Fri, 08 Nov 2024 16:13:41 -0800 (PST) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e336ee20911sm898505276.8.2024.11.08.16.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:40 -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 02/12] fuse: support large folios for retrieves Date: Fri, 8 Nov 2024 16:12:48 -0800 Message-ID: <20241109001258.2216604-3-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 9914cc1243f4..5be666af3ebe 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1719,7 +1719,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); @@ -1737,6 +1737,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])); @@ -1757,25 +1758,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 Sat Nov 9 00:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869097 Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 386A23232 for ; Sat, 9 Nov 2024 00:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111225; cv=none; b=UWLxXUfqDRydQSH4JoGqLa+GMvFJZrlfSmES2ga009ieLViOGns0uEwr0wl/SaiY4xoKI/eSgtKRFc+kSbu3x27yOHb+moi4xgXTaEmT0xLGQI9qUiHyQCmAzy3KCpIXb+9lkKEPo8ts5oa9IHRlDjXFnDEvVsPMw/kYQcle8ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111225; c=relaxed/simple; bh=wqEV/ZMnUjbgJjUAp3L1aME+cCcLDODheG/o816v65I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IzBrRhaUs99cVGytPy3EBC/jkBd8qI1EwGZfDQ0PDqiNUyzfnhDY3g3NpsBDN0youfoDacXxrzAeDB5XlUO0tMe6UfLm79N8Xutm8rwayCMTjM4PqDvbs37/4/xJVv0+pso/x/sA2CO4jH6D0jMqhz1de8SuQpIyIQYt2gMKC1o= 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=R+ZMp1f/; arc=none smtp.client-ip=209.85.219.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R+ZMp1f/" Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e291f1d659aso2710823276.3 for ; Fri, 08 Nov 2024 16:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111223; x=1731716023; 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=8UZCVQtLcgRe4PHhlgikruZTXPYWfQqBHt0rJvAWgD0=; b=R+ZMp1f/GW6Uad2vLPzM9io1ALU1oM+Tsoa52yxT9KcPvD1vo/LCIzcy6j4wyWug8X f++MtYm4H+wJ15Ax0vNNolcWHFnQfjO7A7XQJOSnVcsP91uYHvYD9rnk7tikiIOSEaeq YjRjOdhVqyLgZKbkvoaAy8YrJA+VyDQabK7/2uI/qnqhfs+5go9dGFRfdShcgk3cXWiK 0rQGCLYC8E0m+f8I3JFVhm+i/XOJY/QOzkewdklAfN3ji6Kp2Hn9s3QMiLHUYxIqR9mi bngwoQjP9V+LKDqV6lJ+58P/We8tMGGTOHb66OkaO3J1ubnThWwG0bxDCyrXbFYOG4/1 zXLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111223; x=1731716023; 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=8UZCVQtLcgRe4PHhlgikruZTXPYWfQqBHt0rJvAWgD0=; b=e5cQV/Qo413YuTW+RdToXT0sxQBliYQ7b/LTBt3vrWCTeulqPb/fUXBQBekz+P4+c+ cXjmiyXKczivK/xyDFAJzse/wr/kpANP04j/m88gjH2gz56USih/Sk8FqojfuO8i/zXj uGs+4x7UQkxAd7uJ8vVYy7Ujh2RCjEW8wF0tQndpWF79JHw9YPQ2VRciOOnr2SZ+LoLJ cupS9LHdl67l2NcyqgVKyaS0Lpz4ojvxunCkTy7oMEq4zoEvGr8mkspTKwmJRrPxSJ4P MXGoNx1cSrIO+BclEG0aTcuy1QO8rRWwoGiVZWY9qNTbFfnKk3Z2n3YQ8hlLrWWP2HWo 93qw== X-Forwarded-Encrypted: i=1; AJvYcCXejcg0z+loShAO6uPkKONm7BU0i5MnK2Fc3mzWzgRsLDlb/a0H4rXQ8n1Jc0NBvTVglnyEetYvi4kK31Zs@vger.kernel.org X-Gm-Message-State: AOJu0Yz+QdDvXeatMoyrnmCGynVb+FHNebLZ0YkrMnRGYh9fLcnhLk/p n/lW+lYBym6/IWPL+R9NDRKud5nhgWlbLvQgB/NBkytqBje+1uJO X-Google-Smtp-Source: AGHT+IFPX8+3a/bqxlMHtEjTK2+bzshJqshIMFxvklnUOqD53b7Gfx2gplJk5ZCj6yxDSijI1jfOBA== X-Received: by 2002:a05:6902:288e:b0:e29:1627:d4d3 with SMTP id 3f1490d57ef6-e337f8cf0e5mr4650125276.41.1731111223026; Fri, 08 Nov 2024 16:13:43 -0800 (PST) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e336ef2652csm940830276.22.2024.11.08.16.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:42 -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 03/12] fuse: refactor fuse_fill_write_pages() Date: Fri, 8 Nov 2024 16:12:49 -0800 Message-ID: <20241109001258.2216604-4-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 Sat Nov 9 00:12:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869098 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E20FD81E for ; Sat, 9 Nov 2024 00:13:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111227; cv=none; b=YmiL9V+vY8R5/BqOTVLU4bdwcDDyq8bHydt6qrZrTujIYb5Q8kVuHJmayEaz6gUEsaonXP9z+pXQSPn8Jcr0fu2SebVMa1CiIWadsEiAnv6dIx0wAuWuKwlJPAOuw9zGx92xaLuDi3rzPeo3JyPMkCNRzPp4eKvczsPbHj8kZYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111227; c=relaxed/simple; bh=nJ3vJStqvBAnIo21+zNKzvHLKEvkD+YrIcD87lzgIis=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IKgTOmxYVSWb33UhavRk1plVKtNBX1rEvsknHKaMzXfD/6xsg6Hqj+ByK+gjgWyZXduG5slAnNW/j4wSlVsW8cvNbJEKnQ4rHXBh8yqv+K1Xr8WqmkBjr3R3AWOU7i/UoR/hA50WlQObyUx+528mDzi/3TVJuKATuP1Vk2oA/80= 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=HnEaz1Po; arc=none smtp.client-ip=209.85.219.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HnEaz1Po" Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e28fd83b5bbso3061174276.0 for ; Fri, 08 Nov 2024 16:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111225; x=1731716025; 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=8u0vKDd00/Gx0I67cawEwoAlLYtJSHEVWq7vgYdfHGk=; b=HnEaz1PopPI8B569+AsDLG/l23j+C6H8PtlwVFrKau1tUog6oTgQJ0dBzFYSiXQnCZ HTRHDTPpaFLTNqzSx+qc0YURjwiFbv9mdEOloniAvIMC6wlccSFRHHv63JUMhO6KCnYL HsEz+fHaqmH2vH+EdbrCRKCfATWsSSgwctZ8pnQE1Y3XkJLSr1rPDngMQk3FQeS/uZHK 6LTE7y6AN6gX+36NJBPqggMx5tpjVSUZgo5Ja3OJeZ7MRArdRDQUUfbIbovcApzQJYPI ILUs37RhbrsrEDnKYUaLxxstgXBPeCW2EmR8MxjnP1NFSJy/Aa1joUMQmv6iGR23Cg50 X09Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111225; x=1731716025; 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=8u0vKDd00/Gx0I67cawEwoAlLYtJSHEVWq7vgYdfHGk=; b=HQ+iD+cCNKxwENF2RZ5dUL3P1tZGfPfckAF01+aiDNW92W4il4rv8eWxE2rasTVDVl CyvoG1pvJRCCsWDA5G1TOCD7RDNULQuNybSBZkWWilaoC/QYix+LRR3t6RKs8etaXfEJ pHlPoWCNs+wjfw9yBDCgRJrs2ed3hapntDtgkoRUqaYRv1PydvY77fIbVsF5fObSzy4/ ihikfqk+jVVkPg5VNYpcT+i1LKmko18s9/jwLYBLVsn1vz5zDMtfX3qMzsYcHGXlY1KG SWpOK2Z992Tz46nHOtWrmcFuxG657EwdOI/Vy8RWz2QmIAk99wr5ONizLEgIu9QjmR8k 5jLA== X-Forwarded-Encrypted: i=1; AJvYcCXyX+7X8DJWfIhJ9LYhDfpFiTloMXIPKDHzszp7lejgVOgmOqIm8gdxIS9teKuONoH1mJzZZs6/LFtdPUuL@vger.kernel.org X-Gm-Message-State: AOJu0YxnZh/iyFyGYvgQGLq3gRYBKqg1etGIimiQCxgDbzguD2S+9hbg 0GkWo6xn1ImI25y/y+rqrLfqPVMysW1DorsdYApshky0lMnxyWLM X-Google-Smtp-Source: AGHT+IFW9C3tis6Dk+bmddCPTB9nTFMAU3RBIEaszEQPp9IkG7YH7ua5i07VBY2Rnw8J/PrdlL+a1w== X-Received: by 2002:a05:6902:1827:b0:e28:6b10:51b5 with SMTP id 3f1490d57ef6-e337f8ca22emr4204713276.32.1731111224851; Fri, 08 Nov 2024 16:13:44 -0800 (PST) Received: from localhost (fwdproxy-nha-006.fbsv.net. [2a03:2880:25ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e336ef1fe34sm959394276.13.2024.11.08.16.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:44 -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 04/12] fuse: support large folios for non-writeback writes Date: Fri, 8 Nov 2024 16:12:50 -0800 Message-ID: <20241109001258.2216604-5-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 non-writeback writes. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a89fdc55a40b..6ee23ab9b7f2 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1146,19 +1146,15 @@ 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); - - again: - err = -EFAULT; - if (fault_in_iov_iter_readable(ii, bytes)) - break; + unsigned int bytes; + unsigned int folio_offset; + again: folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, mapping_gfp_mask(mapping)); if (IS_ERR(folio)) { @@ -1166,10 +1162,20 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, break; } + folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset; + bytes = min(folio_size(folio) - folio_offset, num); + + err = -EFAULT; + if (fault_in_iov_iter_readable(ii, bytes)) { + folio_unlock(folio); + folio_put(folio); + break; + } + if (mapping_writably_mapped(mapping)) flush_dcache_folio(folio); - tmp = copy_folio_from_iter_atomic(folio, offset, bytes, ii); + tmp = copy_folio_from_iter_atomic(folio, folio_offset, bytes, ii); flush_dcache_folio(folio); if (!tmp) { @@ -1180,6 +1186,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 +1194,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 Sat Nov 9 00:12:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869099 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 191924A1E for ; Sat, 9 Nov 2024 00:13:46 +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=1731111228; cv=none; b=ZQkdqdRmbjKZ0dC2NQ4zK9mEZVSdRfqEdSuUIykU5DzkhRuNajxR8Q831OEME5sjbQyBxT44oxhYJCOe0pWtV9ZTMM8xYkz+QbqiVeZUAjKm72Va+UM7l9DAF7qvxdadNn0essJtHpUXf8KHTiQfOgR9BjV7/77uR9bW7jVL8XU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111228; c=relaxed/simple; bh=ylITfFLJ65tewDbFcAB+D+4nBXZqswDNP4LcxXdd2M0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pbxrx0jvkdlgCFahP2CBBW6V4jcPo7dTT7TeKvaSGaTiMcqQLFe5xqrC6oxNKVw8RobDDdvpZpyweCPMcRQIQZdfvaMkqs7PHePoUu6fPWyxm8y01UWGoqDIVvzXnkmo1nuNZAYiigCcGazUdXYmA5Seoid3+ygHkxKCoadmISE= 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=C3f+rTJM; 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="C3f+rTJM" Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e28fa2807eeso2786956276.1 for ; Fri, 08 Nov 2024 16:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111226; x=1731716026; 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=FQUHw1Z8Y07Pw/jGBhMnupfm1VKH725NM4ibcSiLPBQ=; b=C3f+rTJM3cZ23/2bdrWZpxj65xaGWgp6RH9kcdyYeMY5ALbIwCbC1uR6TU01Ao5Y2X j5RR3jew733oVhIvUMSGUutevDjCY2ZLiPin2M5sePtVI5lv8LilHnFYML5rvylNwPq8 4QwHnzGjzjFmgPUeGfC9zUIrzRSS6gVG+d2qOFkqsloZUOiVp9O2CnBKK6Q040kbvCHo 8A8F70YgOjlLYQdGFqp61fx601muKnqgGSGlFsGeSCiip9dlJKAxOZMKyHOfv/G0Lomc Jdy0xbk2/zApJtnWS0yFnJIDNdAtuYIDIiG/CAXPEjxavD5bh8Vo8FbwaE/ZiqMuAo/c fTMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111226; x=1731716026; 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=FQUHw1Z8Y07Pw/jGBhMnupfm1VKH725NM4ibcSiLPBQ=; b=w/CYA5ZDdaAPc1zl9cy0X3uhgJgYg1GZse+GrnbHM8U7JHCLbgcOKxFGQbGpMJ9W2t F4PwLoeoD0LSI/KMevSkVvYrkQJU+9Y+aP16wfQpEyuFPsRUWJk+letuAlwm4K3/WkL8 gqYTZE7e/G+/SxMYAz8x9lhJtZjiaxRe/gE8ytIpds00RC1GXLmIFwVIOh8+exlkSIL8 WcJc24zMilLom7KIFR14joBarZtYWj9S+gZODY//Av/Qj13LK+h0zoeTcZqRCFZuDOGp TlTOL6zk9FInFyIC2vB9e9JsbypuNVGhvUylOy4sQdw2Ji9Vd6sFTlLANJY8U8NlpZxF 0onQ== X-Forwarded-Encrypted: i=1; AJvYcCWcc8jodfB6WZYdM+w8/Fh6h4N0nRbsyWeR+Qeytzi94yyI6Y3e4FD+UbWTmwoaLZR6mpa8ppQO3Oo66A80@vger.kernel.org X-Gm-Message-State: AOJu0YwbXBNone/sNSs6xdkll1OetcWqE4DhRK+sgWxkA8VJVkoiAgFt h/KnRkxVycP0oG9S0DoeD65YprV3Y4vBfjYUgjdJP8A/JF1JBVJq X-Google-Smtp-Source: AGHT+IHo6KUglK+KSDAnLEPI0YnlwAFdt5WpZFJ/vE11xgsK/0nvfy72NTpSXquxRaPDO7M53pulVw== X-Received: by 2002:a05:690c:6302:b0:6e5:bf26:578 with SMTP id 00721157ae682-6eaddd96d06mr54477957b3.17.1731111226108; Fri, 08 Nov 2024 16:13:46 -0800 (PST) Received: from localhost (fwdproxy-nha-000.fbsv.net. [2a03:2880:25ff::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8d5386sm9476187b3.7.2024.11.08.16.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:45 -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 05/12] fuse: support large folios for folio reads Date: Fri, 8 Nov 2024 16:12:51 -0800 Message-ID: <20241109001258.2216604-6-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 6ee23ab9b7f2..399bc8898cc4 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 Sat Nov 9 00:12:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869100 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C663186A for ; Sat, 9 Nov 2024 00:13:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111230; cv=none; b=LQTMC3GWqoyh2VDiGRTU1bHMqS/ochjnOIM8YJpK7gWfAsauflG8dUtjKsm7FiBzNzpTzJzQdgZD88v5FmAZzsmixgA29TnHeA0qjQr7FmHw9Vg0fDKxX4BZkMlr5KDcYVv4OX+TTAbp8/Ij/vLwhDQLa6WU7zXYXgCBz0v6Xm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111230; c=relaxed/simple; bh=MdtYQnw2x6WOAlHKd1Uoc0M7fSxeSvJEU1eppAviayU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qqu5eycD7AcTev39FNzBTZ//dVI/MXccS/XfsrKqelO6aMNk7LT1t27GO7U9fDQ+CEtc+Ve6w2NQGIu6Lp/k39C9u4OcIKMrPf5dukS2X9eqEUFVDVKa89C6KBF2MGZV3hxF2iLBnvNicl5WLoJWUf41Cor0nuUDntu4/yciMbA= 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=P7GF1DHv; arc=none smtp.client-ip=209.85.219.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P7GF1DHv" Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e29267b4dc4so2551745276.0 for ; Fri, 08 Nov 2024 16:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111228; x=1731716028; 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=d17+Sv+ICg1qvVxhya12sVWPP7l6cyUpYgcAhzsE2FE=; b=P7GF1DHvRqILqzNtEYzKqToSNiGdyxRPbndHT9pj8LENgiUm0vEWUZ7h/Hwr4RAa3O i3pkeFTDN/ruYWIetWJGARBg9nm+eRrmLwfztiOVakYPvISfC8TwMe9HSs9sk80JODlc G+0APSTZbaT4GER34K0V2pm36IEIWE/4ABalHTc87cQ6UrVD7qb4XPE3ybG5NwLN3I6R ebFtLfBFqO/BUK4o8Zo54QTznO7tdnj3NaVwvXReLSOyAaOuq5ZUYCdyet14pFAQ8zM1 bW3dbgTjd3OsMWsSXqzqI0Q/nyU6cQiXhC+MhRPWh4kP9t/fFyvHbEHZ6SFEK6Vrj6Gc qphA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111228; x=1731716028; 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=d17+Sv+ICg1qvVxhya12sVWPP7l6cyUpYgcAhzsE2FE=; b=MtmOJUa9RQmu2gIUsExEPD4B8wP+/fHwt2ehuW1YP0PUzj880FZhEYbceLqsRXlJyz DF741yJryEJNAxddi+Ta7zysuDXkk9Naj5VXFBR1jq/nC8mYems35VEr4pHzZlcMZ2Ly x4jAa/cS0XviMgGkFR6P7wOf7VISe8IvKUFxvQhnMzlK8cdqm1auBq0PTezkTd5AtRsF knVFe5CCs6Jke4Je1U1byw9T/yw41iPYe8zrIdHK33bj1IrisOsxWPubjJxs/0y9ptxa Kebh80XPJqwdY0IlW05ZAFsTFZVHjrDIfd6z3Vbv+VNliBaOrEMPMJgXyTXbxmn4Xscq 929w== X-Forwarded-Encrypted: i=1; AJvYcCWLvdWzYG6Pao8FqrvKMO3Th4NiyhMx8EPybqG6vDMTv1EwhxWbQ6u9IyL+91IWhVjGEfm7XndfoiCF0Qig@vger.kernel.org X-Gm-Message-State: AOJu0YwMgksBdjoA+N6q33dOYcQhsKyUQOMWri78jSWFyCWMzartIqX5 R8wNjqyl6Es3oj4YGugg+NOIREQ7Oh2yX0pUuPxGWlo7clCfIf+A X-Google-Smtp-Source: AGHT+IG3dAe2XrjOSrNMuX9PTyAdOh0g38/WCYEn7pSzKAYEjmVnHniZZicUnr8wJWKIK2ry/OSMxg== X-Received: by 2002:a05:6902:18c2:b0:e28:30e3:eb97 with SMTP id 3f1490d57ef6-e337f81eef2mr5133186276.8.1731111227617; Fri, 08 Nov 2024 16:13:47 -0800 (PST) Received: from localhost (fwdproxy-nha-113.fbsv.net. [2a03:2880:25ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e336f1f9fb8sm897660276.57.2024.11.08.16.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:47 -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 06/12] fuse: support large folios for symlinks Date: Fri, 8 Nov 2024 16:12:52 -0800 Message-ID: <20241109001258.2216604-7-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 Sat Nov 9 00:12:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869101 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.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 07CDC81E for ; Sat, 9 Nov 2024 00:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111231; cv=none; b=WDHcCfN3+ZjB0R7Wk1aIEFl3A0MWv/qbBaFh0H6dHmtEuvHS95D/QUhmjZSnqkmZHHN4JKC7yxrohtVdfQcIj2AgrogKzKuOb7shzmE0RI4g71CWLVe3ltsUIwjx5Y/qLQhbPre29NfbUgcAr/QCpiDr55OLPfaFS1vlfWQU2ls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111231; c=relaxed/simple; bh=uQ7ed7VaoSKKodByRTTY7Vy9xgq6E4EKe3TJfnPEr9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y6ZoUwMc6xdnmzbmUGOLVTgUj/A4vudISia4DnuwpUgQl1X2AaN6D43k+n1i3MBwc5KlB3LnFktZUntHv1aHmewYz/aEtyF9egKhZY9jTJuAolB2Afi2xlUWul8xm9tDHb63xo7AbhYB90tG9e6Ej+Svs76KX0+B0aE3mKPBEoc= 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=cLrHwLrG; arc=none smtp.client-ip=209.85.128.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="cLrHwLrG" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-6ea5f68e17aso30401847b3.3 for ; Fri, 08 Nov 2024 16:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111229; x=1731716029; 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=P//IZ3vPFKZwRWDvcfeeruexp11/KzxuvABZbXdMKBQ=; b=cLrHwLrGEsX4Snk1D04BAaYLnPy+spFxf5YyEzqxsBSfWDSbFi0RAf0OF1uKgd7QB2 SGdTmP5kckxu4NtebGjaLgoaMnGGeptNiQRTCfKSlW5C4rZ/US9UDF/HjI8qbMmG6lH7 NK64f7RHtTnnAqMdDCwFfbs+r538NnuQOvUhS+w9IrBfJU/R4eu6hZYQM9j879QnCFQf ZbgUPCQ6vucAyg4J9Wpm9fnd4gsrevlVwKvePx1MqLeQmYdo0PlmgdtdYx9wEMGibbAQ 2yTL9B2XhK4FrV/deFktLC5zZfzUoaLQi6SGmazqKDkw7XXUHUT+GfAgMDZCQBWGfm7y +lOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111229; x=1731716029; 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=P//IZ3vPFKZwRWDvcfeeruexp11/KzxuvABZbXdMKBQ=; b=AVIbglmTTHlfdLLqJY+f+C+18ROor8B5KZPdNwtNoOv+0IA8sH2TclRKy8WYe+0nuA KjH7P8gFXOlOSoj8N5liiTmWmrB2e+E0Ly++Ra/2p6PJjgybwz1R1xWEmv+sKxLpya0N uf6uRXoiOrkL95TIK2q43DadR0B8+5yxCJuEmlollDCvrrkKttSUlifpmTtBc5eNHwr3 k84L5sxAbhUhteTWkakW+Lc1V55p+5ZesrQIQp1vbd0Lvf8Pprf0IpzxCVc1z7BEZtr7 xW7uxC7jMkd2ERVzZjNxde1dTIHFa/0isL/duYJfxEl1PL5Xj6pqsnVx+lFYHShApliK vblw== X-Forwarded-Encrypted: i=1; AJvYcCVv86nZNjqDXr/untD02Q9QgXIlt8udQmarii60Nw/cdPBcL+zLzAwiNmWeyDcyl7lU33EobCzpHfD9tjta@vger.kernel.org X-Gm-Message-State: AOJu0YzQ76STF3uVp9sWof2v+Ds6Noa0HHmJxWqJAoq/BCC2gjmA0B03 MNRfzuOtbTkDJH7L6TJ+yjE0UxCYl798RPujxCLHmB+HCZC/MGPU X-Google-Smtp-Source: AGHT+IGHbIj5r4GbPESffghDnHwvOmOiAov7gDgsq//ARFWkdtBhHY61AfKA1vuP/7XkEtulF3h5fQ== X-Received: by 2002:a05:690c:6601:b0:6e3:fd6:6ccb with SMTP id 00721157ae682-6eaddda0f27mr60104767b3.13.1731111229053; Fri, 08 Nov 2024 16:13:49 -0800 (PST) Received: from localhost (fwdproxy-nha-009.fbsv.net. [2a03:2880:25ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8ee1c0sm9399717b3.28.2024.11.08.16.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:48 -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 07/12] fuse: support large folios for stores Date: Fri, 8 Nov 2024 16:12:53 -0800 Message-ID: <20241109001258.2216604-8-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 5be666af3ebe..df9138f33c47 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1658,18 +1658,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); @@ -1678,9 +1683,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 Sat Nov 9 00:12:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869102 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56B8E8836 for ; Sat, 9 Nov 2024 00:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111232; cv=none; b=O5kmSAeC0ijLdDO/Yvq8ri8xLyNDJmhza5yf90Kui4EvW3IDAD+QtHqm96Wjeq0Rgd/qDCLbw82/rFrKzJq3/bhuLwJXvySP86rQzOGvV76D/MGkYH+/Eq/utoQuNeiNXIg1q5ruoiTacqv5ps3M1cB1Uze9Ken5L9d5V5FN20M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111232; c=relaxed/simple; bh=EfvJz6dAtZPmu+joMXDpM3F6Jmc3RbJ0pN7c68vk1tM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B8t+VP+VrRzg8ZNeAh7Ey8O9j7HfOeX3d915VphobAH2fMBs4EXRtBOpWOHXQGsEZX7GyxPALQSe2hYf6iGYgNgPryZl6+fxRrODLgN9rG8+durwdDLlZfc1LC13x3IVgMNVV7lpO34ki4GPRjJFumATd5p4q6YyLJfTfppWlBg= 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=Iws2+8w5; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Iws2+8w5" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6ea7c26e195so30809657b3.0 for ; Fri, 08 Nov 2024 16:13:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111230; x=1731716030; 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=yuvUotWx8eISAi8drzhpx6GLm3Zs1eFnPNa5j8GNQb8=; b=Iws2+8w5nC8XczhvUVdK+O+n1SvTh6u76KT3Vjhz6MrP5vTrvGc6v2Bygxk/Fp/7Mx ojlx6qTxY2jwaVH0YL11ZRBubYQogyjx+m0E9KwTQ1HgEx0SQcflh3mbmJxz6ISI1r6U /V/7IKO0Sj/Z3+Wr719NrU+sMsqHmR5TCjW5bsHIeOJxAque4lAAUy2P3CiKk+gzS6Ci gjgYDa98ToJxH+fQC9QuNya6hRRELUwt+SjB0bwpSyCtrvWQZulza+aRj3a8UBKuN5hC lM8TDORHUPZuzVuOTk4o2hhh+aSSCn3vowVD6Z/VN91Q7Vg9MZU+6WMskvWMisE1hLs/ tocQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111230; x=1731716030; 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=yuvUotWx8eISAi8drzhpx6GLm3Zs1eFnPNa5j8GNQb8=; b=AZhUR+XwsPDdHhuzX5UHRKa6BqEyWvkiYqNcAd3Pc6UJlvzsrGHpc4eMQ/65X5U0qc Kn/8y1zdcnJrwkQYAT3gcNxtcvLhWtEihauqfWvSvfHaWeteTNfmB/f7tGL98CEpLQJH gT2UvT+y1L/3unXaG3YcpdMT2NFyatM2TlWDlbsNbr2mT3yjRud99oY2cfW0U/5klz3e DOAnRdQAhBmwLdrNfU0ye1vQ1+f01dsvlIiLRbtIdZcaltizWyuoZeBl5oj3LjXwTm5h 3atUc1FIOSIVylPDLN18l6r+DqWAOhf8QiWctlf6TLCH8O52wMvHHyP6P0tmLqiGDJpt PMbA== X-Forwarded-Encrypted: i=1; AJvYcCV76s8KfxbAt6hiknk7P8mS7pffTylAjuVY8Uc76OyYO41A4OE7PeJykiAsaITWBiVfEqEHmlj9Vnn5A0VL@vger.kernel.org X-Gm-Message-State: AOJu0Yzfoq3RSYZQDbqa620RP5HuOxKR9i05Irz+utjVBaDRf1PvSrYd tKNtrSEZjSq0ca3hFHu5eLuVVcN/sed+UzFT3YukVDo1qVw8KBTR X-Google-Smtp-Source: AGHT+IFlcpc0RTuF8gHufS9jIfzQrmIZwZmuEVr4kHl8oFTWESceAkpLUHK9N9e74WhMUWmbtXeA4g== X-Received: by 2002:a0d:c304:0:b0:6ea:ef9d:fcba with SMTP id 00721157ae682-6eaef9dfe5cmr9885037b3.6.1731111230352; Fri, 08 Nov 2024 16:13:50 -0800 (PST) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8ef3ebsm9417777b3.34.2024.11.08.16.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:50 -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 08/12] fuse: support large folios for queued writes Date: Fri, 8 Nov 2024 16:12:54 -0800 Message-ID: <20241109001258.2216604-9-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 399bc8898cc4..44a65bdfe8fb 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1793,11 +1793,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 Sat Nov 9 00:12:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869103 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 91B15C2F2 for ; Sat, 9 Nov 2024 00:13:52 +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=1731111234; cv=none; b=MHckUC4nP5Bi7OAvPhHQ0BFwk87DI3YSepxE+d7Pr+01CTJKuTLpLm+fY6aYC9o1mIkJ6p+yKXSIlRhYEcHOu+RZkvxK/peGwCst0a4pv2UTLfe+nPNNUYr0ig/DgkeHu+48g0OjSSD/mOaozW09fEt+Q70+mJ/J7dnH25OSGTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111234; c=relaxed/simple; bh=+u6MlWqVIUPGucDDZ11gt1GWLiWVmel7l/A5JwwHaN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nm7m1FkuYT8jplig1BrONDgmDtta6ny/2aI3g2oI7yhgTAwME5oXqcE1itXZFehaieVGZRk4yc2TljVzHni+HcuwVRYM4lHM0MajWlVnYjUIpu80Vq2vOteQr8HjC/fGMGcFpspm6Snv8BEnfdCDHW3FYHiMDN6xdRmptB/XLds= 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=Ip/nMdir; 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="Ip/nMdir" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e2e2baf1087so2701658276.2 for ; Fri, 08 Nov 2024 16:13:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111231; x=1731716031; 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=xW1L6GLqIuWp0+LGyHyVAr9DCx7A/ZKZoCxcAOHkb3U=; b=Ip/nMdirpAIrtu+hr7lJjDGIoSnC5js6WxsaK9PeIhwui9LN7xpNb2Zlo1mA0AioDv GvSrjPuIs1sWXb5vSUyVZ4/iZnypFbgykC6iI0Z9i0CUxz7c3XCGYuMeESGPzi5QcqiN ALgomd6DXtWDVZOUXzPWkg06zppH7hE9ASeUUq9Z7hAp+sXisA3tqVeOOcMdWQGoLs8s dXdalKCBrlTs0DwUrlmLOh1WOI4gd7M5EKcuKId47QIsV/84R436DB1Z+iNwmAaEfm1q AHvuzBXGsNB6ZUCMP3XLUob/sBtT2jq9a6RZ7WJpoTRJJTmIcxVkB0PLrJqYz+I+/RaB 26FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111231; x=1731716031; 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=xW1L6GLqIuWp0+LGyHyVAr9DCx7A/ZKZoCxcAOHkb3U=; b=rJad33+IrCOIt6LPGUoIbwjKrwAGI/S4sMxbxgO81rthxHGS0pXkUaw0nWdTpaJPvk RC/vMKE9V2+y4OhXE4nmSFn8CfIW8e4vFZUKLzIPOralpWceyoGS8JjXP1ZNjzycj/2r M9xDD1CoKMov/QIgYZXMUN5kwDuhZBYVi2Y6NBVO/clF8GK1GIv9ySBjFXc3BSDYtCNt aO7SBaoafi7zfZtAs8F87Ajip18hYsY5ocEU5SVlJ4KqWLp0orgt5udXFJ/AEup5ZK30 NM4VpfhJuwS6RH6GFjg92o99ycLXlhJCG4PaRU1kpju0bdDXtO6sn5YXe0BD6y6tVEAw Jt5w== X-Forwarded-Encrypted: i=1; AJvYcCUsBb5hSHuMteYWA+LcAAWwX80LrFkISoRn7pqzeYbYpdo+6auZlhAKvB7VGswzTmnk/ldM1TWeZLhoEmgT@vger.kernel.org X-Gm-Message-State: AOJu0YwhWTucKJaW8mZNXFflxcIyIue5V3hhYPb+N8WOrbvaInl58g5+ 5MOL9XSVWwrFITEEI45QgjrX1T7b6qGx6PaaujytZh5Iu3cIhHt/ X-Google-Smtp-Source: AGHT+IFWVPaUg7nYCfwX+mF7CK2zrGz5GmxwEdW/sCpW9NxzDBSXytK2YCdIHVxrRfZ+2XtT7dA7cw== X-Received: by 2002:a05:690c:3609:b0:6e3:26dd:1bf5 with SMTP id 00721157ae682-6eadddac491mr57914787b3.20.1731111231686; Fri, 08 Nov 2024 16:13:51 -0800 (PST) Received: from localhost (fwdproxy-nha-006.fbsv.net. [2a03:2880:25ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8d77e6sm9403887b3.17.2024.11.08.16.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:51 -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 09/12] fuse: support large folios for readahead Date: Fri, 8 Nov 2024 16:12:55 -0800 Message-ID: <20241109001258.2216604-10-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 44a65bdfe8fb..255c7f2f2ed4 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->descs[ap->num_folios].length = folio_pages << PAGE_SHIFT; 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 Sat Nov 9 00:12:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869104 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.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 41A6D442C for ; Sat, 9 Nov 2024 00:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111235; cv=none; b=a1TuuAPzWqhvE6UArcNVpbYAqnu1R0VZKLOP9MZWR5LCChSq3owSU2BLRFJv89eTi++ms0n1w1rddaHfvTJrXAZj1vDxUoriu7ewcM/z+HfaMD6OeACDGy6marx9m5ZHap1lzWMZqC5z8y94XnjVDnc+9oikNAFiENYhU4SNNX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111235; c=relaxed/simple; bh=yYgzzzXpqzFKcmjR/AGOQoB7MN1LkrcU0MPdqJxLRX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DHBk+egNqWHmlrb2qWOWfGB3Vdj92oE9IUSMNvRpuyzcUc907WC0wFav8nJr1F7/0XBKXTgvrfefmyZNdU5wjMIakFfZXVSdx7KitcF5OJXdpZJOqWrSumUTAsnGha3qt0Ka+YZ8RBiWR/mbqQ3kYyQEiEWUfRXlv29djjzHzoo= 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=PajL1n4K; arc=none smtp.client-ip=209.85.128.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="PajL1n4K" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-6e390d9ad1dso23976967b3.3 for ; Fri, 08 Nov 2024 16:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111233; x=1731716033; 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=TuKCwsFn40jERjPqjTeJCxFnlNE/D2gBXzbxhi0+6u8=; b=PajL1n4KCJ8nsaUrZ1jb/H5GJ1Js9ajWI3cNwNCHXvydII3kbWQxl8WIj7JrXU3O96 S9zlL5CaTBq2nkwtbzmZ0pHFq+euFPJQvNfa3Tld+wQnON+2wBePfhh5C0euJkDY1Mgt slPACOmYCR6Qj2C08u7plb1cIMJUtk/jyTxqo5PJ5tFWta5YB2ikrEZuGISxs6HtH8s8 mgYL1iqxDgYO52/TNpQq7u4kSn1PmJak/30B/zBqI3hLq214782hXNRZpAfgFIhx8gwM dQfkXBRBBvjCgcGq1QFIbv28i4tfpZun5md4NPDlwX1S0hXZNe3ZqyxAqx1VYhyvCbsN bbPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111233; x=1731716033; 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=TuKCwsFn40jERjPqjTeJCxFnlNE/D2gBXzbxhi0+6u8=; b=sgiNAWs18TjembFS3sb1l6agsDjD/r1ZX4uvYznsoNM+Cj7YuTurLT1TRXFUJjxrT4 UjuccW4A9OGADys4Xr+WpCzDZD61emaoEx2AM4CmhzftiAq6kspkzT2vglt8/6PWKg9w jk5u5PMG633YPHc8tALoM531Xr0wXRaVzJ8fk3giP94CSlvjIDDhCY3r0+mTjvz7qSQ8 nSDSYqU4o+0W2ZTlkahCpPMSZjt+z2PLmpn4Wr1vK38mNzVQzsmRMvRJg9//eeErDGMW KaDLpJ3cKH4barp9p2/IskfHOUKMRMf3oA361hYxKimFkA8gIZOl2R7I+OJL4KtjLjGg zxrQ== X-Forwarded-Encrypted: i=1; AJvYcCVDOye+513hgrOADo0SKWcg0+7UEPKQg0oIXSXfiLJD3e2h6igNBRvkDvARwgU/pq/uXxWmDVdVhj+VyPSq@vger.kernel.org X-Gm-Message-State: AOJu0Yyp/qsD8AxceqOcvAeIeNxFbL8cullGQZyyD8a9ysOUuPf+Q6xl 0E9vZLrxujmKGp7Vzhuevz1QtcvcZxVaBUG0EF6GEEQ/KNL9ZYtg X-Google-Smtp-Source: AGHT+IE8dzLu7KbTLyVlkvUlD7CNZzDY6LR351WiRa04wyW+7gAVY4WYDTkuSn+eQ+09sVXoyzn+Ew== X-Received: by 2002:a0d:c304:0:b0:6ea:ef9d:fcba with SMTP id 00721157ae682-6eaef9dfe5cmr9885817b3.6.1731111233097; Fri, 08 Nov 2024 16:13:53 -0800 (PST) Received: from localhost (fwdproxy-nha-115.fbsv.net. [2a03:2880:25ff:73::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eaef0b5033sm1676997b3.43.2024.11.08.16.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:52 -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 10/12] fuse: support large folios for direct io Date: Fri, 8 Nov 2024 16:12:56 -0800 Message-ID: <20241109001258.2216604-11-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 255c7f2f2ed4..54e2b58df82f 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1484,7 +1484,8 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii, 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, @@ -1496,19 +1497,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 Sat Nov 9 00:12:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869105 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 7502EEEBB for ; Sat, 9 Nov 2024 00:13:55 +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=1731111237; cv=none; b=nMCyw+GDWiqYMJtJ2/Ddv4fVosHcpc1BXx5GT00qIzF5hFA7BgAwFt8Z3342teQePmOZq/mceLVjxASfv358dsr+MFndvX1UdEZ9Hqmp7yxJ638fUvkb/rYx75uSZXW6ibvZDRCVjgVOO36Q2t5wrdipTMg5WB6lk7qP/97Oqss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111237; c=relaxed/simple; bh=rBDbDvmoteZdm2ODXBKD6VhgXC5D4u68dpFFvBE3ReU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lmt8A0cgoRGJFaEsVkfPyOw4CtkIHSqS/u+b7dev5/XWQWxXxbDGnpR1r6I9MwqHgLIZUTLtW2/Tw5pGsai7VqC7VtDuK650hO/wrfcujYofSFII6TA9+xpUiRGLDFUDaF5o3xl9Y8Xw2KUM+fBz7IArwHQBUTMthbTi9JMr+jk= 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=DMlchaQ3; 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="DMlchaQ3" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e2918664a3fso2499328276.0 for ; Fri, 08 Nov 2024 16:13:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111234; x=1731716034; 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=6LqRa3Ne28mxlZ5do6PIs/3q1kOvHUbDyTO4HkVund0=; b=DMlchaQ3iuGwOWRZ8SvMqsvslgID0aJS7G6K0IvBbgksSAkQxSswXRZn295oHgKLAK 6Z9SAo1GEmMKT2qI2qVo66DpmiWSbR1IWLDNdwiKG48l7aloiOkJmgU4EJ1i8xmIYusz xvP+apXO0AsY024QdBYb0QYvDQrZJYXAOqhx8oi3vjPlXYlk06sjhW286KVGW9fTGj2D WiAOF5yl9TWpegZNz8eeUhKHjTTdqPPeDEi5/xnnkEjuzN5nZBlrYXhOcqTkQdIv+sWh 0z3m8Cnr9soZgUtfZqNBm7WlT2SjqZeAeXqgFuVxnrbNZmQL0/xlBj+h7eR6pK7fwMEK oZBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111234; x=1731716034; 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=6LqRa3Ne28mxlZ5do6PIs/3q1kOvHUbDyTO4HkVund0=; b=ma+TP4XXba5HaOv5fzuvzC/dEkNdK9LRKPS0LxbkNVoahdx081lb442PVLPnT4mAZP 1Mm8pH3Rbdb9p93xuuNEyMyMZ4KTGhh04E+6A8gtDCQLLllWY99I2NcsirVvq3Xh+sZl Lt+0l2e/qY9OlLt/gIw6pumMx4pd/LN6+AGl8nGpobm6SRhwe4n0A+A6p6tOhKW5uPGo yEWAYb7GPIfE49vTHCZUoGPViOJrRKUf/h5LEczg89yoFymX9UbsH+Io+3e+qQqOrlCr +2T3Wr+dFTtQw4XfwigkAdwt1smBVrzqX/ko+h2IRCYj31X5M76HLoZ8bLTHiaNEAAxM kmDg== X-Forwarded-Encrypted: i=1; AJvYcCXM13k/vsIiQdpLEu6rE+fyUUd6Fu+3Pzvg/EKi+4k/Q4hXe9JYsWfs4WS1kqlov9t29IlJux7ZT1hDsRzm@vger.kernel.org X-Gm-Message-State: AOJu0Yx+pfEJfQlxQWvGX2d5Hgxc81FlA1lWiLpUaWVchcmOi49NGGhu ZdG6bFM8ioZYMd9cFWkiXJm/gJlt2UoLa1lQkyy3lgepprfxGE+G X-Google-Smtp-Source: AGHT+IERxBntk1/jJECFPdV/xa7mm6lAAiIKRiFyqsxreUqi2rsUtQb4OISY0W/FQI2u+OAb193QqA== X-Received: by 2002:a25:850e:0:b0:e2b:d28a:5be with SMTP id 3f1490d57ef6-e337e17cbf9mr4957273276.19.1731111234525; Fri, 08 Nov 2024 16:13:54 -0800 (PST) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e336f1ba835sm940485276.47.2024.11.08.16.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:54 -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 11/12] fuse: support large folios for writeback Date: Fri, 8 Nov 2024 16:12:57 -0800 Message-ID: <20241109001258.2216604-12-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-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 --- 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 54e2b58df82f..a542f16d5a69 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1993,7 +1993,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); @@ -2068,6 +2068,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) @@ -2115,15 +2116,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? */ @@ -2154,6 +2155,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) { @@ -2168,6 +2170,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++; @@ -2198,6 +2201,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 Sat Nov 9 00:12:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13869106 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 B6A1E11C83 for ; Sat, 9 Nov 2024 00:13:56 +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=1731111238; cv=none; b=QX7jrO+hAfSKMd89IVuvXnW0S1923XfjlRjtswuZPQjDpIHNz1OF3X+jwsxXJ/inQR9xkkLrNp+bbYJ41Cjey2Aec29utSUiJ7/LKFWYNn67G+x5chZQR1Epjn856RhmroQGvX8xnjBqrRM9PVPGi8HjAFDkwV8A5vwJF8KXUuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731111238; c=relaxed/simple; bh=n0wTy08gTNDcTPVncomZCV+JItLqn+6vP1ed+UPceNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FxmBPH/OfeNJolYXHaRvHoT6bf/GWxzWu35l7eIyzCCV544D7/RdX4DjaEQ5rzgFrmpHRU7fYXHBjD5A/1NWKHPwhQ3mFdtnUrL+GAbyBQBsu6aKKqTHB57/0hbNiUHMGKpFcAnZB98XtQMaSsGoWK5cGIFvUkKzvzBRehQZ798= 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=eu2IFWls; 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="eu2IFWls" Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6e38fa1f82fso22042407b3.1 for ; Fri, 08 Nov 2024 16:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731111236; x=1731716036; 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=0cXyCKYyxPU+j24IjLjAHeILBfQqTehQhtOnNEc9Tsc=; b=eu2IFWlsQlVW5Q18PoBLYh2rY1YHc/Cc2vG5YxRSioem+GGdmEgqP2VPhA5VDLEY1a XUKNmO99eJw29i4/baRatCbUGV1hsNIu5a9aGyzvoHXNxLfbizMp6nA8LQSViQoIQX9u Ka5HaRoSPMiXXCODrd6fBWeIBKqqLOp0zNLnVX7/RCTBvyYrBg36MsA6UNSnFYa/kEFT milhUiFhuUF5wqlUiqIxvkZGmE9uhWZ7xwAT+7q634a/q3IhB5ab0RNwt5fvSrJum50K fmcccfcwcRRl5fLtEEJ4zGSltpF/qsM6z3sopz2m0yeMB2J1yqpLGQVykqVtZ3OJPuGY ymWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731111236; x=1731716036; 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=0cXyCKYyxPU+j24IjLjAHeILBfQqTehQhtOnNEc9Tsc=; b=jXdfxgU+byaT8ql1UJa76kPkEonu8b7tMdhmpNoHMTSzfjQxWguTguv3pcen3bwi7V JiXgEGZwcXujzSyd8WK7A/mLSa14oz3rlLiKNvBKtENB/lSGkdsH98CoBWJnTrxirxzQ sKuQEk+OgP3lHJaBfkdClguvpUhEay1KO2bXFJZqy+nWii9G0gQfjY3dFhWl5rPzuSYO VljAWmI53XWSoXhXrTnqjeR6RAPpQdd2GEKbc0XChDXA6sUugLWV96qDJoitXPIdu78e YKLI0zU8awVgm+Rq5CEQIkLYjsWohxZmxJU2V5JJ38hKA3+3I/WMd1PfXsS0WGGQXP/U mUSA== X-Forwarded-Encrypted: i=1; AJvYcCU8segOgHodan8gS3EVddEfU5Lkn9dIQe9Kp2dtpjEqHfsK1v/y2ow8WNe7nggN6WeycJ97XShmCIdN2bfY@vger.kernel.org X-Gm-Message-State: AOJu0YxSGscLU9sFyI/5pxNu1K5toE2VIkVAw9V8vQ9/uP5XkmFxVsfU sk+TzSEAYfM2nHoieimrT/4I1QX89GwnccZDOAO3GaE9vBAz3x/k X-Google-Smtp-Source: AGHT+IH2qlGPjKHETbOw6e2NjWmPSNSapYh0y7aaToGuXoa4CS99SiFpF5hcWXNMicIn655fRs0Yhg== X-Received: by 2002:a05:690c:7083:b0:6ea:95f5:2608 with SMTP id 00721157ae682-6eaddd8a695mr60643507b3.7.1731111235787; Fri, 08 Nov 2024 16:13:55 -0800 (PST) Received: from localhost (fwdproxy-nha-114.fbsv.net. [2a03:2880:25ff:72::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6eace8ef3ebsm9417937b3.34.2024.11.08.16.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 16:13:55 -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 12/12] fuse: enable large folios Date: Fri, 8 Nov 2024 16:12:58 -0800 Message-ID: <20241109001258.2216604-13-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241109001258.2216604-1-joannelkoong@gmail.com> References: <20241109001258.2216604-1-joannelkoong@gmail.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Enable folios larger than one page size. Signed-off-by: Joanne Koong --- fs/fuse/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a542f16d5a69..20fe3dff8904 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3166,12 +3166,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;