From patchwork Sun Nov 10 15:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13869950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1578BD12D43 for ; Sun, 10 Nov 2024 15:29:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35DA86B00B4; Sun, 10 Nov 2024 10:29:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 30C8D6B00B5; Sun, 10 Nov 2024 10:29:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 185A86B00B6; Sun, 10 Nov 2024 10:29:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EDC1F6B00B4 for ; Sun, 10 Nov 2024 10:29:25 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AE187A1478 for ; Sun, 10 Nov 2024 15:29:25 +0000 (UTC) X-FDA: 82770569112.14.F4866D3 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf21.hostedemail.com (Postfix) with ESMTP id 48F051C000F for ; Sun, 10 Nov 2024 15:28:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="1/+GE2Wl"; spf=pass (imf21.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731252423; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SJBisbj/rGvidSFxNEf05dxDvPbQrKvqbgVXmZ2uTrI=; b=ashXA1kUsC2zP1vE+UN5x8i/HRY99wbfHR94pBYkOb3h1Uw2Z2qiZ2CmDPSh5YtReju0ev dFJJQ5jcfCa6lAgdARX2bmD1xuACbvfq4byCMZzjP8gRK3XLmjQXqPqjboju+1aWs70APG xEsjxK+y4B7DGC2B3+aBS1Euq8vtQ24= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731252423; a=rsa-sha256; cv=none; b=c1OfBvf5ZfvTz5x/SueHKnUVD67uwys0GSAzcflJjR0Aq1LC85aH8tpo/DOUdI8x2nCUfe 3lKGh9L3WD6tFktrYgddhiL+4nL4LlRCY88UJkdRWJmkqrrLEZfWmba1Ob1Z0aGaOrrY0U wR8ZmxpsFGcl3E9XC2y3i9pk+3aoS5Y= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b="1/+GE2Wl"; spf=pass (imf21.hostedemail.com: domain of axboe@kernel.dk designates 209.85.215.173 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7ea9739647bso2613488a12.0 for ; Sun, 10 Nov 2024 07:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731252562; x=1731857362; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SJBisbj/rGvidSFxNEf05dxDvPbQrKvqbgVXmZ2uTrI=; b=1/+GE2WlwCRtDqXq8epwOtkwl+PwKbKK90OMe4y2M2kB6PxPzI1TNFUMcn1lMHNkU7 Kxp9faNOkt+d2/L9+VidA+0QCN0PUHr08ez6cvVOwYopmrNSnadlkmpgB1p+CchHM6xV YlUDvi1WvYIg+3YtoZJqEwmAkNMe7UzWjqPbSGP3eZMRHaQs+Nh4GqdvcAgD7c5usN/j ND09Qwu5Hq/rgyW0RPFgyuFa0GmlDN4FfNdMPvMuxrXub/tRqpgyaTru0GQ7GET0t77e 0/0rMYp2GFTvSr1p+oksgo2sJOMtifPKdkNNWaKIPlynSbKQL1fp2couCvYjGJ9Cbutt 1haA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731252562; x=1731857362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SJBisbj/rGvidSFxNEf05dxDvPbQrKvqbgVXmZ2uTrI=; b=UmzK6NTOYqzls0H2veErh3Ijuvu907peGtgHqbvPj0TVUo8BbMHomBXXjjSLd3+x5l PU/d9b/SmknNy8UCCmgA/BToqzv4hwlKmepoZ+c7MfZgO9nNMrgSoRqff4UGiWrNPsT9 GwFfAxEsstyazUqMPIX9plK888siir5UQXGulXAcYMtnXbf1s1zeJN/npu6LUqHAvdan dJ5pwpZ22TGyPDyWyM0Yc1AXCfjs5dD7OwgpVb/4gaVpFHSq3g8i7ih9ZDF/gTBh1e4o TRKNgsw+DQDMGbzbhCW+GRhXYwYysyJW4dfs4f9954M+9fAiakSNutSxtIrXhv4f2LUZ UGnQ== X-Gm-Message-State: AOJu0Yx2SBw0ZFIBrLu6R9KMeX7MIjCnra+Ef3MYrXMqsxyFxle+7xN8 Q8NuNqai8pu6iv5qVBJvejZfyOwY21hhQdyiipSCK2Ca4pWgtIzl+Shv76N3qHvXSKs4wuFagI7 5lnA= X-Google-Smtp-Source: AGHT+IEztLXy7pfG6RYnicaB5W8MU9mXcvU3VePtiJO2A6vGFaDJWmS6lrttgNl/g5B6W7Nsuo57hw== X-Received: by 2002:a17:90b:224f:b0:2e2:da6e:8807 with SMTP id 98e67ed59e1d1-2e9b177fc52mr13814904a91.26.1731252562169; Sun, 10 Nov 2024 07:29:22 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a5f935dsm9940973a91.35.2024.11.10.07.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 07:29:21 -0800 (PST) From: Jens Axboe To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: hannes@cmpxchg.org, clm@meta.com, linux-kernel@vger.kernel.org, willy@infradead.org, Jens Axboe Subject: [PATCH 06/15] mm/truncate: make invalidate_complete_folio2() public Date: Sun, 10 Nov 2024 08:27:58 -0700 Message-ID: <20241110152906.1747545-7-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110152906.1747545-1-axboe@kernel.dk> References: <20241110152906.1747545-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 48F051C000F X-Stat-Signature: 85i8x4o47o8x4gaqfrmk9pbaum447pah X-HE-Tag: 1731252489-887341 X-HE-Meta: U2FsdGVkX1/yBGrCjyYplJlgI+myY8fq5KQMO6UxIb0MQsbSRsij2ApGkzhJj+cY2E4ECdYxJoZ5EfahAzq0lS4zjRYoGVDYCiLKpIQU2nJn6yjeKSUJVaUsJ8qcf39Zhb9/OEm4jwP/ONRDtA5Q8654/O9NGU7Z+bcw4YpY/dprTS6oTX9NGFM0kfumUAInWYquMXlEW/CH/3vYKRl/FatWJ7GnAy+p/IXDzg8nEB2oHKA8Gi+312p3aL4jHzo/b6wcu48WkNBCgQcQ6mSOzo0xbcXBaShkVDJ3Gs7z/LIYRb06uFaYMtgMsW+o6tcjqJ2S5l0MV4ui3QB5bxNGx980XwSd/qxvi893saNGdkRZMRB3ZSG1cOyVXaUjpKsBBNpxsflj9qctoYM2fwN6WOe8LI3dg3gTnRvosbiWtPrw8kFvOUVAgEZgu0W1XUEJxd7v0knJ7g6bsLwyT8e6iKc5ugwqAw+1wwbhKVfQ36UIpusd8Jv6OHJRaAnmaTgwsLs8t0ge/LKyMLagDnyDLujzT+bMwn1J0nfKmQVXGxLsZ5ocjdKDjGO5C8GdfzICS7LBOotWllQxOWphDbGcs03Epr5Du/8DyZjDQOIO2DUBzv1P/+KYG3Sbp0lAWFykPmqFf9rBLN/4Ifhie7iyr+MdS67ic+8jTQcGfokncQ/4PxXJTEZAehMkFGHUfdh+BQkU8RjkD2ipCXl/mctpkBvHJB35kZDbWwO0NDu71woRMWDoBEXjYaaA0VmDfAu/+zRssGB1xAabXw4Lyt4u06dlvp7MYLobSf1aM+773C6FPKIQ+dOXyhFLJzf7Sgcjio1y3UDFT+63sLavoClt6LSkJwOApKa7lYjqa/ZjQZiHzIbOG03bnDz4H7/xjuFiPsa2IJs27/1uWMBccF7/QE89tWCE3Dwq2vCo35zbPgPePonI6QtnFXdIiJD+PcmoIRJkgeS6yHFA8vvxidV rtqK0Tgd wPCnp6oZKM6u5IjH+3VVqeH0h40kdEBooVhKfCNGskIHmQ2sBEWDtyc8Tpy+/CmkNZCQpOsd0XhB2BkxYH+VGXOpYz9eHNHaXgTwNn/IzyGLnziOovK9TyUI6dgGalUosnjYIW4pSxfI6BhPsUsOMTeVn9dbaigIkeus981vSzkvUSXrx1fm/h47fciIk3RUJO2MpxD5IjlOBMFaoWpY7f2Voyp16ysPTEgoT7x5u0dPNdtTP0vhyHEe2tV5U2F3qbfgbv9hdKZWiG0dnXyw2LC/zqGu616mWGdMhRH6hayJ10g02t0j/QQEjwo6ew1CM+JpHuWdKth0C4G3NOLpl3HO/5Zn572wfVX1W X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Make invalidate_complete_folio2() be publicly available, and have it take a gfp_t mask as well rather than hardcode GFP_KERNEL. The only caller just passes in GFP_KERNEL, no functional changes in this patch. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 2 ++ mm/truncate.c | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 8afacb7520d4..0122b3fbe2ac 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -34,6 +34,8 @@ int kiocb_invalidate_pages(struct kiocb *iocb, size_t count); void kiocb_invalidate_post_direct_write(struct kiocb *iocb, size_t count); int filemap_invalidate_pages(struct address_space *mapping, loff_t pos, loff_t end, bool nowait); +int invalidate_complete_folio2(struct address_space *mapping, + struct folio *folio, gfp_t gfp_mask); int write_inode_now(struct inode *, int sync); int filemap_fdatawrite(struct address_space *); diff --git a/mm/truncate.c b/mm/truncate.c index 0668cd340a46..e084f7aa9370 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -546,13 +546,13 @@ EXPORT_SYMBOL(invalidate_mapping_pages); * shrink_folio_list() has a temp ref on them, or because they're transiently * sitting in the folio_add_lru() caches. */ -static int invalidate_complete_folio2(struct address_space *mapping, - struct folio *folio) +int invalidate_complete_folio2(struct address_space *mapping, + struct folio *folio, gfp_t gfp_mask) { if (folio->mapping != mapping) return 0; - if (!filemap_release_folio(folio, GFP_KERNEL)) + if (!filemap_release_folio(folio, gfp_mask)) return 0; spin_lock(&mapping->host->i_lock); @@ -650,7 +650,8 @@ int invalidate_inode_pages2_range(struct address_space *mapping, ret2 = folio_launder(mapping, folio); if (ret2 == 0) { - if (!invalidate_complete_folio2(mapping, folio)) + if (!invalidate_complete_folio2(mapping, folio, + GFP_KERNEL)) ret2 = -EBUSY; } if (ret2 < 0)