All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] VFS: Export dquot_send_warning
@ 2009-09-23 12:25 Steven Whitehouse
  2009-09-26 16:29 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Whitehouse @ 2009-09-23 12:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: Al Viro, Christoph Hellwig

Hi,

It would be useful to have a generic method of sending quota messages
to userspace. The dquot code has such a method, but it can only currently
be used by that code, so I'm wondering whether there would be any objections
to exporting it so that other (non-dquot) filesystems could use it?

My proposed (first draft) patch is below,

Steve.

------------------------------------------------------------------------
>From 77e4ac5ef6311073e59e6abb34e0ff53df684bd2 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho@redhat.com>
Date: Wed, 16 Sep 2009 18:16:11 +0100
Subject: VFS: Export dquot_send_warning

Sending a message to userspace in a generic format to warn
of events (e.g. quota exceeded) in the quota subsystem is
a generically useful feature. This patch makes some minor
changes to the send_message function in dquot.c renaming
it dquot_send_message and exporting it for use by filesystems
which do not use the dquot quota code.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
 fs/quota/dquot.c      |   45 ++++++++++++++++++++++++++++++---------------
 include/linux/quota.h |   11 +++++++++++
 2 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 38f7bd5..4ced204 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1082,8 +1082,21 @@ static struct genl_family quota_genl_family = {
 	.maxattr = QUOTA_NL_A_MAX,
 };
 
-/* Send warning to userspace about user which exceeded quota */
-static void send_warning(const struct dquot *dquot, const char warntype)
+/**
+ * dquot_send_warning - Send warning to userspace about exceeded quota
+ * @type: The quota type: USRQQUOTA, GRPQUOTA,...
+ * @id: The user or group id of the quota that was exceeded
+ * @dev: The device on which the fs is mounted (sb->s_dev)
+ * @warntype: The type of the warning: QUOTA_NL_...
+ *
+ * This can be used by filesystems (including those which don't use
+ * other parts of dquot) to send a message to userspace relating to
+ * quota limits.
+ *
+ */
+
+void dquot_send_warning(short type, unsigned int id, dev_t dev,
+			const char warntype)
 {
 	static atomic_t seq;
 	struct sk_buff *skb;
@@ -1108,21 +1121,19 @@ static void send_warning(const struct dquot *dquot, const char warntype)
 		  "VFS: Cannot store netlink header in quota warning.\n");
 		goto err_out;
 	}
-	ret = nla_put_u32(skb, QUOTA_NL_A_QTYPE, dquot->dq_type);
+	ret = nla_put_u32(skb, QUOTA_NL_A_QTYPE, type);
 	if (ret)
 		goto attr_err_out;
-	ret = nla_put_u64(skb, QUOTA_NL_A_EXCESS_ID, dquot->dq_id);
+	ret = nla_put_u64(skb, QUOTA_NL_A_EXCESS_ID, id);
 	if (ret)
 		goto attr_err_out;
 	ret = nla_put_u32(skb, QUOTA_NL_A_WARNING, warntype);
 	if (ret)
 		goto attr_err_out;
-	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MAJOR,
-		MAJOR(dquot->dq_sb->s_dev));
+	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MAJOR, MAJOR(dev));
 	if (ret)
 		goto attr_err_out;
-	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MINOR,
-		MINOR(dquot->dq_sb->s_dev));
+	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MINOR, MINOR(dev));
 	if (ret)
 		goto attr_err_out;
 	ret = nla_put_u64(skb, QUOTA_NL_A_CAUSED_ID, current_uid());
@@ -1137,6 +1148,8 @@ attr_err_out:
 err_out:
 	kfree_skb(skb);
 }
