Skip to contentSkip to conversation

ufs: add readahead

PATCH New Showta Ishizaki 1 participant 1 message Nov 25 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ufs: add readahead

ufs has no ->readahead(), so readahead reads one folio at a time through ->read_folio(). Use mpage_readahead(), as ext2 does.

Reading 128 MiB with dd from virtio-blk after dropping the caches, five times, in MB/s: 635-667 before and 1063-1193 after with 1K fragments, 1135-1216 before and 1457-1506 after with 4K fragments.

---

fs/ufs/inode.c +6 -0
index c9ff8673f..fc3d2ec77 100644
@@ -457,6 +457,11 @@ static int ufs_read_folio(struct file *file, struct folio *folio)
 	return block_read_full_folio(folio, ufs_getfrag_block);
 }
 
+static void ufs_readahead(struct readahead_control *rac)
+{
+	mpage_readahead(rac, ufs_getfrag_block);
+}
+
 int ufs_prepare_chunk(struct folio *folio, loff_t pos, unsigned len)
 {
 	return __block_write_begin(folio, pos, len, ufs_getfrag_block);
@@ -510,6 +515,7 @@ const struct address_space_operations ufs_aops = {
 	.dirty_folio = block_dirty_folio,
 	.invalidate_folio = block_invalidate_folio,
 	.read_folio = ufs_read_folio,
+	.readahead = ufs_readahead,
 	.writepages = ufs_writepages,
 	.write_begin = ufs_write_begin,
 	.write_end = ufs_write_end,

base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5