* [Cluster-devel] [PATCH 1/3] libgfs2: Remove exit calls from inode_read and inode_get
@ 2012-08-28 15:36 Andrew Price
2012-08-28 15:36 ` [Cluster-devel] [PATCH 2/3] libgfs2: Remove exit call from __gfs_inode_get Andrew Price
2012-08-28 15:36 ` [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups Andrew Price
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Price @ 2012-08-28 15:36 UTC (permalink / raw)
To: cluster-devel.redhat.com
- Remove exit calls from inode_read and inode_get
- Fix error handling for the functions up the call tree
- The two functions are almost identical so define inode_read using
inode_get
- Update their names with an lgfs2_ prefix
- Move block_is_in_per_node into savemeta.c and make it static
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/convert/gfs2_convert.c | 24 ++++++++++++----
gfs2/edit/extended.c | 24 ++++++++++++----
gfs2/edit/hexedit.c | 47 ++++++++++++-------------------
gfs2/edit/hexedit.h | 1 -
gfs2/edit/savemeta.c | 56 ++++++++++++++++++++++++++++++++-----
gfs2/fsck/fs_recovery.c | 4 ++-
gfs2/fsck/initialize.c | 68 +++++++++++++++++++++++++++++++++------------
gfs2/fsck/metawalk.c | 4 +--
gfs2/libgfs2/fs_ops.c | 34 +++++++++++++----------
gfs2/libgfs2/libgfs2.h | 4 +--
gfs2/libgfs2/structures.c | 8 ++++--
gfs2/mkfs/main_grow.c | 7 +++--
12 files changed, 192 insertions(+), 89 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9944d23..51ec256 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1092,7 +1092,9 @@ static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
{
struct gfs2_inode *fix_inode;
- fix_inode = inode_read(sbp, iblock);
+ fix_inode = lgfs2_inode_read(sbp, iblock);
+ if (fix_inode == NULL)
+ return 1;
inum->no_formal_ino = fix_inode->i_di.di_num.no_formal_ino;
inum->no_addr = fix_inode->i_di.di_num.no_addr;
if (eablk)
@@ -1289,7 +1291,9 @@ static int process_directory(struct gfs2_sbd *sbp, uint64_t dirblock, uint64_t d
struct gfs2_inode *dip;
int error = 0;
/* read in the directory inode */
- dip = inode_read(sbp, dirblock);
+ dip = lgfs2_inode_read(sbp, dirblock);
+ if (dip == NULL)
+ return -1;
/* fix the directory: either exhash (leaves) or linear (stuffed) */
if (dip->i_di.di_flags & GFS2_DIF_EXHASH) {
if (fix_one_directory_exhash(sbp, dip, dentmod)) {
@@ -1391,7 +1395,9 @@ static int fix_cdpn_symlinks(struct gfs2_sbd *sbp, osi_list_t *cdpn_to_fix)
/* initialize the symlink inode to be a directory */
bh = init_dinode(sbp, &fix, S_IFDIR | 0755, 0, &dir);
- fix_inode = inode_get(sbp, bh);
+ fix_inode = lgfs2_inode_get(sbp, bh);
+ if (fix_inode == NULL)
+ return -1;
fix_inode->i_di.di_eattr = eablk; /*fix extended attribute */
inode_put(&fix_inode);
bmodified(bh);
@@ -1588,7 +1594,11 @@ static int init(struct gfs2_sbd *sbp)
sbp->md.riinode = gfs_inode_read(sbp, inum.no_addr);
/* get gfs1 jindex inode - gfs1's journal index inode ptr became master */
gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_jindex_di);
- sbp->md.jiinode = inode_read(sbp, inum.no_addr);
+ sbp->md.jiinode = lgfs2_inode_read(sbp, inum.no_addr);
+ if (sbp->md.jiinode == NULL) {
+ log_crit(_("Could not read journal index: %s\n"), strerror(errno));
+ exit(-1);
+ }
/* read in the journal index data */
read_gfs1_jiindex(sbp);
/* read in the resource group index data: */
@@ -2056,7 +2066,11 @@ static void copy_quotas(struct gfs2_sbd *sdp)
}
gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_quota_di);
- oq_ip = inode_read(sdp, inum.no_addr);
+ oq_ip = lgfs2_inode_read(sdp, inum.no_addr);
+ if (oq_ip == NULL) {
+ fprintf(stderr, _("Couldn't lookup old quota file: %s\n"), strerror(errno));
+ exit(1);
+ }
nq_ip->i_di.di_height = oq_ip->i_di.di_height;
nq_ip->i_di.di_size = oq_ip->i_di.di_size;
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 566fb5b..e2567a5 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -654,7 +654,9 @@ int display_extended(void)
/* Display any indirect pointers that we have. */
if (block_is_rindex()) {
tmp_bh = bread(&sbd, block);
- tmp_inode = inode_get(&sbd, tmp_bh);
+ tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
+ if (tmp_inode == NULL)
+ return -1;
parse_rindex(tmp_inode, TRUE);
inode_put(&tmp_inode);
brelse(tmp_bh);
@@ -669,35 +671,45 @@ int display_extended(void)
tmp_bh = bread(&sbd, sbd1->sb_rindex_di.no_addr);
else
tmp_bh = bread(&sbd, masterblock("rindex"));
- tmp_inode = inode_get(&sbd, tmp_bh);
+ tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
+ if (tmp_inode == NULL)
+ return -1;
parse_rindex(tmp_inode, FALSE);
inode_put(&tmp_inode);
brelse(tmp_bh);
}
else if (block_is_jindex()) {
tmp_bh = bread(&sbd, block);
- tmp_inode = inode_get(&sbd, tmp_bh);
+ tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
+ if (tmp_inode == NULL)
+ return -1;
print_jindex(tmp_inode);
inode_put(&tmp_inode);
brelse(tmp_bh);
}
else if (block_is_inum_file()) {
tmp_bh = bread(&sbd, block);
- tmp_inode = inode_get(&sbd, tmp_bh);
+ tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
+ if (tmp_inode == NULL)
+ return -1;
print_inum(tmp_inode);
inode_put(&tmp_inode);
brelse(tmp_bh);
}
else if (block_is_statfs_file()) {
tmp_bh = bread(&sbd, block);
- tmp_inode = inode_get(&sbd, tmp_bh);
+ tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
+ if (tmp_inode == NULL)
+ return -1;
print_statfs(tmp_inode);
inode_put(&tmp_inode);
brelse(tmp_bh);
}
else if (block_is_quota_file()) {
tmp_bh = bread(&sbd, block);
- tmp_inode = inode_get(&sbd, tmp_bh);
+ tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
+ if (tmp_inode == NULL)
+ return -1;
print_quota(tmp_inode);
inode_put(&tmp_inode);
brelse(tmp_bh);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 2ff1125..79082b8 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1063,7 +1063,9 @@ static uint64_t get_rg_addr(int rgnum)
gblock = sbd1->sb_rindex_di.no_addr;
else
gblock = masterblock("rindex");
- riinode = inode_read(&sbd, gblock);
+ riinode = lgfs2_inode_read(&sbd, gblock);
+ if (riinode == NULL)
+ return 0;
if (rgnum < riinode->i_di.di_size / sizeof(struct gfs2_rindex))
rgblk = find_rgrp_block(riinode, rgnum);
else
@@ -1205,29 +1207,6 @@ int block_is_per_node(void)
}
/* ------------------------------------------------------------------------ */
-/* block_is_in_per_node */
-/* ------------------------------------------------------------------------ */
-int block_is_in_per_node(void)
-{
- int d;
- struct gfs2_inode *per_node_di;
-
- if (sbd.gfs1)
- return FALSE;
-
- per_node_di = inode_read(&sbd, masterblock("per_node"));
-
- do_dinode_extended(&per_node_di->i_di, per_node_di->i_bh);
- inode_put(&per_node_di);
-
- for (d = 0; d < indirect->ii[0].dirents; d++) {
- if (block == indirect->ii[0].dirent[d].block)
- return TRUE;
- }
- return FALSE;
-}
-
-/* ------------------------------------------------------------------------ */
/* block_has_extended_info */
/* ------------------------------------------------------------------------ */
static int block_has_extended_info(void)
@@ -1301,15 +1280,19 @@ static void read_superblock(int fd)
sizeof(uint64_t);
sbd.sd_diptrs = (sbd.bsize - sizeof(struct gfs_dinode)) /
sizeof(uint64_t);
- sbd.md.riinode = inode_read(&sbd, sbd1->sb_rindex_di.no_addr);
+ sbd.md.riinode = lgfs2_inode_read(&sbd, sbd1->sb_rindex_di.no_addr);
} 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);
- sbd.master_dir = inode_read(&sbd,
+ sbd.master_dir = lgfs2_inode_read(&sbd,
sbd.sd_sb.sb_master_dir.no_addr);
- gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
+ if (sbd.master_dir == NULL) {
+ sbd.md.riinode = NULL;
+ } else {
+ gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
+ }
}
sbd.fssize = sbd.device.length;
if (sbd.md.riinode) /* If we found the rindex */
@@ -1521,7 +1504,9 @@ static uint64_t find_journal_block(const char *journal, uint64_t *j_size)
struct gfs2_inode *jiinode;
struct gfs_jindex ji;
- jiinode = inode_get(&sbd, jindex_bh);
+ jiinode = lgfs2_inode_get(&sbd, jindex_bh);
+ if (jiinode == NULL)
+ return 0;
amtread = gfs2_readi(jiinode, (void *)&jbuf,
journal_num * sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
@@ -2682,7 +2667,11 @@ static void dump_journal(const char *journal)
return;
if (!sbd.gfs1) {
j_bh = bread(&sbd, jblock);
- j_inode = inode_get(&sbd, j_bh);
+ j_inode = lgfs2_inode_get(&sbd, j_bh);
+ if (j_inode == NULL) {
+ fprintf(stderr, "Out of memory\n");
+ exit(-1);
+ }
jbuf = malloc(sbd.bsize);
if (jbuf == NULL) {
fprintf(stderr, "Out of memory\n");
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index dd76810..706909c 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -217,7 +217,6 @@ extern int block_is_inum_file(void);
extern int block_is_statfs_file(void);
extern int block_is_quota_file(void);
extern int block_is_per_node(void);
-extern int block_is_in_per_node(void);
extern int display_block_type(int from_restore);
extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
extern void gfs_log_header_in(struct gfs_log_header *head,
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 77cd7fa..77165a7 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -60,6 +60,30 @@ static int block_is_a_journal(void)
return FALSE;
}
+static int block_is_in_per_node(void)
+{
+ int d;
+ struct gfs2_inode *per_node_di;
+
+ if (sbd.gfs1)
+ return FALSE;
+
+ per_node_di = lgfs2_inode_read(&sbd, masterblock("per_node"));
+ if (per_node_di == NULL) {
+ fprintf(stderr, "Failed to read per_node: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ do_dinode_extended(&per_node_di->i_di, per_node_di->i_bh);
+ inode_put(&per_node_di);
+
+ for (d = 0; d < indirect->ii[0].dirents; d++) {
+ if (block == indirect->ii[0].dirent[d].block)
+ return TRUE;
+ }
+ return FALSE;
+}
+
static int block_is_systemfile(void)
{
return block_is_jindex() || block_is_inum_file() ||
@@ -122,10 +146,15 @@ 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 (sbd.gfs1)
+ if (sbd.gfs1) {
inode = gfs_inode_get(&sbd, lbh);
- else
- inode = inode_get(&sbd, lbh);
+ } else {
+ inode = lgfs2_inode_get(&sbd, lbh);
+ if (inode == NULL) {
+ fprintf(stderr, "Out of memory\n");
+ exit(-1);
+ }
+ }
if (S_ISDIR(inode->i_di.di_mode) ||
(sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
*gstruct_len = sbd.bsize;
@@ -461,8 +490,13 @@ static void save_inode_data(struct metafd *mfd)
metabh = bread(&sbd, block);
if (sbd.gfs1)
inode = gfs_inode_get(&sbd, metabh);
- else
- inode = inode_get(&sbd, metabh);
+ else {
+ inode = lgfs2_inode_get(&sbd, metabh);
+ if (inode == NULL) {
+ fprintf(stderr, "Failed to read inode: %s\n", strerror(errno));
+ exit(-1);
+ }
+ }
height = inode->i_di.di_height;
/* If this is a user inode, we don't follow to the file height.
We stop one level less. That way we save off the indirect
@@ -678,11 +712,19 @@ 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)sbd.fssize, sbd.bsize);
if (sbd.gfs1) {
- sbd.md.riinode = inode_read(&sbd, sbd1->sb_rindex_di.no_addr);
+ sbd.md.riinode = lgfs2_inode_read(&sbd, sbd1->sb_rindex_di.no_addr);
+ if (sbd.md.riinode == NULL) {
+ fprintf(stderr, "Unable to read rindex: %s.\n", strerror(errno));
+ exit(-1);
+ }
jindex_block = sbd1->sb_jindex_di.no_addr;
} else {
- sbd.master_dir = inode_read(&sbd,
+ sbd.master_dir = lgfs2_inode_read(&sbd,
sbd.sd_sb.sb_master_dir.no_addr);
+ if (sbd.master_dir == NULL) {
+ fprintf(stderr, "Unable to read master: %s.\n", strerror(errno));
+ exit(-1);
+ }
gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
jindex_block = masterblock("jindex");
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 1d9f632..6c92d0e 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -667,7 +667,9 @@ int ji_update(struct gfs2_sbd *sdp)
return -1;
}
gfs_jindex_in(&ji, buf);
- sdp->md.journal[i] = inode_read(sdp, ji.ji_addr);
+ sdp->md.journal[i] = lgfs2_inode_read(sdp, ji.ji_addr);
+ if (sdp->md.journal[i] == NULL)
+ return -1;
} else {
/* FIXME check snprintf return code */
snprintf(journal_name, JOURNAL_NAME_SIZE,
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index e56161e..a1047f3 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -366,7 +366,11 @@ static int rebuild_master(struct gfs2_sbd *sdp)
inum.no_formal_ino = sdp->md.next_inum++;
inum.no_addr = sdp->sd_sb.sb_master_dir.no_addr;
bh = init_dinode(sdp, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
- sdp->master_dir = inode_get(sdp, bh);
+ sdp->master_dir = lgfs2_inode_get(sdp, bh);
+ if (sdp->master_dir == NULL) {
+ log_crit(_("Error reading master: %s\n"), strerror(errno));
+ return -1;
+ }
sdp->master_dir->bh_owned = 1;
if (fix_md.jiinode) {
@@ -610,7 +614,9 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
log_info( _("Initializing special inodes...\n"));
/* Get root dinode */
- sdp->md.rooti = inode_read(sdp, sdp->sd_sb.sb_root_dir.no_addr);
+ sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_sb.sb_root_dir.no_addr);
+ if (sdp->md.rooti == NULL)
+ return -1;
err = fetch_rgrps(sdp);
if (err)
@@ -655,9 +661,13 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
sdp->md.next_inum = be64_to_cpu(inumbuf);
}
- if (sdp->gfs1)
- sdp->md.statfs = inode_read(sdp, sbd1->sb_license_di.no_addr);
- else
+ if (sdp->gfs1) {
+ sdp->md.statfs = lgfs2_inode_read(sdp, sbd1->sb_license_di.no_addr);
+ if (sdp->md.statfs == NULL) {
+ log_crit(_("Error reading statfs inode: %s\n"), strerror(errno));
+ goto fail;
+ }
+ } else
gfs2_lookupi(sdp->master_dir, "statfs", 6, &sdp->md.statfs);
if (!sdp->gfs1 && !sdp->md.statfs) {
if (!query( _("The gfs2 system statfs inode is missing. "
@@ -697,9 +707,13 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
}
}
- if (sdp->gfs1)
- sdp->md.qinode = inode_read(sdp, sbd1->sb_quota_di.no_addr);
- else
+ if (sdp->gfs1) {
+ sdp->md.qinode = lgfs2_inode_read(sdp, sbd1->sb_quota_di.no_addr);
+ if (sdp->md.qinode == NULL) {
+ log_crit(_("Error reading quota inode: %s\n"), strerror(errno));
+ goto fail;
+ }
+ } else
gfs2_lookupi(sdp->master_dir, "quota", 5, &sdp->md.qinode);
if (!sdp->gfs1 && !sdp->md.qinode) {
if (!query( _("The gfs2 system quota inode is missing. "
@@ -839,7 +853,11 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
sdp->sd_sb.sb_master_dir.no_addr = di->di_num.no_addr;
return;
}
- ip = inode_read(sdp, di->di_num.no_addr);
+ ip = lgfs2_inode_read(sdp, di->di_num.no_addr);
+ if (ip == NULL) {
+ log_crit(_("Error reading inode: %s\n"), strerror(errno));
+ return;
+ }
if ((!sdp->gfs1 && di->di_num.no_formal_ino == 3) ||
(sdp->gfs1 && (di->di_flags & GFS2_DIF_JDATA) &&
(di->di_size % sizeof(struct gfs_jindex) == 0))) {
@@ -962,7 +980,11 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
log_warn(_("Root directory copied from the journal.\n"));
return;
}
- ip = inode_read(sdp, di->di_num.no_addr);
+ ip = lgfs2_inode_read(sdp, di->di_num.no_addr);
+ if (ip == NULL) {
+ log_crit(_("Error reading inode: %s\n"), strerror(errno));
+ return;
+ }
while (ip) {
gfs2_lookupi(ip, "..", 2, &parent_ip);
if (parent_ip && parent_ip->i_di.di_num.no_addr ==
@@ -1147,7 +1169,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
log_err(_("Found a possible root at: 0x%llx\n"),
(unsigned long long)possible_root);
sdp->sd_sb.sb_root_dir.no_addr = possible_root;
- sdp->md.rooti = inode_read(sdp, possible_root);
+ sdp->md.rooti = lgfs2_inode_read(sdp, possible_root);
if (!sdp->md.rooti ||
sdp->md.rooti->i_di.di_header.mh_magic != GFS2_MAGIC) {
struct gfs2_buffer_head *bh;
@@ -1174,14 +1196,22 @@ static int sb_repair(struct gfs2_sbd *sdp)
if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) {
log_info(_("Found system master directory at: 0x%llx\n"),
sdp->sd_sb.sb_master_dir.no_addr);
- sdp->master_dir = inode_read(sdp,
+ sdp->master_dir = lgfs2_inode_read(sdp,
sdp->sd_sb.sb_master_dir.no_addr);
+ if (sdp->master_dir == NULL) {
+ log_crit(_("Error reading master inode: %s\n"), strerror(errno));
+ return -1;
+ }
sdp->master_dir->i_di.di_num.no_addr =
sdp->sd_sb.sb_master_dir.no_addr;
log_info(_("Found the root directory at: 0x%llx\n"),
sdp->sd_sb.sb_root_dir.no_addr);
- sdp->md.rooti = inode_read(sdp,
+ sdp->md.rooti = lgfs2_inode_read(sdp,
sdp->sd_sb.sb_root_dir.no_addr);
+ if (sdp->md.rooti == NULL) {
+ log_crit(_("Error reading root inode: %s\n"), strerror(errno));
+ return -1;
+ }
get_random_bytes(uuid, sizeof(uuid));
build_sb(sdp, uuid);
inode_put(&sdp->md.rooti);
@@ -1345,7 +1375,7 @@ static int init_rindex(struct gfs2_sbd *sdp)
int err;
if (sdp->gfs1)
- sdp->md.riinode = inode_read(sdp, sbd1->sb_rindex_di.no_addr);
+ sdp->md.riinode = lgfs2_inode_read(sdp, sbd1->sb_rindex_di.no_addr);
else
gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode);
@@ -1376,7 +1406,7 @@ static int init_jindex(struct gfs2_sbd *sdp)
/* rgrepair requires the journals be read in in order to distinguish
"real" rgrps from rgrps that are just copies left in journals. */
if (sdp->gfs1)
- sdp->md.jiinode = inode_read(sdp, sbd1->sb_jindex_di.no_addr);
+ sdp->md.jiinode = lgfs2_inode_read(sdp, sbd1->sb_jindex_di.no_addr);
else
gfs2_lookupi(sdp->master_dir, "jindex", 6, &sdp->md.jiinode);
@@ -1488,7 +1518,7 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
if (sdp->gfs1)
sdp->master_dir = NULL;
else
- sdp->master_dir = inode_read(sdp,
+ sdp->master_dir = lgfs2_inode_read(sdp,
sdp->sd_sb.sb_master_dir.no_addr);
if (!sdp->gfs1 &&
(sdp->master_dir->i_di.di_header.mh_magic != GFS2_MAGIC ||
@@ -1496,8 +1526,12 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
!sdp->master_dir->i_di.di_size)) {
inode_put(&sdp->master_dir);
rebuild_master(sdp);
- sdp->master_dir = inode_read(sdp,
+ sdp->master_dir = lgfs2_inode_read(sdp,
sdp->sd_sb.sb_master_dir.no_addr);
+ if (sdp->master_dir == NULL) {
+ log_crit(_("Error reading master directory: %s\n"), strerror(errno));
+ return FSCK_ERROR;
+ }
}
/* Look up the "per_node" inode. If there are journals missing, we
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index acdd10f..aa4f0b5 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -227,7 +227,7 @@ struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block)
return ip;
if (sdp->gfs1)
return gfs_inode_read(sdp, block);
- return inode_read(sdp, block);
+ return lgfs2_inode_read(sdp, block);
}
/* fsck_inode_get - same as inode_get() in libgfs2 but system inodes
@@ -243,7 +243,7 @@ struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
if (sdp->gfs1)
return gfs_inode_get(sdp, bh);
- return inode_get(sdp, bh);
+ return lgfs2_inode_get(sdp, bh);
}
/* fsck_inode_put - same as inode_put() in libgfs2 but system inodes
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 9409332..ec150e8 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -34,34 +34,32 @@ static int inode_is_stuffed(struct gfs2_inode *ip)
return !ip->i_di.di_height;
}
-struct gfs2_inode *inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
+struct gfs2_inode *lgfs2_inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
{
struct gfs2_inode *ip;
ip = calloc(1, sizeof(struct gfs2_inode));
if (ip == NULL) {
- fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
- exit(-1);
+ return NULL;
}
gfs2_dinode_in(&ip->i_di, bh);
ip->i_bh = bh;
ip->i_sbd = sdp;
- ip->bh_owned = 0; /* caller did the bread so we don't own the bh */
return ip;
}
-struct gfs2_inode *inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
+struct gfs2_inode *lgfs2_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
{
struct gfs2_inode *ip;
-
- ip = calloc(1, sizeof(struct gfs2_inode));
+ struct gfs2_buffer_head *bh = bread(sdp, di_addr);
+ if (bh == NULL) {
+ return NULL;
+ }
+ ip = lgfs2_inode_get(sdp, bh);
if (ip == NULL) {
- fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
- exit(-1);
+ brelse(bh);
+ return NULL;
}
- ip->i_bh = bread(sdp, di_addr);
- gfs2_dinode_in(&ip->i_di, ip->i_bh);
- ip->i_sbd = sdp;
ip->bh_owned = 1; /* We did the bread so we own the bh */
return ip;
}
@@ -1405,7 +1403,9 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip,
bh = __init_dinode(sdp, &inum, mode, flags, &dip->i_di.di_num,
if_gfs1);
- ip = inode_get(sdp, bh);
+ ip = lgfs2_inode_get(sdp, bh);
+ if (ip == NULL)
+ return NULL;
bmodified(bh);
}
ip->bh_owned = 1;
@@ -1764,7 +1764,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
return 0;
}
else
- *ipp = inode_read(sdp, inum.no_addr);
+ *ipp = lgfs2_inode_read(sdp, inum.no_addr);
return error;
}
@@ -1808,7 +1808,11 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
osi_list_init(&metalist[h]);
bh = bread(sdp, diblock);
- ip = inode_get(sdp, bh);
+ if (bh == NULL)
+ return -1;
+ ip = lgfs2_inode_get(sdp, bh);
+ if (ip == NULL)
+ return -1;
height = ip->i_di.di_height;
osi_list_add(&bh->b_altlist, &metalist[0]);
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 09f0b1d..9b128ff 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -425,9 +425,9 @@ extern struct metapath *find_metapath(struct gfs2_inode *ip, uint64_t block);
extern void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
unsigned int height, struct metapath *mp,
int create, int *new, uint64_t *block);
-extern struct gfs2_inode *inode_get(struct gfs2_sbd *sdp,
+extern struct gfs2_inode *lgfs2_inode_get(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *bh);
-extern struct gfs2_inode *inode_read(struct gfs2_sbd *sdp, uint64_t di_addr);
+extern struct gfs2_inode *lgfs2_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr);
extern struct gfs2_inode *is_system_inode(struct gfs2_sbd *sdp,
uint64_t block);
extern void inode_put(struct gfs2_inode **ip);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 0c22b01..645c45a 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -26,7 +26,9 @@ int build_master(struct gfs2_sbd *sdp)
bh = init_dinode(sdp, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
- sdp->master_dir = inode_get(sdp, bh);
+ sdp->master_dir = lgfs2_inode_get(sdp, bh);
+ if (sdp->master_dir == NULL)
+ return -1;
if (sdp->debug) {
printf("\nMaster dir:\n");
@@ -429,7 +431,9 @@ int build_root(struct gfs2_sbd *sdp)
inum.no_addr = bn;
bh = init_dinode(sdp, &inum, S_IFDIR | 0755, 0, &inum);
- sdp->md.rooti = inode_get(sdp, bh);
+ sdp->md.rooti = lgfs2_inode_get(sdp, bh);
+ if (sdp->md.rooti == NULL)
+ return -1;
if (sdp->debug) {
printf("\nRoot directory:\n");
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 3fe08a1..7bcfce2 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -376,8 +376,11 @@ main_grow(int argc, char *argv[])
die( _("GFS2 rindex not found. Please run gfs2_fsck.\n"));
}
/* Get master dinode */
- sdp->master_dir =
- inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr);
+ if (sdp->master_dir == NULL) {
+ perror("Could not read master");
+ exit(EXIT_FAILURE);
+ }
gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode);
/* Fetch the rindex from disk. We aren't using gfs2 here, */
/* which means that the bitmaps will most likely be cached */
--
1.7.11.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 2/3] libgfs2: Remove exit call from __gfs_inode_get
2012-08-28 15:36 [Cluster-devel] [PATCH 1/3] libgfs2: Remove exit calls from inode_read and inode_get Andrew Price
@ 2012-08-28 15:36 ` Andrew Price
2012-08-28 15:36 ` [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups Andrew Price
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Price @ 2012-08-28 15:36 UTC (permalink / raw)
To: cluster-devel.redhat.com
Return NULL instead of exiting on a failed calloc() and handle the error
at all call points. Also update the names of gfs_inode_{get,read} with
the lgfs2_ prefix.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/convert/gfs2_convert.c | 12 ++++++++++--
gfs2/edit/savemeta.c | 30 +++++++++++++++++-------------
gfs2/fsck/metawalk.c | 4 ++--
gfs2/libgfs2/gfs1.c | 7 +++----
gfs2/libgfs2/libgfs2.h | 4 ++--
5 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 51ec256..b5d993d 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -895,7 +895,11 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
struct inode_block *fixdir;
int inode_was_gfs1;
- inode = gfs_inode_get(sbp, bh);
+ inode = lgfs2_gfs_inode_get(sbp, bh);
+ if (inode == NULL) {
+ log_crit(_("Error reading inode: %s\n"), strerror(errno));
+ return -1;
+ }
inode_was_gfs1 = (inode->i_di.di_num.no_formal_ino ==
inode->i_di.di_num.no_addr);
@@ -1591,7 +1595,11 @@ static int init(struct gfs2_sbd *sbp)
}
/* get gfs1 rindex inode - gfs1's rindex inode ptr became __pad2 */
gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_rindex_di);
- sbp->md.riinode = gfs_inode_read(sbp, inum.no_addr);
+ sbp->md.riinode = lgfs2_gfs_inode_read(sbp, inum.no_addr);
+ if (sbp->md.riinode == NULL) {
+ log_crit(_("Could not read resource group index: %s\n"), strerror(errno));
+ exit(-1);
+ }
/* get gfs1 jindex inode - gfs1's journal index inode ptr became master */
gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_jindex_di);
sbp->md.jiinode = lgfs2_inode_read(sbp, inum.no_addr);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 77165a7..f35c35d 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -147,13 +147,13 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
break;
case GFS2_METATYPE_DI: /* 4 (disk inode) */
if (sbd.gfs1) {
- inode = gfs_inode_get(&sbd, lbh);
+ inode = lgfs2_gfs_inode_get(&sbd, lbh);
} else {
inode = lgfs2_inode_get(&sbd, lbh);
- if (inode == NULL) {
- fprintf(stderr, "Out of memory\n");
- exit(-1);
- }
+ }
+ if (inode == NULL) {
+ perror("Error reading inode");
+ exit(-1);
}
if (S_ISDIR(inode->i_di.di_mode) ||
(sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
@@ -488,14 +488,14 @@ 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 (sbd.gfs1)
- inode = gfs_inode_get(&sbd, metabh);
- else {
+ if (sbd.gfs1) {
+ inode = lgfs2_gfs_inode_get(&sbd, metabh);
+ } else {
inode = lgfs2_inode_get(&sbd, metabh);
- if (inode == NULL) {
- fprintf(stderr, "Failed to read inode: %s\n", strerror(errno));
- exit(-1);
- }
+ }
+ if (inode == NULL) {
+ perror("Failed to read inode");
+ exit(-1);
}
height = inode->i_di.di_height;
/* If this is a user inode, we don't follow to the file height.
@@ -611,8 +611,12 @@ static void get_journal_inode_blocks(void)
struct gfs_jindex ji;
char jbuf[sizeof(struct gfs_jindex)];
- j_inode = gfs_inode_read(&sbd,
+ j_inode = lgfs2_gfs_inode_read(&sbd,
sbd1->sb_jindex_di.no_addr);
+ if (j_inode == NULL) {
+ fprintf(stderr, "Error reading journal inode: %s\n", strerror(errno));
+ return;
+ }
amt = gfs2_readi(j_inode, (void *)&jbuf,
journal * sizeof(struct gfs_jindex),
sizeof(struct gfs_jindex));
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index aa4f0b5..24de901 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -226,7 +226,7 @@ struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block)
if (ip)
return ip;
if (sdp->gfs1)
- return gfs_inode_read(sdp, block);
+ return lgfs2_gfs_inode_read(sdp, block);
return lgfs2_inode_read(sdp, block);
}
@@ -242,7 +242,7 @@ struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
return sysip;
if (sdp->gfs1)
- return gfs_inode_get(sdp, bh);
+ return lgfs2_gfs_inode_get(sdp, bh);
return lgfs2_inode_get(sdp, bh);
}
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index d6f8794..06fa98f 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -293,8 +293,7 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp,
ip = calloc(1, sizeof(struct gfs2_inode));
if (ip == NULL) {
- fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
- exit(-1);
+ return NULL;
}
ip->bh_owned = 0;
@@ -332,13 +331,13 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp,
return ip;
}
-struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
+struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *bh)
{
return __gfs_inode_get(sdp, bh, 0);
}
-struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
+struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
{
return __gfs_inode_get(sdp, NULL, di_addr);
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 9b128ff..74ee2d0 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -646,9 +646,9 @@ extern void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
extern int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
unsigned int size);
extern int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet);
-extern struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
+extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *bh);
-extern struct gfs2_inode *gfs_inode_read(struct gfs2_sbd *sdp,
+extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp,
uint64_t di_addr);
extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
extern void gfs_rgrp_in(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
--
1.7.11.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups
2012-08-28 15:36 [Cluster-devel] [PATCH 1/3] libgfs2: Remove exit calls from inode_read and inode_get Andrew Price
2012-08-28 15:36 ` [Cluster-devel] [PATCH 2/3] libgfs2: Remove exit call from __gfs_inode_get Andrew Price
@ 2012-08-28 15:36 ` Andrew Price
2012-08-28 17:35 ` Steven Whitehouse
2012-08-28 17:50 ` Bob Peterson
1 sibling, 2 replies; 5+ messages in thread
From: Andrew Price @ 2012-08-28 15:36 UTC (permalink / raw)
To: cluster-devel.redhat.com
Remove some empty function comments to make things a bit more readable.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/edit/extended.c | 45 ----------------------------------
gfs2/edit/gfs2hex.c | 68 +++-------------------------------------------------
gfs2/edit/hexedit.c | 10 --------
3 files changed, 3 insertions(+), 120 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index e2567a5..17372ae 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -30,9 +30,6 @@
static void print_block_details(struct iinfo *ind, int level, int cur_height,
int pndx, uint64_t file_offset);
-/* ------------------------------------------------------------------------ */
-/* get_height */
-/* ------------------------------------------------------------------------ */
static int get_height(void)
{
int cur_height = 0, i;
@@ -49,9 +46,6 @@ static int get_height(void)
return cur_height;
}
-/* ------------------------------------------------------------------------ */
-/* _do_indirect_extended */
-/* ------------------------------------------------------------------------ */
static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
{
unsigned int x, y;
@@ -81,9 +75,6 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
return i_blocks;
}
-/* ------------------------------------------------------------------------ */
-/* do_indirect_extended */
-/* ------------------------------------------------------------------------ */
int do_indirect_extended(char *diebuf, struct iinfo *iinf)
{
return _do_indirect_extended(diebuf, iinf, get_height());
@@ -107,9 +98,6 @@ static int dinode_valid(void)
return 0;
}
-/* ------------------------------------------------------------------------ */
-/* metapath_to_lblock - convert from metapath, height to logical block */
-/* ------------------------------------------------------------------------ */
static uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
{
int h;
@@ -128,9 +116,6 @@ static uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
return lblock;
}
-/* ------------------------------------------------------------------------ */
-/* display_indirect */
-/* ------------------------------------------------------------------------ */
static int display_indirect(struct iinfo *ind, int indblocks, int level,
uint64_t startoff)
{
@@ -246,9 +231,6 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
return 0;
}
-/* ------------------------------------------------------------------------ */
-/* print_inode_type */
-/* ------------------------------------------------------------------------ */
static void print_inode_type(__be16 de_type)
{
if (sbd.gfs1) {
@@ -314,9 +296,6 @@ static void print_inode_type(__be16 de_type)
}
}
-/* ------------------------------------------------------------------------ */
-/* display_leaf - display directory leaf */
-/* ------------------------------------------------------------------------ */
static int display_leaf(struct iinfo *ind)
{
int start_line, total_dirents = start_row[dmode];
@@ -374,9 +353,6 @@ static int display_leaf(struct iinfo *ind)
return 0;
}
-/* ------------------------------------------------------------------------ */
-/* print_block_details */
-/* ------------------------------------------------------------------------ */
static void print_block_details(struct iinfo *ind, int level, int cur_height,
int pndx, uint64_t file_offset)
{
@@ -441,9 +417,6 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,
free(more_indir);
}
-/* ------------------------------------------------------------------------ */
-/* gfs_jindex_print - print an jindex entry. */
-/* ------------------------------------------------------------------------ */
static void gfs_jindex_print(struct gfs_jindex *ji)
{
pv((unsigned long long)ji, ji_addr, "%llu", "0x%llx");
@@ -451,9 +424,6 @@ static void gfs_jindex_print(struct gfs_jindex *ji)
pv(ji, ji_pad, "%u", "0x%x");
}
-/* ------------------------------------------------------------------------ */
-/* print_jindex - print the jindex file. */
-/* ------------------------------------------------------------------------ */
static int print_jindex(struct gfs2_inode *dij)
{
int error, start_line;
@@ -494,9 +464,6 @@ static int print_jindex(struct gfs2_inode *dij)
return error;
}
-/* ------------------------------------------------------------------------ */
-/* parse_rindex - print the rgindex file. */
-/* ------------------------------------------------------------------------ */
static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
{
int error, start_line;
@@ -562,9 +529,6 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
return error;
}
-/* ------------------------------------------------------------------------ */
-/* print_inum - print the inum file. */
-/* ------------------------------------------------------------------------ */
static int print_inum(struct gfs2_inode *dii)
{
uint64_t inum, inodenum;
@@ -587,9 +551,6 @@ static int print_inum(struct gfs2_inode *dii)
return 0;
}
-/* ------------------------------------------------------------------------ */
-/* print_statfs - print the statfs file. */
-/* ------------------------------------------------------------------------ */
static int print_statfs(struct gfs2_inode *dis)
{
struct gfs2_statfs_change sfb, sfc;
@@ -613,9 +574,6 @@ static int print_statfs(struct gfs2_inode *dis)
return 0;
}
-/* ------------------------------------------------------------------------ */
-/* print_quota - print the quota file. */
-/* ------------------------------------------------------------------------ */
static int print_quota(struct gfs2_inode *diq)
{
struct gfs2_quota qbuf, q;
@@ -642,9 +600,6 @@ static int print_quota(struct gfs2_inode *diq)
return 0;
}
-/* ------------------------------------------------------------------------ */
-/* display_extended */
-/* ------------------------------------------------------------------------ */
int display_extended(void)
{
struct gfs2_inode *tmp_inode;
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 41630f9..6979cd9 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -19,7 +19,6 @@
#include "extended.h"
#include "gfs2hex.h"
-/* from libgfs2: */
#include "libgfs2.h"
#define pv(struct, member, fmt, fmt2) do { \
@@ -255,21 +254,6 @@ static int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
return de.de_rec_len;
}
-/******************************************************************************
-*******************************************************************************
-**
-** do_dinode_extended()
-**
-** Description:
-**
-** Input(s):
-**
-** Output(s):
-**
-** Returns:
-**
-*******************************************************************************
-******************************************************************************/
void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh)
{
unsigned int x, y, ptroff = 0;
@@ -350,21 +334,9 @@ void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh)
} /* if exhash */
}/* do_dinode_extended */
-/******************************************************************************
-*******************************************************************************
-**
-** do_leaf_extended()
-**
-** Description:
-**
-** Input(s):
-**
-** Output(s):
-**
-** Returns: next leaf block, if any, in a chain of leaf blocks
-**
-*******************************************************************************
-******************************************************************************/
+/**
+ * Returns: next leaf block, if any, in a chain of leaf blocks
+ */
uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
{
int x, i;
@@ -403,23 +375,6 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
return leaf.lf_next;
}
-
-/******************************************************************************
-*******************************************************************************
-**
-** do_eattr_extended()
-**
-** Description:
-**
-** Input(s):
-**
-** Output(s):
-**
-** Returns:
-**
-*******************************************************************************
-******************************************************************************/
-
static void do_eattr_extended(struct gfs2_buffer_head *ebh)
{
struct gfs2_ea_header ea;
@@ -524,23 +479,6 @@ static void gfs1_rgrp_print(struct gfs1_rgrp *rg)
pv(rg, rg_freemeta, "%u", "0x%x");
}
-/******************************************************************************
-*******************************************************************************
-**
-** int display_gfs2()
-**
-** Description:
-** This routine...
-**
-** Input(s):
-** *buffer -
-** extended -
-**
-** Returns:
-** 0 if OK, 1 on error.
-**
-*******************************************************************************
-******************************************************************************/
int display_gfs2(void)
{
struct gfs2_meta_header mh;
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 79082b8..ff0dca9 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -3101,16 +3101,6 @@ static void process_parameters(int argc, char *argv[], int pass)
} /* for */
}/* process_parameters */
-/******************************************************************************
-*******************************************************************************
-**
-** main()
-**
-** Description:
-** Do everything
-**
-*******************************************************************************
-******************************************************************************/
int main(int argc, char *argv[])
{
int i, j, fd;
--
1.7.11.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups
2012-08-28 15:36 ` [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups Andrew Price
@ 2012-08-28 17:35 ` Steven Whitehouse
2012-08-28 17:50 ` Bob Peterson
1 sibling, 0 replies; 5+ messages in thread
From: Steven Whitehouse @ 2012-08-28 17:35 UTC (permalink / raw)
To: cluster-devel.redhat.com
Hi,
Those three all look ok to me,
Steve.
On Tue, 2012-08-28 at 16:36 +0100, Andrew Price wrote:
> Remove some empty function comments to make things a bit more readable.
>
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
> gfs2/edit/extended.c | 45 ----------------------------------
> gfs2/edit/gfs2hex.c | 68 +++-------------------------------------------------
> gfs2/edit/hexedit.c | 10 --------
> 3 files changed, 3 insertions(+), 120 deletions(-)
>
> diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
> index e2567a5..17372ae 100644
> --- a/gfs2/edit/extended.c
> +++ b/gfs2/edit/extended.c
> @@ -30,9 +30,6 @@
> static void print_block_details(struct iinfo *ind, int level, int cur_height,
> int pndx, uint64_t file_offset);
>
> -/* ------------------------------------------------------------------------ */
> -/* get_height */
> -/* ------------------------------------------------------------------------ */
> static int get_height(void)
> {
> int cur_height = 0, i;
> @@ -49,9 +46,6 @@ static int get_height(void)
> return cur_height;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* _do_indirect_extended */
> -/* ------------------------------------------------------------------------ */
> static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
> {
> unsigned int x, y;
> @@ -81,9 +75,6 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
> return i_blocks;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* do_indirect_extended */
> -/* ------------------------------------------------------------------------ */
> int do_indirect_extended(char *diebuf, struct iinfo *iinf)
> {
> return _do_indirect_extended(diebuf, iinf, get_height());
> @@ -107,9 +98,6 @@ static int dinode_valid(void)
> return 0;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* metapath_to_lblock - convert from metapath, height to logical block */
> -/* ------------------------------------------------------------------------ */
> static uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
> {
> int h;
> @@ -128,9 +116,6 @@ static uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
> return lblock;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* display_indirect */
> -/* ------------------------------------------------------------------------ */
> static int display_indirect(struct iinfo *ind, int indblocks, int level,
> uint64_t startoff)
> {
> @@ -246,9 +231,6 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
> return 0;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* print_inode_type */
> -/* ------------------------------------------------------------------------ */
> static void print_inode_type(__be16 de_type)
> {
> if (sbd.gfs1) {
> @@ -314,9 +296,6 @@ static void print_inode_type(__be16 de_type)
> }
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* display_leaf - display directory leaf */
> -/* ------------------------------------------------------------------------ */
> static int display_leaf(struct iinfo *ind)
> {
> int start_line, total_dirents = start_row[dmode];
> @@ -374,9 +353,6 @@ static int display_leaf(struct iinfo *ind)
> return 0;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* print_block_details */
> -/* ------------------------------------------------------------------------ */
> static void print_block_details(struct iinfo *ind, int level, int cur_height,
> int pndx, uint64_t file_offset)
> {
> @@ -441,9 +417,6 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,
> free(more_indir);
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* gfs_jindex_print - print an jindex entry. */
> -/* ------------------------------------------------------------------------ */
> static void gfs_jindex_print(struct gfs_jindex *ji)
> {
> pv((unsigned long long)ji, ji_addr, "%llu", "0x%llx");
> @@ -451,9 +424,6 @@ static void gfs_jindex_print(struct gfs_jindex *ji)
> pv(ji, ji_pad, "%u", "0x%x");
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* print_jindex - print the jindex file. */
> -/* ------------------------------------------------------------------------ */
> static int print_jindex(struct gfs2_inode *dij)
> {
> int error, start_line;
> @@ -494,9 +464,6 @@ static int print_jindex(struct gfs2_inode *dij)
> return error;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* parse_rindex - print the rgindex file. */
> -/* ------------------------------------------------------------------------ */
> static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
> {
> int error, start_line;
> @@ -562,9 +529,6 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
> return error;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* print_inum - print the inum file. */
> -/* ------------------------------------------------------------------------ */
> static int print_inum(struct gfs2_inode *dii)
> {
> uint64_t inum, inodenum;
> @@ -587,9 +551,6 @@ static int print_inum(struct gfs2_inode *dii)
> return 0;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* print_statfs - print the statfs file. */
> -/* ------------------------------------------------------------------------ */
> static int print_statfs(struct gfs2_inode *dis)
> {
> struct gfs2_statfs_change sfb, sfc;
> @@ -613,9 +574,6 @@ static int print_statfs(struct gfs2_inode *dis)
> return 0;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* print_quota - print the quota file. */
> -/* ------------------------------------------------------------------------ */
> static int print_quota(struct gfs2_inode *diq)
> {
> struct gfs2_quota qbuf, q;
> @@ -642,9 +600,6 @@ static int print_quota(struct gfs2_inode *diq)
> return 0;
> }
>
> -/* ------------------------------------------------------------------------ */
> -/* display_extended */
> -/* ------------------------------------------------------------------------ */
> int display_extended(void)
> {
> struct gfs2_inode *tmp_inode;
> diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
> index 41630f9..6979cd9 100644
> --- a/gfs2/edit/gfs2hex.c
> +++ b/gfs2/edit/gfs2hex.c
> @@ -19,7 +19,6 @@
>
> #include "extended.h"
> #include "gfs2hex.h"
> -/* from libgfs2: */
> #include "libgfs2.h"
>
> #define pv(struct, member, fmt, fmt2) do { \
> @@ -255,21 +254,6 @@ static int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
> return de.de_rec_len;
> }
>
> -/******************************************************************************
> -*******************************************************************************
> -**
> -** do_dinode_extended()
> -**
> -** Description:
> -**
> -** Input(s):
> -**
> -** Output(s):
> -**
> -** Returns:
> -**
> -*******************************************************************************
> -******************************************************************************/
> void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh)
> {
> unsigned int x, y, ptroff = 0;
> @@ -350,21 +334,9 @@ void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh)
> } /* if exhash */
> }/* do_dinode_extended */
>
> -/******************************************************************************
> -*******************************************************************************
> -**
> -** do_leaf_extended()
> -**
> -** Description:
> -**
> -** Input(s):
> -**
> -** Output(s):
> -**
> -** Returns: next leaf block, if any, in a chain of leaf blocks
> -**
> -*******************************************************************************
> -******************************************************************************/
> +/**
> + * Returns: next leaf block, if any, in a chain of leaf blocks
> + */
> uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
> {
> int x, i;
> @@ -403,23 +375,6 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
> return leaf.lf_next;
> }
>
> -
> -/******************************************************************************
> -*******************************************************************************
> -**
> -** do_eattr_extended()
> -**
> -** Description:
> -**
> -** Input(s):
> -**
> -** Output(s):
> -**
> -** Returns:
> -**
> -*******************************************************************************
> -******************************************************************************/
> -
> static void do_eattr_extended(struct gfs2_buffer_head *ebh)
> {
> struct gfs2_ea_header ea;
> @@ -524,23 +479,6 @@ static void gfs1_rgrp_print(struct gfs1_rgrp *rg)
> pv(rg, rg_freemeta, "%u", "0x%x");
> }
>
> -/******************************************************************************
> -*******************************************************************************
> -**
> -** int display_gfs2()
> -**
> -** Description:
> -** This routine...
> -**
> -** Input(s):
> -** *buffer -
> -** extended -
> -**
> -** Returns:
> -** 0 if OK, 1 on error.
> -**
> -*******************************************************************************
> -******************************************************************************/
> int display_gfs2(void)
> {
> struct gfs2_meta_header mh;
> diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
> index 79082b8..ff0dca9 100644
> --- a/gfs2/edit/hexedit.c
> +++ b/gfs2/edit/hexedit.c
> @@ -3101,16 +3101,6 @@ static void process_parameters(int argc, char *argv[], int pass)
> } /* for */
> }/* process_parameters */
>
> -/******************************************************************************
> -*******************************************************************************
> -**
> -** main()
> -**
> -** Description:
> -** Do everything
> -**
> -*******************************************************************************
> -******************************************************************************/
> int main(int argc, char *argv[])
> {
> int i, j, fd;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups
2012-08-28 15:36 ` [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups Andrew Price
2012-08-28 17:35 ` Steven Whitehouse
@ 2012-08-28 17:50 ` Bob Peterson
1 sibling, 0 replies; 5+ messages in thread
From: Bob Peterson @ 2012-08-28 17:50 UTC (permalink / raw)
To: cluster-devel.redhat.com
----- Original Message -----
| Remove some empty function comments to make things a bit more
| readable.
|
| Signed-off-by: Andrew Price <anprice@redhat.com>
| ---
Hi,
ACK to all three patches.
Regards,
Bob Peterson
Red Hat File Systems
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-28 17:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-28 15:36 [Cluster-devel] [PATCH 1/3] libgfs2: Remove exit calls from inode_read and inode_get Andrew Price
2012-08-28 15:36 ` [Cluster-devel] [PATCH 2/3] libgfs2: Remove exit call from __gfs_inode_get Andrew Price
2012-08-28 15:36 ` [Cluster-devel] [PATCH 3/3] gfs2_edit: Some comment cleanups Andrew Price
2012-08-28 17:35 ` Steven Whitehouse
2012-08-28 17:50 ` Bob Peterson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).