From: Hannes Reinecke <hare@suse.de>
To: Pankaj Raghav <p.raghav@samsung.com>
Cc: Matthew Wilcox <willy@infradead.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
mcgrof@kernel.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH] mm/filemap: allocate folios according to the blocksize
Date: Fri, 14 Apr 2023 15:49:08 +0200 [thread overview]
Message-ID: <20230414134908.103932-1-hare@suse.de> (raw)
If the blocksize is larger than the pagesize allocate folios
with the correct order.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
mm/filemap.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index 05fd86752489..468f25714ced 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1927,7 +1927,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
folio_wait_stable(folio);
no_page:
if (!folio && (fgp_flags & FGP_CREAT)) {
- int err;
+ int err, order = 0;
if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping))
gfp |= __GFP_WRITE;
if (fgp_flags & FGP_NOFS)
@@ -1937,7 +1937,9 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
gfp |= GFP_NOWAIT | __GFP_NOWARN;
}
- folio = filemap_alloc_folio(gfp, 0);
+ if (mapping->host->i_blkbits > PAGE_SHIFT)
+ order = mapping->host->i_blkbits - PAGE_SHIFT;
+ folio = filemap_alloc_folio(gfp, order);
if (!folio)
return NULL;
@@ -2492,9 +2494,11 @@ static int filemap_create_folio(struct file *file,
struct folio_batch *fbatch)
{
struct folio *folio;
- int error;
+ int error, order = 0;
- folio = filemap_alloc_folio(mapping_gfp_mask(mapping), 0);
+ if (mapping->host->i_blkbits > PAGE_SHIFT)
+ order = mapping->host->i_blkbits - PAGE_SHIFT;
+ folio = filemap_alloc_folio(mapping_gfp_mask(mapping), order);
if (!folio)
return -ENOMEM;
@@ -3607,14 +3611,16 @@ static struct folio *do_read_cache_folio(struct address_space *mapping,
pgoff_t index, filler_t filler, struct file *file, gfp_t gfp)
{
struct folio *folio;
- int err;
+ int err, order = 0;
+ if (mapping->host->i_blkbits > PAGE_SHIFT)
+ order = mapping->host->i_blkbits - PAGE_SHIFT;
if (!filler)
filler = mapping->a_ops->read_folio;
repeat:
folio = filemap_get_folio(mapping, index);
if (!folio) {
- folio = filemap_alloc_folio(gfp, 0);
+ folio = filemap_alloc_folio(gfp, order);
if (!folio)
return ERR_PTR(-ENOMEM);
err = filemap_add_folio(mapping, folio, index, gfp);
--
2.35.3
next reply other threads:[~2023-04-14 13:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230414134914eucas1p1f0b08409dce8bc946057d0a4fa7f1601@eucas1p1.samsung.com>
2023-04-14 13:49 ` Hannes Reinecke [this message]
2023-04-14 13:56 ` [PATCH] mm/filemap: allocate folios according to the blocksize Matthew Wilcox
2023-04-16 4:00 ` Matthew Wilcox
2023-04-17 2:18 ` kernel test robot
2023-04-17 4:10 ` Matthew Wilcox
2023-04-17 4:36 ` Christoph Hellwig
2023-04-17 6:08 ` Hannes Reinecke
2023-04-17 6:27 ` Christoph Hellwig
2023-04-17 6:30 ` Hannes Reinecke
2023-04-20 12:05 ` Pankaj Raghav
2023-04-20 12:19 ` Hannes Reinecke
2023-04-20 12:28 ` Pankaj Raghav
2023-04-20 15:03 ` Darrick J. Wong
2023-04-22 0:14 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230414134908.103932-1-hare@suse.de \
--to=hare@suse.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).