Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ext4: add large folios support for moving extents

Pass the moving extent length into mext_folio_double_lock() so that it
can acquire a higher-order folio if the length exceeds PAGE_SIZE. This
can speed up extent moving when the extent is larger than one page.
Additionally, remove the unnecessary comments from
mext_folio_double_lock().

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Message-ID: <20251013015128.499308-12-yi.zhang@huaweicloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Zhang Yi and committed by
Theodore Ts'o
65097262 4589c451

+10 -17
+10 -17
fs/ext4/move_extent.c
··· 54 54 up_write(&EXT4_I(donor_inode)->i_data_sem); 55 55 } 56 56 57 - /** 58 - * mext_folio_double_lock - Grab and lock folio on both @inode1 and @inode2 59 - * 60 - * @inode1: the inode structure 61 - * @inode2: the inode structure 62 - * @index1: folio index 63 - * @index2: folio index 64 - * @folio: result folio vector 65 - * 66 - * Grab two locked folio for inode's by inode order 67 - */ 68 - static int 69 - mext_folio_double_lock(struct inode *inode1, struct inode *inode2, 70 - pgoff_t index1, pgoff_t index2, struct folio *folio[2]) 57 + /* Grab and lock folio on both @inode1 and @inode2 by inode order. */ 58 + static int mext_folio_double_lock(struct inode *inode1, struct inode *inode2, 59 + pgoff_t index1, pgoff_t index2, size_t len, 60 + struct folio *folio[2]) 71 61 { 72 62 struct address_space *mapping[2]; 73 63 unsigned int flags; 64 + fgf_t fgp_flags = FGP_WRITEBEGIN; 74 65 75 66 BUG_ON(!inode1 || !inode2); 76 67 if (inode1 < inode2) { ··· 74 83 } 75 84 76 85 flags = memalloc_nofs_save(); 77 - folio[0] = __filemap_get_folio(mapping[0], index1, FGP_WRITEBEGIN, 86 + fgp_flags |= fgf_set_order(len); 87 + folio[0] = __filemap_get_folio(mapping[0], index1, fgp_flags, 78 88 mapping_gfp_mask(mapping[0])); 79 89 if (IS_ERR(folio[0])) { 80 90 memalloc_nofs_restore(flags); 81 91 return PTR_ERR(folio[0]); 82 92 } 83 93 84 - folio[1] = __filemap_get_folio(mapping[1], index2, FGP_WRITEBEGIN, 94 + folio[1] = __filemap_get_folio(mapping[1], index2, fgp_flags, 85 95 mapping_gfp_mask(mapping[1])); 86 96 memalloc_nofs_restore(flags); 87 97 if (IS_ERR(folio[1])) { ··· 206 214 orig_pos = ((loff_t)mext->orig_map.m_lblk) << blkbits; 207 215 donor_pos = ((loff_t)mext->donor_lblk) << blkbits; 208 216 ret = mext_folio_double_lock(orig_inode, donor_inode, 209 - orig_pos >> PAGE_SHIFT, donor_pos >> PAGE_SHIFT, folio); 217 + orig_pos >> PAGE_SHIFT, donor_pos >> PAGE_SHIFT, 218 + ((size_t)mext->orig_map.m_len) << blkbits, folio); 210 219 if (ret) 211 220 return ret; 212 221