From patchwork Thu Nov 14 15:25:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13875210 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 5F313D68B32 for ; Thu, 14 Nov 2024 15:28:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6B9D6B008A; Thu, 14 Nov 2024 10:28:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E1CE46B008C; Thu, 14 Nov 2024 10:28:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBCE26B0092; Thu, 14 Nov 2024 10:28:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A62786B008A for ; Thu, 14 Nov 2024 10:28:06 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 385F3811F6 for ; Thu, 14 Nov 2024 15:28:06 +0000 (UTC) X-FDA: 82785078264.17.218C444 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) by imf23.hostedemail.com (Postfix) with ESMTP id 59A4014001E for ; Thu, 14 Nov 2024 15:27:35 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=EtR1GyuQ; spf=pass (imf23.hostedemail.com: domain of axboe@kernel.dk designates 209.85.161.49 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=1731597995; 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=QzX2IvmAROGBANn6HEgih/p/Joy2MXPhit7EzvqeXZU=; b=MNyvQBBsanXNWq2jnXZhZb6e6a0grCJm+CP8nc+uUPpNHJocd0v9ZhVtfKxasaEYUg9Kmb 1Cr51qYQ7McKqhSmMdGkIKJft3Lkkqoye7RToBimhGo0jT3L8h1/BF+EDVNW4xTECr5o93 xAuHjrp121+C6rSw/7LMbQmYVY/3pu4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731597995; a=rsa-sha256; cv=none; b=q927qs+bV5xy3c4nWR0vurJwWo7sl85zt/PQSFsQRTXxLlgAtKffLF4SSC1qKShJ2PUwUs +nTFuDHqwOxl64MERAoNYj5eaHQ4OvWvgv1ZfHFv/JOKX2g0b5k1lRktgmrzEkSn30xhH+ JHLIBIOJ46O1ferVOkuGzjKRlYwzz1g= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=EtR1GyuQ; spf=pass (imf23.hostedemail.com: domain of axboe@kernel.dk designates 209.85.161.49 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-5ebc349204cso382957eaf.3 for ; Thu, 14 Nov 2024 07:28:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731598083; x=1732202883; 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=QzX2IvmAROGBANn6HEgih/p/Joy2MXPhit7EzvqeXZU=; b=EtR1GyuQhhP02s0NUgTCQ9PyIS3lD6HsgVePfpY4sIQFp9BLX1EYR3hNTvv7dK6WYh Vp2KNW9QKgEuJWapfoh9adu0x5SaaMvNGR4VwaNHCSRkD4YuSZN8/rrkm/Z1MS0XcIYk Tps3Qe7dL8d2a8Kmp78UHMr4Op1ZD/JEzrUT3ne7dwG0jw8JWfU2G7VnO6nH/MHhTT/W 2lPzoBHJonjGuSEF/6yMSrGwY1RtwhdycY2ktNUMRFw3oZbRuGtYzA4mh65nay4VY6yC GhFqZHZrgMFZWZLt5Iw0znsGhPifcyGie6USWL6q3eAEXa1zqgy7tkQVlmlpsMdpLXcQ mCkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731598083; x=1732202883; 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=QzX2IvmAROGBANn6HEgih/p/Joy2MXPhit7EzvqeXZU=; b=ZqCTHI6ZG5MlCM3XsF4ZmuCb5JoZwKX4CXBb0wQiUc8lsDUcVGtWvUvG61l996wKoi fwgmpjq9JzkHfn36JjY/bqD9msiUjhdfx68wgKr4jVFesNUASaFAq6bPxJl9/yZYx3l2 b0JmjZGOf/yBVywAekao9lD3IiANFaK3pKTTtbu3e+kQub4OIBNC26FZt4X/vzqbQts/ 9DjIyROvpYK6Gig7C6H0v649IIpN6cHlXfgmvg0xniwgc2jibposkzASHMM/01K5tKNG f5RpY0lbRPauo2y1Ci5RBZyiF5/bkkSGGZZqqkDC1idEvjWpsxjQqzTF+ATr3TVjDZlp 2ocw== X-Gm-Message-State: AOJu0YzGzDF5nqKxyqJWW2ty/ziz89uft2+d2hlKQw2QV7hJmwpZT+5n 9tT468tjCu8ce/XHCu3RNdh6qBDPMreSo3Y2tFEiQ6mEWr0tTMhadEu/HeUa5DFoi7xdtRVVjtc CBSM= X-Google-Smtp-Source: AGHT+IFRnE0ztQRJK93idhhgrf7Bc5KUMDNOKjdutZVsJeSEeh/0aaiCxUu41HRdHQkrlLeWeSTtMA== X-Received: by 2002:a05:6820:8cc:b0:5eb:6a67:6255 with SMTP id 006d021491bc7-5ee9ec3bae1mr2680975eaf.1.1731598082894; Thu, 14 Nov 2024 07:28:02 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5eea026eb41sm368250eaf.39.2024.11.14.07.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 07:28:02 -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, kirill@shutemov.name, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, bfoster@redhat.com, Jens Axboe Subject: [PATCH 01/17] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Thu, 14 Nov 2024 08:25:05 -0700 Message-ID: <20241114152743.2381672-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114152743.2381672-2-axboe@kernel.dk> References: <20241114152743.2381672-2-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: 1h13yggsuusxnsyfpqp31c6u66fqcm5i X-Rspamd-Queue-Id: 59A4014001E X-Rspam-User: X-HE-Tag: 1731598055-934488 X-HE-Meta: U2FsdGVkX1+ALKFSCqHIFadfXI7aidHFpPmrFD5O5ZVixzc70d41i+jYRuMi63RWRvt4Gv4m/JIPoqbU0hPr1GxHmEN56TB3QV0jT0hM/pEc/Cn0I+vCwJYnjcM8p9ry2ry0kVRikzeL14lOEvQfTFCb2aDboAZDkLEDzQJ9jZElC1OIinlukMGwDlti2iStvResIPpfNl88ifQYDigSMHqhQgWrkeGKokOkzam4ooRormpY7wBSx4Q6jQjwD5AEw42f/K1Yxz1GXy4la+37iCQVpZt5oWTRs1AyQawTk8vsRpDW+34Jw4NV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IhyrOuFy47myRPxydznII93U1RYxFvEfKr5lgS4o9o0wuG+L7h/pMqsPMBK1fDow6tu4D/IMW7qKHWppTm6xIFA== 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: Rather than pass in both the file and position directly from the kiocb, just take a struct kiocb instead. While doing so, move the ki_flags checking into filemap_create_folio() as well. In preparation for actually needing the kiocb in the function. No functional changes in this patch. Signed-off-by: Jens Axboe --- mm/filemap.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 56fa431c52af..91974308e9bf 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2460,15 +2460,17 @@ static int filemap_update_page(struct kiocb *iocb, return error; } -static int filemap_create_folio(struct file *file, - struct address_space *mapping, loff_t pos, - struct folio_batch *fbatch) +static int filemap_create_folio(struct kiocb *iocb, + struct address_space *mapping, struct folio_batch *fbatch) { struct folio *folio; int error; unsigned int min_order = mapping_min_folio_order(mapping); pgoff_t index; + if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) + return -EAGAIN; + folio = filemap_alloc_folio(mapping_gfp_mask(mapping), min_order); if (!folio) return -ENOMEM; @@ -2487,7 +2489,7 @@ static int filemap_create_folio(struct file *file, * well to keep locking rules simple. */ filemap_invalidate_lock_shared(mapping); - index = (pos >> (PAGE_SHIFT + min_order)) << min_order; + index = (iocb->ki_pos >> (PAGE_SHIFT + min_order)) << min_order; error = filemap_add_folio(mapping, folio, index, mapping_gfp_constraint(mapping, GFP_KERNEL)); if (error == -EEXIST) @@ -2495,7 +2497,8 @@ static int filemap_create_folio(struct file *file, if (error) goto error; - error = filemap_read_folio(file, mapping->a_ops->read_folio, folio); + error = filemap_read_folio(iocb->ki_filp, mapping->a_ops->read_folio, + folio); if (error) goto error; @@ -2551,9 +2554,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, filemap_get_read_batch(mapping, index, last_index - 1, fbatch); } if (!folio_batch_count(fbatch)) { - if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) - return -EAGAIN; - err = filemap_create_folio(filp, mapping, iocb->ki_pos, fbatch); + err = filemap_create_folio(iocb, mapping, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err;