From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 10/12] VFS: Export dquot_send_warning
Date: Wed, 23 Sep 2009 14:15:30 +0100 [thread overview]
Message-ID: <1253711732-2955-11-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1253711732-2955-10-git-send-email-swhiteho@redhat.com>
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
next prev parent reply other threads:[~2009-09-23 13:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-23 13:15 [Cluster-devel] GFS2: Another quota of quotas Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 01/12] GFS2: Alter arguments of gfs2_quota/statfs_sync Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 02/12] GFS2: Hook gfs2_quota_sync into VFS via gfs2_quotactl_ops Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 03/12] GFS2: Remove obsolete code in quota.c Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 04/12] GFS2: Add get_xstate quota function Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 05/12] GFS2: Add proper error reporting to quota sync via sysfs Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 06/12] GFS2: Remove constant argument from qdsb_get() Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 07/12] GFS2: Remove constant argument from qd_get() Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 08/12] GFS2: Clean up gfs2_adjust_quota() and do_glock() Steven Whitehouse
2009-09-23 13:15 ` [Cluster-devel] [PATCH 09/12] GFS2: Add get_xquota support Steven Whitehouse
2009-09-23 13:15 ` Steven Whitehouse [this message]
2009-09-23 15:49 ` [Cluster-devel] [PATCH 11/12] GFS2: Use dquot_send_warning() Steven Whitehouse
2009-09-23 15:50 ` [Cluster-devel] [PATCH 12/12] GFS2: Add set_xquota support Steven Whitehouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1253711732-2955-11-git-send-email-swhiteho@redhat.com \
--to=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).