Skip to contentSkip to conversation

f2fs: skip searching non-exist range in truncate_hole

PATCH In review Weichao Guo 2 participants 2 messages Oct 13, 2017 – Oct 16, 2017 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: skip searching non-exist range in truncate_hole

Let's skip entire non-exist area to speed up truncate_hole by using get_next_page_offset.

---
 fs/f2fs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
index 517e112..819c29a 100644
@@ -844,7 +844,7 @@ int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end)
 		err = get_dnode_of_data(&dn, pg_start, LOOKUP_NODE);
 		if (err) {
 			if (err == -ENOENT) {
-				pg_start++;
+				pg_start = get_next_page_offset(&dn, pg_start);
 				continue;
 			}
 			return err;
Signature · 6 lines
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Weichao Guo

Let's skip entire non-exist area to speed up truncate_hole by using get_next_page_offset.

Thanks,

Quoted 10 lines
---
 fs/f2fs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +0 -0
index 517e112..819c29a 100644

fs/f2fs/file.c int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end) · line 850

Quoted 8 lines
fs/f2fs/file.c +1 -1
@@ -844,7 +844,7 @@ int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end)
 		err = get_dnode_of_data(&dn, pg_start, LOOKUP_NODE);
 		if (err) {
 			if (err == -ENOENT) {
-				pg_start++;
+				pg_start = get_next_page_offset(&dn, pg_start);
 				continue;
 			}
 			return err;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot