Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 151803 Details for
Bug 234844
Need to add a "gfs2_grow" command
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
First go at a patch
234844.patch (text/plain), 38.52 KB, created by
Robert Peterson
on 2007-04-05 19:30:08 UTC
(
hide
)
Description:
First go at a patch
Filename:
MIME Type:
Creator:
Robert Peterson
Created:
2007-04-05 19:30:08 UTC
Size:
38.52 KB
patch
obsolete
>Index: libgfs2/device_geometry.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/device_geometry.c,v >retrieving revision 1.1 >diff -w -u -p -p -u -r1.1 device_geometry.c >--- libgfs2/device_geometry.c 27 Apr 2006 19:25:46 -0000 1.1 >+++ libgfs2/device_geometry.c 5 Apr 2007 19:23:39 -0000 >@@ -47,11 +47,8 @@ device_geometry(struct gfs2_sbd *sdp) > printf("\nPartition size = %"PRIu64"\n", > bytes >> GFS2_BASIC_BLOCK_SHIFT); > >- device->nsubdev = 1; >- zalloc(device->subdev, sizeof(struct subdevice)); >- >- device->subdev->start = 0; >- device->subdev->length = bytes >> GFS2_BASIC_BLOCK_SHIFT; >+ device->start = 0; >+ device->length = bytes >> GFS2_BASIC_BLOCK_SHIFT; > } > > /** >@@ -64,30 +61,24 @@ void > fix_device_geometry(struct gfs2_sbd *sdp) > { > struct device *device = &sdp->device; >- unsigned int x; > unsigned int bbsize = sdp->bsize >> GFS2_BASIC_BLOCK_SHIFT; > uint64_t start, length; > unsigned int remainder; > > if (sdp->debug) { > printf("\nDevice Geometry: (in basic blocks)\n"); >- for (x = 0; x < device->nsubdev; x++) >- printf(" SubDevice #%u: start = %"PRIu64", length = %"PRIu64", rgf_flags = 0x%.8X\n", >- x, >- device->subdev[x].start, >- device->subdev[x].length, >- device->subdev[x].rgf_flags); >+ printf(" start = %"PRIu64", length = %"PRIu64", rgf_flags = 0x%.8X\n", >+ device->start, >+ device->length, >+ device->rgf_flags); > } > >- /* Make sure all the subdevices are aligned */ >- >- for (x = 0; x < device->nsubdev; x++) { >- start = device->subdev[x].start; >- length = device->subdev[x].length; >+ start = device->start; >+ length = device->length; > > if (length < 1 << (20 - GFS2_BASIC_BLOCK_SHIFT)) >- die("subdevice %d is way too small (%"PRIu64" bytes)\n", >- x, length << GFS2_BASIC_BLOCK_SHIFT); >+ die("device is way too small (%"PRIu64" bytes)\n", >+ length << GFS2_BASIC_BLOCK_SHIFT); > > remainder = start % bbsize; > if (remainder) { >@@ -98,75 +89,17 @@ fix_device_geometry(struct gfs2_sbd *sdp > start /= bbsize; > length /= bbsize; > >- device->subdev[x].start = start; >- device->subdev[x].length = length; >+ device->start = start; >+ device->length = length; > sdp->device_size = start + length; >- } > > if (sdp->debug) { > printf("\nDevice Geometry: (in FS blocks)\n"); >- for (x = 0; x < device->nsubdev; x++) >- printf(" SubDevice #%u: start = %"PRIu64", length = %"PRIu64", rgf_flags = 0x%.8X\n", >- x, >- device->subdev[x].start, >- device->subdev[x].length, >- device->subdev[x].rgf_flags); >+ printf(" start = %"PRIu64", length = %"PRIu64", rgf_flags = 0x%.8X\n", >+ device->start, >+ device->length, >+ device->rgf_flags); > > printf("\nDevice Size: %"PRIu64"\n", sdp->device_size); > } > } >- >-void >-munge_device_geometry_for_grow(struct gfs2_sbd *sdp) >-{ >- struct device *device = &sdp->device; >- struct device new_dev; >- struct subdevice *new_sdev; >- uint64_t start, length; >- unsigned int x; >- >- memset(&new_dev, 0, sizeof(struct device)); >- >- for (x = 0; x < device->nsubdev; x++) { >- struct subdevice *sdev = device->subdev + x; >- >- if (sdev->start + sdev->length < sdp->orig_fssize) >- continue; >- else if (sdev->start < sdp->orig_fssize) { >- start = sdp->orig_fssize; >- length = sdev->start + sdev->length - sdp->orig_fssize; >- if (length < GFS2_MIN_GROW_SIZE << (20 - sdp->bsize_shift)) >- continue; >- } else { >- start = sdev->start; >- length = sdev->length; >- } >- >- new_dev.subdev = realloc(new_dev.subdev, (new_dev.nsubdev + 1) * sizeof(struct subdevice)); >- if (!new_dev.subdev) >- die("out of memory\n"); >- new_sdev = new_dev.subdev + new_dev.nsubdev; >- new_sdev->start = start; >- new_sdev->length = length; >- new_sdev->rgf_flags = sdev->rgf_flags; >- new_dev.nsubdev++; >- } >- >- free(device->subdev); >- *device = new_dev; >- >- if (!device->nsubdev) >- die("The device didn't grow enough to warrant growing the FS.\n"); >- >- if (sdp->debug) { >- printf("\nMunged Device Geometry: (in FS blocks)\n"); >- for (x = 0; x < device->nsubdev; x++) >- printf(" SubDevice #%u: start = %"PRIu64", length = %"PRIu64", rgf_flags = 0x%.8X\n", >- x, >- device->subdev[x].start, >- device->subdev[x].length, >- device->subdev[x].rgf_flags); >- } >-} >- >- >Index: libgfs2/fs_geometry.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/fs_geometry.c,v >retrieving revision 1.3 >diff -w -u -p -p -u -r1.3 fs_geometry.c >--- libgfs2/fs_geometry.c 30 Nov 2006 15:25:49 -0000 1.3 >+++ libgfs2/fs_geometry.c 5 Apr 2007 19:23:39 -0000 >@@ -28,19 +28,18 @@ > /** > * how_many_rgrps - figure out how many RG to put in a subdevice > * @w: the command line >- * @sdev: the subdevice >+ * @dev: the device > * > * Returns: the number of RGs > */ > >-static uint64_t >-how_many_rgrps(struct gfs2_sbd *sdp, struct subdevice *sdev, >- int rgsize_specified) >+uint64_t >+how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgsize_specified) > { > uint64_t nrgrp; > > while (TRUE) { >- nrgrp = DIV_RU(sdev->length, (sdp->rgsize << 20) / sdp->bsize); >+ nrgrp = DIV_RU(dev->length, (sdp->rgsize << 20) / sdp->bsize); > > if (rgsize_specified || /* If user specified an rg size or */ > nrgrp <= GFS2_EXCESSIVE_RGS || /* not an excessive # of rgs or */ >@@ -67,60 +66,76 @@ how_many_rgrps(struct gfs2_sbd *sdp, str > void > compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified) > { >- struct subdevice *sdev; >- struct rgrp_list *rl, *rlast = NULL; >+ struct device *dev; >+ struct rgrp_list *rl, *rlast = NULL, *rlast2 = NULL; > osi_list_t *tmp, *head = &sdp->rglist; >- uint64_t rgrp, nrgrp; >- unsigned int x; >- int new_fs; >+ uint64_t rgrp = 0, nrgrp; >+ uint64_t rglength; > >- new_fs = TRUE; >- for (x = 0; x < sdp->device.nsubdev; x++) { >- sdev = sdp->device.subdev + x; >- >- /* If this is the first subdevice reserve space for the superblock */ >- if (new_fs) { >- sdev->start += sdp->sb_addr + 1; >- sdev->length -= sdp->sb_addr + 1; >- new_fs = FALSE; >- } >+ sdp->new_rgrps = 0; >+ dev = &sdp->device; > >- if (sdp->debug) >- printf("\nData Subdevice %u\n", x); >+ /* Reserve space for the superblock */ >+ dev->start += sdp->sb_addr + 1; > >- nrgrp = how_many_rgrps(sdp, sdev, rgsize_specified); >+ /* If this is a new file system, compute the length and number */ >+ /* of rgs based on the size of the device. */ >+ /* If we have existing RGs (i.e. gfs2_grow) find the last one. */ >+ if (osi_list_empty(&sdp->rglist)) { >+ dev->length -= sdp->sb_addr + 1; >+ nrgrp = how_many_rgrps(sdp, dev, rgsize_specified); >+ rglength = dev->length / nrgrp; >+ sdp->new_rgrps = nrgrp; >+ } else { >+ uint64_t old_length, new_chunk; > >- for (rgrp = 0; rgrp < nrgrp; rgrp++) { >- zalloc(rl, sizeof(struct rgrp_list)); >+ log_info("Existing resource groups:\n"); >+ rgsize_specified = TRUE; /* consistently use existing size */ >+ for (rgrp = 0, tmp = head->next; tmp != head; >+ tmp = tmp->next, rgrp++) { >+ rl = osi_list_entry(tmp, struct rgrp_list, list); >+ log_info("%d: start: %"PRIu64", length = %"PRIu64"\n", >+ rgrp + 1, rl->start, rl->length); >+ rlast2 = rlast; >+ rlast = rl; >+ } >+ rlast->start = rlast->ri.ri_addr; >+ rglength = rlast->ri.ri_addr - rlast2->ri.ri_addr; >+ rlast->length = rglength; >+ old_length = rlast->ri.ri_addr + rglength; >+ new_chunk = dev->length - old_length; >+ sdp->new_rgrps = new_chunk / rglength; >+ nrgrp = rgrp + sdp->new_rgrps; >+ } > >- rl->subdevice = x; >+ log_info("\nNew resource groups:\n"); >+ for (; rgrp < nrgrp; rgrp++) { >+ zalloc(rl, sizeof(struct rgrp_list)); > > if (rgrp) { > rl->start = rlast->start + rlast->length; >- rl->length = sdev->length / nrgrp; >+ rl->length = rglength; > } else { >- rl->start = sdev->start; >- rl->length = sdev->length - >- (nrgrp - 1) * (sdev->length / nrgrp); >+ rl->start = dev->start; >+ rl->length = dev->length - >+ (nrgrp - 1) * (dev->length / nrgrp); > } >- rl->rgf_flags = sdev->rgf_flags; >+ rl->rgf_flags = dev->rgf_flags; > >+ log_info("%d: start: %"PRIu64", length = %"PRIu64"\n", >+ rgrp + 1, rl->start, rl->length); > osi_list_add_prev(&rl->list, head); >- > rlast = rl; > } > >- sdp->rgrps += nrgrp; >- sdp->new_rgrps += nrgrp; >- } >+ sdp->rgrps = nrgrp; > > if (sdp->debug) { >- printf("\n"); >+ log_info("\n"); > > for (tmp = head->next; tmp != head; tmp = tmp->next) { > rl = osi_list_entry(tmp, struct rgrp_list, list); >- printf("subdevice %u: rg_o = %"PRIu64", rg_l = %"PRIu64"\n", >- rl->subdevice, >+ log_info("rg_o = %"PRIu64", rg_l = %"PRIu64"\n", > rl->start, rl->length); > } > } >@@ -137,7 +152,7 @@ compute_rgrp_layout(struct gfs2_sbd *sdp > * > */ > >-static void >+void > rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks, uint32_t *bitblocks) > { > unsigned int bitbytes_provided, last = 0; >@@ -163,6 +178,11 @@ rgblocks2bitblocks(unsigned int bsize, u > *rgblocks = bitbytes_needed * GFS2_NBBY; > } > >+/** >+ * build_rgrps - write a bunch of resource groups to disk. >+ * If fd > 0, write the data to the given file handle. >+ * Otherwise, use gfs2 buffering in buf.c. >+ */ > void build_rgrps(struct gfs2_sbd *sdp) > { > osi_list_t *tmp, *head; >@@ -200,12 +220,11 @@ void build_rgrps(struct gfs2_sbd *sdp) > rg->rg_flags = rl->rgf_flags; > rg->rg_free = rgblocks; > >- if (!sdp->test) > for (x = 0; x < bitblocks; x++) { > bh = bget(sdp, rl->start + x); >- if (x) { >+ if (x) > gfs2_meta_header_out(&mh, bh->b_data); >- } else >+ else > gfs2_rgrp_out(rg, bh->b_data); > brelse(bh, updated); > } >@@ -219,5 +238,3 @@ void build_rgrps(struct gfs2_sbd *sdp) > sdp->fssize = ri->ri_data0 + ri->ri_data; > } > } >- >- >Index: libgfs2/libgfs2.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/libgfs2.h,v >retrieving revision 1.10 >diff -w -u -p -p -u -r1.10 libgfs2.h >--- libgfs2/libgfs2.h 12 Feb 2007 18:55:29 -0000 1.10 >+++ libgfs2/libgfs2.h 5 Apr 2007 19:23:39 -0000 >@@ -17,6 +17,7 @@ > #include <inttypes.h> > #include <sys/types.h> > #include <linux/types.h> >+#include <linux/limits.h> > > #include "linux_endian.h" > #include <linux/gfs2_ondisk.h> >@@ -63,17 +64,12 @@ static __inline__ uint64_t do_div_i(uint > #define RESRANDOM do { srandom(RANDOM(1000000000)); } while (0) > #define RANDOM(values) ((values) * (random() / (RAND_MAX + 1.0))) > >-struct subdevice { >+struct device { > uint64_t start; > uint64_t length; > uint32_t rgf_flags; > }; > >-struct device { >- unsigned int nsubdev; >- struct subdevice *subdev; >-}; >- > struct gfs2_bitmap > { > uint32_t bi_offset; /* The offset in the buffer of the first byte */ >@@ -84,9 +80,6 @@ typedef struct gfs2_bitmap gfs2_bitmap_t > > struct rgrp_list { > osi_list_t list; >- >- uint32_t subdevice; /* The subdevice who holds this resource group */ >- > uint64_t start; /* The offset of the beginning of this resource group */ > uint64_t length; /* The length of this resource group */ > uint32_t rgf_flags; >@@ -169,11 +162,10 @@ struct gfs2_sbd { > > int debug; > int quiet; >- int test; > int expert; > int override; > >- char *device_name; >+ char device_name[PATH_MAX]; > char *path_name; > > /* Constants */ >@@ -227,6 +219,9 @@ struct gfs2_sbd { > > unsigned int spills; > unsigned int writes; >+ int metafs_fd; >+ int metafs_mounted; /* If metafs was already mounted */ >+ char metafs_path[PATH_MAX]; /* where metafs is mounted */ > }; > > extern char *prog_name; >@@ -351,7 +346,6 @@ void write_buffer(struct gfs2_sbd *sdp, > /* device_geometry.c */ > void device_geometry(struct gfs2_sbd *sdp); > void fix_device_geometry(struct gfs2_sbd *sdp); >-void munge_device_geometry_for_grow(struct gfs2_sbd *sdp); > > /* fs_bits.c */ > #define BFITNOENT (0xFFFFFFFF) >@@ -374,6 +368,10 @@ int gfs2_get_bitmap(struct gfs2_sbd *sdp > int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state); > > /* fs_geometry.c */ >+void rgblocks2bitblocks(unsigned int bsize, uint32_t *rgblocks, >+ uint32_t *bitblocks); >+uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, >+ int rgsize_specified); > void compute_rgrp_layout(struct gfs2_sbd *sdp, int rgsize_specified); > void build_rgrps(struct gfs2_sbd *sdp); > >@@ -501,6 +499,12 @@ int query(struct gfs2_options *opts, con > > /* misc.c */ > void compute_constants(struct gfs2_sbd *sdp); >+int find_gfs2_meta(struct gfs2_sbd *sdp); >+int dir_exists(const char *dir); >+void check_for_gfs2(struct gfs2_sbd *sdp); >+void mount_gfs2_meta(struct gfs2_sbd *sdp); >+void lock_for_admin(struct gfs2_sbd *sdp); >+void cleanup_metafs(struct gfs2_sbd *sdp); > > /* rgrp.c */ > int gfs2_compute_bitstructs(struct gfs2_sbd *sdp, struct rgrp_list *rgd); >@@ -530,6 +534,7 @@ int gfs2_next_rg_metatype(struct gfs2_sb > /* super.c */ > int read_sb(struct gfs2_sbd *sdp); > int ji_update(struct gfs2_sbd *sdp); >+int rindex_read(struct gfs2_sbd *sdp, int *count1); > int ri_update(struct gfs2_sbd *sdp, int *rgcount); > int write_sb(struct gfs2_sbd *sdp); > >Index: libgfs2/misc.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/misc.c,v >retrieving revision 1.2 >diff -w -u -p -p -u -r1.2 misc.c >--- libgfs2/misc.c 6 Jun 2006 14:20:41 -0000 1.2 >+++ libgfs2/misc.c 5 Apr 2007 19:23:39 -0000 >@@ -22,8 +22,10 @@ > #include <unistd.h> > #include <time.h> > #include <errno.h> >- >+#include <sys/mount.h> > #include <linux/types.h> >+#include <sys/file.h> >+ > #include "libgfs2.h" > > void >@@ -102,3 +104,169 @@ compute_constants(struct gfs2_sbd *sdp) > die("bad constants (2)\n"); > } > >+int >+find_gfs2_meta(struct gfs2_sbd *sdp) >+{ >+ FILE *fp = fopen("/proc/mounts", "r"); >+ char name[] = "gfs2meta"; >+ char buffer[PATH_MAX]; >+ char fstype[80], mfsoptions[PATH_MAX]; >+ char meta_device[PATH_MAX]; >+ char meta_path[PATH_MAX]; >+ int fsdump, fspass; >+ >+ if (fp == NULL) { >+ perror("open: /proc/mounts"); >+ exit(EXIT_FAILURE); >+ } >+ sdp->metafs_mounted = FALSE; >+ memset(sdp->metafs_path, 0, sizeof(sdp->metafs_path)); >+ memset(meta_path, 0, sizeof(meta_path)); >+ while ((fgets(buffer, PATH_MAX - 1, fp)) != NULL) { >+ buffer[PATH_MAX - 1] = '\0'; >+ if (strstr(buffer, name) == 0) >+ continue; >+ >+ if (sscanf(buffer, "%s %s %s %s %d %d", meta_device, >+ meta_path, fstype,mfsoptions, &fsdump, >+ &fspass) != 6) >+ continue; >+ >+ if (strcmp(meta_device, sdp->device_name) == 0 || >+ strcmp(meta_device, sdp->path_name) == 0) { >+ fclose(fp); >+ sdp->metafs_mounted = FALSE; >+ strcpy(sdp->metafs_path, meta_path); >+ return TRUE; >+ } >+ } >+ fclose(fp); >+ return FALSE; >+} >+ >+int >+dir_exists(const char *dir) >+{ >+ int fd, ret; >+ struct stat statbuf; >+ fd = open(dir, O_RDONLY); >+ if (fd<0) { >+ if (errno == ENOENT) >+ return 0; >+ die("Couldn't open %s : %s\n", dir, strerror(errno)); >+ } >+ ret = fstat(fd, &statbuf); >+ if (ret) >+ die("stat failed on %s : %s\n", dir, strerror(errno)); >+ if (S_ISDIR(statbuf.st_mode)) { >+ close(fd); >+ return 1; >+ } >+ close(fd); >+ die("%s exists, but is not a directory. Cannot mount metafs here\n", dir); >+} >+ >+void >+check_for_gfs2(struct gfs2_sbd *sdp) >+{ >+ FILE *fp = fopen("/proc/mounts", "r"); >+ char *name = sdp->path_name; >+ char buffer[PATH_MAX]; >+ char fstype[80]; >+ int fsdump, fspass, ret; >+ char fspath[PATH_MAX]; >+ char fsoptions[PATH_MAX]; >+ >+ if (name[strlen(name) - 1] == '/') >+ name[strlen(name) - 1] = '\0'; >+ >+ if (fp == NULL) { >+ perror("open: /proc/mounts"); >+ exit(EXIT_FAILURE); >+ } >+ while ((fgets(buffer, PATH_MAX - 1, fp)) != NULL) { >+ buffer[PATH_MAX - 1] = 0; >+ >+ if (strstr(buffer, "0") == 0) >+ continue; >+ >+ if ((ret = sscanf(buffer, "%s %s %s %s %d %d", >+ sdp->device_name, fspath, >+ fstype, fsoptions, &fsdump, &fspass)) != 6) >+ continue; >+ >+ if (strcmp(fstype, "gfs2") != 0) >+ continue; >+ >+ /* Check if they specified the device instead of mnt point */ >+ if (strcmp(sdp->device_name, name) == 0) >+ strcpy(sdp->path_name, fspath); /* fix it */ >+ else if (strcmp(fspath, name) != 0) >+ continue; >+ >+ fclose(fp); >+ if (strncmp(sdp->device_name, "/dev/loop", 9) == 0) >+ die("Cannot perform this operation on a loopback GFS2 mount.\n"); >+ >+ return; >+ } >+ fclose(fp); >+ die("gfs2 Filesystem %s is not mounted.\n", name); >+} >+ >+void >+mount_gfs2_meta(struct gfs2_sbd *sdp) >+{ >+ int ret; >+ /* mount the meta fs */ >+ strcpy(sdp->metafs_path, "/tmp/.gfs2meta"); >+ if (!dir_exists(sdp->metafs_path)) { >+ ret = mkdir(sdp->metafs_path, 0700); >+ if (ret) >+ die("Couldn't create %s : %s\n", sdp->metafs_path, >+ strerror(errno)); >+ } >+ >+ ret = mount(sdp->device_name, sdp->metafs_path, "gfs2meta", 0, NULL); >+ if (ret) >+ die("Couldn't mount %s : %s\n", sdp->metafs_path, >+ strerror(errno)); >+} >+ >+void >+lock_for_admin(struct gfs2_sbd *sdp) >+{ >+ int error; >+ >+ if (sdp->debug) >+ printf("\nTrying to get admin lock...\n"); >+ >+ sdp->metafs_fd = open(sdp->metafs_path, O_RDONLY | O_NOFOLLOW); >+ if (sdp->metafs_fd < 0) >+ die("can't open %s: %s\n", >+ sdp->metafs_path, strerror(errno)); >+ >+ error = flock(sdp->metafs_fd, LOCK_EX); >+ if (error) >+ die("can't flock %s: %s\n", sdp->metafs_path, strerror(errno)); >+ if (sdp->debug) >+ printf("Got it.\n"); >+} >+ >+void >+cleanup_metafs(struct gfs2_sbd *sdp) >+{ >+ int ret; >+ >+ if (sdp->metafs_fd <= 0) >+ return; >+ >+ close(sdp->metafs_fd); >+ if (!sdp->metafs_mounted) { /* was mounted by us */ >+ ret = umount(sdp->metafs_path); >+ if (ret) >+ fprintf(stderr, "Couldn't unmount %s : %s\n", >+ sdp->metafs_path, strerror(errno)); >+ } >+} >+ >Index: libgfs2/super.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/super.c,v >retrieving revision 1.3 >diff -w -u -p -p -u -r1.3 super.c >--- libgfs2/super.c 19 Jun 2006 20:45:15 -0000 1.3 >+++ libgfs2/super.c 5 Apr 2007 19:23:39 -0000 >@@ -165,23 +165,19 @@ int ji_update(struct gfs2_sbd *sdp) > } > > /** >- * ri_update - attach rgrps to the super block >- * @sdp: >- * >- * Given the rgrp index inode, link in all rgrps into the super block >- * and be sure that they can be read. >+ * rindex_read - read in the rg index file >+ * sdp: the incore superblock pointer > * >- * Returns: 0 on success, -1 on failure. >+ * Returns: 0 on success, -1 on failure > */ >-int ri_update(struct gfs2_sbd *sdp, int *rgcount) >+int rindex_read(struct gfs2_sbd *sdp, int *count1) > { >- struct rgrp_list *rgd; >- osi_list_t *tmp; >- struct gfs2_rindex buf; > unsigned int rg; >- int error, count1 = 0, count2 = 0; >- uint64_t errblock = 0; >+ int error; >+ struct gfs2_rindex buf; >+ struct rgrp_list *rgd; > >+ *count1 = 0; > for (rg = 0; ; rg++) { > error = gfs2_readi(sdp->md.riinode, (char *)&buf, > rg * sizeof(struct gfs2_rindex), >@@ -189,7 +185,7 @@ int ri_update(struct gfs2_sbd *sdp, int > if (!error) > break; > if (error != sizeof(struct gfs2_rindex)) >- goto fail; >+ return -1; > > rgd = (struct rgrp_list *)malloc(sizeof(struct rgrp_list)); > memset(rgd, 0, sizeof(struct rgrp_list)); >@@ -198,32 +194,40 @@ int ri_update(struct gfs2_sbd *sdp, int > gfs2_rindex_in(&rgd->ri, (char *)&buf); > > if(gfs2_compute_bitstructs(sdp, rgd)) >- goto fail; >+ return -1; > >- count1++; >+ (*count1)++; >+ } >+ return 0; > } > >+/** >+ * ri_update - attach rgrps to the super block >+ * @sdp: >+ * >+ * Given the rgrp index inode, link in all rgrps into the super block >+ * and be sure that they can be read. >+ * >+ * Returns: 0 on success, -1 on failure. >+ */ >+int ri_update(struct gfs2_sbd *sdp, int *rgcount) >+{ >+ struct rgrp_list *rgd; >+ osi_list_t *tmp; >+ int count1 = 0, count2 = 0; >+ uint64_t errblock = 0; >+ >+ if (rindex_read(sdp, &count1)) >+ goto fail; > for (tmp = sdp->rglist.next; tmp != &sdp->rglist; tmp = tmp->next) { >- int i; >- uint64_t prev_err = 0; > enum update_flags f; > > f = not_updated; > rgd = osi_list_entry(tmp, struct rgrp_list, list); >- /* If we have errors, we may need to repair and continue. */ >- /* We have multiple bitmaps, and all of them might potentially need */ >- /* repair. So we have to try to read and repair as many times as */ >- /* there are bitmaps. */ >- for (i = 0; i < rgd->ri.ri_length; i++) { > errblock = gfs2_rgrp_read(sdp, rgd); >- if (errblock) { >- if (errblock == prev_err) /* if same block is still bad */ >- goto fail; >- prev_err = errblock; >- } >+ if (errblock) >+ return errblock; > else >- break; >- } /* for all bitmap structures */ > gfs2_rgrp_relse(rgd, f); > count2++; > } >Index: mkfs/Makefile >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/mkfs/Makefile,v >retrieving revision 1.13 >diff -w -u -p -p -u -r1.13 Makefile >--- mkfs/Makefile 26 Mar 2007 19:41:00 -0000 1.13 >+++ mkfs/Makefile 5 Apr 2007 19:23:39 -0000 >@@ -9,20 +9,21 @@ include ${top_srcdir}/make/defines.mk > > MKFS=mkfs.gfs2 > JADD=gfs2_jadd >+GROW=gfs2_grow > INCLUDEPATH=-I${KERNEL_SRC}/include/ -I${top_srcdir}/include/ -I${top_srcdir}/libgfs2/ -I${top_srcdir}/config/ > > INSTALL=install > CC=gcc -c > LD=gcc >-CFLAGS=-Wall -O2 -ggdb -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE \ >+CFLAGS=-Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE \ > -D_GNU_SOURCE -DGFS2_RELEASE_NAME=\"2\" ${INCLUDEPATH} > LDFLAGS=-L${top_srcdir}/libgfs2 -L${libdir} > > H=gfs2_disk_hash.h gfs2_mkfs.h linux_endian.h ondisk.h osi_list.h >-C=main.c main_mkfs.c main_jadd.c >+C=main.c main_mkfs.c main_jadd.c main_grow.c > O=$(subst .c,.o,${C}) > >-all: ${MKFS} ${JADD} >+all: ${MKFS} ${JADD} ${GROW} > > ${MKFS}: ${O} ${top_srcdir}/libgfs2/libgfs2.a > ${LD} ${LDFLAGS} ${O} -o ${@} -lgfs2 -lvolume_id >@@ -30,13 +31,16 @@ ${MKFS}: ${O} ${top_srcdir}/libgfs2/libg > ${JADD}: ${MKFS} > ln -s ${MKFS} ${JADD} > >+${GROW}: ${MKFS} >+ ln -s ${MKFS} ${GROW} >+ > .c.o: $< > ${CC} ${CFLAGS} -o $@ $^ > > install: all > ${INSTALL} -m 0755 ${MKFS} ${sbindir} > ln -f ${sbindir}/${MKFS} ${sbindir}/${JADD} >+ ln -f ${sbindir}/${MKFS} ${sbindir}/${GROW} > > clean: >- rm -f *.o ${MKFS} ${JADD} >- >+ rm -f *.o ${MKFS} ${JADD} ${GROW} >Index: mkfs/main.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/mkfs/main.c,v >retrieving revision 1.7 >diff -w -u -p -p -u -r1.7 main.c >--- mkfs/main.c 10 Jul 2006 22:51:10 -0000 1.7 >+++ mkfs/main.c 5 Apr 2007 19:23:39 -0000 >@@ -53,9 +53,9 @@ main(int argc, char *argv[]) > main_jadd(argc, argv); > else if (!strcmp(whoami, "gfs2_mkfs") || !strcmp(whoami, "mkfs.gfs2")) > main_mkfs(argc, argv); >-#if 0 >- if (!strcmp(whoami, "gfs2_grow")) >+ else if (!strcmp(whoami, "gfs2_grow")) > main_grow(argc, argv); >+#if 0 > else if (!strcmp(whoami, "gfs2_shrink")) > main_shrink(argc, argv); > else >Index: mkfs/main_grow.c >=================================================================== >RCS file: mkfs/main_grow.c >diff -N mkfs/main_grow.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ mkfs/main_grow.c 5 Apr 2007 19:23:39 -0000 >@@ -0,0 +1,301 @@ >+/****************************************************************************** >+******************************************************************************* >+** >+** Copyright (C) 2007 Red Hat, Inc. All rights reserved. >+** >+** This copyrighted material is made available to anyone wishing to use, >+** modify, copy, or redistribute it subject to the terms and conditions >+** of the GNU General Public License v.2. >+** >+******************************************************************************* >+******************************************************************************/ >+ >+#include <stdio.h> >+#include <stdlib.h> >+#include <string.h> >+#include <stdint.h> >+#include <inttypes.h> >+#include <sys/types.h> >+#include <dirent.h> >+#include <sys/stat.h> >+#include <sys/ioctl.h> >+#include <sys/file.h> >+#include <sys/vfs.h> >+#include <sys/mount.h> >+#include <fcntl.h> >+#include <unistd.h> >+#include <time.h> >+#include <errno.h> >+#include <stdarg.h> >+#include <linux/types.h> >+ >+#include "libgfs2.h" >+#include "gfs2_mkfs.h" >+ >+#define BUF_SIZE 4096 >+#define MB (1024 * 1024) >+ >+static uint64_t override_device_size = 0; >+static int verbose = 1; >+static int test = 0; >+ >+extern int create_new_inode(struct gfs2_sbd *sdp); >+extern int rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name); >+ >+/** >+ * usage - Print out the usage message >+ * >+ * This function does not include documentation for the -D option >+ * since normal users have no use for it at all. The -D option is >+ * only for developers. It intended use is in combination with the >+ * -T flag to find out what the result would be of trying different >+ * device sizes without actually having to try them manually. >+ */ >+ >+static void >+usage(void) >+{ >+ fprintf(stdout, >+ "Usage:\n" >+ "\n" >+ "gfs2_grow [options] /path/to/filesystem\n" >+ "\n" >+ "Options:\n" >+ " -h Usage information\n" >+ " -q Quiet, reduce verbosity\n" >+ " -T Test, do everything except update FS\n" >+ " -V Version information\n" >+ " -v Verbose, increase verbosity\n"); >+} >+ >+void >+decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) >+{ >+ int opt; >+ >+ while ((opt = getopt(argc, argv, "VD:hqTv?")) != EOF) { >+ switch (opt) { >+ case 'D': /* This option is for testing only */ >+ override_device_size = atoi(optarg); >+ override_device_size <<= 20; >+ break; >+ case 'V': >+ printf("%s %s (built %s %s)\n", argv[0], >+ GFS2_RELEASE_NAME, __DATE__, __TIME__); >+ printf("%s\n", REDHAT_COPYRIGHT); >+ exit(0); >+ case 'h': >+ usage(); >+ exit(0); >+ case 'q': >+ if (verbose) >+ verbose--; >+ break; >+ case 'T': >+ test = 1; >+ break; >+ case 'v': >+ verbose++; >+ break; >+ case ':': >+ case '?': >+ /* Unknown flag */ >+ fprintf(stderr, "Please use '-h' for usage.\n"); >+ exit(EXIT_FAILURE); >+ default: >+ fprintf(stderr, "Bad programmer! You forgot" >+ " to catch the %c flag\n", opt); >+ exit(EXIT_FAILURE); >+ break; >+ } >+ } >+ >+ if (optind == argc) { >+ usage(); >+ exit(EXIT_FAILURE); >+ } >+} >+ >+/** >+ * figure_out_rgsize >+ */ >+void figure_out_rgsize(struct gfs2_sbd *sdp, unsigned int *rgsize) >+{ >+ osi_list_t *head = &sdp->rglist; >+ struct rgrp_list *r1, *r2; >+ >+ sdp->rgsize = GFS2_DEFAULT_RGSIZE; >+ r1 = osi_list_entry(head->next->next, struct rgrp_list, list); >+ r2 = osi_list_entry(head->next->next->next, struct rgrp_list, list); >+ >+ *rgsize = r2->ri.ri_addr - r1->ri.ri_addr; >+ if (verbose) >+ printf("rgsize = %ul (0x%08x)\n", *rgsize, *rgsize); >+} >+ >+/** >+ * filesystem_size - Calculate the size of the filesystem >+ * >+ * Reads the lists of resource groups in order to >+ * work out where the last block of the filesystem is located. >+ * >+ * Returns: The calculated size >+ */ >+ >+uint64_t >+filesystem_size(struct gfs2_sbd *sdp) >+{ >+ osi_list_t *tmp; >+ struct rgrp_list *rgl; >+ uint64_t size = 0, extent; >+ >+ tmp = &sdp->rglist; >+ for (;;) { >+ tmp = tmp->next; >+ if (tmp == &sdp->rglist) >+ break; >+ rgl = osi_list_entry(tmp, struct rgrp_list, list); >+ extent = rgl->ri.ri_addr + rgl->ri.ri_length + rgl->ri.ri_data; >+ if (extent > size) >+ size = extent; >+ } >+ return size; >+} >+ >+/** >+ * initialize_new_portion - Write the new rg information to disk buffers. >+ */ >+void initialize_new_portion(struct gfs2_sbd *sdp) >+{ >+ uint64_t rgrp = 0; >+ osi_list_t *head = &sdp->rglist; >+ >+ /* Delete the old RGs from the rglist */ >+ for (rgrp = 0; !osi_list_empty(head) && >+ rgrp < (sdp->rgrps - sdp->new_rgrps); rgrp++) { >+ osi_list_del(head->next); >+ } >+ /* Build the remaining resource groups */ >+ build_rgrps(sdp); >+ /* We're done with the libgfs portion, so commit it to disk. */ >+ inode_put(sdp->md.riinode, not_updated); >+ inode_put(sdp->master_dir, not_updated); >+ bsync(sdp); >+} >+ >+/** >+ * fix_rindex - Add the new entries to the end of the rindex file. >+ */ >+void fix_rindex(struct gfs2_sbd *sdp) >+{ >+ char rindex_name[PATH_MAX]; >+ int fd, count; >+ struct rgrp_list *rl; >+ char *buf; >+ osi_list_t *tmp; >+ >+ zalloc(buf, sdp->bsize); >+ if (!buf) >+ die("Unable to allocate memory for buffers.\n"); >+ /* Now add the new rg entries to the rg index. Here we */ >+ /* need to use the gfs2 kernel code rather than the libgfs2 */ >+ /* code so we have a live update while mounted. */ >+ sprintf(rindex_name, "%s/rindex", sdp->metafs_path); >+ fd = open(rindex_name, O_RDWR); >+ if (fd < 0) { >+ cleanup_metafs(sdp); >+ die("GFS2 rindex not found. I suggest you run gfs2_fsck.\n"); >+ } >+ lseek(fd, 0, SEEK_END); >+ /* Now write the new RGs to the rindex */ >+ osi_list_foreach(tmp, &sdp->rglist) { >+ rl = osi_list_entry(tmp, struct rgrp_list, list); >+ gfs2_rindex_out(&rl->ri, buf); >+ count = write(fd, buf, sizeof(struct gfs2_rindex)); >+ } >+ close(fd); >+ free(buf); >+} >+ >+/** >+ * main_grow - do everything >+ * @argc: >+ * @argv: >+ */ >+void >+main_grow(int argc, char *argv[]) >+{ >+ struct gfs2_sbd sbd, *sdp = &sbd; >+ int rgcount, i; >+ static uint64_t fssize, fsgrowth; >+ unsigned int rgsize; >+ >+ memset(sdp, 0, sizeof(struct gfs2_sbd)); >+ sdp->bsize = GFS2_DEFAULT_BSIZE; >+ sdp->rgsize = -1; >+ sdp->jsize = GFS2_DEFAULT_JSIZE; >+ sdp->qcsize = GFS2_DEFAULT_QCSIZE; >+ sdp->md.journals = 1; >+ decode_arguments(argc, argv, sdp); >+ >+ while ((argc - optind) > 0) { >+ sdp->path_name = argv[optind++]; >+ sdp->path_fd = open(sdp->path_name, O_RDONLY); >+ if (sdp->path_fd < 0) >+ die("can't open root directory %s: %s\n", >+ sdp->path_name, strerror(errno)); >+ >+ check_for_gfs2(sdp); >+ sdp->device_fd = open(sdp->device_name, O_RDWR); >+ if (sdp->device_fd < 0) >+ die("can't open device %s: %s\n", >+ sdp->device_name, strerror(errno)); >+ device_geometry(sdp); >+ fix_device_geometry(sdp); >+ log_info("Initializing lists...\n"); >+ osi_list_init(&sdp->rglist); >+ osi_list_init(&sdp->buf_list); >+ for(i = 0; i < BUF_HASH_SIZE; i++) >+ osi_list_init(&sdp->buf_hash[i]); >+ >+ sdp->sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE; >+ sdp->bsize = sdp->sd_sb.sb_bsize; >+ compute_constants(sdp); >+ if(read_sb(sdp) < 0) >+ die("gfs: Error reading superblock.\n"); >+ >+ if (!find_gfs2_meta(sdp)) >+ mount_gfs2_meta(sdp); >+ lock_for_admin(sdp); >+ >+ /* Get master dinode */ >+ sdp->master_dir = >+ gfs2_load_inode(sdp, sdp->sd_sb.sb_master_dir.no_addr); >+ 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 */ >+ /* and therefore out of date. It shouldn't matter because */ >+ /* we're only going to write out new RG information after */ >+ /* the existing RGs, and only write to the index at EOF. */ >+ ri_update(sdp, &rgcount); >+ fssize = filesystem_size(sdp); >+ figure_out_rgsize(sdp, &rgsize); >+ fsgrowth = ((sdp->device.length - fssize) * sdp->bsize); >+ if (fsgrowth < rgsize * sdp->bsize) { >+ log_err("Error: The device has grown by less than one Resource Group (RG).\n"); >+ log_err("The device grew by %" PRIu64 "MB. ", >+ fsgrowth / MB); >+ log_err("One RG is %uMB for this file system.\n", >+ (rgsize * sdp->bsize) / MB); >+ } >+ else { >+ compute_rgrp_layout(sdp, TRUE); >+ initialize_new_portion(sdp); >+ fix_rindex(sdp); >+ } >+ cleanup_metafs(sdp); >+ close(sdp->device_fd); >+ } >+ close(sdp->path_fd); >+ sync(); >+} >Index: mkfs/main_jadd.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/mkfs/main_jadd.c,v >retrieving revision 1.10 >diff -w -u -p -p -u -r1.10 main_jadd.c >--- mkfs/main_jadd.c 26 Oct 2006 18:42:25 -0000 1.10 >+++ mkfs/main_jadd.c 5 Apr 2007 19:23:39 -0000 >@@ -23,15 +23,6 @@ > > #define BUF_SIZE 4096 > >-static char device_name[PATH_MAX]; >-static char fspath[BUF_SIZE]; >-static char fsoptions[BUF_SIZE]; >-static char metafs_path[BUF_SIZE]; >-static char lock_table[PATH_MAX]; >-static char meta_mount[PATH_MAX] = "/tmp/.gfs2meta"; >-static int metafs_fd; >-static int metafs_mounted = 0; /* If metafs was already mounted */ >- > void > make_jdata(int fd, char *value) > { >@@ -56,45 +47,18 @@ rename2system(struct gfs2_sbd *sdp, char > char oldpath[PATH_MAX], newpath[PATH_MAX]; > int error = 0; > error = snprintf(oldpath, PATH_MAX, "%s/new_inode", >- metafs_path); >+ sdp->metafs_path); > if (error >= PATH_MAX) > die("rename2system (1)\n"); > > error = snprintf(newpath, PATH_MAX, "%s/%s/%s", >- metafs_path, new_dir, new_name); >+ sdp->metafs_path, new_dir, new_name); > if (error >= PATH_MAX) > die("rename2system (2)\n"); > > return rename(oldpath, newpath); > } > >-void >-lock_for_admin(struct gfs2_sbd *sdp) >-{ >- int error; >- >- if (sdp->debug) >- printf("\nTrying to get admin lock...\n"); >- >- for (;;) { >- >- metafs_fd = open(metafs_path, O_RDONLY | O_NOFOLLOW); >- if (metafs_fd < 0) >- die("can't open %s: %s\n", >- metafs_path, strerror(errno)); >- >- error = flock(metafs_fd, LOCK_EX); >- if (error) >- die("can't flock %s: %s\n", metafs_path, >- strerror(errno)); >- >- break; >- } >- >- if (sdp->debug) >- printf("Got it.\n"); >-} >- > /** > * print_usage - print out usage information > * >@@ -238,7 +202,7 @@ create_new_inode(struct gfs2_sbd *sdp) > int fd; > int error; > >- error = snprintf(name, PATH_MAX, "%s/new_inode", metafs_path); >+ error = snprintf(name, PATH_MAX, "%s/new_inode", sdp->metafs_path); > if (error >= PATH_MAX) > die("create_new_inode (1)\n"); > >@@ -377,7 +341,8 @@ read_superblock(struct gfs2_sbd *sdp) > gfs2_sb_in(&(sdp->sd_sb), buf); > sdp->bsize = sdp->sd_sb.sb_bsize; > strcpy(lock_table,sdp->sd_sb.sb_locktable); >- sprintf(meta_mount, "%s%s%s", "/sys/fs/gfs2/", lock_table, "/meta"); >+ sprintf(sdp->meta_mount, "%s%s%s", "/sys/fs/gfs2/", lock_table, >+ "/meta"); > > close(fd); > } >@@ -408,7 +373,7 @@ find_current_journals(struct gfs2_sbd *s > DIR *dirp; > int existing_journals = 0; > >- sprintf(jindex, "%s/jindex", metafs_path); >+ sprintf(jindex, "%s/jindex", sdp->metafs_path); > dirp = opendir(jindex); > if (!dirp) { > die("Could not find the jindex directory " >@@ -491,139 +456,6 @@ add_j(struct gfs2_sbd *sdp) > new_name, error, strerror(errno)); > } > >-static int >-find_gfs2_meta(struct gfs2_sbd *sdp) >-{ >- FILE *fp = fopen("/proc/mounts", "r"); >- char name[] = "gfs2meta"; >- char buffer[BUF_SIZE]; >- char fstype[80], mfsoptions[BUF_SIZE]; >- char meta_device[BUF_SIZE]; >- int fsdump, fspass; >- >- if (fp == NULL) { >- perror("open: /proc/mounts"); >- exit(EXIT_FAILURE); >- } >- while ((fgets(buffer, 4095, fp)) != NULL) { >- buffer[4095] = 0; >- if (strstr(buffer, name) == 0) >- continue; >- >- if (sscanf(buffer, "%s %s %s %s %d %d", meta_device, >- metafs_path, fstype,mfsoptions, &fsdump, >- &fspass) != 6) >- continue; >- >- if (strcmp(meta_device, sdp->device_name) != 0 >- && strcmp(meta_device, sdp->path_name) != 0) >- continue; >- >- metafs_mounted = 1; >- >- fclose(fp); >- return TRUE; >- } >- fclose(fp); >- return FALSE; >-} >- >-static int >-dir_exists(const char *dir) >-{ >- int fd, ret; >- struct stat statbuf; >- fd = open(dir, O_RDONLY); >- if (fd<0) { >- if (errno == ENOENT) >- return 0; >- die("Couldn't open %s : %s\n", dir, strerror(errno)); >- } >- ret = fstat(fd, &statbuf); >- if (ret) >- die("stat failed on %s : %s\n", dir, strerror(errno)); >- if (S_ISDIR(statbuf.st_mode)) { >- close(fd); >- return 1; >- } >- close(fd); >- die("%s exists, but is not a directory. Cannot mount metafs here\n", dir); >-} >- >-static void >-mount_gfs2_meta(struct gfs2_sbd *sdp) >-{ >- int ret; >- /* mount the meta fs */ >- if (!dir_exists(meta_mount)) { >- ret = mkdir(meta_mount, 0700); >- if (ret) >- die("Couldn't create %s : %s\n", meta_mount, >- strerror(errno)); >- } >- >- ret = mount(sdp->device_name, meta_mount, "gfs2meta", 0, NULL); >- if (ret) >- die("Couldn't mount %s : %s\n", meta_mount, >- strerror(errno)); >- strcpy(metafs_path, meta_mount); >-} >- >-static void >-check_for_gfs2(struct gfs2_sbd *sdp) >-{ >- FILE *fp = fopen("/proc/mounts", "r"); >- char *name = sdp->path_name; >- char buffer[BUF_SIZE]; >- char fstype[80]; >- int fsdump, fspass, ret; >- >- if (name[strlen(name) - 1] == '/') >- name[strlen(name) - 1] = '\0'; >- >- if (fp == NULL) { >- perror("open: /proc/mounts"); >- exit(EXIT_FAILURE); >- } >- while ((fgets(buffer, 4095, fp)) != NULL) { >- buffer[4095] = 0; >- >- if (strstr(buffer, "0") == 0) >- continue; >- >- if ((ret = sscanf(buffer, "%s %s %s %s %d %d", device_name, fspath, >- fstype, fsoptions, &fsdump, &fspass)) != 6) >- continue; >- sdp->device_name = device_name; >- >- if (strcmp(fstype, "gfs2") != 0) >- continue; >- >- if (strcmp(fspath, name) != 0) >- continue; >- >- fclose(fp); >- if (strncmp(device_name, "/dev/loop", 9) == 0) >- die("Cannot add journal(s) to a loopback GFS mount\n"); >- >- return; >- } >- fclose(fp); >- die("gfs2 Filesystem %s not found\n", name); >-} >- >-static void >-cleanup(struct gfs2_sbd *sdp) >-{ >- int ret; >- if (!metafs_mounted) { /* was mounted by us */ >- ret = umount(meta_mount); >- if (ret) >- fprintf(stderr, "Couldn't unmount %s : %s\n", meta_mount, >- strerror(errno)); >- } >-} >- > /** > * main_jadd - do everything > * @argc: >@@ -654,7 +486,8 @@ main_jadd(int argc, char *argv[]) > > gather_info(sdp); > >- if (!find_gfs2_meta(sdp)) >+ find_gfs2_meta(sdp); >+ if (!sdp->metafs_mounted) > mount_gfs2_meta(sdp); > lock_for_admin(sdp); > >@@ -671,12 +504,8 @@ main_jadd(int argc, char *argv[]) > add_j(sdp); > } > >- close(metafs_fd); > close(sdp->path_fd); >- >- cleanup(sdp); >- >+ cleanup_metafs(sdp); > sync(); >- > print_results(sdp); > } >Index: mkfs/main_mkfs.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/mkfs/main_mkfs.c,v >retrieving revision 1.11 >diff -w -u -p -p -u -r1.11 main_mkfs.c >--- mkfs/main_mkfs.c 19 Dec 2006 17:49:53 -0000 1.11 >+++ mkfs/main_mkfs.c 5 Apr 2007 19:23:39 -0000 >@@ -86,7 +86,7 @@ decode_arguments(int argc, char *argv[], > int cont = TRUE; > int optchar; > >- sdp->device_name = NULL; >+ memset(sdp->device_name, 0, sizeof(sdp->device_name)); > sdp->md.journals = 1; > strcpy(sdp->lockproto, "lock_nolock"); > >@@ -169,10 +169,10 @@ decode_arguments(int argc, char *argv[], > case 1: > if (strcmp(optarg, "gfs2") == 0) > continue; >- if (sdp->device_name) { >+ if (sdp->device_name[0]) { > die("More than one device specified (try -h for help)"); > } >- sdp->device_name = optarg; >+ strcpy(sdp->device_name, optarg); > break; > > default: >@@ -181,11 +181,10 @@ decode_arguments(int argc, char *argv[], > }; > } > >- if ((sdp->device_name == NULL) && (optind < argc)) { >- sdp->device_name = argv[optind++]; >- } >+ if ((sdp->device_name[0] == 0) && (optind < argc)) >+ strcpy(sdp->device_name, argv[optind++]); > >- if (sdp->device_name == NULL) >+ if (sdp->device_name[0] == '\0') > die("no device specified (try -h for help)\n"); > > if (optind < argc) >@@ -264,8 +263,7 @@ static void are_you_sure(struct gfs2_sbd > die("error identifying the contents of %s: %s\n", > sdp->device_name, strerror(errno)); > >- printf("This will destroy any data on %s.\n", >- sdp->device_name); >+ printf("This will destroy any data on %s.\n", sdp->device_name); > if (volume_id_probe_all(vid, 0, sdp->device_size) == 0) > printf(" It appears to contain a %s %s.\n", vid->type, > vid->usage_id == VOLUME_ID_OTHER? "partition" : vid->usage);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 234844
:
151803
|
153018
|
153888
|
154555