Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff... Commit: 75bc339ca91b5114303ea95e4353a872b0d349dd Parent: 164a681c8bff1be33f7524b394e6211477db8f85 Author: Bob Peterson rpeterso@redhat.com AuthorDate: Wed Aug 10 14:07:45 2011 -0500 Committer: Bob Peterson rpeterso@redhat.com CommitterDate: Mon Aug 29 12:54:42 2011 -0500
libgfs2: eliminate gfs1_rindex_read
Now that function rindex_read is able to handle gfs1 file reading, this patch eliminates the gfs1-specific function gfs1_rindex_read.
rhbz#675723 --- gfs2/edit/hexedit.c | 13 +++------- gfs2/libgfs2/gfs1.c | 62 +------------------------------------------------- 2 files changed, 6 insertions(+), 69 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 49971ef..6f4c614 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -1758,7 +1758,7 @@ static int block_has_extended_info(void) /* ------------------------------------------------------------------------ */ static void read_superblock(int fd) { - int count; + int count, sane;
sbd1 = (struct gfs_sb *)&sbd.sd_sb; ioctl(fd, BLKFLSBUF, 0); @@ -1810,11 +1810,7 @@ static void read_superblock(int fd) 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.fssize = sbd.device.length; - gfs1_rindex_read(&sbd, 0, &count); } else { - int sane; - sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs2_meta_header)) / sizeof(uint64_t); sbd.sd_diptrs = (sbd.bsize - sizeof(struct gfs2_dinode)) / @@ -1822,11 +1818,10 @@ static void read_superblock(int fd) sbd.master_dir = inode_read(&sbd, sbd.sd_sb.sb_master_dir.no_addr); gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode); - sbd.fssize = sbd.device.length; - if (sbd.md.riinode) /* If we found the rindex */ - rindex_read(&sbd, 0, &count, &sane); } - + sbd.fssize = sbd.device.length; + if (sbd.md.riinode) /* If we found the rindex */ + rindex_read(&sbd, 0, &count, &sane); }
/* ------------------------------------------------------------------------ */ diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c index 5304b56..a0a6c6c 100644 --- a/gfs2/libgfs2/gfs1.c +++ b/gfs2/libgfs2/gfs1.c @@ -162,65 +162,6 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, }
/** - * gfs1_rindex_read - read in the rg index file - * Stolen from libgfs2/super.c, but modified to handle gfs1. - * @sdp: the incore superblock pointer - * fd: optional file handle for rindex file (if meta_fs file system is mounted) - * (if fd is <= zero, it will read from raw device) - * @count1: return count of the rgs. - * - * Returns: 0 on success, -1 on failure - */ -int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1) -{ - unsigned int rg; - int error; - struct gfs2_rindex buf; - struct rgrp_list *rgd, *prev_rgd; - uint64_t prev_length = 0; - - *count1 = 0; - prev_rgd = NULL; - for (rg = 0; ; rg++) { - if (fd > 0) - error = read(fd, &buf, sizeof(struct gfs2_rindex)); - else - error = gfs2_readi(sdp->md.riinode, (char *)&buf, - (rg * sizeof(struct gfs2_rindex)), - sizeof(struct gfs2_rindex)); - if (!error) - break; - if (error != sizeof(struct gfs2_rindex)) - return -1; - - rgd = (struct rgrp_list *)malloc(sizeof(struct rgrp_list)); - if (!rgd) { - log_crit("Cannot allocate memory for rindex.\n"); - exit(-1); - } - memset(rgd, 0, sizeof(struct rgrp_list)); - osi_list_add_prev(&rgd->list, &sdp->rglist); - - gfs2_rindex_in(&rgd->ri, (char *)&buf); - - rgd->start = rgd->ri.ri_addr; - if (prev_rgd) { - prev_length = rgd->start - prev_rgd->start; - prev_rgd->length = prev_length; - } - - if(gfs2_compute_bitstructs(sdp, rgd)) - return -1; - - (*count1)++; - prev_rgd = rgd; - } - if (prev_rgd) - prev_rgd->length = prev_length; - return 0; -} - -/** * gfs1_ri_update - attach rgrps to the super block * Stolen from libgfs2/super.c, but modified to handle gfs1. * @sdp: @@ -238,8 +179,9 @@ int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet) int count1 = 0, count2 = 0; uint64_t errblock = 0; uint64_t rmax = 0; + int sane;
- if (gfs1_rindex_read(sdp, fd, &count1)) + if (rindex_read(sdp, fd, &count1, &sane)) goto fail; for (tmp = sdp->rglist.next; tmp != &sdp->rglist; tmp = tmp->next) { rgd = osi_list_entry(tmp, struct rgrp_list, list);