+EXPORT_SYMBOL(dquot_send_warning);
+
 #endif
 /*
  * Write warnings to the console and send warning messages over netlink.
@@ -1145,18 +1158,20 @@ err_out:
  */
 static void flush_warnings(struct dquot *const *dquots, char *warntype)
 {
+	struct dquot *dq;
 	int i;
 
-	for (i = 0; i < MAXQUOTAS; i++)
-		if (dquots[i] && warntype[i] != QUOTA_NL_NOWARN &&
-		    !warning_issued(dquots[i], warntype[i])) {
+	for (i = 0; i < MAXQUOTAS; i++) {
+		dq = dquots[i];
+		if (dq && warntype[i] != QUOTA_NL_NOWARN &&
+		    !warning_issued(dq, warntype[i])) {
 #ifdef CONFIG_PRINT_QUOTA_WARNING
-			print_warning(dquots[i], warntype[i]);
-#endif
-#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
-			send_warning(dquots[i], warntype[i]);
+			print_warning(dq, warntype[i]);
 #endif
+			dquot_send_warning(dq->dq_type, dq->dq_id,
+					   dq->dq_sb->s_dev, warntype[i]);
 		}
+	}
 }
 
 static int ignore_hardlimit(struct dquot *dquot)
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 78c4889..c2a13dc 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -376,6 +376,17 @@ static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
 	return flags >> _DQUOT_STATE_FLAGS;
 }
 
+#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
+extern void dquot_send_warning(short type, unsigned int id, dev_t dev,
+			       const char warntype);
+#else
+static inline void dquot_send_warning(short type, unsigned int id, dev_t dev,
+				      const char warntype)
+{
+	return;
+}
+#endif /* CONFIG_QUOTA_NETLINK_INTERFACE */
+
 struct quota_info {
 	unsigned int flags;			/* Flags for diskquotas on this device */
 	struct mutex dqio_mutex;		/* lock device while I/O in progress */
-- 
1.6.2.5




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC] VFS: Export dquot_send_warning
  2009-09-23 12:25 [RFC] VFS: Export dquot_send_warning Steven Whitehouse
@ 2009-09-26 16:29 ` Christoph Hellwig
  2009-09-28  7:26   ` Steven Whitehouse
  2009-09-28 13:43   ` Steven Whitehouse
  0 siblings, 2 replies; 7+ messages in thread
From: Christoph Hellwig @ 2009-09-26 16:29 UTC (permalink / raw)
  To: Steven Whitehouse; +Cc: linux-kernel, Al Viro, Christoph Hellwig

On Wed, Sep 23, 2009 at 01:25:20PM +0100, Steven Whitehouse wrote:
> Hi,
> 
> It would be useful to have a generic method of sending quota messages
> to userspace. The dquot code has such a method, but it can only currently
> be used by that code, so I'm wondering whether there would be any objections
> to exporting it so that other (non-dquot) filesystems could use it?
> 
> My proposed (first draft) patch is below,

If you want to use it without the "generic" quotas it needs to move
from dquota.c to quota.c.  And of course a user in the patch series
makes the likelyhood of getting this included muc higher :)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] VFS: Export dquot_send_warning
  2009-09-26 16:29 ` Christoph Hellwig
@ 2009-09-28  7:26   ` Steven Whitehouse
  2009-09-28 13:09     ` Christoph Hellwig
  2009-09-28 13:43   ` Steven Whitehouse
  1 sibling, 1 reply; 7+ messages in thread
From: Steven Whitehouse @ 2009-09-28  7:26 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel, Al Viro

Hi,

On Sat, 2009-09-26 at 12:29 -0400, Christoph Hellwig wrote:
> On Wed, Sep 23, 2009 at 01:25:20PM +0100, Steven Whitehouse wrote:
> > Hi,
> > 
> > It would be useful to have a generic method of sending quota messages
> > to userspace. The dquot code has such a method, but it can only currently
> > be used by that code, so I'm wondering whether there would be any objections
> > to exporting it so that other (non-dquot) filesystems could use it?
> > 
> > My proposed (first draft) patch is below,
> 
> If you want to use it without the "generic" quotas it needs to move
> from dquota.c to quota.c.  And of course a user in the patch series
> makes the likelyhood of getting this included muc higher :)
> 

Yes, I have a patch to make use of this from GFS2 though I didn't sent
it in the first instance as its trivial and I was more worried about the
generic idea being acceptable. Anyway, I'll send an updated patch,
including moving/renaming where required, shortly,

Steve.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] VFS: Export dquot_send_warning
  2009-09-28  7:26   ` Steven Whitehouse
