libgfs2: Fix a thinko in write_journal()
PATCH 1/2 libgfs2: Fix a thinko in write_journal()
The crc is stored in lh_crc, not lh_hash.
Signed-off-by Andrew Price <[email protected]>
--- gfs2/libgfs2/structures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
gfs2/libgfs2/structures.c +1 -1
@@ -238,7 +238,7 @@ int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)#ifdef GFS2_HAS_LH_V2 ((struct gfs2_log_header *)bh->b_data)->lh_addr =cpu_to_be64 (bh->b_blocknr); hash =lgfs2_log_header_crc (bh->b_data, bsize); - ((struct gfs2_log_header *)bh->b_data)->lh_hash =cpu_to_be32 (hash); + ((struct gfs2_log_header *)bh->b_data)->lh_crc =cpu_to_be32 (hash);#endif bmodified (bh);brelse (bh);
Signature · 1 line
2.14.3
PATCH 2/2 gfs2-utils tests: Add a fsck.gfs2 test for rebuilding journals
Requires a tweak to gfs2_edit to allow journal dinode fields to be modified by keyword.
Signed-off-by Andrew Price <[email protected]>
--- gfs2/edit/hexedit.c | 5 +++-- tests/fsck.at | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-)
gfs2/edit/hexedit.c +3 -2
@@ -2486,8 +2486,9 @@ static void process_parameters(int argc, char *argv[], int pass) }if (termlines ||strchr (argv[i],'/' ))/* if print or slash */ continue ; - -if (!strncmp (argv[i],"journal" ,7 ) &&isdigit (argv[i][7 ])) { + +if (!strncmp (argv[i],"journal" ,7 ) &&isdigit (argv[i][7 ]) && +strcmp (argv[i+1 ],"field" )) {int blk =0 ;if (i < argc -1 &&isdigit (argv[i +1 ][0 ])) {
tests/fsck.at +9 -0
@@ -45,3 +45,12 @@ AT_SETUP([Fix bad rindex entry #1]) AT_KEYWORDS(fsck.gfs2 fsck) GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-i 1]) AT_CLEANUP + +AT_SETUP([Rebuild bad journal]) +AT_KEYWORDS(fsck.gfs2 fsck) +GFS_TGT_REGEN +AT_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], 0, [ignore], [ignore]) +AT_CHECK([gfs2_edit -p journal0 field di_header.mh_magic 0 $GFS_TGT], 0, [ignore], [ignore]) +AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore]) +AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore]) +AT_CLEANUP
Signature · 1 line
2.14.3