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 251611 Details for
Bug 364741
GFS2: gfs2_quota doesn't work unless lock table specified
[?]
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]
Proposed patch to fix the problem
364741.try1.patch (text/plain), 26.56 KB, created by
Robert Peterson
on 2007-11-08 15:22:38 UTC
(
hide
)
Description:
Proposed patch to fix the problem
Filename:
MIME Type:
Creator:
Robert Peterson
Created:
2007-11-08 15:22:38 UTC
Size:
26.56 KB
patch
obsolete
>Index: edit/hexedit.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/edit/hexedit.h,v >retrieving revision 1.12 >diff -w -u -p -p -u -r1.12 hexedit.h >--- edit/hexedit.h 18 Oct 2007 19:56:41 -0000 1.12 >+++ edit/hexedit.h 8 Nov 2007 14:57:28 -0000 >@@ -197,31 +197,6 @@ EXTERN enum dsp_mode dmode INIT(HEX_MODE > #define SCREEN_HEIGHT (16) > #define SCREEN_WIDTH (16) > >-/* I/O macros */ >- >-#define do_lseek(fd, off) \ >-{ \ >- if (lseek((fd), (off), SEEK_SET) != (off)) \ >- die("bad seek: %s on line %d of file %s\n", \ >- strerror(errno),__LINE__, __FILE__); \ >-} >- >-#define do_read(fd, buff, len) \ >-{ \ >- if (read((fd), (buff), (len)) != (len)) \ >- die("bad read: %s on line %d of file %s\n", \ >- strerror(errno), __LINE__, __FILE__); \ >-} >- >-#define do_write(fd, buff, len) \ >-{ \ >- if (write((fd), (buff), (len)) != (len)) \ >- die("bad write: %s on line %d of file %s\n", \ >- strerror(errno), __LINE__, __FILE__); \ >-} >- >- >- > /* Memory macros */ > > #define type_zalloc(ptr, type, count) \ >Index: fsck/initialize.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/fsck/initialize.c,v >retrieving revision 1.10 >diff -w -u -p -p -u -r1.10 initialize.c >--- fsck/initialize.c 19 Oct 2007 15:06:56 -0000 1.10 >+++ fsck/initialize.c 8 Nov 2007 14:57:28 -0000 >@@ -169,7 +169,7 @@ static int set_block_ranges(struct gfs2_ > last_data_block = rmax; > first_data_block = rmin; > >- if(do_lseek(sdp->device_fd, (last_fs_block * sdp->sd_sb.sb_bsize))){ >+ if(fsck_lseek(sdp->device_fd, (last_fs_block * sdp->sd_sb.sb_bsize))){ > log_crit("Can't seek to last block in file system: %" > PRIu64" (0x%" PRIx64 ")\n", last_fs_block, last_fs_block); > goto fail; >Index: fsck/util.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/fsck/util.h,v >retrieving revision 1.2 >diff -w -u -p -p -u -r1.2 util.h >--- fsck/util.h 6 Jun 2006 14:49:31 -0000 1.2 >+++ fsck/util.h 8 Nov 2007 14:57:28 -0000 >@@ -16,16 +16,9 @@ > > #include "libgfs2.h" > >-#define do_lseek(fd, off) \ >+#define fsck_lseek(fd, off) \ > ((lseek((fd), (off), SEEK_SET) == (off)) ? 0 : -1) > >-#define do_read(fd, buff, len) \ >- ((read((fd), (buff), (len)) == (len)) ? 0 : -1) >- >-#define do_write(fd, buff, len) \ >- ((write((fd), (buff), (len)) == (len)) ? 0 : -1) >- >- > int compute_height(struct gfs2_sbd *sdp, uint64_t sz); > struct di_info *search_list(osi_list_t *list, uint64_t addr); > void warm_fuzzy_stuff(uint64_t block); >Index: libgfs2/buf.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/buf.c,v >retrieving revision 1.3 >diff -w -u -p -p -u -r1.3 buf.c >--- libgfs2/buf.c 8 Jun 2006 21:02:15 -0000 1.3 >+++ libgfs2/buf.c 8 Nov 2007 14:57:28 -0000 >@@ -25,27 +25,6 @@ > > #include "libgfs2.h" > >-#define do_lseek(sdp, off) \ >-do { \ >- if (lseek((sdp)->device_fd, (off), SEEK_SET) != (off)) \ >- die("bad seek: %s on line %d of file %s\n", \ >- strerror(errno), __LINE__, __FILE__); \ >-} while (0) >- >-#define do_read(sdp, buf, len) \ >-do { \ >- if (read((sdp)->device_fd, (buf), (len)) != (len)) \ >- die("bad read: %s on line %d of file %s\n", \ >- strerror(errno), __LINE__, __FILE__); \ >-} while (0) >- >-#define do_write(sdp, buf, len) \ >-do { \ >- if (write((sdp)->device_fd, (buf), (len)) != (len)) \ >- die("bad write: %s on line %d of file %s\n", \ >- strerror(errno), __LINE__, __FILE__); \ >-} while (0) >- > static __inline__ osi_list_t * > blkno2head(struct gfs2_sbd *sdp, uint64_t blkno) > { >@@ -59,8 +38,8 @@ void write_buffer(struct gfs2_sbd *sdp, > osi_list_del(&bh->b_hash); > sdp->num_bufs--; > if (bh->b_changed) { >- do_lseek(sdp, bh->b_blocknr * sdp->bsize); >- do_write(sdp, bh->b_data, sdp->bsize); >+ do_lseek(sdp->device_fd, bh->b_blocknr * sdp->bsize); >+ do_write(sdp->device_fd, bh->b_data, sdp->bsize); > sdp->writes++; > } > free(bh); >@@ -126,8 +105,8 @@ struct gfs2_buffer_head *bget_generic(st > bh->b_data = (char *)bh + sizeof(struct gfs2_buffer_head); > bh->b_size = sdp->bsize; > if (read_disk) { >- do_lseek(sdp, num * sdp->bsize); >- do_read(sdp, bh->b_data, sdp->bsize); >+ do_lseek(sdp->device_fd, num * sdp->bsize); >+ do_read(sdp->device_fd, bh->b_data, sdp->bsize); > } > add_buffer(sdp, bh); > bh->b_changed = FALSE; >@@ -196,8 +175,8 @@ void bcommit(struct gfs2_sbd *sdp) > if (!bh->b_count) /* if not reserved for later */ > write_buffer(sdp, bh); /* write the data, free the memory */ > else if (bh->b_changed) { /* if buffer has changed */ >- do_lseek(sdp, bh->b_blocknr * sdp->bsize); >- do_write(sdp, bh->b_data, sdp->bsize); /* write it out */ >+ do_lseek(sdp->device_fd, bh->b_blocknr * sdp->bsize); >+ do_write(sdp->device_fd, bh->b_data, sdp->bsize); /* write it out */ > bh->b_changed = FALSE; /* no longer changed */ > } > } >Index: libgfs2/libgfs2.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/libgfs2.h,v >retrieving revision 1.21 >diff -w -u -p -p -u -r1.21 libgfs2.h >--- libgfs2/libgfs2.h 19 Oct 2007 15:06:56 -0000 1.21 >+++ libgfs2/libgfs2.h 8 Nov 2007 14:57:29 -0000 >@@ -40,6 +40,27 @@ do { \ > exit(EXIT_FAILURE); \ > } while (0) > >+#define do_lseek(fd, off) \ >+{ \ >+ if (lseek((fd), (off), SEEK_SET) != (off)) \ >+ die("bad seek: %s on line %d of file %s\n", \ >+ strerror(errno),__LINE__, __FILE__); \ >+} >+ >+#define do_read(fd, buff, len) \ >+{ \ >+ if (read((fd), (buff), (len)) < 0) \ >+ die("bad read: %s on line %d of file %s\n", \ >+ strerror(errno), __LINE__, __FILE__); \ >+} >+ >+#define do_write(fd, buff, len) \ >+{ \ >+ if (write((fd), (buff), (len)) != (len)) \ >+ die("bad write: %s on line %d of file %s\n", \ >+ strerror(errno), __LINE__, __FILE__); \ >+} >+ > #define zalloc(ptr, size) \ > do { \ > (ptr) = malloc((size)); \ >@@ -507,6 +528,8 @@ int gfs2_query(int *setonabort, struct g > const char *format, ...); > > /* misc.c */ >+#define SYS_BASE "/sys/fs/gfs2" >+ > void compute_constants(struct gfs2_sbd *sdp); > int find_gfs2_meta(struct gfs2_sbd *sdp); > int dir_exists(const char *dir); >@@ -514,6 +537,20 @@ 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); >+char *get_list(void); >+char **str2lines(char *str); >+char *find_debugfs_mount(void); >+char *mp2fsname(char *mp); >+char *name2value(char *str, char *name); >+uint32_t name2u32(char *str, char *name); >+uint64_t name2u64(char *str, char *name); >+char *__get_sysfs(char *fsname, char *filename); >+char *get_sysfs(char *fsname, char *filename); >+unsigned int get_sysfs_uint(char *fsname, char *filename); >+void set_sysfs(char *fsname, char *filename, char *val); >+char *do_basename(char *device); >+char *mp2devname(char *mp); >+int is_fsname(char *name); > > /* recovery.c */ > void gfs2_replay_incr_blk(struct gfs2_inode *ip, unsigned int *blk); >Index: libgfs2/misc.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/libgfs2/misc.c,v >retrieving revision 1.5 >diff -w -u -p -p -u -r1.5 misc.c >--- libgfs2/misc.c 25 Oct 2007 14:14:32 -0000 1.5 >+++ libgfs2/misc.c 8 Nov 2007 14:57:29 -0000 >@@ -25,9 +25,15 @@ > #include <sys/mount.h> > #include <linux/types.h> > #include <sys/file.h> >+#include <dirent.h> >+#include <linux/kdev_t.h> > > #include "libgfs2.h" > >+#define PAGE_SIZE (4096) >+ >+static char sysfs_buf[PAGE_SIZE]; >+ > void > compute_constants(struct gfs2_sbd *sdp) > { >@@ -275,3 +281,432 @@ cleanup_metafs(struct gfs2_sbd *sdp) > } > } > >+char *__get_sysfs(char *fsname, char *filename) >+{ >+ char path[PATH_MAX]; >+ int fd, rv; >+ >+ memset(path, 0, PATH_MAX); >+ memset(sysfs_buf, 0, PAGE_SIZE); >+ snprintf(path, PATH_MAX - 1, "%s/%s/%s", SYS_BASE, fsname, filename); >+ >+ fd = open(path, O_RDONLY); >+ if (fd < 0) >+ die("can't open %s: %s\n", path, strerror(errno)); >+ rv = read(fd, sysfs_buf, PAGE_SIZE); >+ if (rv < 0) >+ die("can't read from %s: %s\n", path, strerror(errno)); >+ >+ close(fd); >+ return sysfs_buf; >+} >+ >+char * >+get_sysfs(char *fsname, char *filename) >+{ >+ char *p = strchr(__get_sysfs(fsname, filename), '\n'); >+ if (p) >+ *p = '\0'; >+ return sysfs_buf; >+} >+ >+unsigned int >+get_sysfs_uint(char *fsname, char *filename) >+{ >+ unsigned int x; >+ sscanf(__get_sysfs(fsname, filename), "%u", &x); >+ return x; >+} >+ >+void >+set_sysfs(char *fsname, char *filename, char *val) >+{ >+ char path[PATH_MAX]; >+ int fd, rv, len; >+ >+ len = strlen(val) + 1; >+ if (len > PAGE_SIZE) >+ die("value for %s is too larger for sysfs\n", path); >+ >+ memset(path, 0, PATH_MAX); >+ snprintf(path, PATH_MAX - 1, "%s/%s/%s", SYS_BASE, fsname, filename); >+ >+ fd = open(path, O_WRONLY); >+ if (fd < 0) >+ die("can't open %s: %s\n", path, strerror(errno)); >+ >+ rv = write(fd, val, len); >+ if (rv != len){ >+ if (rv < 0) >+ die("can't write to %s: %s", path, strerror(errno)); >+ else >+ die("tried to write %d bytes to path, wrote %d\n", >+ len, rv); >+ } >+ close(fd); >+} >+ >+/** >+ * get_list - Get the list of GFS2 filesystems >+ * >+ * Returns: a NULL terminated string >+ */ >+ >+#define LIST_SIZE 1048576 >+ >+char * >+get_list(void) >+{ >+ char path[PATH_MAX]; >+ char s_id[PATH_MAX]; >+ char *list, *p; >+ int rv, fd, x = 0, total = 0; >+ DIR *d; >+ struct dirent *de; >+ >+ list = malloc(LIST_SIZE); >+ if (!list) >+ die("out of memory\n"); >+ >+ memset(path, 0, PATH_MAX); >+ snprintf(path, PATH_MAX, "%s", SYS_BASE); >+ >+ d = opendir(path); >+ if (!d) >+ die("can't open %s: %s\n", SYS_BASE, strerror(errno)); >+ >+ while ((de = readdir(d))) { >+ if (de->d_name[0] == '.') >+ continue; >+ >+ memset(path, 0, PATH_MAX); >+ snprintf(path, PATH_MAX, "%s/%s/id", SYS_BASE, de->d_name); >+ >+ fd = open(path, O_RDONLY); >+ if (fd < 0) >+ die("can't open %s: %s\n", path, strerror(errno)); >+ >+ memset(s_id, 0, PATH_MAX); >+ >+ rv = read(fd, s_id, sizeof(s_id)); >+ if (rv < 0) >+ die("can't read %s: %s\n", path, strerror(errno)); >+ >+ close(fd); >+ >+ p = strstr(s_id, "\n"); >+ if (p) >+ *p = '\0'; >+ >+ total += strlen(s_id) + strlen(de->d_name) + 2; >+ if (total > LIST_SIZE) >+ break; >+ >+ x += sprintf(list + x, "%s %s\n", s_id, de->d_name); >+ >+ } >+ >+ closedir(d); >+ >+ return list; >+} >+ >+/** >+ * str2lines - parse a string into lines >+ * @list: the list >+ * >+ * Returns: An array of character pointers >+ */ >+ >+char ** >+str2lines(char *str) >+{ >+ char *p; >+ unsigned int n = 0; >+ char **lines; >+ unsigned int x = 0; >+ >+ for (p = str; *p; p++) >+ if (*p == '\n') >+ n++; >+ >+ lines = malloc((n + 1) * sizeof(char *)); >+ if (!lines) >+ die("out of memory\n"); >+ >+ for (lines[x] = p = str; *p; p++) >+ if (*p == '\n') { >+ *p = 0; >+ lines[++x] = p + 1; >+ } >+ >+ return lines; >+} >+ >+/** >+ * do_basename - Create dm-N style name for the device >+ * @device: >+ * >+ * Returns: Pointer to dm name or basename >+ */ >+ >+char * >+do_basename(char *device) >+{ >+ FILE *file; >+ int found = FALSE; >+ char line[PATH_MAX], major_name[PATH_MAX]; >+ unsigned int major_number; >+ struct stat st; >+ >+ file = fopen("/proc/devices", "r"); >+ if (!file) >+ goto punt; >+ >+ while (fgets(line, PATH_MAX, file)) { >+ if (sscanf(line, "%u %s", &major_number, major_name) != 2) >+ continue; >+ if (strcmp(major_name, "device-mapper") != 0) >+ continue; >+ found = TRUE; >+ break; >+ } >+ >+ fclose(file); >+ >+ if (!found) >+ goto punt; >+ >+ if (stat(device, &st)) >+ goto punt; >+ if (major(st.st_rdev) == major_number) { >+ static char realname[16]; >+ snprintf(realname, 16, "dm-%u", minor(st.st_rdev)); >+ return realname; >+ } >+ >+ punt: >+ return basename(device); >+} >+ >+char * >+mp2devname(char *mp) >+{ >+ FILE *file; >+ char line[PATH_MAX]; >+ static char device[PATH_MAX]; >+ char *name = NULL; >+ char *realname; >+ >+ realname = realpath(mp, NULL); >+ if (!realname) >+ die("Unable to allocate memory for name resolution.\n"); >+ file = fopen("/proc/mounts", "r"); >+ if (!file) >+ die("can't open /proc/mounts: %s\n", strerror(errno)); >+ >+ while (fgets(line, PATH_MAX, file)) { >+ char path[PATH_MAX], type[PATH_MAX]; >+ >+ if (sscanf(line, "%s %s %s", device, path, type) != 3) >+ continue; >+ if (strcmp(path, realname)) >+ continue; >+ if (strcmp(type, "gfs2")) >+ die("%s is not a GFS2 filesystem\n", mp); >+ >+ name = do_basename(device); >+ >+ break; >+ } >+ >+ free(realname); >+ fclose(file); >+ >+ return name; >+} >+ >+char * >+find_debugfs_mount(void) >+{ >+ FILE *file; >+ char line[PATH_MAX]; >+ char device[PATH_MAX], type[PATH_MAX]; >+ char *path; >+ >+ file = fopen("/proc/mounts", "rt"); >+ if (!file) >+ die("can't open /proc/mounts: %s\n", strerror(errno)); >+ >+ path = malloc(PATH_MAX); >+ if (!path) >+ die("Can't allocate memory for debugfs.\n"); >+ while (fgets(line, PATH_MAX, file)) { >+ >+ if (sscanf(line, "%s %s %s", device, path, type) != 3) >+ continue; >+ if (!strcmp(type, "debugfs")) { >+ fclose(file); >+ return path; >+ } >+ } >+ >+ free(path); >+ fclose(file); >+ return NULL; >+} >+ >+/* The fsname can be substituted for the mountpoint on the command line. >+ This is necessary when we can't resolve a devname from /proc/mounts >+ to a fsname. */ >+ >+int is_fsname(char *name) >+{ >+ int rv = 0; >+ DIR *d; >+ struct dirent *de; >+ >+ d = opendir(SYS_BASE); >+ if (!d) >+ die("can't open %s: %s\n", SYS_BASE, strerror(errno)); >+ >+ while ((de = readdir(d))) { >+ if (de->d_name[0] == '.') >+ continue; >+ >+ if (strcmp(de->d_name, name) == 0) { >+ rv = 1; >+ break; >+ } >+ } >+ >+ closedir(d); >+ >+ return rv; >+} >+ >+/** >+ * mp2fsname - Find the name for a filesystem given its mountpoint >+ * >+ * We do this by iterating through gfs2 dirs in /sys/fs/gfs2/ looking for >+ * one where the "id" attribute matches the device id returned by stat for >+ * the mount point. The reason we go through all this is simple: the >+ * kernel's sysfs is named after the VFS s_id, not the device name. >+ * So it's perfectly legal to do something like this to simulate user >+ * conditions without the proper hardware: >+ * # rm /dev/sdb1 >+ * # mkdir /dev/cciss >+ * # mknod /dev/cciss/c0d0p1 b 8 17 >+ * # mount -tgfs2 /dev/cciss/c0d0p1 /mnt/gfs2 >+ * # gfs2_tool gettune /mnt/gfs2 >+ * In this example the tuning variables are in a directory named after the >+ * VFS s_id, which in this case would be /sys/fs/gfs2/sdb1/ >+ * >+ * Returns: the fsname >+ */ >+ >+char * >+mp2fsname(char *mp) >+{ >+ char device_id[PATH_MAX], *fsname = NULL; >+ struct stat statbuf; >+ DIR *d; >+ struct dirent *de; >+ >+ if (stat(mp, &statbuf)) >+ return NULL; >+ >+ memset(device_id, 0, sizeof(device_id)); >+ sprintf(device_id, "%u:%u", (uint32_t)MAJOR(statbuf.st_dev), >+ (uint32_t)MINOR(statbuf.st_dev)); >+ >+ d = opendir(SYS_BASE); >+ if (!d) >+ die("can't open %s: %s\n", SYS_BASE, strerror(errno)); >+ >+ while ((de = readdir(d))) { >+ if (de->d_name[0] == '.') >+ continue; >+ >+ if (strcmp(get_sysfs(de->d_name, "id"), device_id) == 0) { >+ fsname = strdup(de->d_name); >+ break; >+ } >+ } >+ >+ closedir(d); >+ >+ return fsname; >+} >+ >+/** >+ * name2value - find the value of a name-value pair in a string >+ * @str_in: >+ * @name: >+ * >+ * Returns: the value string in a static buffer >+ */ >+ >+char * >+name2value(char *str_in, char *name) >+{ >+ char str[strlen(str_in) + 1]; >+ static char value[PATH_MAX]; >+ char **lines; >+ unsigned int x; >+ unsigned int len = strlen(name); >+ >+ strcpy(str, str_in); >+ value[0] = 0; >+ >+ lines = str2lines(str); >+ >+ for (x = 0; *lines[x]; x++) >+ if (memcmp(lines[x], name, len) == 0 && >+ lines[x][len] == ' ') { >+ strcpy(value, lines[x] + len + 1); >+ break; >+ } >+ >+ free(lines); >+ >+ return value; >+} >+ >+/** >+ * name2u32 - find the value of a name-value pair in a string >+ * @str_in: >+ * @name: >+ * >+ * Returns: the value uint32 >+ */ >+ >+uint32_t >+name2u32(char *str, char *name) >+{ >+ char *value = name2value(str, name); >+ uint32_t x = 0; >+ >+ sscanf(value, "%u", &x); >+ >+ return x; >+} >+ >+/** >+ * name2u64 - find the value of a name-value pair in a string >+ * @str_in: >+ * @name: >+ * >+ * Returns: the value uint64 >+ */ >+ >+uint64_t >+name2u64(char *str, char *name) >+{ >+ char *value = name2value(str, name); >+ uint64_t x = 0; >+ >+ sscanf(value, "%"SCNu64, &x); >+ >+ return x; >+} >Index: mkfs/gfs2_mkfs.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/mkfs/gfs2_mkfs.h,v >retrieving revision 1.9 >diff -w -u -p -p -u -r1.9 gfs2_mkfs.h >--- mkfs/gfs2_mkfs.h 26 Oct 2006 18:42:25 -0000 1.9 >+++ mkfs/gfs2_mkfs.h 8 Nov 2007 14:57:29 -0000 >@@ -35,46 +35,6 @@ void main_mkfs(int argc, char *argv[]); > /* main_shrink */ > void main_shrink(int argc, char *argv[]); > >-static inline int __do_read(int fd, char *buff, size_t len, >- const char *file, int line) >-{ >- int ret = read(fd, buff, len); >- if (ret < 0) { >- die("bad read: %s on line %d of file %s\n", >- strerror(errno), line, file); >- } >- return ret; >-} >- >-#define do_read(fd, buf, len) \ >- __do_read((fd), (buf), (len), __FILE__, __LINE__) >- >-static inline int __do_write(int fd, char *buff, size_t len, >- const char *file, int line) >-{ >- int ret = write(fd, buff, len); >- if (ret != len) { >- die("bad write: %s on line %d of file %s\n", >- strerror(errno), line, file); >- } >- return ret; >-} >- >-#define do_write(fd, buf, len) \ >- __do_write((fd), (buf), (len), __FILE__, __LINE__) >- >-static inline int __do_lseek(int fd, off_t off, const char *file, int line) >-{ >- if (lseek(fd, off, SEEK_SET) != off) { >- die("bad seek: %s on line %d of file %s\n", >- strerror(errno), line, file); >- } >- return 0; >-} >- >-#define do_lseek(fd, off) \ >- __do_lseek((fd), (off), __FILE__, __LINE__) >- > /* > * The following inode IOCTL macros and inode flags > * are copied from linux/fs.h, because we have duplicate >Index: quota/check.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/quota/check.c,v >retrieving revision 1.6 >diff -w -u -p -p -u -r1.6 check.c >--- quota/check.c 24 Aug 2007 06:08:26 -0000 1.6 >+++ quota/check.c 8 Nov 2007 14:57:29 -0000 >@@ -455,15 +455,15 @@ static void > set_list(struct gfs2_sbd *sdp, commandline_t *comline, int user, > osi_list_t *list, int64_t multiplier) > { >- int fd, fd1; >+ int fd; > osi_list_t *tmp; > values_t *v; > uint64_t offset; > int64_t value; > int error; > char quota_file[BUF_SIZE]; >- char sys_q_refresh[BUF_SIZE]; > char id_str[16]; >+ char *fs; > > strcpy(sdp->path_name, comline->filesystem); > check_for_gfs2(sdp); >@@ -503,27 +503,11 @@ set_list(struct gfs2_sbd *sdp, commandli > } > > /* Write the id to sysfs quota refresh file to refresh gfs quotas */ >- 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); >- if (fd1 < 0) { >- fprintf(stderr, "can't open file %s: %s\n", >- sys_q_refresh, strerror(errno)); >- goto out; >- } >- >+ fs = mp2fsname(comline->filesystem); > sprintf(id_str, "%d", comline->id); >- >- if (write(fd1,(void*)id_str, strlen(id_str)) != strlen(id_str)) { >- close(fd1); >- fprintf(stderr, "failed to write to %s: %s\n", >- sys_q_refresh, strerror(errno)); >- goto out; >- } >- close(fd1); >+ set_sysfs(fs, comline->id_type == GQ_ID_USER ? >+ "quota_refresh_user" : "quota_refresh_group", >+ id_str); > } > > out: >Index: quota/gfs2_quota.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/quota/gfs2_quota.h,v >retrieving revision 1.5 >diff -w -u -p -p -u -r1.5 gfs2_quota.h >--- quota/gfs2_quota.h 24 Aug 2007 06:08:26 -0000 1.5 >+++ quota/gfs2_quota.h 8 Nov 2007 14:57:29 -0000 >@@ -18,21 +18,6 @@ > #include "linux_endian.h" > #include <linux/gfs2_ondisk.h> > >-#ifndef TRUE >-#define TRUE (1) >-#endif >- >-#ifndef FALSE >-#define FALSE (0) >-#endif >- >-#define die(fmt, args...) \ >-do { \ >- fprintf(stderr, "%s: ", prog_name); \ >- fprintf(stderr, fmt, ##args); \ >- exit(EXIT_FAILURE); \ >-} while (0) >- > #define type_zalloc(ptr, type, count) \ > do { \ > (ptr) = (type *)malloc(sizeof(type) * (count)); \ >@@ -116,45 +101,4 @@ void do_quota_init(struct gfs2_sbd *sdp, > uint32_t name_to_id(int user, char *name, int numbers); > char *id_to_name(int user, uint32_t id, int numbers); > >- >-static inline int __do_read(int fd, char *buff, size_t len, >- const char *file, int line) >-{ >- int ret = read(fd, buff, len); >- if (ret < 0) { >- die("bad read: %s on line %d of file %s\n", >- strerror(errno), line, file); >- } >- return ret; >-} >- >-#define do_read(fd, buf, len) \ >- __do_read((fd), (buf), (len), __FILE__, __LINE__) >- >-static inline int __do_write(int fd, char *buff, size_t len, >- const char *file, int line) >-{ >- int ret = write(fd, buff, len); >- if (ret != len) { >- die("bad write: %s on line %d of file %s\n", >- strerror(errno), line, file); >- } >- return ret; >-} >- >-#define do_write(fd, buf, len) \ >- __do_write((fd), (buf), (len), __FILE__, __LINE__) >- >-static inline int __do_lseek(int fd, off_t off, const char *file, int line) >-{ >- if (lseek(fd, off, SEEK_SET) != off) { >- die("bad seek: %s on line %d of file %s\n", >- strerror(errno), line, file); >- } >- return 0; >-} >- >-#define do_lseek(fd, off) \ >- __do_lseek((fd), (off), __FILE__, __LINE__) >- > #endif /* __GFS2_QUOTA_DOT_H__ */ >Index: quota/main.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/quota/main.c,v >retrieving revision 1.9 >diff -w -u -p -p -u -r1.9 main.c >--- quota/main.c 11 Oct 2007 20:27:49 -0000 1.9 >+++ quota/main.c 8 Nov 2007 14:57:29 -0000 >@@ -746,24 +746,10 @@ do_get(struct gfs2_sbd *sdp, commandline > static void > do_sync_one(struct gfs2_sbd *sdp, char *filesystem) > { >- int fd; >- char sys_quota_sync[PATH_MAX]; >- >- strcpy(sdp->path_name, filesystem); >- check_for_gfs2(sdp); >- read_superblock(&sdp->sd_sb, sdp); >- sprintf(sys_quota_sync, "%s%s%s", >- "/sys/fs/gfs2/", sdp->sd_sb.sb_locktable, "/quota_sync"); >+ char *fsname; > >- fd = open(sys_quota_sync, O_WRONLY); >- if (fd < 0) >- die("can't open file %s: %s\n", sys_quota_sync, strerror(errno)); >- >- if (write(fd,(void*)"1", 1) != 1) >- die("failed to write to %s: %s\n", >- sys_quota_sync, strerror(errno)); >- >- close(fd); >+ fsname = mp2fsname(filesystem); >+ set_sysfs(fsname, "quota_sync", "1"); > } > > /** >@@ -809,14 +795,14 @@ do_sync(struct gfs2_sbd *sdp, commandlin > static void > do_set(struct gfs2_sbd *sdp, commandline_t *comline) > { >- int fd, fd1; >+ int fd; > uint64_t offset; > uint64_t new_value; > int error, adj_flag = 0;; > char quota_file[BUF_SIZE]; >- char sys_q_refresh[BUF_SIZE]; > char id_str[16]; > struct stat stat_buf; >+ char *fs; > > if (!*comline->filesystem) > die("need a filesystem to work on\n"); >@@ -958,28 +944,11 @@ do_set(struct gfs2_sbd *sdp, commandline > } > } > >- /* Write the id to sysfs quota refresh file to refresh gfs quotas */ >- 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"); >- >- fd1 = open(sys_q_refresh, O_WRONLY); >- if (fd1 < 0) { >- fprintf(stderr, "can't open file %s: %s\n", sys_q_refresh, >- strerror(errno)); >- goto out; >- } >- >+ fs = mp2fsname(comline->filesystem); > sprintf(id_str, "%d", comline->id); >+ set_sysfs(fs, comline->id_type == GQ_ID_USER ? >+ "quota_refresh_user" : "quota_refresh_group", id_str); > >- if (write(fd1,(void*)id_str, strlen(id_str)) != strlen(id_str)) { >- close(fd1); >- fprintf(stderr, "failed to write to %s: %s\n", >- sys_q_refresh, strerror(errno)); >- goto out; >- } >- close(fd1); > if (adj_flag) > adjust_quota_list(fd, comline); > out: >Index: tool/Makefile >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/tool/Makefile,v >retrieving revision 1.14 >diff -w -u -p -p -u -r1.14 Makefile >--- tool/Makefile 25 Oct 2007 14:14:33 -0000 1.14 >+++ tool/Makefile 8 Nov 2007 14:57:29 -0000 >@@ -22,8 +22,7 @@ OBJS= counters.o \ > misc.o \ > ondisk.o \ > sb.o \ >- tune.o \ >- util.o >+ tune.o > > CFLAGS += -D_FILE_OFFSET_BITS=64 > CFLAGS += -I${KERNEL_SRC}/fs/gfs2/ -I${KERNEL_SRC}/include/ >Index: tool/gfs2_tool.h >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/tool/gfs2_tool.h,v >retrieving revision 1.9 >diff -w -u -p -p -u -r1.9 gfs2_tool.h >--- tool/gfs2_tool.h 7 Nov 2007 14:57:59 -0000 1.9 >+++ tool/gfs2_tool.h 8 Nov 2007 14:57:29 -0000 >@@ -15,23 +15,6 @@ > #define __GFS2_TOOL_DOT_H__ > > >-#ifndef TRUE >-#define TRUE (1) >-#endif >- >-#ifndef FALSE >-#define FALSE (0) >-#endif >- >-#define die(fmt, args...) \ >-do { \ >- fprintf(stderr, "%s: ", prog_name); \ >- fprintf(stderr, fmt, ##args); \ >- exit(EXIT_FAILURE); \ >-} while (0) >- >-#define SYS_BASE "/sys/fs/gfs2" >- > extern char *prog_name; > extern char *action; > extern int override; >@@ -90,20 +73,4 @@ void do_sb(int argc, char **argv); > void get_tune(int argc, char **argv); > void set_tune(int argc, char **argv); > >- >-/* From util.c */ >- >-char *get_list(void); >-char **str2lines(char *str); >-char *find_debugfs_mount(void); >-char *mp2fsname(char *mp); >-char *name2value(char *str, char *name); >-uint32_t name2u32(char *str, char *name); >-uint64_t name2u64(char *str, char *name); >-char *__get_sysfs(char *fsname, char *filename); >-char *get_sysfs(char *fsname, char *filename); >-unsigned int get_sysfs_uint(char *fsname, char *filename); >-void set_sysfs(char *fsname, char *filename, char *val); >- >- > #endif /* __GFS2_TOOL_DOT_H__ */ >Index: tool/main.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/tool/main.c,v >retrieving revision 1.7 >diff -w -u -p -p -u -r1.7 main.c >--- tool/main.c 30 Oct 2007 14:06:06 -0000 1.7 >+++ tool/main.c 8 Nov 2007 14:57:29 -0000 >@@ -28,6 +28,7 @@ > #include "copyright.cf" > > #include "gfs2_tool.h" >+#include "libgfs2.h" > > char *prog_name; > char *action = NULL; >Index: tool/sb.c >=================================================================== >RCS file: /cvs/cluster/cluster/gfs2/tool/sb.c,v >retrieving revision 1.3 >diff -w -u -p -p -u -r1.3 sb.c >--- tool/sb.c 18 Jun 2007 21:35:58 -0000 1.3 >+++ tool/sb.c 8 Nov 2007 14:57:29 -0000 >@@ -29,12 +29,7 @@ > #include <linux/gfs2_ondisk.h> > > #include "gfs2_tool.h" >- >-/* From libgfs2 */ >-extern int gfs2_sb_in(struct gfs2_sb *sb, char *buf); >-extern void gfs2_sb_print(struct gfs2_sb *sb); >-extern int gfs2_sb_out(struct gfs2_sb *sb, char *buf); >- >+#include "libgfs2.h" > > void print_it(const char *label, const char *fmt, const char *fmt2, ...) > { >@@ -47,27 +42,6 @@ void print_it(const char *label, const c > va_end(args); > } > >-#define do_lseek(fd, off) \ >-do { \ >- if (lseek((fd), (off), SEEK_SET) != (off)) \ >- die("bad seek: %s on line %d of file %s\n", \ >- strerror(errno),__LINE__, __FILE__); \ >-} while (0) >- >-#define do_read(fd, buff, len) \ >-do { \ >- if (read((fd), (buff), (len)) != (len)) \ >- die("bad read: %s on line %d of file %s\n", \ >- strerror(errno), __LINE__, __FILE__); \ >-} while (0) >- >-#define do_write(fd, buff, len) \ >-do { \ >- if (write((fd), (buff), (len)) != (len)) \ >- die("bad write: %s on line %d of file %s\n", \ >- strerror(errno), __LINE__, __FILE__); \ >-} while (0) >- > /** > * do_sb - examine/modify a unmounted FS' superblock > * @argc:
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 364741
:
251611
|
253041