From: jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org
To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: tytso-3s7WtUTddSA@public.gmane.org,
jack-AlSwsSmVLrQ@public.gmane.org,
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org,
hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
bpm-sJ/iWh9BUns@public.gmane.org,
christopher.jones-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tm-d1IQDZat3X0@public.gmane.org,
linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
chris.mason-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
tinguely-sJ/iWh9BUns@public.gmane.org
Subject: [PATCH 2/3] container quota tool: add quotaio for lxc
Date: Wed, 30 May 2012 23:07:57 +0800 [thread overview]
Message-ID: <1338390478-13951-2-git-send-email-jeff.liu@oracle.com> (raw)
In-Reply-To: <1338390478-13951-1-git-send-email-jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Add quotaio_lxc.c[.h] to isolate container quotactl operations.
Signed-off-by: Jie Liu <jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
quotaio_lxc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
quotaio_lxc.h | 4 +++
2 files changed, 82 insertions(+), 0 deletions(-)
create mode 100644 quotaio_lxc.c
create mode 100644 quotaio_lxc.h
diff --git a/quotaio_lxc.c b/quotaio_lxc.c
new file mode 100644
index 0000000..b3a8144
--- /dev/null
+++ b/quotaio_lxc.c
@@ -0,0 +1,78 @@
+#include "config.h"
+
+#include <errno.h>
+#include <string.h>
+#include <pwd.h>
+#include <grp.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "pot.h"
+#include "common.h"
+#include "quotaio.h"
+#include "quotaio_generic.h"
+#include "quota.h"
+#include "quotasys.h"
+#include "dqblk_lxc.h"
+
+int lxc_init_io(struct quota_handle *h);
+int lxc_write_info(struct quota_handle *h);
+struct dquot *lxc_read_dquot(struct quota_handle *h, qid_t id);
+int lxc_commit_dquot(struct dquot *dquot, int flags);
+int lxc_scan_dquots(struct quota_handle *h, int (*process_dquot)(struct
+dquot *dquot, char *dqname));
+
+struct quotafile_ops quotafile_ops_lxc = {
+init_io: lxc_init_io,
+write_info: lxc_write_info,
+read_dquot: lxc_read_dquot,
+commit_dquot: lxc_commit_dquot,
+scan_dquots: lxc_scan_dquots
+};
+
+/*
+ * Initialize container quota information
+ */
+int lxc_init_io(struct quota_handle *h)
+{
+ /*
+ * FIXME: at first, before turning LXC quota on,
+ * call vfs_get_info() will failed as ENOSCH, so
+ * just return 0 is ok.
+ * Should we consider to call vfs_get_info(h) here?
+ */
+ return 0;
+}
+
+/*
+ * Write information (grace times)
+ */
+int lxc_write_info(struct quota_handle *h)
+{
+ return vfs_set_info(h, IIF_BGRACE | IIF_IGRACE);
+}
+
+struct dquot *lxc_read_dquot(struct quota_handle *h, qid_t id)
+{
+ struct dquot *dquot = get_empty_dquot();
+
+ dquot->dq_id = id;
+ dquot->dq_h = h;
+ memset(&dquot->dq_dqb, 0, sizeof(struct util_dqblk));
+ if (vfs_get_dquot(dquot) < 0) {
+ free(dquot);
+ return NULL;
+ }
+ return dquot;
+}
+
+int lxc_commit_dquot(struct dquot *dquot, int flags)
+{
+ return vfs_set_dquot(dquot, flags);
+}
+
+int lxc_scan_dquots(struct quota_handle *h, int (*process_dquot)(struct
+dquot *dquot, char *dqname))
+{
+ return generic_scan_dquots(h, process_dquot, vfs_get_dquot);
+}
diff --git a/quotaio_lxc.h b/quotaio_lxc.h
new file mode 100644
index 0000000..2ae2899
--- /dev/null
+++ b/quotaio_lxc.h
@@ -0,0 +1,4 @@
+#ifndef GUARD_QUOTAIO_GENERIC_H
+#define GUARD_QUOTAIO_GENERIC_H
+
+#endif
--
1.7.9
next prev parent reply other threads:[~2012-05-30 15:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-30 15:07 [PATCH 1/3] container quota tool: add LXC quota format identifier jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
[not found] ` <1338390478-13951-1-git-send-email-jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-30 15:07 ` jeff.liu-QHcLZuEGTsvQT0dZR+AlfA [this message]
2012-05-30 15:07 ` [PATCH 3/3] container quota tool: teach quota tools to detect and perfrom quota if desired jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
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=1338390478-13951-2-git-send-email-jeff.liu@oracle.com \
--to=jeff.liu-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=bpm-sJ/iWh9BUns@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=chris.mason-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=christopher.jones-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org \
--cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=jack-AlSwsSmVLrQ@public.gmane.org \
--cc=linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tinguely-sJ/iWh9BUns@public.gmane.org \
--cc=tm-d1IQDZat3X0@public.gmane.org \
--cc=tytso-3s7WtUTddSA@public.gmane.org \
/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).