diff options
author | 2023-03-24 18:01:11 +0000 | |
---|---|---|
committer | 2023-04-06 13:39:51 -0400 | |
commit | f8f8c89f59f7ab037bfca8797e2cc613a5684f21 (patch) | |
tree | 2d75b08b0dec785bb8826c1e7960758828580b5b /fs/ext4/inline.c | |
parent | ext4: Convert ext4_convert_inline_data_to_extent() to use a folio (diff) | |
download | linux-f8f8c89f59f7ab037bfca8797e2cc613a5684f21.tar.gz linux-f8f8c89f59f7ab037bfca8797e2cc613a5684f21.tar.bz2 linux-f8f8c89f59f7ab037bfca8797e2cc613a5684f21.zip |
ext4: Convert ext4_try_to_write_inline_data() to use a folio
Saves a number of calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20230324180129.1220691-12-willy@infradead.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inline.c')
-rw-r--r-- | fs/ext4/inline.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index f339340ba66c..881d559c503f 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -653,8 +653,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, { int ret; handle_t *handle; - unsigned int flags; - struct page *page; + struct folio *folio; struct ext4_iloc iloc; if (pos + len > ext4_get_max_inline_size(inode)) @@ -691,28 +690,27 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, if (ret) goto out; - flags = memalloc_nofs_save(); - page = grab_cache_page_write_begin(mapping, 0); - memalloc_nofs_restore(flags); - if (!page) { + folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS, + mapping_gfp_mask(mapping)); + if (!folio) { ret = -ENOMEM; goto out; } - *pagep = page; + *pagep = &folio->page; down_read(&EXT4_I(inode)->xattr_sem); if (!ext4_has_inline_data(inode)) { ret = 0; - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); goto out_up_read; } - if (!PageUptodate(page)) { - ret = ext4_read_inline_page(inode, page); + if (!folio_test_uptodate(folio)) { + ret = ext4_read_inline_page(inode, &folio->page); if (ret < 0) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); goto out_up_read; } } |