Skip to contentSkip to conversation

cluster/gfs2 edit/hexedit.h fsck/initialize.c ...

Cluster-devel [email protected] 1 participant 1 message Nov 13, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: rpeterso at sourceware.org 2007-11-13 17:06:33

Modified files:

	gfs2/edit      : hexedit.h 
	gfs2/fsck      : initialize.c util.h 
	gfs2/libgfs2   : buf.c libgfs2.h misc.c 
	gfs2/mkfs      : gfs2_mkfs.h 
	gfs2/quota     : check.c gfs2_quota.h main.c 
	gfs2/tool      : Makefile gfs2_tool.h main.c sb.c 

Removed files:
gfs2/tool : util.c

Log message:
Resolves: bz 364741: GFS2: gfs2_quota doesn't work unless lock table specified

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.4&r2=1.4.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/initialize.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6.2.4&r2=1.6.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/util.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2&r2=1.2.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/buf.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/libgfs2.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7.2.14&r2=1.7.2.15
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/misc.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.3&r2=1.2.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mkfs/gfs2_mkfs.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.9&r2=1.9.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/check.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.4&r2=1.2.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/gfs2_quota.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.4&r2=1.1.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.6&r2=1.2.2.7
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.1&r2=1.5.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/gfs2_tool.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.4&r2=1.5.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.2&r2=1.4.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/sb.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.1&r2=1.2.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/tool/util.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.3&r2=NONE

gfs2/edit/hexedit.h +0 -25
@@ -178,31 +178,6 @@
 #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) \
gfs2/fsck/initialize.c +1 -1
@@ -169,7 +169,7 @@
 	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;
gfs2/fsck/util.h +1 -8
@@ -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);
gfs2/libgfs2/buf.c +6 -27
@@ -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 @@
 	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 @@
 	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 @@
 		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 */
 		}
 	}
gfs2/libgfs2/libgfs2.h +37 -0
@@ -40,6 +40,27 @@
 	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 @@
 	       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 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);
gfs2/libgfs2/misc.c +435 -0

447 lines not on this page · raw message

gfs2/mkfs/gfs2_mkfs.h +0 -40
@@ -35,46 +35,6 @@
 /* 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 
gfs2/quota/check.c +5 -22
@@ -455,15 +455,15 @@
 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,10 @@
 		}
 
 		/* 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, (user) ? "quota_refresh_user" :
+			  "quota_refresh_group", id_str);
 	}
 
 out:
gfs2/quota/gfs2_quota.h +0 -56

66 lines not on this page · raw message

gfs2/quota/main.c +8 -39

74 lines not on this page · raw message

gfs2/tool/Makefile +1 -1
@@ -30,7 +30,7 @@
 
 .PHONY: all clean distclean
 
-SOURCES= counters.c df.c layout.c main.c misc.c ondisk.c sb.c tune.c util.c
+SOURCES= counters.c df.c layout.c main.c misc.c ondisk.c sb.c tune.c
 
 OBJECTS=$(subst .c,.o,${SOURCES})
 
gfs2/tool/gfs2_tool.h +0 -33
@@ -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 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__ */
gfs2/tool/main.c +1 -0
@@ -28,6 +28,7 @@
 #include "copyright.cf"
 
 #include "gfs2_tool.h"
+#include "libgfs2.h"
 
 char *prog_name;
 char *action = NULL;
gfs2/tool/sb.c +1 -27
@@ -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 @@
 	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: