Skip to contentSkip to conversation

GFS2: A quota of quota patches

Cluster-devel New Steven Whitehouse 2 participants 7 messages Sep 14, 2009 GFS2 file system

lore
Share & tools
lore
#0 lore raw

This set of patches is a start towards the overall goal of making the GFS2 quota system accessible via a generic interface. In this case I've chosen the XFS style quota interface because it is closer to GFS2's existing quota system in terms of features.

This patch set only makes a couple of operations accessible via this new API. It will now be possible to do a quota sync and also to query the current state of the quota subsytem via the XFS API. There are one or two features which GFS2 doesn't support (such as separate quota files for user and group quotas) which result in the same information being returned to the user in both cases. I don't think this matters too much as it should be obvious from the inode number that it is the same inode.

The long term objective is to make enough of the quota operations available via this API that we can close the bug (#298561) relating to lack of quota management for GFS2 via NFS. Also we hope to add support for netlink notification of quota events too (bug #337691).

We have no plans to support the "project" feature of XFS quotas. We might however split the on/off/account settings so that it is possible to specify them separately for user and group quotas.

My plan is that these pactches should go into the -nmw git tree early in the next cycle, but in the mean time, here is a "heads up",

Steve.

#1 lore raw
Quoted 5 lines · Steven Whitehouse

This set of patches is a start towards the overall goal of making the GFS2 quota system accessible via a generic interface. In this case I've chosen the XFS style quota interface because it is closer to GFS2's existing quota system in terms of features.

- SNIP -

does this mean we need to sync a userland release with a kernel one?

If this is the case, then please let?s coordinate the landing of the changes in STABLE3 release together with the new kernel release with this new quota code.

Fabio

#2 lore raw

Hi,

Quoted 11 lines · Fabio Massimo Di Nitto
Quoted 5 lines · Steven Whitehouse

This set of patches is a start towards the overall goal of making the GFS2 quota system accessible via a generic interface. In this case I've chosen the XFS style quota interface because it is closer to GFS2's existing quota system in terms of features.

- SNIP -

does this mean we need to sync a userland release with a kernel one?

No. There are no required userland changes, and the current quota interface will be around for a good while yet,

Steve.

Quoted 5 lines

If this is the case, then please let?s coordinate the landing of the changes in STABLE3 release together with the new kernel release with this new quota code.

Fabio

#3 lore raw

PATCH 1/4 GFS2: Alter arguments of gfs2_quota/statfs_sync

In reply to Steven Whitehouse

These two functions are altered so that gfs2_quota_sync may in future be called directly from the VFS. The GFS2 superblock changes to a VFS super block and there is an addition of an int argument which is currently ignored.

---
 fs/gfs2/quota.c |    7 ++++---
 fs/gfs2/quota.h |    2 +-
 fs/gfs2/super.c |    7 ++++---
 fs/gfs2/super.h |    2 +-
 fs/gfs2/sys.c   |    4 ++--
 5 files changed, 12 insertions(+), 10 deletions(-)
fs/gfs2/quota.c +4 -3
index 2e9b932..ed9e197 100644
@@ -1069,8 +1069,9 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
 	}
 }
 
-int gfs2_quota_sync(struct gfs2_sbd *sdp)
+int gfs2_quota_sync(struct super_block *sb, int type)
 {
+	struct gfs2_sbd *sdp = sb->s_fs_info;
 	struct gfs2_quota_data **qda;
 	unsigned int max_qd = gfs2_tune_get(sdp, gt_quota_simul_sync);
 	unsigned int num_qd;
@@ -1298,12 +1299,12 @@ static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error)
 }
 
 static void quotad_check_timeo(struct gfs2_sbd *sdp, const char *msg,
-			       int (*fxn)(struct gfs2_sbd *sdp),
+			       int (*fxn)(struct super_block *sb, int type),
 			       unsigned long t, unsigned long *timeo,
 			       unsigned int *new_timeo)
 {
 	if (t >= *timeo) {
-		int error = fxn(sdp);
+		int error = fxn(sdp->sd_vfs, 0);
 		quotad_error(sdp, msg, error);
 		*timeo = gfs2_tune_get_i(&sdp->sd_tune, new_timeo) * HZ;
 	} else {
fs/gfs2/quota.h +1 -1
index 0fa5fa6..437afa7 100644
@@ -25,7 +25,7 @@ extern int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid);
 extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
 			      u32 uid, u32 gid);
 
