From patchwork Wed Aug 28 21:13:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781988 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.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 F0BE51AC429 for ; Wed, 28 Aug 2024 21:14:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879683; cv=none; b=imW9qPmthpslxyu6zJIViWwvup2B85R8VjFauq2Uer+JBpHBWeYmwrbH54r8VDhV/C0wTQrNSf9ZxuL9wNHYA7XSlqeJV4EPyPF7jVJCAAHqr1Zpm778g+PanpFa/8zoOw7/Po0BTPAKOY6ghw/lYAl2AW2+EymTvF3KmnAdzck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879683; c=relaxed/simple; bh=/rTcYLoPcRIZV6/SmiOMJpBdcT9n4KwY5LbgEXkH9j0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MtSIhngCbJ2ec3hIGJIkVQhI48lfQR+4IGQm9OcsTACuIuUqTkWauehUJFnWY1WdE8NtJ5AE+9dmCsJzeJswoJYjnO9lj+lHrs0AH06XD4W7UnTpN2dI7x12i2hc1sOJxeZLv8ydU+3ax1sNenhoaRa2unnzYZ2ZvS26fFZtO3k= 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=q76dVhRl; arc=none smtp.client-ip=209.85.167.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="q76dVhRl" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3db145c8010so1502154b6e.3 for ; Wed, 28 Aug 2024 14:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879681; x=1725484481; 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=pNrq5/HUpXvsAD1MkCKtRH19IM1YIvu9q8Bg/8sxvEc=; b=q76dVhRlTNtlu3urFmq0PjsOV1cJ0CZa/v06jzX4XzI8ar7fqTAuhv4cj86u+AGC1a LxTEsPUsueM72ZpALIFiBmaFVoqjDwxx+TMJcP7kov/VUNveJVu7sIFgDAbypIiLnQg1 +OkpDMCiz22EsGAKTfhNstjjLxZMulLqY2OE1jEyYV4Jvo5BmgLfU5mORA7UcQcWnnCO vdCc+ProGTJiJFQTdb2Qi+ieBUXUlgsMfKFB2zWWR2bQCS2JZhIDJ7DJtqqzMKncweL/ ZxOAv2HSx4JGHxohK/dNylKPS3FlA/HJ90U7gWCYT6ui75j2mUdksX06GjCtJzBCsGOt fgxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879681; x=1725484481; 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=pNrq5/HUpXvsAD1MkCKtRH19IM1YIvu9q8Bg/8sxvEc=; b=X+84LxQsEC2zJm0ajrln5hN8cIjcVjneBWgx77iU06VH6bCezyviH3hGZOcrhFXCpW nQ6ujB2eMEwghG42MyRN32sKxQPlkiNpJi7JJbH64y2tYD6xOwgcJ4y2Nmq2+sM8sDAb 8Xnur6wimGKMMBW0ko4MrFxDLLZln8zagt40ybqVPC99/p2ksmPRoQqSZfXrTI3gHWIg LFKaIF4lHdkLJdhX6TS2/BfpHcdpQEysV5W2zh4DeW5M2CnKVWqxkNEtMFu4woF9ETKu tMzcFU7Sw5ZBkFbI+9mnQZC/io+tIlKzF0dNIgctGARSLxdo5F4KxRasqaHvsYoWUGQP cIpw== X-Gm-Message-State: AOJu0Yyzm2cLX2Tm7FVjn6MwVfqMazDQRBOF1CUrtEolkik++JvbcEDf 9+zNZSBDtXfCu67Xy+1uhbx6+3/cTAn26+zt2WTIrqnf6EDl6gNmhPRnl0oJoBOT5NwbREAwtOt y X-Google-Smtp-Source: AGHT+IEWj6d61UsxElpUcYRhUT/IBgERWAcY7tW3nDPciNZYvgm3z4yzvNzA/L3RRHevdhOl6z7eRQ== X-Received: by 2002:a05:6808:2004:b0:3da:ab89:a808 with SMTP id 5614622812f47-3df05e33094mr753104b6e.20.1724879680764; Wed, 28 Aug 2024 14:14: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 d75a77b69052e-454fdfc5968sm64830931cf.15.2024.08.28.14.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:40 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 01/11] fuse: convert readahead to use folios Date: Wed, 28 Aug 2024 17:13:51 -0400 Message-ID: <277609d4fde934da213f74f235f3731bd7f50230.1724879414.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 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 88f872c02349..2fd6513ac53e 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 Wed Aug 28 21:13:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781989 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 959361ACE10 for ; Wed, 28 Aug 2024 21:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879685; cv=none; b=o5wA9T1t1ymP2RqvBBOD55SyMKccoNRgMBrTcrT5jqos4y3e2Ei0rpPmN52j4Z1XfiTVtuwzFpZEqBOtJxMzDfVItVizQjVT6FyBiu/829w4IjPlXxYzpQYsFG6dK+DxIpXi0bxBj/C6Dy7AifqilxdXiACs9jCoP9L448P/Hn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879685; c=relaxed/simple; bh=rqh63TWKRvEXjWv3XfOW6IdI6JwCyPFzQI0Yoqi+h2A=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pNs8F2N3/1IlZ40++uGDqvGBc0pE8tiA05eOGxIa55u0GsxqTrx3yBXsGADPdmv0jExeOVyt9FEEkW+mLoiphfC4WzVytu9ciy85V5FuNtw7CQXvxMIjRQHI+Ikuw04BdBJRrSn1IVsTMMNrobb/Qege2S+OEUq8NoyQtgVwAUA= 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=gWwbni98; arc=none smtp.client-ip=209.85.222.176 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="gWwbni98" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7a66b813745so408688985a.3 for ; Wed, 28 Aug 2024 14:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879682; x=1725484482; 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=YKt2u9GiqkNR6gbLdnctJUEOsRc41JpjbhpUeXMVOyE=; b=gWwbni98nZveOGtXA0sbUNxvB07yDXJNZV0jIMOsKW7cjBrtblQCaS6GGwZI3Z9U7+ bA1Fo13o6xRnGInfO1P2lpbqttTtz8ErHlw/Ijw+7/vdQ5umhgEju5Lbr/U+DUa6LfoQ VDpU61cAqlqG3NCdvOR4Gz/b0vCcFNQ/71/uxuvDaqhTKi51zPEuPIjcnmsbII9uqC7x XMv2IoBYHZl3gXChLUIqSDNP3iWOem5HgwRTRxmi7Zng18I4dtSqrYU07MD3gT3CBecL jclvHK0XiEkzvpH37lbG/DtzQWjkuHhOT0rnZGPj1juivqLsnQkRgmRLB8n9wvdTHbUh 3qSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879682; x=1725484482; 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=YKt2u9GiqkNR6gbLdnctJUEOsRc41JpjbhpUeXMVOyE=; b=etKz+W5IQ/+gywVxLA+VV/4fQpDiXN2N93wPnzqQMMihnDrfiEkIqzrPjle9l1iv/W PmyzEdl1NB3ctF97MOC3Lyx54zB7rT0BiqdnqUeDVvF+2OnrUes0lmcDM0xN2GKd2WnZ 9709IJvuoepy4NWxZD5zFu8CuCqOfkzxiAR1wVSUiWfAeT+mWR2A0+B+IwiBWq5r1r5V NcO5fJHgKUjM7V9Z31Bf20rQ1zvcIwNh7WRTu8othOnA1avUt2SBn7pF5QbtKKIhN9Z/ KFe/t5zoh5fVvyO/WSuryHgyosZ38PD2+f03olqVALTwyYLVuwOG9x0JNcJtiSXLoMSE 18NQ== X-Gm-Message-State: AOJu0YzURjlp5q+OIEngQDkkiELphpIDm61sx0CBQQpsPrr0fBfkWE5t HxTBhu2IV0kN208fQrJa4UackkLiLERrMYWPb2J4zpvmN0GhdFOec7QQnEjHcbehoKMF2kcy26v C X-Google-Smtp-Source: AGHT+IFqQQ8vD/SxIBZnEAIj2SWucgj5i9MNgDYsxsARrWrYLypIPnik4UOvumcf0d1lTCjF/AODNQ== X-Received: by 2002:a05:620a:1909:b0:7a6:640b:4557 with SMTP id af79cd13be357-7a803f28b7fmr96441785a.0.1724879682200; Wed, 28 Aug 2024 14:14:42 -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-7a67f3f7b75sm671180285a.104.2024.08.28.14.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:41 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 02/11] fuse: convert fuse_send_write_pages to use folios Date: Wed, 28 Aug 2024 17:13:52 -0400 Message-ID: <1278043b334b557d7f3ba4ab5d502a618e100824.1724879414.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) 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 2fd6513ac53e..275af3a7c50b 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 Wed Aug 28 21:13:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781990 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.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 DE8B61AC429 for ; Wed, 28 Aug 2024 21:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879686; cv=none; b=PdvU/CcowJQuXAartsK1jycfO3NVdSYHugtnYi1VPRKPxR9mve2WU979/UjAcywTyUbPprWq3xb2y4zArcaZcaHQ6iK+3fETobp2jn0QCMfMfpmCXGdm4W02zYudVt+nlxls/8e7kGwh/wsMEbNuz4MIMIXw02ZE2zHeOpupzcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879686; c=relaxed/simple; bh=F49A7krWFoimk3w+If7pTG08lS3KZ/Ht+3AzohNhokQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BKNxK9SZZfhzT65Q5sfOjD+XrnykhoomPa6uMCW7buxDxxmLNBe57ad9Mk6AgYeewJKB2sx13b7+1PcPLSeZk9eksMIDi5Vhq77txAeONspftfc7+/zNgIEyah5XbDv1bXZkgFZSdYojAySbxPb3a3yNdPywScS/LCmucCN/IkE= 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=RWwJM0ek; arc=none smtp.client-ip=209.85.219.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="RWwJM0ek" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6bf9db9740aso32066836d6.2 for ; Wed, 28 Aug 2024 14:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879683; x=1725484483; 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=snmcu8eKXQ5sijqek9QxKjvkksZ3ghfNCeeEaNxDCDk=; b=RWwJM0ekx1T3h7dcf72fhKIux65NsqLIrppuU8iPCS2alQk4o6RWQeSQrTkVuZWIuk ZmqTnovGE78/hWKKlIvkjH3o9QyyBLXODWBUz00IxBU+LoWhwa13ZTNT3MEizmPM8Adh 3D9uxfjxFwao4HyIILVsYkksaSsahZwb1u5j1Eaia5tv+LEUUjhxgAbfydijmBmiJtmG MkExhL4v4F6W9DS3e4F6kJ9i2Q4a07+qjimGxFcQ0kqtR3h1N5ytGF4PlM03BtnmJ0L7 PeMlHe5cJ94tsQmAxZnqo7qCYnO+xokEdbPUf2VaI2Z4G7Dn1kGkFurVG7gv7xb9yJ9u awWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879683; x=1725484483; 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=snmcu8eKXQ5sijqek9QxKjvkksZ3ghfNCeeEaNxDCDk=; b=ZJxkzw6odUFKWzJAQ6Gavl+W2q5M154yrzeRj7UIlZuTeN1qV87TL4+HnNQyXaC5JM ZtmQUrPDhO6XcjAH/2N/YI1ASPVBB/vh+/APlluwzdmm/GNuQ7sFfc+TQgVOtHBqfCkw PUBg4FBheIUDx3mGKLLIZt/X58WzSJrA/VTcSeO0UnknigYaT3ci05s95B41OySaFkOi l2xYBT0MjHP4OXflU+5p2f+r6Zcx2JMROs88ibhlDARmxb4Wa2S+J7NZkTeTGt9+IH8K pRlc+0frWXk+9kuJfEXikW5/SVV/1JMefQGFu5hHj9JOfsdFG56oJpamWRcGEiJofa/P Ih9w== X-Gm-Message-State: AOJu0YwAUgxf6+RLt+DRzIO5hAhOrMqctDXsl0zj3Nfe38Jy6fVlFInD zD5PFm46D8oN3e1pulxrgE+V17+XprZl7DoWBRFJSOm8IqhG/F8hxHyTU6aDYCPzaF7HyL2RGAo b X-Google-Smtp-Source: AGHT+IH7FwjmQiE2dhccr8Qbs/jL35RdivTELcfA88CXADM3LBAVKUSsqDCsyFRfRRYPBqEeeQNjlQ== X-Received: by 2002:a05:6214:5f0b:b0:6b5:9439:f048 with SMTP id 6a1803df08f44-6c33e62759dmr8345146d6.19.1724879683592; Wed, 28 Aug 2024 14:14: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 6a1803df08f44-6c162d1d696sm69064976d6.13.2024.08.28.14.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:43 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 03/11] fuse: convert fuse_fill_write_pages to use folios Date: Wed, 28 Aug 2024 17:13:53 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert this to grab the folio 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 275af3a7c50b..08fc44419f01 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 Wed Aug 28 21:13:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781991 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.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 0EDD11AD402 for ; Wed, 28 Aug 2024 21:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879687; cv=none; b=iOJqOHZUXRu9DtrBZWyMTVaUZ6yHViARj64r+R7DxPGh/0aRsk/gm25hUcPswC9EcGu9yWV9nWFPCq+5hEWSblvU66KxQudICKfQCizBgbKGYRS9lfPGXtIVe/hlzaLzlhtsh+5wJOEn/Q6OKRbJ2uxMgc80trEUwrAxIDy9KcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879687; c=relaxed/simple; bh=1IlRaUU6YcpA8dWPljiua34jBMrCzwhmWQyKhY2rhqs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AI6V7N9StRNJgVErY7BK1rPH+YgxVukYMY2uJfVVFC6B5+AsFTdX5O7JDRaJkek1tLdFSHme3YnXdeR2bURcAN8o04NPpTiHPeGWd556/KelEc/E4dt0BdcP3oxyAta31c2OBFK1k8dbHojNUXnSGtpvhFwtE0d4vfNGiqfLgcE= 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=YEFavjjF; arc=none smtp.client-ip=209.85.160.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="YEFavjjF" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-273cf2dbf7dso4653457fac.1 for ; Wed, 28 Aug 2024 14:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879685; x=1725484485; 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=dTT5Pov6rIax3M1vyZfKKYLHP5B8WWVKBD0Bb4kXBo4=; b=YEFavjjFbEKVyb88W6ksJkfAYBzqCVn7xEeNuNUOPaJzj5pegee2kDrPP4/jjfvZva 6krXKvGFKqeE9sjY23A5ijKxsBIWMJ1IdJ9KyLd3Iaw3rKP9lB0Ci6e6NvZ4XTte+cPK MGGTuORIXClZ8A4dCPnzfCNfv/j9B/riSRED0cZUyF7jsIFxC35U43QMNW+xAa8QqM+e 7TRqZBowyNViOcSIqDszrFCR6vtn5i42x1zwRcmHDMG+Tb9YHjiHQag5f+NwxYso9ZcD 4os08K5sRMvFf0FQYlygvPWsQxkLDZQGFmwyStnmXKDQZVKPQzxUYtBDpnYbZjCbkle6 VuTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879685; x=1725484485; 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=dTT5Pov6rIax3M1vyZfKKYLHP5B8WWVKBD0Bb4kXBo4=; b=vs9sXI3MxibqJby2f39oPfHzlncJkmxHoup2W5cRlmDcl+yuozWGC/uCEeSIis0ZW/ pTIKzmamISTQYrSTePhq3r1ndxLmpVLs0/AsTYl5Ey93eAUWY+BXEd/9AfkeV+IxG4// LmBZQ+MXSOCVQ+6bERcYhKbOmgfBnpCgzbPOd1dI2SQVUvgV6AX12CvtW6w3arBJhL3p 30VFyJv38LhWeeIAUsEITXIfAMSTqGtff8BjJew4Jkko8hpRHw2A2Lqtw7+PvF9f3Wue Somyw9ftU58jIdug3Q/NhUUEHaPMseP/CT7UU5Nu+TZrplgr62HoDoMbYUNcFysoVR/I sCzw== X-Gm-Message-State: AOJu0YwLpKhY5GCT+Cn28vq/OHcBEMM5b+yYbLdonyziL8ZPqkmr7FZd WwKZE6i7c5mPwHX1kt0CL3vs7LD8N7jVNjzSc6477JHoVQlWkTTHIXZh6iaIed329jDl/efJMro U X-Google-Smtp-Source: AGHT+IFXvqEYi1OVAIibfeICBWrOJASjypLZy6DZHPsnpojRN3PDyhDFuapmJJX8KPIPU4UHJk5OwA== X-Received: by 2002:a05:6870:8451:b0:270:3a68:cc08 with SMTP id 586e51a60fabf-277902c5662mr829393fac.40.1724879684914; Wed, 28 Aug 2024 14:14:44 -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-7a8025a8b0bsm36381585a.75.2024.08.28.14.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:44 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 04/11] fuse: convert fuse_page_mkwrite to use folios Date: Wed, 28 Aug 2024 17:13:54 -0400 Message-ID: <9e0199cbcdaab094ac839b82b01c43f479bf01f7.1724879414.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert this to grab the folio directly, and update all the helpers to use the folio related functions. Signed-off-by: Josef Bacik --- 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 08fc44419f01..830c09b024ae 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. * @@ -2525,17 +2535,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 Wed Aug 28 21:13:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781992 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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 8D9A81AC89A for ; Wed, 28 Aug 2024 21:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879689; cv=none; b=dE2vdlN6IXnd3nDZjhc5haPsZRcVjuhxKdnMnRjgM2jjyRIjhND2yDyO0NHNhZUnGR+DEEXwoWn4VrIWB+iORFO7vPNcbJ5uPmMXrqHUCxsFwnkwTdE1mGyysd8O2ClbR65p+gTtxAu0hImhILpG55mHPAxLAZQJq1m6QEddM8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879689; c=relaxed/simple; bh=y4QahrmTUMKQVV2JMmvJZB0ByBfJqirYLBWu49zssEk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZIIekCNUjomJKLZQG2H4Lvl00pnXkE9C9y3Vwyh0ECpTLW0PruzDHpUynkxENbxPK90Vjz4+FBhPdTFYU1gNYgQP4EAK1PBlW8TuPyoZzFCAgjAGQTdoJnN6n2TqXMgU4aQWbUtsF6q/jtzdtgFZdFRzhkskka2uDMHqXPp1Yjg= 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=i9og3gst; arc=none smtp.client-ip=209.85.219.51 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="i9og3gst" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6bf7b48d2feso37683196d6.0 for ; Wed, 28 Aug 2024 14:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879687; x=1725484487; 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=kwLAwhjDUEdsahEgqv/OLlx8yFCmH3GI1KdeF6Nt2I4=; b=i9og3gstA9/oWCU4tfI1acpYmJwILfJlXGYHrNx584p0VZcCu4pAFWaTDT9IqtiISb 1WcekbLRgezXsfHI/Pajyt57mfZFZldN1yEs6mTa/kRQqAH6pB5QbxFFG2/TSpUemSJ6 /D+c0dFJx2NiK8nmcfLW15zzq5kyfgFDA8Y32SX5JOpsBPHx52NCHi9nV6Xb1Zg+0mME gTNsMG+KdfuZnc7sDn9xtofnvs5A6YMHAqAb5TOX4sjJBrM9PU5ECf6+ukPxusC6uH7H K3kIJEMu1pMvfilC6HKOQjchk0OpUW9qO4ZuC4PsHYL/BQ/KHYzP3nhLH2aEsWnQwG/E nozw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879687; x=1725484487; 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=kwLAwhjDUEdsahEgqv/OLlx8yFCmH3GI1KdeF6Nt2I4=; b=ilJ/keVBJ+Ry0VQOu+A1UvRqueTsAWKRB9OcisRTzZ599W1ptPB3UqXSOWPLZ4ICjX qxOHNkuvt44djga2OkgDjG60CXlWdzhtMsLrM7NRfRoITN44HHkO9MTHFVBSdypGif6j qy2V2i4SpfYZoyNN2m6KTqQ/AMRJQOdfoS9wpu2n5Dbj7SfBLxG3BZrsXxwGF56roLY/ jZc7lOWsDGNbIrBxJOg0V4AFPLxNRgbX+8jirzfhfKfwQ4qEpZTiMSswk1MlFFhG24XC d57JIsi+V+IdX2KEv3ZWccSOBbebYzi7PNfurrgmlo7pNC7rq6SNblnBbSRmY7hL1qoV 2OYQ== X-Gm-Message-State: AOJu0Yxet5lBPNC5WIfRsOXt93rjk3VlGmzX1xLemxZtSC0q/dL4h9Ej fQDNVoenA3V3x9p8mYXGzGt1wINYANU199eG4Ycmcj89cPABv8witeLSLGX7kCjiP6W6sIQ9bAS l X-Google-Smtp-Source: AGHT+IFHHgHWjK+Zz2P4+tMOgJrZ5Ro9UEYYQjZrPlmaLaaDNzWdpfxb6JfGsHdxTZQvQhf0TaE77g== X-Received: by 2002:a05:6214:4890:b0:6b7:aed3:408f with SMTP id 6a1803df08f44-6c33e626481mr8394886d6.13.1724879686371; Wed, 28 Aug 2024 14:14: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-6c162dcf034sm68009996d6.106.2024.08.28.14.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:45 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 05/11] fuse: use kiocb_modified in buffered write path Date: Wed, 28 Aug 2024 17:13:55 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This combines the file_remove_privs() and file_update_time() call into one call. Signed-off-by: Josef Bacik Reviewed-by: Bernd Schubert --- 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 830c09b024ae..ab531a4694b3 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1454,11 +1454,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 Wed Aug 28 21:13:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781993 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.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 16B0D1AC8A9 for ; Wed, 28 Aug 2024 21:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879691; cv=none; b=XM3Uah8YaG7S7bjWm4Iu10B8WFdgXOQOoC2FhgbnNt0woGO9acYnZrGfdpt0UjaAXEigseoJAZPAAi4faDHdgHLR8EdJ3nVS9sAId5sJA4+0NQ3vTi6eQT1372SkkSvbFynsO5Fm/WLmFcFz8VSqT81M+sVXPZFK9irTqAbl2NI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879691; c=relaxed/simple; bh=EPTtiftFSfELZLbjnZAHuoODiXnvFK83m3r4JOpyy+s=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FY+KLYuwLHrjPKHndBkH+Q/oYTvnGvNncXohOsa65PY+ONXfrlPeVldqrlADdtfTUX+gF7picy2C3ZUpDuYi76E7Mb3mhbUFmtu6CdKtQCRRRVi4c+7fYj702gtzrgSIEAvVEetUaMYrvYMT3ASWVfZpwEwKxSWVnAlRPXFxkCI= 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=asgT9x+l; arc=none smtp.client-ip=209.85.160.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="asgT9x+l" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-4503ccbc218so9590461cf.1 for ; Wed, 28 Aug 2024 14:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879688; x=1725484488; 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=DaTpBNDg2GfeKIc65MjT51a5XarKI2599rDM016xIxM=; b=asgT9x+lNYqRjpMCrsH8CbrY6qhvgp2TaVzdrN5cJjavlhkWGmV695bQUwuYLR07GE RRCcol+1H4nah25O4rFdg5bkPcQe32AXC45DpHzDxWFIK0qhsmMqH6jmF4U+kSURlsa7 hqBnVaed7cgPhKemth7+x3vnsyUpHf7kUqMhbrSeT419rtsJjnQ+Cnyk0GTXRCzjIgp2 /94uUYXCb/Rfqt10/BKZklMmyWJ8XytUj43QOb1xBpkf6lGA+UzINMkrr0D03pSDQ1E0 837+mrqg0dVvLO/Qh8CmfIfZywmFy4HjzNl3lK9RqbjUrHGAbhSaz17viIQn1Oo71kmh LRIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879688; x=1725484488; 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=DaTpBNDg2GfeKIc65MjT51a5XarKI2599rDM016xIxM=; b=u6siWPLAd4OB6grDwLK1ZlmWZImNoVcHtQ07WQ8vXkGaZtCsuhE7xCtnc9YgDnm95g b2NMMXh2ITZFQl0t4aNUH7dZN2cEAYFQi8UwPkXMNoYzRsAKCa+M1aEkJ8uNSiLprvfP bDbeJIbbLfsL97cZ9i/E9KT5ZAsadWbSa6AhxWn6SPmBNxulmJTq0sQlhbBw67k5r0YW K34kBFx4Eckd1kkjqXrI3A/jQoOHMnPVziwLbywjgiPtPAq/pWEvAwdU9oWelyh3vYRu +k2GfuQQR3w9ehqusL5mgOeUT6fiTRx7v6WhM6tyFegqNyseVDEZjz8qEKuxWmYWEN79 R/tw== X-Gm-Message-State: AOJu0YxpAOtlTy+b97XOK00UHCyYS2DIhT1h+MhhoiNRt0SHWkkXVMeF HvZgnRUA6Wa+CFJ1AMbHI0Hybb6MZbMJvc8AOfY39n4S+9MVYrdfqK67XEwYhoA31MSnMZdPYNt G X-Google-Smtp-Source: AGHT+IHL2HaE6jZLI+vVZb3ZtFFB+qrpiRCgpBEC0p5ZBt5xgmMoGZp6ZkS48f7PIg1jw7fsRcRhWw== X-Received: by 2002:a05:6214:412:b0:6bd:738c:842e with SMTP id 6a1803df08f44-6c33f33ba2dmr9729236d6.7.1724879688508; Wed, 28 Aug 2024 14:14: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 6a1803df08f44-6c162d1c856sm68693286d6.14.2024.08.28.14.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:48 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 06/11] fuse: use iomap for writeback cache buffered writes Date: Wed, 28 Aug 2024 17:13:56 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. This does bring BLOCK as a dependency, as the buffered write part of iomap requires CONFIG_BLOCK. This could be shed if we reworked the file write iter portion of the buffered write path was separated out to not need BLOCK. Signed-off-by: Josef Bacik --- fs/fuse/Kconfig | 2 + fs/fuse/file.c | 154 +++++++++++++++++++++--------------------------- 2 files changed, 68 insertions(+), 88 deletions(-) diff --git a/fs/fuse/Kconfig b/fs/fuse/Kconfig index 8674dbfbe59d..8a799324d7bd 100644 --- a/fs/fuse/Kconfig +++ b/fs/fuse/Kconfig @@ -1,7 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only config FUSE_FS tristate "FUSE (Filesystem in Userspace) support" + depends on BLOCK select FS_POSIX_ACL + select FS_IOMAP help With FUSE it is possible to implement a fully functional filesystem in a userspace program. diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ab531a4694b3..af91043b44d7 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, @@ -1420,6 +1421,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; @@ -1428,6 +1486,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) */ @@ -1438,14 +1497,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); @@ -1464,8 +1519,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); @@ -2408,85 +2467,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; @@ -3352,8 +3332,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 Wed Aug 28 21:13:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781994 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (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 4B5E71AC89A for ; Wed, 28 Aug 2024 21:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879692; cv=none; b=ozZVzcE77oZFjbUzNUvuUSr3l9wi4gm79k3hXQbxhq0oRTNeg8zdLVLL01ToMhqMD9sodDfqUvmtbmrQBN5wSwogg+3lfG1czSgO9gF/RjAojQOwJfWaHTbzjq3wDw+PgSscmChJ5IDqmlsyJ2P9BMQRrIUuNek69Lw/sMYxv9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879692; c=relaxed/simple; bh=C7WbJ8HyRiKebH4aRJvaZ+gsrvSb+hM61v0w3L8+lg0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uk/4MX430TekndnSMvicWfKEl/ImoK0sR/FVFHmn6xP333gRNbWiRf3w6MIUiJEori6/IiFqzaSJosx0N4RJH0sirPNj1E7d4VFd4Sjt6OfBiaLrh+8128Wj7Zf+yQGKO+Lox0Oc5JcOsF9lkEHIvXHShEVpp+w2KxHERiwZV9o= 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=JuxP9s1c; arc=none smtp.client-ip=209.85.219.53 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="JuxP9s1c" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6bf784346b9so34589966d6.2 for ; Wed, 28 Aug 2024 14:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879690; x=1725484490; 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=xa2b/UuJ8mJ1f1NOXP+QXHNgtO+81ETtXdFQUbx9D58=; b=JuxP9s1c6RmGo2lO7B07PeOpyRZJqUaR2EmvFH4DFHhbHyfAI8JhN790ia7UzDtAyq Iswq8kVys+hi3WPh5GuqJbZqsweSOTN1xMLzQR/Mx7BhqO387JyP8m6JZtPHapQcQZvh CHg3V8jRdDm6rApmCLin9fjWSL7FMHR4oXXQhpqzfN68jl8V1znTdYApIIayyQeC3/Vg ySyGalwhbBNeqgsgNF7MvML0mHg4HGMDyPqjIJi251UG8CiJ+9BzlQxob48FyIOv+FQ7 BhFaGy+huxnC0CpE0j2VTptsSoLxWcKlm/7LQZ/EHPiZmpg8VbvTzCcTcmQHnbibLRU0 UweQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879690; x=1725484490; 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=xa2b/UuJ8mJ1f1NOXP+QXHNgtO+81ETtXdFQUbx9D58=; b=gaxhMKdDg903EHvD451wA63eaK59kDSU72F/WnsT/p4HPDQHcXniOtXiUPqyMFAY/K irDibdwv7WSiKMQDtOoTW4F0iRPDxgZsTRibNUWu0ud/xM1dqmdKRcFeXe+AyZ974Ew3 aYGC6kqLKOPwrij3tsH8uhnBk697/omgKA9LJ2L2yUeyLicO0zzzpEcSlLwdhUq2EkR1 rkYUg2KNIA6FZ6kQVOLzh4aDaMot9ZMFSNSbjsNgoCeAAkxLfZW9cTLOiavsEbkqt71y rcBdz+D0C3gs0AX2sAcIf+L7uba7wEupjYsb4n27wrnBFuPV049aeUdRpcO6T7BhkOIj lPZQ== X-Gm-Message-State: AOJu0YxYCJ95zwJxUYdMZVGVT0ztMWXpe1WA47buoUriovxeghrLjMd7 Fi8Mmu3lV3d9v4fhdZGSEUfIrOvPsVRRxVibHb5q4hjg1lKTME+NM9j5txYldrV5NGF9mtlOYkv 8 X-Google-Smtp-Source: AGHT+IGxu1jsu2FHhRTp0an6lb2jB5Ew1C6CHguSTxNqwYmRCGFN8HY3LaOexLIrEwinvLEX7cQPlA== X-Received: by 2002:a05:6214:2d46:b0:6c3:2fc5:7c4 with SMTP id 6a1803df08f44-6c33e6a184bmr11004126d6.48.1724879689910; Wed, 28 Aug 2024 14:14: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 6a1803df08f44-6c162d20f64sm68141496d6.24.2024.08.28.14.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:49 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 07/11] fuse: convert fuse_do_readpage to use folios Date: Wed, 28 Aug 2024 17:13:57 -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 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 af91043b44d7..7b44efbe9653 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -859,12 +859,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, @@ -876,11 +877,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); @@ -898,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_readpage(file, folio); fuse_invalidate_atime(inode); out: - unlock_page(page); + folio_unlock(folio); return err; } @@ -1447,7 +1446,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 Wed Aug 28 21:13:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781995 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (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 7F9341AD419 for ; Wed, 28 Aug 2024 21:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879694; cv=none; b=oW08KR1iNbiXtKXJKnuF6TysKOaY6dKd91uDIz+M8x0nwc64zEIdfukP8+3gKyus4XzVzQjSj5JOVb/kRy++WJ7yTVZlc8CGa6NM2i57uiECDWnGeRVRL62hhVc4wVCbt9rI+p1S8iF9Z4e5zvENs5XESlAJzDc8PpahjY7D4CU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879694; c=relaxed/simple; bh=YYV29pYTxYgsBWsZzEyM4sTYsqOEA1TfbxKd63pMxnM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ghE75HxRHh8lHtW/oyLC0GNw1sez6UAWdKgLI2d8o66O2jV9/2qS69F7x7YiHQ8BO+6goqb2Vxe0NGh/Pgzxz7ASiBsOpLRc2OEQ1YkyVU5fVN3NDBmpsdXetytnTDytWylk2sz3tfBI82nrVQxkuauqdRq8MYKU7aNzCvRuYi0= 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=hfczvDxY; arc=none smtp.client-ip=209.85.160.51 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="hfczvDxY" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-27032e6dbf2so4560994fac.1 for ; Wed, 28 Aug 2024 14:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879691; x=1725484491; 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=IOeMxAMMFxnDV6WSRHEEFaOXZzMwCrDnlmMbJf8550s=; b=hfczvDxYM7ZxXbVgmdBrDxl8P16sI9YRyS1Hbe/XcL1pJiNXXVqcgcMfQMQRIMVO4M zxQzpyerQbsLzNopJ3T+kIokuiYJzgWsxZHdgT4XlbJphG7lcqgTVFmtx7gkwsc9PB87 G+q9T3PFr/BcbnHvp9IahB1W8m3Z5PYS+xJIjvUdsiEzvRfW3R2d5r5UZagbSFmSkX4O q06vlVPsiB9qpn5GRgogOO2WoQOwwsBwkqNYlv9ipMKWb5Ej4jbHGTJWeTH7fTrkSKs2 AcFdvfwWfZD6RZJ3bQ3arbVB7AuZLk9/HqsB4dRyCyjVUvCu9X6zHpz7wHsQjElZPZg5 uqJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879691; x=1725484491; 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=IOeMxAMMFxnDV6WSRHEEFaOXZzMwCrDnlmMbJf8550s=; b=NOrBqRAh7NDOkZ2ZpjttCOHxCqcmpfM4EjYKiJnhf7OTc7sqlForYypR22LA6ySSCe BaWPPPZvpa1VQp0ITVYINkV6CDvL8Ud8XclTFITxbsh3ordPvKC8srOSyXVkS5B/rasN LqoDt8QkNd5PHlPKMZLB+ZptRfmo0TQlBpow6mzhGVzM7a1XXHbWmmO4Y0grJcbga1lo bdjUFAH55s5Xoe76I+VYTxzamTEdSkDVQ6kkZfACcOjA5hrFPDX9ePBcEWwA8ndM5qGI qMs2WT1ILQHJS1OZKa96XMxQeNvJ1zBzobx0tI82ich8LJUcSCEXwkd1RMd7McQr1tQX 90Dw== X-Gm-Message-State: AOJu0YyypNP0DkwH9nSGRFsqr/mQuy365N08+JhUYGhOyBnQ9nW+GIex ielO96Tq2KNvcfe5hJDq0kJUgJuSkV9nZlc2rrx4RbYHtsvcp4W7iDKH6TFtIBAPa8CKTF2Wk0D L X-Google-Smtp-Source: AGHT+IGrs8pmhwfKz1j0KuxKzV5CcsRblneWVDYyTUFpBSY7Pb4LaK4/+opYZbwHHY82Wv61LijoZg== X-Received: by 2002:a05:6871:729:b0:260:3ae9:c94 with SMTP id 586e51a60fabf-2779035f7a6mr863273fac.51.1724879691219; Wed, 28 Aug 2024 14:14: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-7a67f3fb45csm668997485a.114.2024.08.28.14.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:50 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 08/11] fuse: convert fuse_writepage_need_send to take a folio Date: Wed, 28 Aug 2024 17:13:58 -0400 Message-ID: <84ea16d5fbdcdb0b0df1d6e0c764e479aaf3af25.1724879414.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 fuse_writepage_need_send is called by fuse_writepages_fill() which already has a folio. Change fuse_writepage_need_send() to take a folio instead, add a helper to check if the folio range is under writeback and use this, as well as the appropriate folio helpers in the rest of the function. Update fuse_writepage_need_send() to pass in the folio directly. Signed-off-by: Josef Bacik --- 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 7b44efbe9653..8cbfdf4ba136 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -484,14 +484,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)); } /* @@ -2320,7 +2325,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) { @@ -2332,7 +2337,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 */ @@ -2344,7 +2349,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? */ @@ -2366,7 +2371,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 Wed Aug 28 21:13:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781996 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 D2C551AC89A for ; Wed, 28 Aug 2024 21:14:53 +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=1724879695; cv=none; b=MyyvSOpImsBdIM2vY/6aJrx/qcFV2YodvH6xfDtZoOOmSiKJtS8+jhpYWFD+a7Cm3XMWb5yngJ4wtovQrGSwHe4+iLNroFtZhiOQC64ArOhAVkxCFD9NJ5on7LvW3tSapoEMnP350Oktb3klZS8H3VgWhxsOuh3t+T7UhYoGwM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879695; c=relaxed/simple; bh=4rZvwGfbKAIBj9NqclSxFrsSSbejHF9TcbujolMP7AU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rh4zDhZghCUVlt4d7gJufO5PXkfrTvvo42bFYyQb180OKWTeeMozcKYcCQd6ZyNFVih0B75VU6yFj/vzQ0bdJ4yfnm7zBL25nzz2g67QyEnYU9O9v4A2zqCurUb2lKxcA/LG4OktVKvu8btuWI3uBBmY0wwe6YoQ44qL0EQKJMI= 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=SbNd7aJw; 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="SbNd7aJw" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7a80511d124so8074485a.1 for ; Wed, 28 Aug 2024 14:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879692; x=1725484492; 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=MusPcByFgHJNuDczFs5hE0TNcGAUiigavtLQWBQ3zbQ=; b=SbNd7aJwj0Eo2CT1f5Kll99+sfijmm25TFxpuGnh4YeneV5Gpvfrnx7tk5lYkmk6uu VokHWyjDTTdRbQ04ePAG88WC55aJBAP4ZMvx6dMOXnW6pEb0bL/LacwTNeEza8Ddge2i dDSNZ2PJARfeHpnQYnhjMgRihtLl0Ro0rAUvAanP/SXSz/HgYvE5zqLXvXFKVky7UPfd 1n0IliZqQBQoETTmPXI/5XfbgXsLpvWZpre8iwQLVgHRZ4w+s880xOINjEjuBjAOvhZs SeW3yjbTvQkKwzZGJ6plVFLjhlKFpONYt8eec2a0bbKCka77Nt8I4MxJfY/Sazhm6BdC rWGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879692; x=1725484492; 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=MusPcByFgHJNuDczFs5hE0TNcGAUiigavtLQWBQ3zbQ=; b=WmefK6TvVvu8kE15GWEq0J4LArcWaMipU/diTSCxte/Y5fAyETrHLqB+aLxoGq0FJe SjVN0Mn7mELxuIrjnoONS8hk+QzCVcPlyrF5q+TFuHYTXU91a/U4xAYSKFQpaOecWDG5 IfNQTl6V1ixO47MHsXoQD3eTXMtgjkqKsgA448HCA+ijKW5XiqiqtdZGr/tl4Z1RYpYH ouvaYmZxYK7raTJIBUXFqUqJuJrwHUBwv1JvGe8eO49yfbRxs034CQdRz/IXWMqqSiH6 Z5KDrJwvzRFCzc6QMJw4OVCdQlGlqs/mEem6ruuukwAuFSJTZaR1f+/fWUllHhsyub+v dr/w== X-Gm-Message-State: AOJu0YzjQSAJuClb340iYlYveHrw/+6ZD9GXRFeuY67mkBmcr0a1UYyP PTeS7xIDAKAUuPfymWPWalqFIxFw4Wb0YoIRmu71KHQ/gNQGSpnV1B5SoXi8B6hVvaCTjJ3VkJ3 T X-Google-Smtp-Source: AGHT+IGuFCvTlbgVLr0XDdKTxJsNDwVAp9iuVTPXA8hWxUAPIk6Uf+K4ynAcRjIw7cIUXEIEr1TXzA== X-Received: by 2002:a05:620a:3945:b0:79f:1105:be3 with SMTP id af79cd13be357-7a8041dcddbmr79627785a.40.1724879692589; Wed, 28 Aug 2024 14:14:52 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41cdd7sm663410785a.135.2024.08.28.14.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:52 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 09/11] fuse: use the folio based vmstat helpers Date: Wed, 28 Aug 2024 17:13:59 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to make it easier to switch to folios in the fuse_args_pages update the places where we update the vmstat counters for writeback to use the folio related helpers. On the inc side this is easy as we already have the folio, on the dec side we have to page_folio() the pages for now. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- fs/fuse/file.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8cbfdf4ba136..9556cd31039a 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1852,12 +1852,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); } @@ -1869,7 +1869,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); } @@ -1924,7 +1924,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); } @@ -2144,7 +2145,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, @@ -2318,7 +2319,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 Wed Aug 28 21:14:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781997 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.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 201251AD419 for ; Wed, 28 Aug 2024 21:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879696; cv=none; b=r9awNp2hA8ULWXcphGDQNsLd/AlNQ/xdK3iVXcs31k4QdqGvKPL4JAkgCXotQweD8aLqhckCBXD5TN9Z2DAUXG+dwnCLSGlm2QYZRtO+2JD3xFo2epC3N85kwDqpHQSPKm9k+IHAQ7CPAXOUp1oqQThjw9qwoB4NPrODO5dGv9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879696; c=relaxed/simple; bh=CcHyS6Bom3SQZBn4LjTJ0CfHs6M34Rvnq7tBZEB3EPg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IvrYHVVuUljBzolNN0IgcdUnEwIRqGrBydJTbcnnxd+iVNMQ6zeCLJif99feq9jjLDvPHzaLHo+Wj0b7IGwU5Xq+ntajI1mckzFDSZcST8+IqXUdcaYr3T/KhmMy3tF3+6izrZA3cjcKDEkEQk5vtPpC8ECvG+Qgr6ci5K+bW80= 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=PIvXS66T; arc=none smtp.client-ip=209.85.167.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="PIvXS66T" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3df06040fa6so160896b6e.3 for ; Wed, 28 Aug 2024 14:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879694; x=1725484494; 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=UYShWyaopsca1NyTpUxwtu+pR/ZJZzNE3uDTpWEJNBM=; b=PIvXS66TPDECWoHGsq5uqUx9w3mvqesh5x4yx9O+msM7pYoYc0/DHyIzoYkuc2OV5/ nLsVu8w2qGBIXiJSlJD2uTcbrK5rzzl3pEOnEl2TK7lx5vr8eoeHDuDdYDD6yPjKkTW4 Jk/wlyJi589JDGKRKnIzTbqy+Rcp85jI1XMwQoVpBXhloBtvoEhhvvYX8kR/JsEButdA e2knaub5godJ/OIc8TD/1/rDbd4DTP90Q1ytVIWmQuwE0YB9EFHiWGZdg86lPxdlEVED X10fYMIkw8Bz5foHKm2U3Esgl1s3tuxn5ubwDf9tT0XAreTFhTpJa4FVbx566UsaHdvE u4uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879694; x=1725484494; 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=UYShWyaopsca1NyTpUxwtu+pR/ZJZzNE3uDTpWEJNBM=; b=C3DvGhmlT/XSahROgAxINTTlKlDo5vZ18U8i8gZwSgk1DZBIFOwZJVTbFI7Odj1Ebg dCUyyJYqdrJcM2L5wBmQYjYZZwQiT2WXTI065xdfrREri6vFaGQcGRNncYVN8j31VM/3 LpAtG+cl1yyix7j0UQrTx901Pt2k3V6qzX0+UQzslH+1gM1nsdW/NYKSiqCXPW9FaGYg gtr0JR+YNoEhKA8eHf0XGgCE1l688lP4QSylGpiszgXI6TAD3IMNEB6G332ruOcD/m/D mZIBriGrjl9ZumlrbQxLcferWqSZyW4pZhbkoPzdhrVhl91VmxGuYcT40pR45qtcojvH AC5Q== X-Gm-Message-State: AOJu0YyBQb3dOfMedEyktKZGR+r295doCYdDzlRo5pT7Vl+vnoMMjRH3 /TeYYCLPi2swSBt+iNpi3fq14sBuAGcGJSuMqBTV0mGWz4SHUK+Poy7Gn6bVBd18f0y74ZlW/P9 0 X-Google-Smtp-Source: AGHT+IGjtvhd2eR+I4/nw0bUxctwKBMWlFHJc7HHnEtcoaZAeyrZbCVspG/32FoJ9h5Ia1MqFWNHfg== X-Received: by 2002:a05:6808:124a:b0:3d5:628a:a41e with SMTP id 5614622812f47-3df05f05ec2mr692532b6e.51.1724879693991; Wed, 28 Aug 2024 14:14: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 d75a77b69052e-454fe1c58e6sm63969921cf.96.2024.08.28.14.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:53 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 10/11] fuse: convert fuse_retrieve to use folios Date: Wed, 28 Aug 2024 17:14:00 -0400 Message-ID: <91692a20e0f3282a819905d75bfe0d19bb5c8d5d.1724879414.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We're just looking for pages in a mapping, use a folio and the folio lookup function directly instead of using the page helper. Reviewed-by: Joanne Koong Signed-off-by: Josef Bacik --- fs/fuse/dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 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 Wed Aug 28 21:14:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13781998 Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.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 D92351AD9D5 for ; Wed, 28 Aug 2024 21:14:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879698; cv=none; b=q6Bl7hyoQ4ki1EosAAsf21IO4p6dX6QpVlIMYvL3f9UtDnqTVvgmT35FYYFZYe1noaTZx2j+5dHhQzY+GxTOmnWhYrTMsUyTtZQthvqAZ1gDmpsAWqKXQpCRKjv12zJRZFq6lcjFT1e77vO9kEkBFuuGIrqPMJAAuOz/S0Mjek0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724879698; c=relaxed/simple; bh=X0DApJFK7Z5eoBilBYIivvWd5ORVAHNlmLt50Lda20s=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lfuMYA/cwObg84CsLK5qJ1lFWMuM4TzIAFGrPPvY6OMa9bRFzQBBolYJfCwjPk9FTUkWagge3kT0M2FmayhIFHA5RgHd+g6+8e/EGHczdALdq0Psi/KWpeL2jgDr4ddUBSPdrspEVjO1Eds1x5VfFcCE84A5XD8BN3Ii32pl6rE= 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=fqtKtSsI; arc=none smtp.client-ip=209.85.222.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="fqtKtSsI" Received: by mail-ua1-f46.google.com with SMTP id a1e0cc1a2514c-844c333b03bso3022241.3 for ; Wed, 28 Aug 2024 14:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1724879695; x=1725484495; 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=fqtKtSsIyxAxHLVq3RPOvT0cnLDRdKw04eZafgPfR4wA+H+4N8ehl9ebpLnlHAU77E oRK0RVJqxYeT3P+B4h32shAbltLGguTAOarlaeJh6XK/o1tOXsKd3jbGU4XKuqbguhr2 flXhDAqYwxdOBcx4tKn1S7XKY2+N9eMzpvOFu3vhybBlQ3Yt8C2x936zxlvEMmMOLiSW JAEIDPubVjIakH9XYRldRKSjLXnhYOIvLU6wnZrxzuyVCQdtFS+w6s2FbJKzqrrHYkYI lD87cZ5hATxwhMI2U9aB6LfA9+KxVnOHz8W24Bkn9sLu5ccpe6r/FmPRY8Eqq5fVPO6Z 8JMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724879695; x=1725484495; 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=tze+H+ACTXhX3CubQH4KowtqcRQRHHrfhd8HI80o1Ngdew+JYOtvWcizusow7HIt49 Z4DINW3IuyzHL6Rkt826gSkIBv3BiGzIw1ByE6Tg7BoeMck17sLalpccI8TtyZE8CnM9 1MalGJV0ayx/r5CGiMSwFqBcGIikehWnQaSgcWUvGL2o2bWdmYlg4xaH46A7I2XYYNe/ wFqDqGgN/quBLa3MtudRvSjgXH6k4zWEolZgJB1nbbePLBX+xDnAsdbv+UQOqL09eLhY dBJVQZEPUpFeNiryLCnZPeHLJ1bCFvRbVXME+N+6axsmtdFjQx0hQ9ZvqglCD52aR9Hm rekg== X-Gm-Message-State: AOJu0Yzh2vkCAZEfrrlPdghJYR7g/7bClIWkoOCIPT1iCWI5eO8GVuTt bwaIyw9sGCgaweufyjWyDku1BzW6FO0TKK0wME3gNYrz9mrPiZ0hMkewyb9vkgVZJO6gENPyB6c d X-Google-Smtp-Source: AGHT+IFkhV/basfN1i49vA2sQlF653aznbM7x+swturFUn1MRyd0UAYuYiIbhR9jqEeU27fdmZPrIQ== X-Received: by 2002:a05:6102:f10:b0:498:c2cd:1ac5 with SMTP id ada2fe7eead31-49a5ae3a057mr1247859137.9.1724879695365; Wed, 28 Aug 2024 14:14:55 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6c162d20f07sm68345536d6.26.2024.08.28.14.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 14:14:54 -0700 (PDT) From: Josef Bacik To: linux-fsdevel@vger.kernel.org, amir73il@gmail.com, miklos@szeredi.hu, joannelkoong@gmail.com, bschubert@ddn.com, willy@infradead.org Subject: [PATCH v2 11/11] fuse: convert fuse_notify_store to use folios Date: Wed, 28 Aug 2024 17:14:01 -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;