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 153018 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]
Patch for gfs2_quota
quota.patch (text/plain), 15.71 KB, created by
Robert Peterson
on 2007-04-19 15:48:49 UTC
(
hide
)
Description:
Patch for gfs2_quota
Filename:
MIME Type:
Creator:
Robert Peterson
Created:
2007-04-19 15:48:49 UTC
Size:
15.71 KB
patch
obsolete
>Index: check.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/quota/check.c,v >retrieving revision 1.3 >diff -w -u -p -p -u -r1.3 check.c >--- check.c 1 Dec 2006 21:28:06 -0000 1.3 >+++ check.c 19 Apr 2007 15:45:30 -0000 >@@ -180,10 +180,10 @@ scan_fs(dev_t device, char *dirname, > * > */ > static void >-read_quota_file(commandline_t *comline, osi_list_t *uid, osi_list_t *gid) >+read_quota_file(struct gfs2_sbd *sdp, commandline_t *comline, >+ osi_list_t *uid, osi_list_t *gid) > { > int fd; >- struct gfs2_sb sb; > char buf[sizeof(struct gfs2_quota)]; > struct gfs2_quota q; > uint64_t offset = 0; >@@ -191,11 +191,11 @@ read_quota_file(commandline_t *comline, > int error; > char quota_file[BUF_SIZE]; > >- check_for_gfs2(comline->filesystem); >- read_superblock(&sb); >- if (!find_gfs2_meta(comline->filesystem)) >- mount_gfs2_meta(); >- lock_for_admin(); >+ check_for_gfs2(sdp); >+ read_superblock(&sdp->sd_sb); >+ if (!find_gfs2_meta(sdp)) >+ mount_gfs2_meta(sdp); >+ lock_for_admin(sdp); > > strcpy(quota_file, metafs_path); > strcat(quota_file, "/quota"); >@@ -224,7 +224,7 @@ read_quota_file(commandline_t *comline, > gfs2_quota_in(&q, buf); > > id = (offset / sizeof(struct gfs2_quota)) >> 1; >- q.qu_value <<= sb.sb_bsize_shift - 9; >+ q.qu_value <<= sdp->sd_sb.sb_bsize_shift - 9; > > if (q.qu_value) { > if (id * sizeof(struct gfs2_quota) * 2 == offset) >@@ -383,7 +383,7 @@ verify_pathname(commandline_t *comline) > */ > > void >-do_check(commandline_t *comline) >+do_check(struct gfs2_sbd *sdp, commandline_t *comline) > { > dev_t device; > osi_list_t fs_uid, fs_gid, qf_uid, qf_gid; >@@ -399,7 +399,7 @@ do_check(commandline_t *comline) > device = verify_pathname(comline); > > scan_fs(device, comline->filesystem, &fs_uid, &fs_gid, &hl); >- read_quota_file(comline, &qf_uid, &qf_gid); >+ read_quota_file(sdp, comline, &qf_uid, &qf_gid); > > print_list("fs user ", &fs_uid); > print_list("fs group", &fs_gid); >@@ -423,10 +423,10 @@ do_check(commandline_t *comline) > */ > > static void >-set_list(commandline_t *comline, int user, osi_list_t *list, int64_t multiplier) >+set_list(struct gfs2_sbd *sdp, commandline_t *comline, int user, >+ osi_list_t *list, int64_t multiplier) > { > int fd, fd1; >- struct gfs2_sb sb; > osi_list_t *tmp; > values_t *v; > uint64_t offset; >@@ -435,11 +435,11 @@ set_list(commandline_t *comline, int use > char quota_file[BUF_SIZE]; > char sys_q_refresh[BUF_SIZE]; > >- check_for_gfs2(comline->filesystem); >- read_superblock(&sb); >- if (!find_gfs2_meta(comline->filesystem)) >- mount_gfs2_meta(); >- lock_for_admin(); >+ check_for_gfs2(sdp); >+ read_superblock(&sdp->sd_sb); >+ if (!find_gfs2_meta(sdp)) >+ mount_gfs2_meta(sdp); >+ lock_for_admin(sdp); > > strcpy(quota_file, metafs_path); > strcat(quota_file, "/quota"); >@@ -460,7 +460,7 @@ set_list(commandline_t *comline, int use > offset += (unsigned long)(&((struct gfs2_quota *)NULL)->qu_value); > > value = v->v_blocks * multiplier; >- value >>= sb.sb_bsize_shift - 9; >+ value >>= sdp->sd_sb.sb_bsize_shift - 9; > value = cpu_to_be64(value); > > lseek(fd, offset, SEEK_SET); >@@ -472,7 +472,8 @@ set_list(commandline_t *comline, int use > } > > /* Write "1" to sysfs quota refresh file to refresh gfs quotas */ >- sprintf(sys_q_refresh, "%s%s%s", "/sys/fs/gfs2/", sb.sb_locktable, >+ sprintf(sys_q_refresh, "%s%s%s", "/sys/fs/gfs2/", >+ sdp->sd_sb.sb_locktable, > (user) ? "/quota_refresh_user" : "/quota_refresh_group"); > > fd1 = open(sys_q_refresh, O_WRONLY); >@@ -503,7 +504,7 @@ out: > */ > > void >-do_quota_init(commandline_t *comline) >+do_quota_init(struct gfs2_sbd *sdp, commandline_t *comline) > { > dev_t device; > osi_list_t fs_uid, fs_gid, qf_uid, qf_gid; >@@ -519,7 +520,7 @@ do_quota_init(commandline_t *comline) > device = verify_pathname(comline); > > scan_fs(device, comline->filesystem, &fs_uid, &fs_gid, &hl); >- read_quota_file(comline, &qf_uid, &qf_gid); >+ read_quota_file(sdp, comline, &qf_uid, &qf_gid); > > type_zalloc(v, values_t, 1); > v->v_id = 0; >@@ -536,12 +537,12 @@ do_quota_init(commandline_t *comline) > print_list("qf user ", &qf_uid); > print_list("qf group", &qf_gid); > >- set_list(comline, TRUE, &qf_uid, 0); >- set_list(comline, FALSE, &qf_gid, 0); >- set_list(comline, TRUE, &fs_uid, 1); >- set_list(comline, FALSE, &fs_gid, 1); >+ set_list(sdp, comline, TRUE, &qf_uid, 0); >+ set_list(sdp, comline, FALSE, &qf_gid, 0); >+ set_list(sdp, comline, TRUE, &fs_uid, 1); >+ set_list(sdp, comline, FALSE, &fs_gid, 1); > >- do_sync(comline); >+ do_sync(sdp, comline); > >- do_check(comline); >+ do_check(sdp, comline); > } >Index: gfs2_quota.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/quota/gfs2_quota.h,v >retrieving revision 1.2 >diff -w -u -p -p -u -r1.2 gfs2_quota.h >--- gfs2_quota.h 1 Dec 2006 21:28:06 -0000 1.2 >+++ gfs2_quota.h 19 Apr 2007 15:45:30 -0000 >@@ -98,19 +98,17 @@ extern char *prog_name; > > /* main.c */ > >-void check_for_gfs2(const char *path); > void do_get_super(int fd, struct gfs2_sb *sb); >-void do_sync(commandline_t *comline); >+void do_sync(struct gfs2_sbd *sdp, commandline_t *comline); > void lock_for_admin(); >-int find_gfs2_meta(const char *mnt); > void mount_gfs2_meta(); > void cleanup(); > void read_superblock(struct gfs2_sb *sb); > > /* check.c */ > >-void do_check(commandline_t *comline); >-void do_quota_init(commandline_t *comline); >+void do_check(struct gfs2_sbd *sdp, commandline_t *comline); >+void do_quota_init(struct gfs2_sbd *sdp, commandline_t *comline); > > /* names.c */ > >Index: main.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/quota/main.c,v >retrieving revision 1.3 >diff -w -u -p -p -u -r1.3 main.c >--- main.c 1 Dec 2006 21:28:06 -0000 1.3 >+++ main.c 19 Apr 2007 15:45:30 -0000 >@@ -93,13 +93,6 @@ print_usage() > } > > /** >- * check_for_gfs2 - Check to see if a descriptor is a file on a GFS2 filesystem >- * @fd: the file descriptor >- * @path: the path used to open the descriptor >- * >- */ >- >-/** > * decode_arguments - parse command line arguments > * @argc: well, it's argc... > * @argv: well, it's argv... >@@ -287,107 +280,6 @@ print_quota(commandline_t *comline, > } > > void >-lock_for_admin() >-{ >- int error; >- >- 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; >- } >-} >- >-int >-find_gfs2_meta(const char *mnt) >-{ >- 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; >- >- metafs_mounted = 0; >- >- 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, device_name) != 0 >- && strcmp(meta_device, mnt) != 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); >-} >- >-void >-mount_gfs2_meta() >-{ >- 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(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); >-} >- >-void > cleanup() > { > int ret; >@@ -400,44 +292,6 @@ cleanup() > } > > void >-check_for_gfs2(const char *mnt) >-{ >- FILE *fp = fopen("/proc/mounts", "r"); >- char buffer[4096]; >- char fstype[80]; >- int fsdump, fspass, ret; >- >- 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; >- >- if (strcmp(fstype, "gfs2") != 0) >- continue; >- >- if (strcmp(fspath, mnt) != 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", mnt); >-} >- >-void > read_superblock(struct gfs2_sb *sb) > { > int fd; >@@ -462,10 +316,9 @@ read_superblock(struct gfs2_sb *sb) > */ > > static void >-do_list(commandline_t *comline) >+do_list(struct gfs2_sbd *sdp, commandline_t *comline) > { > int fd; >- struct gfs2_sb sb; > struct gfs2_quota q; > char buf[sizeof(struct gfs2_quota)]; > uint64_t offset; >@@ -477,11 +330,11 @@ do_list(commandline_t *comline) > if (!*comline->filesystem) > die("need a filesystem to work on\n"); > >- check_for_gfs2(comline->filesystem); >- read_superblock(&sb); >- if (!find_gfs2_meta(comline->filesystem)) >- mount_gfs2_meta(); >- lock_for_admin(); >+ check_for_gfs2(sdp); >+ read_superblock(&sdp->sd_sb); >+ if (!find_gfs2_meta(sdp)) >+ mount_gfs2_meta(sdp); >+ lock_for_admin(sdp); > > strcpy(quota_file, metafs_path); > strcat(quota_file, "/quota"); >@@ -512,7 +365,7 @@ do_list(commandline_t *comline) > > if (q.qu_limit || q.qu_warn || q.qu_value) > print_quota(comline, (pass) ? FALSE : TRUE, id, >- &q, &sb); >+ &q, &sdp->sd_sb); > > offset += 2 * sizeof(struct gfs2_quota); > } while (error == sizeof(struct gfs2_quota)); >@@ -531,21 +384,20 @@ do_list(commandline_t *comline) > */ > > static void >-do_get_one(commandline_t *comline, char *filesystem) >+do_get_one(struct gfs2_sbd *sdp, commandline_t *comline, char *filesystem) > { > int fd; > char buf[256]; > struct gfs2_quota q; >- struct gfs2_sb sb; > uint64_t offset; > int error; > char quota_file[BUF_SIZE]; > >- check_for_gfs2(filesystem); >- read_superblock(&sb); >- if (!find_gfs2_meta(filesystem)) >- mount_gfs2_meta(); >- lock_for_admin(); >+ check_for_gfs2(sdp); >+ read_superblock(&sdp->sd_sb); >+ if (!find_gfs2_meta(sdp)) >+ mount_gfs2_meta(sdp); >+ lock_for_admin(sdp); > > strcpy(quota_file, metafs_path); > strcat(quota_file, "/quota"); >@@ -580,7 +432,7 @@ do_get_one(commandline_t *comline, char > > print_quota(comline, > (comline->id_type == GQ_ID_USER), comline->id, >- &q, &sb); >+ &q, &sdp->sd_sb); > > close(fd); > close(metafs_fd); >@@ -594,12 +446,12 @@ do_get_one(commandline_t *comline, char > */ > > static void >-do_get(commandline_t *comline) >+do_get(struct gfs2_sbd *sdp, commandline_t *comline) > { > int first = TRUE; > > if (*comline->filesystem) >- do_get_one(comline, comline->filesystem); >+ do_get_one(sdp, comline, comline->filesystem); > else { > char buf[256], device[256], path[256], type[256]; > FILE *file; >@@ -620,7 +472,7 @@ do_get(commandline_t *comline) > printf("\n"); > > printf("%s\n", path); >- do_get_one(comline, path); >+ do_get_one(sdp, comline, path); > } > > fclose(file); >@@ -633,16 +485,15 @@ do_get(commandline_t *comline) > * > */ > static void >-do_sync_one(char *filesystem) >+do_sync_one(struct gfs2_sbd *sdp, char *filesystem) > { > int fd; >- struct gfs2_sb sb; > char sys_quota_sync[PATH_MAX]; > >- check_for_gfs2(filesystem); >- read_superblock(&sb); >+ check_for_gfs2(sdp); >+ read_superblock(&sdp->sd_sb); > sprintf(sys_quota_sync, "%s%s%s", >- "/sys/fs/gfs2/", sb.sb_locktable, "/quota_sync"); >+ "/sys/fs/gfs2/", sdp->sd_sb.sb_locktable, "/quota_sync"); > > fd = open(sys_quota_sync, O_WRONLY); > if (fd < 0) >@@ -662,12 +513,12 @@ do_sync_one(char *filesystem) > */ > > void >-do_sync(commandline_t *comline) >+do_sync(struct gfs2_sbd *sdp, commandline_t *comline) > { > sync(); > > if (*comline->filesystem) >- do_sync_one(comline->filesystem); >+ do_sync_one(sdp, comline->filesystem); > else { > char buf[256], device[256], path[256], type[256]; > FILE *file; >@@ -682,7 +533,7 @@ do_sync(commandline_t *comline) > if (strcmp(type, "gfs2") != 0) > continue; > >- do_sync_one(path); >+ do_sync_one(sdp, path); > } > > fclose(file); >@@ -696,11 +547,10 @@ do_sync(commandline_t *comline) > */ > > static void >-do_set(commandline_t *comline) >+do_set(struct gfs2_sbd *sdp, commandline_t *comline) > { > int fd, fd1; > uint64_t offset; >- struct gfs2_sb sb; > uint64_t new_value; > int error; > char quota_file[BUF_SIZE]; >@@ -711,11 +561,11 @@ do_set(commandline_t *comline) > if (!comline->new_value_set) > die("need a new value\n"); > >- check_for_gfs2(comline->filesystem); >- read_superblock(&sb); >- if (!find_gfs2_meta(comline->filesystem)) >- mount_gfs2_meta(); >- lock_for_admin(); >+ check_for_gfs2(sdp); >+ read_superblock(&sdp->sd_sb); >+ if (!find_gfs2_meta(sdp)) >+ mount_gfs2_meta(sdp); >+ lock_for_admin(sdp); > > strcpy(quota_file, metafs_path); > strcat(quota_file, "/quota"); >@@ -758,14 +608,16 @@ do_set(commandline_t *comline) > > switch (comline->units) { > case GQ_UNITS_MEGABYTE: >- new_value = comline->new_value << (20 - sb.sb_bsize_shift); >+ new_value = >+ comline->new_value << (20 - sdp->sd_sb.sb_bsize_shift); > break; > > case GQ_UNITS_KILOBYTE: >- if (sb.sb_bsize == 512) >+ if (sdp->sd_sb.sb_bsize == 512) > new_value = comline->new_value * 2; > else >- new_value = comline->new_value >> (sb.sb_bsize_shift - 10); >+ new_value = comline->new_value >> >+ (sdp->sd_sb.sb_bsize_shift - 10); > break; > > case GQ_UNITS_FSBLOCK: >@@ -773,7 +625,8 @@ do_set(commandline_t *comline) > break; > > case GQ_UNITS_BASICBLOCK: >- new_value = comline->new_value >> (sb.sb_bsize_shift - 9); >+ new_value = comline->new_value >> >+ (sdp->sd_sb.sb_bsize_shift - 9); > break; > > default: >@@ -792,7 +645,8 @@ do_set(commandline_t *comline) > } > > /* Write "1" to sysfs quota refresh file to refresh gfs quotas */ >- sprintf(sys_q_refresh, "%s%s%s", "/sys/fs/gfs2/", sb.sb_locktable, >+ sprintf(sys_q_refresh, "%s%s%s", "/sys/fs/gfs2/", >+ sdp->sd_sb.sb_locktable, > comline->id_type == GQ_ID_USER ? "/quota_refresh_user" : > "/quota_refresh_group"); > >@@ -827,41 +681,44 @@ out: > int > main(int argc, char *argv[]) > { >+ struct gfs2_sbd sbd, *sdp = &sbd; > commandline_t comline; > > prog_name = argv[0]; > metafs_mounted = 0; > >+ memset(sdp, 0, sizeof(struct gfs2_sbd)); > memset(&comline, 0, sizeof(commandline_t)); > > decode_arguments(argc, argv, &comline); >+ strcpy(sdp->path_name, comline.filesystem); > > switch (comline.operation) { > case GQ_OP_LIST: >- do_list(&comline); >+ do_list(sdp, &comline); > break; > > case GQ_OP_GET: >- do_get(&comline); >+ do_get(sdp, &comline); > break; > > case GQ_OP_LIMIT: > case GQ_OP_WARN: >- do_set(&comline); >+ do_set(sdp, &comline); > break; > > case GQ_OP_SYNC: >- do_sync(&comline); >+ do_sync(sdp, &comline); > break; > > case GQ_OP_CHECK: >- do_sync(&comline); >- do_check(&comline); >+ do_sync(sdp, &comline); >+ do_check(sdp, &comline); > break; > > case GQ_OP_INIT: >- do_sync(&comline); >- do_quota_init(&comline); >+ do_sync(sdp, &comline); >+ do_quota_init(sdp, &comline); > break; > > default: >@@ -869,7 +726,7 @@ main(int argc, char *argv[]) > comline.id_type = GQ_ID_USER; > comline.id = geteuid(); > } >- do_get(&comline); >+ do_get(sdp, &comline); > break; > } >
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