-extern int gfs2_quota_sync(struct gfs2_sbd *sdp);
+extern int gfs2_quota_sync(struct super_block *sb, int type);
 extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id);
 
 extern int gfs2_quota_init(struct gfs2_sbd *sdp);
fs/gfs2/super.c +4 -3
index f522bb0..47f7373 100644
@@ -464,8 +464,9 @@ void update_statfs(struct gfs2_sbd *sdp, struct buffer_head *m_bh,
 	gfs2_statfs_change_out(m_sc, m_bh->b_data + sizeof(struct gfs2_dinode));
 }
 
-int gfs2_statfs_sync(struct gfs2_sbd *sdp)
+int gfs2_statfs_sync(struct super_block *sb, int type)
 {
+	struct gfs2_sbd *sdp = sb->s_fs_info;
 	struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
 	struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
 	struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
@@ -692,8 +693,8 @@ static int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
 	int error;
 
 	flush_workqueue(gfs2_delete_workqueue);
-	gfs2_quota_sync(sdp);
-	gfs2_statfs_sync(sdp);
+	gfs2_quota_sync(sdp->sd_vfs, 0);
+	gfs2_statfs_sync(sdp->sd_vfs, 0);
 
 	error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, GL_NOCACHE,
 				   &t_gh);
fs/gfs2/super.h +1 -1
index 22e0417..70ed1ad 100644
@@ -44,7 +44,7 @@ extern void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc,
 				  const void *buf);
 extern void update_statfs(struct gfs2_sbd *sdp, struct buffer_head *m_bh,
 			  struct buffer_head *l_bh);
-extern int gfs2_statfs_sync(struct gfs2_sbd *sdp);
+extern int gfs2_statfs_sync(struct super_block *sb, int type);
 
 extern int gfs2_freeze_fs(struct gfs2_sbd *sdp);
 extern void gfs2_unfreeze_fs(struct gfs2_sbd *sdp);
fs/gfs2/sys.c +2 -2
index a7cbfbd..898f944 100644
@@ -157,7 +157,7 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 	if (simple_strtol(buf, NULL, 0) != 1)
 		return -EINVAL;
 
-	gfs2_statfs_sync(sdp);
+	gfs2_statfs_sync(sdp->sd_vfs, 0);
 	return len;
 }
 
@@ -170,7 +170,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
 	if (simple_strtol(buf, NULL, 0) != 1)
 		return -EINVAL;
 
-	gfs2_quota_sync(sdp);
+	gfs2_quota_sync(sdp->sd_vfs, 0);
 	return len;
 }
 
Signature · 1 line
1.6.2.5
#4 lore raw

PATCH 2/4 GFS2: Hook gfs2_quota_sync into VFS via gfs2_quotactl_ops

The plan is to add further operations to the gfs2_quotactl_ops in future patches. The sync operation is easy, so we start with that one.

We plan to use the XFS quota control functions because they more closely match the GFS2 ones.

---
 fs/gfs2/Kconfig      |    2 ++
 fs/gfs2/ops_fstype.c |    3 +++
 fs/gfs2/quota.c      |    4 ++++
 fs/gfs2/quota.h      |    1 +
 4 files changed, 10 insertions(+), 0 deletions(-)
fs/gfs2/Kconfig +2 -0
index 5971359..4dcddf8 100644
@@ -8,6 +8,8 @@ config GFS2_FS
 	select FS_POSIX_ACL
 	select CRC32
 	select SLOW_WORK
+	select QUOTA
+	select QUOTACTL
 	help
 	  A cluster filesystem.
 
fs/gfs2/ops_fstype.c +3 -0
index 7bc3c45..c22531a 100644
@@ -18,6 +18,7 @@
 #include <linux/mount.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/slow-work.h>
+#include <linux/quotaops.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -1174,6 +1175,8 @@ static int fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_magic = GFS2_MAGIC;
 	sb->s_op = &gfs2_super_ops;
 	sb->s_export_op = &gfs2_export_ops;
+	sb->s_qcop = &gfs2_quotactl_ops;
+	sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
 	sb->s_time_gran = 1;
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 
fs/gfs2/quota.c +4 -0
index ed9e197..73a43ce 100644
@@ -1378,3 +1378,7 @@ int gfs2_quotad(void *data)
 	return 0;
 }
 
+const struct quotactl_ops gfs2_quotactl_ops = {
+	.quota_sync     = gfs2_quota_sync,
+};
+
fs/gfs2/quota.h +1 -0
index 437afa7..025d15b 100644
@@ -50,5 +50,6 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip)
 }
 
 extern int gfs2_shrink_qd_memory(int nr, gfp_t gfp_mask);