@ 2009-09-28 13:09     ` Christoph Hellwig
  2009-09-28 13:15       ` Steven Whitehouse
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2009-09-28 13:09 UTC (permalink / raw)
  To: Steven Whitehouse; +Cc: Christoph Hellwig, linux-kernel, Al Viro

On Mon, Sep 28, 2009 at 08:26:20AM +0100, Steven Whitehouse wrote:
> > If you want to use it without the "generic" quotas it needs to move
> > from dquota.c to quota.c.  And of course a user in the patch series
> > makes the likelyhood of getting this included muc higher :)
> > 
> 
> Yes, I have a patch to make use of this from GFS2 though I didn't sent
> it in the first instance as its trivial and I was more worried about the
> generic idea being acceptable. Anyway, I'll send an updated patch,
> including moving/renaming where required, shortly,

Ok, if you want to be nice send a patch for XFS, too.  Any I really want
to exercise this functionality in XFSQA as it feels a bit fragile to me.
Does anyone know about an example userspace client for the
notifications?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] VFS: Export dquot_send_warning
  2009-09-28 13:09     ` Christoph Hellwig
@ 2009-09-28 13:15       ` Steven Whitehouse
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Whitehouse @ 2009-09-28 13:15 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel, Al Viro

Hi,

On Mon, 2009-09-28 at 09:09 -0400, Christoph Hellwig wrote:
> On Mon, Sep 28, 2009 at 08:26:20AM +0100, Steven Whitehouse wrote:
> > > If you want to use it without the "generic" quotas it needs to move
> > > from dquota.c to quota.c.  And of course a user in the patch series
> > > makes the likelyhood of getting this included muc higher :)
> > > 
> > 
> > Yes, I have a patch to make use of this from GFS2 though I didn't sent
> > it in the first instance as its trivial and I was more worried about the
> > generic idea being acceptable. Anyway, I'll send an updated patch,
> > including moving/renaming where required, shortly,
> 
> Ok, if you want to be nice send a patch for XFS, too.  Any I really want
> to exercise this functionality in XFSQA as it feels a bit fragile to me.
> Does anyone know about an example userspace client for the
> notifications?
> 
Yes, I'll look at the other filesystems too, but I wanted to be
reasonably sure that it would be ok first. I've got an updated patch
which I'll send shortly.

There is a userspace client in the quota tools called quota_nld but at
the moment its refusing to build for me... looks like some version issue
wrt to the netlink library that its using. Otherwise I'll write my
own :-)

Steve.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] VFS: Export dquot_send_warning
  2009-09-26 16:29 ` Christoph Hellwig
  2009-09-28  7:26   ` Steven Whitehouse
@ 2009-09-28 13:43   ` Steven Whitehouse
  2009-09-28 13:45     ` Steven Whitehouse
  1 sibling, 1 reply; 7+ messages in thread
From: Steven Whitehouse @ 2009-09-28 13:43 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel, Al Viro

Hi,

Here is an updated version (moves the function to quota.c). This has had
some testing with a few different kernel configs and also I've got the
userland quota_nld (in the quota tools) daemon working with it,

Steve.

-----------------------------------------------------------------------

>From 42a7f843a445c369c189a8929f80692e341f1bce Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho@redhat.com>
Date: Mon, 28 Sep 2009 12:35:17 +0100
Subject: [PATCH 11/12] VFS: Export dquot_send_warning

Sending a message to userspace in a generic format to warn
of events (e.g. quota exceeded) in the quota subsystem is
a generically useful feature. This patch makes some minor
changes to the send_message function from dquot.c renaming
it quota_send_message, moving it to quota.c and exporting it
for use by filesystems which do not use the dquot code.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
 fs/quota/Kconfig      |    2 +-
 fs/quota/dquot.c      |   93 +++++--------------------------------------------
 fs/quota/quota.c      |   93 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/quota.h |   11 ++++++
 4 files changed, 114 insertions(+), 85 deletions(-)

diff --git a/fs/quota/Kconfig b/fs/quota/Kconfig
index 8047e01..353e78a 100644
--- a/fs/quota/Kconfig
+++ b/fs/quota/Kconfig
@@ -17,7 +17,7 @@ config QUOTA
 
 config QUOTA_NETLINK_INTERFACE
 	bool "Report quota messages through netlink interface"
