cluster: STABLE3 - gfs2_convert: gfs2_convert should fix statfs file
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: b55c086de3d0eba532f8ced97da92d1117718b22
Parent: 4c4127b776eec26d09b09322cea7240a707ce152
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Tue Feb 2 14:29:15 2010 -0600
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Tue Feb 2 14:29:15 2010 -0600
gfs2_convert: gfs2_convert should fix statfs file
This patch modifies the freedi() code path in libgfs2
to update the blks_alloced and dinodes_alloced counts
in the superblock struct. It also moves some code
around in gfs2_convert so that all the block changes
are correctly recorded into the statfs file.
rhbz#556961
---
gfs2/convert/gfs2_convert.c | 9 +++++----
gfs2/libgfs2/fs_ops.c | 5 +++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index a9e42cb..819399c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1351,10 +1351,10 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
rgd->ri.ri_data0 = jndx->ji_addr + rgd->ri.ri_length;
rgd->ri.ri_data = size - rgd->ri.ri_length;
- sdp->blks_total += rgd->ri.ri_data; /* For statfs file update */
/* Round down to nearest multiple of GFS2_NBBY */
while (rgd->ri.ri_data & 0x03)
rgd->ri.ri_data--;
+ sdp->blks_total += rgd->ri.ri_data; /* For statfs file update */
rgd->rg.rg_free = rgd->ri.ri_data;
rgd->ri.ri_bitbytes = rgd->ri.ri_data / GFS2_NBBY;
@@ -1415,7 +1415,7 @@ static void write_statfs_file(struct gfs2_sbd *sdp)
struct gfs2_statfs_change sc;
char buf[sizeof(struct gfs2_statfs_change)];
int count;
-
+
sc.sc_total = sdp->blks_total;
sc.sc_free = sdp->blks_total - sdp->blks_alloced;
sc.sc_dinodes = sdp->dinodes_alloced;
@@ -1586,6 +1586,9 @@ int main(int argc, char **argv)
build_quota(&sb2);
update_inode_file(&sb2);
+ /* Now delete the now-obsolete gfs1 files: */
+ remove_obsolete_gfs1(&sb2);
+
write_statfs_file(&sb2);
inode_put(&sb2.master_dir);
@@ -1594,8 +1597,6 @@ int main(int argc, char **argv)
fsync(sb2.device_fd); /* write the buffers to disk */
- /* Now delete the now-obsolete gfs1 files: */
- remove_obsolete_gfs1(&sb2);
/* Now free all the in memory */
gfs2_rgrp_free(&sb2.rglist);
log_notice("Committing changes to disk.\n");
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 8573dac..254c705 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1673,6 +1673,7 @@ void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block)
gfs2_set_bitmap(sdp, block, GFS2_BLKST_FREE);
rgd->rg.rg_free++; /* adjust the free count */
gfs2_rgrp_out(&rgd->rg, rgd->bh[0]); /* back to the buffer */
+ sdp->blks_alloced--;
}
}
@@ -1728,10 +1729,14 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
/* Set the bitmap type for inode to free space: */
gfs2_set_bitmap(sdp, ip->i_di.di_num.no_addr, GFS2_BLKST_FREE);
inode_put(&ip);
+ /* inode_put deallocated the extra block used by the dist inode, */
+ /* so adjust it in the superblock struct */
+ sdp->blks_alloced--;
/* Now we have to adjust the rg freespace count and inode count: */
rgd = gfs2_blk2rgrpd(sdp, diblock);
rgd->rg.rg_free++;
rgd->rg.rg_dinodes--; /* one less inode in use */
gfs2_rgrp_out(&rgd->rg, rgd->bh[0]);
+ sdp->dinodes_alloced--;
return 0;
}
14 years, 3 months
cluster: STABLE3 - gfs_jadd: Bug 555363 - gfs_jadd does not resolve symbolic links
by Abhijith Das
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 4c4127b776eec26d09b09322cea7240a707ce152
Parent: a1222d2f5923cefbb70990ae89e1cd63aed7d2ca
Author: Abhijith Das <adas(a)redhat.com>
AuthorDate: Mon Feb 1 19:33:37 2010 -0600
Committer: Abhijith Das <adas(a)redhat.com>
CommitterDate: Mon Feb 1 19:33:37 2010 -0600
gfs_jadd: Bug 555363 - gfs_jadd does not resolve symbolic links
This patch resolves symbolic links for the device name.
gfs_grow has this patch already, somehow gfs_jadd missed it.
All other gfs and gfs2 tools seem to be working ok with
symlinks to the devices.
rhbz#555363
---
gfs/gfs_jadd/main.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gfs/gfs_jadd/main.c b/gfs/gfs_jadd/main.c
index f295c86..5f0affd 100644
--- a/gfs/gfs_jadd/main.c
+++ b/gfs/gfs_jadd/main.c
@@ -713,33 +713,42 @@ update_fs(void)
*/
static int
-find_fs(char *name)
+find_fs(const char *name)
{
FILE *fp = fopen("/proc/mounts", "r");
char buffer[4096];
char fstype[80];
int fsdump, fspass;
+ char *realname;
+ realname = realpath(name, NULL);
+ if (!realname) {
+ perror(name);
+ return -1;
+ }
if (fp == NULL) {
perror("open: /proc/mounts");
exit(EXIT_FAILURE);
}
while ((fgets(buffer, 4095, fp)) != NULL) {
buffer[4095] = 0;
- if (strstr(buffer, name) == 0)
+ if (strstr(buffer, realname) == 0)
continue;
if (sscanf(buffer, "%s %s %s %s %d %d", device, fspath, fstype,
fsoptions, &fsdump, &fspass) != 6)
continue;
if (strcmp(fstype, "gfs") != 0)
continue;
- if ((strcmp(device, name) != 0) && (strcmp(fspath, name) != 0))
+ if ((strcmp(device, realname) != 0) &&
+ (strcmp(fspath, realname) != 0))
continue;
fclose(fp);
+ free(realname);
return 0;
}
fprintf(stderr, "GFS Filesystem %s not found\n", name);
fclose(fp);
+ free(realname);
return 1;
}
14 years, 3 months