Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=c201ff82ff…
Commit: c201ff82ff58a1e04212badce010e00bd1def140
Parent: 4a1e4d8c2a9ab5eff3f3f54364c2d482a9e783c8
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Tue Mar 15 15:44:07 2016 -0400
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon May 9 10:48:39 2016 -0500
fsck.gfs2: Move reprocess code to pass1
Since all the passes after pass1 no longer care about the blockmap,
we only need to keep the blockmap in sync with the bitmap in pass1.
Therefore, we can safely move the "reprocess_inode" stuff to pass1.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/metawalk.c | 107 --------------------------------------------------
gfs2/fsck/metawalk.h | 1 -
gfs2/fsck/pass1.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 107 insertions(+), 108 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index cbc73e9..7a77dc9 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1910,110 +1910,3 @@ int delete_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
return delete_block_if_notdup(ip, block, NULL, _("extended attribute"),
NULL, private);
}
-
-static int alloc_metalist(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h, int *is_valid,
- int *was_duplicate, void *private)
-{
- int q;
- const char *desc = (const char *)private;
-
- /* No need to range_check here--if it was added, it's in range. */
- /* We can't check the bitmap here because this function is called
- after the bitmap has been set but before the blockmap has. */
- *is_valid = 1;
- *was_duplicate = 0;
- *bh = bread(ip->i_sbd, block);
- q = bitmap_type(ip->i_sbd, block);
- if (q == GFS2_BLKST_FREE) {
- log_debug(_("%s reference to new metadata block "
- "%lld (0x%llx) is now marked as indirect.\n"),
- desc, (unsigned long long)block,
- (unsigned long long)block);
- gfs2_blockmap_set(bl, block, ip->i_sbd->gfs1 ?
- GFS2_BLKST_DINODE : GFS2_BLKST_USED);
- }
- return meta_is_good;
-}
-
-static int alloc_data(struct gfs2_inode *ip, uint64_t metablock,
- uint64_t block, void *private,
- struct gfs2_buffer_head *bh, uint64_t *ptr)
-{
- int q;
- const char *desc = (const char *)private;
-
- /* No need to range_check here--if it was added, it's in range. */
- /* We can't check the bitmap here because this function is called
- after the bitmap has been set but before the blockmap has. */
- q = bitmap_type(ip->i_sbd, block);
- if (q == GFS2_BLKST_FREE) {
- log_debug(_("%s reference to new data block "
- "%lld (0x%llx) is now marked as data.\n"),
- desc, (unsigned long long)block,
- (unsigned long long)block);
- gfs2_blockmap_set(bl, block, GFS2_BLKST_USED);
- }
- return 0;
-}
-
-static int alloc_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
-{
- int q;
-
- /* No need to range_check here--if it was added, it's in range. */
- /* We can't check the bitmap here because this function is called
- after the bitmap has been set but before the blockmap has. */
- q = bitmap_type(ip->i_sbd, block);
- if (q == GFS2_BLKST_FREE)
- fsck_blockmap_set(ip, block, _("newly allocated leaf"),
- ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE :
- GFS2_BLKST_USED);
- return 0;
-}
-
-struct metawalk_fxns alloc_fxns = {
- .private = NULL,
- .check_leaf = alloc_leaf,
- .check_metalist = alloc_metalist,
- .check_data = alloc_data,
- .check_eattr_indir = NULL,
- .check_eattr_leaf = NULL,
- .check_dentry = NULL,
- .check_eattr_entry = NULL,
- .check_eattr_extentry = NULL,
- .finish_eattr_indir = NULL,
-};
-
-/*
- * reprocess_inode - fixes the blockmap to match the bitmap due to an
- * unexpected block allocation via libgfs2.
- *
- * The problem we're trying to overcome here is when a new block must be
- * added to a dinode because of a write. This will happen when lost+found
- * needs a new indirect block for its hash table. In that case, the write
- * causes a new block to be assigned in the bitmap but that block is not yet
- * accurately reflected in the fsck blockmap. We need to compensate here.
- *
- * We can't really use fsck_blockmap_set here because the new block
- * was already allocated by libgfs2 and therefore it took care of
- * the rgrp free space variable. fsck_blockmap_set adjusts the free space
- * in the rgrp according to the change, which has already been done.
- * So it's only our blockmap that now disagrees with the rgrp bitmap, so we
- * need to fix only that.
- */
-void reprocess_inode(struct gfs2_inode *ip, const char *desc)
-{
- int error;
-
- alloc_fxns.private = (void *)desc;
- log_info( _("%s inode %llu (0x%llx) had blocks added; reprocessing "
- "its metadata tree at height=%d.\n"), desc,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- ip->i_di.di_height);
- error = check_metatree(ip, &alloc_fxns);
- if (error)
- log_err( _("Error %d reprocessing the %s metadata tree.\n"),
- error, desc);
-}
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 6d6c3ff..d505945 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -54,7 +54,6 @@ extern int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
const char *caller, int line);
extern int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk,
int error_on_dinode, int new_blockmap_state);
-extern void reprocess_inode(struct gfs2_inode *ip, const char *desc);
extern struct duptree *dupfind(uint64_t block);
extern struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp,
uint64_t block);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 8d68028..d12e03e 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1180,6 +1180,113 @@ static int set_ip_blockmap(struct gfs2_inode *ip)
return 0;
}
+static int alloc_metalist(struct gfs2_inode *ip, uint64_t block,
+ struct gfs2_buffer_head **bh, int h, int *is_valid,
+ int *was_duplicate, void *private)
+{
+ int q;
+ const char *desc = (const char *)private;
+
+ /* No need to range_check here--if it was added, it's in range. */
+ /* We can't check the bitmap here because this function is called
+ after the bitmap has been set but before the blockmap has. */
+ *is_valid = 1;
+ *was_duplicate = 0;
+ *bh = bread(ip->i_sbd, block);
+ q = bitmap_type(ip->i_sbd, block);
+ if (q == GFS2_BLKST_FREE) {
+ log_debug(_("%s reference to new metadata block "
+ "%lld (0x%llx) is now marked as indirect.\n"),
+ desc, (unsigned long long)block,
+ (unsigned long long)block);
+ gfs2_blockmap_set(bl, block, ip->i_sbd->gfs1 ?
+ GFS2_BLKST_DINODE : GFS2_BLKST_USED);
+ }
+ return meta_is_good;
+}
+
+static int alloc_data(struct gfs2_inode *ip, uint64_t metablock,
+ uint64_t block, void *private,
+ struct gfs2_buffer_head *bh, uint64_t *ptr)
+{
+ int q;
+ const char *desc = (const char *)private;
+
+ /* No need to range_check here--if it was added, it's in range. */
+ /* We can't check the bitmap here because this function is called
+ after the bitmap has been set but before the blockmap has. */
+ q = bitmap_type(ip->i_sbd, block);
+ if (q == GFS2_BLKST_FREE) {
+ log_debug(_("%s reference to new data block "
+ "%lld (0x%llx) is now marked as data.\n"),
+ desc, (unsigned long long)block,
+ (unsigned long long)block);
+ gfs2_blockmap_set(bl, block, GFS2_BLKST_USED);
+ }
+ return 0;
+}
+
+static int alloc_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
+{
+ int q;
+
+ /* No need to range_check here--if it was added, it's in range. */
+ /* We can't check the bitmap here because this function is called
+ after the bitmap has been set but before the blockmap has. */
+ q = bitmap_type(ip->i_sbd, block);
+ if (q == GFS2_BLKST_FREE)
+ fsck_blockmap_set(ip, block, _("newly allocated leaf"),
+ ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE :
+ GFS2_BLKST_USED);
+ return 0;
+}
+
+struct metawalk_fxns alloc_fxns = {
+ .private = NULL,
+ .check_leaf = alloc_leaf,
+ .check_metalist = alloc_metalist,
+ .check_data = alloc_data,
+ .check_eattr_indir = NULL,
+ .check_eattr_leaf = NULL,
+ .check_dentry = NULL,
+ .check_eattr_entry = NULL,
+ .check_eattr_extentry = NULL,
+ .finish_eattr_indir = NULL,
+};
+
+/*
+ * reprocess_inode - fixes the blockmap to match the bitmap due to an
+ * unexpected block allocation via libgfs2.
+ *
+ * The problem we're trying to overcome here is when a new block must be
+ * added to a dinode because of a write. This will happen when lost+found
+ * needs a new indirect block for its hash table. In that case, the write
+ * causes a new block to be assigned in the bitmap but that block is not yet
+ * accurately reflected in the fsck blockmap. We need to compensate here.
+ *
+ * We can't really use fsck_blockmap_set here because the new block
+ * was already allocated by libgfs2 and therefore it took care of
+ * the rgrp free space variable. fsck_blockmap_set adjusts the free space
+ * in the rgrp according to the change, which has already been done.
+ * So it's only our blockmap that now disagrees with the rgrp bitmap, so we
+ * need to fix only that.
+ */
+static void reprocess_inode(struct gfs2_inode *ip, const char *desc)
+{
+ int error;
+
+ alloc_fxns.private = (void *)desc;
+ log_info( _("%s inode %llu (0x%llx) had blocks added; reprocessing "
+ "its metadata tree at height=%d.\n"), desc,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ ip->i_di.di_height);
+ error = check_metatree(ip, &alloc_fxns);
+ if (error)
+ log_err( _("Error %d reprocessing the %s metadata tree.\n"),
+ error, desc);
+}
+
/*
* handle_ip - process an incore structure representing a dinode.
*/
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=2744575f37…
Commit: 2744575f37549f1b73343e9196297b6a88f43bf9
Parent: 3552c6b9eb77eabcd59fa22172f5209df0e6f900
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Mar 14 19:43:33 2016 -0400
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon May 9 10:48:39 2016 -0500
fsck.gfs2: Remove unneeded parameter instree from set_ip_blockmap
This patch removes parameter instree from function set_ip_blockmap,
since it is only called in one place.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/pass1.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index e09bcb4..e1653f1 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1143,11 +1143,9 @@ struct metawalk_fxns eattr_undo_fxns = {
};
/* set_ip_blockmap - set the blockmap for a dinode
*
- * instree: Set to 1 if directories should be inserted into the directory tree
- * otherwise 0.
* returns: 0 if no error, -EINVAL if dinode has a bad mode, -EPERM on error
*/
-static int set_ip_blockmap(struct gfs2_inode *ip, int instree)
+static int set_ip_blockmap(struct gfs2_inode *ip)
{
uint64_t block = ip->i_bh->b_blocknr;
uint32_t mode;
@@ -1184,7 +1182,7 @@ static int set_ip_blockmap(struct gfs2_inode *ip, int instree)
return -EINVAL;
}
if (fsck_blockmap_set(ip, block, ty, GFS2_BLKST_DINODE) ||
- (mode == S_IFDIR && instree && !dirtree_insert(ip->i_di.di_num))) {
+ (mode == S_IFDIR && !dirtree_insert(ip->i_di.di_num))) {
stack;
return -EPERM;
}
@@ -1220,7 +1218,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
return 0;
}
- error = set_ip_blockmap(ip, 1);
+ error = set_ip_blockmap(ip);
if (error == -EINVAL) {
/* We found a dinode that has an invalid mode. At this point
set_ip_blockmap returned an error, which means it never
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=5c3f62df97…
Commit: 5c3f62df970cefe922318223d7862389ec8e85e7
Parent: e352d9865ee230de00c12a03ba0d6a3b812abbda
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Wed Mar 23 12:26:30 2016 -0400
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Apr 15 08:57:43 2016 -0400
fsck.gfs2: pass1b shouldn't complain about non-bitmap blocks
One of the previous patches switched pass1b to stop using the
blockmap and start using the bitmap. One major difference between
them is that the blockmap has a value (0 - 3) for every block on
the device, whereas the bitmap has a value (0 - 3) for every block
in the file system. It does not have a value for blocks that are
on the device but aren't in the file system, such as the superblock
and the blocks preceding it, the blocks reserved for the rgrps
and their respective bitmaps.
That means the block_map function returned 0 for non-fs blocks,
but the bitmap function returned -1 (meaning invalid block).
The result was that pass1b complained about every non-fs block.
This patch makes pass1b check the return code from function
bitmap_type() and if it's a negative number, it skips over it.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/pass1b.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index a7b3e42..ee636fe 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -885,7 +885,7 @@ int pass1b(struct gfs2_sbd *sdp)
}
q = bitmap_type(sdp, i);
- if (q == GFS2_BLKST_FREE || q == GFS2_BLKST_USED)
+ if (q == GFS2_BLKST_FREE || q == GFS2_BLKST_USED || q < 0)
continue;
if (q == GFS2_BLKST_UNLINKED)
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=e352d9865e…
Commit: e352d9865ee230de00c12a03ba0d6a3b812abbda
Parent: 54d819d3eb39e2a2b4a519dc6d9366baf4efdd39
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Tue Mar 29 14:42:05 2016 -0400
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Apr 15 08:57:35 2016 -0400
fsck.gfs2: Use di_entries to determine if lost+found was created
Before this patch, function make_sure_lf_exists compared the bitmap
to the blockmap to determine if the lost+found directory was created.
Since we're phasing out the blockmap, and only want to use the
bitmap, we need an alternative. This patch changes it to check the
number of directory entries in the root directory has increased.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/lost_n_found.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 0b57d21..cd847f8 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -99,14 +99,15 @@ static void add_dotdot(struct gfs2_inode *ip)
void make_sure_lf_exists(struct gfs2_inode *ip)
{
- int q;
struct dir_info *di;
struct gfs2_sbd *sdp = ip->i_sbd;
uint32_t mode;
+ int root_entries;
if (lf_dip)
return;
+ root_entries = sdp->md.rooti->i_di.di_entries;
log_info( _("Locating/Creating lost+found directory\n"));
/* if this is gfs1, we have to trick createi into using
@@ -131,8 +132,7 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
them in sync so that pass4 can detect and fix any descrepancies. */
set_di_nlink(sdp->md.rooti);
- q = bitmap_type(sdp, lf_dip->i_di.di_num.no_addr);
- if (q != GFS2_BLKST_DINODE) {
+ if (sdp->md.rooti->i_di.di_entries > root_entries) {
lf_was_created = 1;
/* This is a new lost+found directory, so set its block type
and increment link counts for the directories */