Skip to contentSkip to conversation

quota-tools: add gfs2 support

PATCH In review Christoph Hellwig 3 participants 4 messages May 4, 2010 – May 7, 2010 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 quota-tools: add gfs2 support

GFS2 implements the XFS interface for setting and reporting the quota information, and only allows state changes via remount.

mntopt.h +1 -0
Index: quota-tools/mntopt.h
===================================================================
@@ -18,6 +18,7 @@
 #define MNTTYPE_NFS4		"nfs4"	/* NFSv4 filesystem */
 #define MNTTYPE_MPFS		"mpfs"  /* EMC Celerra MPFS filesystem */
 #define MNTTYPE_OCFS2		"ocfs2"	/* Oracle Cluster filesystem */
+#define MNTTYPE_GFS2		"gfs2"	/* Red Hat Global filesystem 2 */
 
 /* mount options */
 #define MNTOPT_NOQUOTA		"noquota"	/* don't enforce quota */
quotacheck.c +3 -1
Index: quota-tools/quotacheck.c
===================================================================
@@ -1049,7 +1049,9 @@ static void check_all(void)
 	while ((mnt = get_next_mount())) {
 		if (flags & FL_ALL && flags & FL_NOROOT && !strcmp(mnt->mnt_dir, "/"))
 			continue;
-		if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) || nfs_fstype(mnt->mnt_type) ||
+		if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+		    !strcmp(mnt->mnt_type, MNTTYPE_GFS2) ||
+		    nfs_fstype(mnt->mnt_type) ||
 		    meta_qf_fstype(mnt->mnt_type)) {
 			debug(FL_DEBUG | FL_VERBOSE, _("Skipping %s [%s]\n"), mnt->mnt_fsname, mnt->mnt_dir);
 			continue;
quotaio.c +2 -1
Index: quota-tools/quotaio.c
===================================================================
@@ -78,7 +78,8 @@ struct quota_handle *init_io(struct mnte
 		goto out_handle;
 	}
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem? */
+	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||	/* XFS filesystem? */
+	    !strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {	/* XFS filesystem? */
 		if (fmt != -1 && fmt != QF_XFS) {	/* User wanted some other format? */
 			errstr(_("Only XFS quota format is allowed on XFS filesystem.\n"));
 			goto out_handle;
quotaon.c +6 -2
Index: quota-tools/quotaon.c
===================================================================
@@ -273,7 +273,10 @@ static int newstate(struct mntent *mnt,
 	if (flags & FL_ALL)
 		sflags |= STATEFLAG_ALL;
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem has special handling... */
+	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {
+		errstr(_("Cannot change state of GFS2 quota.\n"));
+		return 1;
+	} else if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem has special handling... */
 		if (!kern_qfmt_supp(QF_XFS)) {
 			errstr(_("Cannot change state of XFS quota. It's not compiled in kernel.\n"));
 			return 1;
@@ -329,7 +332,8 @@ static int print_state(struct mntent *mn
 {
 	int on = 0;
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {
+	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+	    !strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {
 		if (kern_qfmt_supp(QF_XFS))
 			on = kern_quota_on(mnt->mnt_fsname, type, QF_XFS) != -1;
 	}
quotasys.c +9 -3
Index: quota-tools/quotasys.c
===================================================================
@@ -91,7 +91,8 @@ static int correct_fstype(char *type)
 		    !strcmp(type, MNTTYPE_NFS) ||
 		    !strcmp(type, MNTTYPE_NFS4) ||
 		    !strcmp(type, MNTTYPE_OCFS2) ||
-		    !strcmp(type, MNTTYPE_MPFS)) {
+		    !strcmp(type, MNTTYPE_MPFS) ||
+		    !strcmp(type, MNTTYPE_GFS2)) {
 			free(mtype);
 			return 1;
 		}
@@ -495,6 +496,8 @@ int hasquota(struct mntent *mnt, int typ
 	if (!correct_fstype(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA))
 		return 0;
 	
+	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2))
+		return 1;
 	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS))
 		return hasxfsquota(mnt, type, flags);
 	if (nfs_fstype(mnt->mnt_type))	/* NFS always has quota or better there is no good way how to detect it */
@@ -652,11 +655,14 @@ add_entry:
 					goto add_entry;
 				break;
 			case QF_XFS:
-				if (!strcmp(mnt->mnt_type, MNTTYPE_XFS))
+				if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+				    !strcmp(mnt->mnt_type, MNTTYPE_GFS2))
 					goto add_entry;
 				break;
 			default:
-				if (strcmp(mnt->mnt_type, MNTTYPE_XFS) && !nfs_fstype(mnt->mnt_type))
+				if (strcmp(mnt->mnt_type, MNTTYPE_XFS) &&
+				    strcmp(mnt->mnt_type, MNTTYPE_GFS2) &&
+				    !nfs_fstype(mnt->mnt_type))
 					goto add_entry;
 				break;
 			}
#1 lore raw

Hi,

It works for me. Thanks for sorting this out,

Steve.

Quoted 116 lines · Christoph Hellwig

GFS2 implements the XFS interface for setting and reporting the quota information, and only allows state changes via remount.

Index: quota-tools/mntopt.h
===================================================================

mntopt.h +1 -0
@@ -18,6 +18,7 @@
 #define MNTTYPE_NFS4		"nfs4"	/* NFSv4 filesystem */
 #define MNTTYPE_MPFS		"mpfs"  /* EMC Celerra MPFS filesystem */
 #define MNTTYPE_OCFS2		"ocfs2"	/* Oracle Cluster filesystem */
+#define MNTTYPE_GFS2		"gfs2"	/* Red Hat Global filesystem 2 */
 
 /* mount options */
 #define MNTOPT_NOQUOTA		"noquota"	/* don't enforce quota */

Index: quota-tools/quotacheck.c
===================================================================

quotacheck.c +3 -1
@@ -1049,7 +1049,9 @@ static void check_all(void)
 	while ((mnt = get_next_mount())) {
 		if (flags & FL_ALL && flags & FL_NOROOT && !strcmp(mnt->mnt_dir, "/"))
 			continue;
-		if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) || nfs_fstype(mnt->mnt_type) ||
+		if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+		    !strcmp(mnt->mnt_type, MNTTYPE_GFS2) ||
+		    nfs_fstype(mnt->mnt_type) ||
 		    meta_qf_fstype(mnt->mnt_type)) {
 			debug(FL_DEBUG | FL_VERBOSE, _("Skipping %s [%s]\n"), mnt->mnt_fsname, mnt->mnt_dir);
 			continue;

Index: quota-tools/quotaio.c
===================================================================

quotaio.c +2 -1
@@ -78,7 +78,8 @@ struct quota_handle *init_io(struct mnte
 		goto out_handle;
 	}
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem? */
+	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||	/* XFS filesystem? */
+	    !strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {	/* XFS filesystem? */
 		if (fmt != -1 && fmt != QF_XFS) {	/* User wanted some other format? */
 			errstr(_("Only XFS quota format is allowed on XFS filesystem.\n"));
 			goto out_handle;

Index: quota-tools/quotaon.c
===================================================================

quotaon.c +6 -2
@@ -273,7 +273,10 @@ static int newstate(struct mntent *mnt,
 	if (flags & FL_ALL)
 		sflags |= STATEFLAG_ALL;
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem has special handling... */
+	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {
+		errstr(_("Cannot change state of GFS2 quota.\n"));
+		return 1;
+	} else if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem has special handling... */
 		if (!kern_qfmt_supp(QF_XFS)) {
 			errstr(_("Cannot change state of XFS quota. It's not compiled in kernel.\n"));
 			return 1;
@@ -329,7 +332,8 @@ static int print_state(struct mntent *mn
 {
 	int on = 0;
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {
+	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+	    !strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {
 		if (kern_qfmt_supp(QF_XFS))
 			on = kern_quota_on(mnt->mnt_fsname, type, QF_XFS) != -1;
 	}

Index: quota-tools/quotasys.c
===================================================================

quotasys.c +9 -4
@@ -91,7 +91,8 @@ static int correct_fstype(char *type)
 		    !strcmp(type, MNTTYPE_NFS) ||
 		    !strcmp(type, MNTTYPE_NFS4) ||
 		    !strcmp(type, MNTTYPE_OCFS2) ||
-		    !strcmp(type, MNTTYPE_MPFS)) {
+		    !strcmp(type, MNTTYPE_MPFS) ||
+		    !strcmp(type, MNTTYPE_GFS2)) {
 			free(mtype);
 			return 1;
 		}
@@ -495,6 +496,8 @@ int hasquota(struct mntent *mnt, int typ
 	if (!correct_fstype(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA))
 		return 0;
 
+	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2))
+		return 1;
 	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS))
 		return hasxfsquota(mnt, type, flags);
 	if (nfs_fstype(mnt->mnt_type))	/* NFS always has quota or better there is no good way how to detect it */
@@ -652,11 +655,14 @@ add_entry:
 					goto add_entry;
 				break;
 			case QF_XFS:
-				if (!strcmp(mnt->mnt_type, MNTTYPE_XFS))
+				if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+				    !strcmp(mnt->mnt_type, MNTTYPE_GFS2))
 					goto add_entry;
 				break;
 			default:
-				if (strcmp(mnt->mnt_type, MNTTYPE_XFS) && !nfs_fstype(mnt->mnt_type))
+				if (strcmp(mnt->mnt_type, MNTTYPE_XFS) &&
+				    strcmp(mnt->mnt_type, MNTTYPE_GFS2) &&
+				    !nfs_fstype(mnt->mnt_type))
 					goto add_entry;
 				break;
 			}
--

To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo

reviewer
#2 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

GFS2 implements the XFS interface for setting and reporting the quota information, and only allows state changes via remount.

Thanks. I've committed the patch to quota-tools repository.

Honza

Quoted 108 lines

Index: quota-tools/mntopt.h
===================================================================

mntopt.h +1 -0
@@ -18,6 +18,7 @@
 #define MNTTYPE_NFS4		"nfs4"	/* NFSv4 filesystem */
 #define MNTTYPE_MPFS		"mpfs"  /* EMC Celerra MPFS filesystem */
 #define MNTTYPE_OCFS2		"ocfs2"	/* Oracle Cluster filesystem */
+#define MNTTYPE_GFS2		"gfs2"	/* Red Hat Global filesystem 2 */
 
 /* mount options */
 #define MNTOPT_NOQUOTA		"noquota"	/* don't enforce quota */

Index: quota-tools/quotacheck.c
===================================================================

quotacheck.c +3 -1
@@ -1049,7 +1049,9 @@ static void check_all(void)
 	while ((mnt = get_next_mount())) {
 		if (flags & FL_ALL && flags & FL_NOROOT && !strcmp(mnt->mnt_dir, "/"))
 			continue;
-		if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) || nfs_fstype(mnt->mnt_type) ||
+		if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+		    !strcmp(mnt->mnt_type, MNTTYPE_GFS2) ||
+		    nfs_fstype(mnt->mnt_type) ||
 		    meta_qf_fstype(mnt->mnt_type)) {
 			debug(FL_DEBUG | FL_VERBOSE, _("Skipping %s [%s]\n"), mnt->mnt_fsname, mnt->mnt_dir);
 			continue;

Index: quota-tools/quotaio.c
===================================================================

quotaio.c +2 -1
@@ -78,7 +78,8 @@ struct quota_handle *init_io(struct mnte
 		goto out_handle;
 	}
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem? */
+	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||	/* XFS filesystem? */
+	    !strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {	/* XFS filesystem? */
 		if (fmt != -1 && fmt != QF_XFS) {	/* User wanted some other format? */
 			errstr(_("Only XFS quota format is allowed on XFS filesystem.\n"));
 			goto out_handle;

Index: quota-tools/quotaon.c
===================================================================

quotaon.c +6 -2
@@ -273,7 +273,10 @@ static int newstate(struct mntent *mnt,
 	if (flags & FL_ALL)
 		sflags |= STATEFLAG_ALL;
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem has special handling... */
+	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {
+		errstr(_("Cannot change state of GFS2 quota.\n"));
+		return 1;
+	} else if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {	/* XFS filesystem has special handling... */
 		if (!kern_qfmt_supp(QF_XFS)) {
 			errstr(_("Cannot change state of XFS quota. It's not compiled in kernel.\n"));
 			return 1;
@@ -329,7 +332,8 @@ static int print_state(struct mntent *mn
 {
 	int on = 0;
 
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) {
+	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+	    !strcmp(mnt->mnt_type, MNTTYPE_GFS2)) {
 		if (kern_qfmt_supp(QF_XFS))
 			on = kern_quota_on(mnt->mnt_fsname, type, QF_XFS) != -1;
 	}

Index: quota-tools/quotasys.c
===================================================================

quotasys.c +9 -3
@@ -91,7 +91,8 @@ static int correct_fstype(char *type)
 		    !strcmp(type, MNTTYPE_NFS) ||
 		    !strcmp(type, MNTTYPE_NFS4) ||
 		    !strcmp(type, MNTTYPE_OCFS2) ||
-		    !strcmp(type, MNTTYPE_MPFS)) {
+		    !strcmp(type, MNTTYPE_MPFS) ||
+		    !strcmp(type, MNTTYPE_GFS2)) {
 			free(mtype);
 			return 1;
 		}
@@ -495,6 +496,8 @@ int hasquota(struct mntent *mnt, int typ
 	if (!correct_fstype(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA))
 		return 0;
 
+	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2))
+		return 1;
 	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS))
 		return hasxfsquota(mnt, type, flags);
 	if (nfs_fstype(mnt->mnt_type))	/* NFS always has quota or better there is no good way how to detect it */
@@ -652,11 +655,14 @@ add_entry:
 					goto add_entry;
 				break;
 			case QF_XFS:
-				if (!strcmp(mnt->mnt_type, MNTTYPE_XFS))
+				if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) ||
+				    !strcmp(mnt->mnt_type, MNTTYPE_GFS2))
 					goto add_entry;
 				break;
 			default:
-				if (strcmp(mnt->mnt_type, MNTTYPE_XFS) && !nfs_fstype(mnt->mnt_type))
+				if (strcmp(mnt->mnt_type, MNTTYPE_XFS) &&
+				    strcmp(mnt->mnt_type, MNTTYPE_GFS2) &&
+				    !nfs_fstype(mnt->mnt_type))
 					goto add_entry;
 				break;
 			}
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#3 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

GFS2 implements the XFS interface for setting and reporting the quota information, and only allows state changes via remount.

Sorry this patch was missing a hunk I added later after researching it. The patch I sent works as-is, but if you want to avoid possibly strange errors with GFS2 filesystems mounted without quota support your want this tiny patch on top:

quotasys.c +2 -3
Index: quota-tools/quotasys.c
===================================================================
@@ -496,9 +496,8 @@ int hasquota(struct mntent *mnt, int typ
 	if (!correct_fstype(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA))
 		return 0;
 	
-	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2))
-		return 1;
-	if (!strcmp(mnt->mnt_type, MNTTYPE_XFS))
+	if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2) ||
+	    !strcmp(mnt->mnt_type, MNTTYPE_XFS))
 		return hasxfsquota(mnt, type, flags);
 	if (nfs_fstype(mnt->mnt_type))	/* NFS always has quota or better there is no good way how to detect it */
 		return 1;