From patchwork Fri Dec 13 15:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13907398 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 6BFF3E7717F for ; Fri, 13 Dec 2024 15:56:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB3C36B0082; Fri, 13 Dec 2024 10:56:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D89D86B0085; Fri, 13 Dec 2024 10:56:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2B1F6B0088; Fri, 13 Dec 2024 10:56:08 -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 9EFA26B0082 for ; Fri, 13 Dec 2024 10:56:08 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 53722AF643 for ; Fri, 13 Dec 2024 15:56:08 +0000 (UTC) X-FDA: 82890386208.13.B837EED Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by imf28.hostedemail.com (Postfix) with ESMTP id 6C8A2C000B for ; Fri, 13 Dec 2024 15:55:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nAxIGxvL; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.171 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=1734105348; 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=aJTsU8FOCztsZChrgynI/se4Hg526H6WFOVyatkHjPA=; b=5a66RRRoqy2ake808EgmrhKjnCx9yaJUpHiuTfG15cjOcOJd1zMts4irPo+WGKdpxvOhok abUaTKxzw/rOM3rMYgCizE/7zC3gwZMWYvUGL444+qktJETf0ptKwZ1lXH16LBPvtAPgv8 z71GM6OpPPKQh5fObDwXN0ywEfRBNP0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=nAxIGxvL; spf=pass (imf28.hostedemail.com: domain of axboe@kernel.dk designates 209.85.166.171 as permitted sender) smtp.mailfrom=axboe@kernel.dk; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734105349; a=rsa-sha256; cv=none; b=kD1aIF3lbYQFi0tr5Q6zC4yED6j1JvohtvDhk1Kn6Sx3YW5OYaOa4cOQ1dDEuU4dCcsj1o vUNvVP9ePSgVpr+JXmw82//bsf0j6wFYIExh0GaUFPGVqj3/DNVG/IpgOdS2CFhhw8pKGF h2Zf10jJpspK32YPuNAJKgZQWE25q7I= Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-3a8aed87a0dso6517965ab.3 for ; Fri, 13 Dec 2024 07:56:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1734105365; x=1734710165; 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=aJTsU8FOCztsZChrgynI/se4Hg526H6WFOVyatkHjPA=; b=nAxIGxvLjxdiCQw4yemK3+BNf6RzIeeoWizFR0Gwk5YP+t373+2puaGKpsupQUtT/9 kFbXjSGOsiu9SGMFQVVTtIW8RieJezVckNjm3KxTy9hqqqH3CC6fx9Hu4rg/aHF5mBGk D7/wtusbEgvvyZejN3Ngs5TJsnOv5D1UH5RQCGGWxvXigzC2EiW5S++15O644u8rP2Ph oW8GtygWRwbWwy9pKP1x/WLZWyhXjiocVogvAvR+dUZP11TGIphwmqJpZCt4GguO8rYJ AqsIM2hHNcUPTkB4R7OAmlfWnopuijjhLoupx6IubsxUtyt9nl1ESL8NYuL0rY7FmIb9 2s5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734105365; x=1734710165; 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=aJTsU8FOCztsZChrgynI/se4Hg526H6WFOVyatkHjPA=; b=gBE9qo1NhQ0TTs4A1yjH4PXN4vzVXk9egin3BYCMtdtmACe22oro9LFk7YJZ/mD3cU sVp64cb6cRU7WDOT8l8uWy6aMtuaOZmWQ8mWPkBW2M2YZuNCdMwrtjKHhRK0ElPU2Bb3 cNsARbQbFWaGf1QLwOb5G53gwPj83DqnOqa3nX/RegkRLLpCUMB0viLz+G6K/psgEsL/ +Ee5z00oulx67pqtUrxJ881irHsqztaBjmDlnz8z7sCB/DY3iyU0iTiFfyUWdf+ONKLx CR2O688xBnVLMXwdnVxK79luCE7UwCNj0ZmdaSczK/SrNWni3MeqKqfKdkqDRQiHNoSc mwjA== X-Gm-Message-State: AOJu0YzR6dwaaK898j4R0n0X0GOFZ22f99N42JRhWIcQugO+moZi/bpC Kgkc4KSEJq2p55Y4ZT348Vt+QTjjQz9YidACmTbWaAuM+mZCXJgRO0YOAotNOpm7uV7Lt5HqUH7 I X-Gm-Gg: ASbGncvoiblV7OHLoFS1ibwexHhIbb4aDns0dtf8iQtFLp9qUFF5U3PJkNFbfJcGUfe //h5KTz9EvugMKipP5XEacTIJmvd49h/zAifwXCxhNxC5iD4UUEq4U46Y1HliRbeWS6C4qGqmrU OefAaxi4jWz7eb46T4Onid8L2C8YQeKL6X+HppmU6JOyEYdLBRhcM2FO32f9yx0yqejamsLdmGP oTl4vPMf4NVPVGLQyopyOI7Lw1ZmCWyc4VcfQ3LSJUHkifiOEUaLefm1UrV X-Google-Smtp-Source: AGHT+IHzvgK4Rw98UmNxw7TWkyvAABSCjKuo4ks1FFrTwghvSS0Ll84bbCaOcol8J/RzXzpmHkduIA== X-Received: by 2002:a05:6e02:1a8b:b0:3a7:7124:bd2c with SMTP id e9e14a558f8ab-3affab62206mr35203095ab.19.1734105365052; Fri, 13 Dec 2024 07:56:05 -0800 (PST) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a9ca03ae11sm35258405ab.41.2024.12.13.07.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 07:56:03 -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/11] mm/filemap: change filemap_create_folio() to take a struct kiocb Date: Fri, 13 Dec 2024 08:55:15 -0700 Message-ID: <20241213155557.105419-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241213155557.105419-1-axboe@kernel.dk> References: <20241213155557.105419-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: 7e87zn3zbe9mmwb7dwtsqhbay7rmga8n X-Rspamd-Queue-Id: 6C8A2C000B X-Rspam-User: X-HE-Tag: 1734105337-928784 X-HE-Meta: U2FsdGVkX1/msCR+xDeE5zF9VVLbOhUI/uEs3OudI9MKPxjyoRCoTPD9At/4W/XtVucPcXy4epv2k3BsuDmUOba3kTKKfq3Y645URxbtQ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oQaG1FtJ8Fx9URONlvb7C1K+9mvCY4Kb+en4pEWZtRIFQPz6HFVjb0hBOU4uRSLkKA5uz9Ngx+m1XYvRBgegEpFlQKuEclHO9yE/DqTK4Y7Vy/7aHn8l7Uw3yaK2R5Fd5V8HA+7oLgDQshgpOrJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000120, 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. Signed-off-by: Jens Axboe Reviewed-by: Kirill A. Shutemov --- 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;