From patchwork Fri Sep 27 20:44:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814545 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.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 6CA131C1AB9 for ; Fri, 27 Sep 2024 20:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469944; cv=none; b=dWjmT1s4NX9L8xcoF3ZIvTtVyKDb/lucGOQjSEBEzfPFT7YA6PoAsSveGD/Vmzv5UihhnX9A5I+XmgdK2MIJGWC/S6lttsc8lVtrZJQH+L46HT3eg5fOwdmOkTvbmPMeYHnAiVDX5+8xRfwf25MvgeHxBvk+3oyWSRBmffaCd/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469944; c=relaxed/simple; bh=f/Gk8KLKsEiYexhk0587re0F37sdJg/L6HMGRpEpYb0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E/wSCuYlMzO5B49x8UEOy4zlHcoLON6m4BN4zlu5Id4eu/pJOj/gvjlbhwGKtCQNdQlDW+zG5AlofKK/lJ/9MpJBvq3yfxT9bS9kONyFtDev5ckuYZ7DY3sUe9qMgtRnb3SlQgLLtVNdtlNyG+8rjrPdolf4TSYZtau2nlCBOtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=IHICuf0r; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="IHICuf0r" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6da395fb97aso20487057b3.0 for ; Fri, 27 Sep 2024 13:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469941; x=1728074741; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NcyFx8sF4r8eQa55DYdki2Qz8c+eiUu+NpKKcrfpvFc=; b=IHICuf0rT+FTE3nD5IlZYL6SXQhj0LsVOQ5jkqS2zM8tUtDF7jamihDkDXXu1Kyx0G fc0owDaJ+HzyiGbANXdBwyEgolqohIhGR2DQiALNmE13ykTZn66DHvc2EXrDTsKqXpDN Iv8QwJ0dmiwlxXPSsNg50g4Olyf4Nl8xUU795Jqhfv4Vr3h63l3hftvDSAGDt4XgUiXw Qn4QipXL61wcLeMRoV8dU0iDfrRzffBZTRxqSV2GWKN1O0xQ+HppNBNqyTCb1uzVtw7G bP2AuNeN7tvwL4cLHjEqbFkMVg6Xqv2W65ZsWjbIH72AYS4I0crD7vuYI6mtnTh3giO/ frXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469941; x=1728074741; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NcyFx8sF4r8eQa55DYdki2Qz8c+eiUu+NpKKcrfpvFc=; b=DGa+oW8CZgG5A8Ephw7Z3grQpHoNZadBxrsd83ZVcwpww8rKg8BjypWYiWbpBSC5BJ xTwaXAiVYYBc/4pHU3SRv8FaR+/p3KTESKnNgzjZCQDfVmsSoRpYdW1KoPVaw5CyYck/ FpC+U8LPCb2MSRsxqPFWekI8pC2M55JORsWbI1SLIjiolmBO/ZxfrDfOJ1wtIMmiZR92 UkuvXAiViPGO6pBzcAn/14IHHjd8eEHOuIaCANXW1BfRs1m8B3cH59Vwv4A1fGvWJLi6 S5TMg+dSZAF0UAnTcA30V5DMJJIhuhRjYt9SFBPpwUpDpTxcx3Ubs3g+x4b/KfNB8Fxf G7ww== X-Gm-Message-State: AOJu0Yzt8Czwxin1gSX49ojAhb/9mG0CbkyjoimPVcpktgABBlelD7MM /xrQt3TwH9pACTaldU0tetsPXzl/Krb6Hr8PQgIP1Vv4/HSHy+e+hwmLtXnDlFGQkCStXltei4s 4 X-Google-Smtp-Source: AGHT+IGzYhUo84meo83vcXCOAxiSnaaL9zl5bUBf4VG/33Nype4oQdjtHNL2Jlj7DdVGnMccYePWYA== X-Received: by 2002:a05:690c:6612:b0:6e2:ffd:c11e with SMTP id 00721157ae682-6e2474d1224mr38895267b3.6.1727469941038; Fri, 27 Sep 2024 13:45:41 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e2452f7c1bsm4172657b3.4.2024.09.27.13.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:40 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v3 01/10] fuse: convert readahead to use folios Date: Fri, 27 Sep 2024 16:44:52 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently we're using the __readahead_batch() helper which populates our fuse_args_pages->pages array with pages. Convert this to use the newer folio based pattern which is to call readahead_folio() to get the next folio in the read ahead batch. I've updated the code to use things like folio_size() and to take into account larger folio sizes, but this is purely to make that eventual work easier to do, we currently will not get large folios so this is more future proofing than actual support. Signed-off-by: Josef Bacik --- fs/fuse/file.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f33fbce86ae0..132528cde745 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -938,7 +938,6 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args, struct folio *folio = page_folio(ap->pages[i]); folio_end_read(folio, !err); - folio_put(folio); } if (ia->ff) fuse_file_put(ia->ff, false); @@ -985,18 +984,36 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) static void fuse_readahead(struct readahead_control *rac) { struct inode *inode = rac->mapping->host; + struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); - unsigned int i, max_pages, nr_pages = 0; + unsigned int max_pages, nr_pages; + pgoff_t first = readahead_index(rac); + pgoff_t last = first + readahead_count(rac) - 1; if (fuse_is_bad(inode)) return; + wait_event(fi->page_waitq, !fuse_range_is_writeback(inode, first, last)); + max_pages = min_t(unsigned int, fc->max_pages, fc->max_read / PAGE_SIZE); - for (;;) { + /* + * This is only accurate the first time through, since readahead_folio() + * doesn't update readahead_count() from the previous folio until the + * next call. Grab nr_pages here so we know how many pages we're going + * to have to process. This means that we will exit here with + * readahead_count() == folio_nr_pages(last_folio), but we will have + * consumed all of the folios, and read_pages() will call + * readahead_folio() again which will clean up the rac. + */ + nr_pages = readahead_count(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); if (fc->num_background >= fc->congestion_threshold && rac->ra->async_size >= readahead_count(rac)) @@ -1006,23 +1023,19 @@ static void fuse_readahead(struct readahead_control *rac) */ break; - nr_pages = readahead_count(rac) - nr_pages; - if (nr_pages > max_pages) - nr_pages = max_pages; - if (nr_pages == 0) - break; - ia = fuse_io_alloc(NULL, nr_pages); + ia = fuse_io_alloc(NULL, cur_pages); if (!ia) return; ap = &ia->ap; - nr_pages = __readahead_batch(rac, ap->pages, nr_pages); - for (i = 0; i < nr_pages; i++) { - fuse_wait_on_page_writeback(inode, - readahead_index(rac) + i); - ap->descs[i].length = PAGE_SIZE; + + while (ap->num_pages < cur_pages && + (folio = readahead_folio(rac)) != NULL) { + ap->pages[ap->num_pages] = &folio->page; + ap->descs[ap->num_pages].length = folio_size(folio); + ap->num_pages++; } - ap->num_pages = nr_pages; fuse_send_readpages(ia, rac->file); + nr_pages -= cur_pages; } } From patchwork Fri Sep 27 20:44:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814546 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C80361C2DCB for ; Fri, 27 Sep 2024 20:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469946; cv=none; b=ST5+7z7UJ256zPi+kaP6ecMQZltVLeyLKRgYv69OnOGcAJkvGcmpvjnPbzrxgboaAG3OO0A43No/8lmfi6z6KB2GyJAcA0jMaWUUq2/sj0S4SOxEJtk8HeFpEvnOeuPhhDJWrhmAkpZQa3kUEfcZUDa0yS8EWLKbsG0CNpFS2uM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469946; c=relaxed/simple; bh=RweBD+yjU5RwYLC7s7RlewvuN1G9c+cqDexD026qbbg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mphqwTcKRHck5dNy+2Yj8B1dFoWaL4aJ6q04DZcy+emvVcSYs9kPVUJ9kP128+lyy9yg4QKmeJGGWDVW7XTr4F2NRfqxfMCEmOeVnRG8tsS7hRmBB+3zsTFULxW/VaUqXzq0AdCbNdm4IytAyLWIQqdVQR/9JRJzYSJZy4P6ESw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=wxzftcrc; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="wxzftcrc" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-6e232e260c2so20722457b3.0 for ; Fri, 27 Sep 2024 13:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469943; x=1728074743; 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=md2Dl5H5eCKwtjG8j4VlEsjGa9FrCXxESC22tm3GiVY=; b=wxzftcrcg0cERJ0ljAj+00TL2iwzGzS9vZItekrvmwTBv6uQaLwPJnfzjEWYCoEFVe nod7kzfDd02k7+/Fs5XBBY10Nah3EjwxFrhiusJzMuYk+5pV70v6iP7NTtWH0XPRWnQG vAsJpqzqmagE7bWO4sNCI6wN0E3yy2AchLxbadBsYyaui62ddLU7S97Py1o6OBtIS4xk vQ/e0trGPufpUg/HyvxgiUmhAEuvY9DkF6NyLbCWz5fLJp+EZUnuuo/BLmcCJvy7ip5A U8cwBDMHWNS8TXYkGezeQMdaJ3btRxQgNIHTbm/Adm+PiVlQvhosObkh/C2gf8CZAuZM KVHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469943; x=1728074743; 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=md2Dl5H5eCKwtjG8j4VlEsjGa9FrCXxESC22tm3GiVY=; b=eYPrHaImPb52gI/3Es1MIJEz/0GBMRGYK+dTMR61M/IE25immDq/Y8HDgIP+fMs+Dj /bfjx+X2Z1uJAFiK2seUGGKa6XkbNyz1Jid3oaC2xZCUVUa2xUWPh8ArdBNYxYhU1u+V K6uU0eDjc8eSnsuVwLWSwH+yvxkO8csOoobkxPdC1WbXSWf1+9lSgfcUVkoczIRlPU5p jKI0RLoWeM5Mk0k+LD5L37RqMP5dW3r9JmhxWowMvFOFPO/nMEgckzqkrK1LvXSviqUA ZAKdWvEJ1rcgh3Rn0WOjhER575C9HpLgxBjPIKfEhHkApmWYsxtsFwXYGhz0hl+jLaYJ jMlA== X-Gm-Message-State: AOJu0Yz01qEoecHIppoSn/cfilpIxJNi/YoZuHmhUgLDrfzsFUPSE9T6 z0WR2fsLB3KNq2U3UgJ3aDShn6iR4EvcRoDybhEwIgdCPV6ID33wmO7JV3Mp3WFZRCjGqYh9EZh 8 X-Google-Smtp-Source: AGHT+IEGyFHWflUQUYpISusKngKGFd8ih/tb96ZxKH7s+tnAZVFHpNP429MVSXL8aIUUiOkVUQvR2g== X-Received: by 2002:a05:690c:39a:b0:6be:92c7:a27e with SMTP id 00721157ae682-6e2475e2d1emr38856207b3.28.1727469943123; Fri, 27 Sep 2024 13:45:43 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e245369a20sm4135517b3.85.2024.09.27.13.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:42 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Cc: Matthew Wilcox Subject: [PATCH v3 02/10] fuse: convert fuse_send_write_pages to use folios Date: Fri, 27 Sep 2024 16:44:53 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert this to grab the folio from the fuse_args_pages and use the appropriate folio related functions. Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Josef Bacik Reviewed-by: Joanne Koong --- fs/fuse/file.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 132528cde745..17ac2de61cdb 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1168,23 +1168,23 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia, offset = ap->descs[0].offset; count = ia->write.out.size; for (i = 0; i < ap->num_pages; i++) { - struct page *page = ap->pages[i]; + struct folio *folio = page_folio(ap->pages[i]); if (err) { - ClearPageUptodate(page); + folio_clear_uptodate(folio); } else { - if (count >= PAGE_SIZE - offset) - count -= PAGE_SIZE - offset; + if (count >= folio_size(folio) - offset) + count -= folio_size(folio) - offset; else { if (short_write) - ClearPageUptodate(page); + folio_clear_uptodate(folio); count = 0; } offset = 0; } if (ia->write.page_locked && (i == ap->num_pages - 1)) - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); } return err; From patchwork Fri Sep 27 20:44:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814547 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 5DA4E1C2DC6 for ; Fri, 27 Sep 2024 20:45:46 +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=1727469947; cv=none; b=XT+0ly9NJ4N5lvk03T85M4/TkdfMjl4rdz/T+Li/5zPDh2NEO+ekxIkyqrnuZofM+lqZreSNwmlJTgn0TEBU3a8np3pKpv79UAJRwcsX+SZdCBLPe/hVuf46brKd4Xm56j5SsgvYm82I/JP/CIfsIUJWXgaMF26w232Vv3YFCuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469947; c=relaxed/simple; bh=fCTtLuyztHiM+saS9tz62DKRqjSI4mxVPQlXBaJEPL0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HYKnECnTOTQLa7vxjh9/IjIhqcBzv5726z9JH9Tbo2bm0jpcDL304znlBKluhzTvY6UKZkCXf+o0iLkQ0L0j/go1hGupyUbc8hqJ/BDtqSBZmm6RrQpn8Ap0ZsXWAYcNsvQ4Zr1lv2JYAgcRE0cewuZvIwlkiAr0OWXJFo+vlBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=B4C4L3Hq; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="B4C4L3Hq" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6dde476d3dfso21788897b3.3 for ; Fri, 27 Sep 2024 13:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469945; x=1728074745; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nLXFw7FC7c0Zmld/zatVwu9aDMDaZMhEoSDldVy+/SQ=; b=B4C4L3HqwurK7TtWJ08gkZkcZC6RCu3mdxakiClyAJGQqZs6GHXpfnIoDzcakHpyfl s/OTI26C58l0P0z6zIqXrcxL6NFOb72x2hOIYB4a8dhVGI/8uG0rHm9YOjJTJW/ehsYI 11PSjgjLWD0zU6+Ag4MLInLSckeno4ULjObhQaAUWxz0K+BF6+wYFTPkLXkuM7q2ARN6 seWRCHGLAzE6Bbig3Epas+3V41/j0VjgpsxBi2b10fnhTz1ovUX7nnuXb/i9W+2/v6Nw jQqZ7s3zmXLo+4PHaFyiheNlVJ+gsA4C4uw/QvcSpQhaxvGUKfT4656+YZzn0F0/yCXI +Zkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469945; x=1728074745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nLXFw7FC7c0Zmld/zatVwu9aDMDaZMhEoSDldVy+/SQ=; b=Gy350P9oJTfrFHwUITGoxcXa5wp/HvzD8N4jOWe73Q/2hpBoHmTqsvMvMask0asyzs YzI5n2ZMhluiZvHSjMEF4OPvsaBp0NQruJm0JKxqnk20W6MIC1u/FAmxeqUbXoFF3Nnj pgw+PQBZouf2tp9JS0/ujvtvxVchLJkkZo2XSlN7pK0WUeugy33Roq9dxD1H1vDTbHo+ HjiIQXtrFKG0jvoJWnYnQWI/h7pD3i1EFqFr9avOn9NzAbi2lrDo/cf4Dmr7nuzM55zs d+WPHVQUqJnvANYoYS5fb1qRDrCYRQ9RMGNR8xatn/MdTIeN4Qerl/dKACy6lGAQMhgd StyA== X-Gm-Message-State: AOJu0Yz4+VMNF5ByC06rslqAyDR7oc+Dllaf8pen8ftH2hFtv2AFe/Eq KOoi/HX7QmYQOApOrl/MpVsHUfXaSb1MxxadWRi7eVcvpMlDxAeuj2zIuT4T1RXggmTZ/atD6ZN l X-Google-Smtp-Source: AGHT+IHhqiUStJz9R6UM0shmU5Pm/MasV9ar6Og1TVhZi/OZw9INuJtI7t1HIh0bi62klt6t1WmMew== X-Received: by 2002:a05:690c:6f91:b0:64b:5cc7:bcbc with SMTP id 00721157ae682-6e2475d12bbmr47407847b3.32.1727469945017; Fri, 27 Sep 2024 13:45:45 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e24538b5aesm4096667b3.127.2024.09.27.13.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:44 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v3 03/10] fuse: convert fuse_fill_write_pages to use folios Date: Fri, 27 Sep 2024 16:44:54 -0400 Message-ID: <00a02299e944530c1be03d2d31b45614bedbc758.1727469663.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert this to grab the folio directly, and update all the helpers to use the folio related functions. Signed-off-by: Josef Bacik Reviewed-by: Joanne Koong --- fs/fuse/file.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 17ac2de61cdb..1f7fe5416139 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1206,7 +1206,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, do { size_t tmp; - struct page *page; + struct folio *folio; pgoff_t index = pos >> PAGE_SHIFT; size_t bytes = min_t(size_t, PAGE_SIZE - offset, iov_iter_count(ii)); @@ -1218,25 +1218,27 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, if (fault_in_iov_iter_readable(ii, bytes)) break; - err = -ENOMEM; - page = grab_cache_page_write_begin(mapping, index); - if (!page) + folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, + mapping_gfp_mask(mapping)); + if (IS_ERR(folio)) { + err = PTR_ERR(folio); break; + } if (mapping_writably_mapped(mapping)) - flush_dcache_page(page); + flush_dcache_folio(folio); - tmp = copy_page_from_iter_atomic(page, offset, bytes, ii); - flush_dcache_page(page); + tmp = copy_folio_from_iter_atomic(folio, offset, bytes, ii); + flush_dcache_folio(folio); if (!tmp) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); goto again; } err = 0; - ap->pages[ap->num_pages] = page; + ap->pages[ap->num_pages] = &folio->page; ap->descs[ap->num_pages].length = tmp; ap->num_pages++; @@ -1248,10 +1250,10 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, /* If we copied full page, mark it uptodate */ if (tmp == PAGE_SIZE) - SetPageUptodate(page); + folio_mark_uptodate(folio); - if (PageUptodate(page)) { - unlock_page(page); + if (folio_test_uptodate(folio)) { + folio_unlock(folio); } else { ia->write.page_locked = true; break; From patchwork Fri Sep 27 20:44:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814548 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32A561C2DD3 for ; Fri, 27 Sep 2024 20:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469949; cv=none; b=VAfy1ifsS6CA1R+SZeX2GmnSTGtTWC5upxT1meYZzImwRuiEgSYTELK3VQphH2rGfSQkaAd1unIeYq/w5zR8nxIZY2uqFRbu/cFY49K9UXINIEu6uQO5wP1lyWY6xZqJPBN++f2Ml17zNifEoalNgpRQ+m0N+v3gkyP2ocCfK4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469949; c=relaxed/simple; bh=LVRmv1llM4N7tLUXsRjkTEOXviCsRQordYs6xmKABe0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SXz2xDQVQY+o23lPc8m043zrEYGgu2A1VqVgqCWKwY1QnyaaBcFtmfbqQ7ivbtV3oDoEMcGXv7qXygPyq5KhfI8aoE+PA4zCH04ssg1vl5szc10iS3/OASc0YdQS60XM5x4lqcCsQ7bcnTD1FwkCQwdaAbxLXpbwu4mqF6DTyls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=rx81TOYf; arc=none smtp.client-ip=209.85.219.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="rx81TOYf" Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e25d11cc9f0so1930698276.3 for ; Fri, 27 Sep 2024 13:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469947; x=1728074747; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+DRhOsL64sEgZwzB9dQkJkYszAFNjSoT0NcfHOo1fAk=; b=rx81TOYfEGCnXXO+7CeywV2vRiRwDDnehYRMz9XSyjIlh/qt9s9O+2Fzd/9JPaX6T1 h2SOH6HdT+ew1sbAyECjyvGP2PrJJE1kkbtox7QX5tyN66wZCKGY9A9YyQjowPo7qjal X8YalVwKtigIlxPKpmBd7R6nbV/5+91+kRqCOSCKw1o+1MH0UNdAX5suuyDBqD3BwOG9 5zyAemDXukqYhFn7h+p3GoSyuctQoUtzbx0YcOzFV7DVAKGk9l6WjcLhzX1cZ3MczAl1 u8sm2kV27BlozhEc5WZnRoc9pPGIKVif/V7Do/cjb+p18dphEaSDs9b8hedfUf/d+VXc XuEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469947; x=1728074747; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+DRhOsL64sEgZwzB9dQkJkYszAFNjSoT0NcfHOo1fAk=; b=YUJ5N5P1RLjCUtT1bo9QOgSplKWsaLCYBJ6QpJF62NQVIX6A6aACNvgxXmmcUoFTqF IOULVundbSM2F2548+dFd/9feyBKwY3z9txwKJw89zIa7bASlYGZqaO2xx2fi/v0C5w7 hCzL0YYIkfpoU/WAHSpE/3+OW8p3Bc/9RWmU3SjHofxjRNlx06G9UJU/MLLULMD9hT9Z v3EWnoxTtId8PSO4JoDayeaXgAHdHbDzgiJ/VqWrKmMPf514QUx4VWJIfwH8BYI/uwpx vCSvKQhPQubEU1Ax5VYyqmJAKlru4UQ0bRhltXGD+rTOdfyk1CKQUhota26BL+raQqSD cKlw== X-Gm-Message-State: AOJu0YwciApaPz0JGJ0f35anWla2QPWdDkYFGeSOD4k0stM1cse7H4wE d8bkrA1JM2ajxq3byKtRY36SArF7gxD76oWVRKAAq7tJanUDgYeuacx93+ta+Z4UG5jHzyIH55q X X-Google-Smtp-Source: AGHT+IG7T+B7ikAWq1jSzGzaIs8r7KTskdDG540j3YRahUKFHSW5y/kNCuZdGQNWPTo9+RBM8HSL0A== X-Received: by 2002:a05:690c:f94:b0:6be:28ab:d874 with SMTP id 00721157ae682-6e2474d0d48mr42479477b3.2.1727469946678; Fri, 27 Sep 2024 13:45:46 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e24530af08sm4162737b3.45.2024.09.27.13.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:45 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v3 04/10] fuse: convert fuse_page_mkwrite to use folios Date: Fri, 27 Sep 2024 16:44:55 -0400 Message-ID: <1cb4f72d82dce708ca20ff90be622ac302ac2653.1727469663.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert this to grab the folio directly, and update all the helpers to use the folio related functions. Signed-off-by: Josef Bacik Reviewed-by: Joanne Koong --- fs/fuse/file.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1f7fe5416139..c8a5fa579615 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -483,6 +483,16 @@ static void fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index) wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index)); } +static void fuse_wait_on_folio_writeback(struct inode *inode, + struct folio *folio) +{ + struct fuse_inode *fi = get_fuse_inode(inode); + pgoff_t last = folio_next_index(folio) - 1; + + wait_event(fi->page_waitq, + !fuse_range_is_writeback(inode, folio_index(folio), last)); +} + /* * Wait for all pending writepages on the inode to finish. * @@ -2527,17 +2537,17 @@ static void fuse_vma_close(struct vm_area_struct *vma) */ static vm_fault_t fuse_page_mkwrite(struct vm_fault *vmf) { - struct page *page = vmf->page; + struct folio *folio = page_folio(vmf->page); struct inode *inode = file_inode(vmf->vma->vm_file); file_update_time(vmf->vma->vm_file); - lock_page(page); - if (page->mapping != inode->i_mapping) { - unlock_page(page); + folio_lock(folio); + if (folio->mapping != inode->i_mapping) { + folio_unlock(folio); return VM_FAULT_NOPAGE; } - fuse_wait_on_page_writeback(inode, page->index); + fuse_wait_on_folio_writeback(inode, folio); return VM_FAULT_LOCKED; } From patchwork Fri Sep 27 20:44:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814549 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 2572E1C32E5 for ; Fri, 27 Sep 2024 20:45:49 +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=1727469951; cv=none; b=nrc6S684ooCjawj7Q8ZoprbSu+PS1ry4jS529V3CkWF2iwQfFisgVXhPdqk2ifMUx1F0/J35VuAGtbtNv82A4uR7IVi2h6z3tGtF/25rtCUiZ6x9IhwIjy87/izfJ2/bdK1zTDHf7MLCGMALuWdXRmoNMGqCqSS7gFQGeymmL/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469951; c=relaxed/simple; bh=QjhWXX99YcYZggtkS3ASVI5vIztmbk1Bj4ji8EO1PCo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GCekxXal3UEEcowLIxqCACVxTE2q7JRBQXj9foHtUKB78NHeGAbz0D9MGFoo5rwG3YTfesKgBk3A2pd27+kwqdVcuJjZjhhawYubzvzbyJSSHUUrircZLN5D3852IXCxpAmnz7dgOgiR1VfvpzTDlzWpafivYlNWpFAu1nEQ6/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=EhXCAxLy; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="EhXCAxLy" Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e25cc9c93a9so2527234276.2 for ; Fri, 27 Sep 2024 13:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469949; x=1728074749; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=L5zjhaIoS4x1gFV18KSzw13Nd3fOQvJvqPRXABTSAZU=; b=EhXCAxLyfS4AMbUQp7pPGFvjLUB1t4/E6ozNg6lKz3k3oveJgm/goBZd1nCBpYjX31 jU+Y5ARhX8iHJbDDBxdXthUWeft/fbGxcc7BzHRVK4dPX9B0WLP/XZPIlx8A/M52bTl+ lynuNaJpN/bzlv3m89H6eR0/SEp1m845Fs+xedUfzRB2EMuea8UYx6psSFVE6MI+BFNA OXFnO2I6hbhm6elp1qOnuDwjsSkZ7/xf72RPy13O7giZZV54FHwZPZNzlfWxWzQsDPCM OGwfwFr8wSodb+J9Nea48o4mOoZWuzizTVH6hpfkkj5rOKif5dJKNaff7lWB9zKrN+Ts ocUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469949; x=1728074749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L5zjhaIoS4x1gFV18KSzw13Nd3fOQvJvqPRXABTSAZU=; b=EIKpbixTsqOjzPIWqFRnPIxtkemhMFuvjmAjVk7TyDqT1O60ytL5NgMjCp8Nm+iQ9e 8FBXBrjzLdJ3PEGjm6XVXycrOzY3Z7NdE6h9K19mp3bMFnfxNCv6Mb7gTJJ4dzhIGFqC AqbjC9sZsndyF7AcyZgRR2NKe07ymgRBnKGffjnnhfE6DYnYQmBn/sGg+/Rm84Mmv7fy h5D4/KlMw73XH2bV/vOyfuvKE+IOpiHB5pMkTQKDg1C0+gF+r1QB3+MmU1xP6FYqRFs4 QIAKNEeXqb7SpraHutOzx6f+OWbxGwtrmxGPig6t8zxC6Oaj2t0ZBpxgpQ0m6Hn9N3hV x5xQ== X-Gm-Message-State: AOJu0Yz9AH/E6Xc6GNKTWARaix4Qj+Wr4E9k9TANQN34G+SsbZokGW6g t4i/Me5Rkgi1RwdSAsN9sClemKyzYGCGU0nq57qI8ArzLYYYgKSjLjm/O9Q58ShsHSmPrEdI4Z6 n X-Google-Smtp-Source: AGHT+IEUl2rAqLTJowUGpAubeo27o6bs8QghQOREFbkHBdeg4V2jCRcHhazP+c9CU5L5XAhtHJ71XQ== X-Received: by 2002:a05:6902:1ac4:b0:e22:5ede:3f29 with SMTP id 3f1490d57ef6-e2604b157a3mr3934087276.2.1727469948799; Fri, 27 Sep 2024 13:45:48 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e260f96cb5csm12273276.2.2024.09.27.13.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:47 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v3 05/10] fuse: use kiocb_modified in buffered write path Date: Fri, 27 Sep 2024 16:44:56 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This combines the file_remove_privs() and file_update_time() call into one call. Signed-off-by: Josef Bacik --- fs/fuse/file.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c8a5fa579615..2af9ec67a8e7 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1455,11 +1455,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) task_io_account_write(count); - err = file_remove_privs(file); - if (err) - goto out; - - err = file_update_time(file); + err = kiocb_modified(iocb); if (err) goto out; From patchwork Fri Sep 27 20:44:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814550 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAE941C32EF for ; Fri, 27 Sep 2024 20:45:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469953; cv=none; b=JlZnu5qCsEZdID809oNlkMqjt13lwSGDXa2AMRUD07inQ2oi8ildcjAD2h/GZ0EY4AQAWSoJPORgjjla7dh912P2ybodA7M4Zsxmxt3lx4j8PTgL+W9/u6Ls+ao03Jf20sFNan7o+uYjpOLD7wWqXp8mBw8aUoupog9xzqb4llU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469953; c=relaxed/simple; bh=nwz6XfK+mPOFSG4FqpqRIcV+tg1cB8FrENRyhWMZIWM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z8Tv77LLflKrE+ZKo3vWQK1cwWOeOcFjnO6zwuZA+0tDHqXSCuDzJsSx8J7N4kNcu6Kres3iH7FqY9hMRDfSMfLzKUWhDhKuXYzunQUiRt+DOM+8uUuyExEsLmm3AWod7SmxAqlis2WPuipkZbWZg+XLw7vflzy/zTH5PqXngaA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=WtuH29gO; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="WtuH29gO" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6ddd138e0d0so24503427b3.1 for ; Fri, 27 Sep 2024 13:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469950; x=1728074750; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/Qzd63vJ+fCRdeBjKv8oXl3xCmoMjOM5uJKlOm7yyIs=; b=WtuH29gOVOEeXEXnwqALVNFwq5KycNhrLkVBkIRN/6yPvDNBtzGA0TOhFPf9vcQ6mZ PVi8xshik0iSZzs6PXgq7kEJ235TbNs5x1dKCrZdWmB2C22njGOAcoD4G7gYAa62i/eB Yq3kYudjDAMCJoiefzHMne8m8ZgzXmiTJONNQrtzTZ2VausDLbHQggvCZB6U8FxB9XOO rt4KiPsNtn5UqBESMF6yHScv32IwgwdwFQzZaPip2BIkyZfoL13x52JIii+ZVYuIM/qs cutMJqmA0+zzYU3lt8XWtNExCg5B7cu/Yzomq9V+XQFc/Z28pgVFY7+hVqIrtSimz52h ES2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469950; x=1728074750; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/Qzd63vJ+fCRdeBjKv8oXl3xCmoMjOM5uJKlOm7yyIs=; b=QKuWaa6KESaH0GyGp5AvDKlctZH4t4egSky7hPTupNVCT8ODyQHbwb1hpJxXgoD78s hiZR48sB8DX1IZ/ex0B/y7Vdnxj9ZkF6cEOzkPlLsU2wrm81UXqqFKMwi75M2fIp9av0 RNwdER8MAk/dgMv44vbrxaRluZG3F5OnF8j3doZRC96JRiHvyMbSmLR2LLzuptkMOn1N BAl6Qy9mfC3Qyjzifq5a/5VSeqv+OrbjFBY2xBg98y4GvZ9uW9B2Vf2+9jGBK7aFN1e9 7eRMI+Cx2nPIfz70h4q5X75XgC4SC3Vei312RuGqkjyTdzJ/nngn49R2wo6DHA0nVM92 mvpw== X-Gm-Message-State: AOJu0Ywj+R+EjuIyfxXYX2z3ROgfWVAnUbIGX+OlsVkuWYuwHijbRag2 WjU9zWOhxgJ8Vu5HoWe80wYA77YW/EpxFycJcWyKTdwC0/09RyMWz1lqJiVe/Xf2jtVoHh5MKpa c X-Google-Smtp-Source: AGHT+IGmtc9RkJ2MlpjG4zA1NfNlD8pUkXzcrbNP0egnTmlCAIwjUDxXHXHuVzXTPr27+ggCcA4DHg== X-Received: by 2002:a05:690c:89:b0:6db:d5dd:af76 with SMTP id 00721157ae682-6e2475e841bmr47109347b3.32.1727469950334; Fri, 27 Sep 2024 13:45:50 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e2453698fcsm4252377b3.77.2024.09.27.13.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:49 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v3 06/10] fuse: convert fuse_do_readpage to use folios Date: Fri, 27 Sep 2024 16:44:57 -0400 Message-ID: <0fe4cfc0e7d290e539abc215501ebebf658fd2b2.1727469663.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that the buffered write path is using folios, convert fuse_do_readpage() to take a folio instead of a page, update it to use the appropriate folio helpers, and update the callers to pass in the folio directly instead of a page. Signed-off-by: Josef Bacik --- fs/fuse/file.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 2af9ec67a8e7..8a4621939d3b 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -858,12 +858,13 @@ static void fuse_short_read(struct inode *inode, u64 attr_ver, size_t num_read, } } -static int fuse_do_readpage(struct file *file, struct page *page) +static int fuse_do_readpage(struct file *file, struct folio *folio) { - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; struct fuse_mount *fm = get_fuse_mount(inode); - loff_t pos = page_offset(page); + loff_t pos = folio_pos(folio); struct fuse_page_desc desc = { .length = PAGE_SIZE }; + struct page *page = &folio->page; struct fuse_io_args ia = { .ap.args.page_zeroing = true, .ap.args.out_pages = true, @@ -875,11 +876,10 @@ static int fuse_do_readpage(struct file *file, struct page *page) u64 attr_ver; /* - * Page writeback can extend beyond the lifetime of the - * page-cache page, so make sure we read a properly synced - * page. + * Folio writeback can extend beyond the lifetime of the + * folio, so make sure we read a properly synced folio. */ - fuse_wait_on_page_writeback(inode, page->index); + fuse_wait_on_folio_writeback(inode, folio); attr_ver = fuse_get_attr_version(fm->fc); @@ -897,25 +897,24 @@ static int fuse_do_readpage(struct file *file, struct page *page) if (res < desc.length) fuse_short_read(inode, attr_ver, res, &ia.ap); - SetPageUptodate(page); + folio_mark_uptodate(folio); return 0; } static int fuse_read_folio(struct file *file, struct folio *folio) { - struct page *page = &folio->page; - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; int err; err = -EIO; if (fuse_is_bad(inode)) goto out; - err = fuse_do_readpage(file, page); + err = fuse_do_readpage(file, folio); fuse_invalidate_atime(inode); out: - unlock_page(page); + folio_unlock(folio); return err; } @@ -2444,7 +2443,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping, folio_zero_segment(folio, 0, off); goto success; } - err = fuse_do_readpage(file, &folio->page); + err = fuse_do_readpage(file, folio); if (err) goto cleanup; success: From patchwork Fri Sep 27 20:44:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814551 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C8721C32FF for ; Fri, 27 Sep 2024 20:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469955; cv=none; b=AP7/oT1nFnpo4H1GAhJYbPw44AvHtWB2XNjtjj0RFmn8rzXkMthMxKIcllE4lKFP68tScWCTkX7MKEjnMNGQsLBoIQxwziBvBKNUr/NEXHucPsgWxe4mzr0jtz4SX9UMTCIy7GkDvyzWfgZX6fH1L2LMd4nynWxdLarWz3DVa/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469955; c=relaxed/simple; bh=qZnO/PT8Q3/BcHk3WdnUxOqowQGtif/DYfT/Q+jpt/E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cOjNEZcDG4OPLWdoIQqeWK/62GTIgcySmGn860DmHP6MrT4PJauV542M675sbIjL3SInmPa7eq8YzZFR80vgcxyzV0jFe0uX21MdREhzBnpGqh69f4Phcm4NbOHsDficVQJMHrW2rYSMKrZhH0/nJ886qFZ8nKReWg4jaEovENY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=DIDs83bF; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="DIDs83bF" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-6e2598a0070so1977657b3.1 for ; Fri, 27 Sep 2024 13:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469952; x=1728074752; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=UU5U/n5wGWeVhusJQimOUqE0sIjlM9T2CX5s7HYhGfs=; b=DIDs83bFdarACZVKbEsAKaQfEOd645HD+rUDFlg5Wmc0iiWPcbm8jjx2WMn1FvD7s6 5Y7SYtO4m7l3+TmHHWHncZSdLl6eBAhN58KXXsh2AUTrMeTZ2KyRdiyngsfBSmYHxP2l fFw4DIjIzQP+Y8oTgsCEYtzWXvcVwTkq7It7T8jgUOi6Cx+nu1mNWj2Odxol4eemQ/hN pGRfenTG0sDsyEH5DEmThpyYiXUQ4WbqS6eLl+8fjHG2yzNzLv031X2b5cO9GFFOdBEJ b4hy2iBV57iyE+WTrB5Z0cZOsKqyeMhXW43vjc7sxgJGFsyfwTxi+QLfJkLCNR9/kmCM yXQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469952; x=1728074752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UU5U/n5wGWeVhusJQimOUqE0sIjlM9T2CX5s7HYhGfs=; b=I3s+fsOu0yqU3rcVpCkfPD3YCIjD2HAS1MGXJUKQFA5yQxXdK0VO0NvsXzZklxyXdJ 0MeEunggICexX7p16G5fM7lYkB3PCVH242EXz5wJ4WFNVzL9UDf6weLyXhsgaZF1ECXZ m0W1qB6/Hp89iljNAj8CQm2G6en6E8mzIiwgbiaHUEml1xXZXDHI16my0iAbM9lKyAys bWOpKlRKqITe+UFnatNXfEiMCLTnFrJMTZ5oSa9opwdVKp/QEqNPlFnnjCZqZfY/f0Rw zswD69xl1LPfe3iexeICrVB/cErRiBsITs3Vqg45sKTDWlEXqmWSZkedB1Wk4lV5eplA Q/qw== X-Gm-Message-State: AOJu0YyjH+KnS+qu7xUYAGIiGL1p4Ty6tQgxbDcXVrmEjcP+XX8eZbb+ TaX4UNHWApHTlkXSwUteDeqFzyU3W+aOM7HByvqzYsyejV8s+DB38xck6EQC2AqlZ0LmLomB32r d X-Google-Smtp-Source: AGHT+IHfGhx8yDOqADuy3iLsDuBF7MGqByzBQBfJfR5Co8ZoXIPAAC5zs+mz9lS8iJckEoJzT++DFg== X-Received: by 2002:a05:690c:4b0b:b0:6dd:bba1:b86d with SMTP id 00721157ae682-6e247534134mr44683977b3.10.1727469952174; Fri, 27 Sep 2024 13:45:52 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e24549d150sm4095087b3.134.2024.09.27.13.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:51 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v3 07/10] fuse: convert fuse_writepage_need_send to take a folio Date: Fri, 27 Sep 2024 16:44:58 -0400 Message-ID: <622c8c01307fdaa9e9da254b5695eb082261b4a3.1727469663.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 fuse_writepage_need_send is called by fuse_writepages_fill() which already has a folio. Change fuse_writepage_need_send() to take a folio instead, add a helper to check if the folio range is under writeback and use this, as well as the appropriate folio helpers in the rest of the function. Update fuse_writepage_need_send() to pass in the folio directly. Signed-off-by: Josef Bacik Reviewed-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 8a4621939d3b..e02093fe539a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -483,14 +483,19 @@ static void fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index) wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index)); } +static inline bool fuse_folio_is_writeback(struct inode *inode, + struct folio *folio) +{ + pgoff_t last = folio_next_index(folio) - 1; + return fuse_range_is_writeback(inode, folio_index(folio), last); +} + static void fuse_wait_on_folio_writeback(struct inode *inode, struct folio *folio) { struct fuse_inode *fi = get_fuse_inode(inode); - pgoff_t last = folio_next_index(folio) - 1; - wait_event(fi->page_waitq, - !fuse_range_is_writeback(inode, folio_index(folio), last)); + wait_event(fi->page_waitq, !fuse_folio_is_writeback(inode, folio)); } /* @@ -2262,7 +2267,7 @@ static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa, return false; } -static bool fuse_writepage_need_send(struct fuse_conn *fc, struct page *page, +static bool fuse_writepage_need_send(struct fuse_conn *fc, struct folio *folio, struct fuse_args_pages *ap, struct fuse_fill_wb_data *data) { @@ -2274,7 +2279,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct page *page, * the pages are faulted with get_user_pages(), and then after the read * completed. */ - if (fuse_page_is_writeback(data->inode, page->index)) + if (fuse_folio_is_writeback(data->inode, folio)) return true; /* Reached max pages */ @@ -2286,7 +2291,7 @@ static bool fuse_writepage_need_send(struct fuse_conn *fc, struct page *page, return true; /* Discontinuity */ - if (data->orig_pages[ap->num_pages - 1]->index + 1 != page->index) + if (data->orig_pages[ap->num_pages - 1]->index + 1 != folio_index(folio)) return true; /* Need to grow the pages array? If so, did the expansion fail? */ @@ -2308,7 +2313,7 @@ static int fuse_writepages_fill(struct folio *folio, struct folio *tmp_folio; int err; - if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) { + if (wpa && fuse_writepage_need_send(fc, folio, ap, data)) { fuse_writepages_send(data); data->wpa = NULL; } From patchwork Fri Sep 27 20:44:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814552 Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.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 2D5631C2DCC for ; Fri, 27 Sep 2024 20:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469957; cv=none; b=kX0HXT3+CUCkTaoEkWpgiuc7y4MZ+YVGI6c/dQ6B1w2MjdWDbrMMKmbiwwCcnYaL0LMlO+GPU3p0u7I5jDtPXc1jkHl4KDsgp097KYjie20ZIwGPkfu8kcfi8utLlXtfGg6MoHOD7gnEE851GtOcysDTwIl7EFhs0t5tXk1gZ1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469957; c=relaxed/simple; bh=+HnPfo1rD7Vgc5AIyDlbXn29yOYJwGnHhzSitOUVI8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oWfDBO33HPX/Whr9lk0UKgJxv+VUTQYlypfzjFV9jf9qLKrAEiccoXcZSI5MKwx02XPAl7jgXUQN8GXXQf8r1X2lJ2EMS3kPpAoZm/sNDjjtYZb1pxxooiPbiMg0et5Rsgy131OWl8vwFWa6oFUmdeKhZPY6KgL2GmOhpi9LEkg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=efXUwW9f; arc=none smtp.client-ip=209.85.219.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="efXUwW9f" Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e260b747fdcso682770276.3 for ; Fri, 27 Sep 2024 13:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469953; x=1728074753; 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=6Z5BCJNtJV/IvtlHntdQ6UJVoG2UpNpzKZHzKW76QrQ=; b=efXUwW9f3tycqSji8Rid3lcjbou6Mz4cHll3C7dn+kKQo/8A5z1bgIbpAH3QmNFcuT /hBbs3ExxDjFzXBhvj0xzIySYig7bOZTvX4G526owL/LpySPGwFE/bikcLz3BJuzA5xE YqEO2Dd1w5m0ODByXUf0sITEZtJqKerYRnVKpyLU80zouPrgxFou43HDZ/D+F2v2QWfe rEfGJSyiMx0egxoxOwoWbrHSaIoI8Iq5PDg8T0xbeyzF03204vqfjRuNXnTSCDECaibU fWW980OL6xPgIRwjnATk09+dUhkpgQC98V5COV9UyYR6IcOqDYy+SWWSG/t1MH3RsS8O W7eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469953; x=1728074753; 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=6Z5BCJNtJV/IvtlHntdQ6UJVoG2UpNpzKZHzKW76QrQ=; b=ZU3/9VIj1QrmYe5x4B8eyEkDi6iULg0EfBvwTO+g6gOqXG9vxVZw+zS+tSxqVzUQfI M0TtTu+FGwGu8EPhWT7Mokh3d3aGItFijlSuuW3+Z5t9sOZGNh8IMsJ4UJyuC5pB1TlP zYGt8+rW1/jg0PjwwpfudGZR9PzJb8rz8a5aGJYIVcGevc1b6+wwwKupIJGZjywjCWW/ pJ7o4jz+09dYezelpdqicr0w2TiirCkLU3UsBmiohn8DEjufuTbQX2ASjXTpXg74yiXw YrHqjy9qv1OACjQv77JvQIg+IyiB7MqTVV3E8HHXaSUplG+HQhngAuW6n8tHIXLNtisA wx4Q== X-Gm-Message-State: AOJu0Yz8KZ9sjuZ998HXCzMz+23cmarOT1z3ffzJXx3PpwW91jcoLwL8 GwnSsD5h36nosg7qNoU6yKNU4iGcGVb/2fbRxjKX9JfXKSpzRXAK6/FN9xibCdCD2s/QTrCpi+r v X-Google-Smtp-Source: AGHT+IGfQT05VlxWYk1EoK77iZjJNtULSY3oA6W5c3MxiHJw9uKqjG8d4V0+QqWpR8Yzttv2cFhujw== X-Received: by 2002:a05:6902:1b8d:b0:e1d:2f11:3eb9 with SMTP id 3f1490d57ef6-e2604b5f1c3mr3475439276.2.1727469953579; Fri, 27 Sep 2024 13:45:53 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e25e400f009sm610712276.17.2024.09.27.13.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:52 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Cc: Joanne Koong Subject: [PATCH v3 08/10] fuse: use the folio based vmstat helpers Date: Fri, 27 Sep 2024 16:44:59 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to make it easier to switch to folios in the fuse_args_pages update the places where we update the vmstat counters for writeback to use the folio related helpers. On the inc side this is easy as we already have the folio, on the dec side we have to page_folio() the pages for now. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- fs/fuse/file.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index e02093fe539a..4c6eb724212d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1794,12 +1794,12 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa) kfree(wpa); } -static void fuse_writepage_finish_stat(struct inode *inode, struct page *page) +static void fuse_writepage_finish_stat(struct inode *inode, struct folio *folio) { struct backing_dev_info *bdi = inode_to_bdi(inode); dec_wb_stat(&bdi->wb, WB_WRITEBACK); - dec_node_page_state(page, NR_WRITEBACK_TEMP); + node_stat_sub_folio(folio, NR_WRITEBACK_TEMP); wb_writeout_inc(&bdi->wb); } @@ -1811,7 +1811,7 @@ static void fuse_writepage_finish(struct fuse_writepage_args *wpa) int i; for (i = 0; i < ap->num_pages; i++) - fuse_writepage_finish_stat(inode, ap->pages[i]); + fuse_writepage_finish_stat(inode, page_folio(ap->pages[i])); wake_up(&fi->page_waitq); } @@ -1866,7 +1866,8 @@ __acquires(fi->lock) for (aux = wpa->next; aux; aux = next) { next = aux->next; aux->next = NULL; - fuse_writepage_finish_stat(aux->inode, aux->ia.ap.pages[0]); + fuse_writepage_finish_stat(aux->inode, + page_folio(aux->ia.ap.pages[0])); fuse_writepage_free(aux); } @@ -2086,7 +2087,7 @@ static void fuse_writepage_args_page_fill(struct fuse_writepage_args *wpa, struc ap->descs[page_index].length = PAGE_SIZE; inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK); - inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP); + node_stat_add_folio(tmp_folio, NR_WRITEBACK_TEMP); } static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio, @@ -2260,7 +2261,8 @@ static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa, spin_unlock(&fi->lock); if (tmp) { - fuse_writepage_finish_stat(new_wpa->inode, new_ap->pages[0]); + fuse_writepage_finish_stat(new_wpa->inode, + page_folio(new_ap->pages[0])); fuse_writepage_free(new_wpa); } From patchwork Fri Sep 27 20:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814553 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 74EF81C1AB9 for ; Fri, 27 Sep 2024 20:45:56 +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=1727469957; cv=none; b=Roo6Oh15sS3MPzt27nGA/+oKpZ1eIlZk6yO4W38s77eZFogonN04GawyG47q2qM+nzYLImmn4c9Q48z1qNHStKZTKSIxYwDo8Rt3uGCI02k3vwR9I+iZiHj/AZMLCDB8MICCb8r5mF8ipHkxWGr4Cuk/wcmN2s8HcCD5yIuBr1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469957; c=relaxed/simple; bh=wVISCudRt38hav0ZgW6Oe4SSnOs/IfFY15A7fvAwhTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZgMIrKlo93nx+F0DL5wWx6xZOBixs9AeM9MZ8jc4N+uvJvzgUAMU3Epc5joYaJrqEf+oKhQt71r6/3lg9DjVOqkvdSEiqzbVZhJEHpdg+dMcpHVKvvA9pJDx99ldVdDqz0p4nG2ncc0GM79N4lO5J3YOYGtfgT4x5QeVnc5b2h0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=uTW+Gx+Q; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="uTW+Gx+Q" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-6e23aa29408so19598667b3.0 for ; Fri, 27 Sep 2024 13:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469955; x=1728074755; 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=j74oib4cu11+e7bTznb2eAYbEwPMzV5mPl9l6fM+GTg=; b=uTW+Gx+QrQFymaNx67AGmy+nYnmtx5l8JpFL66+o+IHpv6QFUnTciqi9+8Jaymcev5 oBiJgS+9wiqVNLgLG6A6unK7KLu+uUd352ExFbX+k99PzKOaC6z5VqN+IO16RRGAuGmj dUgJ+iZ+hcccx60Mq6eyujzFaEdOTXkHNlrpdXNCvm15cyrt4x73HfoWXaY7KdK308xc U1nAZ7Uztd4p6X9Aci4HtfpOTKikRQ0hadOEpq6s7vs8Hq5R0on6orhVz0S1bqir92e2 s9gi92ScsrL4XqpXe4L0RTgPyWN0AKR5UstdQTUuvpE+ax51rRQZlMHM4vDP/4Wvp84D eiGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469955; x=1728074755; 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=j74oib4cu11+e7bTznb2eAYbEwPMzV5mPl9l6fM+GTg=; b=GL/8kfBiV/XWiayvVFe1zO79k0gsmn/vvSYhutkVs8wDsFLYL8elC/A8mhH6r9I2tu subzRd8ngYInGRl9WUMtbSAlpSezixRH/xciPlzyikjVjbP2xXOtqXymBV8hKld71rZa gNYe9nTKEZymee5tgFfm0/4eXp0bk1GeW8AIi6p+ZEb+WCCrEE6Hj559007Y+u3R2N20 Gg9myVnj1GoZXD8YVXLsqeBkVNTP2Ogqr9Wzdcyv0XjAa7AvNEokB97YeXPm/c6mzhbm 67ulgtL1Bb35DMqR1F2MrxpTV8fJAXmi1gMOuxEJJ9cuzxUdYcoym7aAB6AeQuwOtRn+ nKZg== X-Gm-Message-State: AOJu0YywiqxQkKJWAgHPTVqL/hqrVGNQhhU+Avksk/rWTbYppIgAcj4C j5+9RVRowPvpgnFIYnLH0jn0DL+3K9Et8mM9nxREjG2Krl7XwSvBSuHHa1rT0+0d5dpP1l090F8 M X-Google-Smtp-Source: AGHT+IHZyGxm7wwuRxV6fZ9ZYijhkkFE1PYR/OlTL3n5e3gRe1Py0XHlvrgo2WfVYbrXgbhK5OjyMQ== X-Received: by 2002:a05:690c:55c6:b0:6dd:c6a8:5778 with SMTP id 00721157ae682-6e245386765mr36266807b3.14.1727469955157; Fri, 27 Sep 2024 13:45:55 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e24530a961sm4207717b3.36.2024.09.27.13.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:54 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Cc: Joanne Koong Subject: [PATCH v3 09/10] fuse: convert fuse_retrieve to use folios Date: Fri, 27 Sep 2024 16:45:00 -0400 Message-ID: <5b0e4f2c48a04d66dfe70f8228b05ebc53be6a00.1727469663.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We're just looking for pages in a mapping, use a folio and the folio lookup function directly instead of using the page helper. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- fs/fuse/dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 1f64ae6d7a69..4c58113eb6a1 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1756,15 +1756,15 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode, index = outarg->offset >> PAGE_SHIFT; while (num && ap->num_pages < num_pages) { - struct page *page; + struct folio *folio; unsigned int this_num; - page = find_get_page(mapping, index); - if (!page) + folio = __filemap_get_folio(mapping, index, 0, 0); + if (IS_ERR(folio)) break; this_num = min_t(unsigned, num, PAGE_SIZE - offset); - ap->pages[ap->num_pages] = page; + ap->pages[ap->num_pages] = &folio->page; ap->descs[ap->num_pages].offset = offset; ap->descs[ap->num_pages].length = this_num; ap->num_pages++; From patchwork Fri Sep 27 20:45:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13814554 Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.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 2FABA1C2449 for ; Fri, 27 Sep 2024 20:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469959; cv=none; b=JCrOnNv2VJE0Y/1VHKgigx4Awj50kjdsL9Zeg9mMKcLZ9SM+dfwY2MoKHjvKDx7Guc8moNY72cZ27kt6npBmx6GXm3qPDEi4+ceSMLVZ8yVQw/0U0fkOv0wK5Yp4kXPndECSBHfXQXttZn0Td+bY7JdNupleHQyjXn5xUQsr+Io= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727469959; c=relaxed/simple; bh=/X4btuxiMxcMdVg5txBuKbMPLcmKuhHU9rTmuTsR6wk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XQYUa+CdXa+v7jXDRO3FdfWDziFOt+7yEDFfkRooYi50imGgYcsRBEBJm2uqm6b0MuiJQ9A6BdAU56/HOXxuJmvu0xGygRzTQwlwf0bV3NfLU3c15zcvuYFH59RcbuQUlWLdIqkFBNlbUnRSnmOBcW/PdVSHg44WCIlKlKV4dC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com; spf=none smtp.mailfrom=toxicpanda.com; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b=brfgxVOw; arc=none smtp.client-ip=209.85.219.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toxicpanda.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20230601.gappssmtp.com header.i=@toxicpanda-com.20230601.gappssmtp.com header.b="brfgxVOw" Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-e116d2f5f7fso2910439276.1 for ; Fri, 27 Sep 2024 13:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727469957; x=1728074757; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X0K9wQJTZMdHk5RPuj5mV3fh+1GCFuX7VNn+gD+3fGs=; b=brfgxVOwFKgKQ15X6C4LzPgZ55ZmGxLr7b0NWkFuVVrWrFb72hzNa5VNBl77VR5wgC ek+rOLhEy4KJ11jiYYoy77wbuT0gwFjuFfoaIKfJ5mQPB3fwj1JnULRlGVBb6p/DAP2d 7bWhsglF/oYkwmamO2dqGtgJRZtLYLJzgBHgJ4R/tJzq7M1k+dAFLr9g0I0vrn0TqWb7 mQPxtzihSHJb1z6w5Vf15CoAMxb+0P56QcNbtZVF6o//CpV7m1Gt6msRtKt8FpgDBZm/ f/B/UiK5zQIP/cd7BhX0E6xj2MdoJX0hPUNyLNLCQ6ThKDuM7UImM18KFJYiTSD/YjrK UWiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727469957; x=1728074757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X0K9wQJTZMdHk5RPuj5mV3fh+1GCFuX7VNn+gD+3fGs=; b=TTsxRQvGg6WxjUQlLmHzrNqtJVO96pZNTGQ1A/60lpwU2bLPY20A0xgZLr2OSgfO2s fIMVkXdlaACmAcC5P0DkmWn92j4LmXUxaD0ZRbEu/g/PaycaxKUpu/i7tM3A1rFxiMgE BOJg1jpIlFd1IqVs0ZeZCFy4uZgbyQjqd9+9OTaW5jI1kBr5pEw1MUv6jto+Q1zhuHNw a8kEtcyYucNoB8P1Q0i6RAO4hDWYWztH9/TJYZwcESCgJS+85dfbH4dKctvWYgRnpVvZ q26XiVw4n5VuSG1/1ELB7tYvbJ3ym7X3CSUQEuNsiKpX3rjyHNeSwkqFQcjaGc2eFxU3 kDmA== X-Gm-Message-State: AOJu0YxbcdLf3dqnVkhyJADPE9IILz/1eRJhUhp5HJ6dSyQa8oCmDABI wM61wAZsWCHOxxlohPAaiuGiA0Otgz0Jti/vksl1BcIRJljkrwSoTGO/lEKKyOPBI8P6aco3ht1 T X-Google-Smtp-Source: AGHT+IHEOT+gbpWjlnphQaGIJw+BFPcdoGlY4ZPBdz2DOtjKmOCO0zCeAg5YYjuzYO+HJC3BZldx6A== X-Received: by 2002:a05:6902:13c9:b0:e20:2da6:ed7e with SMTP id 3f1490d57ef6-e25e5d9c859mr3619933276.28.1727469956868; Fri, 27 Sep 2024 13:45:56 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e25e6c314f0sm602154276.54.2024.09.27.13.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 13:45:56 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v3 10/10] fuse: convert fuse_notify_store to use folios Date: Fri, 27 Sep 2024 16:45:01 -0400 Message-ID: <877bb686a99010b19778570591de923296626896.1727469663.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This function creates pages in an inode and copies data into them, update the function to use a folio instead of a page, and use the appropriate folio helpers. Signed-off-by: Josef Bacik Reviewed-by: Joanne Koong --- fs/fuse/dev.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 4c58113eb6a1..5b011c8fa9d6 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1654,24 +1654,28 @@ 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; - err = -ENOMEM; - page = find_or_create_page(mapping, index, - mapping_gfp_mask(mapping)); - if (!page) + folio = __filemap_get_folio(mapping, index, + FGP_LOCK|FGP_ACCESSED|FGP_CREAT, + mapping_gfp_mask(mapping)); + if (IS_ERR(folio)) { + err = PTR_ERR(folio); goto out_iput; - - this_num = min_t(unsigned, num, PAGE_SIZE - offset); - err = fuse_copy_page(cs, &page, offset, this_num, 0); - if (!PageUptodate(page) && !err && offset == 0 && - (this_num == PAGE_SIZE || file_size == end)) { - zero_user_segment(page, this_num, PAGE_SIZE); - SetPageUptodate(page); } - unlock_page(page); - put_page(page); + + page = &folio->page; + this_num = min_t(unsigned, num, folio_size(folio) - offset); + err = fuse_copy_page(cs, &page, offset, this_num, 0); + if (!folio_test_uptodate(folio) && !err && offset == 0 && + (this_num == folio_size(folio) || file_size == end)) { + folio_zero_range(folio, this_num, folio_size(folio)); + folio_mark_uptodate(folio); + } + folio_unlock(folio); + folio_put(folio); if (err) goto out_iput;