From patchwork Tue Aug 27 20: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: 13780114 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.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 49560155725 for ; Tue, 27 Aug 2024 20:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791579; cv=none; b=JEAjMC6s009jhl4UIz0W4l34bIuTS2F7+WpzYPRuD+/c4mD6A/rxOsvXl6tnso9Qv0lw5z8hPSoAqZq7NKpPW90ERwXjg/agyRrmBGpX7dRRsysjICrsMbHi9Lb3fmsnHrLerM5NA0W8HiCY6tyVz/c8V2oL+gNz5Jje6phvd+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791579; c=relaxed/simple; bh=edDSWxmfXaCuzTueDm86Jp/cUZmwSPmPkS0s549IPC4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CV1dJq51o59jQcA5VakoZQMnAcIQKwFHycP/pqKPbnKUAV04veEQIw0AbIeu/dH9BTxcsBPNUCTXbunGa1UfSRkDkeE5C0HEi2Jy0MKhdNlFc7jNXxnRRc8+ee1zCb5bHTOZMO8pRpaGrQ8DIAl2c2RI42dcVF8YSXUOLEsdQZo= 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=auAqS6Td; arc=none smtp.client-ip=209.85.210.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="auAqS6Td" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7093d565310so5817408a34.2 for ; Tue, 27 Aug 2024 13:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791577; x=1725396377; 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=7qc93bZuLUuosBEzFDRporb0v/ZZ56YN9E5pszTfif0=; b=auAqS6TdnRLAOdxRH9sWcrJbw6IcLZUQbruBJUZKBrfeJSUQJgXAqec0tvl/D0tIb1 wlhXDyHH51za/hNV9q6I1Mu3S6P6Hfd97H9o7T2MTXt5uIVYAZHggRVkKFpxGp+izJ98 Vi3WjfH1AgLmVL3hV7QtgnDW/G7mDzMJRp/q4RDutmqPElyzSXf2si7sBEPHVQSEi8Mg P0jEp//V8BZjModjPi/N5drItPVuqCGFCUuycM2kXrv7yzL+MmeGsdJwrbQ9xpOsidyU 1DB88kyrbsbIBwSiH+UaBQ3t3hMFvLhwWiAUW1BOZJuLwqYrCAdKrHWZaxrV449vHiAH OSHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791577; x=1725396377; 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=7qc93bZuLUuosBEzFDRporb0v/ZZ56YN9E5pszTfif0=; b=SxuCV6rMQLeVSJ4cuLLaWcb+TbKXX1XYe7LHGP3CAc6JimjRoyrRfXL4dph7qNBeu5 PKFa9lAYRgu49Bv6Mn8sPLOLkCmWqKQ5aemVvRZeJHLDTFlpcGDfNV5O/WdNUPFSreVv xFzw2Sa6JR7820gmKWJqaG8ID14l4lk7zx5FcCaHewccugYYC77DL3H3uAr93pPVoDPU p8jo3SiBJbJyIfVE8wUBcTnPl2Fm6armKIYGhvVtjksVl2yixNek6FDadJZVmZ5zPO2C u2HhYkf2Md8XUPoFsL5nIjWdfSWLQYTSG4jppABo+GPOQ1KILQ6hIO7fLB/ldL7yub6m AWUA== X-Gm-Message-State: AOJu0YwTPsWdzspnBnch9LnsENgZ9a0up46ClA3GdEPatEItswJIRa53 pmz2rcrXLitf7ARwmzHUbDNPTAgAwKloxEmR82y78bodACuXOHWAR4sRlRi1Z483mPkWJlV8YVM + X-Google-Smtp-Source: AGHT+IENPUvB84YZtY7Bvb9o8iXddgC6wS1XobOZTIhMzEpdOVXn9GHSkkVMrjrGWY9BC197c1a47w== X-Received: by 2002:a05:6830:7106:b0:70d:e5aa:38af with SMTP id 46e09a7af769-70e0eba82c0mr16144556a34.11.1724791576676; Tue, 27 Aug 2024 13:46:16 -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-454fe1b2825sm56277501cf.80.2024.08.27.13.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:16 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 01/11] fuse: convert readahead to use folios Date: Tue, 27 Aug 2024 16:45:14 -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 | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 88f872c02349..5024bc5a1da2 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -483,6 +483,18 @@ static void fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index) wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index)); } +/* + * Wait for page writeback in the range to be completed. This will work for + * folio_size() > PAGE_SIZE, even tho we don't currently allow that. + */ +static void fuse_wait_on_folio_writeback(struct inode *inode, + struct folio *folio) +{ + for (pgoff_t index = folio_index(folio); + index < folio_next_index(folio); index++) + fuse_wait_on_page_writeback(inode, index); +} + /* * Wait for all pending writepages on the inode to finish. * @@ -997,6 +1009,8 @@ static void fuse_readahead(struct readahead_control *rac) for (;;) { struct fuse_io_args *ia; struct fuse_args_pages *ap; + struct folio *folio; + unsigned nr_folios = 0; if (fc->num_background >= fc->congestion_threshold && rac->ra->async_size >= readahead_count(rac)) @@ -1006,7 +1020,14 @@ static void fuse_readahead(struct readahead_control *rac) */ break; - nr_pages = readahead_count(rac) - nr_pages; + /* + * readahead_folio() updates the readahead_count(), so this will + * always return the remaining pages count. NOTE: this is in + * PAGE_SIZE increments, which for now we do not support large + * folios, but in the future we could end up with 1 folio + * covering multiple PAGE_SIZE increments. + */ + nr_pages = readahead_count(rac); if (nr_pages > max_pages) nr_pages = max_pages; if (nr_pages == 0) @@ -1015,13 +1036,14 @@ static void fuse_readahead(struct readahead_control *rac) 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 (nr_folios < nr_pages && + (folio = readahead_folio(rac)) != NULL) { + fuse_wait_on_folio_writeback(inode, folio); + ap->pages[i] = &folio->page; + ap->descs[i].length = folio_size(folio); + ap->num_pages++; } - ap->num_pages = nr_pages; fuse_send_readpages(ia, rac->file); } } From patchwork Tue Aug 27 20: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: 13780115 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 B87F01D31A6 for ; Tue, 27 Aug 2024 20:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791581; cv=none; b=bKqTepCB19b1eCmNnxJzf2o9f8mWuaVBbAG2Dm9LvvoarxV/S6oYkcNiYhr9AKqRSNzx4IxBFmVd529uAKlqWp6ddqlaKgOSVkphcyBv8dfrG97u/2KMk2xAMddEMRkPzYsJvj5tINi0dKSN57g2UO4VE2OdAQkGZA9/7m5ukkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791581; c=relaxed/simple; bh=zf7CAYwSiTrsY7gSvm0A7Rd13FskrooCxwz2ZkyvQpw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tAQ6bbMcGB02RQWAQXhwaDECAzvU6I+bvzqMjaWI9zT+87AsxLDEGvEX4ithVQJ8Xw7VDgsLUT0WHsUwB+M/7n4qSNtPRmwgMbaLouuiQ4SPs+QQAcKB5d2qSP+1ZMmEJIHgAI+1csksFgqdnlF45kkxVRMLN2G3421JeHJooSE= 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=2Y42LbmC; arc=none smtp.client-ip=209.85.161.46 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="2Y42LbmC" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-5d5d0535396so3553002eaf.1 for ; Tue, 27 Aug 2024 13:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791578; x=1725396378; 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=UwkWnqVqcG8mlXDcVaMcok7qIAsDjfcCpuOxNl0BDGc=; b=2Y42LbmCDFInkLtRYrGqZNXTAqNgaoiLRxvuQd0vV0HzeMfv7N5DY041VdV7uVm+Lj VwWQNk9SrAFG2EPgyCxM4DYm96KAaCu0KBinhachc3D8h8ZHbH0U+PcKa2EHQYJRiPfv GkB9/pzXFx9QDkdUla7tGtALDjJCfT9AViFn7yNBdkZkBobtfmAbFsDlVZSGVtUAk8BZ +qX/RdbmcHZWwmFg3yNiTTyxb+MKpZ3wMBu9YXYLCTFra7NQD9x6G3BxU6eXeZ80278m 9OGWAPyxunmDSzaTRx8X8SLFZ0GzzlDVQKBY6xmZ25gy10cczlV4Gv1k2i6a/oTmOnIj 6slw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791578; x=1725396378; 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=UwkWnqVqcG8mlXDcVaMcok7qIAsDjfcCpuOxNl0BDGc=; b=k/dJ98DwFvauR1tG9YRno4BiA3mTIxKKHOLAt579Haam36eh32Sz/um8pM7FTn7Rxe +Wj/JyBeJ8Fc6+2Wh45BPgihZyoNvwD4UtTb20NPtyl4OSdRhcgsW0iNyY38SRUMyLkE 0LAxOJEZRL/++CW8krop8NxrBWRRFgvgRLeUA5rDrxr0mZzkewcF8DipC1q29en1Lqt7 ++ia40WC0G+y/vQR9nLgm+25JjSf9WD8S2R09zBhYP7WPKWOzUGq2Rh7OX1Ehgir+7ZJ hbv4tZ7Vgiqwu5knGBRWV2+UZ7DGeYP/H4OpQ1bBL01oAuqQR0Vd720jIjnQggzTmcll 9Vgg== X-Gm-Message-State: AOJu0YwAEv3FsH8Bj9ThYGV/myA+n9shsG5vI0R/lf/qIhIERJW2O5Jg YwI8FkS5C0zL9eJKQAmAOpYslKavK5HZoUH435SRCkdjMXqfGV+A9VSaOi/meVcZFWC6k2IfAy3 X X-Google-Smtp-Source: AGHT+IH98Xws88C3qE082Nb7OYcxsPcp8sZbHOnj6upWEXPKnZngH0vETetCj3XcESCmI0Pdhn+lEw== X-Received: by 2002:a05:6358:2824:b0:1aa:d3b7:765c with SMTP id e5c5f4694b2df-1b5c215b266mr1617292755d.14.1724791578357; Tue, 27 Aug 2024 13:46:18 -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-7a67f31b2e0sm584949785a.16.2024.08.27.13.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:17 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 02/11] fuse: convert fuse_send_write_pages to use folios Date: Tue, 27 Aug 2024 16: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 Convert this to grab the folio from the fuse_args_pages and use the appropriate folio related functions. Signed-off-by: Josef Bacik Reviewed-by: Matthew Wilcox (Oracle) --- fs/fuse/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 5024bc5a1da2..3621dbc17167 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1177,23 +1177,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; 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 Tue Aug 27 20: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: 13780116 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 244521D362F for ; Tue, 27 Aug 2024 20:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791582; cv=none; b=EU2l1Vl3u4VF4NmQNG5x4Yk0L3cdOMAeh3IwW2jc+GbesmyGGCtOfa9ooACzY2gau74xs0PqvXHIBvHXSOFtOwPjSeEYICirmJ6jZzHR6wc/tgCNuq/J3fGFan7sIJknZT2o3rtGTkw95LCGfwel77FOS431v56eRGl4qfZkMlo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791582; c=relaxed/simple; bh=h58GESlvRDXe3ek+F5uc9f9XUaRxzzp2bcTjgu2JQmg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rhp9a3d+/RADV0k3Zd6ywrvfG2q2G4sKo8lTNse2CDAqDQqlzlV8k5FT8ulShei4vPKqDy2+MxGjE16zRD1b5ugxioX15/Mg1/MYjd87QM4CXxJ5oUO6IX57ha27mn/2mzC7F7QpXEJ+0UiX3Uew+efU9fsq4n06Stb8XuHXdYA= 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=jQkIUcmF; arc=none smtp.client-ip=209.85.219.47 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="jQkIUcmF" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6c331543ef0so4567136d6.1 for ; Tue, 27 Aug 2024 13:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791580; x=1725396380; 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=/7/dxM1vdkG7vAtlLLf0svhtr79HXDwZ7x9Bq9iwmHs=; b=jQkIUcmFRZLg8SfZaUtUETYkyv3dAEQXfSFyFsezCJYphlMkdv/3u0f97/HTB0r7hN SRUrtCL5wCk3l07qxo7GzQ3CBfa87nLEphYnrKjatpcbrwnoAfRfz3Me37fLFXTxefJS BADuU+9j/j+YihutTdD0LPRAhFANyaqAkmThQpfTKqoADFF5Bk7CMoZaoeQ5tK2dBfjz AnnDzfmtJrn+ZErUVpTuqlmRsTKLsDRUAhb3z4PPfKV7cs2pWBTYwNABDSpVfQCPobjD AYdkS4FrlJP2dAzxkprEr4sM5k90TknfU9m/7whKdfdWnY8wEe8KB1wX8wtYLIwOjwfg neUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791580; x=1725396380; 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=/7/dxM1vdkG7vAtlLLf0svhtr79HXDwZ7x9Bq9iwmHs=; b=YJb6fHj8uax2Sx5ZNk1dm2H37WaJpTMpxaZX4kglftABdJBAcv+sdzAVraH+b2qPGW t8QYdAsjyCrkw7CEzx0jEnHV4xRcqCeMOlMznh9h/SlgqB8tmRPAeIKvFbf2voXmtqNW Tjdz3hD+5RqPbyWAAHCTGmnQZKeYCHtRghJ4WHRlb7YhNc8QVYqJ1mWXczPgCjhQ2D3u MSwUahj/QRfnbjt5mECIrkw9TmpdW+cyEokdXPQ7N9xpsNp0NOU99Cidrq+VvlbsT6NZ hncCU9sCNbU/P6NSwydVs7cEMkwbCn14wSmz+wIicw0PxbdW6owdWs4tnzJQfjgbZMmH C2wQ== X-Gm-Message-State: AOJu0Yznhbhs8NyW1a6IpsZCFMgRllKfWXYD0JZqyH2RPUSwM3UWoWyD UTk2y/rE9XvmGi7bzHvBnqgAYRVQi3dV96W5bEGJ5rDK37qzSnOQKaD+o7m8KpQ06MDokVaKHEM T X-Google-Smtp-Source: AGHT+IE14pMb4e+Cu7xI7Vh5LxEeqffr1kHb/nkuJsWgLci2vq8HX9hDaAp4bTh8pSN19NR345KjEA== X-Received: by 2002:a05:6214:2f90:b0:6b5:def0:b60 with SMTP id 6a1803df08f44-6c32b677f6amr47681866d6.4.1724791579661; Tue, 27 Aug 2024 13:46:19 -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-6c162d216fasm59240236d6.22.2024.08.27.13.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:19 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 03/11] fuse: convert fuse_fill_write_pages to use folios Date: Tue, 27 Aug 2024 16:45:16 -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. 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 3621dbc17167..8cd3911446b6 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1215,7 +1215,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)); @@ -1227,25 +1227,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++; @@ -1257,10 +1259,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 Tue Aug 27 20: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: 13780117 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 6BA1C1D363C for ; Tue, 27 Aug 2024 20:46:23 +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=1724791585; cv=none; b=dt3jFopa3SG6q2NEQfvn16opxs7bMEibv7lyUIPaUZgyjYqFFdd8P/8BHvfh8t7pFpkdp25EzauWvlCkQKj0PbTF9nJJc77YT/KXNIRlhnBRzwzBZlxDGIFoqpgkclYje341XiRTVXB5wadcjCuzLbVJ/IeWmrbkcdLzZhAfS/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791585; c=relaxed/simple; bh=68tGStDSDr4B8RKeH/KjbTEzVenYeDClVq7NfNM+F2s=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BlHwW/T+Fq3IS/n6hvpm3MLR/KNZewRg5JpM0gvbXVGKzO2MoVeVx3NpeLstUiVcv1UIyTSjTjDjWsJx1cVXhf3NG2xeSVdoFUNbI3jcng0GZUI4pN2rTC6K8ZTJTbJmgjNRBEEXcO0L6zlmoaxeBExiDdolKHDkpM0yQJkXMO4= 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=b6l7dLO7; 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="b6l7dLO7" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6bf7658f4aaso31385706d6.0 for ; Tue, 27 Aug 2024 13:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791582; x=1725396382; 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=Vs1wV5bOQctoxrXYwauzmoK2OAvZj6QgRF9kCz24XjY=; b=b6l7dLO7d2NyXWx/8q6ZEttJ/ZV2ixRRV5EjN9S4lGiv2/1VN5IpeMa6QTS5qlzJrq a5Tt+5sJX43pH1sQvpRYKty44434+WJ8xH1V6+RAR6mlmF3Y6tMeSWaJUt7FjXJlApqP JqfAQY7i+i1SA5CiDXt67d3eP0ye63wEVye044+ZKupifZdj+N+CE6ig/Am6DMFXKvt9 lY5QM4cOkY5Mh6Ex1k5YDPBqQy/IkbGPH0Un8RkvSrXuFFB94KS2w6aOAPhULCN65PJV VPcXnUoaEDy0OCyJkxgYLv6Frf/3NCAgZI24L4xdI4QsTQbU4tRkdMWQra3Gs8FCZFQk SabA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791582; x=1725396382; 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=Vs1wV5bOQctoxrXYwauzmoK2OAvZj6QgRF9kCz24XjY=; b=Xmn5Kh8mtvBbQA6Rbz7tVUfCdTRU66vz/Uk3p1SwKQIH65KgEihpuKPaNzppMMYNvi QAQd4HW6rb6YSRkDQOxK21LqRp9owhvYz00uAmh5n+oczmPy2DzzPRZoztuFxp55I71k HIzKpkvauG6gF38FeLbgZjNQhbGagh6rOZ6Ds7zOOophXbZ7PSeZV71PG+D9Ds+WbWuW LBXUaMrU3PEcCpNQYbCBJSj7ixKvlHkstP7O3Br636Lw07+WNp+jbzw5zunuhLgIl/ab l9QIjKAltYDTKNTTGkEL3XKDMhmrYwbpTdRFSQ49IWymrFiidSrBf5L4/ZudrPw6p51/ Yjnw== X-Gm-Message-State: AOJu0Yw3l+SkYpa5ogkxwqblc2yzQHjDEWtfCP6SEjXfSPDjd/8JR2P1 1uq+gPCcRslYDXGqu1g7WR+wyTuSXYQHaT4jxxA7r8JbtSIHrn3IzOkqO8Mk9poZET04MHd0G61 Q X-Google-Smtp-Source: AGHT+IG+qlqHgHHFueSkGn3Mpz+5wodyk8UOgG4RjhEPTZyoySHysR+g70Vx4+Z9dkC/WHLClxTwWw== X-Received: by 2002:a05:6214:3205:b0:6c1:5546:8acc with SMTP id 6a1803df08f44-6c32b677e0amr58190326d6.1.1724791582084; Tue, 27 Aug 2024 13:46:22 -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-6c162d21759sm59238186d6.25.2024.08.27.13.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:20 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 04/11] fuse: convert fuse_page_mkwrite to use folios Date: Tue, 27 Aug 2024 16: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 Convert this to grab the folio directly, and update all the helpers to use the folio related functions. Signed-off-by: Josef Bacik --- fs/fuse/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8cd3911446b6..3cc1917fd1b9 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2534,17 +2534,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 Tue Aug 27 20: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: 13780118 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.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 12FAC1D2795 for ; Tue, 27 Aug 2024 20:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791586; cv=none; b=nKql5VDPe7kSrgDoM4Rd8mbUdxC+mphdwja5ZSNHGHtJyoOdGpd+mUS5uUUvHWM9bZu6wVS2+JOPfWI12pxGdYYuM5vMP52dCWSyFlmy+KbsAq9EqpfAJ+zVq9CDpFd5sLmNe26R1TOiOoSe7LxOyblIoYOIq2DrqgCh3kOJ9us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791586; c=relaxed/simple; bh=8TyThD08zTc1r9IX1xYb2/J+wPW9gQTNMKoeurIRzXc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QEorvEMu3ukAFzXU8geN2vGjQq3aO6jTtZnh8pBFdwinhGTpvdQ8LbDlDIzHS1Uv9xIusZil7Gal/PX5P0Z3IjFkjFGIFpYdwARzyjUPF/p/67vIdKQaW+jxdVhWr3LG3fPfmDS8xvHTQIzCjJSnj+mAkPbJwa7zF41p3HqmLgg= 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=ABaq6hPQ; arc=none smtp.client-ip=209.85.222.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="ABaq6hPQ" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7a1d436c95fso356718585a.3 for ; Tue, 27 Aug 2024 13:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791583; x=1725396383; 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=tAn6We4TZxLVLRIbIvzp2bUFCY2LSbhSBcMD+QTACdk=; b=ABaq6hPQcxeehNTPUixxmxb5FiAuTy88mnj2vn1nIoWiVhnpw9s++eq/yurJhUQdOP qqVYnaIFEqqGJtXhxqiz3lT6ztbS7Ctot9eeWQ6Iy4TywNvP7PMIYXzqWd+2qprL3re7 3BVC3HjPOKNsaa6FafvizcAQ8/+ddGgALCvHuktzlAtJTYbfUruo6/EwFXLsn65+jueH AOW7HEn2E+e2npeTsnz880R0NYiPzixoMot3HQr4+EIO+5zGWDHDU5Fk5fg/lf5OqRA+ AuJ3IeenGyNfiNEq0DuXBGQUOuEFd/dX5X3KVSRcTwRPPwJNJdqsvp6rlbaCH7oHeHHW ybTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791583; x=1725396383; 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=tAn6We4TZxLVLRIbIvzp2bUFCY2LSbhSBcMD+QTACdk=; b=tSQUxceOLykFeoo4QeKXaioaeWZD4Vf4a3cAWVfCOeW+CzmB/qV3WTu5KPBB4AwM12 odhhDzaJA6LBNz1rSGcudHgilftZev3GfWqJjM+lWRt+EAeMcuhugZgYgNQDwgVlnvV0 pElTj67RF3O6UtO9Gg00w6sZiZ66N/po12O1rAFCipM00l8IwWOtgDNv7UYnWIE7PGJq Py2H4xjQlUuS2+SA6OuwKdApAUFohSg3E9/mV8Fw17vlV6hek/6mEv9xz959jaYnaa1U APppcUM9DufWyL1W2YXjPhSG6M5SAgBbE+A4NbV+Ny5ZONnuMrgJE7m0/hXqRlB+EtK2 ewnw== X-Gm-Message-State: AOJu0Yzs5/ZPsep/iReEonp8oD5Gpg0M+JQ518uXLBcKlmFNdzcj364P 5QP/Fgmgy2eOQOaCqqlQesjv5X4LtZRErqp0DFt57rjoESOWJ7d97holHzyqao/ozHb0qAUJViN x X-Google-Smtp-Source: AGHT+IFI/Z32K//+PzrPY5mUFV45DWi33MLmi4NVBhNOyUCazHncC1fYPP1Ems8IkyKjXQaOQF9CLw== X-Received: by 2002:a05:620a:4046:b0:79d:781d:3f5d with SMTP id af79cd13be357-7a6897ac809mr1941147385a.51.1724791583639; Tue, 27 Aug 2024 13:46:23 -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-7a67f3d5cd2sm583854685a.82.2024.08.27.13.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:23 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 05/11] fuse: use kiocb_modified in buffered write path Date: Tue, 27 Aug 2024 16:45:18 -0400 Message-ID: <0cb400723ac0ccd1b496d9511fd2d6c5537e19d8.1724791233.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 3cc1917fd1b9..b259d4db0ff1 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1453,11 +1453,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 Tue Aug 27 20:45:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13780119 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.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 B8A441D31A0 for ; Tue, 27 Aug 2024 20:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791588; cv=none; b=AWSLhJmb0gnfYrXpxbc8PgBrXEpZOEemUmZUMCaIc7rKfoo1ksayIcuNFCq/cNfGVe9aAwBdgu/C4M/kDAEny+hKbTR0pmAhm07/tneBsbwZqf+r2BcwQnCzPYi82fpBZjALKaAnpfcmKhmAnnIWfGeAYlt5T+H/rLUzS84nIrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791588; c=relaxed/simple; bh=zFlBcsUiZJn9q1vlsEwyspUOjL14G5c8Lhb4SBpF8U8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QXZSZ88vvxsZXJwCnDiuTXlp+qH//IUlZ6tX1qjiutiindqnixC7CN/43TJi2ipI0TsaBJQz72oRurxeOS+TLehzluqmxh1dHdYOy6x930q7gWD/jOxI/+HC+x83CZHmM/t8Z3SDXmDgzVKysxxZgt4y51gSHyztpgCOmndxFts= 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=VKFrLXuW; arc=none smtp.client-ip=209.85.128.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="VKFrLXuW" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-68518bc1407so65645287b3.2 for ; Tue, 27 Aug 2024 13:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791585; x=1725396385; 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=qWNvVlUDhv+Rc4ICGZzwkrwvqmFhZSdHtfp+0p4lK7k=; b=VKFrLXuWgbDx+Hd81Auc2COKzDXZahV9AfvgEHJwq1alO4wZ+PM87ph2rUyHRBjQm8 hIdZMiTVzdbFrMnI6rEP9UiKfmHax04fEve4WJ+EEWYkLEsm/BKDAw13inLFBXRtVUHF OwPSAYKdcd5bARKA7L+d1HUrOtcCuPWGb6ObW1Vzw+iMpWp4xRbxChE7w3Q9wKaO1CwQ sS8QGhGKbCeu+RbzpqqBjBjbElFaaVk8W6aIR4waCQGPdKoK0bmNNN6dO1O+/PytVPOx Cuv7sSdOLvlulqkzcSIGOyq4TuXbCpmRoM5k1METDUShvHG407CrdOaFU/GvYGdInXxs 7afg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791585; x=1725396385; 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=qWNvVlUDhv+Rc4ICGZzwkrwvqmFhZSdHtfp+0p4lK7k=; b=RX8vsHVI7kqQkbiAIl09aWlPalg8bQhZljFAZB3Np6V+jkp2FvWodhtC86/qAZ11Vl 4Zhj0IO5q7sOw2Jt/r5U2mahDNc8O77Yo8LuCoVIispNJ/mx2OVHuf99gBXMc/zU2ESc Huof+Q4IMdzxDzYiUS4SAL81DaN2p0ZXEXuINqyWErwmNOXUj+6NuIvea86KOSE7IC+Y R404vGcZQbKTtX8lnDSSQSPZnA3KCj56f8KDmD06v4IVmq9VAEpb3/8HcUdxGIRzPvIT y78j8OCxBI8EEKJKLE7ej8x5GwBIzKglKggIC9jwVLmj+8TeJx889fGk/xosQjdcXMfh NAoA== X-Gm-Message-State: AOJu0Yz+YlMiVIdg3fqD7QvH/tP48mjjuT4ZrAQCb5jQL5DlLwUatBN6 rtgofuZTIOhHhxrLGCCI6G2iO3NkFtEXt/Ft4VtivrqYSEfxnrjULSo+EiZg6Srely2xnbrpTAa Q X-Google-Smtp-Source: AGHT+IGOYaZXg20LgJ138MCELRlyaRvtlVgk5tBYeqP6oZ4GE3YeM+8AB5nJhvdP72uFRah/XyscmA== X-Received: by 2002:a05:690c:3248:b0:683:37a8:cd77 with SMTP id 00721157ae682-6c629250047mr126522867b3.29.1724791585357; Tue, 27 Aug 2024 13:46:25 -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-6c162d4bb7fsm59865156d6.41.2024.08.27.13.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:24 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 06/11] fuse: use iomap for writeback cache buffered writes Date: Tue, 27 Aug 2024 16:45:19 -0400 Message-ID: <11b0ac855816688f6ae9a6653ddb0b814a62c3bc.1724791233.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 currently using the old ->write_begin()/->write_end() method of doing buffered writes. This isn't a huge deal for fuse since we basically just want to copy the pages and move on, but the iomap infrastructure gives us access to having huge folios. Rework the buffered write path when we have writeback cache to use the iomap buffered write code, the ->get_folio() callback now handles the work that we did in ->write_begin(), the rest of the work is handled inside of iomap so we don't need a replacement for ->write_end. Signed-off-by: Josef Bacik --- fs/fuse/file.c | 154 +++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 88 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b259d4db0ff1..c61bc4396649 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -21,6 +21,7 @@ #include #include #include +#include static int fuse_send_open(struct fuse_mount *fm, u64 nodeid, unsigned int open_flags, int opcode, @@ -1419,6 +1420,63 @@ static void fuse_dio_unlock(struct kiocb *iocb, bool exclusive) } } +static struct folio *fuse_iomap_get_folio(struct iomap_iter *iter, + loff_t pos, unsigned len) +{ + struct file *file = (struct file *)iter->private; + struct inode *inode = iter->inode; + struct folio *folio; + loff_t fsize; + + folio = iomap_get_folio(iter, pos, len); + if (IS_ERR(folio)) + return folio; + + fuse_wait_on_folio_writeback(inode, folio); + + if (folio_test_uptodate(folio)) + return folio; + + /* + * If we're going to write past EOF then avoid the read, but zero the + * whole thing and mark it uptodate so that if we get a short write we + * don't try to re-read this page, we just carry on. + */ + fsize = i_size_read(inode); + if (fsize <= folio_pos(folio)) { + folio_zero_range(folio, 0, folio_size(folio)); + } else { + int err = fuse_do_readpage(file, &folio->page); + if (err) { + folio_unlock(folio); + folio_put(folio); + return ERR_PTR(err); + } + } + + return folio; +} + +static const struct iomap_folio_ops fuse_iomap_folio_ops = { + .get_folio = fuse_iomap_get_folio, +}; + +static int fuse_iomap_begin_write(struct inode *inode, loff_t pos, loff_t length, + unsigned flags, struct iomap *iomap, + struct iomap *srcmap) +{ + iomap->type = IOMAP_DELALLOC; + iomap->addr = IOMAP_NULL_ADDR; + iomap->offset = pos; + iomap->length = length; + iomap->folio_ops = &fuse_iomap_folio_ops; + return 0; +} + +static const struct iomap_ops fuse_iomap_write_ops = { + .iomap_begin = fuse_iomap_begin_write, +}; + static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; @@ -1427,6 +1485,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = mapping->host; ssize_t err, count; struct fuse_conn *fc = get_fuse_conn(inode); + bool writethrough = (fc->writeback_cache == 0); if (fc->writeback_cache) { /* Update size (EOF optimization) and mode (SUID clearing) */ @@ -1437,14 +1496,10 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) if (fc->handle_killpriv_v2 && setattr_should_drop_suidgid(&nop_mnt_idmap, - file_inode(file))) { - goto writethrough; - } - - return generic_file_write_iter(iocb, from); + file_inode(file))) + writethrough = true; } -writethrough: inode_lock(inode); err = count = generic_write_checks(iocb, from); @@ -1463,8 +1518,12 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) goto out; written = direct_write_fallback(iocb, from, written, fuse_perform_write(iocb, from)); - } else { + } else if (writethrough) { written = fuse_perform_write(iocb, from); + } else { + written = iomap_file_buffered_write(iocb, from, + &fuse_iomap_write_ops, + file); } out: inode_unlock(inode); @@ -2407,85 +2466,6 @@ static int fuse_writepages(struct address_space *mapping, return err; } -/* - * It's worthy to make sure that space is reserved on disk for the write, - * but how to implement it without killing performance need more thinking. - */ -static int fuse_write_begin(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, struct page **pagep, void **fsdata) -{ - pgoff_t index = pos >> PAGE_SHIFT; - struct fuse_conn *fc = get_fuse_conn(file_inode(file)); - struct page *page; - loff_t fsize; - int err = -ENOMEM; - - WARN_ON(!fc->writeback_cache); - - page = grab_cache_page_write_begin(mapping, index); - if (!page) - goto error; - - fuse_wait_on_page_writeback(mapping->host, page->index); - - if (PageUptodate(page) || len == PAGE_SIZE) - goto success; - /* - * Check if the start this page comes after the end of file, in which - * case the readpage can be optimized away. - */ - fsize = i_size_read(mapping->host); - if (fsize <= (pos & PAGE_MASK)) { - size_t off = pos & ~PAGE_MASK; - if (off) - zero_user_segment(page, 0, off); - goto success; - } - err = fuse_do_readpage(file, page); - if (err) - goto cleanup; -success: - *pagep = page; - return 0; - -cleanup: - unlock_page(page); - put_page(page); -error: - return err; -} - -static int fuse_write_end(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, unsigned copied, - struct page *page, void *fsdata) -{ - struct inode *inode = page->mapping->host; - - /* Haven't copied anything? Skip zeroing, size extending, dirtying. */ - if (!copied) - goto unlock; - - pos += copied; - if (!PageUptodate(page)) { - /* Zero any unwritten bytes at the end of the page */ - size_t endoff = pos & ~PAGE_MASK; - if (endoff) - zero_user_segment(page, endoff, PAGE_SIZE); - SetPageUptodate(page); - } - - if (pos > inode->i_size) - i_size_write(inode, pos); - - set_page_dirty(page); - -unlock: - unlock_page(page); - put_page(page); - - return copied; -} - static int fuse_launder_folio(struct folio *folio) { int err = 0; @@ -3351,8 +3331,6 @@ static const struct address_space_operations fuse_file_aops = { .migrate_folio = filemap_migrate_folio, .bmap = fuse_bmap, .direct_IO = fuse_direct_IO, - .write_begin = fuse_write_begin, - .write_end = fuse_write_end, }; void fuse_init_file_inode(struct inode *inode, unsigned int flags) From patchwork Tue Aug 27 20:45:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13780120 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 3A3511D1F60 for ; Tue, 27 Aug 2024 20:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791589; cv=none; b=IkQhkX0GfnnBmnLAxhgq4JLIH4eJHAaHmXLODU0PzjSXAprRaHDLOW6BkrukTiddsEoq32nQn+X6P8w4Qvm0g0kA0QyXCpd273vu1vyXuiS5a5exwRXK5UUdIGhN+9b4eV0mhU23K894PCdjzWhr/edoHSpgpgiLiJZS+TW4lhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791589; c=relaxed/simple; bh=XV6kS0+Pfazf+gnw8rE0kSJpovr6OxjLV8yVC6OgrOg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SlKIvwF/0SM0lRyumexn9FtgOdXiEDku7qZKSVRnEfgXx+inq26oXUPOJ3jQ0y1Ic7FCU1QjkWKAZuEOvGcQOa1jIKyrunsN5/bLqxjrJuMP7xo/IwiiEKYDBXWit45aryKiI+fGvj+aJecIfNeJh6/3FY6P5ibXJ+0mlKZgUPs= 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=huuIK7he; arc=none smtp.client-ip=209.85.210.54 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="huuIK7he" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-70942ebcc29so5334762a34.0 for ; Tue, 27 Aug 2024 13:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791587; x=1725396387; 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=3GaOAS1OWATnJoGW/KHZeFcx5X9aHGtIlOnElvn46UQ=; b=huuIK7heguw5e3+xlq+9zJkztSj3BF9S4EDpe2k73WpIdEeQMiE1bXsKOAf9VC/qck OOxrs0hiezW7XfSWxPGLCn8RY3niA7pCWSjmmkWE6477hGRmXj4LcDIfXmaZ1EJgsLpc ABq1OJMAofijIvdapMIbvbLm9lJiUCOYHMHWYWFYDrNxuTVtuX6iZzJ/GsDqDh7wN8Nd AwdyFpXSNULI01UyB/GJI9+HzXGB17/TT0ISqzsFeA7xp6gqeh+yJbBlGc99bj6Ux8mx CKL4VBAuKWedzIVr5LUxyaE8Zlt2T0NlOGmnwPrH3lzbH8x5uhfVzXdE3tsPzXOAem2J 5UUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791587; x=1725396387; 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=3GaOAS1OWATnJoGW/KHZeFcx5X9aHGtIlOnElvn46UQ=; b=QufBsUH+GBSTBDQWLFygxGwYVKIyuV1cSUbHGT8da0QvzuF1rQe0tyy3UTijyfooj9 VToq7lKshFv7SE2jwysSiX6t30kffEjmzPSY0Hj70D3ObEdZlVwC4Yp9ewoL1snVYbsj ZX8/UwE0+4UWUBFEotVqf9vlCkeHzSePKonotUGnD3yBouW7oBvyeRPm5QLM38Gvnz9X JzBOVY2a+JQoG/SDAmZJwVK+UxhNKZaxfZgU3UdTZbVROayKvzSa2CWvUSQF6FMRTfKr c5kewslgXB5skBCJjVEoiQ3LWywoxGXeqxVLxWDYGIsUr5Eli4saQU0PPZgfrsdorOK+ 05+w== X-Gm-Message-State: AOJu0Yy2CZQqRlC/3m49YL3iDCF9DqeWAClsRK/n/03ocFzbTtPgwiDH dcXZh4MRm6d/naDnGQJ3nBu/Fzw2RRwX/wTuIEDabOzwaOVb8V3hSSxEeC1ay58wfAgk2RSbQpm n X-Google-Smtp-Source: AGHT+IEzNUy1jpkwy4hqRHI12bVshwCDpUJZJAVOahAgsgbyy5VU+ITDEs6GAQH/S2ttnTd6CEK5+Q== X-Received: by 2002:a05:6830:2d8a:b0:709:4757:973 with SMTP id 46e09a7af769-70e0ebd0cd0mr16059363a34.23.1724791586939; Tue, 27 Aug 2024 13:46:26 -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-4564cdb1296sm27918841cf.65.2024.08.27.13.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:26 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 07/11] fuse: convert fuse_do_readpage to use folios Date: Tue, 27 Aug 2024 16:45:20 -0400 Message-ID: <07b50db20f6a86179a05b1f4f23eb10aefcbaeec.1724791233.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 c61bc4396649..f06f0239427b 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -861,12 +861,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, @@ -878,11 +879,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); @@ -900,25 +900,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; } @@ -1446,7 +1445,7 @@ static struct folio *fuse_iomap_get_folio(struct iomap_iter *iter, if (fsize <= folio_pos(folio)) { folio_zero_range(folio, 0, folio_size(folio)); } else { - int err = fuse_do_readpage(file, &folio->page); + int err = fuse_do_readpage(file, folio); if (err) { folio_unlock(folio); folio_put(folio); From patchwork Tue Aug 27 20:45:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13780121 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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 DAFC91D3657 for ; Tue, 27 Aug 2024 20:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791591; cv=none; b=kv0IKOnsPwTWtge+i+rjy4htEnXnvlXWqD/wQa+lJtOwthvNGOaYv4/FeAFhhJ8+sszfE7i78ZWa3RPCpgwQcHOJsr5vyM07goVYBVFBYnYpfbOHaIlEmyADkTaG6XnjnJX6GU5Wu2jfiGGFIcQBNaojjyOD6HhJju6kuBYXYc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791591; c=relaxed/simple; bh=r63lu2F0dIUEB3OoPbVUZhaDSz+c7JGMDP+e6wv+x+E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JQiFFC2TJPrHpFGlCXpH8fGCSWhKrmLqGg9/HN5V3saQZeQM6VGrggZZPb/R+tuyt85/cOsSKFteE4x+/VqQ3jgLouqCqo5oNGS1cWRWRUyz1MpR8YWUwaVowCCnQqHqaZl86MP4wdmpBuN497xgsPhc+aOwD1pgVK6EjfBKnIk= 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=cSOg8Mk+; arc=none smtp.client-ip=209.85.219.42 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="cSOg8Mk+" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-6bf9db9740aso26790866d6.2 for ; Tue, 27 Aug 2024 13:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791588; x=1725396388; 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=GOF+ElhywBlYSZgj+ON3lSoaKQYrzzRHrogJZy0VJM0=; b=cSOg8Mk+23pG02U0M2m0/Dy6dh502sq5iZTOhDhi8z/Ojd52h1r1/NXDZpXXhj0YEF lAgnM+Vnv1eigDEROG/0FlIeCyZZbaIyb2CM9F9TCjnR4b3QXRMFDVpBPxrVpMpIsJDm C7zgi/1+Y6Qa7NbHQYT0xYzrm+NU9/ZH15eUzF7s14nptA+I/wEyGPa+joWPCs+ObfBE 9S/9fPtfK65dZYxAO38m6tVKlIiRDUC2boxHK8DpnTtewxKW8HzwXBc3NdaBvMHYkRMR 7g+gTQumRTy++O9dBR9b5CPd/OioEDigz8eVE98ddUN2MpUj/YNvKy0h2Xj/NxQjI7T6 Z4tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791588; x=1725396388; 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=GOF+ElhywBlYSZgj+ON3lSoaKQYrzzRHrogJZy0VJM0=; b=q5RrynCZrDEmE1oFsozzaulqQ5aDSAO9hNgqA6Zezl+31hvJklbU5RneDN66lUba1I OzBMf1KfYHQTFQbyufFpVaaxw2SPkqkXJ5HJxL5fvgEcO3yp0p5ooDskV8MxYw6XWu8t w7cx/Tn2LAMn2r1yU7lKyOnap5uPJZFciiTYw93rUv97WH+0Z1fbh45aBV5BG6Qb9Lsc xlpqlttRt3Ln+6NwTyPU1hkGordJtLXd6vp2SMfzbb29xzYh8FfNZJAm2N3a49p6QfJu jZtHIMD15IE6jQBsSekEmEWOkvilZmxBwx/0ejvTPJRNxwpGIG4EEau1G+bFYbe30/NT dwUg== X-Gm-Message-State: AOJu0YwqEhf0s7Wu+2b0DtFMPaXQIW5jk/9iwPnIVLij/f1/jX93NKHk Pz5oma9KSQFbP80DmyUWLtiJrICVtkeW3IUfkUttBq/ivGvHtnvQQ/sU5ipZGIBPhYawCQYJ+QX x X-Google-Smtp-Source: AGHT+IHBOmSF2R3pufMmsA1xwN0PnD/qR4ga56m0H0uNryTgBEYp+CHTWB781LQzQ2mgpjc1xqurCQ== X-Received: by 2002:a05:6214:3bc6:b0:6bf:7ae2:3f13 with SMTP id 6a1803df08f44-6c32b695e8amr46578316d6.8.1724791588614; Tue, 27 Aug 2024 13:46:28 -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-6c162d1cb93sm59492686d6.6.2024.08.27.13.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:28 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 08/11] fuse: convert fuse_writepage_need_send to take a folio Date: Tue, 27 Aug 2024 16:45:21 -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. Signed-off-by: Josef Bacik --- fs/fuse/file.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f06f0239427b..3ef6c2f58940 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -484,6 +484,13 @@ 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) +{ + return fuse_range_is_writeback(inode, folio_index(folio), + folio_next_index(folio) - 1); +} + /* * Wait for page writeback in the range to be completed. This will work for * folio_size() > PAGE_SIZE, even tho we don't currently allow that. @@ -2319,7 +2326,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) { @@ -2331,7 +2338,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 */ @@ -2343,7 +2350,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? */ @@ -2365,7 +2372,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 Tue Aug 27 20:45:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13780122 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 3D6781D3653 for ; Tue, 27 Aug 2024 20:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791592; cv=none; b=LmyXd+VKsL+NoL8Imr+6MVYEE3/4nZzXJumDN0gb5F8WbolxxazIg6kQ/CX3UMcrivkN8nIoIcwRqSm/fsD3lUe0KheXMV/J+tyElUkrZmt/ohHHPmjU8PUjjHpZf6cSG60R+ckoatQt5+n5dohlrWNJ8VNAZhi544ljI0FtBys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791592; c=relaxed/simple; bh=XgJYggbPBA2c9Xr1EQQjg7BmU9Fov0L6xwdn15TjMz4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kRtOml1b4dxXVWqifI0KHU+Yuv5WoWD1Pai5Rc9h3dOpv7hVcTa/aE+ejGWBKAG+FrmWzGDJSuGmKAn2j7W9hX6ghFtV+aDTKmJ6iaODTYqp/l6ju3lXsgQrFM1uN+/PYsx8eQ5prL9Z8Ylob8e6ebLU3LDCPgk5RA3uMFVqGqc= 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=u4F7p8ps; arc=none smtp.client-ip=209.85.210.50 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="u4F7p8ps" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-709340f1cb1so3063999a34.3 for ; Tue, 27 Aug 2024 13:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791590; x=1725396390; 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=he4O+sxrssYyZF27J4CmArR86KDscMItuRK1/tSV4qI=; b=u4F7p8ps+mRppfFepdao25Fs2IJ/9fj0Mz5RjbkAYFH/LdolZRfeFTHG6C66anDRhu iges8b4qHcF/e4yMn+VOU8fJh2LRCKIM3Md1UduQzF/ZPkfiDQ0Vy/stutkjWrYrOcOS NgA4IzdQqeIHVr+hzwjq/yUetKSIAmvt0L6qgEHNSkRwnKOwOLQ2lH3waKainGb7Nqs4 91OJrT7qu3O/bAf/EaAdkVY8QU+DrEtgaB78kyyvJKUMqR++rTj8sXsL68G3//l1xbMz 6YvR4o22RsTpvRmdn8xcsf/VUyqVqUWYbXb09FRfp4MOJpPv3lsg60XTHPtSqG3VNzEZ xwcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791590; x=1725396390; 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=he4O+sxrssYyZF27J4CmArR86KDscMItuRK1/tSV4qI=; b=Wj1KOjo4/5F6ilm/GS5/bhSH1Rpd1Ha3f/jP+24elzj1hC6CWnqcsWQUuBqwI40Rei K765M3DKHqGBx9ik090qvYOoAlFulYiw0TvNeeQiaK/gUp03lAqcx0aGFWYHNvyaygri GjkZbN/HSKhEqCUCjXyih8vqLAPnH1MNQLQJH/LujAo871PT9VGZufhZGj+/Lq7VxymL 2sD+mJVNTAZ812NhvqfI9y/6bbUWBo1mp/M4iy8rrMpgG2/rW4xmICtS7CKvkXBwpJiz XB2/5TVofXKQyUrB4Z6CkjA3pe8ZCK0YR+NTM+oJ9YrHkw74YM3yo1xruanRxke7ndFr V94w== X-Gm-Message-State: AOJu0YzceH4z/FQrw8hivTCR53aJzYqXXnmqbsN5SMUfyF2t1b0YSLzB lST98X0HeUlEdF6+spy8/fI73qqgLnqZ6YjOtq99+miTOPwZHaMo08vLquilx6ZfSPX7Oo4DQ1A U X-Google-Smtp-Source: AGHT+IGRr1vvrfRhnw3diZwAnhvHrwp3KuH7GnnWmsZ2B0dcO5KQ/qhUWXG6A7PCfZTS8RjH6HRAMQ== X-Received: by 2002:a05:6830:6f87:b0:709:4d7a:3438 with SMTP id 46e09a7af769-70e0eb2b8a6mr17441012a34.11.1724791589916; Tue, 27 Aug 2024 13:46:29 -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-6c162dcd590sm59035616d6.109.2024.08.27.13.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:29 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 09/11] fuse: use the folio based vmstat helpers Date: Tue, 27 Aug 2024 16:45:22 -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. Signed-off-by: Josef Bacik Reviewed-by: Joanne Koong --- 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 3ef6c2f58940..e03b915d8229 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1853,12 +1853,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); } @@ -1870,7 +1870,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); } @@ -1925,7 +1925,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); } @@ -2145,7 +2146,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, @@ -2319,7 +2320,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 Tue Aug 27 20:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13780123 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.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 BD9971D2F61 for ; Tue, 27 Aug 2024 20:46:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791594; cv=none; b=HtczMJEBEflEgcrFO9nrXURxZCRM6EVdGpzfMEfjCZPwv2h6pNoIeqyqLHWaORBifYqc9b8TZw0xM8FxO4LhZxkwuPzYdxD0Bc8mL1V6A2Pxz1qDEF2BLEQABDic5fhZLS5WqTzC7N1p+W01P0MOHYDmgwn587uopXvjobtZ8Vk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791594; c=relaxed/simple; bh=OV3zooZBd3zMTYsF5C24bLlFtKpkafNeiOFd0zeySog=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=psBey6dKgIrEElOxfUZpqDJliYb+UvwrHqTpkq1TkM6bn9u9zdWJZUT05qS38U/5MNsLFfl8RcJr86jrzOWWLanh/e5UzQq3pDulB+eezwBkwUnST2lvmGmTIifDGDqm4rKujo7ygHa5hDWIVmUYT9wPtqKmwxT9WSTQlpuRKPc= 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=kBP2u5AL; arc=none smtp.client-ip=209.85.222.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="kBP2u5AL" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7a1d7a544e7so391479585a.3 for ; Tue, 27 Aug 2024 13:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791591; x=1725396391; 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=r9dT/v3YgOTooURpd2nrSPGuDHyhAqYavjf+ZVThVnU=; b=kBP2u5ALuNr/ytcnaD0saYBm8gZ9ZMjTzlfrX2eQH2e0Few4kD0rxsQK4Ltl7nvo2H E5ZENVpWRQJOqiSHcztTTVL5sBGTnzvo8VF8PwNgu8MXaxyZLwew6gjJ3SOuMwiB6GBs IGW49iHaNq2dHQpSLnsxe07x58/LktQaSWqAbOUXWDtCv3stEhRgSxJBAgD+pg2DzYe8 81gkz0x3HRplcXavvMwmGCuJBh5wuEoaWvlJVy4M9KYUjQav3/fl/5j8Fyw7c9rsDrat AVG1xPBuC1YabUU0MrkhN992Cm/yZ7BqvisRb9DdE+IN60LRPtf7Oly1n1BcbxWbb9/z VeXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791591; x=1725396391; 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=r9dT/v3YgOTooURpd2nrSPGuDHyhAqYavjf+ZVThVnU=; b=YU/Yw0wYJU+3/lE04LMJ0CQQThNwu8qzgZIr/xFdUFh2qyavigv6+lcavPv6PkUc8p Rf8uKWp6AyztSm5UkQDcWcg0kl9/Jmy1oMhwW4xN8knFvHFS/YAqM5ssRA28/Q6WQKhv WPIevx2rHuhuHkc9N0bNc9I+U8vbS5pkP18hhqmUvK95mGDzbhWsjBDBoAJfxfVFdUOl hxV7WbMgzZSAijJO2/mIEMx+RTy9eTDIUL+5osR6CIObmq9VBS8/uCNmfMx/qob1pc4M bFpS7HKIBallf6b2nbrxPAeSDxZkyqPOdCiM8gEtNrgTkIJfOxu92ZNDpDy+gApdKX1D SkJg== X-Gm-Message-State: AOJu0YxFrMvZxOVto4+vrfxStRwzWZBrpW4dayHnrCCiP12OAdWTRFMc Xz9Mfy8tNKEEaH4s+I1lMzXMj2OpjlVy2HonuFJLlwMs71RusM9NV923aedNuF5ZSLQw1J2D8OB Z X-Google-Smtp-Source: AGHT+IEwLEEM81zHFlYT5j3b+Wf5oXR98btPnECe5l7B9KQUiJKW0H2Cba4SZbAoJwqT0QZj6sxQuw== X-Received: by 2002:a05:620a:2990:b0:7a2:bd9:70e1 with SMTP id af79cd13be357-7a6897b941fmr1614820785a.60.1724791591270; Tue, 27 Aug 2024 13:46:31 -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-7a67f41f507sm577821485a.132.2024.08.27.13.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:30 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 10/11] fuse: convert fuse_retrieve to use folios Date: Tue, 27 Aug 2024 16:45:23 -0400 Message-ID: <5666724f5947145cec4f7b774cf276eeb236eda5.1724791233.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. Signed-off-by: Josef Bacik Reviewed-by: Joanne Koong --- 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 7146038b2fe7..bcce75e07678 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1709,15 +1709,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 Tue Aug 27 20:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13780124 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 026181D3626 for ; Tue, 27 Aug 2024 20:46:33 +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=1724791595; cv=none; b=UMbiW1kJutLVO9pM4T0qt8fBBvQs0T9yF0QCP57UXH0Sv+sSRrDUCo0RYLtyuCWmzju526BsfmsX2sBSN6WoexoYVaw+ZS+lDq3FLO5K0vWfuZmzFD6A9cAnupb1naAX+FZcICK3ZCkHPx1Kfx3MtVOhHq8TvPxLKZei+XXoPqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724791595; c=relaxed/simple; bh=X0DApJFK7Z5eoBilBYIivvWd5ORVAHNlmLt50Lda20s=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i0QiYlPlRt1bF/ZwZxL6JFuY9DasDRmwlE82ioXGLFAQ8iPqbc4D2etm6RszPSz4uIZMcvILaGVVbJ33WSfpTNS8xh67v46g2K9hveT6UhkqhBgRQisV1l74F9OzyWC3iRVojRuM96tNA2Lm9Fs+Kyu9YrWwjXdROpOhXeFPZXE= 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=vrsmy/B0; 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="vrsmy/B0" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6bf7f4a133aso32239566d6.2 for ; Tue, 27 Aug 2024 13:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724791593; x=1725396393; 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=mQ15t9uWlNPdfkJDsR4E1Urv+RYku/UF4TJezYHI1D8=; b=vrsmy/B0U0lYhb8UK6rahWV+5GcOE5bTG+vNm/xauWfHM5H36NsdZIZ+dtVhJFix/M h1PCDAjLHkHC9F3eTNMV+jyK9npbfeJMKff+/EgdmzUXImlzp73C8sDRgcYUJN1euW84 uA79dH45X+s0iiymxLMjPsUb1XLjvUsLcHBAd3ifXd1LjfjrccmufVHTgwlLAM97SM7/ wmbgwLz2c9WluwrXX7d/IOfkiwQzbMnzWtMnj9/SvuIqOiwxm0Ct5LQz7y3Sjmf7jZVV +CTqgEkkG639iXH/liHY4v7yUfyAVlIpgMyyt14SZV0dUfAzzVknyucXA81kE5zbLE1U uA7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724791593; x=1725396393; 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=mQ15t9uWlNPdfkJDsR4E1Urv+RYku/UF4TJezYHI1D8=; b=Uix76uBqjYdqi/1JL7orQNiakzljzh6mwfXd4FTZdHoNkfU/V/UFhqQMrn2spFiAOq kIQpw2F6A/owEy38fM9OH7z34JMAro1qfBR6g6Um1jlNATzxRZX/QUYj+4qeXAQM/VZz CsV73K89uRIInpN0NrVfWBfYz68iN19ednZzO8NV3yexZyXs20div4ayW7NCYrPbkdcj VMhPTsTnfalk1/+5DzJep0oBUjTq0Y/qFNDZwjKIqwqS2IjvdIsf7t5JQ0zlJwFboSEd mu1AmPTpEIgRdDqE0uBWN+ttM7nsKL2CzF4MFTfi8yl/rGIfLgqIwEWxSUNEifH1uBcf HenA== X-Gm-Message-State: AOJu0Yx6LcXdn+U83AIt+rmeB61oDQi5keLQEeGBxmfN31deAF8oc64m BikpbMR6RJI9edKTxQJ2x2dXloYEdZUBinAq9YiIbJuRHxDug/VMvQ7ZuMJqKp591YAk9dlhz3M x X-Google-Smtp-Source: AGHT+IHY64FvbMBVx9McZPr66d6evKiFqwvWlKUdtgc6bwkMCo9Gl+Eejo56MjSJ5PZBowDoxEFURw== X-Received: by 2002:a05:6214:43c2:b0:6bf:8186:be29 with SMTP id 6a1803df08f44-6c16dcbd348mr167877416d6.43.1724791592631; Tue, 27 Aug 2024 13:46:32 -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-6c162d2122csm59779466d6.12.2024.08.27.13.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 13:46:32 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com Subject: [PATCH 11/11] fuse: convert fuse_notify_store to use folios Date: Tue, 27 Aug 2024 16:45:24 -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. 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 bcce75e07678..eeb5cea4b7e4 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1607,24 +1607,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;