-	depends on QUOTA && NET
+	depends on QUOTACTL && NET
 	help
 	  If you say Y here, quota warnings (about exceeding softlimit, reaching
 	  hardlimit, etc.) will be reported through netlink interface. If unsure,
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 39b49c4..9b6ad90 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -77,10 +77,6 @@
 #include <linux/capability.h>
 #include <linux/quotaops.h>
 #include <linux/writeback.h> /* for inode_lock, oddly enough.. */
-#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
-#include <net/netlink.h>
-#include <net/genetlink.h>
-#endif
 
 #include <asm/uaccess.h>
 
@@ -1071,73 +1067,6 @@ static void print_warning(struct dquot *dquot, const int warntype)
 }
 #endif
 
-#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
-
-/* Netlink family structure for quota */
-static struct genl_family quota_genl_family = {
-	.id = GENL_ID_GENERATE,
-	.hdrsize = 0,
-	.name = "VFS_DQUOT",
-	.version = 1,
-	.maxattr = QUOTA_NL_A_MAX,
-};
-
-/* Send warning to userspace about user which exceeded quota */
-static void send_warning(const struct dquot *dquot, const char warntype)
-{
-	static atomic_t seq;
-	struct sk_buff *skb;
-	void *msg_head;
-	int ret;
-	int msg_size = 4 * nla_total_size(sizeof(u32)) +
-		       2 * nla_total_size(sizeof(u64));
-
-	/* We have to allocate using GFP_NOFS as we are called from a
-	 * filesystem performing write and thus further recursion into
-	 * the fs to free some data could cause deadlocks. */
-	skb = genlmsg_new(msg_size, GFP_NOFS);
-	if (!skb) {
-		printk(KERN_ERR
-		  "VFS: Not enough memory to send quota warning.\n");
-		return;
-	}
-	msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
-			&quota_genl_family, 0, QUOTA_NL_C_WARNING);
-	if (!msg_head) {
-		printk(KERN_ERR
-		  "VFS: Cannot store netlink header in quota warning.\n");
-		goto err_out;
-	}
-	ret = nla_put_u32(skb, QUOTA_NL_A_QTYPE, dquot->dq_type);
-	if (ret)
-		goto attr_err_out;
-	ret = nla_put_u64(skb, QUOTA_NL_A_EXCESS_ID, dquot->dq_id);
-	if (ret)
-		goto attr_err_out;
-	ret = nla_put_u32(skb, QUOTA_NL_A_WARNING, warntype);
-	if (ret)
-		goto attr_err_out;
-	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MAJOR,
-		MAJOR(dquot->dq_sb->s_dev));
-	if (ret)
-		goto attr_err_out;
-	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MINOR,
-		MINOR(dquot->dq_sb->s_dev));
-	if (ret)
-		goto attr_err_out;
-	ret = nla_put_u64(skb, QUOTA_NL_A_CAUSED_ID, current_uid());
-	if (ret)
-		goto attr_err_out;
-	genlmsg_end(skb, msg_head);
-
-	genlmsg_multicast(skb, 0, quota_genl_family.id, GFP_NOFS);
-	return;
-attr_err_out:
-	printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");
-err_out:
-	kfree_skb(skb);
-}
-#endif
 /*
  * Write warnings to the console and send warning messages over netlink.
  *
@@ -1145,18 +1074,20 @@ err_out:
  */
 static void flush_warnings(struct dquot *const *dquots, char *warntype)
 {
+	struct dquot *dq;
 	int i;
 
-	for (i = 0; i < MAXQUOTAS; i++)
-		if (dquots[i] && warntype[i] != QUOTA_NL_NOWARN &&
-		    !warning_issued(dquots[i], warntype[i])) {
+	for (i = 0; i < MAXQUOTAS; i++) {
+		dq = dquots[i];
+		if (dq && warntype[i] != QUOTA_NL_NOWARN &&
+		    !warning_issued(dq, warntype[i])) {
 #ifdef CONFIG_PRINT_QUOTA_WARNING
-			print_warning(dquots[i], warntype[i]);
-#endif
-#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
-			send_warning(dquots[i], warntype[i]);
+			print_warning(dq, warntype[i]);
 #endif
+			quota_send_warning(dq->dq_type, dq->dq_id,
+					   dq->dq_sb->s_dev, warntype[i]);
 		}
+	}
 }
 
 static int ignore_hardlimit(struct dquot *dquot)
@@ -2607,12 +2538,6 @@ static int __init dquot_init(void)
 
 	register_shrinker(&dqcache_shrinker);
 
-#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
-	if (genl_register_family(&quota_genl_family) != 0)
-		printk(KERN_ERR
-		       "VFS: Failed to create quota netlink interface.\n");
-#endif
-
 	return 0;
 }
 module_init(dquot_init);
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 95c5b42..ee91e27 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -18,6 +18,8 @@
 #include <linux/capability.h>
 #include <linux/quotaops.h>
 #include <linux/types.h>
