From patchwork Fri Dec 20 15:47:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13916932 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 B6A11E7718C for ; Fri, 20 Dec 2024 15:48:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 738B56B0083; Fri, 20 Dec 2024 10:48:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E7BE6B0088; Fri, 20 Dec 2024 10:48:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 588296B0089; Fri, 20 Dec 2024 10:48:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3C0396B0083 for ; Fri, 20 Dec 2024 10:48:40 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D3554120BBB for ; Fri, 20 Dec 2024 15:48:39 +0000 (UTC) X-FDA: 82915769328.04.F3AD808 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf22.hostedemail.com (Postfix) with ESMTP id EDCD6C000A for ; Fri, 20 Dec 2024 15:48:01 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=FfY53oW9; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.174 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=1734709695; 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=1VCPzs6l+RtFDMTSDAiMfSmCwqht+PTO7Juc8Thzg3k=; b=tbVz26qA5C/3GRqTtOPj7aQyj/WQafCjPmMnxbESUrkzSolvSXupUflZQE9Qi2IQXW2L+O BCOFEe11WAq3X3zkpjw5OT4lRYKJkjMUTSeU95lkhCg9ysIAddGcyW8u/0N47L1O4Q2AS1 lm+AZjrPpYF6tjfJ5yU+m64b24gxts4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734709695; a=rsa-sha256; cv=none; b=23OHADy+zPhXlL5H+UkREQBHkx9QpJa3q+/MfPWBEc3yTNZ8cKFXl1meOW8urf58BUP6A7 a9+/Lq4d3WcpUYx/lf5im9f+vDjAsNBIxUC3oek7lfsNaAeFc/gGGOj2D4QTUqi8FbhMpU bJs5JQft1oDkS7VdQwjOOLC8WKtplus= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=FfY53oW9; spf=pass (imf22.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.174 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-3a8160382d4so5925905ab.0 for ; Fri, 20 Dec 2024 07:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734709716; x=1735314516; 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=1VCPzs6l+RtFDMTSDAiMfSmCwqht+PTO7Juc8Thzg3k=; b=FfY53oW91vwovZXGphBn48G2842QdBbeO9zvIZydZm8P/fN2uDKg+/co1Js7DJoAOs y72Zvp4iSPqPW0zzgZgmsG9tEzKhVdm0T5K8Vw02XhoypDQ8kW7zS1UZ4ZqSYcZa2tN+ 9xQc565SjZ9NxRWV0BaTvsT5o0ziL5zXqmbXR3E2CVFcjl2qDakhBvR4vw6lutbvmd/2 1WFxwSmJp+vvb21SvvWE+3PQc/n8fowVXvs7+q0hpVHWiQn7fu2jBeGWZdlmekkGIVuG Fs1q1R3+G45v/X1JTYigt6QR7NORpq9bxrjX+dShJKpLsku0d9e5uI97RhQIgaSr6qK3 FaVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734709716; x=1735314516; 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=1VCPzs6l+RtFDMTSDAiMfSmCwqht+PTO7Juc8Thzg3k=; b=L4JebB3cLuRUi+YVdy/romF0ebUe0B1AbhPVXVpUhK50yLzAdJUGYmvrWBcElmQ2xV etBRdzC0bvlrOcrKchi/ezZHipBNl9frWbDErlFq/oJfLXVpc0Cc2QhPdKhBXfYyVZgh BzJr1Wt3hwhQpJsIs2fV+GtArVDKx1zfiO4OkVOnFAYu/CTxjSlRvrxK1WvkBBJQhT/u oJx5ag3VJ38o23bEKIMuYcaNC7H8APFKgK1BedxyeEaOhjjIZ0l3Rv4AxArMc/BDatbx EdYWGEQJmOPkrh148XzKS+aOGGaYljiCpMdFxYI85vGSdbB2xqY3FSajL/7vFy1810do fJCQ== X-Gm-Message-State: AOJu0YwjrJUFSD1o0pCO3EsV5W1EC6RejCnD5yKXDarzo83EEEq7nLHJ 5Q3hnF2FoRjGDeDd6Th1QOMyK/DUb3z4ff+x0KqGQ7BDermL7syRUZVQvQyW5QvAKIMqioqmyjG l X-Gm-Gg: ASbGncuZ5zopGLHpykhmoeCn5odVJG6rs9nUYeYjB6/D5lv01Xx9ULXXu8EL57bSG0F 6n61lsSwZisX2v5je/fG0Wk99F6l8cDXwnKU/AQvX+u9T2f0rUJ5vG+B3P3VjAAL0Y85r84AHBP qLHdMVHS3cSBWohaV5Swe6BUj3js4VztpkuyLgW1QvtGE6lINyMCJiFEdwi6DU2P61Cc6F4DkLI pyEs4webt8RmMRY6QDRctku/GwdM5EvZfi0MuEM5iNOQKxGFICXaoIIAM3P X-Google-Smtp-Source: AGHT+IHcbw9zIKJRxdjYyzhRRbFlhvov/fILoOcF1iNDb9M6UqXSGlIvkLvTLfoaxOcUHsgp350Srg== X-Received: by 2002:a05:6e02:1e08:b0:3a7:8720:9deb with SMTP id e9e14a558f8ab-3c2d2d50993mr23190015ab.11.1734709716455; Fri, 20 Dec 2024 07:48:36 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4e68bf66ed9sm837821173.45.2024.12.20.07.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 07:48:35 -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 , "Kirill A . Shutemov" Subject: [PATCH 01/12] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Fri, 20 Dec 2024 08:47:39 -0700 Message-ID: <20241220154831.1086649-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220154831.1086649-1-axboe@kernel.dk> References: <20241220154831.1086649-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EDCD6C000A X-Stat-Signature: c9hequgnpk3axmqjfah5scmjykodqsm3 X-Rspam-User: X-HE-Tag: 1734709681-383144 X-HE-Meta: U2FsdGVkX1/z1tbuv7ODthqx2OuzeQ3T1lVcp2hOMTEanadBpp1dkdoCsvy5jvpDopEt7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+j5ew4MiFsIFvfSwjY3IqHzfTiGmp2CiN+e4gqfRHgkplqWMzbnBMCc3WSy+6oVHW/qP0arn15jk3E/UNRooUWi/zskRV7ETOpRnwIpfA13Gp0CYBnKhM5lblBUm7Fp5f4nViLPWmqlepuSTozXxnq97n4pjJM1t2mP+IovcSe/tksJUHAtpD1M7cRksMHCJCJSknplyCun5LamLCTQ2bZhQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.003258, 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. With the kiocb being passed in, skip passing in the address_space separately as well. 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. Reviewed-by: Kirill A. Shutemov Signed-off-by: Jens Axboe Reviewed-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index f61cf51c2238..8b29323b15d7 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 folio_batch *fbatch) { + struct address_space *mapping = iocb->ki_filp->f_mapping; 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, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err;