From patchwork Tue Dec 3 15:31:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13892618 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 242DFE69EA6 for ; Tue, 3 Dec 2024 15:32:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD38C6B0085; Tue, 3 Dec 2024 10:32:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A82C36B0088; Tue, 3 Dec 2024 10:32:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FC8D6B0089; Tue, 3 Dec 2024 10:32:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 72A4D6B0085 for ; Tue, 3 Dec 2024 10:32:50 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3150A80A60 for ; Tue, 3 Dec 2024 15:32:50 +0000 (UTC) X-FDA: 82854039954.07.B7DBB5A Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf06.hostedemail.com (Postfix) with ESMTP id E85ED180002 for ; Tue, 3 Dec 2024 15:32:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=l6LJQLx5; spf=pass (imf06.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.175 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=1733239958; 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=ReI+Zr1x7wQ/SlfmJGhzAq3WrMPRqrYdy9B8AN1mepA=; b=QiSGLpUONlKa2GT8sce9i2dUSAQTy3lJInOhZJluLRLh1FCmGYdheVyxY0a91Tdu/s2Nqb L8CraG9zuvuXciIMF/897Zg+VFkZZdSntRFwhVLYN5v1UDp5+WAnwGWs5wv7omIB5k7VtS wGktfiMWsGkvm32Mm6L3HC7+gkO6deI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=l6LJQLx5; spf=pass (imf06.hostedemail.com: domain of axboe@kernel.dk designates 209.85.167.175 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733239958; a=rsa-sha256; cv=none; b=eRCurWrQ9ycF03NwVTin3oxYATfZpTIAHwNI9+kFnY7MaD6PEoqfgrtR25V46b925FrfAN LAv7TllbSHCACQ6TMhk7/H2wfwfAkzEEb8hXfGAg0Y8e8MSU2fVMOPg+CuI5Zeuct16lI/ Dg9Bf39C5DQYINcBbXvJSfCFQUnhsT4= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3ea47651a10so2502008b6e.0 for ; Tue, 03 Dec 2024 07:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1733239967; x=1733844767; 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=ReI+Zr1x7wQ/SlfmJGhzAq3WrMPRqrYdy9B8AN1mepA=; b=l6LJQLx5x0hWs03XVt1uRT9ROb10+MLH0v5g5qJjuBSUvpkI5H8sFyvImA/sq2yO6i Nigp6oEsixUr6N+ZswEMOzHNO7qxrxHh73Z+VIhxcpZBlkCxP0kQxsqa6hb2z79v9PRW tkAQ0CdfentDGoZ9e0nc9us1iNxuBCCOQLZAfmj8d6MILxzDpCdINZc2n/ahCV2MMr/d rrw4MKJGZ2mR24Y5IT49XAxoGcVY8LkeQy81rTNJFzR8QpMzTF/tjn1BjpdSbfFL0WV9 IJWpcfYipThaQ0XYa4JnWiilrztpFEb+B+M37hB2sEIu9vb4r1EvppBGi6WN+LvGIFba 8SEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733239967; x=1733844767; 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=ReI+Zr1x7wQ/SlfmJGhzAq3WrMPRqrYdy9B8AN1mepA=; b=dqEUAmSy9Kmw1HE7S7mtTANDz+57GJvKwWV+0cjukBSbvv6qR4nu/mc0PI+EMk2dBW HPE6PiRNRhlUB7jsRPgvq5H9EsdbjagguZxUY6tXcXoRBWEf3pazAucOF0ccGu404z4J nLUqlYD5tGraPHEQ8eyXFLpElaxjm7BtUToLVJTVnN/MX/tq2ZlATASJBVgVGLY+8k42 o+hxrVo8IZ4WvFK2NSCQq7bMsPtdtl1V0JWq+AfX1dVnx7D9rfWEcS3eT0pMGRRmnwOI 74Hg03HcQPlG8LpKVxyfYCIJAWEbefHrHum8cZtOtvCd6VMqlWzBCTOlpZSH52msQ8Jf Rphw== X-Gm-Message-State: AOJu0YwfCEv2eL7zOOo64LYN8spHIUGiLoX6CIO1R5hDhGWwcsOKobFJ nSMLxDg9EB9xaPa7sabRXJR+M+jMdVSAg2BEtqzatlmyoSjinSw2nXb6VBKUFYyKAmkK+jvSKZL r X-Gm-Gg: ASbGncvk7JuQ3im4UWbu7VA7FXXhXIlPiyV6ya1OZ3UCI6VYB6QzphD+bQDJ1oto4SV mE5a2TYLVYK7pd/+V6BBw6t00ghw+Ua7jMC1RG191so4RbAE5ByhyUhqFdz/hx5DfaCk4mHWP/f BV/auf1DxMPhuJ/rIv4ZXzbe0I4tyj02JEnTcPZdl06dN+tumxv914gdJZwje984wMH4AQc6b1y dOf7QRz08hk6TRFzPo6NTWK8R3x4+Douq3EFvAXXIvy8BB1r01i+uqkAmc= X-Google-Smtp-Source: AGHT+IEjGwc7GFJjqyvYWDgJBqgGGBcMfQCEEJJRf9YUZZ1W6BgQFHNlpJWElLeXDmEpw+9XPHnUvQ== X-Received: by 2002:a05:6808:1406:b0:3e6:1ea5:6b30 with SMTP id 5614622812f47-3eae4f9162amr3792647b6e.24.1733239966815; Tue, 03 Dec 2024 07:32:46 -0800 (PST) Received: from localhost.localdomain ([130.250.255.163]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3ea86036cbbsm2891878b6e.8.2024.12.03.07.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 07:32:46 -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, bfoster@redhat.com, Jens Axboe Subject: [PATCH 01/12] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Tue, 3 Dec 2024 08:31:37 -0700 Message-ID: <20241203153232.92224-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241203153232.92224-2-axboe@kernel.dk> References: <20241203153232.92224-2-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: E85ED180002 X-Rspamd-Server: rspam12 X-Stat-Signature: jtwd6df8homtkrg5de8i5djb1kewecc6 X-Rspam-User: X-HE-Tag: 1733239958-421543 X-HE-Meta: U2FsdGVkX1/NGC0ApLaZIR9o4kPcnopkw3reHoDwY482G4Mf849vC9UrlO3/D1Wil6Lqj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Ib14anOXxJaCfXT/ChKr4o2xnu+OIMmgAIofCuTPKUgk9usvrsOuTB7QtEdpv0oV6Af2emOH15BBuHnR3qGCpe14NJZ2XBGhl1GOQP7GT0Xm4uBYFOQ9/zgBPd2cMkCMaTjfi8QwCvqp/bzogLVNCcp9dnHglBscLuK4zWUDZi7mdHQSyITons6EVDjHVSukKmMlYZ 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 7c76a123ba18..898e992039e8 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2459,15 +2459,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; @@ -2486,7 +2488,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) @@ -2494,7 +2496,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; @@ -2550,9 +2553,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;