+#include <net/netlink.h>
+#include <net/genetlink.h>
 
 /* Check validity of generic quotactl commands */
 static int generic_quotactl_valid(struct super_block *sb, int type, int cmd,
@@ -525,3 +527,94 @@ asmlinkage long sys32_quotactl(unsigned int cmd, const char __user *special,
 	return ret;
 }
 #endif
+
+
+#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
+
+/* Netlink family structure for quota */
+static struct genl_family quota_genl_family = {
+	.id = GENL_ID_GENERATE,
+	.hdrsize = 0,
+	.name = "VFS_DQUOT",
+	.version = 1,
+	.maxattr = QUOTA_NL_A_MAX,
+};
+
+/**
+ * quota_send_warning - Send warning to userspace about exceeded quota
+ * @type: The quota type: USRQQUOTA, GRPQUOTA,...
+ * @id: The user or group id of the quota that was exceeded
+ * @dev: The device on which the fs is mounted (sb->s_dev)
+ * @warntype: The type of the warning: QUOTA_NL_...
+ *
+ * This can be used by filesystems (including those which don't use
+ * dquot) to send a message to userspace relating to quota limits.
+ *
+ */
+
+void quota_send_warning(short type, unsigned int id, dev_t dev,
+			const char warntype)
+{
+	static atomic_t seq;
+	struct sk_buff *skb;
+	void *msg_head;
+	int ret;
+	int msg_size = 4 * nla_total_size(sizeof(u32)) +
+		       2 * nla_total_size(sizeof(u64));
+
+	/* We have to allocate using GFP_NOFS as we are called from a
+	 * filesystem performing write and thus further recursion into
+	 * the fs to free some data could cause deadlocks. */
+	skb = genlmsg_new(msg_size, GFP_NOFS);
+	if (!skb) {
+		printk(KERN_ERR
+		  "VFS: Not enough memory to send quota warning.\n");
+		return;
+	}
+	msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
+			&quota_genl_family, 0, QUOTA_NL_C_WARNING);
+	if (!msg_head) {
+		printk(KERN_ERR
+		  "VFS: Cannot store netlink header in quota warning.\n");
+		goto err_out;
+	}
+	ret = nla_put_u32(skb, QUOTA_NL_A_QTYPE, type);
+	if (ret)
+		goto attr_err_out;
+	ret = nla_put_u64(skb, QUOTA_NL_A_EXCESS_ID, id);
+	if (ret)
+		goto attr_err_out;
+	ret = nla_put_u32(skb, QUOTA_NL_A_WARNING, warntype);
+	if (ret)
+		goto attr_err_out;
+	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MAJOR, MAJOR(dev));
+	if (ret)
+		goto attr_err_out;
+	ret = nla_put_u32(skb, QUOTA_NL_A_DEV_MINOR, MINOR(dev));
+	if (ret)
+		goto attr_err_out;
+	ret = nla_put_u64(skb, QUOTA_NL_A_CAUSED_ID, current_uid());
+	if (ret)
+		goto attr_err_out;
+	genlmsg_end(skb, msg_head);
+
+	genlmsg_multicast(skb, 0, quota_genl_family.id, GFP_NOFS);
+	return;
+attr_err_out:
+	printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");
+err_out:
+	kfree_skb(skb);
+}
+EXPORT_SYMBOL(quota_send_warning);
+
+static int __init quota_init(void)
+{
+	if (genl_register_family(&quota_genl_family) != 0)
+		printk(KERN_ERR
+		       "VFS: Failed to create quota netlink interface.\n");
+	return 0;
+};
+
+module_init(quota_init);
+#endif
+
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 78c4889..ce9a9b2 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -376,6 +376,17 @@ static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
 	return flags >> _DQUOT_STATE_FLAGS;
 }
 
