f2fs-tools: add testcases
cover f2fs-tools: add testcases
Hi, all
This patchset tries to add an auto testsuit for f2fs-tools (fsck only for now).
The basic idea of these testcases are:
1. create f2fs image
2. corrupt the image by inject specific fields
3. fsck fixes the image
4. verify fsck output with expected message
Some helper scripts are provided:
* test_config.in: is used to derive basic configurations of all testcases.
* runtests.in: is used to derive `runtests' which is used to run testcases.
* filter.sed: removes unnecessary messages and cleanup arbitrary values.
* helpers: provides helper functions
The usage of `runtests':
* run all testcases:
runtests
* run one testcase:
runtests <testcase directory path>
* cleanup previous results:
runtests clean
Some testcase requires root permission to mount the image and create files.
Each testcase should have a sub-directory, where three files are needed:
* README: describe information of the testcase
* script: testcase itself
* expect.in: is used to derive expected output message
an optional file is:
* img.tar.gz: if some scenario is too complex to create by script, the gz file could be prepared in advance, and the operations of how to create the image should be described in README
New files are generated in the testcase directory after test:
* log: output in detail
* expect: derived from expect.in
* out: output that will be compared with expect
* PASS: testcase is passed
* FAIL: testcase is failed, in which differ of out and expect is saved
The name of testcase directory has some optional prefix:
* f_: fsck testcase
* m_: mkfs testcase
But there are only fsck testcases for now.
To run testcases, it's better to compile fsck.f2fs as statically linked executable, or `make install' installs tools and libraries. Otherwise, libtool compiles f2fs-tools in debug mode and create a wrapper script to locate elf executable and libraries. However, dump.f2fs and inject.f2fs cannot be used in the wrapper way.
PATCH 1,2: change dump.f2fs
PATCH 3: overwrite invalid cp with backup cp PATCH 4~7: allow inject.f2fs to corrupt more fields PATCH 8: add helper scripts for test
PATCH 9~end: add testcases
Sheng Yong (24):
f2fs-tools: add option N to answer no for all questions dump.f2fs: print checkpoint crc
fsck.f2fs: fix invalidate checkpoint
inject.f2fs: add members in inject_cp
inject.f2fs: add member `feature' in inject_sb inject.f2fs: add members in inject_node
inject.f2fs: add member `filename' in inject_dentry
tests: prepare helper scripts for testcases
tests: add fsck testcase of fixing bad super magic
tests: add fsck testcase of fixing errors recorded in sb
tests: add fsck testcase of fixing cp crc
tests: add fsck testcase of fixing nat entry with invalid ino
tests: add fsck testcase of fixing nat entry with invalid blkaddr
tests: add fsck testcase of fixing sit entry type
tests: add fsck testcase of fixing sit entry vblocks
tests: add fsck testcase of fixing sit entry valid_map
tests: add fsck testcase of fixing sum entry nid
tests: add fsck testcase of fixing sum footer type
tests: add fsck testcase of fixing sum entry ofs_in_node
tests: add fsck testcase of fixing invalid i_addr
tests: add fsck testcase of fixing dentry hash code
tests: add fsck testcase of fixing lost dots
tests: add fsck testcase of fixing duplicated dots
tests: add fsck testcase of fixing loop fsync dnodes
.gitignore | 13 ++ Makefile.am | 2 +- configure.ac | 1 + fsck/dump.c | 3 + fsck/f2fs.h | 6 + fsck/fsck.c | 2 +- fsck/fsck.h | 3 +- fsck/inject.c | 207 ++++++++++++++++++++++++-- fsck/inject.h | 1 + fsck/main.c | 14 +- fsck/mount.c | 32 +++- include/f2fs_fs.h | 1 + man/inject.f2fs.8 | 37 ++++- tests/Makefile.am | 28 ++++ tests/f_cp_bad_crc/README | 5 + tests/f_cp_bad_crc/expect.in | 22 +++ tests/f_cp_bad_crc/script | 46 ++++++ tests/f_dentry_bad_hash/README | 8 + tests/f_dentry_bad_hash/expect.in | 62 ++++++++ tests/f_dentry_bad_hash/script | 71 +++++++++ tests/f_dentry_dup_dots/README | 11 ++ tests/f_dentry_dup_dots/expect.in | 150 +++++++++++++++++++ tests/f_dentry_dup_dots/script | 58 ++++++++ tests/f_dentry_lost_dots/README | 7 + tests/f_dentry_lost_dots/expect.in | 74 +++++++++ tests/f_dentry_lost_dots/script | 46 ++++++ tests/f_inode_bad_iaddr/README | 6 + tests/f_inode_bad_iaddr/expect.in | 38 +++++ tests/f_inode_bad_iaddr/script | 58 ++++++++ tests/f_loop_fsync_dnodes/README | 39 +++++ tests/f_loop_fsync_dnodes/expect.in | 40 +++++ tests/f_loop_fsync_dnodes/imgs.tar.gz | Bin 0 -> 173228 bytes tests/f_loop_fsync_dnodes/script | 16 ++ tests/f_nat_bad_blkaddr/README | 4 + tests/f_nat_bad_blkaddr/expect.in | 39 +++++ tests/f_nat_bad_blkaddr/script | 35 +++++ tests/f_nat_bad_ino/README | 4 + tests/f_nat_bad_ino/expect.in | 39 +++++ tests/f_nat_bad_ino/script | 39 +++++ tests/f_sb_bad_magic/README | 3 + tests/f_sb_bad_magic/expect.in | 40 +++++ tests/f_sb_bad_magic/script | 16 ++ tests/f_sb_errors/README | 5 + tests/f_sb_errors/expect.in | 59 ++++++++ tests/f_sb_errors/script | 23 +++ tests/f_sit_bad_type/README | 5 + tests/f_sit_bad_type/expect.in | 34 +++++ tests/f_sit_bad_type/script | 45 ++++++ tests/f_sit_bad_valid_map/README | 5 + tests/f_sit_bad_valid_map/expect.in | 35 +++++ tests/f_sit_bad_valid_map/script | 50 +++++++ tests/f_sit_bad_vblocks/README | 5 + tests/f_sit_bad_vblocks/expect.in | 34 +++++ tests/f_sit_bad_vblocks/script | 45 ++++++ tests/f_ssa_bad_nid/README | 5 + tests/f_ssa_bad_nid/expect.in | 34 +++++ tests/f_ssa_bad_nid/script | 44 ++++++ tests/f_ssa_bad_ofs_in_node/README | 5 + tests/f_ssa_bad_ofs_in_node/expect.in | 34 +++++ tests/f_ssa_bad_ofs_in_node/script | 44 ++++++ tests/f_ssa_bad_type/README | 5 + tests/f_ssa_bad_type/expect.in | 34 +++++ tests/f_ssa_bad_type/script | 39 +++++ tests/filter.sed | 60 ++++++++ tests/helpers | 157 +++++++++++++++++++ tests/runtests.in | 46 ++++++ tests/test_config.in | 47 ++++++ 67 files changed, 2196 insertions(+), 29 deletions(-) create mode 100644 tests/Makefile.am create mode 100644 tests/f_cp_bad_crc/README create mode 100644 tests/f_cp_bad_crc/expect.in create mode 100644 tests/f_cp_bad_crc/script create mode 100644 tests/f_dentry_bad_hash/README create mode 100644 tests/f_dentry_bad_hash/expect.in create mode 100644 tests/f_dentry_bad_hash/script create mode 100644 tests/f_dentry_dup_dots/README create mode 100644 tests/f_dentry_dup_dots/expect.in create mode 100644 tests/f_dentry_dup_dots/script create mode 100644 tests/f_dentry_lost_dots/README create mode 100644 tests/f_dentry_lost_dots/expect.in create mode 100644 tests/f_dentry_lost_dots/script create mode 100644 tests/f_inode_bad_iaddr/README create mode 100644 tests/f_inode_bad_iaddr/expect.in create mode 100644 tests/f_inode_bad_iaddr/script create mode 100644 tests/f_loop_fsync_dnodes/README create mode 100644 tests/f_loop_fsync_dnodes/expect.in create mode 100644 tests/f_loop_fsync_dnodes/imgs.tar.gz create mode 100644 tests/f_loop_fsync_dnodes/script create mode 100644 tests/f_nat_bad_blkaddr/README create mode 100644 tests/f_nat_bad_blkaddr/expect.in create mode 100644 tests/f_nat_bad_blkaddr/script create mode 100644 tests/f_nat_bad_ino/README create mode 100644 tests/f_nat_bad_ino/expect.in create mode 100644 tests/f_nat_bad_ino/script create mode 100644 tests/f_sb_bad_magic/README create mode 100644 tests/f_sb_bad_magic/expect.in create mode 100644 tests/f_sb_bad_magic/script create mode 100644 tests/f_sb_errors/README create mode 100644 tests/f_sb_errors/expect.in create mode 100644 tests/f_sb_errors/script create mode 100644 tests/f_sit_bad_type/README create mode 100644 tests/f_sit_bad_type/expect.in create mode 100644 tests/f_sit_bad_type/script create mode 100644 tests/f_sit_bad_valid_map/README create mode 100644 tests/f_sit_bad_valid_map/expect.in create mode 100644 tests/f_sit_bad_valid_map/script create mode 100644 tests/f_sit_bad_vblocks/README create mode 100644 tests/f_sit_bad_vblocks/expect.in create mode 100644 tests/f_sit_bad_vblocks/script create mode 100644 tests/f_ssa_bad_nid/README create mode 100644 tests/f_ssa_bad_nid/expect.in create mode 100644 tests/f_ssa_bad_nid/script create mode 100644 tests/f_ssa_bad_ofs_in_node/README create mode 100644 tests/f_ssa_bad_ofs_in_node/expect.in create mode 100644 tests/f_ssa_bad_ofs_in_node/script create mode 100644 tests/f_ssa_bad_type/README create mode 100644 tests/f_ssa_bad_type/expect.in create mode 100644 tests/f_ssa_bad_type/script create mode 100644 tests/filter.sed create mode 100644 tests/helpers create mode 100644 tests/runtests.in create mode 100644 tests/test_config.in
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 1/24 f2fs-tools: add option N to answer no for all questions
In some scenarino, such as autotest, it is not expected to answer question from fsck or dump. To simply answer no to all these questions, this patch adds an option `N' to do that.
--- fsck/dump.c | 3 +++ fsck/fsck.c | 2 +- fsck/main.c | 14 +++++++++++--- include/f2fs_fs.h | 1 + 4 files changed, 16 insertions(+), 4 deletions(-)
fsck/dump.c +3 -0
@@ -681,6 +681,9 @@ static int dump_filesystem(struct f2fs_sb_info *sbi, struct node_info *ni,if (c.show_file_map)return dump_inode_blk (sbi, ni->ino, node_blk); +if (c.answer_no) +return 0 ; +printf ("Do you want to dump this %s into %s/? [Y/N] " ,S_ISDIR (imode) ?"folder" :"file" , base_path);
fsck/fsck.c +1 -1
@@ -3693,7 +3693,7 @@ int fsck_verify(struct f2fs_sb_info *sbi) }#ifndef WITH_ANDROID -if (nr_unref_nid && !c.ro) { +if (nr_unref_nid && !c.ro && !c.answer_no) {char ans[255 ] = {0 };int res;
fsck/main.c +11 -3
@@ -86,6 +86,7 @@ void fsck_usage()MSG (0 ," -t show directory tree\n" );MSG (0 ," -q preserve quota limits\n" );MSG (0 ," -y fix all the time\n" ); +MSG (0 ," -N Answer \"No\" for all questions\n" );MSG (0 ," -V print the version number and exit\n" );MSG (0 ," --dry-run do not really fix corruptions\n" );MSG (0 ," --no-kernel-check skips detecting kernel change\n" );
@@ -111,6 +112,7 @@ void dump_usage()MSG (0 ," -f do not prompt before dumping\n" );MSG (0 ," -H support write hint\n" );MSG (0 ," -y alias for -f\n" ); +MSG (0 ," -N Answer \"No\" for all questions\n" );MSG (0 ," -o dump inodes to the given path\n" );MSG (0 ," -P preserve mode/owner/group for dumped inode\n" );MSG (0 ," -L Preserves symlinks. Otherwise symlinks are dumped as regular files.\n" );
@@ -250,7 +252,7 @@ void f2fs_parse_options(int argc, char *argv[]) }if (!strcmp ("fsck.f2fs" , prog)) { -const char *option_string =":aC:c:m:Md:fg:HlO:p:q:StyV" ; +const char *option_string =":aC:c:m:Md:fg:HlO:p:q:StyNV" ;int opt =0 , val;char *token;struct option long_opt[] = {
@@ -356,6 +358,9 @@ void f2fs_parse_options(int argc, char *argv[]) c.force =1 ;MSG (0 ,"Info: Force to fix corruption\n" );break ; +case 'N' : + c.answer_no = true; +break ;case 'q' : c.preserve_limits =atoi (optarg); MSG(0, "Info: Preserve quota limits = %d\n",
@@ -409,7 +414,7 @@ void f2fs_parse_options(int argc, char *argv[]) } }else if (!strcmp ("dump.f2fs" , prog)) {#ifdef WITH_DUMP -const char *option_string ="d:fi:I:n:LMo:Prs:Sa:b:Vy" ; +const char *option_string ="d:fi:I:n:LMo:Prs:Sa:b:VyN" ;static struct dump_option dump_opt = { .nid =0 ,/* default root ino */ .start_nat = -1,
@@ -487,6 +492,9 @@ void f2fs_parse_options(int argc, char *argv[])case 'f' : c.force =1 ;break ; +case 'N' : + c.answer_no = true; +break ;case 'r' : dump_opt.use_root_nid =1 ;break ;
@@ -1311,7 +1319,7 @@ fsck_again:f2fs_do_umount (sbi); -if (c.func ==FSCK && c.bug_on) { +if (c.func ==FSCK && c.bug_on && !c.answer_no) {if (!c.ro && c.fix_on ==0 && c.auto_fix ==0 && !c.dry_run) {char ans[255 ] = {0 }; retry:
include/f2fs_fs.h +1 -0
@@ -1545,6 +1545,7 @@ struct f2fs_configuration {int whint;int aliased_devices;uint32_t aliased_segments; +bool answer_no;/* mkfs parameters */ int fake_seed;
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 2/24 dump.f2fs: print checkpoint crc
In reply to Sheng Yong via Linux-f2fs-devel--- fsck/mount.c | 6 ++++++ 1 file changed, 6 insertions(+)
fsck/mount.c +6 -0
@@ -560,6 +560,7 @@ printout:void print_ckpt_info (struct f2fs_sb_info *sbi) {struct f2fs_checkpoint *cp =F2FS_CKPT (sbi); +uint32_t crc;if (c.layout) goto printout;
@@ -613,6 +614,11 @@ printout:DISP_u64 (cp, elapsed_time);DISP_u32 (cp, sit_nat_version_bitmap[0 ]); + crc =f2fs_checkpoint_chksum (cp); +if (c.layout) +printf ("%-30s %u\n" ,"crc" , crc); +else +printf ("%-30s" "\t\t[0x%8x : %u]\n" ,"crc" , crc, crc);printf ("\n\n" ); }
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 3/24 fsck.f2fs: fix invalidate checkpoint
In reply to Sheng Yong via Linux-f2fs-develIf one cp is invalidate, set CP_FSCK_FLAG to allow fixing cp at the end of check.
--- fsck/f2fs.h | 6 ++++++ fsck/mount.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
fsck/f2fs.h +6 -0
@@ -346,6 +346,12 @@ static inline __u64 cur_cp_crc(struct f2fs_checkpoint *cp)return le32_to_cpu (*((__le32 *)((unsigned char *)cp + crc_offset))); } +static inline void set_ckpt_flags (struct f2fs_checkpoint *cp,unsigned int f) +{ +unsigned int ckpt_flags =le32_to_cpu (cp->ckpt_flags); + cp->ckpt_flags =cpu_to_le32 (ckpt_flags | f); +} +static inline bool is_set_ckpt_flags (struct f2fs_checkpoint *cp,unsigned int f) {unsigned int ckpt_flags =le32_to_cpu (cp->ckpt_flags);
fsck/mount.c +8 -3
@@ -1322,8 +1322,11 @@ void *validate_checkpoint(struct f2fs_sb_info *sbi, block_t cp_addr,return NULL ; cp = (struct f2fs_checkpoint *)cp_page_1; -if (get_cp (cp_pack_total_block_count) > sbi->blocks_per_seg) +if (get_cp (cp_pack_total_block_count) > sbi->blocks_per_seg) { +MSG (0 ,"\tInvalid CP pack block count: %u\n" , +get_cp (cp_pack_total_block_count)); goto invalid_cp1; + } pre_version =get_cp (checkpoint_ver);
@@ -1387,14 +1390,16 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi) sbi->cur_cp =1 ; version = cp1_version; } - }else if (cp1) { + }else if (cp1) {// cp2 is invalidate cur_page = cp1; sbi->cur_cp =1 ; version = cp1_version; - }else if (cp2) { +set_ckpt_flags (cp1,CP_FSCK_FLAG ); + }else if (cp2) {// cp1 is invalidate cur_page = cp2; sbi->cur_cp =2 ; version = cp2_version; +set_ckpt_flags (cp2,CP_FSCK_FLAG ); }else goto fail_no_cp;
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 4/24 inject.f2fs: add members in inject_cp
In reply to Sheng Yong via Linux-f2fs-develThe following members are add to inject more fields in cp:
* next_blkaddr: inject fsync dnodes
An error is returned if no fsync dnode is found.
However, the injection is not supported on zoned device. This is because fsync dnodes must remains at the end of current warm node segnemt, any dnode change causes all previous dnodes in the chain to be updated out-of-place, and there may not have enough space left in the curseg. To simplify the injection, it returns an error on zoned device.
* alloc_type: inject curseg's alloc type
* crc: inject cp's checksum
* elapsed_time: inject cp's mount elapsed time
--- fsck/fsck.h | 3 +- fsck/inject.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++- fsck/mount.c | 15 ++++++--- man/inject.f2fs.8 | 9 ++++++ 4 files changed, 101 insertions(+), 6 deletions(-)
fsck/fsck.h +2 -1
@@ -222,6 +222,7 @@ extern int f2fs_ra_meta_pages(struct f2fs_sb_info *, block_t, int, int);extern int f2fs_do_mount (struct f2fs_sb_info *);extern void f2fs_do_umount (struct f2fs_sb_info *);extern int f2fs_sparse_initialize_meta (struct f2fs_sb_info *); +extern int f2fs_find_fsync_inode (struct f2fs_sb_info *,struct list_head *);extern void flush_journal_entries (struct f2fs_sb_info *);extern void update_curseg_info (struct f2fs_sb_info *,int );
@@ -238,7 +239,7 @@ extern void duplicate_checkpoint(struct f2fs_sb_info *);extern void write_checkpoint (struct f2fs_sb_info *);extern void write_checkpoints (struct f2fs_sb_info *);extern void write_raw_cp_blocks (struct f2fs_sb_info *sbi, -struct f2fs_checkpoint *cp,int which); +struct f2fs_checkpoint *cp,int which,bool update_crc);extern void update_superblock (struct f2fs_super_block *,int );extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t ,struct f2fs_node *);
fsck/inject.c +79 -1
104 lines not on this page · raw message
fsck/mount.c +11 -4
@@ -3454,17 +3454,19 @@ void write_checkpoints(struct f2fs_sb_info *sbi)write_checkpoint (sbi); } -void write_raw_cp_blocks (struct f2fs_sb_info *sbi, -struct f2fs_checkpoint *cp,int which) +void write_raw_cp_blocks (struct f2fs_sb_info *sbi,struct f2fs_checkpoint *cp, +int which,bool update_crc) {struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);uint32_t crc;block_t cp_blkaddr;int ret; - crc =f2fs_checkpoint_chksum (cp); - *((__le32 *)((unsigned char *)cp +get_cp (checksum_offset))) = +if (update_crc) { + crc =f2fs_checkpoint_chksum (cp); + *((__le32 *)((unsigned char *)cp +get_cp (checksum_offset))) =cpu_to_le32 (crc); + } cp_blkaddr =get_sb (cp_blkaddr);if (which ==2 )
@@ -3864,6 +3866,11 @@ next:return err; } +int f2fs_find_fsync_inode (struct f2fs_sb_info *sbi,struct list_head *head) +{ +return find_fsync_inode (sbi, head); +} +static int do_record_fsync_data (struct f2fs_sb_info *sbi,struct f2fs_node *node_blk,block_t blkaddr)
man/inject.f2fs.8 +9 -0
@@ -79,6 +79,15 @@ cur_data_segno array. .TP .BI cur_data_blkoff cur_data_blkoff array. +.TP +.BI next_blkaddr +fsync dnodes. +.TP +.BI crc +crc checksum. +.TP +.BI elapsed_time +elapsed mount time. .RE .TP .BI \-\-nat " 0 or 1 or 2"
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [RFC PATCH 04/24] inject.f2fs: add members in inject_cp
Quoted 121 lines · Sheng Yong
The following members are add to inject more fields in cp:
*
next_blkaddr: inject fsync dnodesAn error is returned if no fsync dnode is found.
However, the injection is not supported on zoned device. This is because fsync dnodes must remains at the end of current warm node segnemt, any dnode change causes all previous dnodes in the chain to be updated out-of-place, and there may not have enough space left in the curseg. To simplify the injection, it returns an error on zoned device.
*
alloc_type: inject curseg's alloc type
* crc: inject cp's checksum
*elapsed_time: inject cp's mount elapsed timeSigned-off-by Sheng Yong <[email protected]>--- fsck/fsck.h | 3 +- fsck/inject.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++- fsck/mount.c | 15 ++++++--- man/inject.f2fs.8 | 9 ++++++ 4 files changed, 101 insertions(+), 6 deletions(-)fsck/fsck.h +2
-1@@ -222,6 +222,7 @@ extern int f2fs_ra_meta_pages(struct f2fs_sb_info *, block_t, int, int);extern int f2fs_do_mount (struct f2fs_sb_info *);extern void f2fs_do_umount (struct f2fs_sb_info *);extern int f2fs_sparse_initialize_meta (struct f2fs_sb_info *); +extern int f2fs_find_fsync_inode (struct f2fs_sb_info *,struct list_head *);extern void flush_journal_entries (struct f2fs_sb_info *);extern void update_curseg_info (struct f2fs_sb_info *,int );@@ -238,7 +239,7 @@ extern void duplicate_checkpoint(struct f2fs_sb_info *);extern void write_checkpoint (struct f2fs_sb_info *);extern void write_checkpoints (struct f2fs_sb_info *);extern void write_raw_cp_blocks (struct f2fs_sb_info *sbi, -struct f2fs_checkpoint *cp,int which); +struct f2fs_checkpoint *cp,int which,bool update_crc);extern void update_superblock (struct f2fs_super_block *,int );extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t ,struct f2fs_node *);fsck/inject.c +54
-0@@ -138,6 +138,10 @@ static void inject_cp_usage(void)MSG (0 ," cur_node_blkoff: inject cur_node_blkoff array selected by --idx <index>\n" );MSG (0 ," cur_data_segno: inject cur_data_segno array selected by --idx <index>\n" );MSG (0 ," cur_data_blkoff: inject cur_data_blkoff array selected by --idx <index>\n" ); +MSG (0 ," alloc_type: inject alloc_type array selected by --idx <index>\n" ); +MSG (0 ," next_blkaddr: inject next_blkaddr of fsync dnodes selected by --idx <index>\n" ); +MSG (0 ," crc: inject crc checksum\n" ); +MSG (0 ," elapsed_time: inject elapsed_time\n" ); }static void inject_nat_usage (void )@@ -440,6 +444,7 @@ out:static int inject_cp (struct f2fs_sb_info *sbi,struct inject_option *opt) {struct f2fs_checkpoint *cp, *cur_cp =F2FS_CKPT (sbi); +bool update_crc = true;char *buf =NULL ;int ret =0 ;@@ -518,6 +523,79 @@ static int inject_cp(struct f2fs_sb_info *sbi, struct inject_option *opt) opt->idx, opt->cp,get_cp (cur_data_blkoff[opt->idx]), (u16)opt->val);set_cp (cur_data_blkoff[opt->idx], (u16 )opt->val); + }else if (!strcmp (opt->mb,"alloc_type" )) { +if (opt->idx >=MAX_ACTIVE_LOGS ) { +ERR_MSG ("invalid index %u of cp->alloc_type[]\n" , + opt->idx); + ret = -EINVAL ; + goto out; + } +MSG (0 ,"Info: inject alloc_type[%d] of cp %d: 0x%x -> 0x%x\n" , + opt->idx, opt->cp, cp->alloc_type[opt->idx], + (unsigned char )opt->val); + cp->alloc_type[opt->idx] = (unsigned char )opt->val; + }else if (!strcmp (opt->mb,"next_blkaddr" )) { +struct fsync_inode_entry *entry; +struct list_head inode_list =LIST_HEAD_INIT (inode_list); +struct f2fs_node *node; +block_t blkaddr; +int i =0 ; + +if (c.zoned_model ==F2FS_ZONED_HM ) { +ERR_MSG ("inject fsync dnodes not supported in " +"zoned device\n" ); + ret = -EOPNOTSUPP ; + goto out; + } + +if (!need_fsync_data_record (sbi)) { +ERR_MSG ("no need to recover fsync dnodes\n" ); + ret = -EINVAL ; + goto out; + } + + ret =f2fs_find_fsync_inode (sbi, &inode_list); +if (ret) { +ERR_MSG ("failed to find fsync inodes: %d\n" , ret); + goto out; + } + +list_for_each_entry (entry, &inode_list, list) { +if (i == opt->idx) + blkaddr = entry->blkaddr; +DBG (0 ,"[%4d] blkaddr:0x%x\n" , i++, entry->blkaddr); + } + +if (opt->idx ==0 || opt->idx >= i) { +ERR_MSG ("invalid index %u of fsync dnodes range [1, %u]\n" , + opt->idx, i); + ret = -EINVAL ; + goto out; + }
fsck/inject.c static int inject_cp(struct f2fs_sb_info *sbi, struct inject_option *opt) · line 584
Quoted 10 lines
fsck/inject.c +10
-0+ +MSG (0 ,"Info: inject next_blkaddr[%d] of cp %d: 0x%x -> 0x%x\n" , + opt->idx, opt->cp, blkaddr, (u32 )opt->val); + + node =malloc (F2FS_BLKSIZE ); +ASSERT (node); + ret =dev_read_block (node, blkaddr); +ASSERT (ret >=0 ); +F2FS_NODE_FOOTER (node)->next_blkaddr =cpu_to_le32 ((u32 )opt->val); + ret =update_block (sbi, node, &blkaddr,NULL );
Needs to call update_inode() to update & persist chksum fields?
Thanks,
Quoted 76 lines
fsck/inject.c +15
-1+ASSERT (ret >=0 ); + goto out; + }else if (!strcmp (opt->mb,"crc" )) { +__le32 *crc = (__le32 *)((unsigned char *)cp + +get_cp (checksum_offset)); + +MSG (0 ,"Info: inject crc of cp %d: 0x%x -> 0x%x\n" , + opt->cp,le32_to_cpu (*crc), (u32 )opt->val); + *crc =cpu_to_le32 ((u32 )opt->val); + update_crc = false; + }else if (!strcmp (opt->mb,"elapsed_time" )) { +MSG (0 ,"Info: inject elapsed_time of cp %d: %llu -> %" PRIu64"\n" , + opt->cp,get_cp (elapsed_time), (u64 )opt->val); +set_cp (elapsed_time, (u64 )opt->val); }else {ERR_MSG ("unknown or unsupported member \"%s\"\n" , opt->mb); ret = -EINVAL ;@@ -525,7 +603,7 @@ static int inject_cp(struct f2fs_sb_info *sbi, struct inject_option *opt) }print_ckpt_info (sbi); -write_raw_cp_blocks (sbi, cp, opt->cp); +write_raw_cp_blocks (sbi, cp, opt->cp, update_crc); out:free (buf);fsck/mount.c +11
-4@@ -3454,17 +3454,19 @@ void write_checkpoints(struct f2fs_sb_info *sbi)write_checkpoint (sbi); } -void write_raw_cp_blocks (struct f2fs_sb_info *sbi, -struct f2fs_checkpoint *cp,int which) +void write_raw_cp_blocks (struct f2fs_sb_info *sbi,struct f2fs_checkpoint *cp, +int which,bool update_crc) {struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);uint32_t crc;block_t cp_blkaddr;int ret; - crc =f2fs_checkpoint_chksum (cp); - *((__le32 *)((unsigned char *)cp +get_cp (checksum_offset))) = +if (update_crc) { + crc =f2fs_checkpoint_chksum (cp); + *((__le32 *)((unsigned char *)cp +get_cp (checksum_offset))) =cpu_to_le32 (crc); + } cp_blkaddr =get_sb (cp_blkaddr);if (which ==2 )@@ -3864,6 +3866,11 @@ next:return err; } +int f2fs_find_fsync_inode (struct f2fs_sb_info *sbi,struct list_head *head) +{ +return find_fsync_inode (sbi, head); +} +static int do_record_fsync_data (struct f2fs_sb_info *sbi,struct f2fs_node *node_blk,block_t blkaddr)man/inject.f2fs.8 +2
-0@@ -79,6 +79,15 @@ cur_data_segno array. .TP .BI cur_data_blkoff cur_data_blkoff array. +.TP +.BI next_blkaddr
man/inject.f2fs.8 cur_data_segno array. · line 93
Quoted 10 lines
man/inject.f2fs.8 +7
-0+fsync dnodes. +.TP +.BI crc +crc checksum. +.TP +.BI elapsed_time +elapsed mount time. .RE .TP .BI \-\-nat " 0 or 1 or 2"
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 5/24 inject.f2fs: add member `feature' in inject_sb
In reply to Sheng Yong via Linux-f2fs-develThis patch adds a new member `feature' in inject_sb to inject features.
--- fsck/inject.c | 5 +++++ man/inject.f2fs.8 | 3 +++ 2 files changed, 8 insertions(+)
fsck/inject.c +5 -0
@@ -121,6 +121,7 @@ static void inject_sb_usage(void)MSG (0 ," magic: inject magic number\n" );MSG (0 ," s_stop_reason: inject s_stop_reason array selected by --idx <index>\n" );MSG (0 ," s_errors: inject s_errors array selected by --idx <index>\n" ); +MSG (0 ," feature: inject feature\n" );MSG (0 ," devs.path: inject path in devs array selected by --idx <index> specified by --str <string>\n" ); }
@@ -412,6 +413,10 @@ static int inject_sb(struct f2fs_sb_info *sbi, struct inject_option *opt)MSG (0 ,"Info: inject s_errors[%d] of sb %d: %x -> %x\n" , opt->idx, opt->sb, sb->s_errors[opt->idx], (u8 )opt->val); sb->s_errors[opt->idx] = (u8 )opt->val; + }else if (!strcmp (opt->mb,"feature" )) { +MSG (0 ,"Info: inject feature of sb %d: 0x%x -> 0x%x\n" , + opt->sb,get_sb (feature), (u32 )opt->val); +set_sb (feature, (u32 )opt->val); }else if (!strcmp (opt->mb,"devs.path" )) {if (opt->idx >=MAX_DEVICES ) {ERR_MSG ("invalid index %u of sb->devs[]\n" , opt->idx);
man/inject.f2fs.8 +3 -0
@@ -53,6 +53,9 @@ s_stop_reason array. .BI s_errors s_errors array. .TP +.BI feature +feature. +.TP .BI devs.path path in devs array. .RE
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 6/24 inject.f2fs: add members in inject_node
In reply to Sheng Yong via Linux-f2fs-develThis patch adds new members in inject_node to inject inode:
* i_ext.fofs: extent fofs
* i_ext.blk_addr: extent blk_addr
* i_ext.len: extent len
* i_inline_xattr_size: inline xattr size
* i_compr_blocks: compression blocks
--- fsck/inject.c | 28 ++++++++++++++++++++++++++++ man/inject.f2fs.8 | 12 ++++++++++++ 2 files changed, 40 insertions(+)
fsck/inject.c +28 -0
@@ -197,8 +197,13 @@ static void inject_node_usage(void)MSG (0 ," i_links: inject inode i_links\n" );MSG (0 ," i_size: inject inode i_size\n" );MSG (0 ," i_blocks: inject inode i_blocks\n" ); +MSG (0 ," i_ext.fofs: inject inode i_ext.fofs\n" ); +MSG (0 ," i_ext.blk_addr: inject inode i_ext.blk_addr\n" ); +MSG (0 ," i_ext.len: inject inode i_ext.len\n" );MSG (0 ," i_extra_isize: inject inode i_extra_isize\n" ); +MSG (0 ," i_inline_xattr_size: inject inode i_inline_xattr_size\n" );MSG (0 ," i_inode_checksum: inject inode i_inode_checksum\n" ); +MSG (0 ," i_compr_blocks: inject inode i_compr_blocks\n" );MSG (0 ," i_addr: inject inode i_addr array selected by --idx <index>\n" );MSG (0 ," i_nid: inject inode i_nid array selected by --idx <index>\n" );MSG (0 ," addr: inject {in}direct node nid/addr array selected by --idx <index>\n" );
@@ -877,16 +882,39 @@ static int inject_inode(struct f2fs_sb_info *sbi, struct f2fs_node *node,MSG (0 ,"Info: inject inode i_blocks of nid %u: %" PRIu64" -> %" PRIu64"\n" , opt->nid,le64_to_cpu (inode->i_blocks), (u64 )opt->val); inode->i_blocks =cpu_to_le64 ((u64 )opt->val); + }else if (!strcmp (opt->mb,"i_ext.fofs" )) { +MSG (0 ,"Info: inject inode i_ext.fofs of nid %u: %u -> %u\n" , + opt->nid,le32_to_cpu (inode->i_ext.fofs), (u32 )opt->val); + inode->i_ext.fofs =cpu_to_le32 ((u32 )opt->val); + }else if (!strcmp (opt->mb,"i_ext.blk_addr" )) { +MSG (0 ,"Info: inject inode i_ext.blk_addr of nid 0x%x: " +"0x%x -> 0x%x\n" , opt->nid, +le32_to_cpu (inode->i_ext.blk_addr), (u32 )opt->val); + inode->i_ext.blk_addr =cpu_to_le32 ((u32 )opt->val); + }else if (!strcmp (opt->mb,"i_ext.len" )) { +MSG (0 ,"Info: inject inode i_ext.len of nid %u: %u -> %u\n" , + opt->nid,le32_to_cpu (inode->i_ext.len), (u32 )opt->val); + inode->i_ext.len =cpu_to_le32 ((u32 )opt->val); }else if (!strcmp (opt->mb,"i_extra_isize" )) {/* do not care if F2FS_EXTRA_ATTR is enabled */ MSG (0 ,"Info: inject inode i_extra_isize of nid %u: %d -> %d\n" , opt->nid,le16_to_cpu (inode->i_extra_isize), (u16 )opt->val); inode->i_extra_isize =cpu_to_le16 ((u16 )opt->val); + }else if (!strcmp (opt->mb,"i_inline_xattr_size" )) { +MSG (0 ,"Info: inject inode i_inline_xattr_size of nid %u: " +"%d -> %d\n" , opt->nid, +le16_to_cpu (inode->i_inline_xattr_size), (u16 )opt->val); + inode->i_inline_xattr_size =cpu_to_le16 ((u16 )opt->val); }else if (!strcmp (opt->mb,"i_inode_checksum" )) {MSG (0 ,"Info: inject inode i_inode_checksum of nid %u: " "0x%x -> 0x%x\n" , opt->nid,le32_to_cpu (inode->i_inode_checksum), (u32 )opt->val); inode->i_inode_checksum =cpu_to_le32 ((u32 )opt->val); + }else if (!strcmp (opt->mb,"i_compr_blocks" )) { +MSG (0 ,"Info: inject inode i_compr_blocks of nid %u: " +"%lu -> %lu\n" , opt->nid, +le64_to_cpu (inode->i_compr_blocks), (u64 )opt->val); + inode->i_compr_blocks =cpu_to_le64 ((u64 )opt->val); }else if (!strcmp (opt->mb,"i_addr" )) {/* do not care if it is inline data */ if (opt->idx >=DEF_ADDRS_PER_INODE ) {
man/inject.f2fs.8 +12 -0
@@ -182,9 +182,21 @@ inode i_size. .BI i_blocks inode i_blocks. .TP +.BI i_ext.fofs +inode i_ext.fofs. +.TP +.BI i_ext.blk_addr +inode i_ext.blk_addr. +.TP +.BI i_ext.len +inode i_ext.len. +.TP .BI i_extra_isize inode i_extra_isize. .TP +.BI i_inline_xattr_size +inode i_inline_xattr_size. +.TP .BI i_inode_checksum inode i_inode_checksum. .TP
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 7/24 inject.f2fs: add member `filename' in inject_dentry
In reply to Sheng Yong via Linux-f2fs-develThis patch adds a new member `filename' in inject_dentry to inject dentry filename. The dentry is specified by nid option.
Note that .' and ..' dentries are special, because they are not in the parent directory of nid. So this patch also adds a new option `--dots' to inject these two dentries.
--- fsck/inject.c | 94 ++++++++++++++++++++++++++++++++++++++++------- fsck/inject.h | 1 + man/inject.f2fs.8 | 13 ++++++- 3 files changed, 93 insertions(+), 15 deletions(-)
fsck/inject.c +80 -14
@@ -104,7 +104,7 @@ void inject_usage(void)MSG (0 ," --sit <0|1|2> --mb <name> --blk <blk> [--idx <index>] --val <value> inject sit entry\n" );MSG (0 ," --ssa --mb <name> --blk <blk> [--idx <index>] --val <value> inject summary entry\n" );MSG (0 ," --node --mb <name> --nid <nid> [--idx <index>] --val <value> inject node\n" ); -MSG (0 ," --dent --mb <name> --nid <ino> [--idx <index>] --val <value> inject ino's dentry\n" ); +MSG (0 ," --dent --mb <name> --nid <ino> [--dots <1|2>] --val/str <value/string> inject ino's dentry\n" );MSG (0 ," --dry-run do not really inject\n" );exit (1 );
@@ -211,12 +211,16 @@ static void inject_node_usage(void)static void inject_dent_usage (void ) { -MSG (0 ,"inject.f2fs --dent --mb <name> --nid <nid> [--idx <index>] --val <value> inject dentry\n" ); +MSG (0 ,"inject.f2fs --dent --mb <name> --nid <nid> [--dots <1|2>] --val/str <value/string> inject dentry\n" ); +MSG (0 ,"[dots]:\n" ); +MSG (0 ," 1: inject \".\" in directory which is specified by nid\n" ); +MSG (0 ," 2: inject \"..\" in directory which is specified by nid\n" );MSG (0 ,"[mb]:\n" );MSG (0 ," d_bitmap: inject dentry block d_bitmap of nid\n" );MSG (0 ," d_hash: inject dentry hash\n" );MSG (0 ," d_ino: inject dentry ino\n" );MSG (0 ," d_ftype: inject dentry ftype\n" ); +MSG (0 ," filename: inject dentry filename, its hash and len are updated implicitly\n" ); }int inject_parse_options (int argc,char *argv[],struct inject_option *opt)
@@ -240,6 +244,7 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) {"ssa", no_argument, 0, 12}, {"node", no_argument, 0, 13}, {"dent", no_argument, 0, 14}, + {"dots", required_argument, 0, 15}, {0, 0, 0, 0} };
@@ -336,6 +341,14 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) opt->dent = true;MSG (0 ,"Info: inject dentry\n" );break ; +case 15 : + opt->dots =atoi (optarg); +if (opt->dots !=TYPE_DOT && + opt->dots !=TYPE_DOTDOT ) +return -ERANGE ; +MSG (0 ,"Info: inject %s dentry\n" , + opt->dots ==TYPE_DOT ?"dot" :"dotdot" ); +break ;case 'd' :if (optarg[0 ] =='-' || !is_digits (optarg))return EWRONG_OPT ;
@@ -368,6 +381,9 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) }else if (opt->dent) {inject_dent_usage ();exit (0 ); + }else { +MSG (0 ,"\tError: Wrong option -%c (%d) %s\n" , + o, o, optarg); }return EUNKNOWN_OPT ; }
@@ -1056,12 +1072,12 @@ static int find_dir_entry(struct f2fs_dentry_ptr *d, nid_t ino) } de = &d->dentry[slot]; -if (le32_to_cpu (de->ino) == ino && de->hash_code !=0 ) -return slot;if (de->name_len ==0 ) { slot++;continue ; } +if (le32_to_cpu (de->ino) == ino) +return slot; slot +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); }
@@ -1074,14 +1090,15 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)struct f2fs_node *node_blk =NULL ;struct f2fs_inode *inode;struct f2fs_dentry_ptr d; -void *inline_dentry; +void *buf =NULL , *inline_dentry;struct f2fs_dentry_block *dent_blk =NULL ;block_t addr =0 ; -void *buf =NULL ;struct f2fs_dir_entry *dent =NULL ;struct dnode_of_data dn;nid_t pino; -int slot = -ENOENT , ret; +int slot = -ENOENT , namelen, namecap, ret; +unsigned int dentry_hash; +char *name; node_blk =malloc (F2FS_BLKSIZE );ASSERT (node_blk !=NULL );
@@ -1090,12 +1107,25 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)get_node_info (sbi, opt->nid, &ni); ret =dev_read_block (node_blk, ni.blk_addr);ASSERT (ret >=0 ); - pino =le32_to_cpu (node_blk->i.i_pino); -/* get parent inode */ -get_node_info (sbi, pino, &ni); - ret =dev_read_block (node_blk, ni.blk_addr); -ASSERT (ret >=0 ); +if (opt->dots) { +if (!LINUX_S_ISDIR (le16_to_cpu (node_blk->i.i_mode))) { +ERR_MSG ("ino %u is not a directory, cannot inject " +"its %s\n" , opt->nid, + opt->dots ==TYPE_DOT ?"." :".." ); + ret = -EINVAL ; + goto out; + } +/* pino is itself */ + pino = opt->nid; + }else { + pino =le32_to_cpu (node_blk->i.i_pino); + +/* get parent inode */ +get_node_info (sbi, pino, &ni); + ret =dev_read_block (node_blk, ni.blk_addr); +ASSERT (ret >=0 ); + } inode = &node_blk->i;/* find child dentry */
@@ -1105,7 +1135,10 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt) addr = ni.blk_addr; buf = node_blk; - slot =find_dir_entry (&d, opt->nid); +if (opt->dots ==TYPE_DOTDOT ) + slot =find_dir_entry (&d,le32_to_cpu (node_blk->i.i_pino)); +else + slot =find_dir_entry (&d, opt->nid);if (slot >=0 ) dent = &d.dentry[slot]; }else {
@@ -1141,7 +1174,10 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)ASSERT (ret >=0 );make_dentry_ptr (&d, node_blk, dent_blk,1 ); - slot =find_dir_entry (&d, opt->nid); +if (opt->dots ==TYPE_DOTDOT ) + slot =find_dir_entry (&d,le32_to_cpu (node_blk->i.i_pino)); +else + slot =find_dir_entry (&d, opt->nid);if (slot >=0 ) { dent = &d.dentry[slot]; buf = dent_blk;
@@ -1175,6 +1211,36 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)"%d -> %d\n" , opt->nid, dent->file_type, (u8)opt->val); dent->file_type = (u8 )opt->val; + }else if (!strcmp (opt->mb,"filename" )) { +if (!opt->str) { +ERR_MSG ("option str is needed\n" ); + ret = -EINVAL ; + goto out; + } + namecap =ALIGN_UP (le16_to_cpu (dent->name_len),F2FS_SLOT_LEN ); + namelen =strlen (opt->str); +if (namelen > namecap) { +ERR_MSG ("option str too long\n" ); + ret = -EINVAL ; + goto out; + } + name = (char *)d.filename[slot]; +MSG (0 ,"Info: inject dentry filename of nid %u: " +"%.*s -> %s\n" , opt->nid,le16_to_cpu (dent->name_len), + name, opt->str); +memcpy (name, opt->str, namelen); +MSG (0 ,"Info: inject dentry namelen of nid %u: " +"%d -> %d\n" , opt->nid,le16_to_cpu (dent->name_len), + namelen); + dent->name_len =cpu_to_le16 (namelen); + dentry_hash =f2fs_dentry_hash (get_encoding (sbi), +IS_CASEFOLDED (inode), + (unsigned char *)name, + namelen); +MSG (0 ,"Info: inject dentry d_hash of nid %u: " +"0x%x -> 0x%x\n" , opt->nid,le32_to_cpu (dent->hash_code), + dentry_hash); + dent->hash_code =cpu_to_le32 (dentry_hash); }else {ERR_MSG ("unknown or unsupported member \"%s\"\n" , opt->mb); ret = -EINVAL ;
fsck/inject.h +1 -0
@@ -30,6 +30,7 @@ struct inject_option {int cp;/* which cp */ int nat;/* which nat pack */ int sit;/* which sit pack */ +int dots;/* . or .. dentry */ bool ssa;bool node;bool dent;
man/inject.f2fs.8 +12 -1
@@ -211,12 +211,20 @@ inode i_nid array specified by \fIidx\fP. .RE .TP .BI \-\-dent -Inject dentry block or dir entry specified \fInid\fP. +Inject dentry block or dir entry specified by \fInid\fP. +.RS 1.2i +.TP +.BI \-\-dots " 1 or 2" +The option means the "." or ".." directory entry of \fInid\fP is going to be injected. +.RE +.TP +.BI "" The available \fImb\fP of \fIdent\fP are: .RS 1.2i .TP .BI d_bitmap dentry block d_bitmap. +dentry block d_bitmap. .TP .BI d_hash dentry hash.
@@ -226,6 +234,9 @@ dentry ino. .TP .BI d_ftype dentry ftype. +.TP +.BI filename +dentry filename, and corresponding d_hash and namelen are updated implicitly. .RE .TP .BI \-\-dry\-run
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [RFC PATCH 07/24] inject.f2fs: add member `filename' in inject_dentry
Quoted 170 lines · Sheng Yong
This patch adds a new member `filename' in
inject_dentryto inject dentry filename. The dentry is specified by nid option.Note that
.' and..' dentries are special, because they are not in the parent directory of nid. So this patch also adds a new option `--dots' to inject these two dentries.Signed-off-by Sheng Yong <[email protected]>--- fsck/inject.c | 94 ++++++++++++++++++++++++++++++++++++++++------- fsck/inject.h | 1 + man/inject.f2fs.8 | 13 ++++++- 3 files changed, 93 insertions(+), 15 deletions(-)fsck/inject.c +50
-14@@ -104,7 +104,7 @@ void inject_usage(void)MSG (0 ," --sit <0|1|2> --mb <name> --blk <blk> [--idx <index>] --val <value> inject sit entry\n" );MSG (0 ," --ssa --mb <name> --blk <blk> [--idx <index>] --val <value> inject summary entry\n" );MSG (0 ," --node --mb <name> --nid <nid> [--idx <index>] --val <value> inject node\n" ); -MSG (0 ," --dent --mb <name> --nid <ino> [--idx <index>] --val <value> inject ino's dentry\n" ); +MSG (0 ," --dent --mb <name> --nid <ino> [--dots <1|2>] --val/str <value/string> inject ino's dentry\n" );MSG (0 ," --dry-run do not really inject\n" );exit (1 );@@ -211,12 +211,16 @@ static void inject_node_usage(void)static void inject_dent_usage (void ) { -MSG (0 ,"inject.f2fs --dent --mb <name> --nid <nid> [--idx <index>] --val <value> inject dentry\n" ); +MSG (0 ,"inject.f2fs --dent --mb <name> --nid <nid> [--dots <1|2>] --val/str <value/string> inject dentry\n" ); +MSG (0 ,"[dots]:\n" ); +MSG (0 ," 1: inject \".\" in directory which is specified by nid\n" ); +MSG (0 ," 2: inject \"..\" in directory which is specified by nid\n" );MSG (0 ,"[mb]:\n" );MSG (0 ," d_bitmap: inject dentry block d_bitmap of nid\n" );MSG (0 ," d_hash: inject dentry hash\n" );MSG (0 ," d_ino: inject dentry ino\n" );MSG (0 ," d_ftype: inject dentry ftype\n" ); +MSG (0 ," filename: inject dentry filename, its hash and len are updated implicitly\n" ); }int inject_parse_options (int argc,char *argv[],struct inject_option *opt)@@ -240,6 +244,7 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) {"ssa", no_argument, 0, 12}, {"node", no_argument, 0, 13}, {"dent", no_argument, 0, 14}, + {"dots", required_argument, 0, 15}, {0, 0, 0, 0} };@@ -336,6 +341,14 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) opt->dent = true;MSG (0 ,"Info: inject dentry\n" );break ; +case 15 : + opt->dots =atoi (optarg); +if (opt->dots !=TYPE_DOT && + opt->dots !=TYPE_DOTDOT ) +return -ERANGE ; +MSG (0 ,"Info: inject %s dentry\n" , + opt->dots ==TYPE_DOT ?"dot" :"dotdot" ); +break ;case 'd' :if (optarg[0 ] =='-' || !is_digits (optarg))return EWRONG_OPT ;@@ -368,6 +381,9 @@ int inject_parse_options(int argc, char *argv[], struct inject_option *opt) }else if (opt->dent) {inject_dent_usage ();exit (0 ); + }else { +MSG (0 ,"\tError: Wrong option -%c (%d) %s\n" , + o, o, optarg); }return EUNKNOWN_OPT ; }@@ -1056,12 +1072,12 @@ static int find_dir_entry(struct f2fs_dentry_ptr *d, nid_t ino) } de = &d->dentry[slot]; -if (le32_to_cpu (de->ino) == ino && de->hash_code !=0 ) -return slot;if (de->name_len ==0 ) { slot++;continue ; } +if (le32_to_cpu (de->ino) == ino) +return slot; slot +=GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); }@@ -1074,14 +1090,15 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)struct f2fs_node *node_blk =NULL ;struct f2fs_inode *inode;struct f2fs_dentry_ptr d; -void *inline_dentry; +void *buf =NULL , *inline_dentry;struct f2fs_dentry_block *dent_blk =NULL ;block_t addr =0 ; -void *buf =NULL ;struct f2fs_dir_entry *dent =NULL ;struct dnode_of_data dn;nid_t pino; -int slot = -ENOENT , ret; +int slot = -ENOENT , namelen, namecap, ret; +unsigned int dentry_hash; +char *name; node_blk =malloc (F2FS_BLKSIZE );ASSERT (node_blk !=NULL );@@ -1090,12 +1107,25 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)get_node_info (sbi, opt->nid, &ni); ret =dev_read_block (node_blk, ni.blk_addr);ASSERT (ret >=0 ); - pino =le32_to_cpu (node_blk->i.i_pino); -/* get parent inode */ -get_node_info (sbi, pino, &ni); - ret =dev_read_block (node_blk, ni.blk_addr); -ASSERT (ret >=0 ); +if (opt->dots) { +if (!LINUX_S_ISDIR (le16_to_cpu (node_blk->i.i_mode))) { +ERR_MSG ("ino %u is not a directory, cannot inject " +"its %s\n" , opt->nid, + opt->dots ==TYPE_DOT ?"." :".." ); + ret = -EINVAL ; + goto out; + } +/* pino is itself */ + pino = opt->nid; + }else { + pino =le32_to_cpu (node_blk->i.i_pino); + +/* get parent inode */ +get_node_info (sbi, pino, &ni); + ret =dev_read_block (node_blk, ni.blk_addr); +ASSERT (ret >=0 ); + } inode = &node_blk->i;/* find child dentry */ @@ -1105,7 +1135,10 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt) addr = ni.blk_addr; buf = node_blk; - slot =find_dir_entry (&d, opt->nid); +if (opt->dots ==TYPE_DOTDOT ) + slot =find_dir_entry (&d,le32_to_cpu (node_blk->i.i_pino)); +else + slot =find_dir_entry (&d, opt->nid);if (slot >=0 ) dent = &d.dentry[slot]; }else {@@ -1141,7 +1174,10 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)ASSERT (ret >=0 );make_dentry_ptr (&d, node_blk, dent_blk,1 ); - slot =find_dir_entry (&d, opt->nid); +if (opt->dots ==TYPE_DOTDOT ) + slot =find_dir_entry (&d,le32_to_cpu (node_blk->i.i_pino)); +else + slot =find_dir_entry (&d, opt->nid);if (slot >=0 ) { dent = &d.dentry[slot]; buf = dent_blk;@@ -1175,6 +1211,36 @@ static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt)"%d -> %d\n" , opt->nid, dent->file_type, (u8)opt->val);
fsck/inject.c static int inject_dentry(struct f2fs_sb_info *sbi, struct inject_option *opt) · line 1222
Quoted 10 lines
fsck/inject.c +9
-0dent->file_type = (u8 )opt->val; + }else if (!strcmp (opt->mb,"filename" )) { +if (!opt->str) { +ERR_MSG ("option str is needed\n" ); + ret = -EINVAL ; + goto out; + } + namecap =ALIGN_UP (le16_to_cpu (dent->name_len),F2FS_SLOT_LEN ); + namelen =strlen (opt->str); +if (namelen > namecap) {
if (namelen > namecap || namelen > F2FS_NAME_LEN)
or maybe later, we can remove this check to allow injecting filename w/ longer name length than original one.
Thanks,
Quoted 63 lines
fsck/inject.c +21
-0+ERR_MSG ("option str too long\n" ); + ret = -EINVAL ; + goto out; + } + name = (char *)d.filename[slot]; +MSG (0 ,"Info: inject dentry filename of nid %u: " +"%.*s -> %s\n" , opt->nid,le16_to_cpu (dent->name_len), + name, opt->str); +memcpy (name, opt->str, namelen); +MSG (0 ,"Info: inject dentry namelen of nid %u: " +"%d -> %d\n" , opt->nid,le16_to_cpu (dent->name_len), + namelen); + dent->name_len =cpu_to_le16 (namelen); + dentry_hash =f2fs_dentry_hash (get_encoding (sbi), +IS_CASEFOLDED (inode), + (unsigned char *)name, + namelen); +MSG (0 ,"Info: inject dentry d_hash of nid %u: " +"0x%x -> 0x%x\n" , opt->nid,le32_to_cpu (dent->hash_code), + dentry_hash); + dent->hash_code =cpu_to_le32 (dentry_hash); }else {ERR_MSG ("unknown or unsupported member \"%s\"\n" , opt->mb); ret = -EINVAL ;fsck/inject.h +1
-0@@ -30,6 +30,7 @@ struct inject_option {int cp;/* which cp */ int nat;/* which nat pack */ int sit;/* which sit pack */ +int dots;/* . or .. dentry */ bool ssa;bool node;bool dent;man/inject.f2fs.8 +9
-1@@ -211,12 +211,20 @@ inode i_nid array specified by \fIidx\fP. .RE .TP .BI \-\-dent -Inject dentry block or dir entry specified \fInid\fP. +Inject dentry block or dir entry specified by \fInid\fP. +.RS 1.2i +.TP +.BI \-\-dots " 1 or 2" +The option means the "." or ".." directory entry of \fInid\fP is going to be injected. +.RE +.TP +.BI "" The available \fImb\fP of \fIdent\fP are: .RS 1.2i .TP .BI d_bitmap dentry block d_bitmap. +dentry block d_bitmap. .TP .BI d_hash dentry hash.
man/inject.f2fs.8 dentry ino. · line 242
Quoted 9 lines
man/inject.f2fs.8 +3
-0@@ -226,6 +234,9 @@ dentry ino. .TP .BI d_ftype dentry ftype. +.TP +.BI filename +dentry filename, and corresponding d_hash and namelen are updated implicitly. .RE .TP .BI \-\-dry\-run
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 8/24 tests: prepare helper scripts for testcases
In reply to Sheng Yong via Linux-f2fs-develThis patch addes helper scripts for auto testcases, and testcases of fsck will be submitted in the following commits.
The basic idea of these testcases are:
1. create f2fs image
2. corrupt the image by inject specific fields
3. fsck fixes the corrupted image
4. verify fsck output with expected message
The helper scripts include:
* test_config.in: is used to generate the basic configurations of all testcases.
* runtests.in: is used to generate `runtests'.
* filter.sed: is used to remove unnecessary messages and cleanup arbitrary values.
* helpers: provides helper functions
The usage of runtests:
* run all testcases:
runtests
* run one testcase:
runtests <testcase directory path>
* cleanup previous results:
runtests clean
Each testcase should have a sub-directory, where three files should be included:
* README: describe information of the testcase
* script: testcase itself
* expect.in: expected output message
an optional file is:
* img.tar.gz: if some scenario is too complex to create by script, the gz file could be prepared in advance, and the operations of how to create the image should be described in README
New files are generated in the testcase directory after test:
* log: output in detail
* expect: derived from expect.in
* out: output that will be compared with expect
* PASS: testcase is passed
* FAIL: testcase is failed
--- .gitignore | 13 ++++ Makefile.am | 2 +- configure.ac | 1 + tests/Makefile.am | 28 ++++++++ tests/filter.sed | 60 +++++++++++++++++ tests/helpers | 157 +++++++++++++++++++++++++++++++++++++++++++ tests/runtests.in | 46 +++++++++++++ tests/test_config.in | 47 +++++++++++++ 8 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 tests/Makefile.am create mode 100644 tests/filter.sed create mode 100644 tests/helpers create mode 100644 tests/runtests.in create mode 100644 tests/test_config.in
.gitignore +13 -0
@@ -46,6 +46,8 @@ stamp-h1 /mkfs/mkfs.f2fs /fsck/fsck.f2fs +/fsck/dump.f2fs +/fsck/inject.f2fs /tools/fibmap.f2fs /tools/parse.f2fs /tools/f2fscrypt
@@ -54,3 +56,14 @@ stamp-h1 # cscope files cscope.* ncscope.* + +# testcase files +tests/*/log +tests/*/out +tests/*/PASS +tests/*/FAIL +tests/*/expect +tests/meta.img +tests/data.img +tests/runtests +tests/test_config
Makefile.am +1 -1
@@ -2,4 +2,4 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = man lib mkfs fsck tools +SUBDIRS = man lib mkfs fsck tools tests
configure.ac +1 -0
@@ -263,6 +263,7 @@ AC_CONFIG_FILES([ fsck/Makefile tools/Makefile tools/f2fs_io/Makefile + tests/Makefile ]) AC_CHECK_MEMBER([struct blk_zone.capacity],
tests/Makefile.am new file +28 -0
@@ -0,0 +1,28 @@ +## Makefile.am + +noinst_SCRIPTS = test_config runtests +CLEANFILES = $(bin_SCRIPTS) +EXTRA_DIST = test_config.in runtests.in + +test_config: $(srcdir)/test_config.in + @echo "Creating test_config script..." + @[ -f test_config ] && chmod u+w test_config || true + @echo "#!/bin/bash" > test_config + @echo "" >> test_config + @echo "TOPDIR=@top_srcdir@" >> test_config + @cat $(srcdir)/test_config.in >> test_config + @chmod +x-w test_config + +runtests: $(srcdir)/runtests.in + @echo "Creating runtests script..." + @[ -f runtests ] && chmod u+w runtests || true + @echo "#!/bin/bash" > runtests + @echo "" >> runtests + @echo "SRCDIR=@srcdir@" >> runtests + @cat $(srcdir)/runtests.in >> runtests + @chmod +x-w runtests + +clean-local: + @[ -f runtests ] && runtests clean || true + @rm -f runtests test_config +
tests/filter.sed new file +60 -0
60 lines not on this page · raw message
tests/helpers new file +157 -0
157 lines not on this page · raw message
tests/runtests.in new file +46 -0
46 lines not on this page · raw message
tests/test_config.in new file +47 -0
47 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 9/24 tests: add fsck testcase of fixing bad super magic
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_sb_bad_magic/README | 3 +++ tests/f_sb_bad_magic/expect.in | 40 ++++++++++++++++++++++++++++++++++ tests/f_sb_bad_magic/script | 16 ++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 tests/f_sb_bad_magic/README create mode 100644 tests/f_sb_bad_magic/expect.in create mode 100644 tests/f_sb_bad_magic/script
tests/f_sb_bad_magic/README new file +3 -0
@@ -0,0 +1,3 @@ +1. create f2fs image +2. inject magic in sb 1 with value 0x12345 +3. fsck fixes bad magic by copying sb 2
tests/f_sb_bad_magic/expect.in new file +40 -0
@@ -0,0 +1,40 @@ +Info: Force to fix corruption +Magic Mismatch, valid(0xf2f52010) - read(0x12345) + Can't find a valid F2FS superblock at 0x0 +Looking for secondary superblock assuming 4K Block Size +Info: Write valid nat_bits in checkpoint +Info: checkpoint state = x : nat_bits compacted_summary unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: write_checkpoint() cur_cp:x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x +[update_superblock: x] Info: Done to update superblock + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_sb_bad_magic/script new file +16 -0
@@ -0,0 +1,16 @@ +#!/bin/bash + +DESC="superblock[1] with invalid magic number" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 +make_f2fs >> $LOG 2>&1 + +$INJECT --sb 1 --mb magic --val 0x12345 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -f $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +check_result +cleanup post >> $LOG 2>&1
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 10/24 tests: add fsck testcase of fixing errors recorded in sb
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_sb_errors/README | 5 ++++ tests/f_sb_errors/expect.in | 59 +++++++++++++++++++++++++++++++++++++ tests/f_sb_errors/script | 23 +++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 tests/f_sb_errors/README create mode 100644 tests/f_sb_errors/expect.in create mode 100644 tests/f_sb_errors/script
tests/f_sb_errors/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. inject s_stop_reason in super block +3. fsck -a detects error and clear the error +4. inject s_errors in super block +5. fsck -a detects error and clear the error
tests/f_sb_errors/expect.in new file +59 -0
59 lines not on this page · raw message
tests/f_sb_errors/script new file +23 -0
@@ -0,0 +1,23 @@ +#!/bin/bash + +DESC="superblock[1] with s_stop_reason and s_errors" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 +make_f2fs >> $LOG 2>&1 + +$INJECT --sb 1 --mb s_stop_reason --idx 1 --val 1 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -a $META > $OUT 2>&1 + +$INJECT --sb 1 --mb s_errors --idx 0 --val 2 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -a $META >> $OUT 2>&1 + +# both -a and -f cannot detect errors +$FSCK $FSCK_OPTS -a $META >> $OUT 2>&1 +echo "" >> $OUT +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +check_result +cleanup post >> $LOG 2>&1
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 11/24 tests: add fsck testcase of fixing cp crc
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_cp_bad_crc/README | 5 ++++ tests/f_cp_bad_crc/expect.in | 22 +++++++++++++++++ tests/f_cp_bad_crc/script | 46 ++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/f_cp_bad_crc/README create mode 100644 tests/f_cp_bad_crc/expect.in create mode 100644 tests/f_cp_bad_crc/script
tests/f_cp_bad_crc/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. create a new file +3. inject crc in current cp with value 0x12345 +4. fsck fixes bad cp by copying backup cp +5. compare cp1 version with cp2 version, both cp should have the same version
tests/f_cp_bad_crc/expect.in new file +22 -0
@@ -0,0 +1,22 @@ +Info: Automatic fix mode enabled. + Invalid CP CRC: offset:_OFFS_, crc:0x12345, calc:_CRC_ +Info: checkpoint state = x : nat_bits crc fsck compacted_summary unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: write_checkpoint() cur_cp:x + +Info: Automatic fix mode enabled. +Info: checkpoint state = x : nat_bits unmount +Info: No error was reported
tests/f_cp_bad_crc/script new file +46 -0
46 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 12/24 tests: add fsck testcase of fixing nat entry with invalid ino
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_nat_bad_ino/README | 4 ++++ tests/f_nat_bad_ino/expect.in | 39 +++++++++++++++++++++++++++++++++++ tests/f_nat_bad_ino/script | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/f_nat_bad_ino/README create mode 100644 tests/f_nat_bad_ino/expect.in create mode 100644 tests/f_nat_bad_ino/script
tests/f_nat_bad_ino/README new file +4 -0
@@ -0,0 +1,4 @@ +1. create f2fs image +2. mount f2fs and create a regular file +3. inject ino in nat entry with value 0x12345 of the regular file +4. fsck fixes the nat entry by nullifying it
tests/f_nat_bad_ino/expect.in new file +39 -0
@@ -0,0 +1,39 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (sanity_check_nid: x) --> nid[_INO_] nat_entry->ino[0x12345] footer.ino[_INO_] +[FIX] (__chk_dentries:x) --> Unlink [_INO_] - testfile len[0x8], type[0x1] + +NID[_INO_] is unreachable, blkaddr:_BLK_ +[FSCK] Unreachable nat entries [Fail] [x] +[FSCK] SIT valid block bitmap checking [Fail] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Fail] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Fail] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Fail] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: write_checkpoint() cur_cp:x +[FIX] (nullify_nat_entry:x) --> Remove nid [_INO_] in NAT +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_nat_bad_ino/script new file +39 -0
@@ -0,0 +1,39 @@ +#!/bin/sh + +DESC="nat entry with invalid ino" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 +make_f2fs >> $LOG 2>&1 + +mkdir $TESTDIR/mntdir +safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot mount f2fs image" + exit +fi +touch $TESTDIR/mntdir/testfile +ino=`stat -c "%i" $TESTDIR/mntdir/testfile` +safe_umount $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot umount f2fs image" + exit +fi +rm -rf $TESTDIR/mntdir + +blk=`$DUMP $DUMP_OPTS -i $ino -d 1 $META | grep nat_entry.block_addr | sed 's/.*nat_entry\.block_addr\s*\[\(0x[0-9a-f]\+\)\]/\1/g'` + +echo "ino:$ino blk:$blk" >> $LOG + +$INJECT --nat 1 --nid $ino --mb ino --val 0x12345 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -f $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +INO=`printf "0x%x" $ino` +sed "s/_INO_/$INO/g" $TESTDIR/expect.in > $TESTDIR/expect +sed -i "s/_BLK_/$blk/g" $TESTDIR/expect + +check_result +cleanup post >> $LOG 2>&1
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 13/24 tests: add fsck testcase of fixing nat entry with invalid blkaddr
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_nat_bad_blkaddr/README | 4 ++++ tests/f_nat_bad_blkaddr/expect.in | 39 +++++++++++++++++++++++++++++++ tests/f_nat_bad_blkaddr/script | 35 +++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 tests/f_nat_bad_blkaddr/README create mode 100644 tests/f_nat_bad_blkaddr/expect.in create mode 100644 tests/f_nat_bad_blkaddr/script
tests/f_nat_bad_blkaddr/README new file +4 -0
@@ -0,0 +1,4 @@ +1. create f2fs image +2. mount f2fs and create a regular file +3. inject block_addr in nat entry with value 0x12345 of the regular file +4. fsck fixes the nat entry by nullifying it
tests/f_nat_bad_blkaddr/expect.in new file +39 -0
@@ -0,0 +1,39 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (sanity_check_nat: x) --> blkaddress is not valid. [_BLK_] +[FIX] (__chk_dentries:x) --> Unlink [_INO_] - testfile len[0x8], type[0x1] + +NID[_INO_] is unreachable, blkaddr:_BLK_ +[FSCK] Unreachable nat entries [Fail] [x] +[FSCK] SIT valid block bitmap checking [Fail] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Fail] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Fail] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Fail] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: write_checkpoint() cur_cp:x +[FIX] (nullify_nat_entry:x) --> Remove nid [_INO_] in NAT +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_nat_bad_blkaddr/script new file +35 -0
@@ -0,0 +1,35 @@ +#!/bin/bash + +DESC="nat entry with invalid block_addr" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 +make_f2fs >> $LOG 2>&1 + +mkdir $TESTDIR/mntdir +safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot mount f2fs image" + exit +fi +touch $TESTDIR/mntdir/testfile +ino=`stat -c "%i" $TESTDIR/mntdir/testfile` +safe_umount $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot umount f2fs image" + exit +fi +rm -rf $TESTDIR/mntdir + +$INJECT --nat 0 --nid $ino --mb block_addr --val 0x12345 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -f $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +INO=`printf "0x%x" $ino` +sed "s/_INO_/$INO/g" $TESTDIR/expect.in > $TESTDIR/expect +sed -i "s/_BLK_/0x12345/g" $TESTDIR/expect + +check_result +cleanup post >> $LOG 2>&1
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 14/24 tests: add fsck testcase of fixing sit entry type
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_sit_bad_type/README | 5 ++++ tests/f_sit_bad_type/expect.in | 34 +++++++++++++++++++++++++ tests/f_sit_bad_type/script | 45 ++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 tests/f_sit_bad_type/README create mode 100644 tests/f_sit_bad_type/expect.in create mode 100644 tests/f_sit_bad_type/script
tests/f_sit_bad_type/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject type in the sit entry of the blkaddr and change its type to NODE +5. fsck fixes the type to DATA
tests/f_sit_bad_type/expect.in new file +34 -0
@@ -0,0 +1,34 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FIX] (check_sit_types:x) --> Wrong segment type [_SEGNO_] 3 -> 1 +[FSCK] other corrupted bugs [Ok..] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_sit_bad_type/script new file +45 -0
45 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 15/24 tests: add fsck testcase of fixing sit entry vblocks
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_sit_bad_vblocks/README | 5 ++++ tests/f_sit_bad_vblocks/expect.in | 34 +++++++++++++++++++++++ tests/f_sit_bad_vblocks/script | 45 +++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 tests/f_sit_bad_vblocks/README create mode 100644 tests/f_sit_bad_vblocks/expect.in create mode 100644 tests/f_sit_bad_vblocks/script
tests/f_sit_bad_vblocks/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject vblocks in the sit entry of the blkaddr by subtracting 1 +5. fsck fixed the vblocks
tests/f_sit_bad_vblocks/expect.in new file +34 -0
@@ -0,0 +1,34 @@ +Info: Force to fix corruption +[ASSERT] (check_block_count:x) --> Wrong SIT valid blocks: segno=_SEGNO_, 511 vs. 512 +Info: checkpoint state = x : nat_bits crc compacted_summary unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_sit_bad_vblocks/script new file +45 -0
45 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 16/24 tests: add fsck testcase of fixing sit entry valid_map
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_sit_bad_valid_map/README | 5 +++ tests/f_sit_bad_valid_map/expect.in | 35 ++++++++++++++++++++ tests/f_sit_bad_valid_map/script | 50 +++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 tests/f_sit_bad_valid_map/README create mode 100644 tests/f_sit_bad_valid_map/expect.in create mode 100644 tests/f_sit_bad_valid_map/script
tests/f_sit_bad_valid_map/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject bitmap in the sit entry of the blkaddr by clearing its bit +5. fsck fixes the bitmap
tests/f_sit_bad_valid_map/expect.in new file +35 -0
@@ -0,0 +1,35 @@ +Info: Force to fix corruption +[ASSERT] (check_block_count:x) --> Wrong SIT valid blocks: segno=_SEGNO_, 512 vs. 511 +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (fsck_chk_data_blk:x) --> SIT bitmap is 0x0. blk_addr[_BLKADDR_] + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Fail] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_sit_bad_valid_map/script new file +50 -0
50 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 17/24 tests: add fsck testcase of fixing sum entry nid
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_ssa_bad_nid/README | 5 ++++ tests/f_ssa_bad_nid/expect.in | 34 +++++++++++++++++++++++++++ tests/f_ssa_bad_nid/script | 44 +++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/f_ssa_bad_nid/README create mode 100644 tests/f_ssa_bad_nid/expect.in create mode 100644 tests/f_ssa_bad_nid/script
tests/f_ssa_bad_nid/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject nid in the ssa entry of the blkaddr with an unused nid +5. fsck fixes the ssa entry
tests/f_ssa_bad_nid/expect.in new file +34 -0
@@ -0,0 +1,34 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (is_valid_ssa_data_blk: x) --> Set data summary _SEGNO_ -> [_INO_] [0x0] [_OFS_IN_NODE_] + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_ssa_bad_nid/script new file +44 -0
44 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 18/24 tests: add fsck testcase of fixing sum footer type
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_ssa_bad_type/README | 5 +++++ tests/f_ssa_bad_type/expect.in | 34 +++++++++++++++++++++++++++++ tests/f_ssa_bad_type/script | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 tests/f_ssa_bad_type/README create mode 100644 tests/f_ssa_bad_type/expect.in create mode 100644 tests/f_ssa_bad_type/script
tests/f_ssa_bad_type/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject footer entry_type in the summary block of the blkaddr and change it to NODE +5. fsck fixes the footer
tests/f_ssa_bad_type/expect.in new file +34 -0
@@ -0,0 +1,34 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (is_valid_ssa_data_blk: x) --> Summary footer indicates a data segment: _SEGNO_ + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_ssa_bad_type/script new file +39 -0
@@ -0,0 +1,39 @@ +#!/bin/sh + +DESC="ssa block footer with invalid type" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 +make_f2fs >> $LOG 2>&1 + +mkdir $TESTDIR/mntdir +safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot mount f2fs image" + exit +fi +dd if=/dev/zero of=$TESTDIR/mntdir/testfile bs=4K count=513 status=none +ino=`stat -c "%i" $TESTDIR/mntdir/testfile` +safe_umount $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot umount f2fs image" + exit +fi +rm -rf $TESTDIR/mntdir + +$DUMP $DUMP_OPTS -i $ino $META >> $LOG 2>&1 +blkaddr=`$DUMP $DUMP_OPTS -i $ino $META | grep "\[0x100\]" | sed 's/i_addr\[0x100\].*: \([0-9]*\)\]$/\1/g'` +echo "ino:$ino blkaddr:$blkaddr" >> $LOG + +$INJECT --ssa --blk $blkaddr --mb entry_type --val 1 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -f $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +segno=`get_segno $blkaddr` +SEGNO=`printf "0x%x" $segno` +sed "s/_SEGNO_/$SEGNO/g" $TESTDIR/expect.in > $TESTDIR/expect + +check_result +cleanup post >> $LOG 2>&1
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 19/24 tests: add fsck testcase of fixing sum entry ofs_in_node
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_ssa_bad_ofs_in_node/README | 5 +++ tests/f_ssa_bad_ofs_in_node/expect.in | 34 +++++++++++++++++++++ tests/f_ssa_bad_ofs_in_node/script | 44 +++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/f_ssa_bad_ofs_in_node/README create mode 100644 tests/f_ssa_bad_ofs_in_node/expect.in create mode 100644 tests/f_ssa_bad_ofs_in_node/script
tests/f_ssa_bad_ofs_in_node/README new file +5 -0
@@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject ofs_in_node in the ssa entry of the blkaddr +5. fsck fixes the ssa entry
tests/f_ssa_bad_ofs_in_node/expect.in new file +34 -0
@@ -0,0 +1,34 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (is_valid_ssa_data_blk: x) --> Set data summary _SEGNO_ -> [_INO_] [0x0] [_OFS_IN_NODE_] + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_ssa_bad_ofs_in_node/script new file +44 -0
44 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 20/24 tests: add fsck testcase of fixing invalid i_addr
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_inode_bad_iaddr/README | 6 ++++ tests/f_inode_bad_iaddr/expect.in | 38 ++++++++++++++++++++ tests/f_inode_bad_iaddr/script | 58 +++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 tests/f_inode_bad_iaddr/README create mode 100644 tests/f_inode_bad_iaddr/expect.in create mode 100644 tests/f_inode_bad_iaddr/script
tests/f_inode_bad_iaddr/README new file +6 -0
@@ -0,0 +1,6 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject i_addr[0x100] of the inode with an invalid value +5. fsck fixes the inode by nullify i_addr[0x100] +6. check if i_addr[0x100] is 0
tests/f_inode_bad_iaddr/expect.in new file +38 -0
@@ -0,0 +1,38 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (fsck_chk_data_blk:x) --> blkaddress is not valid. [0x12345] +[FIX] (fsck_chk_inode_blk:x) --> [_INO_] i_addr[256] = NULL_ADDR +[ASSERT] (fsck_chk_inode_blk:x) --> ino: _INO_ has wrong ext: [pgofs:_PGOFS_, blk:_BLK_, len:_LEN_] +[ASSERT] (fsck_chk_inode_blk:x) --> ino: _INO_ has i_blocks: 0x00000202, but has 0x201 blocks +[FIX] (fsck_chk_inode_blk:x) --> [0x4] i_blocks=0x00000202 -> 0x201 + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Fail] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Fail] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_inode_bad_iaddr/script new file +58 -0
58 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 21/24 tests: add fsck testcase of fixing dentry hash code
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_dentry_bad_hash/README | 8 ++++ tests/f_dentry_bad_hash/expect.in | 62 +++++++++++++++++++++++++++ tests/f_dentry_bad_hash/script | 71 +++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 tests/f_dentry_bad_hash/README create mode 100644 tests/f_dentry_bad_hash/expect.in create mode 100644 tests/f_dentry_bad_hash/script
tests/f_dentry_bad_hash/README new file +8 -0
@@ -0,0 +1,8 @@ +1. create f2fs image +2. mount f2fs +3. create an inline dentry directory, and create a file in it +4. inject dentry's hash_code of the file +5. fsck fixes the dentry's hash_code +6. create a non-inline dentry directory (by converting), and create a file in it +7. inject dentry's hash_code of the file +8. fsck fixes the dentry's hash_code
tests/f_dentry_bad_hash/expect.in new file +62 -0
62 lines not on this page · raw message
tests/f_dentry_bad_hash/script new file +71 -0
71 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 22/24 tests: add fsck testcase of fixing lost dots
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_dentry_lost_dots/README | 7 +++ tests/f_dentry_lost_dots/expect.in | 74 ++++++++++++++++++++++++++++++ tests/f_dentry_lost_dots/script | 46 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 tests/f_dentry_lost_dots/README create mode 100644 tests/f_dentry_lost_dots/expect.in create mode 100644 tests/f_dentry_lost_dots/script
tests/f_dentry_lost_dots/README new file +7 -0
@@ -0,0 +1,7 @@ +1. create f2fs image +2. mount f2fs +3. create a directory, and create a file in it +4. inject dot dentry in the directory by invalidating its valid bit +5. fsck fixes by adding a new dot dentry +6. inject dotdot dentry in the directory by invalidating its valid bit +7. fsck fixes by adding a new dotdot dentry
tests/f_dentry_lost_dots/expect.in new file +74 -0
74 lines not on this page · raw message
tests/f_dentry_lost_dots/script new file +46 -0
46 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 23/24 tests: add fsck testcase of fixing duplicated dots
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_dentry_dup_dots/README | 11 +++ tests/f_dentry_dup_dots/expect.in | 150 ++++++++++++++++++++++++++++++ tests/f_dentry_dup_dots/script | 58 ++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 tests/f_dentry_dup_dots/README create mode 100644 tests/f_dentry_dup_dots/expect.in create mode 100644 tests/f_dentry_dup_dots/script
tests/f_dentry_dup_dots/README new file +11 -0
@@ -0,0 +1,11 @@ +1. create f2fs image +2. mount f2fs +3. create a directory, and create a file in it +4. inject dot dentry in the directory by changing its d_ino to the dotdot's ino +5. fsck fixes the dot's d_ino +6. inject dotdot dentry in the directory by changing its d_ino to the dot's ino +7. fsck fixes the dotdot's d_ino +8. inject dot dentry in the directory by changing its filename to ".." +9. fsck fixes it by deleting duplicated dotdot dentry and adding a new dot dentry +10. inject dotdot dentry in the directory by changing its filename to the "." +11. fsck fixes it by deleting duplicated dot dentry and adding a new dotdot dentry
tests/f_dentry_dup_dots/expect.in new file +150 -0
150 lines not on this page · raw message
tests/f_dentry_dup_dots/script new file +58 -0
58 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
RFC PATCH 24/24 tests: add fsck testcase of fixing loop fsync dnodes
In reply to Sheng Yong via Linux-f2fs-devel--- tests/f_loop_fsync_dnodes/README | 39 +++++++++++++++++++++++++ tests/f_loop_fsync_dnodes/expect.in | 40 ++++++++++++++++++++++++++ tests/f_loop_fsync_dnodes/imgs.tar.gz | Bin 0 -> 173228 bytes tests/f_loop_fsync_dnodes/script | 16 +++++++++++ 4 files changed, 95 insertions(+) create mode 100644 tests/f_loop_fsync_dnodes/README create mode 100644 tests/f_loop_fsync_dnodes/expect.in create mode 100644 tests/f_loop_fsync_dnodes/imgs.tar.gz create mode 100644 tests/f_loop_fsync_dnodes/script
tests/f_loop_fsync_dnodes/README new file +39 -0
@@ -0,0 +1,39 @@ +1. prepare f2fs image with fsync dnodes: + + mkfs.f2fs $MKFS_OPTS $META + mkdir mntdir + mount $META mntdir -o mode=lfs + touch mntdir/testfile + f2fs_io checkpoint mntdir/testfile + fio -rw=write -bs=4k -direct=0 -size=4k -numjobs=10 -name=testfile -fsync_on_close=1 -group_reporting -stats=0 --output=/dev/null -directory=mntdir + f2fs_io shutdown 2 mntdir/testfile + umount mntdir + +2. inject fsync dnodes to generate a loop + + inject.f2fs --dry-run --cp 0 --mb next_blkaddr --idx 1 --val 0 $META + [inject_cp: 592] [ 0] blkaddr:0x1201 + [inject_cp: 592] [ 1] blkaddr:0x1202 + [inject_cp: 592] [ 2] blkaddr:0x1203 + [inject_cp: 592] [ 3] blkaddr:0x1204 + [inject_cp: 592] [ 4] blkaddr:0x1205 + [inject_cp: 592] [ 5] blkaddr:0x1206 + [inject_cp: 592] [ 6] blkaddr:0x1207 + [inject_cp: 592] [ 7] blkaddr:0x1208 + [inject_cp: 592] [ 8] blkaddr:0x1209 + [inject_cp: 592] [ 9] blkaddr:0x120a + inject.f2fs --cp 0 --mb next_blkaddr --idx 6 --val 0x1202 $META + [inject_cp: 592] [ 0] blkaddr:0x1201 + [inject_cp: 592] [ 1] blkaddr:0x1202 + [inject_cp: 592] [ 2] blkaddr:0x1203 + [inject_cp: 592] [ 3] blkaddr:0x1204 + [inject_cp: 592] [ 4] blkaddr:0x1205 + [inject_cp: 592] [ 5] blkaddr:0x1206 + [inject_cp: 592] [ 6] blkaddr:0x1207 + [inject_cp: 592] [ 7] blkaddr:0x1208 + [inject_cp: 592] [ 8] blkaddr:0x1209 + [inject_cp: 592] [ 9] blkaddr:0x120a + Info: inject next_blkaddr[6] of cp 2: 0x1207 -> 0x1202 + tar cf - meta.img | gzip -9 - > imgs.tar.gz + +3. fsck fixes fsync dnodes by breaking the loop
tests/f_loop_fsync_dnodes/expect.in new file +40 -0
@@ -0,0 +1,40 @@ +Info: Force to fix corruption +[ASSERT] (sanity_check_node_chain:x) --> detect looped node chain, blkaddr:4615 + +[FIX] (loop_node_chain_fix:x) --> Fix looped node chain on blkaddr 4615 + +Info: Write valid nat_bits in checkpoint +Info: checkpoint state = x : nat_bits crc compacted_summary sudden-power-off + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: write_checkpoint() cur_cp:x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits sudden-power-off + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +
tests/f_loop_fsync_dnodes/imgs.tar.gz new file binary +0 -0
tests/f_loop_fsync_dnodes/script new file +16 -0
@@ -0,0 +1,16 @@ +#!/bin/bash + +DESC="recover loop fsync dnodes" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 + +tar xf $TESTDIR/imgs.tar.gz -C $TESTDIR/../ + +$FSCK $FSCK_OPTS -f $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +check_result +cleanup post >> $LOG 2>&1
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel