Skip to contentSkip to conversation

f2fs: read node blocks ahead when truncating blocks

PATCH New Jaegeuk Kim 1 participant 2 messages May 7, 2016

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/2 f2fs: read node blocks ahead when truncating blocks

This patch enables reading node blocks in advance when truncating large data blocks.

Quoted 1 line

time rm $MNT/testfile (500GB) after drop_cachees

Before : 9.422 s
After : 4.821 s

---
 fs/f2fs/file.c |  2 +-
 fs/f2fs/node.c | 52 ++++++++++++++++++++++++++++------------------------
 2 files changed, 29 insertions(+), 25 deletions(-)
fs/f2fs/file.c +1 -1
index fb8cc27..3146129 100644
@@ -584,7 +584,7 @@ int truncate_blocks(struct inode *inode, u64 from, bool lock)
 	}
 
 	set_new_dnode(&dn, inode, ipage, NULL, 0);
-	err = get_dnode_of_data(&dn, free_from, LOOKUP_NODE);
+	err = get_dnode_of_data(&dn, free_from, LOOKUP_NODE_RA);
 	if (err) {
 		if (err == -ENOENT)
 			goto free_next;
fs/f2fs/node.c +28 -24

82 lines not on this page · raw message

Signature · 1 line
2.6.3
author maintainer
#1 lore raw

PATCH 2/2 f2fs: do not preallocate block unaligned to 4KB

Previously f2fs_preallocate_blocks() tries to allocate unaligned blocks. In f2fs_write_begin(), however, prepare_write_begin() does not skip its allocation due to (len != 4KB).
So, it needs locking node page twice unexpectedly.

---
 fs/f2fs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -2
index 96b0353..369d953 100644
@@ -582,8 +582,8 @@ ssize_t f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
 	struct f2fs_map_blocks map;
 	ssize_t ret = 0;
 
-	map.m_lblk = F2FS_BYTES_TO_BLK(iocb->ki_pos);
-	map.m_len = F2FS_BLK_ALIGN(iov_iter_count(from));
+	map.m_lblk = F2FS_BLK_ALIGN(iocb->ki_pos);
+	map.m_len = F2FS_BYTES_TO_BLK(iov_iter_count(from));
 	map.m_next_pgofs = NULL;
 
 	if (f2fs_encrypted_inode(inode))
Signature · 1 line
2.6.3