+#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
+extern void quota_send_warning(short type, unsigned int id, dev_t dev,
+			       const char warntype);
+#else
+static inline void quota_send_warning(short type, unsigned int id, dev_t dev,
+				      const char warntype)
+{
+	return;
+}
+#endif /* CONFIG_QUOTA_NETLINK_INTERFACE */
+
 struct quota_info {
 	unsigned int flags;			/* Flags for diskquotas on this device */
 	struct mutex dqio_mutex;		/* lock device while I/O in progress */
-- 
1.6.2.5




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC] VFS: Export dquot_send_warning
  2009-09-28 13:43   ` Steven Whitehouse
@ 2009-09-28 13:45     ` Steven Whitehouse
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Whitehouse @ 2009-09-28 13:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel, Al Viro

Hi,

Here is the patch to make it work with GFS2,

Steve.

------------------------------------------------------------------------------
>From 2d098b275c0ef952e3a3a328bae1beac7d9b9017 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho@redhat.com>
Date: Mon, 28 Sep 2009 12:49:15 +0100
Subject: [PATCH 12/12] GFS2: Use dquot_send_warning()

This adds support to GFS2 to send quota warnings via netlink.
Also it removes a stray \r which was left over from when the
code used to print warnings on the console.

Signed-off-by: Steven Whitehouse <swhitehouse@redhat.com>
---
 fs/gfs2/quota.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index e8db534..1d4fc04 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -47,6 +47,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/kthread.h>
 #include <linux/freezer.h>
+#include <linux/quota.h>
 #include <linux/dqblk_xfs.h>
 
 #include "gfs2.h"
@@ -1001,7 +1002,7 @@ static int print_message(struct gfs2_quota_data *qd, char *type)
 {
 	struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
 
-	printk(KERN_INFO "GFS2: fsid=%s: quota %s for %s %u\r\n",
+	printk(KERN_INFO "GFS2: fsid=%s: quota %s for %s %u\n",
 	       sdp->sd_fsname, type,
 	       (test_bit(QDF_USER, &qd->qd_flags)) ? "user" : "group",
 	       qd->qd_id);
@@ -1038,6 +1039,10 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
 
 		if (be64_to_cpu(qd->qd_qb.qb_limit) && (s64)be64_to_cpu(qd->qd_qb.qb_limit) < value) {
 			print_message(qd, "exceeded");
+			quota_send_warning(test_bit(QDF_USER, &qd->qd_flags) ?
+					   USRQUOTA : GRPQUOTA, qd->qd_id,
+					   sdp->sd_vfs->s_dev, QUOTA_NL_BHARDWARN);
+
 			error = -EDQUOT;
 			break;
 		} else if (be64_to_cpu(qd->qd_qb.qb_warn) &&
@@ -1045,6 +1050,9 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
 			   time_after_eq(jiffies, qd->qd_last_warn +
 					 gfs2_tune_get(sdp,
 						gt_quota_warn_period) * HZ)) {
+			quota_send_warning(test_bit(QDF_USER, &qd->qd_flags) ?
+					   USRQUOTA : GRPQUOTA, qd->qd_id,
+					   sdp->sd_vfs->s_dev, QUOTA_NL_BSOFTWARN);
 			error = print_message(qd, "warning");
 			qd->qd_last_warn = jiffies;
 		}
-- 
1.6.2.5




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-09-28 14:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-23 12:25 [RFC] VFS: Export dquot_send_warning Steven Whitehouse
2009-09-26 16:29 ` Christoph Hellwig
2009-09-28  7:26   ` Steven Whitehouse
2009-09-28 13:09     ` Christoph Hellwig
2009-09-28 13:15       ` Steven Whitehouse
2009-09-28 13:43   ` Steven Whitehouse
2009-09-28 13:45     ` Steven Whitehouse

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.