Skip to contentSkip to conversation

cluster/gfs2 libgfs2/ondisk.c quota/check.c qu ...

Cluster-devel [email protected] 1 participant 1 message Aug 24, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: adas at sourceware.org 2007-08-24 06:08:26

Modified files:
gfs2/libgfs2 : ondisk.c
gfs2/quota : check.c gfs2_quota.h main.c

Log message:
fix for bz253016: userland fixes for gfs2 quota linked list

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/ondisk.c.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/check.c.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/gfs2_quota.h.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/quota/main.c.diff?cvsroot=cluster&r1=1.7&r2=1.8

gfs2/libgfs2/ondisk.c +4 -1
@@ -252,6 +252,8 @@
 	CPIN_64(qu, str, qu_limit);
 	CPIN_64(qu, str, qu_warn);
 	CPIN_64(qu, str, qu_value);
+	CPIN_32(qu, str, qu_ll_next);
+	CPIN_08(qu, str, qu_reserved, 60);
 }
 
 void gfs2_quota_out(struct gfs2_quota *qu, char *buf)
@@ -261,7 +263,8 @@
 	CPOUT_64(qu, str, qu_limit);
 	CPOUT_64(qu, str, qu_warn);
 	CPOUT_64(qu, str, qu_value);
-	memset(qu->qu_reserved, 0, sizeof(qu->qu_reserved));
+	CPOUT_32(qu, str, qu_ll_next);
+	CPOUT_08(qu, str, qu_reserved, 60);
 }
 
 void gfs2_quota_print(struct gfs2_quota *qu)
gfs2/quota/check.c +30 -2
@@ -187,8 +187,8 @@
 	char buf[sizeof(struct gfs2_quota)];
 	struct gfs2_quota q;
 	uint64_t offset = 0;
-	uint32_t id;
-	int error;
+	uint32_t id, prev, maxid;
+	int error, pass, id_type;
 	char quota_file[BUF_SIZE];
 	
 	strcpy(sdp->path_name, comline->filesystem);
@@ -209,6 +209,33 @@
 		    strerror(errno));
 	}
 
+	if (!is_valid_quota_list(fd)) {
+		print_quota_list_warning();
+		goto do_old_school;
+	}
+	get_last_quota_id(fd, &maxid);
+	
+	for (pass=0; pass<2; pass++) {
+		id = 0;
+		id_type = pass ? GQ_ID_GROUP : GQ_ID_USER;
+		
+		do {
+			read_quota_internal(fd, id, id_type, &q);
+			prev = id;
+			q.qu_value <<= sdp->sd_sb.sb_bsize_shift - 9;
+			
+			if (q.qu_value) {
+				if (pass)
+					add_value(gid, id, q.qu_value);
+				else
+					add_value(uid, id, q.qu_value);
+			}
+			id = q.qu_ll_next;
+		} while(id && id > prev && id <= maxid);
+	}
+	goto out;
+	
+do_old_school:
 	do {
 		
 		memset(buf, 0, sizeof(struct gfs2_quota));
@@ -237,6 +264,7 @@
 		offset += sizeof(struct gfs2_quota);
 	} while (error == sizeof(struct gfs2_quota));
 
+out:
 	close(fd);
 	close(sdp->metafs_fd);
 	cleanup_metafs(sdp);
gfs2/quota/gfs2_quota.h +8 -0
@@ -58,6 +58,7 @@
 #define GQ_OP_WARN           (16)
 #define GQ_OP_CHECK          (17)
 #define GQ_OP_INIT           (18)
+#define GQ_OP_RESET           (19)
 
 #define GQ_ID_USER           (23)
 #define GQ_ID_GROUP          (24)
@@ -97,6 +98,13 @@
 void mount_gfs2_meta();
 void cleanup();
 void read_superblock(struct gfs2_sb *sb, struct gfs2_sbd *sdp);
+void get_last_quota_id(int fd, uint32_t *max_id);
+int is_valid_quota_list(int fd);
+inline void read_quota_internal(int fd, unsigned int id, int id_type, 
+				struct gfs2_quota *q);
+inline void write_quota_internal(int fd, unsigned int id, int id_type, 
+				 struct gfs2_quota *q);
+void print_quota_list_warning();
 
 /*  check.c  */
 
gfs2/quota/main.c +283 -4

374 lines not on this page · raw message