+extern const struct quotactl_ops gfs2_quotactl_ops;
 
 #endif /* __QUOTA_DOT_H__ */
Signature · 1 line
1.6.2.5
#5 lore raw

PATCH 3/4 GFS2: Remove obsolete code in quota.c

There is no point in testing for GLF_DEMOTE here, we might as well always release the glock at that point.

---
 fs/gfs2/glock.h |    9 ---------
 fs/gfs2/quota.c |   13 +++++--------
 2 files changed, 5 insertions(+), 17 deletions(-)
fs/gfs2/glock.h +0 -9
index c609894..13f0bd2 100644
@@ -180,15 +180,6 @@ static inline int gfs2_glock_is_held_shrd(struct gfs2_glock *gl)
 	return gl->gl_state == LM_ST_SHARED;
 }
 
-static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl)
-{
-	int ret;
-	spin_lock(&gl->gl_spin);
-	ret = test_bit(GLF_DEMOTE, &gl->gl_flags);
-	spin_unlock(&gl->gl_spin);
-	return ret;
-}
-
 int gfs2_glock_get(struct gfs2_sbd *sdp,
 		   u64 number, const struct gfs2_glock_operations *glops,
 		   int create, struct gfs2_glock **glp);
fs/gfs2/quota.c +5 -8
index 73a43ce..6aaa6c5 100644
@@ -843,9 +843,8 @@ restart:
 	if (force_refresh || qd->qd_qb.qb_magic != cpu_to_be32(GFS2_MAGIC)) {
 		loff_t pos;
 		gfs2_glock_dq_uninit(q_gh);
-		error = gfs2_glock_nq_init(qd->qd_gl,
-					   LM_ST_EXCLUSIVE, GL_NOCACHE,
-					   q_gh);
+		error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_EXCLUSIVE,
+					   GL_NOCACHE, q_gh);
 		if (error)
 			return error;
 
@@ -871,11 +870,9 @@ restart:
 		qlvb->qb_value = cpu_to_be64(q.qu_value);
 		qd->qd_qb = *qlvb;
 
-		if (gfs2_glock_is_blocking(qd->qd_gl)) {
-			gfs2_glock_dq_uninit(q_gh);
-			force_refresh = 0;
-			goto restart;
-		}
+		gfs2_glock_dq_uninit(q_gh);
+		force_refresh = 0;
+		goto restart;
 	}
 
 	return 0;
Signature · 1 line
1.6.2.5
#6 lore raw

PATCH 4/4 GFS2: Add get_xstate quota function

This allows querying of the quota state via the XFS quota API.

---
 fs/gfs2/quota.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
fs/gfs2/quota.c +23 -0
index 6aaa6c5..e7114be 100644
@@ -47,6 +47,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/kthread.h>
 #include <linux/freezer.h>
+#include <linux/dqblk_xfs.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -1375,7 +1376,29 @@ int gfs2_quotad(void *data)
 	return 0;
 }
 
+static int gfs2_quota_get_xstate(struct super_block *sb,
+				 struct fs_quota_stat *fqs)
+{
+	struct gfs2_sbd *sdp = sb->s_fs_info;
+
+	memset(fqs, 0, sizeof(struct fs_quota_stat));
+	fqs->qs_version = FS_QSTAT_VERSION;
+	if (sdp->sd_args.ar_quota == GFS2_QUOTA_ON)
+		fqs->qs_flags = (XFS_QUOTA_UDQ_ENFD | XFS_QUOTA_GDQ_ENFD);
+	else if (sdp->sd_args.ar_quota == GFS2_QUOTA_ACCOUNT)
+		fqs->qs_flags = (XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_GDQ_ACCT);
+	if (sdp->sd_quota_inode) {
+		fqs->qs_uquota.qfs_ino = GFS2_I(sdp->sd_quota_inode)->i_no_addr;
+		fqs->qs_uquota.qfs_nblks = sdp->sd_quota_inode->i_blocks;
+	}
+	fqs->qs_uquota.qfs_nextents = 1; /* unsupported */
+	fqs->qs_gquota = fqs->qs_uquota; /* its the same inode in both cases */
+	fqs->qs_incoredqs = atomic_read(&qd_lru_count);
+	return 0;
+}
+
 const struct quotactl_ops gfs2_quotactl_ops = {
 	.quota_sync     = gfs2_quota_sync,
+	.get_xstate     = gfs2_quota_get_xstate,
 };
 
Signature · 1 line
1.6.2.5