From nobody Sun Feb 8 14:10:37 2026 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDF851E1C26 for ; Fri, 13 Dec 2024 15:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734105368; cv=none; b=fNTGDRRU9ecKJFNOR6NewCt7N5yk0B4Bfne32PPCHwzszaU9XYdjclLrblYoiZ4hAsXOTPST0ahbCfnitbYnifX6RJkZRubW/JMgvrwK821nAfAYjn3j3vlbTfQKM3Wdt/EDmLmJNV/RrE6eSMQxvKeJHMLaQNMDwXK3QacCOwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734105368; c=relaxed/simple; bh=CQHljKL0HvF5DjNsL/7Q8SjdRe1DhHG7gJBg0F4F8y0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rfe9OrZdU6j68OImPwA0V5jCw9TNhoJz9zZED2rZE4hkjyoQnsC3+v67m8zY90IvFB/BA9xRNXQGl/I6HLrOZE9lnLsE0rd1nAU+Bfc41Ys5gMioyktnkZHCAD7MD3MqqQQ5hX0mM2kZdOiI6TXNAUeQkomxZEihaWfYybU7VSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=rA2TyAiT; arc=none smtp.client-ip=209.85.166.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="rA2TyAiT" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-3a817ee9936so6488485ab.2 for ; Fri, 13 Dec 2024 07:56:05 -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=vger.kernel.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=rA2TyAiTEnZDuJUEzMLUg7pzz4q8wsMtXMQ2nso5c9/p5yCYWDwsrcSh98ibhdDugo QYV5xGrQopJndH/3afNqdFjHohTuwzsGMkT761zJSNSavteA9lV4LtZy3bVeWeEALQC7 y2U5OgpUZOM/ilJDz/2vlhIHaKxNy7YNbaHa0Y6V1CvSFxFSqL0Zed5VpY7KA2Mbm13b RIPhV06nHYQpDmJvWZLtjsFn9pkXVnRcIJ/wY0tu4icjeX7eaBnpKohIA8TsfsH9ZdF4 g8AAiof2EMeyErrAX30lLtyacgcuzUBw4bCRybt59rq1NmeuU/eLUcwz7Tcm0Zh4oVim BvWg== 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=S8jtvIyRW2vSC4oZWi5l+FmosTt4ef0CA0wRXq3H9VnJOF5lzWl2v1dCrxLe2wuO6p Cq+aKfaSG5Nm+bEytR7sqrWK8Ewaz1OpuJbQnuArGIuNuBt/wbA/RZQKFkV3CChaxCl7 hqYrKqAZCoQZ2bEXf3WfxzM00Tc2y4tGwKHQH5xy8+f7w+uR4JXecKHZsn/F/oNrn1zj FhAiOREP/tZwkAlWCdRDmSKgIiRy4+yiuBPB8v+4CsoYpMrUEtxveQU+JRyZ79SjkIjM Esn0snv+sMSKRTNlJkw2tEbso3p++GwrBEWnfoKU8fW6Y7tkZoMsQMQXfuYw2E+FDc2d 6Ckw== X-Forwarded-Encrypted: i=1; AJvYcCUZjR/KLEzsRm3mSOKwBFzmLSkuTfd4ZVNZ+6B/IenQwb7QQlnHDZOyei7+ly4cmCeeLgg20rwHnBB5UBQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+RJ8JuGbd4/pwx3sKRDcE0DQvJ353cv6HDnRrwXDzvDqnFkme sPWh8BEgo5t40hrCvXu4DYpNbDkOij2785JqUk8EFH9Rpq8GfnUQaUInUs9VNLs= X-Gm-Gg: ASbGnctXHGt5u4z+DcCZItzBW141Dl+tQ+tZAkMqcWxnVzQy9r2t9vpwGs7vCypw4A2 qQQBcX3pYV5wOTBg9Oj18VlChV9/Q5FklATidmK97agm+TaYxiu1Mhz1rWazxZTm+ZMUBhbZ5DN VfseSnTbO8OOf1fUU3g5gDDhGnBu3S78SnFbdnqhdAiYp2+4Zuyz46W4GWJFfhjidIbYQE5YrNT FTYEN0tiBO1k56aNuSYzSIUInC8Q9mEy9paHq2Wb0Gr9UjHbXc/TsfWBXmd 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; } =20 -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 *fb= atch) { + struct address_space *mapping =3D iocb->ki_filp->f_mapping; struct folio *folio; int error; unsigned int min_order =3D mapping_min_folio_order(mapping); pgoff_t index; =20 + if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) + return -EAGAIN; + folio =3D 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 =3D (pos >> (PAGE_SHIFT + min_order)) << min_order; + index =3D (iocb->ki_pos >> (PAGE_SHIFT + min_order)) << min_order; error =3D filemap_add_folio(mapping, folio, index, mapping_gfp_constraint(mapping, GFP_KERNEL)); if (error =3D=3D -EEXIST) @@ -2494,7 +2496,8 @@ static int filemap_create_folio(struct file *file, if (error) goto error; =20 - error =3D filemap_read_folio(file, mapping->a_ops->read_folio, folio); + error =3D filemap_read_folio(iocb->ki_filp, mapping->a_ops->read_folio, + folio); if (error) goto error; =20 @@ -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 =3D filemap_create_folio(filp, mapping, iocb->ki_pos, fbatch); + err =3D filemap_create_folio(iocb, fbatch); if (err =3D=3D AOP_TRUNCATED_PAGE) goto retry; return err; --=20 2.45.2