From patchwork Mon Sep 30 13:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816475 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.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 A91B518E046 for ; Mon, 30 Sep 2024 13:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703940; cv=none; b=ZIKwGkamxe7fAFlZm/cPDen1RdqGSumbZmaShUqIsOc24i6XXPZ9EOuc9yfWWftlEhad67P9TS6tai7wMy1/OHsxUp//BEHbvNJS/9e0hEavOkr5M11Dbln3NE0Xhha/9YgWkrbKfP37Eyzh7+4gQG5jND9oO8fsfw4MAwAEbqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703940; c=relaxed/simple; bh=f/Gk8KLKsEiYexhk0587re0F37sdJg/L6HMGRpEpYb0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3RsihhAFlMJ7+NZMUPOxGkODiXm07zHkqqbxATET4PrJedA9/sH1/wtyJFzNN0UAdMGN+QolwzXLS7OkkUsJxKNt6ikWgtRz6CCpqLGUH0sp1YXMeHzEQEQ75WSErP6oTsVJi+EDL77R8gA0MMaLLtkZz78ORdETR+mJ+5Xm+E= 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=jaayH1i4; arc=none smtp.client-ip=209.85.222.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="jaayH1i4" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7a9b049251eso349101985a.2 for ; Mon, 30 Sep 2024 06:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703937; x=1728308737; 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=jaayH1i4i/ZYbj26I1QJ14anDtP5tIITIIhXdiYvMhLcUCikJH/mKcEVdzIv41HYBU m5w8FrctOpZslgNnnomPlBWp45xzSBON2eMm5x/HWnvtsxdhr8TAA31p1IvgTxxyclvL NNftFLSOvMNdtpL7MNbea7POSft/Ddo0MD+i+PfTkYK/IuNFSZCrDvGYELqY/+HHPaiu LEpXTXTSK8l+KhkFAKb4PyihOtJI2EnRYnMQY92X2gSJbpBrQCmG5a8WEj6aR3FVejjS u/AD4Or09HGPkswN+ovPSZo43Bd3BGOdwN7CJMVhtBXVEzx/bn6CsYUVqz4de9fgR9AB FdMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703937; x=1728308737; 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=Dgp1RJYXVqadTZo98yN1K3ii0OpGXXKUSZrAJ8/LcMXnr79BXtkkpZSKDWjC+B6KnR wzRYwdORF6TQmHxoANNF4h92p90kd6MkJsjKH7cnwv+U44Nm33F177tIIgHpOE95jYlS fnFcp31OTUB5TzvVWQkRe1gN7Qm04BgdZM+mD+vY1Ymhv9nRXZOfT6qLDXWdrIl4lYm+ i3ou7NNlS7BM67wZZUt5TSQEWQ/vT1mm6OR/eG7T5f3EenXHZOalAqLmgEFi3L3cYbIb Rc5MvGsaCZxZwZ7ZSp5r/KhmT/1oP/K1XeA8KtI6a0cfNx7D3n0JV7o7GPrntWkYvGre 3m6g== X-Gm-Message-State: AOJu0Yy1vV7tT6r+gT9TZfJxb1s8sxh0eihmmL4gvD4khnLJa2Qtsbfh AubJsBZWbLsFzpUDpotMAaL+HsLlbPlHQioeTwIzqdOIKSNoFQ/6tK2IH/7Asxwdjtw2w/bvRaI w X-Google-Smtp-Source: AGHT+IF8N/+kgY+LXfQWYBuBp2J6rfSLBwBCB66B/OyM8xaDjnokwBwlHZ9XEP1Wp09geGXaMY0rMw== X-Received: by 2002:a0c:f651:0:b0:6cb:3bb7:93fc with SMTP id 6a1803df08f44-6cb3bb79422mr160312476d6.2.1727703937124; Mon, 30 Sep 2024 06:45:37 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb3b68fd9asm39720186d6.137.2024.09.30.06.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:36 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v4 01/10] fuse: convert readahead to use folios Date: Mon, 30 Sep 2024 09:45:09 -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 Mon Sep 30 13:45:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816476 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 8FA0518E02A for ; Mon, 30 Sep 2024 13:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703943; cv=none; b=IbLyDoJDKx0FJACl5bWVHkAhWnm6euJ0MPx824iWTMocJcgTixRtIB/KtBqLaXUsrnzAciKPVzdNLSpR5WP/GYaRChtwE2K3z134YLwjILFovykZDHDqkXe9G/riikZx5uEF6lSObqh/HrBiTDu8bMXpvk7t/LxlhBxUV1aowPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703943; c=relaxed/simple; bh=NIMnjsmggbnxzBEW4uwR4TD2Ew40UGbWjKw34K8b/Do=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sRJqissdyiX+0IBcCF9hb5GdRYQPUHLm7cC+OFSurALuryYsdO0coYBeg3sAcONSVrXATwIc0uuiJfLjXMAmydWmx5f38GmTp41pCedOc2gTHsfXxlYihWQbTJ/9nenhjFXQLq/hKdL5wrY82Ad+L8lwQxoHxystnkvIJe/6TcY= 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=jw6wk6YJ; arc=none smtp.client-ip=209.85.219.43 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="jw6wk6YJ" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6cb259e2eafso36476166d6.0 for ; Mon, 30 Sep 2024 06:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703940; x=1728308740; 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=sIdykmDXYXqWHPWczE8moE+Dme0TRAg0JjJRVJFxKHY=; b=jw6wk6YJ0s8MOvAYncfDVQ0jnJJqcN772HCFaWAcN5KokltyzRr36T91DJJUZqaO4/ PUhVZ1pil6aKaUgc3lbbpXT69rHYLg8Fo5XhLMl/WhHMpSE2uzjCNj6afyWvMkXiDX9E 6pe7IhM0H9n/WziCX/HIAcyOe8tvPPAPgsIJvH/BH4sLfMRiAUFS9HTp+0ox0qwTc8ET pP/9y6gB4p/Dt2kFp3I65h35mIJG3QaPNZhei6J3ZXsGRN96kUklhyIXtj+UJPircQ8k 5+zXBG6K8TRaICmPBQ/ehs4l2VFDg6fuiK8PmkqzmyhcL9LY2+GudVkYF6nXH5uimTwZ +NZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703940; x=1728308740; 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=sIdykmDXYXqWHPWczE8moE+Dme0TRAg0JjJRVJFxKHY=; b=EVXM/8bF77j+wTNyVjhJugv5qErO0JqUwIIIFzAi/Vv7xR5MbPTVvCMeqoIY8DVjj6 M6yNYBAiCvf+0hORzk6K1wsiDw0NW4MP6OZGr7xZbszNXe1lLSBvHPzipiOxqUfeiZlp STwqqE4ksNNg+YwgqMiQXzW7+YIr/xGlVFlORvb2mwN+BbB2mTbGB9NoHikN2VaHk0xo mnt3ICdf298n/4Z6pT4k8VNOnDny1hH9SbioJU7xKUuHUY61LSzUFUdymu0OfurOsqGJ E/ftKWtMaxFLcPCZ+cTwhckQCMXztNaokNWMDXE1zCS6duinzxayG5vi7NctLscThtFu CGng== X-Gm-Message-State: AOJu0Yw7rHtuGVVisNbgven8nlz4Y1bVNrQu6lrQLIYtg5VJ42fhHX3N 8i6bAH2RwMLjD9JOEbipR3ihy0tfRpLmuLwT4UBUln0+Rg05+w0FxZUDu4mBOWelET6GOEpxvOU 4 X-Google-Smtp-Source: AGHT+IFAeBrlnzTEiyC5RXXGoTUiJ2/uNyiG3/C6k6f/SkBBtpSZNIbpASQi4eSaTQ/KLK0pVFS4OQ== X-Received: by 2002:a0c:e906:0:b0:6cb:3da9:d5a2 with SMTP id 6a1803df08f44-6cb3da9d990mr159410456d6.19.1727703940104; Mon, 30 Sep 2024 06:45:40 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cb3b5ff5a2sm40160476d6.4.2024.09.30.06.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:39 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Cc: Matthew Wilcox , Joanne Koong Subject: [PATCH v4 02/10] fuse: convert fuse_send_write_pages to use folios Date: Mon, 30 Sep 2024 09:45:10 -0400 Message-ID: <82d1c7f2d0427e126e6dc0e660a7c4e04d347068.1727703714.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 from the fuse_args_pages and use the appropriate folio related functions. Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- 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 Mon Sep 30 13:45:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816477 Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) (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 3482918E343 for ; Mon, 30 Sep 2024 13:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703944; cv=none; b=m0qINLtoBAOSx5q4S9/ujA9QJBkE5KjvdtoNrV1c5JAypGOkn9HvbviYhUhs4Ws0bHEeX1C68qpg733Wh7ExAnaqnBAOY3wSGKYqIR24D1PXVuxFc68VUatf8zjHtPQsHHxDiGDfbrZnnPfRlUJmlFFGi1WGk/qcPyyvPpv6lr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703944; c=relaxed/simple; bh=hkji6g9KRmvGRiod0999Qw4pNzeDVZriSsV/ihIGiC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PUJ7DXuvJeYs3EA6BZioRymuiRAb0Xt+7vbK0cBIOxU9JXZ5Nbr5y2sd8Ng1P/VpXrGRX7Jx8DDx6nrS6G6hQBJULitbr7UyZokiHFnneLYmodBs4iz6edYsjiHiF7Y12R5FqxYyHoihuhcC3UZklq+Ef4lsZWU4ziZOeMeZZc4= 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=VcxRb5fS; arc=none smtp.client-ip=209.85.222.45 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="VcxRb5fS" Received: by mail-ua1-f45.google.com with SMTP id a1e0cc1a2514c-84e9dda8266so1014308241.3 for ; Mon, 30 Sep 2024 06:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703941; x=1728308741; 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=NPu7E8gCGa+P+gKtfRE2uglpSB3dSETJKz0VOQ1VXsY=; b=VcxRb5fSk1lr+LwvxRu5D1bgQOsW2b0m8SsAhXdltAZOCjrnY83TN8w17ouYHzPkCH D9jm6Hnxm1gjY33USD8wCaMz6jATKxCQz0KdcOrU+n/XD+GoOFlgBlw+6L19JFhUtRat 5kOad764GnuREsBUoAapmoQY9nxli2Mh4opz2/os80/A6lONVdCifyZufsvD/8Zfq6Nw t4dqFdigva6KZLdH0vBnigD4JO07ZJcep1KQxOneVm9pMGZN08EoRPsG+zih5dyEEzpR mQbW838bxDJ31DlTqQz8xxTw6lp62svRiMLhCfri9HFvZGoICqZ/o3IDisbISw7Bpb93 rL4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703941; x=1728308741; 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=NPu7E8gCGa+P+gKtfRE2uglpSB3dSETJKz0VOQ1VXsY=; b=NxUTEm+bz6e0jwXNtcyDg6xaiF1hm9NF2KDWIh+Kchfovtyc4o1Ek8fE0A9LIGQsMK ygykW5B4zGtSBLeVtGmkWXtxeFDD/TOULc9RjC1jjbhvZ0DfDRZUREYVYStBJBtKCCwH Ttr0PIspfuRcKCUsCIxIykITCCxV+H8rqpDznY4ywXCh9o8lnBAOPFdSlseIEp1Apgbe L3JF3wAsm/NDv6i/kAjsz4ezfQ+NFY/lWtUUwNkKtSxAW5b+edMPNj4hirVLo0jgaRwB JoRQun46Uq3VZgHvHCxOGfx7MtwO7n6NtKXS6zlqk8lKNKEP2TY8bYFFzRtS0Hz8UI+R gVqQ== X-Gm-Message-State: AOJu0YzfFYwc8hXggqpegB0DtUt7N9CK9EgN4VNJDPy5NCNiImXI7yCZ enwjN5kYmuntxZWL9qNwIqyVrPHvHXruA5KCPfPA/zr+4OR8XOTxvrfBpbHmqeIB3bYcJ4LlL3r N X-Google-Smtp-Source: AGHT+IF2CLcB3SR2OHM98yyt8fIdc5sTi3K//9JkTEfpJ69wDkpBhtOZuKYF08syizKKDCWB7vEo6A== X-Received: by 2002:a05:6122:4687:b0:50a:c8bf:dadc with SMTP id 71dfb90a1353d-50ac8bfdeb4mr973580e0c.6.1727703941600; Mon, 30 Sep 2024 06: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 6a1803df08f44-6cb3b68ec2dsm39621336d6.136.2024.09.30.06.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:41 -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 v4 03/10] fuse: convert fuse_fill_write_pages to use folios Date: Mon, 30 Sep 2024 09:45:11 -0400 Message-ID: <32197de556a7d51e416449588a233bb904abc1fa.1727703714.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. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- 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 Mon Sep 30 13:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816478 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.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 C7E0218FDCD for ; Mon, 30 Sep 2024 13:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703946; cv=none; b=uYQbs4T/+7EWufnL903Kn9hXHhyptg9rFFhGtVxHkzlxU5Bx8X0LD2yeco50llIoLJxhKQUA+dz4bAVypHzWPUWltL66K98L/36EciHL0ITU2RqxgezOHDyNfz49D0vkdlFK6xZnDAzKMMMaji+M9Nm8jGSdJd1UOXOyCVQCYhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703946; c=relaxed/simple; bh=xxhxTHyFUzZc6W6EvO+2eV+lF9gnD8fALop23pcy+yw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n2+V9tJOj/3q1iXdls0YpU1CteGF8glUq0vTTf051Mg3VVpmfdbsjPVhtQ5/GDKLT++1WXI3vtu+WuWB63m3QvZt/YGIu0FmRdmBV/ynfSfBS3TwXIlaP8kLgl8kSDl3L0yIgKooMomZjZSQlMepX0YMR3hYxr141OTZZBuM9vA= 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=eiION8L5; arc=none smtp.client-ip=209.85.222.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="eiION8L5" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7a9ad8a7c63so459956085a.3 for ; Mon, 30 Sep 2024 06:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703943; x=1728308743; 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=UIKIdrD3iJmv0MkDAQAM/afUozWyhGSMgRruKAM/Ey8=; b=eiION8L5shmgln+PHaLlNG/BhAcSjxBpQR2H3oek0y7m6rGBJ6i3LMZGqYw0YrCu+t Pk+TDL1oIN24hSsFjS4b0TXAfixB6sn0qBFZu8TdSn88ARJ1HvcNBy5Csrdnb+NALhaX V9Ev1BxQZRwGZqTHHxKnJTSNYWCUEFCQEfXaPJSSWkjmMOR4x7UJTggykZfCpKd2Mdtj dVPA2L2O++7VsUr8+6e9sEyGDcOGGHN8GK7+WZZFwHPPfKcTXz2b5J/QZz8NEGLi0XzF eKOe4lVdScNGf5w6lDVsUsLe/Jr751Q09DcV/OPl31jxSpArZ4FUmC15pAEP7pDmyW5/ IEHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703943; x=1728308743; 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=UIKIdrD3iJmv0MkDAQAM/afUozWyhGSMgRruKAM/Ey8=; b=QaKrU6Z4nZVlOiwMsGbUFEZA4AiW4K2Tg0A0wpCIVUJV9pKHPxFvQYvEcQOcgX29ZR MFKXlvnmwcBhNkF4gqA36XaZFheXeLYMV6E3tU0Vr6YN0XLnAJwAw6igCgh8KgP7Pxak GYJfpZhKR21EvT22s/7jgU7yMI9W1NOJLPUsm18PwfFQ4lB3xSjTohFnAZ/r6fT4ZaM7 TLM/odJLh/qmE0sr/IxQQ6ZhcVfh9kBRrmXDcl0Cn+EkzRqhNxA2jzzgcx4xUjG76VCg f4QjdWl2mhPDPHhtEzzqGaN/74aBZaEuGPiRcjFwgzoGjPa1+vjJhuXiA3keSKE90FGU s/Ig== X-Gm-Message-State: AOJu0Yy4hR6NLl+hwUH9aV9hYLPKMv0XIQgCSgvrRemWfK8Cz9qRt8SW lehTu1uhaFwc6wNgkOPKTwsEbrN7t+g4udOj2Ks9l9F933DvHV4BpguMCarpYwT1swKPOX45Ac8 b X-Google-Smtp-Source: AGHT+IHgN4wW+vqIUMbUKJ0UzXkh6939GSoSSXOP/HeDs6j3mIy3V2Ob5CBZVDEvj4hLdv0x+iOfQw== X-Received: by 2002:a05:620a:319f:b0:7a9:c0b8:9337 with SMTP id af79cd13be357-7ae37859ec4mr2091462885a.37.1727703943359; Mon, 30 Sep 2024 06: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 d75a77b69052e-45c9f2b6d4asm36339101cf.21.2024.09.30.06.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:42 -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 v4 04/10] fuse: convert fuse_page_mkwrite to use folios Date: Mon, 30 Sep 2024 09:45:12 -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 directly, and update all the helpers to use the folio related functions. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- 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 Mon Sep 30 13:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816479 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.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 A3C3918E046 for ; Mon, 30 Sep 2024 13:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703948; cv=none; b=t+M1vfg5CSTZBCHLT2k6FRKShLdPir1zFNK5JTzko+UMy9AXvqWCB0LJQl0ufT+Xa82gmmmPqeJXd/JpHFs7/vVoVVqKwpXHPaGG/OBXOVrmoVY3JQPVbmqg+1rDs9WgxBy24qlI/s7FOwhrpYcJ+3U7Ah8cihnpEKu4XXl1V0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703948; c=relaxed/simple; bh=QjhWXX99YcYZggtkS3ASVI5vIztmbk1Bj4ji8EO1PCo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FdoYYsliBxI0QyI4Wt+JB7tudRrSXAe7fTpNyJIs1xwig3nj9rB47GnW8fTlqG+Mcqti17uLk29qNxYUJdeEgURB0t5AqpMPRWdfqYxDGdqiU/Xz8je+r0z0xV2GHJamCWR+viFlaaqjl7/yGDiQArkcQTSCVcuZuoJ/xK9Hei8= 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=14fdPih7; arc=none smtp.client-ip=209.85.160.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="14fdPih7" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-45815723c87so34834431cf.0 for ; Mon, 30 Sep 2024 06:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703945; x=1728308745; 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=14fdPih78nUGLN0ChiSrZj7rd9OiW0iVjne/th6U/wIjlK7iLHEFLaVMNqAIH9Chab bVtMB/C/FYkYrtQbO51cAV1VhmS3F32JHYp8vzkd8nvBCcDY+F4s5EBkc/5JK7XywkGO OGQT5Q9fYZODQNIA/fqZlR7Lh9OK0jnUdc6rffNS88p1oF2htgpXhu4pXJEQs07qbMke IwSirBav48fmGB6QifFnfrwLVbcnf53W7GzZXfR1YCR0/1ECRqZrRAUgMnFLSO2BgV1r wprvRFAeROgi9koSBVKzXTGCWdiF31RI/cnbEvuYsOUF9iLajPaIC09IeUwJITgwdbSX XO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703945; x=1728308745; 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=DeZah3yXHkii30l/VK6Cy8/3Q4qRQZgOuzWXhpvVT66AnCkbgHsKXeM0CZObxTrjvh NJgYRSs4gY+ZOjk2rG6nsOMxAet5+e0aROntEMe+JksDMcTirRc2no69WXKTGCdo2DXN 35ia775xY/xlbrubdhn0v3Tij3SRH67Tapj7ipMt/IWVClftSAu2tJAUCSvuSH0w1Qpo yG8gppzyaodXxv75f9nKz3hy7PHjVM0Ta8hrsvc4HHtI8wFGHMUKSd5v+ulDrWb77D3x n0CAZNXECjomEzEfbMsk/ABjkz6BmFPNrO5deo/03mHKDbvosiHo07MbIl9YB2Nn1Eze 1LWw== X-Gm-Message-State: AOJu0YzGd/IKWzNQt+DmTjIcV7CtUm4oBGe9U+nBI0Xvdgd69Vwg8+j8 XHzxs5KSjIygk4uu+a9VZqqOTTumEZHO0LtZqwsi75fsYugsKKEC2S8uCbU3CtgwhU3hCoWpf8Z k X-Google-Smtp-Source: AGHT+IETnyyAlyvSZsPlIYriCQmIDl20xXWgkUs+n5Yuixbij1QuKGa0KLNouV6gd99ggq7XsKeJUg== X-Received: by 2002:a05:622a:144a:b0:447:d963:ebbf with SMTP id d75a77b69052e-45c9ed2afbfmr244081421cf.21.1727703945112; Mon, 30 Sep 2024 06: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 d75a77b69052e-45c9f2f2264sm36508421cf.56.2024.09.30.06.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06: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 v4 05/10] fuse: use kiocb_modified in buffered write path Date: Mon, 30 Sep 2024 09:45:13 -0400 Message-ID: <5b7dc1e745c0747e4141520b037cb9e592422dd1.1727703714.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 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 Mon Sep 30 13:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816480 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 1CA471E4A4 for ; Mon, 30 Sep 2024 13:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703949; cv=none; b=rBpJvvVC8uychhIcFDUMXzleY00QYyuH4zMCC+8wwSlHLF3Wjid7RBn9jOZW6dEf+C48M/sAGCeAVd0htPdM7poeQLNPXH2x8PukZR4KurGMWVbhF7dUEOblsunSTzOP/dwAqMaskua8fJQ/zWkBAq2Y2VbSF9Z4gXJ6rSbQpiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703949; c=relaxed/simple; bh=Qrr6OJ249fqkmKs7a9LMg35Xw1pXf2Hk8Mfn4uz7irs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ett+RGIe6Y79QK2iMxzdwsAfYHq+P/lC3XXSltPQm4iot54TQfRw+zAzN1aU2Dw6+YnP82qaYkn2mohbnuYGr/VXvOBQWt3L4LHFxSSpnMF9EGIrEiXRd4ytiu4/39nxpnDsWfdKXHlqJ1VKmrxDHW83YvxPAUaaclRa6wnaaeo= 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=YEWFSlDs; arc=none smtp.client-ip=209.85.219.49 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="YEWFSlDs" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6cb2e136da3so29843226d6.1 for ; Mon, 30 Sep 2024 06:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703947; x=1728308747; 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=xEA31PVjDHej/o795UL7q1iQP5rvE5UvcpBV5xt9Whc=; b=YEWFSlDs7DEFQqVVYbxZGRr9zKGAZjJZBM8Pp68wcMkHSw7hVAVUm9sEBoGJt2NxR2 8j7JyTUqazN9wSfeHuLZifcJ0JdJucrcZvoliO1Vc2MzGPm8YdZ7dssnMbc3Fje0xVMK Jr3m3P3m6b6J5KsL9vom1xePAMKVh5wmd6toUmI2JWxCyt1GWit22qEEHSGZ4XF1w0NG DS8ye0ghKtCRwyRR+2ETxpHGPslKdfbdTeUIPFmNM72XkVkgRMIzVgPQ2bq32S3n7HP1 GbQjtgDOGEtftuFdXMlWZhEgR/XyvPFcXcUZOUXRv5svKASEmU81ywnOgKjgIUGFjlrR QsdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703947; x=1728308747; 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=xEA31PVjDHej/o795UL7q1iQP5rvE5UvcpBV5xt9Whc=; b=nRJ9YmNsya7f4nPe4iKMZKFmHHqd3wP97w0Shn5xRmvnIGdKiar+qLxoDrouGECnUy FAVtVXdLcoDF6ZYFSnL//j8NTAt+n+CqkUqMsK3G53ugOwMjSuL8HqnCMe2lrOpaw8Jy ENwGCDqzdUgZ58lpKZxWoBTgg7UXi3qizdSPrzS5867PiUABvcTAv1/Yk15uydLszRop 7mii52Druv5ApYW7Z0luFlmLvlSXaqzRbEPiS5Fn5mQwitaIyIo4KKcm20g+ridpRyGT D1FMW9V+V5fmi/IybQ6qsV2pTmm38SafK2Uk1/Zk1ffYBO0uLNU/TbR3qvqqEt6h/EV6 HuSQ== X-Gm-Message-State: AOJu0Yy7ZQ/4ROvfX0g6hfRjsSr+SgB5N88dDexXbgl8YLf8t0oMQwky vl88U/+qgdoBZ0KxR+uIdceEWRjBp2xdlQ4KbF5FGFPZYPTYsLFTfXl6lFUAUvYdYK76kBOHkoQ I X-Google-Smtp-Source: AGHT+IEF/0YwcYQNLfPWvZqhNmRQXQ5JbBaN0rwp67tpGA/hJqJHkmvNa+VM9ZuV/6GZz6MTVMsBDw== X-Received: by 2002:a05:6214:3d13:b0:6cb:69dc:9923 with SMTP id 6a1803df08f44-6cb69dc992dmr35526886d6.41.1727703946731; Mon, 30 Sep 2024 06: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 6a1803df08f44-6cb3b612ecfsm39987916d6.55.2024.09.30.06.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:46 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, kernel-team@fb.com Subject: [PATCH v4 06/10] fuse: convert fuse_do_readpage to use folios Date: Mon, 30 Sep 2024 09:45:14 -0400 Message-ID: <17ca5aafb5c9591d28553c8af42551c8bc23a9ef.1727703714.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 Reviewed-by: Joanne Koong --- fs/fuse/file.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 2af9ec67a8e7..45667c40de7a 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_readfolio(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,11 @@ 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. + * With the temporary pages that are used to complete writeback, we can + * have writeback that extends 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 +898,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_readfolio(file, folio); fuse_invalidate_atime(inode); out: - unlock_page(page); + folio_unlock(folio); return err; } @@ -2444,7 +2444,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_readfolio(file, folio); if (err) goto cleanup; success: From patchwork Mon Sep 30 13:45:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816481 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.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 B18E018DF9B for ; Mon, 30 Sep 2024 13:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703951; cv=none; b=SvSacknqkPxWIlIuNIU6+mjVjzSbLh0IhI9lfyc0XUhgSsxhaMyQsinMETgb0SDWKZ4q+RbwA6Hxpk283XpDYmMRPdVG/HrtQ7VT5M6Q+Upu+SNwSSj9KUEhzxmuJV9nUpFEbe92EnntRAheqL3GLiWCKZT1yk5JKt/q6eOIfMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703951; c=relaxed/simple; bh=hxIdkYJbYaGmZD4/VZaVql3VRw40/UEU587zIk9dHqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FKnW0U7FoSleufdlaVOY7P88AsgqW78Ve3y9AzYEp0VJxB5v159qo3gQCaxMicyNlqfiyp2tzUhXL6/EGT/b9VbozZt2Bz7QbFDeT+lEvIJRzDRkfFz7AZWADdc5gBPmcm7I11sQBghiOrOcFVpbeUGwdiKJ9TQaEKUuv1r4SkY= 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=wgq9fZDW; arc=none smtp.client-ip=209.85.160.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="wgq9fZDW" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-4582f9abb43so32479621cf.2 for ; Mon, 30 Sep 2024 06:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703948; x=1728308748; 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=FacLCPRk8JOpjY0CME80CbB0FcXhlgP3XFZb3CcxNJ8=; b=wgq9fZDWjd81JHXWt0Snf//QbU9To8gOGqmvOMCds2kL6g3boghyDIAlXnTK02gMh/ iH/lLChLpmiOR3+S+v/fFSDMSb+fJlG1FdR2UQY23zYms3CCFCbKyyYJuv2MewRFzcGx FLrWHSv7PrG0ctUQzOS4GT6gMAuEJX1wRcGMQUMhHyhiOvOhCGHPmZvNbMc/RuJjuD5X Rh9E8K2w8Qaw2f2j7Eiyw6mywhEF5lnPqU5sdpjBOgZ3Su09tnwY07svxRC2wHJSXLqa 0k1MJgfNOAUnPWU8g0IduXKyLa/Q14i60zWjkzADeqGSCTf7+9u01MfifCxDHK0O5Viu ClGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703948; x=1728308748; 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=FacLCPRk8JOpjY0CME80CbB0FcXhlgP3XFZb3CcxNJ8=; b=i1ft0DvN5bFrRibRL+dFDJWBrbeZZWkEqg5iJOCMI8bnvqpsoSoUKC2JewoSlfqql4 UEzAKUdvvNv/IMm7yZwHQ/0/TjGUzMT1YYaHkDstId6Wz/ZoX4wMPk2rZ2CmjtGH9lYO lUNxvd/PIpWwIRCgVQxbKY5NJo5bYrrCqwwBGafmODhNPpDSTQiAaIaFPOSG708tnCzs 2fmbUGUF4j8QwUUJEnnz9pRXJrpK0QTcgEYKuiU2j6giVxL+0HTTlRX1GyOstUy93KIs vyL8iBRf6MxJyWRxHe4VTzamQckNNlU1b3oauAWXbS99RLVHuIuoJUORCwDfGhGAWVxc bKgA== X-Gm-Message-State: AOJu0YyP0pZiu7tFRRcHiFqcqI1GsxYoDwmQBHBrj5At4Kv68nl7tqYk ucu12F7HzYycu2yDk15ab0U4NYx270XQpmW8yIiLR48mNbjZ3XggrTbptFn4af1BRBdQR6pOzO6 y X-Google-Smtp-Source: AGHT+IEQqcKSCNXyO83RFf8J1ELIDGRzWPVRT8FRWQ0V6r0J1toz4rCbZUrcq10LxonFj8nuIoA95w== X-Received: by 2002:a05:622a:11c5:b0:457:f8b1:a042 with SMTP id d75a77b69052e-45c9f2258e1mr208962061cf.33.1727703948152; Mon, 30 Sep 2024 06: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 d75a77b69052e-45c9f2f2264sm36508941cf.56.2024.09.30.06.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:47 -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 v4 07/10] fuse: convert fuse_writepage_need_send to take a folio Date: Mon, 30 Sep 2024 09:45:15 -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 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. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- 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 45667c40de7a..33f98cd27e09 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)); } /* @@ -2263,7 +2268,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) { @@ -2275,7 +2280,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 */ @@ -2287,7 +2292,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? */ @@ -2309,7 +2314,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 Mon Sep 30 13:45:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816482 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.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 1831317DFEB for ; Mon, 30 Sep 2024 13:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703952; cv=none; b=p5LpbiuSM+7p+/o64fnAxg3Y50WQ+B680T/VnmqfbvoTF70jPBAyPd9e7E4DynbFXKxejP47GE+KeMtGPkg/tef962fBFFY+cj/oEDhg2lHWBsfzNxe+1TplCITAVKOXdonTgAbbK2bZHMO1RtA4QbyCzsqYWDGWNL7sLXKdhAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703952; c=relaxed/simple; bh=qZlCjnZHu78Ye80wR+W/hA25QQcmF5a5SCKL/DpTXZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZfRdUc1aKSIz9psx/NGAxVvAeCWhPIwOcmbUi28cS41VKPVFlw0YSDqsQhYSFN5gKLJ+m2n4fpN5y/krljPrZ/9aL1ulsMES5dSwCKtuABfnSsZvdilf5EaSHNlkdhT9bFdqf5bgrC0PGBU/jX8xH7sgcQ4L8xHNHErreAAcEh4= 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=ObiyKQxk; arc=none smtp.client-ip=209.85.222.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="ObiyKQxk" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7a9b72749bcso394688185a.0 for ; Mon, 30 Sep 2024 06:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703950; x=1728308750; 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=q5PR4giWp5I+DKzF9GTBZufPl+DFduV88fR38nmYw1c=; b=ObiyKQxkbYyhk4tyoUZq1VRegE/d5xy1LeqqZRlfeQrdcSLIB/x1NTqoRM2zh7dg6T Mdkn51G4APRZundRocuqxF0ZvzwPGZYUBAKRt4mNLybvU4TIvv8uZNoDn8OhVdNTIw9w gzRmLfxaA9wfcN/3JiSNzrRZBZtnYpOhmrWtqGPcOzD2O83wthf5IhptL8z8eOWnw9kx YGeRQ1QRDiilSG7a8RZoP+HnRQn5tSlDBz/MVR3HTgLrAaz3z2afX3s6FTMSEBX/yzWD l51KJlcyj/xhmmX4cSZimEfuwTHyrU1nZeV0Q6pd6f5xUPLetrNHpGcDCH3gvn+7k3kH T3Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703950; x=1728308750; 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=q5PR4giWp5I+DKzF9GTBZufPl+DFduV88fR38nmYw1c=; b=OO9aBoUy7htEmT+4bgaHcNuIdkCW5E4gvj9UG2W3bITy9UvGJC4PW+jh1FGYBK6Q5h 62h8C/lVeJta3clV8EdDkDZYc1ybq7OuajYw2r0dzRw3q+t6yEgujYoHwBObz6j5NLFt K/eATavfYMXdVxJgEdT9rZ7YTW7fsoQVYcl3vF/OSsHLeNNPrfQSbUpCVvQe+L1IL6VI exzUhGxNXSDwnlkrGWOzJeUvTiDiCLN1JL1w7mfAYHM5prkC8FjeOIYditXNys/QU+Hl Po5HUqare1gOA1u9HPMUc2R4Ozzxz9N4hpfdSN/up2qxdENc9x4zphyWTJVgkyEz44Mi 42kw== X-Gm-Message-State: AOJu0Yxk5de3+lS57F41NwpLJ127zsqL9L6kC1j23pREqo3VAE3crK65 3wD+ZsMw1IastXeJjKmKKeWTJRcqAX3TUu9NphG2bkfExIKlBy13ouU2N2XwbQ2gNSSF1Cwcbah q X-Google-Smtp-Source: AGHT+IHwvH5WwzaI/3zOkYFgiISfNqwSz60DrK7nvmT/gYx+SmHeyDnETMxE8czAqOFJRiGfgJidXQ== X-Received: by 2002:a05:620a:444c:b0:7a9:bf2a:d7c8 with SMTP id af79cd13be357-7ae378b4f50mr1867804285a.41.1727703949648; Mon, 30 Sep 2024 06:45:49 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7ae37841c2fsm412466185a.125.2024.09.30.06.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:49 -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 v4 08/10] fuse: use the folio based vmstat helpers Date: Mon, 30 Sep 2024 09:45:16 -0400 Message-ID: <44643d2bd0fa21575d9d7aba1355ac88bc02944f.1727703714.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 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 33f98cd27e09..dc701fa94c58 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1795,12 +1795,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); } @@ -1812,7 +1812,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); } @@ -1867,7 +1867,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); } @@ -2087,7 +2088,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, @@ -2261,7 +2262,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 Mon Sep 30 13:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816483 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.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 5ED1D190471 for ; Mon, 30 Sep 2024 13:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703954; cv=none; b=JoaTZHQY1VESyEoMAfqRkXQbz0YjOdO9h1qabfAe/ZsxfrHmEljCSrvDPYuIuXm9c/VSBx+YZSVmi9zTVXSC005cqOevOGIV0It5uizkZOnM+bw11/bun6o08y4MUeCTxV/q+FVIRqURIB7HPcQIqWVyWVGyuTVB1AWY/U0Twa8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703954; c=relaxed/simple; bh=ms4yYgL0E9iyFXWAfAhYgK4KaUE8et45BfesbrUOark=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rcs7oV/eXWCxf2i51+Y8kZp2VQPXl2BcUzVZ07IafGfXrhv7hAYtPB6NLCnpr4mIJ+TAL4WmAkDTItzrLWcGtjP7m2XYqv8h7fSK1sYsr5fAH/P1nfM3G39KRv7qGGdWPuDaMPCIIyNcRAMBWdoP9+zCHH7xM81PW6zL4y+HC1w= 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=dRIZRh0n; arc=none smtp.client-ip=209.85.222.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="dRIZRh0n" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7acdd65fbceso365790785a.3 for ; Mon, 30 Sep 2024 06:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703952; x=1728308752; 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=14HFQdB4kShb1FL6dQLgu7eLq4rRewlARylk3CgabXw=; b=dRIZRh0nAzUoeXgcbR6fIclmMEb4tL0oQCKuIX80QpjxRJdoq6iaqNM4YS2/wL4dO9 AoODZkwhZadqbvVunoxbPAglFHIuZQHI7F6UxkcJGLOurlyIAaqgSNPlH8TPbSX2BNWE U8pRi+bvlbsxRWCqwhjFEV+U+AOL8N5Xbv7zy9Q4gVdPZZFgyIZg95D3F8i0m5KXK5Ce zeRacPq3cVETEuN0Cq8i8KkUa83B1/SXLfbT+cT8agc61O23D0XAoahp37f8ogme+5XZ saOp1guvMYku6mps7Luv2pDUhrtxjySZJSUnNGGF4dqQG17znsw7+K0WRhq0yzZckiw8 js8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703952; x=1728308752; 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=14HFQdB4kShb1FL6dQLgu7eLq4rRewlARylk3CgabXw=; b=ImPANaiAVEb1nbECL4k888PFtuXjmV7S11bYFIm1jrykl1lK/bskV8zuxK9IdaNJPB WHrLRtS+liU03JYla3nzC0bMepJKWmQw1d8HVEV+G06nhRsmGpRFP0I00bnaYkMX7xuJ xyF+PWBxGkFqE3wYEHYpFqewiddQ2IG/qC63PMdGrKAsGXsiMB6L7kLBg1GmLQhp6N3z 9zA3A+2hjtBFLNlC7Qs6knbz2FgQ6hKeYZXtBO9amH3Wr0BTJcLlVoA+S88V6DGYdWkY Ooevdjpxhb6goMYga5IoRZXg4W9r/y3EyK/9OXek8W+p0g8J1ebwM9FU7OpcJMLUgULx 3x8w== X-Gm-Message-State: AOJu0YxTavEFvM65LSQGExEhufjNzd8py0oraHvT5RfV5GSBstRR48/l nsYdXeT8hFDxvQIpkX/410Rv+vIGo4BG8upWSYVLOnH3b6T6TdoDHdMyMscwXpEa03vPZa8gV/y Q X-Google-Smtp-Source: AGHT+IGRB27P/2NzIFaZtLeRDJvEJRcMAJBKbSKZCFg+yMOJGXyawp+l6PRTWUJ+7Lvv64u3/7MrWQ== X-Received: by 2002:a05:620a:471f:b0:7ac:d673:2057 with SMTP id af79cd13be357-7ae3782577cmr2523901085a.13.1727703951581; Mon, 30 Sep 2024 06:45:51 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7ae3782cd47sm412422085a.79.2024.09.30.06.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06:45:50 -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 v4 09/10] fuse: convert fuse_retrieve to use folios Date: Mon, 30 Sep 2024 09:45:17 -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 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..a332cb799967 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); + 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 Mon Sep 30 13:45:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13816484 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.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 AEC6618E02A for ; Mon, 30 Sep 2024 13:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703956; cv=none; b=LpT7ooI62z8qHlV/MfZvMG8NslA7jLl4jO9Io2Js7G+REPHnEzS3ZjP2mkjJymlIacAtnx+XLmjn6WH2f92+QzbrXpEaILcryD8iZ13jcukiWJ8Dx61Ea1rET+pMpaqDdHcHzaQxI6nKqy7dV+V52e1c4d/1mgrF+jSyMIvrnAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727703956; c=relaxed/simple; bh=3yoAzpc6x7RiKepbAWzbPPZl/rfOMuOQW7PbDw7hlOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rrnqio0XtKsjY4SYX6DaIhUTxfwkJNNGyRLLZZMIp4K6xgsERcZj6GXk3N3crimVBxy1xP0K8Q23maoOZK0yfAI79sCUW5NLOjFVfFQ/IQMQOK5GLWQMXv6MOM8ZS11oZ73JxJmnARSPTe1XsK9WLQFQhshERB1eMC9gj4dBMRE= 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=zKRenhHC; arc=none smtp.client-ip=209.85.160.180 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="zKRenhHC" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-45812fdcd0aso47513041cf.0 for ; Mon, 30 Sep 2024 06:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1727703953; x=1728308753; 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=QXm352ZikGGcWRy0f758PDXSSrckconTdtleB82mBFs=; b=zKRenhHCwutukpJ1uOjElYd0X2FAsrOHoTfZU2YUrQhRsjJIUmaatvpL+xyYmZq5ty ZYPOTkGAZw1RUT/6/oh/0DzefMXc7SIIVVZoi0tNix4W4oagshOJy8grXw+QFjYckKKE FdBokLK/tdpEaD/nk3fvEyQu2jx0MfR1OCR4zO0x1hRhAVsHd7nosEKRw8gXFSX8WyhD Wkc7Ms3/tiBYzue5/H9Qqf15dFyv6LZLTh4fSsYMI7VGwJtPSQ8znQo7kb7pLfp9xzvJ /GG02hrHyTcNi89ftJ3U/xSlkVbpieITqR8dPie8SgY9cfiVuxWbETG0hAjG/AU8gyA/ elXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727703953; x=1728308753; 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=QXm352ZikGGcWRy0f758PDXSSrckconTdtleB82mBFs=; b=nK/2x21HzqxesYikNkdSOvBU313QTsJPzMi/iBdAumAbNM8PK37nu+5xFgzUMDcGWp XwE6KXmWNFhwOjfL5PUiTXgp3O6qrv5WyC4TJat9sEDkRBZM2yCOTECs2qlGpIoeK5yD pyMMCF17OvfO9ZLOsa8rbzJfpQCp9u9u2bElUqxHw6EU9xE5hZMccLO/RipkVflURt7Y ae06Gcp6lm5WQ+RZolG+u/kuIVmK1VtugrBdfrn5mhzgE/JmJj58G/VTuQQwUugWxNHe rpXHks2N9w4J/ehdRAwE/gAvPDD4SDAAdDsW9E4wsGjYUl0deUZaictFkA17WXjZ8PZH GLiw== X-Gm-Message-State: AOJu0YyQKRzXcn0cHgvReXfW317u3uWQ1ICjzX79wLrG8xqtS5la3tBa YZ15OOrHYqlRwWjodn99we+8rpysETP8bdLi7Wu6YalCKebngncTQI40u3bXQ6PaHNExneGpNwT B X-Google-Smtp-Source: AGHT+IGMPE7B+bd8DIU6zTUjipwGbHHQXTwEtVUV8/xm75Jgana7gCtHE03z1iZ5SdOP56PYa7mmJA== X-Received: by 2002:a05:6214:d0e:b0:6b0:8ac1:26bc with SMTP id 6a1803df08f44-6cb2f2832d2mr263806366d6.14.1727703953118; Mon, 30 Sep 2024 06: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 6a1803df08f44-6cb3b66b0adsm40111976d6.91.2024.09.30.06.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 06: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 v4 10/10] fuse: convert fuse_notify_store to use folios Date: Mon, 30 Sep 2024 09:45:18 -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 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. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- 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 a332cb799967..7e4c5be45aec 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;