fsck.gfs2: Handle duplicate reference to dinode blocks
PATCH 46/56 fsck.gfs2: Handle duplicate reference to dinode blocks
From 9ed45847f7ab17177fda10ba47e768e96ef0389d Mon Sep 17 00:00:00 2001
From: Bob Peterson <[email protected]>
Date: Fri, 19 Aug 2011 08:50:07 -0500
Subject: [PATCH 46/56] fsck.gfs2: Handle duplicate reference to dinode blocks
The fsck.gfs2 tool was not properly handling cases where dinode blocks were referenced by other dinodes as another type. For example, if some dinode wrongly thought that another dinode was one of its metadata blocks or data blocks. This patch fixes that situation by introducing a new "ref_is_inode" duplicate reference type. The only thing that should ever reference a dinode is a directory, and that's a special case. Any other reference is wrong and should be removed. This patch takes care of those situations.
The patch also moves the code that marks dinodes as their proper type to a new function in util.c called set_ip_blockmap. That allows duplicate processing to set the proper type in the blockmap in cases where the invalid reference was found first (before the dinode itself was encountered). It also removes the redundant "reftype_str" array of descriptions in favor of a central one already in util.c called "reftypes".
rhbz#675723
--- gfs2/fsck/fsck.h | 11 +++++--- gfs2/fsck/pass1.c | 50 +++--------------------------------- gfs2/fsck/pass1b.c | 57 +++++++++++++++++++++++++---------------- gfs2/fsck/util.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++- gfs2/fsck/util.h | 3 +- 5 files changed, 119 insertions(+), 73 deletions(-)
gfs2/fsck/fsck.h +7 -4
@@ -61,10 +61,13 @@ struct duptree { };enum dup_ref_type { - ref_as_data =0 , - ref_as_meta =1 , - ref_as_ea =2 , - ref_types =3 + ref_as_data =0 ,/* dinode references this block as a data block */ + ref_as_meta =1 ,/* dinode references this block as a metadata block */ + ref_as_ea =2 ,/* dinode references this block as an extended attr */ + ref_is_inode=3 ,/* The reference is itself a dinode. In other words, +it's a dinode, not pointed to as data or +metadata */ + ref_types =4 , };struct inode_with_dups {
gfs2/fsck/pass1.c +5 -45
68 lines not on this page · raw message
gfs2/fsck/pass1b.c +35 -22
107 lines not on this page · raw message
gfs2/fsck/util.c +70 -1
82 lines not on this page · raw message
gfs2/fsck/util.h +2 -1
@@ -21,7 +21,7 @@ extern struct inode_with_dups *find_dup_ref_inode(struct duptree *dt, struct gfs2_inode *ip);extern void dup_listent_delete (struct inode_with_dups *id); -extern const char *reftypes[3 ]; +extern const char *reftypes[ref_types +1 ];static inline uint8_t block_type (uint64_t bblock) {
@@ -170,4 +170,5 @@ extern struct gfs2_bmap *gfs2_bmap_create(struct gfs2_sbd *sdp, uint64_t size,extern void *gfs2_bmap_destroy (struct gfs2_sbd *sdp,struct gfs2_bmap *il);extern int gfs2_blockmap_set (struct gfs2_bmap *il,uint64_t block,enum gfs2_mark_block mark); +extern int set_ip_blockmap (struct gfs2_inode *ip,int instree);#endif /* __UTIL_H__ */
Signature · 1 line
1.7.4.4