Skip to contentSkip to conversation

f2fs-tools: introduce f2fs_update_sparse_file()

PATCH Superseded Chao Yu 1 participant 1 message May 5, 2019 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH v2 2/2 f2fs-tools: introduce f2fs_update_sparse_file()

This patch fixes to initialize NAT/SIT/CP.payload region in sparse file mode for fsck/sload/resize/defrag/dump tools.

---
v2:
- add missing log in f2fs_update_sparse_file().

 fsck/fsck.h      |  1 +
 fsck/main.c      |  5 +++
 fsck/mount.c     | 84 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/libf2fs_io.c |  9 ------
 4 files changed, 90 insertions(+), 9 deletions(-)
fsck/fsck.h +1 -0
index 60e052a..c21731e 100644
@@ -181,6 +181,7 @@ extern int fsck_verify(struct f2fs_sb_info *);
 extern void fsck_free(struct f2fs_sb_info *);
 extern int f2fs_do_mount(struct f2fs_sb_info *);
 extern void f2fs_do_umount(struct f2fs_sb_info *);
+extern int f2fs_update_sparse_file(struct f2fs_sb_info *);
 
 extern void flush_journal_entries(struct f2fs_sb_info *);
 extern void zero_journal_entries(struct f2fs_sb_info *);
fsck/main.c +5 -0
index afdfec9..0670696 100644
@@ -845,6 +845,11 @@ retry:
 				goto fsck_again;
 		}
 	}
+
+	ret = f2fs_update_sparse_file(sbi);
+	if (ret < 0)
+		return ret;
+
 	ret = f2fs_finalize_device();
 	if (ret < 0)
 		return ret;
fsck/mount.c +84 -0

87 lines not on this page · raw message

lib/libf2fs_io.c +0 -9
index 4d0ea0d..2f2b6bd 100644
@@ -358,15 +358,6 @@ int f2fs_finalize_device(void)
 		int64_t chunk_start = (blocks[0] == NULL) ? -1 : 0;
 		uint64_t j;
 
-		if (c.func != MKFS) {
-			sparse_file_destroy(f2fs_sparse_file);
-			ret = ftruncate(c.devices[0].fd, 0);
-			ASSERT(!ret);
-			lseek(c.devices[0].fd, 0, SEEK_SET);
-			f2fs_sparse_file = sparse_file_new(F2FS_BLKSIZE,
-							c.device_size);
-		}
-
 		for (j = 0; j < blocks_count; ++j) {
 			if (chunk_start != -1) {
 				if (j - chunk_start >= MAX_CHUNK_COUNT) {
Signature · 1 line
2.18.0.rc1