From patchwork Mon Nov 11 23:37:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13871484 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 145F1D3ABFD for ; Mon, 11 Nov 2024 23:48:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BE626B00D4; Mon, 11 Nov 2024 18:48:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F6C06B00D6; Mon, 11 Nov 2024 18:48:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 670436B00D8; Mon, 11 Nov 2024 18:48:52 -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 4727C6B00D4 for ; Mon, 11 Nov 2024 18:48:52 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DC1A1161AE0 for ; Mon, 11 Nov 2024 23:48:51 +0000 (UTC) X-FDA: 82775454762.07.ADF78E1 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf07.hostedemail.com (Postfix) with ESMTP id 5BD2B40005 for ; Mon, 11 Nov 2024 23:47:52 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nZw8RX7S; dmarc=none; spf=pass (imf07.hostedemail.com: domain of axboe@kernel.dk designates 209.85.210.171 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731368801; a=rsa-sha256; cv=none; b=k/Aj1N9xVcbexfKDj6PILuAS5Optqu/CpAN3pNeshjFGo+1TRafAK4ZkjMimVpLiRmIo/c qaP8erNmYmYIZwj7eqyGiMSYiE9oNs+rCnZzO6Gc4Dt9KSnrD9i25Wp4lmGlR17rIBnYtp QMvPpDeMEYPi0rWaVPbCJwILZY6ZAwM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nZw8RX7S; dmarc=none; spf=pass (imf07.hostedemail.com: domain of axboe@kernel.dk designates 209.85.210.171 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731368801; 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=InlV1VYvfgPrbw00kx0NXAhK4Dtz16qLkohbyhMyFJ5v9OEyVhRj+Vpup1ecpGXTd6jrEv 2g7Nk9y9NXbh4uPleMenDGih2QzPWIg1dFRmsQbM21dKTLS+Srwob2tULwbzUdj5NCv/EU cchyRmID4A8qXIRGgtQp52TPBCAMIVQ= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-720e94d36c8so5156763b3a.1 for ; Mon, 11 Nov 2024 15:48:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1731368928; x=1731973728; 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=nZw8RX7Sg2JvCXPZ/OWee6WZBtXpxJPVjcxk/O9020MOmgfxrFWnhwvw9SWMCsk0sN G6O/Bs7whHxTBknkcUehB1/fOMvgYm7mlTCcYOQK5KZSI6vQNSUfkS+BQTU/nJM8ed1g OHd72BLa6V2S73sP800z6yKSxpTJhvcnxsG9NF3J5xNsqqL0aXJlKQCL4OISOYnXJ0EV Ze5lOfVBmsymr2g08DRysHR/CipD+4Kd2te4aXLrKg42iRGekDJ5Q/QS4Sa7gR9TzXaf EfZ0fG4ZkvpzHYX4cPUYq+4+99KLR0ZY2+PtnbyQUsW88Ex5ljpWlfW9JP80zvFm0zlR BuDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731368928; x=1731973728; 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=YFVOqScrm6iRQvDFBRDD1HIKB15jKQ5Bmkz0fxBRLD9yZIdbX0f4m7XhT8EYeJLP+i 0pgXXpTUUF3MOb9C4mNBHe04+jpIHWftHxoYNszN5WeVxsNqx/ztbxSN0SkYGAdDUevw 4cvsvvNaOG6ksTCBHz8kWY7TWx5TY/K0Qvw5LDjBflAu+bkZgZMwAkpwBPb6Tw0pDZIy TpIZ8q2K4G3R0qZDiMCwSmiNGj8uBy8BMl9dLNEN0usWiBusf2T2M8oe4xCmyD9uSFjE qyqWlAwguDVzR9zYddx7bXszhoF6zGVjY8e+2kky4pRc9tViu1vr736ZQSw7Srpbkhg1 cL2g== X-Gm-Message-State: AOJu0YwkSmYbJFeU7195bnJ2ahAunXzhXlXWXpK9/s1aGpAUGOQG5w1E beiFz5oje2rr1X7N/eSs2hWxeIOc+QbZtskXQj2zHJLifMnQYBuhAIV2EN1G7PbqOh+wrqUSM30 69jM= X-Google-Smtp-Source: AGHT+IFPjohwvXk7XeJJhxpW4zvvN4HHe41fbVtZtFFrzITrw1kyHBpDFfhvHRsSHEkN13Wz8BpfRA== X-Received: by 2002:a05:6a20:12ce:b0:1d9:15b2:83e with SMTP id adf61e73a8af0-1dc23322093mr23031517637.7.1731368928327; Mon, 11 Nov 2024 15:48:48 -0800 (PST) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724078a7ee9sm10046057b3a.64.2024.11.11.15.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2024 15:48:47 -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, Jens Axboe Subject: [PATCH 01/16] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Mon, 11 Nov 2024 16:37:28 -0700 Message-ID: <20241111234842.2024180-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111234842.2024180-1-axboe@kernel.dk> References: <20241111234842.2024180-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5BD2B40005 X-Stat-Signature: dbft8asanhs1ee8qrmsqm5pfq7zau6is X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1731368872-462871 X-HE-Meta: U2FsdGVkX18KtmaI2pa/3RG0Sn6iwYJKd1EhhKFjcPjkfHh0qz7m7zmdApdPcMoccdG9OpWLFtfFAV6wzJZ5GFmq/GqM5OwKsMOWsVloBNvpXiE7WUKDblWeoOKhS+/m+wxE8KyOOVd6rLNm6c2vDBQNh4fs9FOE8wZ4rAnV8UY2gHfJx4rMkRdG+hIa+dB0eTgD0HBsXGuHje766YAghNIoNdfIShFDrYE7NYa2ihjhYpVt0S33G4KqttKb2vuVPXuqWtY5spfC6nloYUT1gGxNkQ4oYbAgtkWHhxY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amicity=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;