cluster: RHEL56 - fsck.gfs2 truncates directories with more than 100, 000 entries
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 6f1e7d39673a0c8d145d923204f7daa4dd56a0aa
Parent: 18d6d10d0ba6f939b22e65978f0c85233dba1fa1
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Sep 17 11:25:09 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Sep 17 13:50:06 2010 -0500
fsck.gfs2 truncates directories with more than 100,000 entries
This patch allows fsck.gfs2 to properly process "continuation
leaf blocks" in directories. It also fixes a memory leak.
rhbz#629010
---
gfs2/fsck/link.c | 8 ++
gfs2/fsck/lost_n_found.c | 18 ++++-
gfs2/fsck/metawalk.c | 171 ++++++++++++++++++++++------------------------
gfs2/fsck/pass1.c | 15 +++-
gfs2/libgfs2/fs_ops.c | 14 +++--
5 files changed, 124 insertions(+), 102 deletions(-)
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 525836d..0503f42 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -81,6 +81,14 @@ int decrement_link(uint64_t inode_no, uint64_t referenced_from,
/* If the list has entries, look for one that matches
* inode_no */
if(ii) {
+ if (!ii->counted_links) {
+ log_debug( _("Directory %lld (0x%llx)'s link to "
+ " %"PRIu64" (0x%" PRIx64 ") via %s is zero!\n"),
+ (unsigned long long)referenced_from,
+ (unsigned long long)referenced_from,
+ inode_no, inode_no, why);
+ return 0;
+ }
ii->counted_links--;
log_debug( _("Directory %lld (0x%llx) decremented counted "
"links to %u for %"PRIu64" (0x%" PRIx64 ") "
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 7d65fe0..b89b25a 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -121,10 +121,20 @@ int add_inode_to_lf(struct gfs2_inode *ip){
ip->i_di.di_num.no_addr,
_(".. unlinked, moving to lost+found"));
dip = fsck_load_inode(sdp, di->dotdot_parent);
- dip->i_di.di_nlink--;
- log_debug(_("Decrementing its links to %d\n"),
- dip->i_di.di_nlink);
- bmodified(dip->i_bh);
+ if (dip->i_di.di_nlink > 0) {
+ dip->i_di.di_nlink--;
+ log_debug(_("Decrementing its links to %d\n"),
+ dip->i_di.di_nlink);
+ bmodified(dip->i_bh);
+ } else if (!dip->i_di.di_nlink) {
+ log_debug(_("Its link count is zero.\n"));
+ } else {
+ log_debug(_("Its link count is %d! "
+ "Changing it to 0.\n"),
+ dip->i_di.di_nlink);
+ dip->i_di.di_nlink = 0;
+ bmodified(dip->i_bh);
+ }
fsck_inode_put(&dip);
di = NULL;
} else
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 330dace..3a4e462 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -539,6 +539,68 @@ static int fix_leaf_pointers(struct gfs2_inode *dip, int *lindex,
return 0;
}
+/* check_num_ptrs - check a previously processed leaf's pointer count */
+static int check_num_ptrs(struct gfs2_inode *ip, uint64_t old_leaf,
+ int *ref_count, int *exp_count, int *lindex,
+ struct gfs2_leaf *oldleaf)
+{
+ int factor = 0, divisor = *ref_count, multiple = 1, error = 0;
+ struct gfs2_buffer_head *lbh;
+
+ /* Check to see if the number of pointers we found is a power of 2.
+ It needs to be and if it's not we need to fix it.*/
+ while (divisor > 1) {
+ factor++;
+ divisor /= 2;
+ multiple = multiple << 1;
+ }
+ if (*ref_count != multiple) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "invalid number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: %u, "
+ "which is not a factor of 2.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory inode was not fixed.\n"));
+ return 1;
+ }
+ error = fix_leaf_pointers(ip, lindex, *ref_count, multiple);
+ if (error)
+ return error;
+ *ref_count = multiple;
+ log_err( _("Directory inode was fixed.\n"));
+ }
+ /* Check to see if the counted number of leaf pointers is what we
+ expect. */
+ if (*ref_count != *exp_count) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "incorrect number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: "
+ "%u, Expected: %u\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count, *exp_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory leaf was not fixed.\n"));
+ return 1;
+ }
+ lbh = bread(ip->i_sbd, old_leaf);
+ gfs2_leaf_in(oldleaf, lbh);
+ log_err( _("Leaf depth was %d, changed to %d\n"),
+ oldleaf->lf_depth, ip->i_di.di_depth - factor);
+ oldleaf->lf_depth = ip->i_di.di_depth - factor;
+ gfs2_leaf_out(oldleaf, lbh);
+ brelse(lbh);
+ *exp_count = *ref_count;
+ log_err( _("Directory leaf was fixed.\n"));
+ }
+ return 0;
+}
+
/* Checks exhash directory entries */
static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
@@ -595,76 +657,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
ref_count++;
continue;
}
- if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
- int factor = 0, divisor = ref_count, multiple = 1;
-
- /* Check to see if the number of pointers we found is
- a power of 2. It needs to be and if it's not we
- need to fix it.*/
- while (divisor > 1) {
- factor++;
- divisor /= 2;
- multiple = multiple << 1;
- }
- if (ref_count != multiple) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "invalid number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: %u, "
- "which is not a factor of 2.\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory inode was not "
- "fixed.\n"));
- return 1;
- }
- error = fix_leaf_pointers(ip, &lindex,
- ref_count, multiple);
+
+ do {
+ if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
+ error = check_num_ptrs(ip, old_leaf,
+ &ref_count, &exp_count,
+ &lindex, &oldleaf);
if (error)
return error;
- ref_count = multiple;
- log_err( _("Directory inode was fixed.\n"));
- }
- /* Check to see if the counted number of leaf pointers
- is what we expect. */
- if (ref_count != exp_count) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "incorrect number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: "
- "%u, Expected: %u\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count, exp_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory leaf was not "
- "fixed.\n"));
- return 1;
- }
- lbh = bread(sbp, old_leaf);
- gfs2_leaf_in(&oldleaf, lbh);
- log_err( _("Leaf depth was %d, changed to "
- "%d\n"), oldleaf.lf_depth,
- ip->i_di.di_depth - factor);
- oldleaf.lf_depth = ip->i_di.di_depth - factor;
- gfs2_leaf_out(&oldleaf, lbh);
- brelse(lbh);
- exp_count = ref_count;
- log_err( _("Directory leaf was fixed.\n"));
}
- }
- ref_count = 1;
-
- count = 0;
- do {
+ ref_count = 1;
+ count = 0;
if (fsck_abort)
break;
/* Make sure the block number is in range. */
@@ -697,10 +700,9 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
break;
}
gfs2_leaf_in(&leaf, lbh);
- if(pass->check_leaf) {
+ if(pass->check_leaf)
error = pass->check_leaf(ip, leaf_no, lbh,
pass->private);
- }
/*
* Early versions of GFS2 had an endianess bug in the
@@ -735,22 +737,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
leaf depth %u\n"),
exp_count, ip->i_di.di_depth, leaf.lf_depth);*/
- if(pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
+ if (pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
error = check_entries(ip, lbh, DIR_EXHASH,
&count, pass);
-
- /* Since the buffer possibly got
- * updated directly, release it now,
- * and grab it again later if we need it. */
-
- brelse(lbh);
-
if(error < 0) {
stack;
+ brelse(lbh);
return -1;
}
if(count != leaf.lf_entries) {
+ brelse(lbh);
lbh = bread(sbp, leaf_no);
gfs2_leaf_in(&leaf, lbh);
@@ -772,21 +769,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
log_warn( _("Leaf entry count updated\n"));
} else
log_err( _("Leaf entry count left in inconsistant state\n"));
- brelse(lbh);
}
- /* FIXME: Need to get entry count and
- * compare it against leaf->lf_entries */
- break; /* not a chain; go back to outer loop */
- } else {
- brelse(lbh);
- if(!leaf.lf_next)
- break;
- leaf_no = leaf.lf_next;
- log_debug( _("Leaf chain detected.\n"));
}
+ brelse(lbh);
+ old_leaf = leaf_no;
+ memcpy(&oldleaf, &leaf, sizeof(oldleaf));
+ if (!leaf.lf_next)
+ break;
+ leaf_no = leaf.lf_next;
+ log_debug( _("Leaf chain 0x%llx detected.\n"),
+ (unsigned long long)leaf_no);
} while(1); /* while we have chained leaf blocks */
- old_leaf = leaf_no;
- memcpy(&oldleaf, &leaf, sizeof(oldleaf));
} /* for every leaf block */
return 0;
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index f584aab..3bdcf60 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -280,13 +280,16 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count++;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("indirect"),
gfs2_indir_blk);
@@ -338,13 +341,17 @@ static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count--;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
+ *bh = NULL;
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("bad indirect"),
gfs2_block_free);
return 0;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 4beb3c4..2b1fa46 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -787,6 +787,13 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
uint16_t cur_rec_len, prev_rec_len;
bmodified(bh);
+ if (gfs2_check_meta(bh, GFS2_METATYPE_LF) == 0) {
+ struct gfs2_leaf *lf = (struct gfs2_leaf *)bh->b_data;
+
+ lf->lf_entries = be16_to_cpu(lf->lf_entries) - 1;
+ lf->lf_entries = cpu_to_be16(lf->lf_entries);
+ }
+
if (dip->i_di.di_entries) {
bmodified(dip->i_bh);
dip->i_di.di_entries--;
@@ -905,9 +912,6 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
dirent2_del(dip, obh, prev, dent);
- oleaf->lf_entries = be16_to_cpu(oleaf->lf_entries) - 1;
- oleaf->lf_entries = cpu_to_be16(oleaf->lf_entries);
-
if (!prev)
prev = dent;
@@ -1719,8 +1723,8 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
/* Set the bitmap type for inode to free space: */
gfs2_set_bitmap(sdp, ip->i_di.di_num.no_addr, GFS2_BLKST_FREE);
inode_put(&ip);
- /* inode_put deallocated the extra block used by the disk inode, */
- /* so adjust it in the superblock struct */
+ /* inode_put deallocated the extra block used by the disk inode, */
+ /* so adjust it in the superblock struct */
sdp->blks_alloced--;
/* Now we have to adjust the rg freespace count and inode count: */
rgd = gfs2_blk2rgrpd(sdp, diblock);
13 years, 8 months
cluster: RHEL6 - fsck.gfs2 truncates directories with more than 100, 000 entries
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: f230a400c7b99d9cc95e19ab6fdca9fcd64811ee
Parent: 87fdbcaeea44fc14264695a4c2164f8c3cec9a84
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Sep 17 13:42:50 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Sep 17 13:45:46 2010 -0500
fsck.gfs2 truncates directories with more than 100,000 entries
This patch allows fsck.gfs2 to properly process "continuation
leaf blocks" in directories. It also fixes a memory leak.
rhbz#628013
---
gfs2/fsck/link.c | 8 ++
gfs2/fsck/lost_n_found.c | 18 ++++-
gfs2/fsck/metawalk.c | 172 ++++++++++++++++++++++------------------------
gfs2/fsck/pass1.c | 15 +++-
gfs2/libgfs2/fs_ops.c | 12 ++-
5 files changed, 123 insertions(+), 102 deletions(-)
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 5bb3ae2..ce8eb52 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -68,6 +68,14 @@ int decrement_link(uint64_t inode_no, uint64_t referenced_from,
/* If the list has entries, look for one that matches
* inode_no */
if(ii) {
+ if (!ii->counted_links) {
+ log_debug( _("Directory %lld (0x%llx)'s link to "
+ " %"PRIu64" (0x%" PRIx64 ") via %s is zero!\n"),
+ (unsigned long long)referenced_from,
+ (unsigned long long)referenced_from,
+ inode_no, inode_no, why);
+ return 0;
+ }
ii->counted_links--;
log_debug( _("Directory %lld (0x%llx) decremented counted "
"links to %u for %"PRIu64" (0x%" PRIx64 ") "
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 4a3a926..3256bdc 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -108,10 +108,20 @@ int add_inode_to_lf(struct gfs2_inode *ip){
ip->i_di.di_num.no_addr,
_(".. unlinked, moving to lost+found"));
dip = fsck_load_inode(sdp, di->dotdot_parent);
- dip->i_di.di_nlink--;
- log_debug(_("Decrementing its links to %d\n"),
- dip->i_di.di_nlink);
- bmodified(dip->i_bh);
+ if (dip->i_di.di_nlink > 0) {
+ dip->i_di.di_nlink--;
+ log_debug(_("Decrementing its links to %d\n"),
+ dip->i_di.di_nlink);
+ bmodified(dip->i_bh);
+ } else if (!dip->i_di.di_nlink) {
+ log_debug(_("Its link count is zero.\n"));
+ } else {
+ log_debug(_("Its link count is %d! "
+ "Changing it to 0.\n"),
+ dip->i_di.di_nlink);
+ dip->i_di.di_nlink = 0;
+ bmodified(dip->i_bh);
+ }
fsck_inode_put(&dip);
di = NULL;
} else
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index ef1b6b5..2151ced 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -377,7 +377,6 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
- /* FIXME: Do something about this */
log_err( _("Directory entry with inode number of "
"zero in leaf %llu (0x%llx) of "
"directory %llu (0x%llx)!\n"),
@@ -526,6 +525,68 @@ static int fix_leaf_pointers(struct gfs2_inode *dip, int *lindex,
return 0;
}
+/* check_num_ptrs - check a previously processed leaf's pointer count */
+static int check_num_ptrs(struct gfs2_inode *ip, uint64_t old_leaf,
+ int *ref_count, int *exp_count, int *lindex,
+ struct gfs2_leaf *oldleaf)
+{
+ int factor = 0, divisor = *ref_count, multiple = 1, error = 0;
+ struct gfs2_buffer_head *lbh;
+
+ /* Check to see if the number of pointers we found is a power of 2.
+ It needs to be and if it's not we need to fix it.*/
+ while (divisor > 1) {
+ factor++;
+ divisor /= 2;
+ multiple = multiple << 1;
+ }
+ if (*ref_count != multiple) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "invalid number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: %u, "
+ "which is not a factor of 2.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory inode was not fixed.\n"));
+ return 1;
+ }
+ error = fix_leaf_pointers(ip, lindex, *ref_count, multiple);
+ if (error)
+ return error;
+ *ref_count = multiple;
+ log_err( _("Directory inode was fixed.\n"));
+ }
+ /* Check to see if the counted number of leaf pointers is what we
+ expect. */
+ if (*ref_count != *exp_count) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "incorrect number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: "
+ "%u, Expected: %u\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count, *exp_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory leaf was not fixed.\n"));
+ return 1;
+ }
+ lbh = bread(ip->i_sbd, old_leaf);
+ gfs2_leaf_in(oldleaf, lbh);
+ log_err( _("Leaf depth was %d, changed to %d\n"),
+ oldleaf->lf_depth, ip->i_di.di_depth - factor);
+ oldleaf->lf_depth = ip->i_di.di_depth - factor;
+ gfs2_leaf_out(oldleaf, lbh);
+ brelse(lbh);
+ *exp_count = *ref_count;
+ log_err( _("Directory leaf was fixed.\n"));
+ }
+ return 0;
+}
+
/* Checks exhash directory entries */
static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
@@ -582,76 +643,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
ref_count++;
continue;
}
- if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
- int factor = 0, divisor = ref_count, multiple = 1;
-
- /* Check to see if the number of pointers we found is
- a power of 2. It needs to be and if it's not we
- need to fix it.*/
- while (divisor > 1) {
- factor++;
- divisor /= 2;
- multiple = multiple << 1;
- }
- if (ref_count != multiple) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "invalid number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: %u, "
- "which is not a factor of 2.\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory inode was not "
- "fixed.\n"));
- return 1;
- }
- error = fix_leaf_pointers(ip, &lindex,
- ref_count, multiple);
+
+ do {
+ if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
+ error = check_num_ptrs(ip, old_leaf,
+ &ref_count, &exp_count,
+ &lindex, &oldleaf);
if (error)
return error;
- ref_count = multiple;
- log_err( _("Directory inode was fixed.\n"));
- }
- /* Check to see if the counted number of leaf pointers
- is what we expect. */
- if (ref_count != exp_count) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "incorrect number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: "
- "%u, Expected: %u\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count, exp_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory leaf was not "
- "fixed.\n"));
- return 1;
- }
- lbh = bread(sbp, old_leaf);
- gfs2_leaf_in(&oldleaf, lbh);
- log_err( _("Leaf depth was %d, changed to "
- "%d\n"), oldleaf.lf_depth,
- ip->i_di.di_depth - factor);
- oldleaf.lf_depth = ip->i_di.di_depth - factor;
- gfs2_leaf_out(&oldleaf, lbh);
- brelse(lbh);
- exp_count = ref_count;
- log_err( _("Directory leaf was fixed.\n"));
}
- }
- ref_count = 1;
-
- count = 0;
- do {
+ ref_count = 1;
+ count = 0;
if (fsck_abort)
break;
/* Make sure the block number is in range. */
@@ -684,10 +686,9 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
break;
}
gfs2_leaf_in(&leaf, lbh);
- if(pass->check_leaf) {
+ if(pass->check_leaf)
error = pass->check_leaf(ip, leaf_no, lbh,
pass->private);
- }
/*
* Early versions of GFS2 had an endianess bug in the
@@ -722,22 +723,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
leaf depth %u\n"),
exp_count, ip->i_di.di_depth, leaf.lf_depth);*/
- if(pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
+ if (pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
error = check_entries(ip, lbh, DIR_EXHASH,
&count, pass);
-
- /* Since the buffer possibly got
- * updated directly, release it now,
- * and grab it again later if we need it. */
-
- brelse(lbh);
-
if(error < 0) {
stack;
+ brelse(lbh);
return -1;
}
if(count != leaf.lf_entries) {
+ brelse(lbh);
lbh = bread(sbp, leaf_no);
gfs2_leaf_in(&leaf, lbh);
@@ -759,21 +755,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
log_warn( _("Leaf entry count updated\n"));
} else
log_err( _("Leaf entry count left in inconsistant state\n"));
- brelse(lbh);
}
- /* FIXME: Need to get entry count and
- * compare it against leaf->lf_entries */
- break; /* not a chain; go back to outer loop */
- } else {
- brelse(lbh);
- if(!leaf.lf_next)
- break;
- leaf_no = leaf.lf_next;
- log_debug( _("Leaf chain detected.\n"));
}
+ brelse(lbh);
+ old_leaf = leaf_no;
+ memcpy(&oldleaf, &leaf, sizeof(oldleaf));
+ if (!leaf.lf_next)
+ break;
+ leaf_no = leaf.lf_next;
+ log_debug( _("Leaf chain 0x%llx detected.\n"),
+ (unsigned long long)leaf_no);
} while(1); /* while we have chained leaf blocks */
- old_leaf = leaf_no;
- memcpy(&oldleaf, &leaf, sizeof(oldleaf));
} /* for every leaf block */
return 0;
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 17b23df..bc500fd 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -265,13 +265,16 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count++;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("indirect"),
gfs2_indir_blk);
@@ -323,13 +326,17 @@ static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count--;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
+ *bh = NULL;
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("bad indirect"),
gfs2_block_free);
return 0;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index e0a1681..4019894 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -790,6 +790,13 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
uint16_t cur_rec_len, prev_rec_len;
bmodified(bh);
+ if (gfs2_check_meta(bh, GFS2_METATYPE_LF) == 0) {
+ struct gfs2_leaf *lf = (struct gfs2_leaf *)bh->b_data;
+
+ lf->lf_entries = be16_to_cpu(lf->lf_entries) - 1;
+ lf->lf_entries = cpu_to_be16(lf->lf_entries);
+ }
+
if (dip->i_di.di_entries) {
bmodified(dip->i_bh);
dip->i_di.di_entries--;
@@ -908,9 +915,6 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
dirent2_del(dip, obh, prev, dent);
- oleaf->lf_entries = be16_to_cpu(oleaf->lf_entries) - 1;
- oleaf->lf_entries = cpu_to_be16(oleaf->lf_entries);
-
if (!prev)
prev = dent;
@@ -1726,7 +1730,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
/* Set the bitmap type for inode to free space: */
gfs2_set_bitmap(sdp, ip->i_di.di_num.no_addr, GFS2_BLKST_FREE);
inode_put(&ip);
- /* inode_put deallocated the extra block used by the dist inode, */
+ /* inode_put deallocated the extra block used by the disk inode, */
/* so adjust it in the superblock struct */
sdp->blks_alloced--;
/* Now we have to adjust the rg freespace count and inode count: */
13 years, 8 months
cluster: STABLE3 - fsck.gfs2 truncates directories with more than 100, 000 entries
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 806743e2063b7f0db573c784eb6a7fc14378e93c
Parent: c0d48a75764c8595362a34fa8c1d271587bf4cc9
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Sep 17 13:42:50 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Sep 17 13:44:21 2010 -0500
fsck.gfs2 truncates directories with more than 100,000 entries
This patch allows fsck.gfs2 to properly process "continuation
leaf blocks" in directories. It also fixes a memory leak.
rhbz#628013
---
gfs2/fsck/link.c | 8 ++
gfs2/fsck/lost_n_found.c | 18 ++++-
gfs2/fsck/metawalk.c | 172 ++++++++++++++++++++++------------------------
gfs2/fsck/pass1.c | 15 +++-
gfs2/libgfs2/fs_ops.c | 12 ++-
5 files changed, 123 insertions(+), 102 deletions(-)
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 5bb3ae2..ce8eb52 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -68,6 +68,14 @@ int decrement_link(uint64_t inode_no, uint64_t referenced_from,
/* If the list has entries, look for one that matches
* inode_no */
if(ii) {
+ if (!ii->counted_links) {
+ log_debug( _("Directory %lld (0x%llx)'s link to "
+ " %"PRIu64" (0x%" PRIx64 ") via %s is zero!\n"),
+ (unsigned long long)referenced_from,
+ (unsigned long long)referenced_from,
+ inode_no, inode_no, why);
+ return 0;
+ }
ii->counted_links--;
log_debug( _("Directory %lld (0x%llx) decremented counted "
"links to %u for %"PRIu64" (0x%" PRIx64 ") "
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 4a3a926..3256bdc 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -108,10 +108,20 @@ int add_inode_to_lf(struct gfs2_inode *ip){
ip->i_di.di_num.no_addr,
_(".. unlinked, moving to lost+found"));
dip = fsck_load_inode(sdp, di->dotdot_parent);
- dip->i_di.di_nlink--;
- log_debug(_("Decrementing its links to %d\n"),
- dip->i_di.di_nlink);
- bmodified(dip->i_bh);
+ if (dip->i_di.di_nlink > 0) {
+ dip->i_di.di_nlink--;
+ log_debug(_("Decrementing its links to %d\n"),
+ dip->i_di.di_nlink);
+ bmodified(dip->i_bh);
+ } else if (!dip->i_di.di_nlink) {
+ log_debug(_("Its link count is zero.\n"));
+ } else {
+ log_debug(_("Its link count is %d! "
+ "Changing it to 0.\n"),
+ dip->i_di.di_nlink);
+ dip->i_di.di_nlink = 0;
+ bmodified(dip->i_bh);
+ }
fsck_inode_put(&dip);
di = NULL;
} else
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index ef1b6b5..2151ced 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -377,7 +377,6 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
- /* FIXME: Do something about this */
log_err( _("Directory entry with inode number of "
"zero in leaf %llu (0x%llx) of "
"directory %llu (0x%llx)!\n"),
@@ -526,6 +525,68 @@ static int fix_leaf_pointers(struct gfs2_inode *dip, int *lindex,
return 0;
}
+/* check_num_ptrs - check a previously processed leaf's pointer count */
+static int check_num_ptrs(struct gfs2_inode *ip, uint64_t old_leaf,
+ int *ref_count, int *exp_count, int *lindex,
+ struct gfs2_leaf *oldleaf)
+{
+ int factor = 0, divisor = *ref_count, multiple = 1, error = 0;
+ struct gfs2_buffer_head *lbh;
+
+ /* Check to see if the number of pointers we found is a power of 2.
+ It needs to be and if it's not we need to fix it.*/
+ while (divisor > 1) {
+ factor++;
+ divisor /= 2;
+ multiple = multiple << 1;
+ }
+ if (*ref_count != multiple) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "invalid number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: %u, "
+ "which is not a factor of 2.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory inode was not fixed.\n"));
+ return 1;
+ }
+ error = fix_leaf_pointers(ip, lindex, *ref_count, multiple);
+ if (error)
+ return error;
+ *ref_count = multiple;
+ log_err( _("Directory inode was fixed.\n"));
+ }
+ /* Check to see if the counted number of leaf pointers is what we
+ expect. */
+ if (*ref_count != *exp_count) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "incorrect number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: "
+ "%u, Expected: %u\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count, *exp_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory leaf was not fixed.\n"));
+ return 1;
+ }
+ lbh = bread(ip->i_sbd, old_leaf);
+ gfs2_leaf_in(oldleaf, lbh);
+ log_err( _("Leaf depth was %d, changed to %d\n"),
+ oldleaf->lf_depth, ip->i_di.di_depth - factor);
+ oldleaf->lf_depth = ip->i_di.di_depth - factor;
+ gfs2_leaf_out(oldleaf, lbh);
+ brelse(lbh);
+ *exp_count = *ref_count;
+ log_err( _("Directory leaf was fixed.\n"));
+ }
+ return 0;
+}
+
/* Checks exhash directory entries */
static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
@@ -582,76 +643,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
ref_count++;
continue;
}
- if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
- int factor = 0, divisor = ref_count, multiple = 1;
-
- /* Check to see if the number of pointers we found is
- a power of 2. It needs to be and if it's not we
- need to fix it.*/
- while (divisor > 1) {
- factor++;
- divisor /= 2;
- multiple = multiple << 1;
- }
- if (ref_count != multiple) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "invalid number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: %u, "
- "which is not a factor of 2.\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory inode was not "
- "fixed.\n"));
- return 1;
- }
- error = fix_leaf_pointers(ip, &lindex,
- ref_count, multiple);
+
+ do {
+ if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
+ error = check_num_ptrs(ip, old_leaf,
+ &ref_count, &exp_count,
+ &lindex, &oldleaf);
if (error)
return error;
- ref_count = multiple;
- log_err( _("Directory inode was fixed.\n"));
- }
- /* Check to see if the counted number of leaf pointers
- is what we expect. */
- if (ref_count != exp_count) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "incorrect number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: "
- "%u, Expected: %u\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count, exp_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory leaf was not "
- "fixed.\n"));
- return 1;
- }
- lbh = bread(sbp, old_leaf);
- gfs2_leaf_in(&oldleaf, lbh);
- log_err( _("Leaf depth was %d, changed to "
- "%d\n"), oldleaf.lf_depth,
- ip->i_di.di_depth - factor);
- oldleaf.lf_depth = ip->i_di.di_depth - factor;
- gfs2_leaf_out(&oldleaf, lbh);
- brelse(lbh);
- exp_count = ref_count;
- log_err( _("Directory leaf was fixed.\n"));
}
- }
- ref_count = 1;
-
- count = 0;
- do {
+ ref_count = 1;
+ count = 0;
if (fsck_abort)
break;
/* Make sure the block number is in range. */
@@ -684,10 +686,9 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
break;
}
gfs2_leaf_in(&leaf, lbh);
- if(pass->check_leaf) {
+ if(pass->check_leaf)
error = pass->check_leaf(ip, leaf_no, lbh,
pass->private);
- }
/*
* Early versions of GFS2 had an endianess bug in the
@@ -722,22 +723,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
leaf depth %u\n"),
exp_count, ip->i_di.di_depth, leaf.lf_depth);*/
- if(pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
+ if (pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
error = check_entries(ip, lbh, DIR_EXHASH,
&count, pass);
-
- /* Since the buffer possibly got
- * updated directly, release it now,
- * and grab it again later if we need it. */
-
- brelse(lbh);
-
if(error < 0) {
stack;
+ brelse(lbh);
return -1;
}
if(count != leaf.lf_entries) {
+ brelse(lbh);
lbh = bread(sbp, leaf_no);
gfs2_leaf_in(&leaf, lbh);
@@ -759,21 +755,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
log_warn( _("Leaf entry count updated\n"));
} else
log_err( _("Leaf entry count left in inconsistant state\n"));
- brelse(lbh);
}
- /* FIXME: Need to get entry count and
- * compare it against leaf->lf_entries */
- break; /* not a chain; go back to outer loop */
- } else {
- brelse(lbh);
- if(!leaf.lf_next)
- break;
- leaf_no = leaf.lf_next;
- log_debug( _("Leaf chain detected.\n"));
}
+ brelse(lbh);
+ old_leaf = leaf_no;
+ memcpy(&oldleaf, &leaf, sizeof(oldleaf));
+ if (!leaf.lf_next)
+ break;
+ leaf_no = leaf.lf_next;
+ log_debug( _("Leaf chain 0x%llx detected.\n"),
+ (unsigned long long)leaf_no);
} while(1); /* while we have chained leaf blocks */
- old_leaf = leaf_no;
- memcpy(&oldleaf, &leaf, sizeof(oldleaf));
} /* for every leaf block */
return 0;
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 17b23df..bc500fd 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -265,13 +265,16 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count++;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("indirect"),
gfs2_indir_blk);
@@ -323,13 +326,17 @@ static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count--;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
+ *bh = NULL;
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("bad indirect"),
gfs2_block_free);
return 0;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index e0a1681..4019894 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -790,6 +790,13 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
uint16_t cur_rec_len, prev_rec_len;
bmodified(bh);
+ if (gfs2_check_meta(bh, GFS2_METATYPE_LF) == 0) {
+ struct gfs2_leaf *lf = (struct gfs2_leaf *)bh->b_data;
+
+ lf->lf_entries = be16_to_cpu(lf->lf_entries) - 1;
+ lf->lf_entries = cpu_to_be16(lf->lf_entries);
+ }
+
if (dip->i_di.di_entries) {
bmodified(dip->i_bh);
dip->i_di.di_entries--;
@@ -908,9 +915,6 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
dirent2_del(dip, obh, prev, dent);
- oleaf->lf_entries = be16_to_cpu(oleaf->lf_entries) - 1;
- oleaf->lf_entries = cpu_to_be16(oleaf->lf_entries);
-
if (!prev)
prev = dent;
@@ -1726,7 +1730,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
/* Set the bitmap type for inode to free space: */
gfs2_set_bitmap(sdp, ip->i_di.di_num.no_addr, GFS2_BLKST_FREE);
inode_put(&ip);
- /* inode_put deallocated the extra block used by the dist inode, */
+ /* inode_put deallocated the extra block used by the disk inode, */
/* so adjust it in the superblock struct */
sdp->blks_alloced--;
/* Now we have to adjust the rg freespace count and inode count: */
13 years, 8 months
gfs2-utils: master - fsck.gfs2 truncates directories with more than 100, 000 entries
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 8ef7be619e783c92bf75cbf4dfb8e7a05399c399
Parent: 85ab1eeb40508dcc0f0a5c5ae63ca71dfb08c173
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Sep 17 13:38:03 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Sep 17 13:38:03 2010 -0500
fsck.gfs2 truncates directories with more than 100,000 entries
This patch allows fsck.gfs2 to properly process "continuation
leaf blocks" in directories. It also fixes a memory leak.
rhbz#628013
---
gfs2/fsck/link.c | 8 ++
gfs2/fsck/lost_n_found.c | 18 ++++-
gfs2/fsck/metawalk.c | 172 ++++++++++++++++++++++------------------------
gfs2/fsck/pass1.c | 15 +++-
gfs2/libgfs2/fs_ops.c | 12 ++-
5 files changed, 123 insertions(+), 102 deletions(-)
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 9b518a8..213a643 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -70,6 +70,14 @@ int decrement_link(uint64_t inode_no, uint64_t referenced_from,
/* If the list has entries, look for one that matches
* inode_no */
if(ii) {
+ if (!ii->counted_links) {
+ log_debug( _("Directory %lld (0x%llx)'s link to "
+ " %"PRIu64" (0x%" PRIx64 ") via %s is zero!\n"),
+ (unsigned long long)referenced_from,
+ (unsigned long long)referenced_from,
+ inode_no, inode_no, why);
+ return 0;
+ }
ii->counted_links--;
log_debug( _("Directory %lld (0x%llx) decremented counted "
"links to %u for %"PRIu64" (0x%" PRIx64 ") "
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 991c289..2fcae00 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -110,10 +110,20 @@ int add_inode_to_lf(struct gfs2_inode *ip){
ip->i_di.di_num.no_addr,
_(".. unlinked, moving to lost+found"));
dip = fsck_load_inode(sdp, di->dotdot_parent);
- dip->i_di.di_nlink--;
- log_debug(_("Decrementing its links to %d\n"),
- dip->i_di.di_nlink);
- bmodified(dip->i_bh);
+ if (dip->i_di.di_nlink > 0) {
+ dip->i_di.di_nlink--;
+ log_debug(_("Decrementing its links to %d\n"),
+ dip->i_di.di_nlink);
+ bmodified(dip->i_bh);
+ } else if (!dip->i_di.di_nlink) {
+ log_debug(_("Its link count is zero.\n"));
+ } else {
+ log_debug(_("Its link count is %d! "
+ "Changing it to 0.\n"),
+ dip->i_di.di_nlink);
+ dip->i_di.di_nlink = 0;
+ bmodified(dip->i_bh);
+ }
fsck_inode_put(&dip);
di = NULL;
} else
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 5cb531d..421a645 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -379,7 +379,6 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
- /* FIXME: Do something about this */
log_err( _("Directory entry with inode number of "
"zero in leaf %llu (0x%llx) of "
"directory %llu (0x%llx)!\n"),
@@ -528,6 +527,68 @@ static int fix_leaf_pointers(struct gfs2_inode *dip, int *lindex,
return 0;
}
+/* check_num_ptrs - check a previously processed leaf's pointer count */
+static int check_num_ptrs(struct gfs2_inode *ip, uint64_t old_leaf,
+ int *ref_count, int *exp_count, int *lindex,
+ struct gfs2_leaf *oldleaf)
+{
+ int factor = 0, divisor = *ref_count, multiple = 1, error = 0;
+ struct gfs2_buffer_head *lbh;
+
+ /* Check to see if the number of pointers we found is a power of 2.
+ It needs to be and if it's not we need to fix it.*/
+ while (divisor > 1) {
+ factor++;
+ divisor /= 2;
+ multiple = multiple << 1;
+ }
+ if (*ref_count != multiple) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "invalid number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: %u, "
+ "which is not a factor of 2.\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory inode was not fixed.\n"));
+ return 1;
+ }
+ error = fix_leaf_pointers(ip, lindex, *ref_count, multiple);
+ if (error)
+ return error;
+ *ref_count = multiple;
+ log_err( _("Directory inode was fixed.\n"));
+ }
+ /* Check to see if the counted number of leaf pointers is what we
+ expect. */
+ if (*ref_count != *exp_count) {
+ log_err( _("Directory #%llu (0x%llx) has an "
+ "incorrect number of pointers to "
+ "leaf #%llu (0x%llx)\n\tFound: "
+ "%u, Expected: %u\n"),
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)old_leaf,
+ (unsigned long long)old_leaf, *ref_count, *exp_count);
+ if (!query( _("Attempt to fix it? (y/n) "))) {
+ log_err( _("Directory leaf was not fixed.\n"));
+ return 1;
+ }
+ lbh = bread(ip->i_sbd, old_leaf);
+ gfs2_leaf_in(oldleaf, lbh);
+ log_err( _("Leaf depth was %d, changed to %d\n"),
+ oldleaf->lf_depth, ip->i_di.di_depth - factor);
+ oldleaf->lf_depth = ip->i_di.di_depth - factor;
+ gfs2_leaf_out(oldleaf, lbh);
+ brelse(lbh);
+ *exp_count = *ref_count;
+ log_err( _("Directory leaf was fixed.\n"));
+ }
+ return 0;
+}
+
/* Checks exhash directory entries */
static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
@@ -584,76 +645,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
ref_count++;
continue;
}
- if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
- int factor = 0, divisor = ref_count, multiple = 1;
-
- /* Check to see if the number of pointers we found is
- a power of 2. It needs to be and if it's not we
- need to fix it.*/
- while (divisor > 1) {
- factor++;
- divisor /= 2;
- multiple = multiple << 1;
- }
- if (ref_count != multiple) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "invalid number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: %u, "
- "which is not a factor of 2.\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory inode was not "
- "fixed.\n"));
- return 1;
- }
- error = fix_leaf_pointers(ip, &lindex,
- ref_count, multiple);
+
+ do {
+ if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
+ error = check_num_ptrs(ip, old_leaf,
+ &ref_count, &exp_count,
+ &lindex, &oldleaf);
if (error)
return error;
- ref_count = multiple;
- log_err( _("Directory inode was fixed.\n"));
- }
- /* Check to see if the counted number of leaf pointers
- is what we expect. */
- if (ref_count != exp_count) {
- log_err( _("Directory #%llu (0x%llx) has an "
- "incorrect number of pointers to "
- "leaf #%llu (0x%llx)\n\tFound: "
- "%u, Expected: %u\n"),
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)
- ip->i_di.di_num.no_addr,
- (unsigned long long)old_leaf,
- (unsigned long long)old_leaf,
- ref_count, exp_count);
- if (!query( _("Attempt to fix it? (y/n) "))) {
- log_err( _("Directory leaf was not "
- "fixed.\n"));
- return 1;
- }
- lbh = bread(sbp, old_leaf);
- gfs2_leaf_in(&oldleaf, lbh);
- log_err( _("Leaf depth was %d, changed to "
- "%d\n"), oldleaf.lf_depth,
- ip->i_di.di_depth - factor);
- oldleaf.lf_depth = ip->i_di.di_depth - factor;
- gfs2_leaf_out(&oldleaf, lbh);
- brelse(lbh);
- exp_count = ref_count;
- log_err( _("Directory leaf was fixed.\n"));
}
- }
- ref_count = 1;
-
- count = 0;
- do {
+ ref_count = 1;
+ count = 0;
if (fsck_abort)
break;
/* Make sure the block number is in range. */
@@ -686,10 +688,9 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
break;
}
gfs2_leaf_in(&leaf, lbh);
- if(pass->check_leaf) {
+ if(pass->check_leaf)
error = pass->check_leaf(ip, leaf_no, lbh,
pass->private);
- }
/*
* Early versions of GFS2 had an endianess bug in the
@@ -724,22 +725,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
leaf depth %u\n"),
exp_count, ip->i_di.di_depth, leaf.lf_depth);*/
- if(pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
+ if (pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
error = check_entries(ip, lbh, DIR_EXHASH,
&count, pass);
-
- /* Since the buffer possibly got
- * updated directly, release it now,
- * and grab it again later if we need it. */
-
- brelse(lbh);
-
if(error < 0) {
stack;
+ brelse(lbh);
return -1;
}
if(count != leaf.lf_entries) {
+ brelse(lbh);
lbh = bread(sbp, leaf_no);
gfs2_leaf_in(&leaf, lbh);
@@ -761,21 +757,17 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
log_warn( _("Leaf entry count updated\n"));
} else
log_err( _("Leaf entry count left in inconsistant state\n"));
- brelse(lbh);
}
- /* FIXME: Need to get entry count and
- * compare it against leaf->lf_entries */
- break; /* not a chain; go back to outer loop */
- } else {
- brelse(lbh);
- if(!leaf.lf_next)
- break;
- leaf_no = leaf.lf_next;
- log_debug( _("Leaf chain detected.\n"));
}
+ brelse(lbh);
+ old_leaf = leaf_no;
+ memcpy(&oldleaf, &leaf, sizeof(oldleaf));
+ if (!leaf.lf_next)
+ break;
+ leaf_no = leaf.lf_next;
+ log_debug( _("Leaf chain 0x%llx detected.\n"),
+ (unsigned long long)leaf_no);
} while(1); /* while we have chained leaf blocks */
- old_leaf = leaf_no;
- memcpy(&oldleaf, &leaf, sizeof(oldleaf));
} /* for every leaf block */
return 0;
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 6936d02..0aea38c 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -267,13 +267,16 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count++;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("indirect"),
gfs2_indir_blk);
@@ -325,13 +328,17 @@ static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
return 1;
}
brelse(nbh);
+ nbh = NULL;
} else /* blk check ok */
*bh = nbh;
bc->indir_count--;
- if (found_dup)
+ if (found_dup) {
+ if (nbh)
+ brelse(nbh);
+ *bh = NULL;
return 1; /* don't process the metadata again */
- else
+ } else
fsck_blockmap_set(ip, block, _("bad indirect"),
gfs2_block_free);
return 0;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 633eb5a..e0b3e7c 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -792,6 +792,13 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
uint16_t cur_rec_len, prev_rec_len;
bmodified(bh);
+ if (gfs2_check_meta(bh, GFS2_METATYPE_LF) == 0) {
+ struct gfs2_leaf *lf = (struct gfs2_leaf *)bh->b_data;
+
+ lf->lf_entries = be16_to_cpu(lf->lf_entries) - 1;
+ lf->lf_entries = cpu_to_be16(lf->lf_entries);
+ }
+
if (dip->i_di.di_entries) {
bmodified(dip->i_bh);
dip->i_di.di_entries--;
@@ -910,9 +917,6 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
dirent2_del(dip, obh, prev, dent);
- oleaf->lf_entries = be16_to_cpu(oleaf->lf_entries) - 1;
- oleaf->lf_entries = cpu_to_be16(oleaf->lf_entries);
-
if (!prev)
prev = dent;
@@ -1728,7 +1732,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
/* Set the bitmap type for inode to free space: */
gfs2_set_bitmap(sdp, ip->i_di.di_num.no_addr, GFS2_BLKST_FREE);
inode_put(&ip);
- /* inode_put deallocated the extra block used by the dist inode, */
+ /* inode_put deallocated the extra block used by the disk inode, */
/* so adjust it in the superblock struct */
sdp->blks_alloced--;
/* Now we have to adjust the rg freespace count and inode count: */
13 years, 8 months
cluster: RHEL56 - fence-agents: Add power-wait to fence_ipmilan
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 18d6d10d0ba6f939b22e65978f0c85233dba1fa1
Parent: 6616b37f2a68650112926c06973955dcd9fa4aa4
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Thu Sep 16 14:23:51 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Sep 16 14:27:08 2010 -0400
fence-agents: Add power-wait to fence_ipmilan
Resolves: rhbz#548575
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
fence/agents/ipmilan/ipmilan.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 163f0c6..016a0fb 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -54,6 +54,7 @@ do { \
#define ST_CYCLE 4
#define DEFAULT_TIMEOUT 20
+#define DEFAULT_POWER_WAIT 2
#define DEFAULT_METHOD "onoff"
@@ -112,6 +113,7 @@ struct ipmi {
int i_verbose;
int i_lanplus;
int i_timeout;
+ int i_power_wait;
int i_cipher;
};
@@ -478,7 +480,7 @@ ipmi_off(struct ipmi *ipmi)
if (ret != 0)
return ret;
- sleep(2);
+ sleep(ipmi->i_power_wait);
--retries;
ret = ipmi_op(ipmi, ST_STATUS, power_status);
@@ -583,6 +585,7 @@ ipmi_destroy(struct ipmi *i)
static struct ipmi *
ipmi_init(struct ipmi *i, char *host, char *authtype,
char *user, char *password, int lanplus, int verbose,int timeout,
+ int power_wait,
int cipher)
{
const char *p;
@@ -655,6 +658,7 @@ ipmi_init(struct ipmi *i, char *host, char *authtype,
i->i_verbose = verbose;
i->i_lanplus = lanplus;
i->i_timeout = timeout;
+ i->i_power_wait = power_wait;
i->i_cipher = cipher;
return i;
@@ -941,6 +945,7 @@ get_options_stdin(char *ip, size_t iplen,
char *user, size_t userlen,
char *op, size_t oplen,
int *lanplus, int *verbose,int *timeout,
+ int *power_wait,
int *cipher, char *method, int methodlen,
char *delay, size_t delaylen)
{
@@ -1009,6 +1014,10 @@ get_options_stdin(char *ip, size_t iplen,
if ((sscanf(val,"%d",timeout)!=1) || *timeout<1) {
*timeout=DEFAULT_TIMEOUT;
}
+ } else if (!strcasecmp(name,"power-wait")) {
+ if ((sscanf(val,"%d",power_wait)!=1) || *power_wait<1) {
+ *power_wait=DEFAULT_POWER_WAIT;
+ }
} else if (!strcasecmp(name,"cipher")) {
if ((sscanf(val,"%d",cipher)!=1) || *cipher<0) {
*cipher=-1;
@@ -1078,6 +1087,7 @@ printf(" operation=<op> Same as -o\n");
printf(" action=<op> Same as -o\n");
printf(" delay=<seconds> Same as -f\n");
printf(" timeout=<timeout> Same as -t\n");
+printf(" power-wait=<time> Same as -T\n");
printf(" cipher=<cipher> Same as -C\n");
printf(" method=<method> Same as -M\n");
printf(" verbose Same as -v\n\n");
@@ -1146,6 +1156,7 @@ main(int argc, char **argv)
char *pname = basename(argv[0]);
struct ipmi *i;
int timeout=DEFAULT_TIMEOUT;
+ int down_sleep=DEFAULT_POWER_WAIT;
int cipher=-1;
int print_final_status=1;
int translated_ret = -1;
@@ -1162,7 +1173,7 @@ main(int argc, char **argv)
/*
Parse command line options if any were specified
*/
- while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:C:M:f:")) != EOF) {
+ while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:T:C:M:f:")) != EOF) {
switch(opt) {
case 'A':
/* Auth type */
@@ -1202,6 +1213,12 @@ main(int argc, char **argv)
fail_exit("Timeout option expects positive number parameter");
}
break;
+ case 'T':
+ /* Shutdown Sleep Time */
+ if ((sscanf(optarg,"%d",&down_sleep)!=1) || down_sleep<1) {
+ fail_exit("Shutdown time option expects positive number parameter");
+ }
+ break;
case 'C':
/* Ciphersuite */
if ((sscanf(optarg,"%d",&cipher)!=1) || cipher<0) {
@@ -1236,6 +1253,7 @@ main(int argc, char **argv)
pwd_script, sizeof(pwd_script),
user, sizeof(user),
op, sizeof(op), &lanplus, &verbose,&timeout,
+ &down_sleep,
&cipher, method, sizeof(method),
delay, sizeof(delay)) != 0)
return 1;
@@ -1316,7 +1334,7 @@ main(int argc, char **argv)
}
/* Ok, set up the IPMI struct */
- i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, cipher);
+ i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, down_sleep, cipher);
if (!i)
fail_exit("Failed to initialize\n");
13 years, 8 months
cluster: RHEL60 - Updating /proc/mounts and /etc/mtab with mount args for GFS2 fs
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c4d0ebcd261faa04ea6764b5c96dff27db9c0fd5
Parent: 6a73e92beebf62fe1a1da1284dcd56a028e4662f
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Sep 13 12:21:32 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Sep 16 09:34:02 2010 -0500
Updating /proc/mounts and /etc/mtab with mount args for GFS2 fs
This patch changes the way the gfs2 mount helper, mount.gfs2,
updates the /etc/mtab file. Before, it was copying the line
from /proc/mounts directly into /etc/mtab after a successful
mount. The problem is, that may be mapped to a different device
by the device-mapper layer, which meant it did not match the
device properly if a subsequent mount was done for the same device.
This patch uses the device specified on the mount.gfs2 command
line argument (which normally comes from the mount command), already
translated properly as it expects for subsequent mount attempts.
rhbz#632595
---
gfs2/mount/mount.gfs2.c | 1 +
gfs2/mount/mtab.c | 2 +-
gfs2/mount/util.c | 4 ++--
gfs2/mount/util.h | 1 +
4 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/gfs2/mount/mount.gfs2.c b/gfs2/mount/mount.gfs2.c
index 38ec9a1..d8e19a7 100644
--- a/gfs2/mount/mount.gfs2.c
+++ b/gfs2/mount/mount.gfs2.c
@@ -86,6 +86,7 @@ static void read_options(int argc, char **argv, struct mount_options *mo)
if (!real)
die("invalid device path \"%s\"\n", argv[optind]);
strncpy(mo->dev, real, PATH_MAX);
+ strncpy(mo->specified_dev, argv[optind], PATH_MAX);
free(real);
}
diff --git a/gfs2/mount/mtab.c b/gfs2/mount/mtab.c
index fe5c744..a43d04e 100644
--- a/gfs2/mount/mtab.c
+++ b/gfs2/mount/mtab.c
@@ -97,7 +97,7 @@ void add_mtab_entry(struct mount_options *mo)
return;
}
- fprintf(file, "%s", mo->proc_entry);
+ fprintf(file, "%s%s", mo->specified_dev, strchr(mo->proc_entry, ' '));
fclose(file);
diff --git a/gfs2/mount/util.c b/gfs2/mount/util.c
index bc26daf..5a1f999 100644
--- a/gfs2/mount/util.c
+++ b/gfs2/mount/util.c
@@ -209,7 +209,6 @@ static int mnt_unescape(char *dest, size_t len, const char *src)
{
unsigned i = 0, j = 0;
size_t srclen;
- int ret = -1;
srclen = strlen(src);
while (i < srclen) {
@@ -316,7 +315,8 @@ void read_proc_mounts(struct mount_options *mo)
strncpy(mo->proc_entry, save_line, PATH_MAX);
}
- log_debug("read_proc_mounts: device = \"%s\"", mo->dev);
+ log_debug("read_proc_mounts: device = \"%s\"", mo->specified_dev);
+ log_debug("read_proc_mounts: dm device = \"%s\"", mo->dev);
log_debug("read_proc_mounts: opts = \"%s\"", mo->opts);
}
diff --git a/gfs2/mount/util.h b/gfs2/mount/util.h
index 7b856ac..e866cd4 100644
--- a/gfs2/mount/util.h
+++ b/gfs2/mount/util.h
@@ -46,6 +46,7 @@ do { \
} while (0)
struct mount_options {
+ char specified_dev[PATH_MAX+1];
char dev[PATH_MAX+1];
char dir[PATH_MAX+1];
char opts[PATH_MAX+1];
13 years, 8 months
cluster: STABLE3 - Reported UUID from 'gfs2_edit -p sb' should be lower-case
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c0d48a75764c8595362a34fa8c1d271587bf4cc9
Parent: 3b7c1dafab865ebabf8bb686cfaa41b69a9a4ae5
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Sep 16 09:13:57 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Sep 16 09:13:57 2010 -0500
Reported UUID from 'gfs2_edit -p sb' should be lower-case
This patch changes the uuid output from uppercase to lowercase.
rhbz#632385
---
gfs2/libgfs2/ondisk.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 0d16c15..2902ba1 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -144,7 +144,7 @@ const char *str_uuid(const unsigned char *uuid)
memset(str, 0, sizeof(str));
ch = str;
for (i = 0; i < 16; i++) {
- sprintf(ch, "%02X", uuid[i]);
+ sprintf(ch, "%02x", uuid[i]);
ch += 2;
if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) {
*ch = '-';
13 years, 8 months
gfs2-utils: master - Reported UUID from 'gfs2_edit -p sb' should be lower-case
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 85ab1eeb40508dcc0f0a5c5ae63ca71dfb08c173
Parent: cbcad2164d2d04264f15e0e03c49790b6758fc4e
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Sep 16 09:17:42 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Sep 16 09:17:42 2010 -0500
Reported UUID from 'gfs2_edit -p sb' should be lower-case
This patch changes the uuid output from uppercase to lowercase.
rhbz#632385
---
gfs2/libgfs2/ondisk.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 58af15a..2290016 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -146,7 +146,7 @@ const char *str_uuid(const unsigned char *uuid)
memset(str, 0, sizeof(str));
ch = str;
for (i = 0; i < 16; i++) {
- sprintf(ch, "%02X", uuid[i]);
+ sprintf(ch, "%02x", uuid[i]);
ch += 2;
if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) {
*ch = '-';
13 years, 8 months
cluster: STABLE3 - resource-agents: Stop using '-' as 1st char of log messages
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 3b7c1dafab865ebabf8bb686cfaa41b69a9a4ae5
Parent: 988356d5a4df442cf294983cf9042a8d0c61e58d
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue Sep 14 10:44:51 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Sep 14 10:44:51 2010 -0400
resource-agents: Stop using '-' as 1st char of log messages
Resolves: rhbz#633856
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/lvm.sh | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/rgmanager/src/resources/lvm.sh b/rgmanager/src/resources/lvm.sh
index 7f174ca..e71460c 100644
--- a/rgmanager/src/resources/lvm.sh
+++ b/rgmanager/src/resources/lvm.sh
@@ -28,7 +28,7 @@ function ha_lvm_proper_setup_check
##
if ! lvm dumpconfig activation/volume_list >& /dev/null; then
ocf_log err "HA LVM: Improper setup detected"
- ocf_log err "- \"volume_list\" not specified in lvm.conf."
+ ocf_log err "* \"volume_list\" not specified in lvm.conf."
return $OCF_ERR_GENERIC
fi
@@ -38,7 +38,7 @@ function ha_lvm_proper_setup_check
##
if ! lvm dumpconfig activation/volume_list | grep $(local_node_name); then
ocf_log err "HA LVM: Improper setup detected"
- ocf_log err "- @$(local_node_name) missing from \"volume_list\" in lvm.conf"
+ ocf_log err "* @$(local_node_name) missing from \"volume_list\" in lvm.conf"
return $OCF_ERR_GENERIC
fi
@@ -49,7 +49,7 @@ function ha_lvm_proper_setup_check
##
if lvm dumpconfig activation/volume_list | grep "\"$OCF_RESKEY_vg_name\""; then
ocf_log err "HA LVM: Improper setup detected"
- ocf_log err "- $OCF_RESKEY_vg_name found in \"volume_list\" in lvm.conf"
+ ocf_log err "* $OCF_RESKEY_vg_name found in \"volume_list\" in lvm.conf"
return $OCF_ERR_GENERIC
fi
@@ -61,7 +61,7 @@ function ha_lvm_proper_setup_check
# Fixme: we might be able to perform a better check...
if [ "$(find /boot -name *.img -newer /etc/lvm/lvm.conf)" == "" ]; then
ocf_log err "HA LVM: Improper setup detected"
- ocf_log err "- initrd image needs to be newer than lvm.conf"
+ ocf_log err "* initrd image needs to be newer than lvm.conf"
return $OCF_ERR_GENERIC
fi
13 years, 8 months
cluster: RHEL6 - Updating /proc/mounts and /etc/mtab with mount args for GFS2 fs
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 87fdbcaeea44fc14264695a4c2164f8c3cec9a84
Parent: c38bc14a73ac6de7b8839f7eafc6ac6c6179e9be
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Sep 13 12:21:32 2010 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Sep 13 12:21:32 2010 -0500
Updating /proc/mounts and /etc/mtab with mount args for GFS2 fs
This patch changes the way the gfs2 mount helper, mount.gfs2,
updates the /etc/mtab file. Before, it was copying the line
from /proc/mounts directly into /etc/mtab after a successful
mount. The problem is, that may be mapped to a different device
by the device-mapper layer, which meant it did not match the
device properly if a subsequent mount was done for the same device.
This patch uses the device specified on the mount.gfs2 command
line argument (which normally comes from the mount command), already
translated properly as it expects for subsequent mount attempts.
rhbz#632595
---
gfs2/mount/mount.gfs2.c | 1 +
gfs2/mount/mtab.c | 2 +-
gfs2/mount/util.c | 4 ++--
gfs2/mount/util.h | 1 +
4 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/gfs2/mount/mount.gfs2.c b/gfs2/mount/mount.gfs2.c
index 38ec9a1..d8e19a7 100644
--- a/gfs2/mount/mount.gfs2.c
+++ b/gfs2/mount/mount.gfs2.c
@@ -86,6 +86,7 @@ static void read_options(int argc, char **argv, struct mount_options *mo)
if (!real)
die("invalid device path \"%s\"\n", argv[optind]);
strncpy(mo->dev, real, PATH_MAX);
+ strncpy(mo->specified_dev, argv[optind], PATH_MAX);
free(real);
}
diff --git a/gfs2/mount/mtab.c b/gfs2/mount/mtab.c
index fe5c744..a43d04e 100644
--- a/gfs2/mount/mtab.c
+++ b/gfs2/mount/mtab.c
@@ -97,7 +97,7 @@ void add_mtab_entry(struct mount_options *mo)
return;
}
- fprintf(file, "%s", mo->proc_entry);
+ fprintf(file, "%s%s", mo->specified_dev, strchr(mo->proc_entry, ' '));
fclose(file);
diff --git a/gfs2/mount/util.c b/gfs2/mount/util.c
index bc26daf..5a1f999 100644
--- a/gfs2/mount/util.c
+++ b/gfs2/mount/util.c
@@ -209,7 +209,6 @@ static int mnt_unescape(char *dest, size_t len, const char *src)
{
unsigned i = 0, j = 0;
size_t srclen;
- int ret = -1;
srclen = strlen(src);
while (i < srclen) {
@@ -316,7 +315,8 @@ void read_proc_mounts(struct mount_options *mo)
strncpy(mo->proc_entry, save_line, PATH_MAX);
}
- log_debug("read_proc_mounts: device = \"%s\"", mo->dev);
+ log_debug("read_proc_mounts: device = \"%s\"", mo->specified_dev);
+ log_debug("read_proc_mounts: dm device = \"%s\"", mo->dev);
log_debug("read_proc_mounts: opts = \"%s\"", mo->opts);
}
diff --git a/gfs2/mount/util.h b/gfs2/mount/util.h
index 7b856ac..e866cd4 100644
--- a/gfs2/mount/util.h
+++ b/gfs2/mount/util.h
@@ -46,6 +46,7 @@ do { \
} while (0)
struct mount_options {
+ char specified_dev[PATH_MAX+1];
char dev[PATH_MAX+1];
char dir[PATH_MAX+1];
char opts[PATH_MAX+1];
13 years, 8 months