gfs2-utils: master - fsck.gfs2: fsck.gfs2: Sync di_nlink adding links for lost+found
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 6bee78a1e1e0e759339da5a01d42b1c8c4260d73
Parent: 6bc54f5d14c2d0432f97fd2c4a20dfdb8ece8c84
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 14:21:06 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:52:10 2011 -0500
fsck.gfs2: fsck.gfs2: Sync di_nlink adding links for lost+found
When adding a ".." entry to a directory newly linked to lost+found
fsck.gfs2 needs to update its di_nlink value to account for the new
link. If not, it can "correct" the di_nlink value to the wrong
value and not find the error until a second fsck.gfs2 is done.
This only happens in the rare case where there is no pre-existing
".." entry that may be reused to re-link to lost+found.
rhbz#675723
---
gfs2/fsck/lost_n_found.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 32f3c5c..b6f02b9 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -118,6 +118,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
dip = fsck_load_inode(sdp, di->dotdot_parent);
if (dip->i_di.di_nlink > 0) {
dip->i_di.di_nlink--;
+ set_di_nlink(dip); /* keep inode tree in sync */
log_debug(_("Decrementing its links to %d\n"),
dip->i_di.di_nlink);
bmodified(dip->i_bh);
@@ -128,6 +129,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
"Changing it to 0.\n"),
dip->i_di.di_nlink);
dip->i_di.di_nlink = 0;
+ set_di_nlink(dip); /* keep inode tree in sync */
bmodified(dip->i_bh);
}
fsck_inode_put(&dip);
12 years, 8 months
gfs2-utils: master - fsck.gfs2: fsck.gfs2: Rename nlink functions to be intuitive
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 6bc54f5d14c2d0432f97fd2c4a20dfdb8ece8c84
Parent: 7a8f8902d88d57c778c8b48d8eb3187efcfc6c3c
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 14:01:18 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:52:02 2011 -0500
fsck.gfs2: fsck.gfs2: Rename nlink functions to be intuitive
Part of fsck's checks is to verify the count of links for directories,
but the variable names and function names are too confusing to understand
without in-depth analysis of what the code is doing.
This patch renames the structure variable "link_count" to something that
makes more intuitive sense: di_nlink, which matches the variable name in
the dinode. That distinguishes it from the number of links that fsck is
trying to count manually. It also renames the link count functions to
make them more intuitively obvious as well: set_di_nlink sets the di_nlink
based on the value passed in from the dinode, and incr_link_count and
decr_link_count increment and decrement the counted links respectively.
rhbz#675723
---
gfs2/fsck/fsck.h | 4 ++--
gfs2/fsck/link.c | 16 ++++++++++------
gfs2/fsck/link.h | 10 +++++-----
gfs2/fsck/lost_n_found.c | 29 ++++++++++++++---------------
gfs2/fsck/pass1.c | 2 +-
gfs2/fsck/pass2.c | 20 ++++++++++----------
gfs2/fsck/pass3.c | 4 ++--
gfs2/fsck/pass4.c | 14 +++++++-------
8 files changed, 51 insertions(+), 48 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 25bc3b9..6353dfc 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -29,8 +29,8 @@ struct inode_info
{
struct osi_node node;
uint64_t inode;
- uint16_t link_count; /* the number of links the inode
- * thinks it has */
+ uint16_t di_nlink; /* the number of links the inode
+ * thinks it has */
uint16_t counted_links; /* the number of links we've found */
};
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 08ea94c..e49f3af 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -13,22 +13,26 @@
#include "inode_hash.h"
#include "link.h"
-int set_link_count(uint64_t inode_no, uint32_t count)
+int set_di_nlink(struct gfs2_inode *ip)
{
struct inode_info *ii;
+ uint64_t inode_no = ip->i_di.di_num.no_addr;
+
+ /*log_debug( _("Setting link count to %u for %" PRIu64
+ " (0x%" PRIx64 ")\n"), count, inode_no, inode_no);*/
/* If the list has entries, look for one that matches inode_no */
ii = inodetree_find(inode_no);
if (!ii)
ii = inodetree_insert(inode_no);
if (ii)
- ii->link_count = count;
+ ii->di_nlink = ip->i_di.di_nlink;
else
return -1;
return 0;
}
-int increment_link(uint64_t inode_no, uint64_t referenced_from,
- const char *why)
+int incr_link_count(uint64_t inode_no, uint64_t referenced_from,
+ const char *why)
{
struct inode_info *ii = NULL;
@@ -61,8 +65,8 @@ int increment_link(uint64_t inode_no, uint64_t referenced_from,
return 0;
}
-int decrement_link(uint64_t inode_no, uint64_t referenced_from,
- const char *why)
+int decr_link_count(uint64_t inode_no, uint64_t referenced_from,
+ const char *why)
{
struct inode_info *ii = NULL;
diff --git a/gfs2/fsck/link.h b/gfs2/fsck/link.h
index f890575..ad040e6 100644
--- a/gfs2/fsck/link.h
+++ b/gfs2/fsck/link.h
@@ -1,10 +1,10 @@
#ifndef _LINK_H
#define _LINK_H
-int set_link_count(uint64_t inode_no, uint32_t count);
-int increment_link(uint64_t inode_no, uint64_t referenced_from,
- const char *why);
-int decrement_link(uint64_t inode_no, uint64_t referenced_from,
- const char *why);
+int set_di_nlink(struct gfs2_inode *ip);
+int incr_link_count(uint64_t inode_no, uint64_t referenced_from,
+ const char *why);
+int decr_link_count(uint64_t inode_no, uint64_t referenced_from,
+ const char *why);
#endif /* _LINK_H */
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 4eff83b..32f3c5c 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -51,8 +51,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
the root directory. We must increment the nlink value
in the hash table to keep them in sync so that pass4 can
detect and fix any descrepancies. */
- set_link_count(sdp->sd_sb.sb_root_dir.no_addr,
- sdp->md.rooti->i_di.di_nlink);
+ set_di_nlink(sdp->md.rooti);
q = block_type(lf_dip->i_di.di_num.no_addr);
if (q != gfs2_inode_dir) {
@@ -68,15 +67,15 @@ int add_inode_to_lf(struct gfs2_inode *ip){
_("lost+found dinode"),
gfs2_inode_dir);
/* root inode links to lost+found */
- increment_link(sdp->md.rooti->i_di.di_num.no_addr,
+ incr_link_count(sdp->md.rooti->i_di.di_num.no_addr,
lf_dip->i_di.di_num.no_addr, _("root"));
/* lost+found link for '.' from itself */
- increment_link(lf_dip->i_di.di_num.no_addr,
- lf_dip->i_di.di_num.no_addr, "\".\"");
+ incr_link_count(lf_dip->i_di.di_num.no_addr,
+ lf_dip->i_di.di_num.no_addr, "\".\"");
/* lost+found link for '..' back to root */
- increment_link(lf_dip->i_di.di_num.no_addr,
- sdp->md.rooti->i_di.di_num.no_addr,
- "\"..\"");
+ incr_link_count(lf_dip->i_di.di_num.no_addr,
+ sdp->md.rooti->i_di.di_num.no_addr,
+ "\"..\"");
}
log_info( _("lost+found directory is dinode %lld (0x%llx)\n"),
(unsigned long long)lf_dip->i_di.di_num.no_addr,
@@ -113,9 +112,9 @@ int add_inode_to_lf(struct gfs2_inode *ip){
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)di->dotdot_parent,
(unsigned long long)di->dotdot_parent);
- decrement_link(di->dotdot_parent,
- ip->i_di.di_num.no_addr,
- _(".. unlinked, moving to lost+found"));
+ decr_link_count(di->dotdot_parent,
+ ip->i_di.di_num.no_addr,
+ _(".. unlinked, moving to lost+found"));
dip = fsck_load_inode(sdp, di->dotdot_parent);
if (dip->i_di.di_nlink > 0) {
dip->i_di.di_nlink--;
@@ -203,12 +202,12 @@ int add_inode_to_lf(struct gfs2_inode *ip){
reprocess_inode(lf_dip, "lost+found");
/* This inode is linked from lost+found */
- increment_link(ip->i_di.di_num.no_addr, lf_dip->i_di.di_num.no_addr,
- _("from lost+found"));
+ incr_link_count(ip->i_di.di_num.no_addr, lf_dip->i_di.di_num.no_addr,
+ _("from lost+found"));
/* If it's a directory, lost+found is back-linked to it via .. */
if (S_ISDIR(ip->i_di.di_mode))
- increment_link(lf_dip->i_di.di_num.no_addr,
- ip->i_di.di_mode, _("to lost+found"));
+ incr_link_count(lf_dip->i_di.di_num.no_addr,
+ ip->i_di.di_mode, _("to lost+found"));
log_notice( _("Added inode #%llu (0x%llx) to lost+found dir\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index f0e7277..1bd8464 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1060,7 +1060,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
goto bad_dinode;
return 0;
}
- if (set_link_count(ip->i_di.di_num.no_addr, ip->i_di.di_nlink))
+ if (set_di_nlink(ip))
goto bad_dinode;
if (S_ISDIR(ip->i_di.di_mode) &&
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 72bd107..614c963 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -219,7 +219,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
(*count)++;
ds->entry_count++;
/* can't do this because the block is out of range:
- increment_link(entryblock); */
+ incr_link_count(entryblock); */
return 0;
}
}
@@ -306,7 +306,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* Don't decrement the link here: Here in pass2, we increment
only when we know it's okay.
- decrement_link(ip->i_di.di_num.no_addr); */
+ decr_link_count(ip->i_di.di_num.no_addr); */
/* If it was previously marked invalid (i.e. known
to be bad, not just a free block, etc.) then the temptation
would be to delete any metadata it holds. The trouble is:
@@ -504,8 +504,8 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
dentry_is_valid:
/* This directory inode links to this inode via this dentry */
- increment_link(entryblock, ip->i_di.di_num.no_addr,
- _("valid reference"));
+ incr_link_count(entryblock, ip->i_di.di_num.no_addr,
+ _("valid reference"));
(*count)++;
ds->entry_count++;
/* End of checks */
@@ -601,9 +601,9 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
if (cur_blks != sysinode->i_di.di_blocks)
reprocess_inode(sysinode, dirname);
/* This system inode is linked to itself via '.' */
- increment_link(sysinode->i_di.di_num.no_addr,
- sysinode->i_di.di_num.no_addr,
- "sysinode \".\"");
+ incr_link_count(sysinode->i_di.di_num.no_addr,
+ sysinode->i_di.di_num.no_addr,
+ "sysinode \".\"");
ds.entry_count++;
free(filename);
} else
@@ -820,9 +820,9 @@ int pass2(struct gfs2_sbd *sdp)
reprocess_inode(ip, dirname);
}
/* directory links to itself via '.' */
- increment_link(ip->i_di.di_num.no_addr,
- ip->i_di.di_num.no_addr,
- _("\". (itself)\""));
+ incr_link_count(ip->i_di.di_num.no_addr,
+ ip->i_di.di_num.no_addr,
+ _("\". (itself)\""));
ds.entry_count++;
free(filename);
log_err( _("The directory was fixed.\n"));
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index ff045de..ea8c51d 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -52,7 +52,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
if (gfs2_dirent_del(ip, filename, filename_len))
log_warn( _("Unable to remove \"..\" directory entry.\n"));
else
- decrement_link(olddotdot, block, _("old \"..\""));
+ decr_link_count(olddotdot, block, _("old \"..\""));
cur_blks = ip->i_di.di_blocks;
err = dir_add(ip, filename, filename_len, &pip->i_di.di_num, DT_DIR);
if (err) {
@@ -68,7 +68,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
(unsigned long long)ip->i_di.di_num.no_addr);
reprocess_inode(ip, dirname);
}
- increment_link(newdotdot, block, _("new \"..\""));
+ incr_link_count(newdotdot, block, _("new \"..\""));
fsck_inode_put(&ip);
fsck_inode_put(&pip);
free(filename);
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 4a1566d..0614372 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -142,11 +142,11 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
log_err( _("Unlinked inode left unlinked\n"));
fsck_inode_put(&ip);
} /* if (ii->counted_links == 0) */
- else if (ii->link_count != ii->counted_links) {
+ else if (ii->di_nlink != ii->counted_links) {
log_err( _("Link count inconsistent for inode %llu"
" (0x%llx) has %u but fsck found %u.\n"),
(unsigned long long)ii->inode,
- (unsigned long long)ii->inode, ii->link_count,
+ (unsigned long long)ii->inode, ii->di_nlink,
ii->counted_links);
/* Read in the inode, adjust the link count,
* and write it back out */
@@ -156,13 +156,13 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
(unsigned long long)ii->inode)) {
ip = fsck_load_inode(sdp, ii->inode); /* bread, inode_get */
fix_link_count(ii, ip);
- ii->link_count = ii->counted_links;
+ ii->di_nlink = ii->counted_links;
fsck_inode_put(&ip); /* out, brelse, free */
log_warn( _("Link count updated to %d for "
"inode %llu (0x%llx)\n"),
- ii->link_count,
- (unsigned long long)ii->inode,
- (unsigned long long)ii->inode);
+ ii->di_nlink,
+ (unsigned long long)ii->inode,
+ (unsigned long long)ii->inode);
} else {
log_err( _("Link count for inode %llu (0x%llx) still incorrect\n"),
(unsigned long long)ii->inode,
@@ -171,7 +171,7 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
}
log_debug( _("block %llu (0x%llx) has link count %d\n"),
(unsigned long long)ii->inode,
- (unsigned long long)ii->inode, ii->link_count);
+ (unsigned long long)ii->inode, ii->di_nlink);
} /* osi_list_foreach(tmp, list) */
if (lf_addition) {
12 years, 8 months
gfs2-utils: master - fsck.gfs2: fsck.gfs2: Delete vestigial buffer_head in check_leaf
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 7a8f8902d88d57c778c8b48d8eb3187efcfc6c3c
Parent: 253733e22ad8acd89332579784ff7aa42c039a34
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 13:28:08 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:51:54 2011 -0500
fsck.gfs2: fsck.gfs2: Delete vestigial buffer_head in check_leaf
This patch eliminates a variable bh from all the check_leaf metawalk
functions because it is no longer referenced.
rhbzs#675723
---
gfs2/fsck/metawalk.c | 10 ++++------
gfs2/fsck/metawalk.h | 5 ++---
gfs2/fsck/pass1.c | 14 ++++++--------
3 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 5d0afa5..ea1774a 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -686,7 +686,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
}
gfs2_leaf_in(&leaf, lbh);
if (pass->check_leaf)
- error = pass->check_leaf(ip, leaf_no, lbh,
+ error = pass->check_leaf(ip, leaf_no,
pass->private);
/*
@@ -1462,10 +1462,9 @@ int delete_metadata(struct gfs2_inode *ip, uint64_t block,
return delete_block_if_notdup(ip, block, bh, _("metadata"), private);
}
-int delete_leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private)
+int delete_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
{
- return delete_block_if_notdup(ip, block, &bh, _("leaf"), private);
+ return delete_block_if_notdup(ip, block, NULL, _("leaf"), private);
}
int delete_data(struct gfs2_inode *ip, uint64_t block, void *private)
@@ -1528,8 +1527,7 @@ static int alloc_data(struct gfs2_inode *ip, uint64_t block, void *private)
return 0;
}
-static int alloc_leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private)
+static int alloc_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
{
uint8_t q;
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index c1e61fb..ea023b6 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -20,8 +20,7 @@ extern int delete_block(struct gfs2_inode *ip, uint64_t block,
void *private);
extern int delete_metadata(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, int h, void *private);
-extern int delete_leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private);
+extern int delete_leaf(struct gfs2_inode *ip, uint64_t block, void *private);
extern int delete_data(struct gfs2_inode *ip, uint64_t block, void *private);
extern int delete_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
struct gfs2_buffer_head **bh, void *private);
@@ -60,7 +59,7 @@ extern struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp,
struct metawalk_fxns {
void *private;
int (*check_leaf) (struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private);
+ void *private);
int (*check_metalist) (struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, int h,
void *private);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 30d6b3c..f0e7277 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -34,8 +34,7 @@ struct block_count {
uint64_t ea_count;
};
-static int leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private);
+static int leaf(struct gfs2_inode *ip, uint64_t block, void *private);
static int check_metalist(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, int h, void *private);
static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
@@ -66,7 +65,7 @@ static int invalidate_metadata(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, int h,
void *private);
static int invalidate_leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private);
+ void *private);
static int invalidate_data(struct gfs2_inode *ip, uint64_t block,
void *private);
static int invalidate_eattr_indir(struct gfs2_inode *ip, uint64_t block,
@@ -200,8 +199,7 @@ struct metawalk_fxns sysdir_fxns = {
.check_dentry = resuscitate_dentry,
};
-static int leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private)
+static int leaf(struct gfs2_inode *ip, uint64_t block, void *private)
{
struct block_count *bc = (struct block_count *) private;
@@ -856,7 +854,7 @@ static int invalidate_metadata(struct gfs2_inode *ip, uint64_t block,
}
static int invalidate_leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private)
+ void *private)
{
return mark_block_invalid(ip, block, ref_as_meta, _("leaf"));
}
@@ -939,9 +937,9 @@ static int rangecheck_metadata(struct gfs2_inode *ip, uint64_t block,
}
static int rangecheck_leaf(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head *bh, void *private)
+ void *private)
{
- return rangecheck_block(ip, block, &bh, _("leaf"), private);
+ return rangecheck_block(ip, block, NULL, _("leaf"), private);
}
static int rangecheck_data(struct gfs2_inode *ip, uint64_t block,
12 years, 8 months
gfs2-utils: master - fsck.gfs2: Rename check_leaf to check_ealeaf_block
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 253733e22ad8acd89332579784ff7aa42c039a34
Parent: 666afe39c6e318dfe596351232fd37586b0d5ae2
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 12:58:04 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:51:48 2011 -0500
fsck.gfs2: Rename check_leaf to check_ealeaf_block
This patch renames function check_leaf_block to check_ealeaf_block to
avoid confusion between directory leaf block handling and extended
attribute leaf block handling.
rhbz#675723
---
gfs2/fsck/pass1.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index e2fe73c..30d6b3c 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -636,8 +636,11 @@ static int finish_eattr_indir(struct gfs2_inode *ip, int leaf_pointers,
return 1;
}
-static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
- struct gfs2_buffer_head **bh, void *private)
+/* check_ealeaf_block
+ * checks an extended attribute (not directory) leaf block
+ */
+static int check_ealeaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
+ struct gfs2_buffer_head **bh, void *private)
{
struct gfs2_buffer_head *leaf_bh = NULL;
struct gfs2_sbd *sdp = ip->i_sbd;
@@ -728,7 +731,7 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, uint64_t *data_ptr,
gfs2_bad_block);
return 1;
}
- error = check_leaf_block(ip, el_blk, GFS2_METATYPE_ED, &bh, private);
+ error = check_ealeaf_block(ip, el_blk, GFS2_METATYPE_ED, &bh, private);
if (bh)
brelse(bh);
return error;
@@ -769,7 +772,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
"Attribute leaf"), gfs2_bad_block);
return 1;
}
- return check_leaf_block(ip, block, GFS2_METATYPE_EA, bh, private);
+ return check_ealeaf_block(ip, block, GFS2_METATYPE_EA, bh, private);
}
static int check_eattr_entries(struct gfs2_inode *ip,
12 years, 8 months
gfs2-utils: master - fsck.gfs2: Check for blocks wrongly inside resource groups
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 666afe39c6e318dfe596351232fd37586b0d5ae2
Parent: 3e12755de1021c62eab9c47bf3958b29a206a653
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 12:46:29 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:51:38 2011 -0500
fsck.gfs2: Check for blocks wrongly inside resource groups
It's not enough to range_check blocks in order to call them valid.
We also need to check whether those block collide with resource groups.
We don't want a bitmap block to ever be referenced unless it's part of
the rgrp and rindex functions. This patch changes most of the fsck code
from doing simple block range checks to doing range checks plus checks
for blocks inside the resource groups.
rhbz#675723
---
gfs2/fsck/lost_n_found.c | 2 +-
gfs2/fsck/metawalk.c | 20 +++++++-------
gfs2/fsck/pass1.c | 66 +++++++++++++++++++++++----------------------
gfs2/fsck/pass1b.c | 2 +-
gfs2/fsck/pass1c.c | 10 +++---
gfs2/fsck/pass2.c | 4 +-
gfs2/fsck/rgrepair.c | 2 +-
gfs2/fsck/util.c | 2 +-
gfs2/libgfs2/fs_bits.c | 19 ++++++++++++-
gfs2/libgfs2/libgfs2.h | 1 +
10 files changed, 74 insertions(+), 54 deletions(-)
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 04aa90d..4eff83b 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -104,7 +104,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
/* If there's a pre-existing .. directory entry, we have to
back out the links. */
di = dirtree_find(ip->i_di.di_num.no_addr);
- if (di && gfs2_check_range(sdp, di->dotdot_parent) == 0) {
+ if (di && !valid_block(sdp, di->dotdot_parent) == 0) {
struct gfs2_inode *dip;
log_debug(_("Directory %lld (0x%llx) already had a "
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 3cee0fd..5d0afa5 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -455,7 +455,7 @@ static void warn_and_patch(struct gfs2_inode *ip, uint64_t *leaf_no,
}
if (*leaf_no == *bad_leaf ||
query( _("Attempt to patch around it? (y/n) "))) {
- if (gfs2_check_range(ip->i_sbd, old_leaf) == 0)
+ if (!valid_block(ip->i_sbd, old_leaf) == 0)
gfs2_put_leaf_nr(ip, pindex, old_leaf);
else
gfs2_put_leaf_nr(ip, pindex, first_ok_leaf);
@@ -605,7 +605,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
first_ok_leaf = leaf_no = -1;
for(lindex = 0; lindex < (1 << ip->i_di.di_depth); lindex++) {
gfs2_get_leaf_nr(ip, lindex, &leaf_no);
- if (gfs2_check_range(ip->i_sbd, leaf_no) == 0) {
+ if (!valid_block(ip->i_sbd, leaf_no) == 0) {
lbh = bread(sdp, leaf_no);
/* Make sure it's really a valid leaf block. */
if (gfs2_check_meta(lbh, GFS2_METATYPE_LF) == 0) {
@@ -644,7 +644,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
}
do {
- if (gfs2_check_range(ip->i_sbd, old_leaf) == 0) {
+ if (!valid_block(ip->i_sbd, old_leaf) == 0) {
error = check_num_ptrs(ip, old_leaf,
&ref_count, &exp_count,
&lindex, &oldleaf);
@@ -656,7 +656,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (fsck_abort)
break;
/* Make sure the block number is in range. */
- if (gfs2_check_range(ip->i_sbd, leaf_no)){
+ if (!valid_block(ip->i_sbd, leaf_no)){
log_err( _("Leaf block #%llu (0x%llx) is out "
"of range for directory #%llu (0x%llx"
").\n"), (unsigned long long)leaf_no,
@@ -909,7 +909,7 @@ int delete_block(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, const char *btype,
void *private)
{
- if (gfs2_check_range(ip->i_sbd, block) == 0) {
+ if (!valid_block(ip->i_sbd, block) == 0) {
fsck_blockmap_set(ip, block, btype, gfs2_block_free);
return 0;
}
@@ -930,7 +930,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
uint8_t q;
struct duptree *d;
- if (gfs2_check_range(ip->i_sbd, block) != 0)
+ if (!valid_block(ip->i_sbd, block) != 0)
return -EFAULT;
q = block_type(block);
@@ -1190,7 +1190,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
(unsigned long long)block);
continue;
}
- if (gfs2_check_range(ip->i_sbd, block)) {
+ if (!valid_block(ip->i_sbd, block)) {
log_debug( _("Skipping invalid block "
"%lld (0x%llx)\n"),
(unsigned long long)block,
@@ -1237,7 +1237,7 @@ static int check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
if (skip_this_pass || fsck_abort)
return error;
block = be64_to_cpu(*ptr);
- /* It's important that we don't call gfs2_check_range and
+ /* It's important that we don't call !valid_block and
bypass calling check_data on invalid blocks because that
would defeat the rangecheck_block related functions in
pass1. Therefore the individual check_data functions
@@ -1437,8 +1437,8 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
" (0x%llx)\n"), (unsigned long long)dentryblock,
(unsigned long long)dentryblock,
(unsigned long long)dir, (unsigned long long)dir);
- if (gfs2_check_range(sdp, dir)) {
- log_err( _("Parent directory out of range\n"));
+ if (!valid_block(sdp, dir)) {
+ log_err( _("Parent directory is invalid\n"));
return 1;
}
remove_dentry_fxns.private = &dentryblock;
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 2670d8c..e2fe73c 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -122,11 +122,11 @@ static int resuscitate_metalist(struct gfs2_inode *ip, uint64_t block,
struct block_count *bc = (struct block_count *)private;
*bh = NULL;
- if (gfs2_check_range(ip->i_sbd, block)){ /* blk outside of FS */
+ if (!valid_block(ip->i_sbd, block)){ /* blk outside of FS */
fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
_("itself"), gfs2_bad_block);
- log_err( _("Bad indirect block pointer (out of range) "
- "found in system inode %lld (0x%llx).\n"),
+ log_err( _("Bad indirect block pointer (invalid or out of "
+ "range) found in system inode %lld (0x%llx).\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
return 1;
@@ -166,10 +166,10 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
strncpy(tmp_name, filename, de->de_name_len);
else
strncpy(tmp_name, filename, sizeof(tmp_name) - 1);
- if (gfs2_check_range(sdp, block)) {
+ if (!valid_block(sdp, block)) {
log_err( _("Block # referenced by system directory entry %s "
- "in inode %lld (0x%llx) is out of range; "
- "ignored.\n"),
+ "in inode %lld (0x%llx) is invalid or out of range;"
+ " ignored.\n"),
tmp_name, (unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
return 0;
@@ -221,10 +221,10 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
*bh = NULL;
- if (gfs2_check_range(ip->i_sbd, block)){ /* blk outside of FS */
+ if (!valid_block(ip->i_sbd, block)){ /* blk outside of FS */
fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
_("itself"), gfs2_bad_block);
- log_debug( _("Bad indirect block pointer (out of range) "
+ log_debug( _("Bad indirect block (invalid/out of range) "
"found in inode %lld (0x%llx).\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
@@ -295,7 +295,7 @@ static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
*bh = NULL;
- if (gfs2_check_range(ip->i_sbd, block)){ /* blk outside of FS */
+ if (!valid_block(ip->i_sbd, block)){ /* blk outside of FS */
fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
_("itself"), gfs2_block_free);
return 1;
@@ -350,9 +350,9 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
uint8_t q;
struct block_count *bc = (struct block_count *) private;
- if (gfs2_check_range(ip->i_sbd, block)) {
+ if (!valid_block(ip->i_sbd, block)) {
log_err( _("inode %lld (0x%llx) has a bad data block pointer "
- "%lld (out of range)\n"),
+ "%lld (invalid or out of range)\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)block);
@@ -401,12 +401,12 @@ static int undo_check_data(struct gfs2_inode *ip, uint64_t block,
struct duptree *d;
struct block_count *bc = (struct block_count *) private;
- if (gfs2_check_range(ip->i_sbd, block)) {
+ if (!valid_block(ip->i_sbd, block)) {
/* Mark the owner of this block with the bad_block
* designator so we know to check it for out of range
* blocks later */
fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
- _("bad (out of range) data"),
+ _("bad (invalid or out of range) data"),
gfs2_block_free);
return 1;
}
@@ -547,7 +547,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
/* This inode contains an eattr - it may be invalid, but the
* eattr attributes points to a non-zero block */
- if (gfs2_check_range(sdp, indirect)) {
+ if (!valid_block(sdp, indirect)) {
/* Doesn't help to mark this here - this gets checked
* in pass1c */
return 1;
@@ -713,10 +713,10 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, uint64_t *data_ptr,
struct gfs2_buffer_head *bh = NULL;
int error;
- if (gfs2_check_range(sdp, el_blk)){
+ if (!valid_block(sdp, el_blk)){
log_err( _("Inode #%llu (0x%llx): Extended Attribute block "
"%llu (0x%llx) has an extended leaf block #%llu "
- "(0x%llx) that is out of range.\n"),
+ "(0x%llx) that is invalid or out of range.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_eattr,
@@ -757,9 +757,10 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
}
if (!b || b->block != ip->i_di.di_num.no_addr)
gfs2_special_add(&sdp->eattr_blocks, ip->i_di.di_num.no_addr);
- if (gfs2_check_range(sdp, block)) {
+ if (!valid_block(sdp, block)) {
log_warn( _("Inode #%llu (0x%llx): Extended Attribute leaf "
- "block #%llu (0x%llx) is out of range.\n"),
+ "block #%llu (0x%llx) is invalid or out of "
+ "range.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)block, (unsigned long long)block);
@@ -825,15 +826,15 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
{
uint8_t q;
- if (gfs2_check_range(ip->i_sbd, block) != 0)
+ if (!valid_block(ip->i_sbd, block) != 0)
return -EFAULT;
q = block_type(block);
if (q != gfs2_block_free) {
add_duplicate_ref(ip, block, reftype, 0, INODE_INVALID);
log_info( _("%s block %lld (0x%llx), part of inode "
- "%lld (0x%llx), was free so the invalid "
- "reference is ignored.\n"),
+ "%lld (0x%llx), was previously referenced so "
+ "the invalid reference is ignored.\n"),
btype, (unsigned long long)block,
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -897,13 +898,13 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
long *bad_pointers = (long *)private;
uint8_t q;
- if (gfs2_check_range(ip->i_sbd, block) != 0) {
+ if (!valid_block(ip->i_sbd, block) != 0) {
(*bad_pointers)++;
- log_debug( _("Bad %s block pointer (out of range #%ld) "
- "found in inode %lld (0x%llx).\n"), btype,
- *bad_pointers,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_info( _("Bad %s block pointer (invalid or out of range "
+ "#%ld) found in inode %lld (0x%llx).\n"),
+ btype, *bad_pointers,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
return ENOENT;
else
@@ -913,11 +914,12 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
q = block_type(block);
if (q != gfs2_block_free) {
(*bad_pointers)++;
- log_debug( _("Duplicated %s block pointer (violation #%ld) "
- "found in inode %lld (0x%llx).\n"), btype,
- *bad_pointers,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_info( _("Duplicated %s block pointer (violation %ld, block"
+ " %lld (0x%llx)) found in inode %lld (0x%llx).\n"),
+ btype, *bad_pointers,
+ (unsigned long long)block, (unsigned long long)block,
+ (unsigned long long)ip->i_di.di_num.no_addr,
+ (unsigned long long)ip->i_di.di_num.no_addr);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
return ENOENT;
else
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 6b7bc41..bbf33d2 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -205,7 +205,7 @@ static int clear_dup_metalist(struct gfs2_inode *ip, uint64_t block,
struct dup_handler *dh = (struct dup_handler *) private;
struct duptree *d;
- if (gfs2_check_range(ip->i_sbd, block) != 0)
+ if (!valid_block(ip->i_sbd, block) != 0)
return 0;
/* This gets tricky. We're traversing a metadata tree trying to
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index 0fbe0ce..209c32d 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -78,10 +78,10 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
uint8_t q;
struct gfs2_buffer_head *indir_bh = NULL;
- if (gfs2_check_range(sdp, block)) {
+ if (!valid_block(sdp, block)) {
log_err( _("Extended attributes indirect block #%llu"
" (0x%llx) for inode #%llu"
- " (0x%llx) out of range...removing\n"),
+ " (0x%llx) is invalid...removing\n"),
(unsigned long long)block,
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -92,7 +92,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
if (q != gfs2_indir_blk) {
log_err( _("Extended attributes indirect block #%llu"
" (0x%llx) for inode #%llu"
- " (0x%llx) invalid.\n"),
+ " (0x%llx) is invalid.\n"),
(unsigned long long)block,
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -113,9 +113,9 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
struct gfs2_sbd *sdp = ip->i_sbd;
uint8_t q;
- if (gfs2_check_range(sdp, block)) {
+ if (!valid_block(sdp, block)) {
log_err( _("Extended attributes block for inode #%llu"
- " (0x%llx) out of range.\n"),
+ " (0x%llx) is invalid.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
return ask_remove_eattr(ip);
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 573ed30..72bd107 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -206,9 +206,9 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
else
strncpy(tmp_name, filename, MAX_FILENAME - 1);
- if (gfs2_check_range(ip->i_sbd, entryblock)) {
+ if (!valid_block(ip->i_sbd, entryblock)) {
log_err( _("Block # referenced by directory entry %s in inode "
- "%lld (0x%llx) is out of range\n"),
+ "%lld (0x%llx) is invalid\n"),
tmp_name, (unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
if (query( _("Clear directory entry to out of range block? "
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 1dd49b1..c91e4be 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -710,7 +710,7 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, osi_list_t *ret_list,
osi_list_t *tmp;
struct rgrp_list *exp, *rgd; /* expected, actual */
- *num_rgs = sdp->md.riinode->i_di.di_size / sizeof(struct gfs2_rindex);
+ *num_rgs = sdp->md.riinode->i_di.di_size / sizeof(struct gfs2_rindex) ;
osi_list_init(ret_list);
for (tmp = sdp->rglist.next; tmp != &sdp->rglist; tmp = tmp->next) {
rgd = osi_list_entry(tmp, struct rgrp_list, list);
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index d496833..706a386 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -204,7 +204,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
struct inode_with_dups *id, *found_id;
struct duptree *dt;
- if (gfs2_check_range(ip->i_sbd, block) != 0)
+ if (!valid_block(ip->i_sbd, block) != 0)
return 0;
/* If this is not the first reference (i.e. all calls from pass1) we
need to create the duplicate reference. If this is pass1b, we want
diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index 97172df..9f71471 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -145,7 +145,24 @@ int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno)
}
/*
- * fs_set_bitmap
+ * valid_block - check if blkno is valid and not part of our rgrps or bitmaps
+ * @sdp: super block
+ * @blkno: block number
+ *
+ * Returns: 1 if ok, 0 if out of bounds
+ */
+int valid_block(struct gfs2_sbd *sdp, uint64_t blkno)
+{
+ if((blkno > sdp->fssize) || (blkno <= sdp->sb_addr))
+ return 0;
+ /* Check if the block is one of our rgrp or bitmap blocks */
+ if (gfs2_get_bitmap(sdp, blkno, NULL) < 0)
+ return 0;
+ return 1;
+}
+
+/*
+ * gfs2_set_bitmap
* @sdp: super block
* @blkno: block number relative to file system
* @state: one of three possible states
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 254a8e6..140a7a0 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -410,6 +410,7 @@ extern uint32_t gfs2_blkalloc_internal(struct rgrp_list *rgd, uint32_t goal,
extern int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno);
/* functions with blk #'s that are file system relative */
+extern int valid_block(struct gfs2_sbd *sdp, uint64_t blkno);
extern int gfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno,
struct rgrp_list *rgd);
extern int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state);
12 years, 8 months
gfs2-utils: master - libgfs2: move gfs1 structures to libgfs2
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 3e12755de1021c62eab9c47bf3958b29a206a653
Parent: 78d1bdc636de8dca788d0bcebe0128a899f2bb29
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 11:23:47 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:51:32 2011 -0500
libgfs2: move gfs1 structures to libgfs2
This patch moves a number of gfs1-specific structures from gfs2_edit to
libgfs2 so other utils can reference them.
It also changes function rindex_read so it can operate on gfs1 or gfs2
rindex files.
rhbz#675723
---
gfs2/edit/extended.c | 11 +++--
gfs2/edit/hexedit.c | 13 +++--
gfs2/edit/hexedit.h | 126 ------------------------------------------------
gfs2/libgfs2/libgfs2.h | 94 +++++++++++++++++++++++++++++++++++
gfs2/libgfs2/super.c | 41 ++++++++++-----
5 files changed, 136 insertions(+), 149 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 575c387..792b724 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -505,7 +505,8 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
start_line = line;
error = 0;
- print_gfs2("RG index entries found: %d.", dip->i_di.di_size / risize());
+ print_gfs2("RG index entries found: %d.", dip->i_di.di_size /
+ sizeof(struct gfs2_rindex));
eol(0);
lines_per_row[dmode] = 6;
memset(highlighted_addr, 0, sizeof(highlighted_addr));
@@ -513,12 +514,14 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
for (print_entry_ndx=0; ; print_entry_ndx++) {
uint64_t roff;
- roff = print_entry_ndx * risize();
+ roff = print_entry_ndx * sizeof(struct gfs2_rindex);
if (sbd.gfs1)
- error = gfs1_readi(dip, (void *)&rbuf, roff, risize());
+ error = gfs1_readi(dip, (void *)&rbuf, roff,
+ sizeof(struct gfs2_rindex));
else
- error = gfs2_readi(dip, (void *)&rbuf, roff, risize());
+ error = gfs2_readi(dip, (void *)&rbuf, roff,
+ sizeof(struct gfs2_rindex));
if (!error) /* end of file */
break;
gfs2_rindex_in(&ri, rbuf);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 651c6f6..49971ef 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1466,7 +1466,8 @@ uint64_t masterblock(const char *fn)
static void rgcount(void)
{
printf("%lld RGs in this file system.\n",
- (unsigned long long)sbd.md.riinode->i_di.di_size / risize());
+ (unsigned long long)sbd.md.riinode->i_di.di_size /
+ sizeof(struct gfs2_rindex));
inode_put(&sbd.md.riinode);
gfs2_rgrp_free(&sbd.rglist);
exit(EXIT_SUCCESS);
@@ -1481,7 +1482,7 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
struct gfs2_rindex fbuf, ri;
uint64_t foffset, gfs1_adj = 0;
- foffset = rg * risize();
+ foffset = rg * sizeof(struct gfs2_rindex);
if (sbd.gfs1) {
uint64_t sd_jbsize =
(sbd.bsize - sizeof(struct gfs2_meta_header));
@@ -1490,7 +1491,8 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
sizeof(struct gfs2_meta_header);
gfs1_adj += sizeof(struct gfs2_meta_header);
}
- amt = gfs2_readi(dif, (void *)&fbuf, foffset + gfs1_adj, risize());
+ amt = gfs2_readi(dif, (void *)&fbuf, foffset + gfs1_adj,
+ sizeof(struct gfs2_rindex));
if (!amt) /* end of file */
return 0;
gfs2_rindex_in(&ri, (void *)&fbuf);
@@ -1559,11 +1561,12 @@ static uint64_t get_rg_addr(int rgnum)
else
gblock = masterblock("rindex");
riinode = inode_read(&sbd, gblock);
- if (rgnum < riinode->i_di.di_size / risize())
+ if (rgnum < riinode->i_di.di_size / sizeof(struct gfs2_rindex))
rgblk = find_rgrp_block(riinode, rgnum);
else
fprintf(stderr, "Error: File system only has %lld RGs.\n",
- (unsigned long long)riinode->i_di.di_size / risize());
+ (unsigned long long)riinode->i_di.di_size /
+ sizeof(struct gfs2_rindex));
inode_put(&riinode);
return rgblk;
}
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 8a3c615..f7b539e 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -21,27 +21,6 @@
enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2, INIT_MODE = 3 };
#define BLOCK_STACK_SIZE 256
-#define GFS_FORMAT_SB (100) /* Super-Block */
-#define GFS_METATYPE_SB (1) /* Super-Block */
-#define GFS_FORMAT_FS (1309) /* Filesystem (all-encompassing) */
-#define GFS_FORMAT_MULTI (1401) /* Multi-Host */
-/* GFS1 Dinode types */
-#define GFS_FILE_NON (0)
-#define GFS_FILE_REG (1) /* regular file */
-#define GFS_FILE_DIR (2) /* directory */
-#define GFS_FILE_LNK (5) /* link */
-#define GFS_FILE_BLK (7) /* block device node */
-#define GFS_FILE_CHR (8) /* character device node */
-#define GFS_FILE_FIFO (101) /* fifo/pipe */
-#define GFS_FILE_SOCK (102) /* socket */
-
-/* GFS 1 journal block types: */
-#define GFS_LOG_DESC_METADATA (300) /* metadata */
-#define GFS_LOG_DESC_IUL (400) /* unlinked inode */
-#define GFS_LOG_DESC_IDA (401) /* de-allocated inode */
-#define GFS_LOG_DESC_Q (402) /* quota */
-#define GFS_LOG_DESC_LAST (500) /* final in a logged transaction */
-
#define pv(struct, member, fmt, fmt2) do { \
print_it(" "#member, fmt, fmt2, struct->member); \
} while (FALSE);
@@ -89,71 +68,6 @@ extern int dsplines;
extern int dsp_lines[DMODES];
extern int combined_display;
-struct gfs_jindex {
- uint64_t ji_addr; /* starting block of the journal */
- uint32_t ji_nsegment; /* number (quantity) of segments in journal */
- uint32_t ji_pad;
-
- char ji_reserved[64];
-};
-
-struct gfs_log_descriptor {
- struct gfs2_meta_header ld_header;
-
- uint32_t ld_type; /* GFS_LOG_DESC_... Type of this log chunk */
- uint32_t ld_length; /* Number of buffers in this chunk */
- uint32_t ld_data1; /* descriptor-specific field */
- uint32_t ld_data2; /* descriptor-specific field */
- char ld_reserved[64];
-};
-
-struct gfs_log_header {
- struct gfs2_meta_header lh_header;
-
- uint32_t lh_flags; /* GFS_LOG_HEAD_... */
- uint32_t lh_pad;
-
- uint64_t lh_first; /* Block number of first header in this trans */
- uint64_t lh_sequence; /* Sequence number of this transaction */
-
- uint64_t lh_tail; /* Block number of log tail */
- uint64_t lh_last_dump; /* Block number of last dump */
-
- char lh_reserved[64];
-};
-
-struct gfs_rindex {
- uint64_t ri_addr; /* block # of 1st block (header) in rgrp */
- uint32_t ri_length; /* # fs blocks containing rgrp header & bitmap */
- uint32_t ri_pad;
-
- uint64_t ri_data1; /* block # of first data/meta block in rgrp */
- uint32_t ri_data; /* number (qty) of data/meta blocks in rgrp */
-
- uint32_t ri_bitbytes; /* total # bytes used by block alloc bitmap */
-
- char ri_reserved[64];
-};
-
-struct gfs_rgrp {
- struct gfs2_meta_header rg_header;
-
- uint32_t rg_flags; /* ?? */
-
- uint32_t rg_free; /* Number (qty) of free data blocks */
-
- /* Dinodes are USEDMETA, but are handled separately from other METAs */
- uint32_t rg_useddi; /* Number (qty) of dinodes (used or free) */
- uint32_t rg_freedi; /* Number (qty) of unused (free) dinodes */
- struct gfs2_inum rg_freedi_list; /* 1st block in chain of free dinodes */
-
- /* These META statistics do not include dinodes (used or free) */
- uint32_t rg_usedmeta; /* Number (qty) of used metadata blocks */
- uint32_t rg_freemeta; /* Number (qty) of unused metadata blocks */
-
- char rg_reserved[64];
-};
-
struct gfs2_dirents {
uint64_t block;
struct gfs2_dirent dirent;
@@ -189,35 +103,6 @@ struct blkstack_info {
struct metapath mp;
};
-struct gfs_sb {
- /* Order is important; need to be able to read old superblocks
- in order to support on-disk version upgrades */
- struct gfs2_meta_header sb_header;
-
- uint32_t sb_fs_format; /* GFS_FORMAT_FS (on-disk version) */
- uint32_t sb_multihost_format; /* GFS_FORMAT_MULTI */
- uint32_t sb_flags; /* ?? */
-
- uint32_t sb_bsize; /* fundamental FS block size in bytes */
- uint32_t sb_bsize_shift; /* log2(sb_bsize) */
- uint32_t sb_seg_size; /* Journal segment size in FS blocks */
-
- /* These special inodes do not appear in any on-disk directory. */
- struct gfs2_inum sb_jindex_di; /* journal index inode */
- struct gfs2_inum sb_rindex_di; /* resource group index inode */
- struct gfs2_inum sb_root_di; /* root directory inode */
-
- /* Default inter-node locking protocol (lock module) and namespace */
- char sb_lockproto[GFS2_LOCKNAME_LEN]; /* lock protocol name */
- char sb_locktable[GFS2_LOCKNAME_LEN]; /* unique name for this FS */
-
- /* More special inodes */
- struct gfs2_inum sb_quota_di; /* quota inode */
- struct gfs2_inum sb_license_di; /* license inode */
-
- char sb_reserved[96];
-};
-
extern struct blkstack_info blockstack[BLOCK_STACK_SIZE];
extern struct iinfo *indirect; /* more than the most indirect
pointers possible for any given 4K block */
@@ -226,17 +111,6 @@ extern int indirect_blocks; /* count of indirect blocks */
extern enum dsp_mode dmode;
/* ------------------------------------------------------------------------ */
-/* risize - size of one rindex entry, whether gfs1 or gfs2 */
-/* ------------------------------------------------------------------------ */
-static inline int risize(void)
-{
- if (sbd.gfs1)
- return sizeof(struct gfs_rindex);
- else
- return sizeof(struct gfs2_rindex);
-}
-
-/* ------------------------------------------------------------------------ */
/* block_is_rglist - there's no such block as the rglist. This is a */
/* special case meant to parse the rindex and follow the */
/* blocks to the real rgs. */
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 82c39f1..254a8e6 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -568,6 +568,100 @@ struct gfs_dinode {
char di_reserved[56];
};
+struct gfs_sb {
+ /* Order is important; need to be able to read old superblocks
+ in order to support on-disk version upgrades */
+ struct gfs2_meta_header sb_header;
+
+ uint32_t sb_fs_format; /* GFS_FORMAT_FS (on-disk version) */
+ uint32_t sb_multihost_format; /* GFS_FORMAT_MULTI */
+ uint32_t sb_flags; /* ?? */
+
+ uint32_t sb_bsize; /* fundamental FS block size in bytes */
+ uint32_t sb_bsize_shift; /* log2(sb_bsize) */
+ uint32_t sb_seg_size; /* Journal segment size in FS blocks */
+
+ /* These special inodes do not appear in any on-disk directory. */
+ struct gfs2_inum sb_jindex_di; /* journal index inode */
+ struct gfs2_inum sb_rindex_di; /* resource group index inode */
+ struct gfs2_inum sb_root_di; /* root directory inode */
+
+ /* Default inter-node locking protocol (lock module) and namespace */
+ char sb_lockproto[GFS2_LOCKNAME_LEN]; /* lock protocol name */
+ char sb_locktable[GFS2_LOCKNAME_LEN]; /* unique name for this FS */
+
+ /* More special inodes */
+ struct gfs2_inum sb_quota_di; /* quota inode */
+ struct gfs2_inum sb_license_di; /* license inode */
+
+ char sb_reserved[96];
+};
+
+struct gfs_rgrp {
+ struct gfs2_meta_header rg_header;
+
+ uint32_t rg_flags; /* ?? */
+
+ uint32_t rg_free; /* Number (qty) of free data blocks */
+
+ /* Dinodes are USEDMETA, but are handled separately from other METAs */
+ uint32_t rg_useddi; /* Number (qty) of dinodes (used or free) */
+ uint32_t rg_freedi; /* Number (qty) of unused (free) dinodes */
+ struct gfs2_inum rg_freedi_list; /* 1st block in chain of free dinodes */
+
+ /* These META statistics do not include dinodes (used or free) */
+ uint32_t rg_usedmeta; /* Number (qty) of used metadata blocks */
+ uint32_t rg_freemeta; /* Number (qty) of unused metadata blocks */
+
+ char rg_reserved[64];
+};
+
+struct gfs_log_header {
+ struct gfs2_meta_header lh_header;
+
+ uint32_t lh_flags; /* GFS_LOG_HEAD_... */
+ uint32_t lh_pad;
+
+ uint64_t lh_first; /* Block number of first header in this trans */
+ uint64_t lh_sequence; /* Sequence number of this transaction */
+
+ uint64_t lh_tail; /* Block number of log tail */
+ uint64_t lh_last_dump; /* Block number of last dump */
+
+ char lh_reserved[64];
+};
+
+struct gfs_rindex {
+ uint64_t ri_addr; /* block # of 1st block (header) in rgrp */
+ uint32_t ri_length; /* # fs blocks containing rgrp header & bitmap */
+ uint32_t ri_pad;
+
+ uint64_t ri_data1; /* block # of first data/meta block in rgrp */
+ uint32_t ri_data; /* number (qty) of data/meta blocks in rgrp */
+
+ uint32_t ri_bitbytes; /* total # bytes used by block alloc bitmap */
+
+ char ri_reserved[64];
+};
+
+struct gfs_jindex {
+ uint64_t ji_addr; /* starting block of the journal */
+ uint32_t ji_nsegment; /* number (quantity) of segments in journal */
+ uint32_t ji_pad;
+
+ char ji_reserved[64];
+};
+
+struct gfs_log_descriptor {
+ struct gfs2_meta_header ld_header;
+
+ uint32_t ld_type; /* GFS_LOG_DESC_... Type of this log chunk */
+ uint32_t ld_length; /* Number of buffers in this chunk */
+ uint32_t ld_data1; /* descriptor-specific field */
+ uint32_t ld_data2; /* descriptor-specific field */
+ char ld_reserved[64];
+};
+
extern void gfs1_lookup_block(struct gfs2_inode *ip,
struct gfs2_buffer_head *bh,
unsigned int height, struct metapath *mp,
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index ee18850..9e8d079 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -145,7 +145,10 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane)
{
unsigned int rg;
int error;
- struct gfs2_rindex buf;
+ union {
+ struct gfs_rindex bufgfs1;
+ struct gfs2_rindex bufgfs2;
+ } buf;
struct rgrp_list *rgd, *prev_rgd;
uint64_t prev_length = 0;
@@ -157,8 +160,14 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane)
for (rg = 0; ; rg++) {
if (fd > 0)
error = read(fd, &buf, sizeof(struct gfs2_rindex));
+ else if (sdp->gfs1)
+ error = gfs1_readi(sdp->md.riinode,
+ (char *)&buf.bufgfs1,
+ rg * sizeof(struct gfs2_rindex),
+ sizeof(struct gfs2_rindex));
else
- error = gfs2_readi(sdp->md.riinode, (char *)&buf,
+ error = gfs2_readi(sdp->md.riinode,
+ (char *)&buf.bufgfs2,
rg * sizeof(struct gfs2_rindex),
sizeof(struct gfs2_rindex));
if (!error)
@@ -174,23 +183,27 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane)
memset(rgd, 0, sizeof(struct rgrp_list));
osi_list_add_prev(&rgd->list, &sdp->rglist);
- gfs2_rindex_in(&rgd->ri, (char *)&buf);
+ gfs2_rindex_in(&rgd->ri, (char *)&buf.bufgfs2);
rgd->start = rgd->ri.ri_addr;
if (prev_rgd) {
/* If rg addresses go backwards, it's not sane
(or it's converted from gfs1). */
- if (prev_rgd->start >= rgd->start)
- *sane = 0;
- /* If rg lengths are not consistent, it's not sane
- (or it's converted from gfs1). The first RG will
- be a different length due to space allocated for
- the superblock, so we can't detect this until
- we check rgrp 3, when we can compare the distance
- between rgrp 1 and rgrp 2. */
- if (rg > 2 && prev_length &&
- prev_length != rgd->start - prev_rgd->start)
- *sane = 0;
+ if (!sdp->gfs1) {
+ if (prev_rgd->start >= rgd->start)
+ *sane = 0;
+ /* If rg lengths are not consistent, it's not
+ sane (or it's converted from gfs1). The
+ first RG will be a different length due to
+ space allocated for the superblock, so we
+ can't detect this until we check rgrp 3,
+ when we can compare the distance between
+ rgrp 1 and rgrp 2. */
+ if (rg > 2 && prev_length &&
+ prev_length != rgd->start -
+ prev_rgd->start)
+ *sane = 0;
+ }
prev_length = rgd->start - prev_rgd->start;
prev_rgd->length = prev_length;
}
12 years, 8 months
gfs2-utils: master - libgfs2: Make check_sb and read_sb operate on gfs1
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 78d1bdc636de8dca788d0bcebe0128a899f2bb29
Parent: 42827d8c37d21218b7dec0570599af3ffc33f13e
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Aug 12 14:46:22 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:51:07 2011 -0500
libgfs2: Make check_sb and read_sb operate on gfs1
This patch adds "allow_gfs1" parameters to the read_sb and check_sb functions.
This will allow gfs2-utils to read and operate on gfs1 file systems in
follow-up patches.
rhbz#675723
---
gfs2/edit/savemeta.c | 38 +++++++++-------------------
gfs2/fsck/initialize.c | 4 +-
gfs2/fsck/util.c | 5 ++-
gfs2/libgfs2/libgfs2.h | 28 +++++++++++++++++++--
gfs2/libgfs2/super.c | 63 +++++++++++++++++++++++++++++-------------------
gfs2/mkfs/main_grow.c | 2 +-
6 files changed, 81 insertions(+), 59 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index e8bcf8f..081ad23 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -630,7 +630,7 @@ static int next_rg_freemeta(struct gfs2_sbd *sdp, struct rgrp_list *rgd,
void savemeta(char *out_fn, int saveoption, int gziplevel)
{
- int slow;
+ int slow, ret;
osi_list_t *tmp;
int rgcount;
uint64_t jindex_block;
@@ -668,26 +668,13 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
fprintf(stderr, "Bad constants (1)\n");
exit(-1);
}
- if(sbd.gfs1) {
- sbd.bsize = sbd.sd_sb.sb_bsize;
- sbd.sd_inptrs = (sbd.bsize -
- sizeof(struct gfs_indirect)) /
- sizeof(uint64_t);
- sbd.sd_diptrs = (sbd.bsize -
- sizeof(struct gfs_dinode)) /
- sizeof(uint64_t);
- } else {
- if (read_sb(&sbd) < 0)
- slow = TRUE;
- else {
- sbd.sd_inptrs = (sbd.bsize -
- sizeof(struct gfs2_meta_header)) /
- sizeof(uint64_t);
- sbd.sd_diptrs = (sbd.bsize -
- sizeof(struct gfs2_dinode)) /
- sizeof(uint64_t);
- }
+ ret = read_sb(&sbd, 1);
+ if (ret < 0) {
+ slow = TRUE;
+ sbd.gfs1 = 0;
}
+ if (sbd.gfs1)
+ sbd.bsize = sbd.sd_sb.sb_bsize;
}
last_fs_block = lseek(sbd.device_fd, 0, SEEK_END) / sbd.bsize;
printf("There are %llu blocks of %u bytes in the destination "
@@ -913,20 +900,19 @@ static int restore_data(int fd, gzFile *gzin_fd, int printblocksonly,
}
if (first) {
struct gfs2_sb bufsb;
+ int ret;
dummy_bh.b_data = (char *)&bufsb;
memcpy(&bufsb, savedata->buf, sizeof(bufsb));
gfs2_sb_in(&sbd.sd_sb, &dummy_bh);
sbd1 = (struct gfs_sb *)&sbd.sd_sb;
- if (sbd1->sb_fs_format == GFS_FORMAT_FS &&
- sbd1->sb_header.mh_type == GFS_METATYPE_SB &&
- sbd1->sb_header.mh_format == GFS_FORMAT_SB &&
- sbd1->sb_multihost_format == GFS_FORMAT_MULTI) {
- sbd.gfs1 = TRUE;
- } else if (check_sb(&sbd.sd_sb)) {
+ ret = check_sb(&sbd.sd_sb, 1);
+ if (ret < 0) {
fprintf(stderr,"Error: Invalid superblock data.\n");
return -1;
}
+ if (ret == 1)
+ sbd.gfs1 = TRUE;
sbd.bsize = sbd.sd_sb.sb_bsize;
if (find_highblk)
;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 2506108..18d13cc 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1160,7 +1160,7 @@ static int fill_super_block(struct gfs2_sbd *sdp)
log_crit(_("Bad constants (1)\n"));
exit(-1);
}
- if (read_sb(sdp) < 0) {
+ if (read_sb(sdp, 0) < 0) {
/* First, check for a gfs1 (not gfs2) file system */
if (sdp->sd_sb.sb_header.mh_magic == GFS2_MAGIC &&
sdp->sd_sb.sb_header.mh_type == GFS2_METATYPE_SB)
@@ -1169,7 +1169,7 @@ static int fill_super_block(struct gfs2_sbd *sdp)
if (sb_repair(sdp) != 0)
return -1; /* unrepairable, so exit */
/* Now that we've tried to repair it, re-read it. */
- if (read_sb(sdp) < 0)
+ if (read_sb(sdp, 0) < 0)
return -1;
}
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 2a35989..d496833 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -29,7 +29,7 @@ void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked)
if (blks_checked - last_reported_fblock < one_percent)
return;
- last_reported_block = blks_checked;
+ last_reported_fblock = blks_checked;
gettimeofday(&tv, NULL);
if (!seconds)
seconds = tv.tv_sec;
@@ -64,7 +64,8 @@ void warm_fuzzy_stuff(uint64_t block)
if (!one_percent)
one_percent = last_fs_block / 100;
- if (block - last_reported_block >= one_percent) {
+ if (!last_reported_block ||
+ block - last_reported_block >= one_percent) {
last_reported_block = block;
gettimeofday(&tv, NULL);
if (!seconds)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 5f66312..82c39f1 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -493,7 +493,29 @@ extern int write_journal(struct gfs2_sbd *sdp, unsigned int j,
extern int device_size(int fd, uint64_t *bytes);
-/* gfs1.c - GFS1 backward compatibility functions */
+/* gfs1.c - GFS1 backward compatibility structures and functions */
+
+#define GFS_FORMAT_SB (100) /* Super-Block */
+#define GFS_METATYPE_SB (1) /* Super-Block */
+#define GFS_FORMAT_FS (1309) /* Filesystem (all-encompassing) */
+#define GFS_FORMAT_MULTI (1401) /* Multi-Host */
+/* GFS1 Dinode types */
+#define GFS_FILE_NON (0)
+#define GFS_FILE_REG (1) /* regular file */
+#define GFS_FILE_DIR (2) /* directory */
+#define GFS_FILE_LNK (5) /* link */
+#define GFS_FILE_BLK (7) /* block device node */
+#define GFS_FILE_CHR (8) /* character device node */
+#define GFS_FILE_FIFO (101) /* fifo/pipe */
+#define GFS_FILE_SOCK (102) /* socket */
+
+/* GFS 1 journal block types: */
+#define GFS_LOG_DESC_METADATA (300) /* metadata */
+#define GFS_LOG_DESC_IUL (400) /* unlinked inode */
+#define GFS_LOG_DESC_IDA (401) /* de-allocated inode */
+#define GFS_LOG_DESC_Q (402) /* quota */
+#define GFS_LOG_DESC_LAST (500) /* final in a logged transaction */
+
struct gfs_indirect {
struct gfs2_meta_header in_header;
@@ -672,8 +694,8 @@ extern int gfs2_next_rg_meta(struct rgrp_list *rgd, uint64_t *block,
extern int gfs2_next_rg_metatype(struct gfs2_sbd *sdp, struct rgrp_list *rgd,
uint64_t *block, uint32_t type, int first);
/* super.c */
-extern int check_sb(struct gfs2_sb *sb);
-extern int read_sb(struct gfs2_sbd *sdp);
+extern int check_sb(struct gfs2_sb *sb, int allow_gfs);
+extern int read_sb(struct gfs2_sbd *sdp, int allow_gfs);
extern int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane);
extern int ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int *sane);
extern int write_sb(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 995e503..ee18850 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -20,9 +20,9 @@
* read and that the sizes of the various on-disk structures have not
* changed.
*
- * Returns: 0 on success, -1 on failure
+ * Returns: -1 on failure, 1 if this is gfs (gfs1), 2 if this is gfs2
*/
-int check_sb(struct gfs2_sb *sb)
+int check_sb(struct gfs2_sb *sb, int allow_gfs)
{
if (sb->sb_header.mh_magic != GFS2_MAGIC ||
sb->sb_header.mh_type != GFS2_METATYPE_SB) {
@@ -33,13 +33,16 @@ int check_sb(struct gfs2_sb *sb)
sb->sb_header.mh_type);
return -EINVAL;
}
- /* If format numbers match exactly, we're done. */
- if (sb->sb_fs_format != GFS2_FORMAT_FS ||
- sb->sb_multihost_format != GFS2_FORMAT_MULTI) {
+ if (sb->sb_fs_format == GFS_FORMAT_FS &&
+ sb->sb_header.mh_format == GFS_FORMAT_SB &&
+ sb->sb_multihost_format == GFS_FORMAT_MULTI) {
+ if (allow_gfs)
+ return 1;
+
log_crit("Old gfs1 file system detected.\n");
return -EINVAL;
}
- return 0;
+ return 2;
}
@@ -51,31 +54,44 @@ int check_sb(struct gfs2_sb *sb)
* initializes various constants maintained in the super
* block
*
- * Returns: 0 on success, -1 on failure.
+ * allow_gfs - passed in as 1 if we're allowed to accept gfs1 file systems
+ *
+ * Returns: 0 on success, -1 on failure
+ * sdp->gfs1 will be set if this is gfs (gfs1)
*/
-int read_sb(struct gfs2_sbd *sdp)
+int read_sb(struct gfs2_sbd *sdp, int allow_gfs)
{
struct gfs2_buffer_head *bh;
uint64_t space = 0;
unsigned int x;
- int error;
+ int ret;
bh = bread(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift);
gfs2_sb_in(&sdp->sd_sb, bh);
brelse(bh);
- error = check_sb(&sdp->sd_sb);
- if (error)
- goto out;
-
+ ret = check_sb(&sdp->sd_sb, allow_gfs);
+ if (ret < 0)
+ return ret;
+ if (ret == 1)
+ sdp->gfs1 = 1;
sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT;
sdp->bsize = sdp->sd_sb.sb_bsize;
- sdp->sd_diptrs =
- (sdp->sd_sb.sb_bsize-sizeof(struct gfs2_dinode)) /
- sizeof(uint64_t);
- sdp->sd_inptrs =
- (sdp->sd_sb.sb_bsize-sizeof(struct gfs2_meta_header)) /
- sizeof(uint64_t);
+ if (sdp->gfs1) {
+ sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
+ sizeof(struct gfs_dinode)) /
+ sizeof(uint64_t);
+ sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
+ sizeof(struct gfs_indirect)) /
+ sizeof(uint64_t);
+ } else {
+ sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
+ sizeof(struct gfs2_dinode)) /
+ sizeof(uint64_t);
+ sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
+ sizeof(struct gfs2_meta_header)) /
+ sizeof(uint64_t);
+ }
sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
sdp->sd_hash_bsize = sdp->bsize / 2;
sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
@@ -92,8 +108,7 @@ int read_sb(struct gfs2_sbd *sdp)
}
if (x > GFS2_MAX_META_HEIGHT){
log_err("Bad max metadata height.\n");
- error = -1;
- goto out;
+ return -1;
}
sdp->sd_jheightsize[0] = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
@@ -108,14 +123,12 @@ int read_sb(struct gfs2_sbd *sdp)
sdp->sd_max_jheight = x;
if(sdp->sd_max_jheight > GFS2_MAX_META_HEIGHT) {
log_err("Bad max jheight.\n");
- error = -1;
+ return -1;
}
sdp->fssize = lseek(sdp->device_fd, 0, SEEK_END) / sdp->sd_sb.sb_bsize;
sdp->sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->bsize;
- out:
-
- return error;
+ return 0;
}
/**
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 0eca396..48e6377 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -354,7 +354,7 @@ main_grow(int argc, char *argv[])
log_crit(_("Bad constants (1)\n"));
exit(-1);
}
- if(read_sb(sdp) < 0)
+ if (read_sb(sdp, 0) < 0)
die( _("gfs: Error reading superblock.\n"));
if (fix_device_geometry(sdp)) {
12 years, 8 months
gfs2-utils: master - libgfs1: Add gfs1 variable to superblock structure
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 42827d8c37d21218b7dec0570599af3ffc33f13e
Parent: 3c53b7921867efc25bf0b41cc44f8070a8c0f063
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 09:45:36 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:48:47 2011 -0500
libgfs1: Add gfs1 variable to superblock structure
This patch adds a "gfs1" variable to the in-core superblock structure
for utils that can operate on both gfs and gfs2 file systems and need
to determine which is which.
rhbz#675723
---
gfs2/edit/extended.c | 10 ++--
gfs2/edit/gfs2hex.c | 13 +++---
gfs2/edit/hexedit.c | 111 ++++++++++++++++++++++++------------------------
gfs2/edit/hexedit.h | 3 +-
gfs2/edit/savemeta.c | 30 ++++++------
gfs2/libgfs2/libgfs2.h | 1 +
6 files changed, 84 insertions(+), 84 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 3cf6f8b..575c387 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -66,7 +66,7 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
iinf->ii[x].dirents = 0;
memset(&iinf->ii[x].dirent, 0, sizeof(struct gfs2_dirents));
}
- for (x = (gfs1 ? sizeof(struct gfs_indirect):
+ for (x = (sbd.gfs1 ? sizeof(struct gfs_indirect):
sizeof(struct gfs2_meta_header)), y = 0;
x < sbd.bsize;
x += sizeof(uint64_t), y++) {
@@ -251,7 +251,7 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
/* ------------------------------------------------------------------------ */
static void print_inode_type(__be16 de_type)
{
- if (gfs1) {
+ if (sbd.gfs1) {
switch(de_type) {
case GFS_FILE_NON:
print_gfs2("Unknown");
@@ -515,7 +515,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
roff = print_entry_ndx * risize();
- if (gfs1)
+ if (sbd.gfs1)
error = gfs1_readi(dip, (void *)&rbuf, roff, risize());
else
error = gfs2_readi(dip, (void *)&rbuf, roff, risize());
@@ -543,7 +543,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
struct gfs2_buffer_head *tmp_bh;
tmp_bh = bread(&sbd, ri.ri_addr);
- if (gfs1) {
+ if (sbd.gfs1) {
struct gfs_rgrp rg1;
gfs_rgrp_in(&rg1, tmp_bh);
gfs_rgrp_print(&rg1);
@@ -664,7 +664,7 @@ int display_extended(void)
else if (display_indirect(indirect, indirect_blocks, 0, 0) == 0)
return -1;
else if (block_is_rglist()) {
- if (gfs1)
+ if (sbd.gfs1)
tmp_bh = bread(&sbd, sbd1->sb_rindex_di.no_addr);
else
tmp_bh = bread(&sbd, masterblock("rindex"));
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 8dbd7e5..40959c7 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -45,7 +45,6 @@ uint64_t block = 0;
int blockhist = 0;
struct iinfo *indirect;
int indirect_blocks;
-int gfs1 = 0;
uint64_t block_in_mem = -1;
struct gfs2_sbd sbd;
uint64_t starting_blk;
@@ -277,7 +276,7 @@ void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh)
unsigned int x, y, ptroff = 0;
uint64_t p, last;
int isdir = !!(S_ISDIR(dine->di_mode)) ||
- (gfs1 && dine->__pad1 == GFS_FILE_DIR);
+ (sbd.gfs1 && dine->__pad1 == GFS_FILE_DIR);
indirect_blocks = 0;
memset(indirect, 0, sizeof(indirect));
@@ -468,11 +467,11 @@ static void gfs2_sb_print2(struct gfs2_sb *sbp2)
pv(sbp2, sb_fs_format, "%u", "0x%x");
pv(sbp2, sb_multihost_format, "%u", "0x%x");
- if (gfs1)
+ if (sbd.gfs1)
pv(sbd1, sb_flags, "%u", "0x%x");
pv(sbp2, sb_bsize, "%u", "0x%x");
pv(sbp2, sb_bsize_shift, "%u", "0x%x");
- if (gfs1) {
+ if (sbd.gfs1) {
pv(sbd1, sb_seg_size, "%u", "0x%x");
gfs2_inum_print2("jindex ino", &sbd1->sb_jindex_di);
gfs2_inum_print2("rindex ino", &sbd1->sb_rindex_di);
@@ -483,7 +482,7 @@ static void gfs2_sb_print2(struct gfs2_sb *sbp2)
pv(sbp2, sb_lockproto, "%s", NULL);
pv(sbp2, sb_locktable, "%s", NULL);
- if (gfs1) {
+ if (sbd.gfs1) {
gfs2_inum_print2("quota ino ", &gfs1_quota_di);
gfs2_inum_print2("license ", &gfs1_license_di);
}
@@ -575,7 +574,7 @@ int display_gfs2(void)
break;
case GFS2_METATYPE_RG:
- if (gfs1) {
+ if (sbd.gfs1) {
struct gfs1_rgrp rg1;
gfs1_rgrp_in(&rg1, bh);
@@ -608,7 +607,7 @@ int display_gfs2(void)
break;
case GFS2_METATYPE_LH:
- if (gfs1) {
+ if (sbd.gfs1) {
gfs_log_header_in(&lh1, bh);
gfs_log_header_print(&lh1);
} else {
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index d445f05..651c6f6 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1069,13 +1069,14 @@ int display_block_type(int from_restore)
print_gfs2("of %llu (0x%llx) ", max_block, max_block);
if (block == RGLIST_DUMMY_BLOCK) {
ret_type = GFS2_METATYPE_RG;
- struct_len = gfs1 ? sizeof(struct gfs_rgrp) : sizeof(struct gfs2_rgrp);
+ struct_len = sbd.gfs1 ? sizeof(struct gfs_rgrp) :
+ sizeof(struct gfs2_rgrp);
}
else if ((ret_type = get_block_type(bh))) {
switch (*(bh->b_data + 7)) {
case GFS2_METATYPE_SB: /* 1 */
print_gfs2("(superblock)");
- if (gfs1)
+ if (sbd.gfs1)
struct_len = sizeof(struct gfs_sb);
else
struct_len = sizeof(struct gfs2_sb);
@@ -1094,7 +1095,7 @@ int display_block_type(int from_restore)
break;
case GFS2_METATYPE_IN: /* 5 */
print_gfs2("(indir blklist)");
- if (gfs1)
+ if (sbd.gfs1)
struct_len = sizeof(struct gfs_indirect);
else
struct_len = sizeof(struct gfs2_meta_header);
@@ -1113,7 +1114,7 @@ int display_block_type(int from_restore)
break;
case GFS2_METATYPE_LD:
print_gfs2("(log descriptor)");
- if (gfs1)
+ if (sbd.gfs1)
struct_len = sizeof(struct gfs_log_descriptor);
else
struct_len =
@@ -1168,7 +1169,7 @@ int display_block_type(int from_restore)
print_gfs2("(p.%d of %d--%s)", pgnum + 1,
(sbd.bsize % screen_chunk_size) > 0 ?
sbd.bsize / screen_chunk_size + 1 : sbd.bsize /
- screen_chunk_size, allocdesc[gfs1][type]);
+ screen_chunk_size, allocdesc[sbd.gfs1][type]);
/*eol(9);*/
if ((*(bh->b_data + 7) == GFS2_METATYPE_RG)) {
int ptroffset = edit_row[dmode] * 16 + edit_col[dmode];
@@ -1185,7 +1186,7 @@ int display_block_type(int from_restore)
for (b = blknum; b < blknum + 4; b++) {
btype = gfs2_get_bitmap(&sbd, b, rgd);
print_gfs2("0x%x-%s ", b,
- allocdesc[gfs1][btype]);
+ allocdesc[sbd.gfs1][btype]);
}
}
} else if ((*(bh->b_data + 7) == GFS2_METATYPE_RB)) {
@@ -1217,7 +1218,7 @@ int display_block_type(int from_restore)
for (b = blknum; b < blknum + 4; b++) {
btype = gfs2_get_bitmap(&sbd, b, rgd);
print_gfs2("0x%x-%s ", b,
- allocdesc[gfs1][btype]);
+ allocdesc[sbd.gfs1][btype]);
}
}
}
@@ -1226,12 +1227,12 @@ int display_block_type(int from_restore)
}
if (block == sbd.sd_sb.sb_root_dir.no_addr)
print_gfs2("--------------- Root directory ------------------");
- else if (!gfs1 && block == sbd.sd_sb.sb_master_dir.no_addr)
+ else if (!sbd.gfs1 && block == sbd.sd_sb.sb_master_dir.no_addr)
print_gfs2("-------------- Master directory -----------------");
- else if (!gfs1 && block == RGLIST_DUMMY_BLOCK)
+ else if (!sbd.gfs1 && block == RGLIST_DUMMY_BLOCK)
print_gfs2("------------------ RG List ----------------------");
else {
- if (gfs1) {
+ if (sbd.gfs1) {
if (block == sbd1->sb_rindex_di.no_addr)
print_gfs2("---------------- rindex file -------------------");
else if (block == gfs1_quota_di.no_addr)
@@ -1437,7 +1438,7 @@ static int hexdump(uint64_t startaddr, int len)
l+=16;
print_entry_ndx++;
} /* while */
- if (gfs1) {
+ if (sbd.gfs1) {
COLORS_NORMAL;
print_gfs2(" *** This seems to be a GFS-1 file system ***");
eol(0);
@@ -1481,7 +1482,7 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
uint64_t foffset, gfs1_adj = 0;
foffset = rg * risize();
- if (gfs1) {
+ if (sbd.gfs1) {
uint64_t sd_jbsize =
(sbd.bsize - sizeof(struct gfs2_meta_header));
@@ -1553,7 +1554,7 @@ static uint64_t get_rg_addr(int rgnum)
uint64_t rgblk = 0, gblock;
struct gfs2_inode *riinode;
- if (gfs1)
+ if (sbd.gfs1)
gblock = sbd1->sb_rindex_di.no_addr;
else
gblock = masterblock("rindex");
@@ -1585,7 +1586,7 @@ static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
rgblk = get_rg_addr(rgnum);
rbh = bread(&sbd, rgblk);
- if (gfs1)
+ if (sbd.gfs1)
gfs_rgrp_in(&rg.rg1, rbh);
else
gfs2_rgrp_in(&rg.rg2, rbh);
@@ -1594,7 +1595,7 @@ static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
rgnum, (unsigned long long)rgblk,
(unsigned long long)rgblk, rg.rg2.rg_flags, new_flags);
rg.rg2.rg_flags = new_flags;
- if (gfs1)
+ if (sbd.gfs1)
gfs_rgrp_out(&rg.rg1, rbh);
else
gfs2_rgrp_out(&rg.rg2, rbh);
@@ -1604,7 +1605,7 @@ static void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full)
print_gfs2("RG #%d", rgnum);
print_gfs2(" located at: %llu (0x%llx)", rgblk, rgblk);
eol(0);
- if (gfs1)
+ if (sbd.gfs1)
gfs_rgrp_print(&rg.rg1);
else
gfs2_rgrp_print(&rg.rg2);
@@ -1640,7 +1641,7 @@ int has_indirect_blocks(void)
if (indirect_blocks || gfs2_struct_type == GFS2_METATYPE_SB ||
gfs2_struct_type == GFS2_METATYPE_LF ||
(gfs2_struct_type == GFS2_METATYPE_DI &&
- (S_ISDIR(di.di_mode) || (gfs1 && di.__pad1 == GFS_FILE_DIR))))
+ (S_ISDIR(di.di_mode) || (sbd.gfs1 && di.__pad1 == GFS_FILE_DIR))))
return TRUE;
return FALSE;
}
@@ -1650,7 +1651,7 @@ int has_indirect_blocks(void)
/* ------------------------------------------------------------------------ */
int block_is_rindex(void)
{
- if ((gfs1 && block == sbd1->sb_rindex_di.no_addr) ||
+ if ((sbd.gfs1 && block == sbd1->sb_rindex_di.no_addr) ||
(block == masterblock("rindex")))
return TRUE;
return FALSE;
@@ -1661,7 +1662,7 @@ int block_is_rindex(void)
/* ------------------------------------------------------------------------ */
int block_is_jindex(void)
{
- if ((gfs1 && block == sbd1->sb_jindex_di.no_addr))
+ if ((sbd.gfs1 && block == sbd1->sb_jindex_di.no_addr))
return TRUE;
return FALSE;
}
@@ -1671,7 +1672,7 @@ int block_is_jindex(void)
/* ------------------------------------------------------------------------ */
int block_is_inum_file(void)
{
- if (!gfs1 && block == masterblock("inum"))
+ if (!sbd.gfs1 && block == masterblock("inum"))
return TRUE;
return FALSE;
}
@@ -1681,9 +1682,9 @@ int block_is_inum_file(void)
/* ------------------------------------------------------------------------ */
int block_is_statfs_file(void)
{
- if (gfs1 && block == gfs1_license_di.no_addr)
+ if (sbd.gfs1 && block == gfs1_license_di.no_addr)
return TRUE;
- if (!gfs1 && block == masterblock("statfs"))
+ if (!sbd.gfs1 && block == masterblock("statfs"))
return TRUE;
return FALSE;
}
@@ -1693,9 +1694,9 @@ int block_is_statfs_file(void)
/* ------------------------------------------------------------------------ */
int block_is_quota_file(void)
{
- if (gfs1 && block == gfs1_quota_di.no_addr)
+ if (sbd.gfs1 && block == gfs1_quota_di.no_addr)
return TRUE;
- if (!gfs1 && block == masterblock("quota"))
+ if (!sbd.gfs1 && block == masterblock("quota"))
return TRUE;
return FALSE;
}
@@ -1705,7 +1706,7 @@ int block_is_quota_file(void)
/* ------------------------------------------------------------------------ */
int block_is_per_node(void)
{
- if (!gfs1 && block == masterblock("per_node"))
+ if (!sbd.gfs1 && block == masterblock("per_node"))
return TRUE;
return FALSE;
}
@@ -1718,7 +1719,7 @@ int block_is_in_per_node(void)
int d;
struct gfs2_inode *per_node_di;
- if (gfs1)
+ if (sbd.gfs1)
return FALSE;
per_node_di = inode_read(&sbd, masterblock("per_node"));
@@ -1775,7 +1776,7 @@ static void read_superblock(int fd)
sbd1->sb_multihost_format == GFS_FORMAT_MULTI) {
struct gfs_sb *sbbuf = (struct gfs_sb *)bh->b_data;
- gfs1 = TRUE;
+ sbd.gfs1 = TRUE;
sbd1->sb_flags = be32_to_cpu(sbbuf->sb_flags);
sbd1->sb_seg_size = be32_to_cpu(sbbuf->sb_seg_size);
gfs2_inum_in(&sbd1->sb_rindex_di, (void *)&sbbuf->sb_rindex_di);
@@ -1783,12 +1784,12 @@ static void read_superblock(int fd)
gfs2_inum_in(&gfs1_license_di, (void *)&sbbuf->sb_license_di);
}
else
- gfs1 = FALSE;
+ sbd.gfs1 = FALSE;
sbd.bsize = sbd.sd_sb.sb_bsize;
if (!sbd.bsize)
sbd.bsize = GFS2_DEFAULT_BSIZE;
compute_constants(&sbd);
- if (gfs1 || (sbd.sd_sb.sb_header.mh_magic == GFS2_MAGIC &&
+ if (sbd.gfs1 || (sbd.sd_sb.sb_header.mh_magic == GFS2_MAGIC &&
sbd.sd_sb.sb_header.mh_type == GFS2_METATYPE_SB))
block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.bsize);
else {
@@ -1800,7 +1801,7 @@ static void read_superblock(int fd)
(unsigned long long)sbd.device.length << GFS2_BASIC_BLOCK_SHIFT);
exit(-1);
}
- if(gfs1) {
+ if(sbd.gfs1) {
sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs_indirect)) /
sizeof(uint64_t);
sbd.sd_diptrs = (sbd.bsize - sizeof(struct gfs_dinode)) /
@@ -1855,7 +1856,7 @@ int display(int identify_only)
uint64_t blk;
if (block == RGLIST_DUMMY_BLOCK) {
- if (gfs1)
+ if (sbd.gfs1)
blk = sbd1->sb_rindex_di.no_addr;
else
blk = masterblock("rindex");
@@ -2015,7 +2016,7 @@ static uint64_t find_journal_block(const char *journal, uint64_t *j_size)
journal_num = atoi(journal + 7);
/* Figure out the block of the jindex file */
- if (gfs1)
+ if (sbd.gfs1)
jindex_block = sbd1->sb_jindex_di.no_addr;
else
jindex_block = masterblock("jindex");
@@ -2024,10 +2025,10 @@ static uint64_t find_journal_block(const char *journal, uint64_t *j_size)
/* get the dinode data from it. */
gfs2_dinode_in(&di, jindex_bh); /* parse disk inode to struct*/
- if (!gfs1)
+ if (!sbd.gfs1)
do_dinode_extended(&di, jindex_bh); /* parse dir. */
- if (gfs1) {
+ if (sbd.gfs1) {
struct gfs2_inode *jiinode;
struct gfs_jindex ji;
@@ -2206,36 +2207,36 @@ uint64_t check_keywords(const char *kword)
else if (!strcmp(kword, "root") || !strcmp(kword, "rootdir"))
blk = sbd.sd_sb.sb_root_dir.no_addr;
else if (!strcmp(kword, "master")) {
- if (!gfs1)
+ if (!sbd.gfs1)
blk = sbd.sd_sb.sb_master_dir.no_addr;
else
fprintf(stderr, "This is GFS1; there's no master directory.\n");
}
else if (!strcmp(kword, "jindex")) {
- if (gfs1)
+ if (sbd.gfs1)
blk = sbd1->sb_jindex_di.no_addr;
else
blk = masterblock("jindex"); /* journal index */
}
- else if (!gfs1 && !strcmp(kword, "per_node"))
+ else if (!sbd.gfs1 && !strcmp(kword, "per_node"))
blk = masterblock("per_node");
- else if (!gfs1 && !strcmp(kword, "inum"))
+ else if (!sbd.gfs1 && !strcmp(kword, "inum"))
blk = masterblock("inum");
else if (!strcmp(kword, "statfs")) {
- if (gfs1)
+ if (sbd.gfs1)
blk = gfs1_license_di.no_addr;
else
blk = masterblock("statfs");
}
else if (!strcmp(kword, "rindex") || !strcmp(kword, "rgindex")) {
- if (gfs1)
+ if (sbd.gfs1)
blk = sbd1->sb_rindex_di.no_addr;
else
blk = masterblock("rindex");
} else if (!strcmp(kword, "rgs")) {
blk = RGLIST_DUMMY_BLOCK;
} else if (!strcmp(kword, "quota")) {
- if (gfs1)
+ if (sbd.gfs1)
blk = gfs1_quota_di.no_addr;
else
blk = masterblock("quota");
@@ -2551,7 +2552,7 @@ static void find_change_block_alloc(int *newval)
printf("Error: value %d is not valid.\nValid values are:\n",
*newval);
for (i = GFS2_BLKST_FREE; i <= GFS2_BLKST_DINODE; i++)
- printf("%d - %s\n", i, allocdesc[gfs1][i]);
+ printf("%d - %s\n", i, allocdesc[sbd.gfs1][i]);
gfs2_rgrp_free(&sbd.rglist);
exit(-1);
}
@@ -2574,7 +2575,7 @@ static void find_change_block_alloc(int *newval)
"an rgrp).\n");
exit(-1);
}
- printf("%d (%s)\n", type, allocdesc[gfs1][type]);
+ printf("%d (%s)\n", type, allocdesc[sbd.gfs1][type]);
}
gfs2_rgrp_relse(rgd);
} else {
@@ -3058,7 +3059,7 @@ static int print_ld_blocks(const uint64_t *b, const char *end, int start_line)
bcount++;
}
b++;
- if (gfs1)
+ if (sbd.gfs1)
b++;
}
eol(0);
@@ -3177,14 +3178,14 @@ static void dump_journal(const char *journal)
jblock = find_journal_block(journal, &j_size);
if (!jblock)
return;
- if (!gfs1) {
+ if (!sbd.gfs1) {
j_bh = bread(&sbd, jblock);
j_inode = inode_get(&sbd, j_bh);
jbuf = malloc(sbd.bsize);
}
- for (jb = 0; jb < j_size; jb += (gfs1 ? 1:sbd.bsize)) {
- if (gfs1) {
+ for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1:sbd.bsize)) {
+ if (sbd.gfs1) {
if (j_bh)
brelse(j_bh);
j_bh = bread(&sbd, jblock + jb);
@@ -3219,21 +3220,21 @@ static void dump_journal(const char *journal)
"Quota", "Final Entry", "Unknown"}};
print_gfs2("0x%llx (j+%4llx): Log descriptor, ",
- abs_block, jb / (gfs1 ? 1 : sbd.bsize));
+ abs_block, jb / (sbd.gfs1 ? 1 : sbd.bsize));
gfs2_log_descriptor_in(&ld, &dummy_bh);
print_gfs2("type %d ", ld.ld_type);
for (ltndx = 0;; ltndx++) {
- if (ld.ld_type == logtypes[gfs1][ltndx] ||
- logtypes[gfs1][ltndx] == 0)
+ if (ld.ld_type == logtypes[sbd.gfs1][ltndx] ||
+ logtypes[sbd.gfs1][ltndx] == 0)
break;
}
- print_gfs2("(%s) ", logtypestr[gfs1][ltndx]);
+ print_gfs2("(%s) ", logtypestr[sbd.gfs1][ltndx]);
print_gfs2("len:%u, data1: %u",
ld.ld_length, ld.ld_data1);
eol(0);
print_gfs2(" ");
- if (gfs1)
+ if (sbd.gfs1)
b = (uint64_t *)(dummy_bh.b_data +
sizeof(struct gfs_log_descriptor));
else
@@ -3247,7 +3248,7 @@ static void dump_journal(const char *journal)
struct gfs2_log_header lh;
struct gfs_log_header lh1;
- if (gfs1) {
+ if (sbd.gfs1) {
gfs_log_header_in(&lh1, &dummy_bh);
check_journal_wrap(lh1.lh_sequence,
&highest_seq);
@@ -3269,7 +3270,7 @@ static void dump_journal(const char *journal)
lh.lh_tail, lh.lh_blkno);
}
eol(0);
- } else if (gfs1 && ld_blocks > 0) {
+ } else if (sbd.gfs1 && ld_blocks > 0) {
print_gfs2("0x%llx (j+%4llx): GFS log descriptor"
" continuation block", abs_block, jb);
eol(0);
@@ -3660,7 +3661,7 @@ int main(int argc, char *argv[])
read_superblock(fd);
max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
strcpy(sbd.device_name, device);
- if (gfs1)
+ if (sbd.gfs1)
edit_row[GFS2_MODE]++;
else
read_master_dir();
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index cc87925..8a3c615 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -81,7 +81,6 @@ extern char device[NAME_MAX];
extern int identify;
extern int color_scheme;
extern WINDOW *wind;
-extern int gfs1;
extern int editing;
extern uint64_t temp_blk;
extern uint64_t starting_blk;
@@ -231,7 +230,7 @@ extern enum dsp_mode dmode;
/* ------------------------------------------------------------------------ */
static inline int risize(void)
{
- if (gfs1)
+ if (sbd.gfs1)
return sizeof(struct gfs_rindex);
else
return sizeof(struct gfs2_rindex);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 0c567da..e8bcf8f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -122,12 +122,12 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
*gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_DI: /* 4 (disk inode) */
- if (gfs1)
+ if (sbd.gfs1)
inode = inode_get(&sbd, lbh);
else
inode = gfs_inode_get(&sbd, lbh);
if (S_ISDIR(inode->i_di.di_mode) ||
- (gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
+ (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
*gstruct_len = sbd.bsize;
else if (!inode->i_di.di_height && !block_is_systemfile() &&
!S_ISDIR(inode->i_di.di_mode))
@@ -145,7 +145,7 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
*gstruct_len = sbd.bsize;
break;
case GFS2_METATYPE_LH: /* 8 (log header) */
- if (gfs1)
+ if (sbd.gfs1)
*gstruct_len = 512; /* gfs copies the log header
twice and compares the copy,
so we need to save all 512
@@ -456,7 +456,7 @@ static void save_inode_data(struct metafd *mfd)
for (i = 0; i < GFS2_MAX_META_HEIGHT; i++)
osi_list_init(&metalist[i]);
metabh = bread(&sbd, block);
- if (gfs1)
+ if (sbd.gfs1)
inode = inode_get(&sbd, metabh);
else
inode = gfs_inode_get(&sbd, metabh);
@@ -468,7 +468,7 @@ static void save_inode_data(struct metafd *mfd)
the hash table exists, and we have to save the directory data. */
if (inode->i_di.di_flags & GFS2_DIF_EXHASH &&
(S_ISDIR(inode->i_di.di_mode) ||
- (gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR)))
+ (sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR)))
height++;
else if (height && !(inode->i_di.di_flags & GFS2_DIF_SYSTEM) &&
!block_is_systemfile() && !S_ISDIR(inode->i_di.di_mode))
@@ -565,7 +565,7 @@ static void get_journal_inode_blocks(void)
int amt;
struct gfs2_inode *j_inode = NULL;
- if (gfs1) {
+ if (sbd.gfs1) {
struct gfs_jindex ji;
char jbuf[sizeof(struct gfs_jindex)];
@@ -649,7 +649,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
lseek(sbd.device_fd, 0, SEEK_SET);
blks_saved = total_out = last_reported_block = 0;
- if (!gfs1)
+ if (!sbd.gfs1)
sbd.bsize = BUFSIZE;
if (!slow) {
if (device_geometry(&sbd)) {
@@ -662,13 +662,13 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
exit(-1);
}
osi_list_init(&sbd.rglist);
- if (!gfs1)
+ if (!sbd.gfs1)
sbd.sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE;
if (compute_constants(&sbd)) {
fprintf(stderr, "Bad constants (1)\n");
exit(-1);
}
- if(gfs1) {
+ if(sbd.gfs1) {
sbd.bsize = sbd.sd_sb.sb_bsize;
sbd.sd_inptrs = (sbd.bsize -
sizeof(struct gfs_indirect)) /
@@ -693,7 +693,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
printf("There are %llu blocks of %u bytes in the destination "
"device.\n", (unsigned long long)last_fs_block, sbd.bsize);
if (!slow) {
- if (gfs1) {
+ if (sbd.gfs1) {
sbd.md.riinode = inode_read(&sbd,
sbd1->sb_rindex_di.no_addr);
jindex_block = sbd1->sb_jindex_di.no_addr;
@@ -708,7 +708,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
}
lbh = bread(&sbd, jindex_block);
gfs2_dinode_in(&di, lbh);
- if (!gfs1)
+ if (!sbd.gfs1)
do_dinode_extended(&di, lbh);
brelse(lbh);
}
@@ -718,7 +718,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
printf("Reading resource groups...");
fflush(stdout);
- if (gfs1)
+ if (sbd.gfs1)
slow = gfs1_ri_update(&sbd, 0, &rgcount, 0);
else
slow = ri_update(&sbd, 0, &rgcount, &sane);
@@ -740,7 +740,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
save_block(sbd.device_fd, &mfd, 0x10 * (4096 / sbd.bsize));
/* If this is gfs1, save off the rindex because it's not
part of the file system as it is in gfs2. */
- if (gfs1) {
+ if (sbd.gfs1) {
int j;
block = sbd1->sb_rindex_di.no_addr;
@@ -922,7 +922,7 @@ static int restore_data(int fd, gzFile *gzin_fd, int printblocksonly,
sbd1->sb_header.mh_type == GFS_METATYPE_SB &&
sbd1->sb_header.mh_format == GFS_FORMAT_SB &&
sbd1->sb_multihost_format == GFS_FORMAT_MULTI) {
- gfs1 = TRUE;
+ sbd.gfs1 = TRUE;
} else if (check_sb(&sbd.sd_sb)) {
fprintf(stderr,"Error: Invalid superblock data.\n");
return -1;
@@ -937,7 +937,7 @@ static int restore_data(int fd, gzFile *gzin_fd, int printblocksonly,
"the destination device.\n\n",
(unsigned long long)last_fs_block, sbd.bsize);
} else {
- printf("This is %s metadata\n", gfs1 ?
+ printf("This is %s metadata\n", sbd.gfs1 ?
"gfs (not gfs2)" : "gfs2");
}
first = 0;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 73431fa..5f66312 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -243,6 +243,7 @@ struct gfs2_sbd {
uint32_t physical_block_size;
uint64_t rg_one_length;
uint64_t rg_length;
+ int gfs1;
};
struct metapath {
12 years, 8 months
gfs2-utils: master - fsck.gfs2: Change "if(" to "if ("
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 3c53b7921867efc25bf0b41cc44f8070a8c0f063
Parent: 650edf1c80d451159ce4ca3b01ddd40e326c0e6c
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 09:04:13 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:48:40 2011 -0500
fsck.gfs2: Change "if(" to "if ("
This patch changes all if and while statements to have a space before
the parenthesis so they are consistent.
rhbz#675723
---
gfs2/fsck/eattr.c | 8 ++--
gfs2/fsck/fs_recovery.c | 6 +-
gfs2/fsck/initialize.c | 30 ++++++------
gfs2/fsck/link.c | 2 +-
gfs2/fsck/lost_n_found.c | 10 ++--
gfs2/fsck/main.c | 14 +++---
gfs2/fsck/metawalk.c | 74 +++++++++++++++---------------
gfs2/fsck/pass1.c | 46 +++++++++---------
gfs2/fsck/pass1b.c | 22 ++++----
gfs2/fsck/pass1c.c | 28 ++++++------
gfs2/fsck/pass2.c | 114 +++++++++++++++++++++++-----------------------
gfs2/fsck/pass3.c | 44 +++++++++---------
gfs2/fsck/pass4.c | 36 +++++++-------
gfs2/fsck/pass5.c | 20 ++++----
gfs2/fsck/rgrepair.c | 2 +-
gfs2/fsck/util.c | 10 ++--
16 files changed, 233 insertions(+), 233 deletions(-)
diff --git a/gfs2/fsck/eattr.c b/gfs2/fsck/eattr.c
index cdcc956..3f95d93 100644
--- a/gfs2/fsck/eattr.c
+++ b/gfs2/fsck/eattr.c
@@ -18,25 +18,25 @@ int clear_eattr_entry (struct gfs2_inode *ip,
{
struct gfs2_sbd *sdp = ip->i_sbd;
- if(!ea_hdr->ea_name_len){
+ if (!ea_hdr->ea_name_len){
/* Skip this entry for now */
return 1;
}
- if(!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
+ if (!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
/* Skip invalid entry */
return 1;
}
- if(ea_hdr->ea_num_ptrs){
+ if (ea_hdr->ea_num_ptrs){
uint32_t avail_size;
int max_ptrs;
avail_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len)+avail_size-1)/avail_size;
- if(max_ptrs > ea_hdr->ea_num_ptrs) {
+ if (max_ptrs > ea_hdr->ea_num_ptrs) {
return 1;
} else {
log_debug( _(" Pointers Required: %d\n"
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 198111b..c6901d0 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -412,7 +412,7 @@ int preen_is_safe(struct gfs2_sbd *sdp, int preen, int force_check)
return 1; /* not called by rc.sysinit--we're okay to preen */
if (force_check) /* If check was forced by the user? */
return 1; /* user's responsibility--we're okay to preen */
- if(!memcmp(sdp->sd_sb.sb_lockproto + 5, "nolock", 6))
+ if (!memcmp(sdp->sd_sb.sb_lockproto + 5, "nolock", 6))
return 1; /* local file system--preen is okay */
return 0; /* might be mounted on another node--not guaranteed safe */
}
@@ -633,7 +633,7 @@ int ji_update(struct gfs2_sbd *sdp)
char journal_name[JOURNAL_NAME_SIZE];
int i;
- if(!ip) {
+ if (!ip) {
log_crit("Journal index inode not found.\n");
return -1;
}
@@ -647,7 +647,7 @@ int ji_update(struct gfs2_sbd *sdp)
else
sdp->md.journals = ip->i_di.di_entries - 2;
- if(!(sdp->md.journal = calloc(sdp->md.journals,
+ if (!(sdp->md.journal = calloc(sdp->md.journals,
sizeof(struct gfs2_inode *)))) {
log_err("Unable to allocate journal index\n");
return -1;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 55a4f19..2506108 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -22,7 +22,7 @@
#include "inode_hash.h"
#define CLEAR_POINTER(x) \
- if(x) { \
+ if (x) { \
free(x); \
x = NULL; \
}
@@ -40,9 +40,9 @@ static struct master_dir fix_md;
*/
static int block_mounters(struct gfs2_sbd *sdp, int block_em)
{
- if(block_em) {
+ if (block_em) {
/* verify it starts with lock_ */
- if(!strncmp(sdp->sd_sb.sb_lockproto, "lock_", 5)) {
+ if (!strncmp(sdp->sd_sb.sb_lockproto, "lock_", 5)) {
/* Change lock_ to fsck_ */
memcpy(sdp->sd_sb.sb_lockproto, "fsck_", 5);
}
@@ -51,13 +51,13 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em)
} else {
/* verify it starts with fsck_ */
/* verify it starts with lock_ */
- if(!strncmp(sdp->sd_sb.sb_lockproto, "fsck_", 5)) {
+ if (!strncmp(sdp->sd_sb.sb_lockproto, "fsck_", 5)) {
/* Change fsck_ to lock_ */
memcpy(sdp->sd_sb.sb_lockproto, "lock_", 5);
}
}
- if(write_sb(sdp)) {
+ if (write_sb(sdp)) {
stack;
return -1;
}
@@ -164,7 +164,7 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
last_data_block = rmax;
first_data_block = rmin;
- if(fsck_lseek(sdp->device_fd, (last_fs_block * sdp->sd_sb.sb_bsize))){
+ if (fsck_lseek(sdp->device_fd, (last_fs_block * sdp->sd_sb.sb_bsize))){
log_crit( _("Can't seek to last block in file system: %llu"
" (0x%llx)\n"), (unsigned long long)last_fs_block,
(unsigned long long)last_fs_block);
@@ -659,7 +659,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
/*******************************************************************
******* Now, set boundary fields in the super block *************
*******************************************************************/
- if(set_block_ranges(sdp)){
+ if (set_block_ranges(sdp)){
log_err( _("Unable to determine the boundaries of the"
" file system.\n"));
goto fail;
@@ -1150,7 +1150,7 @@ static int fill_super_block(struct gfs2_sbd *sdp)
sdp->sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE;
sdp->bsize = sdp->sd_sb.sb_bsize;
- if(sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize){
+ if (sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize){
log_crit( _("GFS superblock is larger than the blocksize!\n"));
log_debug("sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize\n");
return -1;
@@ -1187,7 +1187,7 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
*all_clean = 0;
- if(opts.no)
+ if (opts.no)
open_flag = O_RDONLY;
else
open_flag = O_RDWR | O_EXCL;
@@ -1236,8 +1236,8 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
return FSCK_ERROR;
/* Change lock protocol to be fsck_* instead of lock_* */
- if(!opts.no && preen_is_safe(sdp, preen, force_check)) {
- if(block_mounters(sdp, 1)) {
+ if (!opts.no && preen_is_safe(sdp, preen, force_check)) {
+ if (block_mounters(sdp, 1)) {
log_err( _("Unable to block other mounters\n"));
return FSCK_USAGE;
}
@@ -1261,8 +1261,8 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
/* verify various things */
- if(replay_journals(sdp, preen, force_check, &clean_journals)) {
- if(!opts.no && preen_is_safe(sdp, preen, force_check))
+ if (replay_journals(sdp, preen, force_check, &clean_journals)) {
+ if (!opts.no && preen_is_safe(sdp, preen, force_check))
block_mounters(sdp, 0);
stack;
return FSCK_ERROR;
@@ -1289,8 +1289,8 @@ mount_fail:
static void destroy_sdp(struct gfs2_sbd *sdp)
{
- if(!opts.no) {
- if(block_mounters(sdp, 0)) {
+ if (!opts.no) {
+ if (block_mounters(sdp, 0)) {
log_warn( _("Unable to unblock other mounters - manual intervention required\n"));
log_warn( _("Use 'gfs2_tool sb <device> proto' to fix\n"));
}
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index f2ff013..08ea94c 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -69,7 +69,7 @@ int decrement_link(uint64_t inode_no, uint64_t referenced_from,
ii = inodetree_find(inode_no);
/* If the list has entries, look for one that matches
* inode_no */
- if(ii) {
+ if (ii) {
if (!ii->counted_links) {
log_debug( _("Directory %llu (0x%llx)'s link to "
" %llu (0x%llx) via %s is zero!\n"),
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index aea48c5..04aa90d 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -34,7 +34,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
struct dir_info *di;
int err = 0;
- if(!lf_dip) {
+ if (!lf_dip) {
uint8_t q;
log_info( _("Locating/Creating lost+found directory\n"));
@@ -55,7 +55,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
sdp->md.rooti->i_di.di_nlink);
q = block_type(lf_dip->i_di.di_num.no_addr);
- if(q != gfs2_inode_dir) {
+ if (q != gfs2_inode_dir) {
/* This is a new lost+found directory, so set its
* block type and increment link counts for
* the directories */
@@ -88,7 +88,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
di = NULL;
}
}
- if(ip->i_di.di_num.no_addr == lf_dip->i_di.di_num.no_addr) {
+ if (ip->i_di.di_num.no_addr == lf_dip->i_di.di_num.no_addr) {
log_err( _("Trying to add lost+found to itself...skipping"));
return 0;
}
@@ -138,7 +138,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
"for orphan directory %lld (0x%llx)\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(gfs2_dirent_del(ip, "..", 2))
+ if (gfs2_dirent_del(ip, "..", 2))
log_warn( _("add_inode_to_lf: Unable to remove "
"\"..\" directory entry.\n"));
@@ -206,7 +206,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
increment_link(ip->i_di.di_num.no_addr, lf_dip->i_di.di_num.no_addr,
_("from lost+found"));
/* If it's a directory, lost+found is back-linked to it via .. */
- if(S_ISDIR(ip->i_di.di_mode))
+ if (S_ISDIR(ip->i_di.di_mode))
increment_link(lf_dip->i_di.di_num.no_addr,
ip->i_di.di_mode, _("to lost+found"));
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index dc3f7aa..52bc9a0 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -63,7 +63,7 @@ static int read_cmdline(int argc, char **argv, struct gfs2_options *gopts)
{
int c;
- while((c = getopt(argc, argv, "afhnpqvyV")) != -1) {
+ while ((c = getopt(argc, argv, "afhnpqvyV")) != -1) {
switch(c) {
case 'a':
@@ -107,9 +107,9 @@ static int read_cmdline(int argc, char **argv, struct gfs2_options *gopts)
}
}
- if(argc > optind) {
+ if (argc > optind) {
gopts->device = (argv[optind]);
- if(!gopts->device) {
+ if (!gopts->device) {
fprintf(stderr, _("Please use '-h' for help.\n"));
return FSCK_USAGE;
}
@@ -136,7 +136,7 @@ static void interrupt(int sig)
_("Do you want to abort gfs2_fsck, skip " \
"the rest of this pass or continue " \
"(a/s/c)?"), "asc");
- if(tolower(response) == 's') {
+ if (tolower(response) == 's') {
skip_this_pass = TRUE;
return;
}
@@ -228,7 +228,7 @@ int main(int argc, char **argv)
memset(sdp, 0, sizeof(*sdp));
- if((error = read_cmdline(argc, argv, &opts)))
+ if ((error = read_cmdline(argc, argv, &opts)))
exit(error);
setbuf(stdout, NULL);
log_notice( _("Initializing fsck\n"));
@@ -258,7 +258,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 1b";
log_notice( _("Starting pass1b\n"));
- if((error = pass1b(sdp)))
+ if ((error = pass1b(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -271,7 +271,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 1c";
log_notice( _("Starting pass1c\n"));
- if((error = pass1c(sdp)))
+ if ((error = pass1c(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 808673c..3cee0fd 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -52,7 +52,7 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk,
(unsigned long long)blk, (unsigned long long)blk,
allocdesc[new_bitmap_state],
allocdesc[old_bitmap_state]);
- if(query( _("Okay to fix the bitmap? (y/n)"))) {
+ if (query( _("Okay to fix the bitmap? (y/n)"))) {
/* If the new bitmap state is free (and therefore the
old state was not) we have to add to the free
space in the rgrp. If the old bitmap state was
@@ -311,7 +311,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
bh_end = bh->b_data + ip->i_sbd->bsize;
- if(type == DIR_LINEAR) {
+ if (type == DIR_LINEAR) {
dent = (struct gfs2_dirent *)(bh->b_data + sizeof(struct gfs2_dinode));
}
else if (type == DIR_EXHASH) {
@@ -326,10 +326,10 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
}
prev = NULL;
- if(!pass->check_dentry)
+ if (!pass->check_dentry)
return 0;
- while(1) {
+ while (1) {
if (skip_this_pass || fsck_abort)
return FSCK_OK;
memset(&de, 0, sizeof(struct gfs2_dirent));
@@ -372,7 +372,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
}
}
if (!de.de_inum.no_formal_ino){
- if(first){
+ if (first){
log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
@@ -409,7 +409,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
error = pass->check_dentry(ip, dent, prev, bh,
filename, count,
pass->private);
- if(error < 0) {
+ if (error < 0) {
stack;
return -1;
}
@@ -428,7 +428,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
/* If we didn't clear the dentry, or if we did, but it
* was the first dentry, set prev */
- if(!error || first)
+ if (!error || first)
prev = dent;
first = 0;
dent = (struct gfs2_dirent *)((char *)dent + de.de_rec_len);
@@ -638,7 +638,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
leaf info */
ref_count++;
continue;
- } else if(old_leaf == leaf_no) {
+ } else if (old_leaf == leaf_no) {
ref_count++;
continue;
}
@@ -656,7 +656,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (fsck_abort)
break;
/* Make sure the block number is in range. */
- if(gfs2_check_range(ip->i_sbd, leaf_no)){
+ if (gfs2_check_range(ip->i_sbd, leaf_no)){
log_err( _("Leaf block #%llu (0x%llx) is out "
"of range for directory #%llu (0x%llx"
").\n"), (unsigned long long)leaf_no,
@@ -685,7 +685,7 @@ 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);
@@ -729,13 +729,13 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (skip_this_pass || fsck_abort)
return 0;
- if(error < 0) {
+ if (error < 0) {
stack;
brelse(lbh);
return -1;
}
- if(count != leaf.lf_entries) {
+ if (count != leaf.lf_entries) {
brelse(lbh);
lbh = bread(sdp, leaf_no);
gfs2_leaf_in(&leaf, lbh);
@@ -752,7 +752,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
(unsigned long long)
ip->i_di.di_num.no_addr,
leaf.lf_entries, count);
- if(query( _("Update leaf entry count? (y/n) "))) {
+ if (query( _("Update leaf entry count? (y/n) "))) {
leaf.lf_entries = count;
gfs2_leaf_out(&leaf, lbh);
log_warn( _("Leaf entry count updated\n"));
@@ -768,7 +768,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
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 */
+ } while (1); /* while we have chained leaf blocks */
} /* for every leaf block */
return 0;
}
@@ -783,24 +783,24 @@ static int check_eattr_entries(struct gfs2_inode *ip,
int error = 0;
uint32_t offset = (uint32_t)sizeof(struct gfs2_meta_header);
- if(!pass->check_eattr_entry)
+ if (!pass->check_eattr_entry)
return 0;
ea_hdr = (struct gfs2_ea_header *)(bh->b_data +
sizeof(struct gfs2_meta_header));
- while(1){
+ while (1){
if (ea_hdr->ea_type == GFS2_EATYPE_UNUSED)
error = 0;
else
error = pass->check_eattr_entry(ip, bh, ea_hdr,
ea_hdr_prev,
pass->private);
- if(error < 0) {
+ if (error < 0) {
stack;
return -1;
}
- if(error == 0 && pass->check_eattr_extentry &&
+ if (error == 0 && pass->check_eattr_extentry &&
ea_hdr->ea_num_ptrs) {
uint32_t tot_ealen = 0;
struct gfs2_sbd *sdp = ip->i_sbd;
@@ -817,7 +817,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
** reuse........... */
for(i = 0; i < ea_hdr->ea_num_ptrs; i++){
- if(pass->check_eattr_extentry(ip,
+ if (pass->check_eattr_extentry(ip,
ea_data_ptr,
bh, ea_hdr,
ea_hdr_prev,
@@ -850,7 +850,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
}
}
offset += be32_to_cpu(ea_hdr->ea_rec_len);
- if(ea_hdr->ea_flags & GFS2_EAFLAG_LAST ||
+ if (ea_hdr->ea_flags & GFS2_EAFLAG_LAST ||
offset >= ip->i_sbd->sd_sb.sb_bsize || ea_hdr->ea_rec_len == 0){
break;
}
@@ -880,14 +880,14 @@ static int check_leaf_eattr(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)block,
(unsigned long long)block);
- if(pass->check_eattr_leaf) {
+ if (pass->check_eattr_leaf) {
error = pass->check_eattr_leaf(ip, block, parent, &bh,
pass->private);
- if(error < 0) {
+ if (error < 0) {
stack;
return -1;
}
- if(error > 0) {
+ if (error > 0) {
if (bh)
brelse(bh);
return 1;
@@ -993,7 +993,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
end = ea_leaf_ptr + ((sdp->sd_sb.sb_bsize
- sizeof(struct gfs2_meta_header)) / 8);
- while(*ea_leaf_ptr && (ea_leaf_ptr < end)){
+ while (*ea_leaf_ptr && (ea_leaf_ptr < end)){
block = be64_to_cpu(*ea_leaf_ptr);
leaf_pointers++;
error = check_leaf_eattr(ip, block, indirect, pass);
@@ -1065,15 +1065,15 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
int error = 0;
- if(!ip->i_di.di_eattr)
+ if (!ip->i_di.di_eattr)
return 0;
log_debug( _("Extended attributes exist for inode #%llu (0x%llx).\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT){
- if((error = check_indirect_eattr(ip, ip->i_di.di_eattr, pass)))
+ if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT){
+ if ((error = check_indirect_eattr(ip, ip->i_di.di_eattr, pass)))
stack;
} else {
error = check_leaf_eattr(ip, ip->i_di.di_eattr,
@@ -1136,7 +1136,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
if (S_ISDIR(ip->i_di.di_mode))
height++;
- /* if(<there are no indirect blocks to check>) */
+ /* if (<there are no indirect blocks to check>) */
if (height < 2)
return 0;
for (h = 1; h < height; h++) {
@@ -1177,12 +1177,12 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
pass->private);
/* check_metalist should hold any buffers
it gets with "bread". */
- if(err < 0) {
+ if (err < 0) {
stack;
error = err;
goto fail;
}
- if(err > 0) {
+ if (err > 0) {
if (!error)
error = err;
log_debug( _("Skipping block %llu (0x%llx)\n"),
@@ -1197,7 +1197,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
(unsigned long long)block);
continue;
}
- if(!nbh)
+ if (!nbh)
nbh = bread(ip->i_sbd, block);
osi_list_add(&nbh->b_altlist, cur_list);
} /* for all data on the indirect block */
@@ -1376,7 +1376,7 @@ int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
uint16_t count = 0;
error = check_entries(ip, bh, DIR_LINEAR, &count, pass);
- if(error < 0) {
+ if (error < 0) {
stack;
return -1;
}
@@ -1391,12 +1391,12 @@ int check_dir(struct gfs2_sbd *sdp, uint64_t block, struct metawalk_fxns *pass)
ip = fsck_load_inode(sdp, block);
- if(ip->i_di.di_flags & GFS2_DIF_EXHASH)
+ if (ip->i_di.di_flags & GFS2_DIF_EXHASH)
error = check_leaf_blks(ip, pass);
else
error = check_linear_dir(ip, ip->i_bh, pass);
- if(error < 0)
+ if (error < 0)
stack;
fsck_inode_put(&ip); /* does a brelse */
@@ -1417,7 +1417,7 @@ static int remove_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
gfs2_dirent_in(&dentry, (char *)dent);
de = &dentry;
- if(de->de_inum.no_addr == *dentryblock)
+ if (de->de_inum.no_addr == *dentryblock)
dirent2_del(ip, bh, prev_de, dent);
else
(*count)++;
@@ -1437,7 +1437,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
" (0x%llx)\n"), (unsigned long long)dentryblock,
(unsigned long long)dentryblock,
(unsigned long long)dir, (unsigned long long)dir);
- if(gfs2_check_range(sdp, dir)) {
+ if (gfs2_check_range(sdp, dir)) {
log_err( _("Parent directory out of range\n"));
return 1;
}
@@ -1445,7 +1445,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
remove_dentry_fxns.check_dentry = remove_dentry;
q = block_type(dir);
- if(q != gfs2_inode_dir) {
+ if (q != gfs2_inode_dir) {
log_info( _("Parent block is not a directory...ignoring\n"));
return 1;
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index ef4628c..2670d8c 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -162,11 +162,11 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
block = de->de_inum.no_addr;
/* Start of checks */
memset(tmp_name, 0, sizeof(tmp_name));
- if(de->de_name_len < sizeof(tmp_name))
+ if (de->de_name_len < sizeof(tmp_name))
strncpy(tmp_name, filename, de->de_name_len);
else
strncpy(tmp_name, filename, sizeof(tmp_name) - 1);
- if(gfs2_check_range(sdp, block)) {
+ if (gfs2_check_range(sdp, block)) {
log_err( _("Block # referenced by system directory entry %s "
"in inode %lld (0x%llx) is out of range; "
"ignored.\n"),
@@ -239,7 +239,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
blktypedesc = _("a journaled data block");
}
q = block_type(block);
- if(q != gfs2_block_free) {
+ if (q != gfs2_block_free) {
log_err( _("Found duplicate block %llu (0x%llx) referenced "
"as metadata in indirect block for dinode "
"%llu (0x%llx) - was marked %d (%s)\n"),
@@ -261,7 +261,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)block,
(unsigned long long)block, blktypedesc);
- if(!found_dup) {
+ if (!found_dup) {
fsck_blockmap_set(ip, block, _("bad indirect"),
gfs2_meta_inval);
brelse(nbh);
@@ -322,7 +322,7 @@ static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
nbh = bread(ip->i_sbd, block);
if (gfs2_check_meta(nbh, iblk_type)) {
- if(!found_dup) {
+ if (!found_dup) {
fsck_blockmap_set(ip, block, _("bad indirect"),
gfs2_block_free);
brelse(nbh);
@@ -547,7 +547,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
/* This inode contains an eattr - it may be invalid, but the
* eattr attributes points to a non-zero block */
- if(gfs2_check_range(sdp, indirect)) {
+ if (gfs2_check_range(sdp, indirect)) {
/* Doesn't help to mark this here - this gets checked
* in pass1c */
return 1;
@@ -559,8 +559,8 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
handling sort it out. If it isn't, clear it but don't
count it as a duplicate. */
*bh = bread(sdp, indirect);
- if(gfs2_check_meta(*bh, GFS2_METATYPE_IN)) {
- if(q != gfs2_block_free) { /* Duplicate? */
+ if (gfs2_check_meta(*bh, GFS2_METATYPE_IN)) {
+ if (q != gfs2_block_free) { /* Duplicate? */
add_duplicate_ref(ip, indirect, ref_as_ea, 0,
INODE_VALID);
if (!clear_eas(ip, bc, indirect, 1,
@@ -574,7 +574,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
"type"));
return 1;
}
- if(q != gfs2_block_free) { /* Duplicate? */
+ if (q != gfs2_block_free) { /* Duplicate? */
log_err( _("Inode #%llu (0x%llx): Duplicate Extended "
"Attribute indirect block found at #%llu "
"(0x%llx).\n"),
@@ -649,8 +649,8 @@ static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
really is an EA. If it is, let duplicate handling sort it out.
If it isn't, clear it but don't count it as a duplicate. */
leaf_bh = bread(sdp, block);
- if(gfs2_check_meta(leaf_bh, btype)) {
- if(q != gfs2_block_free) { /* Duplicate? */
+ if (gfs2_check_meta(leaf_bh, btype)) {
+ if (q != gfs2_block_free) { /* Duplicate? */
add_duplicate_ref(ip, block, ref_as_ea, 0,
INODE_VALID);
clear_eas(ip, bc, block, 1,
@@ -663,7 +663,7 @@ static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
brelse(leaf_bh);
return 1;
}
- if(q != gfs2_block_free) { /* Duplicate? */
+ if (q != gfs2_block_free) { /* Duplicate? */
log_debug( _("Duplicate block found at #%lld (0x%llx).\n"),
(unsigned long long)block,
(unsigned long long)block);
@@ -713,7 +713,7 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, uint64_t *data_ptr,
struct gfs2_buffer_head *bh = NULL;
int error;
- if(gfs2_check_range(sdp, el_blk)){
+ if (gfs2_check_range(sdp, el_blk)){
log_err( _("Inode #%llu (0x%llx): Extended Attribute block "
"%llu (0x%llx) has an extended leaf block #%llu "
"(0x%llx) that is out of range.\n"),
@@ -780,7 +780,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
struct gfs2_sbd *sdp = ip->i_sbd;
char ea_name[256];
- if(!ea_hdr->ea_name_len){
+ if (!ea_hdr->ea_name_len){
/* Skip this entry for now */
return 1;
}
@@ -789,20 +789,20 @@ static int check_eattr_entries(struct gfs2_inode *ip,
strncpy(ea_name, (char *)ea_hdr + sizeof(struct gfs2_ea_header),
ea_hdr->ea_name_len);
- if(!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
+ if (!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
/* Skip invalid entry */
return 1;
}
- if(ea_hdr->ea_num_ptrs){
+ if (ea_hdr->ea_num_ptrs){
uint32_t avail_size;
int max_ptrs;
avail_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len)+avail_size-1)/avail_size;
- if(max_ptrs > ea_hdr->ea_num_ptrs) {
+ if (max_ptrs > ea_hdr->ea_num_ptrs) {
return 1;
} else {
log_debug( _(" Pointers Required: %d\n Pointers Reported: %d\n"),
@@ -1006,7 +1006,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
if (fsck_blockmap_set(ip, block, _("directory"),
gfs2_inode_dir))
goto bad_dinode;
- if(!dirtree_insert(block))
+ if (!dirtree_insert(block))
goto bad_dinode;
break;
case S_IFREG:
@@ -1057,7 +1057,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
goto bad_dinode;
return 0;
}
- if(set_link_count(ip->i_di.di_num.no_addr, ip->i_di.di_nlink))
+ if (set_link_count(ip->i_di.di_num.no_addr, ip->i_di.di_nlink))
goto bad_dinode;
if (S_ISDIR(ip->i_di.di_mode) &&
@@ -1069,7 +1069,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
(unsigned long long)ip->i_di.di_num.no_addr,
ip->i_di.di_depth,
(1 >> (ip->i_di.di_size/sizeof(uint64_t))));
- if(fsck_blockmap_set(ip, block, _("bad depth"),
+ if (fsck_blockmap_set(ip, block, _("bad depth"),
gfs2_block_free))
goto bad_dinode;
return 0;
@@ -1150,7 +1150,7 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
ip = fsck_inode_get(sdp, bh);
q = block_type(block);
- if(q != gfs2_block_free) {
+ if (q != gfs2_block_free) {
log_err( _("Found a duplicate inode block at #%llu"
" (0x%llx) previously marked as a %s\n"),
(unsigned long long)block,
@@ -1166,7 +1166,7 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
(unsigned long long)block,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(query( _("Fix address in inode at block #%llu"
+ if (query( _("Fix address in inode at block #%llu"
" (0x%llx)? (y/n) "),
(unsigned long long)block, (unsigned long long)block)) {
ip->i_di.di_num.no_addr = ip->i_di.di_num.no_formal_ino = block;
@@ -1238,7 +1238,7 @@ static int check_system_inode(struct gfs2_sbd *sdp,
inode and get it all setup - of course, everything will be in
lost+found then, but we *need* our system inodes before we can
do any of that. */
- if(!(*sysinode) || ds.q != mark) {
+ if (!(*sysinode) || ds.q != mark) {
log_err( _("Invalid or missing %s system inode (should be %d, "
"is %d).\n"), filename, mark, ds.q);
if (query(_("Create new %s system inode? (y/n) "), filename)) {
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 373b796..6b7bc41 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -143,11 +143,11 @@ static int check_dir_dup_ref(struct gfs2_inode *ip, struct gfs2_dirent *de,
struct inode_with_dups *id;
id = osi_list_entry(tmp2, struct inode_with_dups, list);
- if(id->name)
+ if (id->name)
/* We can only have one parent of inodes that contain duplicate
* blocks...no need to keep looking for this one. */
return 1;
- if(id->block_no == de->de_inum.no_addr) {
+ if (id->block_no == de->de_inum.no_addr) {
id->name = strdup(filename);
id->parent = ip->i_di.di_num.no_addr;
log_debug( _("Duplicate block %llu (0x%llx"
@@ -225,7 +225,7 @@ static int clear_dup_metalist(struct gfs2_inode *ip, uint64_t block,
return 0;
}
/* This block, having failed the above test, is duplicated somewhere */
- if(block == dh->b->block) {
+ if (block == dh->b->block) {
log_err( _("Not clearing duplicate reference in inode \"%s\" "
"at block #%llu (0x%llx) to block #%llu (0x%llx) "
"because it's valid for another inode.\n"),
@@ -276,7 +276,7 @@ static int clear_eattr_entry (struct gfs2_inode *ip,
struct gfs2_sbd *sdp = ip->i_sbd;
char ea_name[256];
- if(!ea_hdr->ea_name_len){
+ if (!ea_hdr->ea_name_len){
/* Skip this entry for now */
return 1;
}
@@ -285,13 +285,13 @@ static int clear_eattr_entry (struct gfs2_inode *ip,
strncpy(ea_name, (char *)ea_hdr + sizeof(struct gfs2_ea_header),
ea_hdr->ea_name_len);
- if(!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
+ if (!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
/* Skip invalid entry */
return 1;
}
- if(ea_hdr->ea_num_ptrs){
+ if (ea_hdr->ea_num_ptrs){
uint32_t avail_size;
int max_ptrs;
@@ -299,7 +299,7 @@ static int clear_eattr_entry (struct gfs2_inode *ip,
max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len) + avail_size - 1) /
avail_size;
- if(max_ptrs > ea_hdr->ea_num_ptrs)
+ if (max_ptrs > ea_hdr->ea_num_ptrs)
return 1;
else {
log_debug( _(" Pointers Required: %d\n Pointers Reported: %d\n"),
@@ -345,11 +345,11 @@ static int find_block_ref(struct gfs2_sbd *sdp, uint64_t inode)
/* Exhash dir leafs will be checked by check_metatree (right after
the "end:" label.) But if this is a linear directory we need to
check the dir with check_linear_dir. */
- if(S_ISDIR(ip->i_di.di_mode) && !(ip->i_di.di_flags & GFS2_DIF_EXHASH))
+ if (S_ISDIR(ip->i_di.di_mode) && !(ip->i_di.di_flags & GFS2_DIF_EXHASH))
error = check_linear_dir(ip, ip->i_bh, &find_dirents);
/* Check for ea references in the inode */
- if(!error)
+ if (!error)
error = check_inode_eattr(ip, &find_refs);
fsck_inode_put(&ip); /* out, brelse, free */
@@ -409,7 +409,7 @@ static int clear_a_reference(struct gfs2_sbd *sdp, struct duptree *b,
id = osi_list_entry(tmp, struct inode_with_dups, list);
dh->b = b;
dh->id = id;
- if(dh->ref_inode_count == 1) /* down to the last reference */
+ if (dh->ref_inode_count == 1) /* down to the last reference */
return 1;
if (!(query( _("Okay to clear %s inode %lld (0x%llx)? (y/n) "),
(inval ? _("invalidated") : ""),
@@ -439,7 +439,7 @@ static int clear_a_reference(struct gfs2_sbd *sdp, struct duptree *b,
* block for each duplicate and point the metadata at
* the cloned blocks */
}
- if(dh->ref_inode_count == 1) /* down to the last reference */
+ if (dh->ref_inode_count == 1) /* down to the last reference */
return 1;
return 0;
}
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index 3367e77..0fbe0ce 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -78,7 +78,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
uint8_t q;
struct gfs2_buffer_head *indir_bh = NULL;
- if(gfs2_check_range(sdp, block)) {
+ if (gfs2_check_range(sdp, block)) {
log_err( _("Extended attributes indirect block #%llu"
" (0x%llx) for inode #%llu"
" (0x%llx) out of range...removing\n"),
@@ -89,7 +89,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
return ask_remove_eattr(ip);
}
q = block_type(block);
- if(q != gfs2_indir_blk) {
+ if (q != gfs2_indir_blk) {
log_err( _("Extended attributes indirect block #%llu"
" (0x%llx) for inode #%llu"
" (0x%llx) invalid.\n"),
@@ -113,7 +113,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
struct gfs2_sbd *sdp = ip->i_sbd;
uint8_t q;
- if(gfs2_check_range(sdp, block)) {
+ if (gfs2_check_range(sdp, block)) {
log_err( _("Extended attributes block for inode #%llu"
" (0x%llx) out of range.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -121,7 +121,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
return ask_remove_eattr(ip);
}
q = block_type(block);
- if(q != gfs2_meta_eattr) {
+ if (q != gfs2_meta_eattr) {
log_err( _("Extended attributes block for inode #%llu"
" (0x%llx) invalid.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -146,23 +146,23 @@ static int check_eattr_entry(struct gfs2_inode *ip,
((unsigned long)leaf_bh->b_data));
uint32_t max_size = sdp->sd_sb.sb_bsize;
- if(!ea_hdr->ea_name_len){
+ if (!ea_hdr->ea_name_len){
log_err( _("EA has name length of zero\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 1, 1);
}
- if(offset + be32_to_cpu(ea_hdr->ea_rec_len) > max_size){
+ if (offset + be32_to_cpu(ea_hdr->ea_rec_len) > max_size){
log_err( _("EA rec length too long\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 1, 1);
}
- if(offset + be32_to_cpu(ea_hdr->ea_rec_len) == max_size &&
+ if (offset + be32_to_cpu(ea_hdr->ea_rec_len) == max_size &&
(ea_hdr->ea_flags & GFS2_EAFLAG_LAST) == 0){
log_err( _("last EA has no last entry flag\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 0, 0);
}
- if(!ea_hdr->ea_name_len){
+ if (!ea_hdr->ea_name_len){
log_err( _("EA has name length of zero\n"));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 0, 0);
@@ -172,7 +172,7 @@ static int check_eattr_entry(struct gfs2_inode *ip,
strncpy(ea_name, (char *)ea_hdr + sizeof(struct gfs2_ea_header),
ea_hdr->ea_name_len);
- if(!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
+ if (!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
log_err( _("EA (%s) type is invalid (%d > %d).\n"),
ea_name, ea_hdr->ea_type, GFS2_EATYPE_LAST);
@@ -180,14 +180,14 @@ static int check_eattr_entry(struct gfs2_inode *ip,
ea_hdr_prev, 0, 0);
}
- if(ea_hdr->ea_num_ptrs){
+ if (ea_hdr->ea_num_ptrs){
uint32_t avail_size;
int max_ptrs;
avail_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len)+avail_size-1)/avail_size;
- if(max_ptrs > ea_hdr->ea_num_ptrs){
+ if (max_ptrs > ea_hdr->ea_num_ptrs){
log_err( _("EA (%s) has incorrect number of pointers.\n"), ea_name);
log_err( _(" Required: %d\n Reported: %d\n"),
max_ptrs, ea_hdr->ea_num_ptrs);
@@ -210,8 +210,8 @@ static int check_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_ptr,
struct gfs2_sbd *sdp = ip->i_sbd;
q = block_type(be64_to_cpu(*ea_ptr));
- if(q != gfs2_meta_eattr) {
- if(remove_eattr_entry(sdp, leaf_bh, ea_hdr, ea_hdr_prev)){
+ if (q != gfs2_meta_eattr) {
+ if (remove_eattr_entry(sdp, leaf_bh, ea_hdr, ea_hdr_prev)){
stack;
return -1;
}
@@ -260,7 +260,7 @@ int pass1c(struct gfs2_sbd *sdp)
(unsigned long long)ip->i_di.di_eattr);
/* FIXME: Handle walking the eattr here */
error = check_inode_eattr(ip, &pass1c_fxns);
- if(error < 0) {
+ if (error < 0) {
stack;
brelse(bh);
return FSCK_ERROR;
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index b4fcc1d..573ed30 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -26,7 +26,7 @@ static int set_parent_dir(struct gfs2_sbd *sdp, uint64_t childblock,
struct dir_info *di;
di = dirtree_find(childblock);
- if(!di) {
+ if (!di) {
log_err( _("Unable to find block %llu (0x%llx"
") in dir_info list\n"),
(unsigned long long)childblock,
@@ -34,7 +34,7 @@ static int set_parent_dir(struct gfs2_sbd *sdp, uint64_t childblock,
return -1;
}
- if(di->dinode == childblock) {
+ if (di->dinode == childblock) {
if (di->treewalk_parent) {
log_err( _("Another directory at block %llu"
" (0x%llx) already contains this "
@@ -66,11 +66,11 @@ static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
struct dir_info *di;
di = dirtree_find(childblock);
- if(di) {
- if(di->dinode == childblock) {
+ if (di) {
+ if (di->dinode == childblock) {
/* Special case for root inode because we set
* it earlier */
- if(di->dotdot_parent && sdp->md.rooti->i_di.di_num.no_addr
+ if (di->dotdot_parent && sdp->md.rooti->i_di.di_num.no_addr
!= di->dinode) {
/* This should never happen */
log_crit( _("Dotdot parent already set for"
@@ -126,31 +126,31 @@ static int check_file_type(uint8_t de_type, uint8_t blk_type)
{
switch(blk_type) {
case gfs2_inode_dir:
- if(de_type != DT_DIR)
+ if (de_type != DT_DIR)
return 1;
break;
case gfs2_inode_file:
- if(de_type != DT_REG)
+ if (de_type != DT_REG)
return 1;
break;
case gfs2_inode_lnk:
- if(de_type != DT_LNK)
+ if (de_type != DT_LNK)
return 1;
break;
case gfs2_inode_blk:
- if(de_type != DT_BLK)
+ if (de_type != DT_BLK)
return 1;
break;
case gfs2_inode_chr:
- if(de_type != DT_CHR)
+ if (de_type != DT_CHR)
return 1;
break;
case gfs2_inode_fifo:
- if(de_type != DT_FIFO)
+ if (de_type != DT_FIFO)
return 1;
break;
case gfs2_inode_sock:
- if(de_type != DT_SOCK)
+ if (de_type != DT_SOCK)
return 1;
break;
default:
@@ -201,17 +201,17 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* Start of checks */
memset(tmp_name, 0, MAX_FILENAME);
- if(de->de_name_len < MAX_FILENAME)
+ if (de->de_name_len < MAX_FILENAME)
strncpy(tmp_name, filename, de->de_name_len);
else
strncpy(tmp_name, filename, MAX_FILENAME - 1);
- if(gfs2_check_range(ip->i_sbd, entryblock)) {
+ if (gfs2_check_range(ip->i_sbd, entryblock)) {
log_err( _("Block # referenced by directory entry %s in inode "
"%lld (0x%llx) is out of range\n"),
tmp_name, (unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(query( _("Clear directory entry to out of range block? "
+ if (query( _("Clear directory entry to out of range block? "
"(y/n) "))) {
goto nuke_dentry;
} else {
@@ -228,7 +228,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
log_err( _("Dir entry with bad record or name length\n"
"\tRecord length = %u\n\tName length = %u\n"),
de->de_rec_len, de->de_name_len);
- if(!query( _("Clear the directory entry? (y/n) "))) {
+ if (!query( _("Clear the directory entry? (y/n) "))) {
log_err( _("Directory entry not fixed.\n"));
goto dentry_is_valid;
}
@@ -248,7 +248,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
log_err( _("\tName length found = %u\n"
"\tHash expected = %u (0x%x)\n"),
de->de_name_len, calculated_hash, calculated_hash);
- if(!query( _("Fix directory hash for %s? (y/n) "),
+ if (!query( _("Fix directory hash for %s? (y/n) "),
tmp_name)) {
log_err( _("Directory entry hash for %s not "
"fixed.\n"), tmp_name);
@@ -263,13 +263,13 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
q = block_type(entryblock);
/* Get the status of the directory inode */
- if(q == gfs2_inode_invalid || q == gfs2_bad_block) {
+ if (q == gfs2_inode_invalid || q == gfs2_bad_block) {
/* This entry's inode has bad blocks in it */
/* Handle bad blocks */
log_err( _("Found a bad directory entry: %s\n"), tmp_name);
- if(!query( _("Delete inode containing bad blocks? (y/n)"))) {
+ if (!query( _("Delete inode containing bad blocks? (y/n)"))) {
log_warn( _("Entry to inode containing bad blocks remains\n"));
goto dentry_is_valid;
}
@@ -286,7 +286,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
_("bad directory entry"), gfs2_block_free);
goto nuke_dentry;
}
- if(q < gfs2_inode_dir || q > gfs2_inode_sock) {
+ if (q < gfs2_inode_dir || q > gfs2_inode_sock) {
log_err( _("Directory entry '%s' referencing inode %llu "
"(0x%llx) in dir inode %llu (0x%llx) block type "
"%d: %s.\n"), tmp_name,
@@ -298,7 +298,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
_("was previously marked invalid") :
_("was deleted or is not an inode"));
- if(!query( _("Clear directory entry to non-inode block? "
+ if (!query( _("Clear directory entry to non-inode block? "
"(y/n) "))) {
log_err( _("Directory entry to non-inode block remains\n"));
goto dentry_is_valid;
@@ -324,7 +324,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
error = check_file_type(de->de_type, q);
- if(error < 0) {
+ if (error < 0) {
log_err( _("Error: directory entry type is "
"incompatible with block type at block %lld "
"(0x%llx) in directory inode %llu (0x%llx).\n"),
@@ -337,14 +337,14 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
stack;
return -1;
}
- if(error > 0) {
+ if (error > 0) {
log_err( _("Type '%s' in dir entry (%s, %llu/0x%llx) conflicts"
" with type '%s' in dinode. (Dir entry is stale.)\n"),
de_type_string(de->de_type), tmp_name,
(unsigned long long)entryblock,
(unsigned long long)entryblock,
block_type_string(q));
- if(!query( _("Clear stale directory entry? (y/n) "))) {
+ if (!query( _("Clear stale directory entry? (y/n) "))) {
log_err( _("Stale directory entry remains\n"));
goto dentry_is_valid;
}
@@ -358,15 +358,15 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto nuke_dentry;
}
- if(!strcmp(".", tmp_name)) {
+ if (!strcmp(".", tmp_name)) {
log_debug( _("Found . dentry\n"));
- if(ds->dotdir) {
+ if (ds->dotdir) {
log_err( _("Already found '.' entry in directory %llu"
" (0x%llx)\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(!query( _("Clear duplicate '.' entry? (y/n) "))) {
+ if (!query( _("Clear duplicate '.' entry? (y/n) "))) {
log_err( _("Duplicate '.' entry remains\n"));
/* FIXME: Should we continue on here
* and check the rest of the '.' entry? */
@@ -386,7 +386,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* location */
/* check that '.' refers to this inode */
- if(entryblock != ip->i_di.di_num.no_addr) {
+ if (entryblock != ip->i_di.di_num.no_addr) {
log_err( _("'.' entry's value incorrect in directory %llu"
" (0x%llx). Points to %llu"
" (0x%llx) when it should point to %llu"
@@ -397,7 +397,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
(unsigned long long)entryblock,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(!query( _("Remove '.' reference? (y/n) "))) {
+ if (!query( _("Remove '.' reference? (y/n) "))) {
log_err( _("Invalid '.' reference remains\n"));
/* Not setting ds->dotdir here since
* this '.' entry is invalid */
@@ -416,14 +416,14 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
ds->dotdir = 1;
goto dentry_is_valid;
}
- if(!strcmp("..", tmp_name)) {
+ if (!strcmp("..", tmp_name)) {
log_debug( _("Found .. dentry\n"));
- if(ds->dotdotdir) {
+ if (ds->dotdotdir) {
log_err( _("Already found '..' entry in directory %llu"
"(0x%llx)\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(!query( _("Clear duplicate '..' entry? (y/n) "))) {
+ if (!query( _("Clear duplicate '..' entry? (y/n) "))) {
log_err( _("Duplicate '..' entry remains\n"));
/* FIXME: Should we continue on here
* and check the rest of the '..'
@@ -442,12 +442,12 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto nuke_dentry;
}
- if(q != gfs2_inode_dir) {
+ if (q != gfs2_inode_dir) {
log_err( _("Found '..' entry in directory %llu (0x%llx) "
"pointing to something that's not a directory"),
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(!query( _("Clear bad '..' directory entry? (y/n) "))) {
+ if (!query( _("Clear bad '..' directory entry? (y/n) "))) {
log_err( _("Bad '..' directory entry remains\n"));
goto dentry_is_valid;
}
@@ -466,7 +466,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* Add the address this entry is pointing to
* to this inode's dotdot_parent in
* dir_info */
- if(set_dotdot_dir(sdp, ip->i_di.di_num.no_addr, entryblock)) {
+ if (set_dotdot_dir(sdp, ip->i_di.di_num.no_addr, entryblock)) {
stack;
return -1;
}
@@ -476,7 +476,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
/* After this point we're only concerned with directories */
- if(q != gfs2_inode_dir) {
+ if (q != gfs2_inode_dir) {
log_debug( _("Found non-dir inode dentry pointing to %lld "
"(0x%llx)\n"),
(unsigned long long)entryblock,
@@ -486,13 +486,13 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/*log_debug( _("Found plain directory dentry\n"));*/
error = set_parent_dir(sdp, entryblock, ip->i_di.di_num.no_addr);
- if(error > 0) {
+ if (error > 0) {
log_err( _("%s: Hard link to block %llu (0x%llx"
") detected.\n"), tmp_name,
(unsigned long long)entryblock,
(unsigned long long)entryblock);
- if(query( _("Clear hard link to directory? (y/n) ")))
+ if (query( _("Clear hard link to directory? (y/n) ")))
goto nuke_dentry;
else {
log_err( _("Hard link to directory remains\n"));
@@ -548,7 +548,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
ds.q = block_type(iblock);
}
pass2_fxns.private = (void *) &ds;
- if(ds.q == gfs2_bad_block) {
+ if (ds.q == gfs2_bad_block) {
/* First check that the directory's metatree is valid */
error = check_metatree(sysinode, &pass2_fxns);
if (error < 0) {
@@ -559,7 +559,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
error = check_dir(sysinode->i_sbd, iblock, &pass2_fxns);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- if(error < 0) {
+ if (error < 0) {
stack;
return -1;
}
@@ -567,23 +567,23 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
fsck_blockmap_set(sysinode, iblock, dirname,
gfs2_inode_invalid);
- if(check_inode_eattr(sysinode, &pass2_fxns)) {
+ if (check_inode_eattr(sysinode, &pass2_fxns)) {
stack;
return -1;
}
- if(!ds.dotdir) {
+ if (!ds.dotdir) {
log_err( _("No '.' entry found for %s directory.\n"), dirname);
if (query( _("Is it okay to add '.' entry? (y/n) "))) {
uint64_t cur_blks = sysinode->i_di.di_blocks;
sprintf(tmp_name, ".");
filename_len = strlen(tmp_name); /* no trailing NULL */
- if(!(filename = malloc(sizeof(char) * filename_len))) {
+ if (!(filename = malloc(sizeof(char) * filename_len))) {
log_err( _("Unable to allocate name string\n"));
stack;
return -1;
}
- if(!(memset(filename, 0, sizeof(char) *
+ if (!(memset(filename, 0, sizeof(char) *
filename_len))) {
log_err( _("Unable to zero name string\n"));
stack;
@@ -609,13 +609,13 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
} else
log_err( _("The directory was not fixed.\n"));
}
- if(sysinode->i_di.di_entries != ds.entry_count) {
+ if (sysinode->i_di.di_entries != ds.entry_count) {
log_err( _("%s inode %llu (0x%llx"
"): Entries is %d - should be %d\n"), dirname,
(unsigned long long)sysinode->i_di.di_num.no_addr,
(unsigned long long)sysinode->i_di.di_num.no_addr,
sysinode->i_di.di_entries, ds.entry_count);
- if(query( _("Fix entries for %s inode %llu (0x%llx)? (y/n) "),
+ if (query( _("Fix entries for %s inode %llu (0x%llx)? (y/n) "),
dirname,
(unsigned long long)sysinode->i_di.di_num.no_addr,
(unsigned long long)sysinode->i_di.di_num.no_addr)) {
@@ -707,7 +707,7 @@ int pass2(struct gfs2_sbd *sdp)
q = block_type(dirblk);
- if(q != gfs2_inode_dir)
+ if (q != gfs2_inode_dir)
continue;
log_debug( _("Checking directory inode at block %llu (0x%llx)\n"),
@@ -715,7 +715,7 @@ int pass2(struct gfs2_sbd *sdp)
memset(&ds, 0, sizeof(ds));
pass2_fxns.private = (void *) &ds;
- if(ds.q == gfs2_bad_block) {
+ if (ds.q == gfs2_bad_block) {
/* First check that the directory's metatree
* is valid */
ip = fsck_load_inode(sdp, dirblk);
@@ -729,7 +729,7 @@ int pass2(struct gfs2_sbd *sdp)
error = check_dir(sdp, dirblk, &pass2_fxns);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- if(error < 0) {
+ if (error < 0) {
stack;
return FSCK_ERROR;
}
@@ -737,11 +737,11 @@ int pass2(struct gfs2_sbd *sdp)
struct dir_info *di;
di = dirtree_find(dirblk);
- if(!di) {
+ if (!di) {
stack;
return FSCK_ERROR;
}
- if(query( _("Remove directory entry for bad"
+ if (query( _("Remove directory entry for bad"
" inode %llu (0x%llx) in %llu"
" (0x%llx)? (y/n)"),
(unsigned long long)dirblk,
@@ -750,11 +750,11 @@ int pass2(struct gfs2_sbd *sdp)
(unsigned long long)di->treewalk_parent)) {
error = remove_dentry_from_dir(sdp, di->treewalk_parent,
dirblk);
- if(error < 0) {
+ if (error < 0) {
stack;
return FSCK_ERROR;
}
- if(error > 0) {
+ if (error > 0) {
log_warn( _("Unable to find dentry for %llu"
" (0x%llx) in %llu"
" (0x%llx)\n"),
@@ -776,7 +776,7 @@ int pass2(struct gfs2_sbd *sdp)
check_n_fix_bitmap(sdp, dirblk, gfs2_inode_invalid);
}
ip = fsck_load_inode(sdp, dirblk);
- if(!ds.dotdir) {
+ if (!ds.dotdir) {
log_err(_("No '.' entry found for directory inode at "
"block %llu (0x%llx)\n"),
(unsigned long long)dirblk,
@@ -788,13 +788,13 @@ int pass2(struct gfs2_sbd *sdp)
sprintf(tmp_name, ".");
filename_len = strlen(tmp_name); /* no trailing
NULL */
- if(!(filename = malloc(sizeof(char) *
+ if (!(filename = malloc(sizeof(char) *
filename_len))) {
log_err(_("Unable to allocate name\n"));
stack;
return FSCK_ERROR;
}
- if(!memset(filename, 0, sizeof(char) *
+ if (!memset(filename, 0, sizeof(char) *
filename_len)) {
log_err( _("Unable to zero name\n"));
stack;
@@ -831,7 +831,7 @@ int pass2(struct gfs2_sbd *sdp)
}
}
- if(!fsck_abort && ip->i_di.di_entries != ds.entry_count) {
+ if (!fsck_abort && ip->i_di.di_entries != ds.entry_count) {
log_err( _("Entries is %d - should be %d for inode "
"block %llu (0x%llx)\n"),
ip->i_di.di_entries, ds.entry_count,
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 9a022ca..ff045de 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -34,14 +34,14 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
* this case? */
filename_len = strlen("..");
- if(!(filename = malloc((sizeof(char) * filename_len) + 1))) {
+ if (!(filename = malloc((sizeof(char) * filename_len) + 1))) {
log_err( _("Unable to allocate name\n"));
fsck_inode_put(&ip);
fsck_inode_put(&pip);
stack;
return -1;
}
- if(!memset(filename, 0, (sizeof(char) * filename_len) + 1)) {
+ if (!memset(filename, 0, (sizeof(char) * filename_len) + 1)) {
log_err( _("Unable to zero name\n"));
fsck_inode_put(&ip);
fsck_inode_put(&pip);
@@ -49,7 +49,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
return -1;
}
memcpy(filename, "..", filename_len);
- if(gfs2_dirent_del(ip, filename, filename_len))
+ if (gfs2_dirent_del(ip, filename, filename_len))
log_warn( _("Unable to remove \"..\" directory entry.\n"));
else
decrement_link(olddotdot, block, _("old \"..\""));
@@ -83,10 +83,10 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
di->checked = 1;
- if(!di->treewalk_parent)
+ if (!di->treewalk_parent)
return NULL;
- if(di->dotdot_parent != di->treewalk_parent) {
+ if (di->dotdot_parent != di->treewalk_parent) {
log_warn( _("Directory '..' and treewalk connections disagree for inode %llu"
" (0x%llx)\n"), (unsigned long long)di->dinode,
(unsigned long long)di->dinode);
@@ -105,8 +105,8 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
* choose? if neither are directories, we have a
* problem - need to move this directory into lost+found
*/
- if(q_dotdot != gfs2_inode_dir) {
- if(q_treewalk != gfs2_inode_dir) {
+ if (q_dotdot != gfs2_inode_dir) {
+ if (q_treewalk != gfs2_inode_dir) {
log_err( _("Orphaned directory, move to lost+found\n"));
return NULL;
}
@@ -120,14 +120,14 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
di->dotdot_parent = di->treewalk_parent;
}
} else {
- if(q_treewalk != gfs2_inode_dir) {
+ if (q_treewalk != gfs2_inode_dir) {
int error = 0;
log_warn( _(".. parent is valid, but treewalk"
"is bad - reattaching to lost+found"));
/* FIXME: add a dinode for this entry instead? */
- if(query( _("Remove directory entry for bad"
+ if (query( _("Remove directory entry for bad"
" inode %llu (0x%llx) in %llu"
" (0x%llx)? (y/n)"),
(unsigned long long)di->dinode,
@@ -136,11 +136,11 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
(unsigned long long)di->treewalk_parent)) {
error = remove_dentry_from_dir(sdp, di->treewalk_parent,
di->dinode);
- if(error < 0) {
+ if (error < 0) {
stack;
return NULL;
}
- if(error > 0) {
+ if (error > 0) {
log_warn( _("Unable to find dentry for block %llu"
" (0x%llx) in %llu (0x%llx)\n"),
(unsigned long long)di->dinode,
@@ -169,7 +169,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
}
else {
q_dotdot = block_type(di->dotdot_parent);
- if(q_dotdot != gfs2_inode_dir) {
+ if (q_dotdot != gfs2_inode_dir) {
log_err( _("Orphaned directory at block %llu (0x%llx) moved to lost+found\n"),
(unsigned long long)di->dinode,
(unsigned long long)di->dinode);
@@ -213,7 +213,7 @@ int pass3(struct gfs2_sbd *sdp)
for (tmp = osi_first(&dirtree); tmp; tmp = next) {
next = osi_next(tmp);
di = (struct dir_info *)tmp;
- while(!di->checked) {
+ while (!di->checked) {
/* FIXME: Change this so it returns success or
* failure and put the parent inode in a
* param */
@@ -229,10 +229,10 @@ int pass3(struct gfs2_sbd *sdp)
continue;
}
q = block_type(di->dinode);
- if(q == gfs2_bad_block) {
+ if (q == gfs2_bad_block) {
log_err( _("Found unlinked directory "
"containing bad block\n"));
- if(query(_("Clear unlinked directory "
+ if (query(_("Clear unlinked directory "
"with bad blocks? (y/n) "))) {
log_warn( _("inode %lld (0x%llx) is "
"now marked as free\n"),
@@ -250,13 +250,13 @@ int pass3(struct gfs2_sbd *sdp)
} else
log_err( _("Unlinked directory with bad block remains\n"));
}
- if(q != gfs2_inode_dir && q != gfs2_inode_file &&
+ if (q != gfs2_inode_dir && q != gfs2_inode_file &&
q != gfs2_inode_lnk && q != gfs2_inode_blk &&
q != gfs2_inode_chr && q != gfs2_inode_fifo &&
q != gfs2_inode_sock) {
log_err( _("Unlinked block marked as an inode "
"is not an inode\n"));
- if(!query(_("Clear the unlinked block?"
+ if (!query(_("Clear the unlinked block?"
" (y/n) "))) {
log_err( _("The block was not "
"cleared\n"));
@@ -281,10 +281,10 @@ int pass3(struct gfs2_sbd *sdp)
(unsigned long long)di->dinode);
ip = fsck_load_inode(sdp, di->dinode);
/* Don't skip zero size directories with eattrs */
- if(!ip->i_di.di_size && !ip->i_di.di_eattr){
+ if (!ip->i_di.di_size && !ip->i_di.di_eattr){
log_err( _("Unlinked directory has zero "
"size.\n"));
- if(query( _("Remove zero-size unlinked "
+ if (query( _("Remove zero-size unlinked "
"directory? (y/n) "))) {
fsck_blockmap_set(ip, di->dinode,
_("zero-sized unlinked inode"),
@@ -296,9 +296,9 @@ int pass3(struct gfs2_sbd *sdp)
"directory remains\n"));
}
}
- if(query( _("Add unlinked directory to "
+ if (query( _("Add unlinked directory to "
"lost+found? (y/n) "))) {
- if(add_inode_to_lf(ip)) {
+ if (add_inode_to_lf(ip)) {
fsck_inode_put(&ip);
stack;
return FSCK_ERROR;
@@ -311,7 +311,7 @@ int pass3(struct gfs2_sbd *sdp)
break;
}
}
- if(lf_dip)
+ if (lf_dip)
log_debug( _("At end of pass3, lost+found entries is %u\n"),
lf_dip->i_di.di_entries);
return FSCK_OK;
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 82144f9..4a1566d 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -29,7 +29,7 @@ static int fix_link_count(struct inode_info *ii, struct gfs2_inode *ip)
ip->i_di.di_nlink, ii->counted_links,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)ip->i_di.di_num.no_addr);
- if(ip->i_di.di_nlink == ii->counted_links)
+ if (ip->i_di.di_nlink == ii->counted_links)
return 0;
ip->i_di.di_nlink = ii->counted_links;
bmodified(ip->i_bh);
@@ -54,21 +54,21 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return 0;
next = osi_next(tmp);
- if(!(ii = (struct inode_info *)tmp)) {
+ if (!(ii = (struct inode_info *)tmp)) {
log_crit( _("osi_tree broken in scan_info_list!!\n"));
exit(FSCK_ERROR);
}
- if(ii->counted_links == 0) {
+ if (ii->counted_links == 0) {
log_err( _("Found unlinked inode at %llu (0x%llx)\n"),
(unsigned long long)ii->inode,
(unsigned long long)ii->inode);
q = block_type(ii->inode);
- if(q == gfs2_bad_block) {
+ if (q == gfs2_bad_block) {
log_err( _("Unlinked inode %llu (0x%llx) contains "
"bad blocks\n"),
(unsigned long long)ii->inode,
(unsigned long long)ii->inode);
- if(query( _("Delete unlinked inode with bad "
+ if (query( _("Delete unlinked inode with bad "
"blocks? (y/n) "))) {
ip = fsck_load_inode(sdp, ii->inode);
check_inode_eattr(ip,
@@ -82,7 +82,7 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
} else
log_err( _("Unlinked inode with bad blocks not cleared\n"));
}
- if(q != gfs2_inode_dir &&
+ if (q != gfs2_inode_dir &&
q != gfs2_inode_file &&
q != gfs2_inode_lnk &&
q != gfs2_inode_blk &&
@@ -95,7 +95,7 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
(unsigned long long)ii->inode,
(unsigned long long)ii->inode, q);
ip = fsck_load_inode(sdp, ii->inode);
- if(query(_("Delete unlinked inode? (y/n) "))) {
+ if (query(_("Delete unlinked inode? (y/n) "))) {
check_inode_eattr(ip,
&pass4_fxns_delete);
check_metatree(ip, &pass4_fxns_delete);
@@ -116,9 +116,9 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
/* We don't want to clear zero-size files with
* eattrs - there might be relevent info in
* them. */
- if(!ip->i_di.di_size && !ip->i_di.di_eattr){
+ if (!ip->i_di.di_size && !ip->i_di.di_eattr){
log_err( _("Unlinked inode has zero size\n"));
- if(query(_("Clear zero-size unlinked inode? "
+ if (query(_("Clear zero-size unlinked inode? "
"(y/n) "))) {
fsck_blockmap_set(ip, ii->inode,
_("unlinked zero-length"),
@@ -128,9 +128,9 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
}
}
- if(query( _("Add unlinked inode to lost+found? "
+ if (query( _("Add unlinked inode to lost+found? "
"(y/n)"))) {
- if(add_inode_to_lf(ip)) {
+ if (add_inode_to_lf(ip)) {
stack;
fsck_inode_put(&ip);
return -1;
@@ -141,8 +141,8 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
} else
log_err( _("Unlinked inode left unlinked\n"));
fsck_inode_put(&ip);
- } /* if(ii->counted_links == 0) */
- else if(ii->link_count != ii->counted_links) {
+ } /* if (ii->counted_links == 0) */
+ else if (ii->link_count != ii->counted_links) {
log_err( _("Link count inconsistent for inode %llu"
" (0x%llx) has %u but fsck found %u.\n"),
(unsigned long long)ii->inode,
@@ -150,7 +150,7 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
ii->counted_links);
/* Read in the inode, adjust the link count,
* and write it back out */
- if(query( _("Update link count for inode %llu"
+ if (query( _("Update link count for inode %llu"
" (0x%llx) ? (y/n) "),
(unsigned long long)ii->inode,
(unsigned long long)ii->inode)) {
@@ -175,7 +175,7 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
} /* osi_list_foreach(tmp, list) */
if (lf_addition) {
- if(!(ii = inodetree_find(lf_dip->i_di.di_num.no_addr))) {
+ if (!(ii = inodetree_find(lf_dip->i_di.di_num.no_addr))) {
log_crit( _("Unable to find lost+found inode in inode_hash!!\n"));
return -1;
} else {
@@ -197,16 +197,16 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
*/
int pass4(struct gfs2_sbd *sdp)
{
- if(lf_dip)
+ if (lf_dip)
log_debug( _("At beginning of pass4, lost+found entries is %u\n"),
lf_dip->i_di.di_entries);
log_info( _("Checking inode reference counts.\n"));
- if(scan_inode_list(sdp)) {
+ if (scan_inode_list(sdp)) {
stack;
return FSCK_ERROR;
}
- if(lf_dip)
+ if (lf_dip)
log_debug( _("At end of pass4, lost+found entries is %u\n"),
lf_dip->i_di.di_entries);
return FSCK_OK;
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index b2c9438..742dfca 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -64,7 +64,7 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer, unsigned int b
bit = 0;
end = (unsigned char *) buffer + buflen;
- while(byte < end) {
+ while (byte < end) {
rg_status = ((*byte >> bit) & GFS2_BIT_MASK);
block = rg_data + *rg_block;
warm_fuzzy_stuff(block);
@@ -85,8 +85,8 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer, unsigned int b
"block %llu (0x%llx).\n"),
(unsigned long long)block,
(unsigned long long)block);
- if(query(_("Do you want to fix the bitmap? (y/n) "))) {
- if(gfs2_set_bitmap(sdp, block, block_status))
+ if (query(_("Do you want to fix the bitmap? (y/n) "))) {
+ if (gfs2_set_bitmap(sdp, block, block_status))
log_err(_("Unlinked block %llu "
"(0x%llx) bitmap not fixed."
"\n"),
@@ -117,10 +117,10 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer, unsigned int b
log_err( _("Metadata type is %u (%s)\n"), q,
block_type_string(q));
- if(query(_("Fix bitmap for block %llu (0x%llx) ? (y/n) "),
+ if (query(_("Fix bitmap for block %llu (0x%llx) ? (y/n) "),
(unsigned long long)block,
(unsigned long long)block)) {
- if(gfs2_set_bitmap(sdp, block, block_status))
+ if (gfs2_set_bitmap(sdp, block, block_status))
log_err( _("Failed.\n"));
else
log_err( _("Succeeded.\n"));
@@ -159,7 +159,7 @@ static void update_rgrp(struct gfs2_sbd *sdp, struct rgrp_list *rgp,
}
/* actually adjust counters and write out to disk */
- if(rgp->rg.rg_free != count[0]) {
+ if (rgp->rg.rg_free != count[0]) {
log_err( _("RG #%llu (0x%llx) free count inconsistent: "
"is %u should be %u\n"),
(unsigned long long)rgp->ri.ri_addr,
@@ -168,21 +168,21 @@ static void update_rgrp(struct gfs2_sbd *sdp, struct rgrp_list *rgp,
rgp->rg.rg_free = count[0];
update = 1;
}
- if(rgp->rg.rg_dinodes != count[1]) {
+ if (rgp->rg.rg_dinodes != count[1]) {
log_err( _("Inode count inconsistent: is %u should be %u\n"),
rgp->rg.rg_dinodes, count[1]);
rgp->rg.rg_dinodes = count[1];
update = 1;
}
- if((rgp->ri.ri_data - count[0] - count[1]) != count[2]) {
+ if ((rgp->ri.ri_data - count[0] - count[1]) != count[2]) {
/* FIXME not sure how to handle this case ATM - it
* means that the total number of blocks we've counted
* exceeds the blocks in the rg */
log_err( _("Internal fsck error - AAHHH!\n"));
exit(FSCK_ERROR);
}
- if(update) {
- if(query( _("Update resource group counts? (y/n) "))) {
+ if (update) {
+ if (query( _("Update resource group counts? (y/n) "))) {
log_warn( _("Resource group counts updated\n"));
/* write out the rgrp */
gfs2_rgrp_out(&rgp->rg, rgp->bh[0]);
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index bb0309c..1dd49b1 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -746,7 +746,7 @@ static void sort_rgrp_list(osi_list_t *head)
osi_list_t *tmp, *x, *next;
int swaps;
- while(1) {
+ while (1) {
swaps = 0;
osi_list_foreach_safe(tmp, head, x) {
next = tmp->next;
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index f0f23db..2a35989 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -94,11 +94,11 @@ int fsck_query(const char *format, ...)
errors_found++;
fsck_abort = 0;
- if(opts.yes) {
+ if (opts.yes) {
errors_corrected++;
return 1;
}
- if(opts.no)
+ if (opts.no)
return 0;
opts.query = TRUE;
@@ -126,7 +126,7 @@ int fsck_query(const char *format, ...)
break;
}
printf("Continuing.\n");
- } else if(tolower(response) == 'y') {
+ } else if (tolower(response) == 'y') {
errors_corrected++;
ret = 1;
break;
@@ -256,12 +256,12 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
/* Check for the inode on the invalid inode reference list. */
uint8_t q;
- if(!(found_id = malloc(sizeof(*found_id)))) {
+ if (!(found_id = malloc(sizeof(*found_id)))) {
log_crit( _("Unable to allocate "
"inode_with_dups structure\n"));
return -1;
}
- if(!(memset(found_id, 0, sizeof(*found_id)))) {
+ if (!(memset(found_id, 0, sizeof(*found_id)))) {
log_crit( _("Unable to zero inode_with_dups "
"structure\n"));
return -1;
12 years, 8 months
gfs2-utils: master - fsck.gfs2: Make functions use sdp rather than sbp
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 650edf1c80d451159ce4ca3b01ddd40e326c0e6c
Parent: 2d2b671fc8118f4896b9cfdd33c1631a850ae42b
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Aug 8 08:41:36 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Mon Aug 29 12:48:33 2011 -0500
fsck.gfs2: Make functions use sdp rather than sbp
For years, the fsck.gfs2 tool used two different variable names to refer to the
same structure: sdp and sbp. This patch changes them all to sdp so they are now
consistent with the kernel code.
rhbz#675723
---
gfs2/fsck/fsck.h | 20 ++++++------
gfs2/fsck/initialize.c | 84 ++++++++++++++++++++++++------------------------
gfs2/fsck/main.c | 48 ++++++++++++++--------------
gfs2/fsck/metawalk.c | 24 +++++++-------
gfs2/fsck/metawalk.h | 4 +-
gfs2/fsck/pass1.c | 18 +++++-----
gfs2/fsck/pass1b.c | 34 ++++++++++----------
gfs2/fsck/pass1c.c | 26 +++++++-------
gfs2/fsck/pass2.c | 58 ++++++++++++++++----------------
gfs2/fsck/pass3.c | 28 ++++++++--------
gfs2/fsck/pass4.c | 14 ++++----
gfs2/fsck/pass5.c | 16 ++++----
12 files changed, 187 insertions(+), 187 deletions(-)
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index bc14b88..25bc3b9 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -92,21 +92,21 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */
must have been converted from gfs2_convert. */
};
-extern struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sbp, uint64_t block);
+extern struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block);
extern struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *bh);
extern void fsck_inode_put(struct gfs2_inode **ip);
-extern int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
+extern int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
int *all_clean);
-extern void destroy(struct gfs2_sbd *sbp);
-extern int pass1(struct gfs2_sbd *sbp);
-extern int pass1b(struct gfs2_sbd *sbp);
-extern int pass1c(struct gfs2_sbd *sbp);
-extern int pass2(struct gfs2_sbd *sbp);
-extern int pass3(struct gfs2_sbd *sbp);
-extern int pass4(struct gfs2_sbd *sbp);
-extern int pass5(struct gfs2_sbd *sbp);
+extern void destroy(struct gfs2_sbd *sdp);
+extern int pass1(struct gfs2_sbd *sdp);
+extern int pass1b(struct gfs2_sbd *sdp);
+extern int pass1c(struct gfs2_sbd *sdp);
+extern int pass2(struct gfs2_sbd *sdp);
+extern int pass3(struct gfs2_sbd *sdp);
+extern int pass4(struct gfs2_sbd *sdp);
+extern int pass5(struct gfs2_sbd *sdp);
extern int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count,
int *sane);
extern void gfs2_dup_free(void);
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 0930ba6..55a4f19 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -38,26 +38,26 @@ static struct master_dir fix_md;
* Change the lock protocol so nobody can mount the fs
*
*/
-static int block_mounters(struct gfs2_sbd *sbp, int block_em)
+static int block_mounters(struct gfs2_sbd *sdp, int block_em)
{
if(block_em) {
/* verify it starts with lock_ */
- if(!strncmp(sbp->sd_sb.sb_lockproto, "lock_", 5)) {
+ if(!strncmp(sdp->sd_sb.sb_lockproto, "lock_", 5)) {
/* Change lock_ to fsck_ */
- memcpy(sbp->sd_sb.sb_lockproto, "fsck_", 5);
+ memcpy(sdp->sd_sb.sb_lockproto, "fsck_", 5);
}
/* FIXME: Need to do other verification in the else
* case */
} else {
/* verify it starts with fsck_ */
/* verify it starts with lock_ */
- if(!strncmp(sbp->sd_sb.sb_lockproto, "fsck_", 5)) {
+ if(!strncmp(sdp->sd_sb.sb_lockproto, "fsck_", 5)) {
/* Change fsck_ to lock_ */
- memcpy(sbp->sd_sb.sb_lockproto, "lock_", 5);
+ memcpy(sdp->sd_sb.sb_lockproto, "lock_", 5);
}
}
- if(write_sb(sbp)) {
+ if(write_sb(sdp)) {
stack;
return -1;
}
@@ -1180,7 +1180,7 @@ static int fill_super_block(struct gfs2_sbd *sdp)
* initialize - initialize superblock pointer
*
*/
-int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
+int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
int *all_clean)
{
int clean_journals = 0, open_flag;
@@ -1192,8 +1192,8 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
else
open_flag = O_RDWR | O_EXCL;
- sbp->device_fd = open(opts.device, open_flag);
- if (sbp->device_fd < 0) {
+ sdp->device_fd = open(opts.device, open_flag);
+ if (sdp->device_fd < 0) {
int is_mounted, ro;
if (open_flag == O_RDONLY || errno != EBUSY) {
@@ -1207,10 +1207,10 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
allow it.) We use is_pathname_mounted here even though
we're specifying a device name, not a path name. The
function checks for device as well. */
- strncpy(sbp->device_name, opts.device,
- sizeof(sbp->device_name));
- sbp->path_name = sbp->device_name; /* This gets overwritten */
- is_mounted = is_pathname_mounted(sbp, &ro);
+ strncpy(sdp->device_name, opts.device,
+ sizeof(sdp->device_name));
+ sdp->path_name = sdp->device_name; /* This gets overwritten */
+ is_mounted = is_pathname_mounted(sdp, &ro);
/* If the device is busy, but not because it's mounted, fail.
This protects against cases where the file system is LVM
and perhaps mounted on a different node. */
@@ -1225,49 +1225,49 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
/* The device is mounted RO, so it's likely our own root
file system. We can only do so much to protect the users
from themselves. Try opening without O_EXCL. */
- if ((sbp->device_fd = open(opts.device, O_RDWR)) < 0)
+ if ((sdp->device_fd = open(opts.device, O_RDWR)) < 0)
goto mount_fail;
was_mounted_ro = 1;
}
/* read in sb from disk */
- if (fill_super_block(sbp))
+ if (fill_super_block(sdp))
return FSCK_ERROR;
/* Change lock protocol to be fsck_* instead of lock_* */
- if(!opts.no && preen_is_safe(sbp, preen, force_check)) {
- if(block_mounters(sbp, 1)) {
+ if(!opts.no && preen_is_safe(sdp, preen, force_check)) {
+ if(block_mounters(sdp, 1)) {
log_err( _("Unable to block other mounters\n"));
return FSCK_USAGE;
}
}
/* Get master dinode */
- sbp->master_dir = inode_read(sbp, sbp->sd_sb.sb_master_dir.no_addr);
- if (sbp->master_dir->i_di.di_header.mh_magic != GFS2_MAGIC ||
- sbp->master_dir->i_di.di_header.mh_type != GFS2_METATYPE_DI ||
- !sbp->master_dir->i_di.di_size) {
- inode_put(&sbp->master_dir);
- rebuild_master(sbp);
- sbp->master_dir = inode_read(sbp,
- sbp->sd_sb.sb_master_dir.no_addr);
+ sdp->master_dir = inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr);
+ if (sdp->master_dir->i_di.di_header.mh_magic != GFS2_MAGIC ||
+ sdp->master_dir->i_di.di_header.mh_type != GFS2_METATYPE_DI ||
+ !sdp->master_dir->i_di.di_size) {
+ inode_put(&sdp->master_dir);
+ rebuild_master(sdp);
+ sdp->master_dir = inode_read(sdp,
+ sdp->sd_sb.sb_master_dir.no_addr);
}
/* Look up the "per_node" inode. If there are journals missing, we
need to figure out what's missing from per_node. And we need all
our journals to be there before we can replay them. */
- lookup_per_node(sbp, 0);
+ lookup_per_node(sdp, 0);
/* verify various things */
- if(replay_journals(sbp, preen, force_check, &clean_journals)) {
- if(!opts.no && preen_is_safe(sbp, preen, force_check))
- block_mounters(sbp, 0);
+ if(replay_journals(sdp, preen, force_check, &clean_journals)) {
+ if(!opts.no && preen_is_safe(sdp, preen, force_check))
+ block_mounters(sdp, 0);
stack;
return FSCK_ERROR;
}
- if (sbp->md.journals == clean_journals)
+ if (sdp->md.journals == clean_journals)
*all_clean = 1;
else {
if (force_check || !preen)
@@ -1277,7 +1277,7 @@ int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
if (!force_check && *all_clean && preen)
return FSCK_OK;
- if (init_system_inodes(sbp))
+ if (init_system_inodes(sdp))
return FSCK_ERROR;
return FSCK_OK;
@@ -1287,30 +1287,30 @@ mount_fail:
return FSCK_USAGE;
}
-static void destroy_sbp(struct gfs2_sbd *sbp)
+static void destroy_sdp(struct gfs2_sbd *sdp)
{
if(!opts.no) {
- if(block_mounters(sbp, 0)) {
+ if(block_mounters(sdp, 0)) {
log_warn( _("Unable to unblock other mounters - manual intervention required\n"));
log_warn( _("Use 'gfs2_tool sb <device> proto' to fix\n"));
}
log_info( _("Syncing the device.\n"));
- fsync(sbp->device_fd);
+ fsync(sdp->device_fd);
}
- empty_super_block(sbp);
- close(sbp->device_fd);
+ empty_super_block(sdp);
+ close(sdp->device_fd);
if (was_mounted_ro && errors_corrected) {
- sbp->device_fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
- if (sbp->device_fd >= 0) {
- write(sbp->device_fd, "2", 1);
- close(sbp->device_fd);
+ sdp->device_fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
+ if (sdp->device_fd >= 0) {
+ write(sdp->device_fd, "2", 1);
+ close(sdp->device_fd);
} else
log_err( _("fsck.gfs2: Non-fatal error dropping "
"caches.\n"));
}
}
-void destroy(struct gfs2_sbd *sbp)
+void destroy(struct gfs2_sbd *sdp)
{
- destroy_sbp(sbp);
+ destroy_sdp(sdp);
}
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index d0aceb1..dc3f7aa 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -218,7 +218,7 @@ static void check_statfs(struct gfs2_sbd *sdp)
int main(int argc, char **argv)
{
struct gfs2_sbd sb;
- struct gfs2_sbd *sbp = &sb;
+ struct gfs2_sbd *sdp = &sb;
int j;
int error = 0;
int all_clean = 0;
@@ -226,18 +226,18 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
textdomain("gfs2-utils");
- memset(sbp, 0, sizeof(*sbp));
+ memset(sdp, 0, sizeof(*sdp));
if((error = read_cmdline(argc, argv, &opts)))
exit(error);
setbuf(stdout, NULL);
log_notice( _("Initializing fsck\n"));
- if ((error = initialize(sbp, force_check, preen, &all_clean)))
+ if ((error = initialize(sdp, force_check, preen, &all_clean)))
exit(error);
if (!force_check && all_clean && preen) {
log_err( _("%s: clean.\n"), opts.device);
- destroy(sbp);
+ destroy(sdp);
exit(FSCK_OK);
}
@@ -245,7 +245,7 @@ int main(int argc, char **argv)
log_notice( _("Starting pass1\n"));
pass = "pass 1";
last_reported_block = 0;
- if ((error = pass1(sbp)))
+ if ((error = pass1(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -258,7 +258,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 1b";
log_notice( _("Starting pass1b\n"));
- if((error = pass1b(sbp)))
+ if((error = pass1b(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -271,7 +271,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 1c";
log_notice( _("Starting pass1c\n"));
- if((error = pass1c(sbp)))
+ if((error = pass1c(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -284,7 +284,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 2";
log_notice( _("Starting pass2\n"));
- if ((error = pass2(sbp)))
+ if ((error = pass2(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -297,7 +297,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 3";
log_notice( _("Starting pass3\n"));
- if ((error = pass3(sbp)))
+ if ((error = pass3(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -310,7 +310,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 4";
log_notice( _("Starting pass4\n"));
- if ((error = pass4(sbp)))
+ if ((error = pass4(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -323,7 +323,7 @@ int main(int argc, char **argv)
last_reported_block = 0;
pass = "pass 5";
log_notice( _("Starting pass5\n"));
- if ((error = pass5(sbp)))
+ if ((error = pass5(sdp)))
exit(error);
if (skip_this_pass || fsck_abort) {
skip_this_pass = FALSE;
@@ -337,26 +337,26 @@ int main(int argc, char **argv)
}
if (!fsck_abort)
- check_statfs(sbp);
+ check_statfs(sdp);
/* Free up our system inodes */
- inode_put(&sbp->md.inum);
- inode_put(&sbp->md.statfs);
- for (j = 0; j < sbp->md.journals; j++)
- inode_put(&sbp->md.journal[j]);
- inode_put(&sbp->md.jiinode);
- inode_put(&sbp->md.riinode);
- inode_put(&sbp->md.qinode);
- inode_put(&sbp->md.pinode);
- inode_put(&sbp->md.rooti);
- inode_put(&sbp->master_dir);
+ inode_put(&sdp->md.inum);
+ inode_put(&sdp->md.statfs);
+ for (j = 0; j < sdp->md.journals; j++)
+ inode_put(&sdp->md.journal[j]);
+ inode_put(&sdp->md.jiinode);
+ inode_put(&sdp->md.riinode);
+ inode_put(&sdp->md.qinode);
+ inode_put(&sdp->md.pinode);
+ inode_put(&sdp->md.rooti);
+ inode_put(&sdp->master_dir);
if (lf_dip)
inode_put(&lf_dip);
if (!opts.no && errors_corrected)
log_notice( _("Writing changes to disk\n"));
- fsync(sbp->device_fd);
- destroy(sbp);
+ fsync(sdp->device_fd);
+ destroy(sdp);
log_notice( _("gfs2_fsck complete\n"));
if (!error) {
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 5d48fbe..808673c 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -183,14 +183,14 @@ struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp, uint64_t block)
/* fsck_load_inode - same as gfs2_load_inode() in libgfs2 but system inodes
get special treatment. */
-struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sbp, uint64_t block)
+struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block)
{
struct gfs2_inode *ip = NULL;
- ip = fsck_system_inode(sbp, block);
+ ip = fsck_system_inode(sdp, block);
if (ip)
return ip;
- return inode_read(sbp, block);
+ return inode_read(sdp, block);
}
/* fsck_inode_get - same as inode_get() in libgfs2 but system inodes
@@ -595,7 +595,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
uint64_t first_ok_leaf;
struct gfs2_buffer_head *lbh;
int lindex;
- struct gfs2_sbd *sbp = ip->i_sbd;
+ struct gfs2_sbd *sdp = ip->i_sbd;
uint16_t count;
int ref_count = 0, exp_count = 0;
@@ -606,7 +606,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
for(lindex = 0; lindex < (1 << ip->i_di.di_depth); lindex++) {
gfs2_get_leaf_nr(ip, lindex, &leaf_no);
if (gfs2_check_range(ip->i_sbd, leaf_no) == 0) {
- lbh = bread(sbp, leaf_no);
+ lbh = bread(sdp, leaf_no);
/* Make sure it's really a valid leaf block. */
if (gfs2_check_meta(lbh, GFS2_METATYPE_LF) == 0) {
brelse(lbh);
@@ -673,7 +673,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
}
/* Try to read in the leaf block. */
- lbh = bread(sbp, leaf_no);
+ lbh = bread(sdp, leaf_no);
/* Make sure it's really a valid leaf block. */
if (gfs2_check_meta(lbh, GFS2_METATYPE_LF)) {
warn_and_patch(ip, &leaf_no, &bad_leaf,
@@ -737,7 +737,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if(count != leaf.lf_entries) {
brelse(lbh);
- lbh = bread(sbp, leaf_no);
+ lbh = bread(sdp, leaf_no);
gfs2_leaf_in(&leaf, lbh);
log_err( _("Leaf %llu (0x%llx) entry "
@@ -1384,12 +1384,12 @@ int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
return error;
}
-int check_dir(struct gfs2_sbd *sbp, uint64_t block, struct metawalk_fxns *pass)
+int check_dir(struct gfs2_sbd *sdp, uint64_t block, struct metawalk_fxns *pass)
{
struct gfs2_inode *ip;
int error = 0;
- ip = fsck_load_inode(sbp, block);
+ ip = fsck_load_inode(sdp, block);
if(ip->i_di.di_flags & GFS2_DIF_EXHASH)
error = check_leaf_blks(ip, pass);
@@ -1426,7 +1426,7 @@ static int remove_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
-int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
+int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
uint64_t dentryblock)
{
struct metawalk_fxns remove_dentry_fxns = {0};
@@ -1437,7 +1437,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
" (0x%llx)\n"), (unsigned long long)dentryblock,
(unsigned long long)dentryblock,
(unsigned long long)dir, (unsigned long long)dir);
- if(gfs2_check_range(sbp, dir)) {
+ if(gfs2_check_range(sdp, dir)) {
log_err( _("Parent directory out of range\n"));
return 1;
}
@@ -1451,7 +1451,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
}
/* Need to run check_dir with a private var of dentryblock,
* and fxns that remove that dentry if found */
- error = check_dir(sbp, dir, &remove_dentry_fxns);
+ error = check_dir(sdp, dir, &remove_dentry_fxns);
return error;
}
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 3ee12fe..c1e61fb 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -9,11 +9,11 @@ struct metawalk_fxns;
extern int check_inode_eattr(struct gfs2_inode *ip,
struct metawalk_fxns *pass);
extern int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass);
-extern int check_dir(struct gfs2_sbd *sbp, uint64_t block,
+extern int check_dir(struct gfs2_sbd *sdp, uint64_t block,
struct metawalk_fxns *pass);
extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
struct metawalk_fxns *pass);
-extern int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
+extern int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
uint64_t dentryblock);
extern int delete_block(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, const char *btype,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 6649ec8..ef4628c 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1189,7 +1189,7 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
static int check_system_inode(struct gfs2_sbd *sdp,
struct gfs2_inode **sysinode,
const char *filename,
- int builder(struct gfs2_sbd *sbp),
+ int builder(struct gfs2_sbd *sdp),
enum gfs2_mark_block mark)
{
uint64_t iblock = 0;
@@ -1383,7 +1383,7 @@ static int check_system_inodes(struct gfs2_sbd *sdp)
* inodes size
* dir info
*/
-int pass1(struct gfs2_sbd *sbp)
+int pass1(struct gfs2_sbd *sdp)
{
struct gfs2_buffer_head *bh;
osi_list_t *tmp;
@@ -1400,7 +1400,7 @@ int pass1(struct gfs2_sbd *sbp)
* the sweeps start that we won't find otherwise? */
/* Make sure the system inodes are okay & represented in the bitmap. */
- check_system_inodes(sbp);
+ check_system_inodes(sdp);
/* So, do we do a depth first search starting at the root
* inode, or use the rg bitmaps, or just read every fs block
@@ -1411,7 +1411,7 @@ int pass1(struct gfs2_sbd *sbp)
* uses the rg bitmaps, so maybe that's the best way to start
* things - we can change the method later if necessary.
*/
- for (tmp = sbp->rglist.next; tmp != &sbp->rglist;
+ for (tmp = sdp->rglist.next; tmp != &sdp->rglist;
tmp = tmp->next, rg_count++) {
log_debug( _("Checking metadata in Resource Group #%llu\n"),
(unsigned long long)rg_count);
@@ -1427,7 +1427,7 @@ int pass1(struct gfs2_sbd *sbp)
}
/* rgrps and bitmaps don't have bits to represent
their blocks, so don't do this:
- check_n_fix_bitmap(sbp, rgd->ri.ri_addr + i,
+ check_n_fix_bitmap(sdp, rgd->ri.ri_addr + i,
gfs2_meta_rgrp);*/
}
@@ -1448,7 +1448,7 @@ int pass1(struct gfs2_sbd *sbp)
skip_this_pass = FALSE;
fflush(stdout);
}
- if (fsck_system_inode(sbp, block)) {
+ if (fsck_system_inode(sdp, block)) {
log_debug(_("Already processed system inode "
"%lld (0x%llx)\n"),
(unsigned long long)block,
@@ -1456,7 +1456,7 @@ int pass1(struct gfs2_sbd *sbp)
first = 0;
continue;
}
- bh = bread(sbp, block);
+ bh = bread(sdp, block);
if (gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
log_err( _("Found invalid inode at block #"
@@ -1469,9 +1469,9 @@ int pass1(struct gfs2_sbd *sbp)
brelse(bh);
return FSCK_ERROR;
}
- check_n_fix_bitmap(sbp, block,
+ check_n_fix_bitmap(sdp, block,
gfs2_block_free);
- } else if (handle_di(sbp, bh) < 0) {
+ } else if (handle_di(sdp, bh) < 0) {
stack;
brelse(bh);
return FSCK_ERROR;
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 5bbda7c..373b796 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -90,12 +90,12 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
uint64_t parent, struct gfs2_buffer_head **bh,
void *private)
{
- struct gfs2_sbd *sbp = ip->i_sbd;
+ struct gfs2_sbd *sdp = ip->i_sbd;
int error;
error = add_duplicate_ref(ip, block, ref_as_ea, 1, INODE_VALID);
if (!error)
- *bh = bread(sbp, block);
+ *bh = bread(sdp, block);
return error;
}
@@ -104,12 +104,12 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
uint64_t parent, struct gfs2_buffer_head **bh,
void *private)
{
- struct gfs2_sbd *sbp = ip->i_sbd;
+ struct gfs2_sbd *sdp = ip->i_sbd;
int error;
error = add_duplicate_ref(ip, block, ref_as_ea, 1, INODE_VALID);
if (!error)
- *bh = bread(sbp, block);
+ *bh = bread(sdp, block);
return error;
}
@@ -321,12 +321,12 @@ static int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
}
/* Finds all references to duplicate blocks in the metadata */
-static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode)
+static int find_block_ref(struct gfs2_sbd *sdp, uint64_t inode)
{
struct gfs2_inode *ip;
int error = 0;
- ip = fsck_load_inode(sbp, inode); /* bread, inode_get */
+ ip = fsck_load_inode(sdp, inode); /* bread, inode_get */
/* double-check the meta header just to be sure it's metadata */
if (ip->i_di.di_header.mh_magic != GFS2_MAGIC ||
ip->i_di.di_header.mh_type != GFS2_METATYPE_DI) {
@@ -386,7 +386,7 @@ static void log_inode_reference(struct duptree *b, osi_list_t *tmp, int inval)
(unsigned long long)b->block, reftypestring);
}
-static int clear_a_reference(struct gfs2_sbd *sbp, struct duptree *b,
+static int clear_a_reference(struct gfs2_sbd *sdp, struct duptree *b,
osi_list_t *ref_list, struct dup_handler *dh,
int inval)
{
@@ -423,7 +423,7 @@ static int clear_a_reference(struct gfs2_sbd *sbp, struct duptree *b,
(unsigned long long)id->block_no);
clear_dup_fxns.private = (void *) dh;
/* Clear the EAs for the inode first */
- ip = fsck_load_inode(sbp, id->block_no);
+ ip = fsck_load_inode(sdp, id->block_no);
check_inode_eattr(ip, &clear_dup_fxns);
/* If the dup wasn't only in the EA, clear the inode */
if (id->reftypecount[ref_as_data] ||
@@ -444,7 +444,7 @@ static int clear_a_reference(struct gfs2_sbd *sbp, struct duptree *b,
return 0;
}
-static int handle_dup_blk(struct gfs2_sbd *sbp, struct duptree *b)
+static int handle_dup_blk(struct gfs2_sbd *sdp, struct duptree *b)
{
struct gfs2_inode *ip;
osi_list_t *tmp;
@@ -480,7 +480,7 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct duptree *b)
struct gfs2_buffer_head *bh;
uint32_t cmagic;
- bh = bread(sbp, b->block);
+ bh = bread(sdp, b->block);
cmagic = ((struct gfs2_meta_header *)(bh->b_data))->mh_magic;
brelse(bh);
if (be32_to_cpu(cmagic) == GFS2_MAGIC) {
@@ -502,7 +502,7 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct duptree *b)
log_warn( _("Clearing inode %lld (0x%llx)...\n"),
(unsigned long long)id->block_no,
(unsigned long long)id->block_no);
- ip = fsck_load_inode(sbp, id->block_no);
+ ip = fsck_load_inode(sdp, id->block_no);
ii = inodetree_find(ip->i_di.di_num.no_addr);
if (ii)
inodetree_delete(ii);
@@ -536,10 +536,10 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct duptree *b)
osi_list_foreach(tmp, &b->ref_inode_list)
log_inode_reference(b, tmp, 0);
- last_reference = clear_a_reference(sbp, b, &b->ref_invinode_list,
+ last_reference = clear_a_reference(sdp, b, &b->ref_invinode_list,
&dh, 1);
if (!last_reference)
- last_reference = clear_a_reference(sbp, b, &b->ref_inode_list,
+ last_reference = clear_a_reference(sdp, b, &b->ref_inode_list,
&dh, 0);
if (last_reference && !osi_list_empty(&b->ref_inode_list)) {
@@ -556,7 +556,7 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct duptree *b)
"reference in inode %lld (0x%llx).\n"),
(unsigned long long)id->block_no,
(unsigned long long)id->block_no);
- ip = fsck_load_inode(sbp, id->block_no);
+ ip = fsck_load_inode(sdp, id->block_no);
q = block_type(id->block_no);
if (q == gfs2_inode_invalid) {
@@ -597,7 +597,7 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct duptree *b)
/* Pass 1b handles finding the previous inode for a duplicate block
* When found, store the inodes pointing to the duplicate block for
* use in pass2 */
-int pass1b(struct gfs2_sbd *sbp)
+int pass1b(struct gfs2_sbd *sdp)
{
struct duptree *b;
uint64_t i;
@@ -642,7 +642,7 @@ int pass1b(struct gfs2_sbd *sbp)
(unsigned long long)i);
warm_fuzzy_stuff(i);
- if (find_block_ref(sbp, i) < 0) {
+ if (find_block_ref(sdp, i) < 0) {
stack;
rc = FSCK_ERROR;
goto out;
@@ -657,7 +657,7 @@ out:
next = osi_next(n);
b = (struct duptree *)n;
if (!skip_this_pass && !rc) /* no error & not asked to skip the rest */
- handle_dup_blk(sbp, b);
+ handle_dup_blk(sdp, b);
/* Do not attempt to free the dup_blocks list or its parts
here because any func that calls check_metatree needs
to check duplicate status based on this linked list.
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index 781e8d5..3367e77 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -74,11 +74,11 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
uint64_t parent, struct gfs2_buffer_head **bh,
void *private)
{
- struct gfs2_sbd *sbp = ip->i_sbd;
+ struct gfs2_sbd *sdp = ip->i_sbd;
uint8_t q;
struct gfs2_buffer_head *indir_bh = NULL;
- if(gfs2_check_range(sbp, block)) {
+ if(gfs2_check_range(sdp, block)) {
log_err( _("Extended attributes indirect block #%llu"
" (0x%llx) for inode #%llu"
" (0x%llx) out of range...removing\n"),
@@ -100,7 +100,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
return ask_remove_eattr(ip);
}
else
- indir_bh = bread(sbp, block);
+ indir_bh = bread(sdp, block);
*bh = indir_bh;
return 0;
@@ -110,10 +110,10 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
uint64_t parent, struct gfs2_buffer_head **bh,
void *private)
{
- struct gfs2_sbd *sbp = ip->i_sbd;
+ struct gfs2_sbd *sdp = ip->i_sbd;
uint8_t q;
- if(gfs2_check_range(sbp, block)) {
+ if(gfs2_check_range(sdp, block)) {
log_err( _("Extended attributes block for inode #%llu"
" (0x%llx) out of range.\n"),
(unsigned long long)ip->i_di.di_num.no_addr,
@@ -129,7 +129,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
return ask_remove_eattr(ip);
}
else
- *bh = bread(sbp, block);
+ *bh = bread(sdp, block);
return 0;
}
@@ -207,11 +207,11 @@ static int check_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_ptr,
struct gfs2_ea_header *ea_hdr_prev, void *private)
{
uint8_t q;
- struct gfs2_sbd *sbp = ip->i_sbd;
+ struct gfs2_sbd *sdp = ip->i_sbd;
q = block_type(be64_to_cpu(*ea_ptr));
if(q != gfs2_meta_eattr) {
- if(remove_eattr_entry(sbp, leaf_bh, ea_hdr, ea_hdr_prev)){
+ if(remove_eattr_entry(sdp, leaf_bh, ea_hdr, ea_hdr_prev)){
stack;
return -1;
}
@@ -222,7 +222,7 @@ static int check_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_ptr,
/* Go over all inodes with extended attributes and verify the EAs are
* valid */
-int pass1c(struct gfs2_sbd *sbp)
+int pass1c(struct gfs2_sbd *sdp)
{
uint64_t block_no = 0;
struct gfs2_buffer_head *bh;
@@ -239,20 +239,20 @@ int pass1c(struct gfs2_sbd *sbp)
pass1c_fxns.private = NULL;
log_info( _("Looking for inodes containing ea blocks...\n"));
- osi_list_foreach_safe(tmp, &sbp->eattr_blocks.list, x) {
+ osi_list_foreach_safe(tmp, &sdp->eattr_blocks.list, x) {
ea_block = osi_list_entry(tmp, struct special_blocks, list);
block_no = ea_block->block;
warm_fuzzy_stuff(block_no);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- bh = bread(sbp, block_no);
+ bh = bread(sdp, block_no);
if (!gfs2_check_meta(bh, GFS2_METATYPE_DI)) { /* if a dinode */
log_info( _("EA in inode %llu (0x%llx)\n"),
(unsigned long long)block_no,
(unsigned long long)block_no);
- gfs2_special_clear(&sbp->eattr_blocks, block_no);
- ip = fsck_inode_get(sbp, bh);
+ gfs2_special_clear(&sdp->eattr_blocks, block_no);
+ ip = fsck_inode_get(sdp, bh);
ip->bh_owned = 1;
log_debug( _("Found eattr at %llu (0x%llx)\n"),
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index d0d67ed..b4fcc1d 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -20,7 +20,7 @@
/* Set children's parent inode in dir_info structure - ext2 does not set
* dotdot inode here, but instead in pass3 - should we? */
-static int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
+static int set_parent_dir(struct gfs2_sbd *sdp, uint64_t childblock,
uint64_t parentblock)
{
struct dir_info *di;
@@ -60,7 +60,7 @@ static int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
}
/* Set's the child's '..' directory inode number in dir_info structure */
-static int set_dotdot_dir(struct gfs2_sbd *sbp, uint64_t childblock,
+static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
uint64_t parentblock)
{
struct dir_info *di;
@@ -70,7 +70,7 @@ static int set_dotdot_dir(struct gfs2_sbd *sbp, uint64_t childblock,
if(di->dinode == childblock) {
/* Special case for root inode because we set
* it earlier */
- if(di->dotdot_parent && sbp->md.rooti->i_di.di_num.no_addr
+ if(di->dotdot_parent && sdp->md.rooti->i_di.di_num.no_addr
!= di->dinode) {
/* This should never happen */
log_crit( _("Dotdot parent already set for"
@@ -177,7 +177,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_buffer_head *bh, char *filename,
uint16_t *count, void *priv)
{
- struct gfs2_sbd *sbp = ip->i_sbd;
+ struct gfs2_sbd *sdp = ip->i_sbd;
uint8_t q;
char tmp_name[MAX_FILENAME];
uint64_t entryblock;
@@ -277,7 +277,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ip->i_di.di_num.no_addr == entryblock)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sbp, entryblock);
+ entry_ip = fsck_load_inode(sdp, entryblock);
check_inode_eattr(entry_ip, &pass2_fxns_delete);
check_metatree(entry_ip, &pass2_fxns_delete);
if (entry_ip != ip)
@@ -351,7 +351,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ip->i_di.di_num.no_addr == entryblock)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sbp, entryblock);
+ entry_ip = fsck_load_inode(sdp, entryblock);
check_inode_eattr(entry_ip, &clear_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -375,7 +375,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ip->i_di.di_num.no_addr == entryblock)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sbp, entryblock);
+ entry_ip = fsck_load_inode(sdp, entryblock);
check_inode_eattr(entry_ip, &clear_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -406,7 +406,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ip->i_di.di_num.no_addr == entryblock)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sbp, entryblock);
+ entry_ip = fsck_load_inode(sdp, entryblock);
check_inode_eattr(entry_ip, &clear_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -434,7 +434,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ip->i_di.di_num.no_addr == entryblock)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sbp, entryblock);
+ entry_ip = fsck_load_inode(sdp, entryblock);
check_inode_eattr(entry_ip, &clear_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -454,7 +454,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ip->i_di.di_num.no_addr == entryblock)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sbp, entryblock);
+ entry_ip = fsck_load_inode(sdp, entryblock);
check_inode_eattr(entry_ip, &clear_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -466,7 +466,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* Add the address this entry is pointing to
* to this inode's dotdot_parent in
* dir_info */
- if(set_dotdot_dir(sbp, ip->i_di.di_num.no_addr, entryblock)) {
+ if(set_dotdot_dir(sdp, ip->i_di.di_num.no_addr, entryblock)) {
stack;
return -1;
}
@@ -485,7 +485,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
/*log_debug( _("Found plain directory dentry\n"));*/
- error = set_parent_dir(sbp, entryblock, ip->i_di.di_num.no_addr);
+ error = set_parent_dir(sdp, entryblock, ip->i_di.di_num.no_addr);
if(error > 0) {
log_err( _("%s: Hard link to block %llu (0x%llx"
") detected.\n"), tmp_name,
@@ -532,7 +532,7 @@ struct metawalk_fxns pass2_fxns = {
/* Check system directory inode */
/* Should work for all system directories: root, master, jindex, per_node */
static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
- int builder(struct gfs2_sbd *sbp))
+ int builder(struct gfs2_sbd *sdp))
{
uint64_t iblock = 0;
struct dir_status ds = {0};
@@ -637,12 +637,12 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
/**
* is_system_dir - determine if a given block is for a system directory.
*/
-static inline int is_system_dir(struct gfs2_sbd *sbp, uint64_t block)
+static inline int is_system_dir(struct gfs2_sbd *sdp, uint64_t block)
{
- if (block == sbp->md.rooti->i_di.di_num.no_addr ||
- block == sbp->md.jiinode->i_di.di_num.no_addr ||
- block == sbp->md.pinode->i_di.di_num.no_addr ||
- block == sbp->master_dir->i_di.di_num.no_addr)
+ if (block == sdp->md.rooti->i_di.di_num.no_addr ||
+ block == sdp->md.jiinode->i_di.di_num.no_addr ||
+ block == sdp->md.pinode->i_di.di_num.no_addr ||
+ block == sdp->master_dir->i_di.di_num.no_addr)
return TRUE;
return FALSE;
}
@@ -658,7 +658,7 @@ static inline int is_system_dir(struct gfs2_sbd *sbp, uint64_t block)
* directory name length
* entries in range
*/
-int pass2(struct gfs2_sbd *sbp)
+int pass2(struct gfs2_sbd *sdp)
{
uint64_t dirblk;
uint8_t q;
@@ -670,25 +670,25 @@ int pass2(struct gfs2_sbd *sbp)
int error = 0;
/* Check all the system directory inodes. */
- if (check_system_dir(sbp->md.jiinode, "jindex", build_jindex)) {
+ if (check_system_dir(sdp->md.jiinode, "jindex", build_jindex)) {
stack;
return FSCK_ERROR;
}
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- if (check_system_dir(sbp->md.pinode, "per_node", build_per_node)) {
+ if (check_system_dir(sdp->md.pinode, "per_node", build_per_node)) {
stack;
return FSCK_ERROR;
}
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- if (check_system_dir(sbp->master_dir, "master", build_master)) {
+ if (check_system_dir(sdp->master_dir, "master", build_master)) {
stack;
return FSCK_ERROR;
}
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- if (check_system_dir(sbp->md.rooti, "root", build_root)) {
+ if (check_system_dir(sdp->md.rooti, "root", build_root)) {
stack;
return FSCK_ERROR;
}
@@ -702,7 +702,7 @@ int pass2(struct gfs2_sbd *sbp)
return FSCK_OK;
/* Skip the system inodes - they're checked above */
- if (is_system_dir(sbp, dirblk))
+ if (is_system_dir(sdp, dirblk))
continue;
q = block_type(dirblk);
@@ -718,7 +718,7 @@ int pass2(struct gfs2_sbd *sbp)
if(ds.q == gfs2_bad_block) {
/* First check that the directory's metatree
* is valid */
- ip = fsck_load_inode(sbp, dirblk);
+ ip = fsck_load_inode(sdp, dirblk);
error = check_metatree(ip, &pass2_fxns);
fsck_inode_put(&ip);
if (error < 0) {
@@ -726,7 +726,7 @@ int pass2(struct gfs2_sbd *sbp)
return error;
}
}
- error = check_dir(sbp, dirblk, &pass2_fxns);
+ error = check_dir(sdp, dirblk, &pass2_fxns);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
if(error < 0) {
@@ -748,7 +748,7 @@ int pass2(struct gfs2_sbd *sbp)
(unsigned long long)dirblk,
(unsigned long long)di->treewalk_parent,
(unsigned long long)di->treewalk_parent)) {
- error = remove_dentry_from_dir(sbp, di->treewalk_parent,
+ error = remove_dentry_from_dir(sdp, di->treewalk_parent,
dirblk);
if(error < 0) {
stack;
@@ -773,9 +773,9 @@ int pass2(struct gfs2_sbd *sbp)
/* Can't use fsck_blockmap_set here because we don't
have an inode in memory. */
gfs2_blockmap_set(bl, dirblk, gfs2_inode_invalid);
- check_n_fix_bitmap(sbp, dirblk, gfs2_inode_invalid);
+ check_n_fix_bitmap(sdp, dirblk, gfs2_inode_invalid);
}
- ip = fsck_load_inode(sbp, dirblk);
+ ip = fsck_load_inode(sdp, dirblk);
if(!ds.dotdir) {
log_err(_("No '.' entry found for directory inode at "
"block %llu (0x%llx)\n"),
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 93514be..9a022ca 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -16,7 +16,7 @@
#include "metawalk.h"
#include "util.h"
-static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
+static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
uint64_t olddotdot, uint64_t block)
{
char *filename;
@@ -24,8 +24,8 @@ static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
struct gfs2_inode *ip, *pip;
uint64_t cur_blks;
- ip = fsck_load_inode(sbp, block);
- pip = fsck_load_inode(sbp, newdotdot);
+ ip = fsck_load_inode(sdp, block);
+ pip = fsck_load_inode(sdp, newdotdot);
/* FIXME: Need to add some interactive
* options here and come up with a
* good default for non-interactive */
@@ -75,7 +75,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
return 0;
}
-static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
+static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
struct dir_info *di)
{
struct dir_info *pdi;
@@ -115,7 +115,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
" fixing dotdot -> %llu (0x%llx)\n"),
(unsigned long long)di->treewalk_parent,
(unsigned long long)di->treewalk_parent);
- attach_dotdot_to(sbp, di->treewalk_parent,
+ attach_dotdot_to(sdp, di->treewalk_parent,
di->dotdot_parent, di->dinode);
di->dotdot_parent = di->treewalk_parent;
}
@@ -134,7 +134,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
(unsigned long long)di->dinode,
(unsigned long long)di->treewalk_parent,
(unsigned long long)di->treewalk_parent)) {
- error = remove_dentry_from_dir(sbp, di->treewalk_parent,
+ error = remove_dentry_from_dir(sdp, di->treewalk_parent,
di->dinode);
if(error < 0) {
stack;
@@ -160,7 +160,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
log_err( _("Both .. and treewalk parents are "
"directories, going with treewalk "
"for now...\n"));
- attach_dotdot_to(sbp, di->treewalk_parent,
+ attach_dotdot_to(sdp, di->treewalk_parent,
di->dotdot_parent,
di->dinode);
di->dotdot_parent = di->treewalk_parent;
@@ -187,19 +187,19 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
* handle disconnected directories
* handle lost+found directory errors (missing, not a directory, no space)
*/
-int pass3(struct gfs2_sbd *sbp)
+int pass3(struct gfs2_sbd *sdp)
{
struct osi_node *tmp, *next = NULL;
struct dir_info *di, *tdi;
struct gfs2_inode *ip;
uint8_t q;
- di = dirtree_find(sbp->md.rooti->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->md.rooti->i_di.di_num.no_addr);
if (di) {
log_info( _("Marking root inode connected\n"));
di->checked = 1;
}
- di = dirtree_find(sbp->master_dir->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->master_dir->i_di.di_num.no_addr);
if (di) {
log_info( _("Marking master directory inode connected\n"));
di->checked = 1;
@@ -219,7 +219,7 @@ int pass3(struct gfs2_sbd *sbp)
* param */
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
- tdi = mark_and_return_parent(sbp, di);
+ tdi = mark_and_return_parent(sdp, di);
if (tdi) {
log_debug( _("Directory at block %llu (0x%llx) connected\n"),
@@ -244,7 +244,7 @@ int pass3(struct gfs2_sbd *sbp)
because we don't have ip */
gfs2_blockmap_set(bl, di->dinode,
gfs2_block_free);
- check_n_fix_bitmap(sbp, di->dinode,
+ check_n_fix_bitmap(sdp, di->dinode,
gfs2_block_free);
break;
} else
@@ -270,7 +270,7 @@ int pass3(struct gfs2_sbd *sbp)
because we don't have ip */
gfs2_blockmap_set(bl, di->dinode,
gfs2_block_free);
- check_n_fix_bitmap(sbp, di->dinode,
+ check_n_fix_bitmap(sdp, di->dinode,
gfs2_block_free);
log_err( _("The block was cleared\n"));
break;
@@ -279,7 +279,7 @@ int pass3(struct gfs2_sbd *sbp)
log_err( _("Found unlinked directory at block %llu"
" (0x%llx)\n"), (unsigned long long)di->dinode,
(unsigned long long)di->dinode);
- ip = fsck_load_inode(sbp, di->dinode);
+ ip = fsck_load_inode(sdp, di->dinode);
/* Don't skip zero size directories with eattrs */
if(!ip->i_di.di_size && !ip->i_di.di_eattr){
log_err( _("Unlinked directory has zero "
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 3305fb3..82144f9 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -41,7 +41,7 @@ static int fix_link_count(struct inode_info *ii, struct gfs2_inode *ip)
return 0;
}
-static int scan_inode_list(struct gfs2_sbd *sbp) {
+static int scan_inode_list(struct gfs2_sbd *sdp) {
struct osi_node *tmp, *next = NULL;
struct inode_info *ii;
struct gfs2_inode *ip;
@@ -70,7 +70,7 @@ static int scan_inode_list(struct gfs2_sbd *sbp) {
(unsigned long long)ii->inode);
if(query( _("Delete unlinked inode with bad "
"blocks? (y/n) "))) {
- ip = fsck_load_inode(sbp, ii->inode);
+ ip = fsck_load_inode(sdp, ii->inode);
check_inode_eattr(ip,
&pass4_fxns_delete);
check_metatree(ip, &pass4_fxns_delete);
@@ -94,7 +94,7 @@ static int scan_inode_list(struct gfs2_sbd *sbp) {
"not an inode (%d)\n"),
(unsigned long long)ii->inode,
(unsigned long long)ii->inode, q);
- ip = fsck_load_inode(sbp, ii->inode);
+ ip = fsck_load_inode(sdp, ii->inode);
if(query(_("Delete unlinked inode? (y/n) "))) {
check_inode_eattr(ip,
&pass4_fxns_delete);
@@ -111,7 +111,7 @@ static int scan_inode_list(struct gfs2_sbd *sbp) {
}
continue;
}
- ip = fsck_load_inode(sbp, ii->inode);
+ ip = fsck_load_inode(sdp, ii->inode);
/* We don't want to clear zero-size files with
* eattrs - there might be relevent info in
@@ -154,7 +154,7 @@ static int scan_inode_list(struct gfs2_sbd *sbp) {
" (0x%llx) ? (y/n) "),
(unsigned long long)ii->inode,
(unsigned long long)ii->inode)) {
- ip = fsck_load_inode(sbp, ii->inode); /* bread, inode_get */
+ ip = fsck_load_inode(sdp, ii->inode); /* bread, inode_get */
fix_link_count(ii, ip);
ii->link_count = ii->counted_links;
fsck_inode_put(&ip); /* out, brelse, free */
@@ -195,13 +195,13 @@ static int scan_inode_list(struct gfs2_sbd *sbp) {
* handle unreferenced inodes of other types
* handle bad blocks
*/
-int pass4(struct gfs2_sbd *sbp)
+int pass4(struct gfs2_sbd *sdp)
{
if(lf_dip)
log_debug( _("At beginning of pass4, lost+found entries is %u\n"),
lf_dip->i_di.di_entries);
log_info( _("Checking inode reference counts.\n"));
- if(scan_inode_list(sbp)) {
+ if(scan_inode_list(sdp)) {
stack;
return FSCK_ERROR;
}
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index 685aa77..b2c9438 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -50,7 +50,7 @@ static int convert_mark(uint8_t q, uint32_t *count)
return -1;
}
-static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int buflen,
+static int check_block_status(struct gfs2_sbd *sdp, char *buffer, unsigned int buflen,
uint64_t *rg_block, uint64_t rg_data, uint32_t *count)
{
unsigned char *byte, *end;
@@ -86,7 +86,7 @@ static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int b
(unsigned long long)block,
(unsigned long long)block);
if(query(_("Do you want to fix the bitmap? (y/n) "))) {
- if(gfs2_set_bitmap(sbp, block, block_status))
+ if(gfs2_set_bitmap(sdp, block, block_status))
log_err(_("Unlinked block %llu "
"(0x%llx) bitmap not fixed."
"\n"),
@@ -120,7 +120,7 @@ static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int b
if(query(_("Fix bitmap for block %llu (0x%llx) ? (y/n) "),
(unsigned long long)block,
(unsigned long long)block)) {
- if(gfs2_set_bitmap(sbp, block, block_status))
+ if(gfs2_set_bitmap(sdp, block, block_status))
log_err( _("Failed.\n"));
else
log_err( _("Succeeded.\n"));
@@ -140,7 +140,7 @@ static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int b
return 0;
}
-static void update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp,
+static void update_rgrp(struct gfs2_sbd *sdp, struct rgrp_list *rgp,
uint32_t *count)
{
uint32_t i;
@@ -152,7 +152,7 @@ static void update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp,
bits = &rgp->bits[i];
/* update the bitmaps */
- check_block_status(sbp, rgp->bh[i]->b_data + bits->bi_offset,
+ check_block_status(sdp, rgp->bh[i]->b_data + bits->bi_offset,
bits->bi_len, &rg_block, rgp->ri.ri_data0, count);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return;
@@ -197,7 +197,7 @@ static void update_rgrp(struct gfs2_sbd *sbp, struct rgrp_list *rgp,
* fix free block maps
* fix used inode maps
*/
-int pass5(struct gfs2_sbd *sbp)
+int pass5(struct gfs2_sbd *sdp)
{
osi_list_t *tmp;
struct rgrp_list *rgp = NULL;
@@ -205,7 +205,7 @@ int pass5(struct gfs2_sbd *sbp)
uint64_t rg_count = 0;
/* Reconcile RG bitmaps with fsck bitmap */
- for(tmp = sbp->rglist.next; tmp != &sbp->rglist; tmp = tmp->next){
+ for(tmp = sdp->rglist.next; tmp != &sdp->rglist; tmp = tmp->next){
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
log_info( _("Verifying Resource Group #%llu\n"), (unsigned long long)rg_count);
@@ -214,7 +214,7 @@ int pass5(struct gfs2_sbd *sbp)
rg_count++;
/* Compare the bitmaps and report the differences */
- update_rgrp(sbp, rgp, count);
+ update_rgrp(sdp, rgp, count);
}
/* Fix up superblock info based on this - don't think there's
* anything to do here... */
12 years, 8 months