|
|
e40344 |
From 7367f5d511ec4555fbb7a87c1c1853fd4fd01712 Mon Sep 17 00:00:00 2001
|
|
|
e40344 |
From: Jan Kara <jack@suse.cz>
|
|
|
e40344 |
Date: Tue, 26 Jan 2016 14:06:59 +0100
|
|
|
e40344 |
Subject: [PATCH 2/2] Add support for scanning using Q_XGETNEXTQUOTA
|
|
|
e40344 |
MIME-Version: 1.0
|
|
|
e40344 |
Content-Type: text/plain; charset=UTF-8
|
|
|
e40344 |
Content-Transfer-Encoding: 8bit
|
|
|
e40344 |
|
|
|
e40344 |
Add support for scanning of all available quota structures using
|
|
|
e40344 |
Q_XGETNEXTQUOTA quotactl.
|
|
|
e40344 |
|
|
|
e40344 |
Signed-off-by: Jan Kara <jack@suse.cz>
|
|
|
e40344 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
e40344 |
---
|
|
|
e40344 |
quotaio_xfs.c | 42 +++++++++++++++++++++++++++++++++++++++---
|
|
|
e40344 |
quotaio_xfs.h | 1 +
|
|
|
e40344 |
2 files changed, 40 insertions(+), 3 deletions(-)
|
|
|
e40344 |
|
|
|
e40344 |
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
|
|
|
e40344 |
index 903c03e..9d90a3e 100644
|
|
|
e40344 |
--- a/quotaio_xfs.c
|
|
|
e40344 |
+++ b/quotaio_xfs.c
|
|
|
e40344 |
@@ -191,15 +191,51 @@ static int xfs_get_dquot(struct dquot *dq)
|
|
|
e40344 |
return 0;
|
|
|
e40344 |
}
|
|
|
e40344 |
|
|
|
e40344 |
+static int xfs_kernel_scan_dquots(struct quota_handle *h,
|
|
|
e40344 |
+ int (*process_dquot)(struct dquot *dquot, char *dqname))
|
|
|
e40344 |
+{
|
|
|
e40344 |
+ struct dquot *dquot = get_empty_dquot();
|
|
|
e40344 |
+ qid_t id = 0;
|
|
|
e40344 |
+ struct xfs_kern_dqblk xdqblk;
|
|
|
e40344 |
+ int ret;
|
|
|
e40344 |
+
|
|
|
e40344 |
+ dquot->dq_h = h;
|
|
|
e40344 |
+ while (1) {
|
|
|
e40344 |
+ ret = quotactl(QCMD(Q_XGETNEXTQUOTA, h->qh_type),
|
|
|
e40344 |
+ h->qh_quotadev, id, (void *)&xdqblk);
|
|
|
e40344 |
+ if (ret < 0)
|
|
|
e40344 |
+ break;
|
|
|
e40344 |
+
|
|
|
e40344 |
+ xfs_kern2utildqblk(&dquot->dq_dqb, &xdqblk);
|
|
|
e40344 |
+ dquot->dq_id = xdqblk.d_id;
|
|
|
e40344 |
+ ret = process_dquot(dquot, NULL);
|
|
|
e40344 |
+ if (ret < 0)
|
|
|
e40344 |
+ break;
|
|
|
e40344 |
+ id = xdqblk.d_id + 1;
|
|
|
e40344 |
+ }
|
|
|
e40344 |
+ free(dquot);
|
|
|
e40344 |
+
|
|
|
e40344 |
+ if (errno == ENOENT)
|
|
|
e40344 |
+ return 0;
|
|
|
e40344 |
+ return ret;
|
|
|
e40344 |
+}
|
|
|
e40344 |
+
|
|
|
e40344 |
/*
|
|
|
e40344 |
* Scan all known dquots and call callback on each
|
|
|
e40344 |
*/
|
|
|
e40344 |
static int xfs_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *dquot, char *dqname))
|
|
|
e40344 |
{
|
|
|
e40344 |
- if (!XFS_USRQUOTA(h) && !XFS_GRPQUOTA(h))
|
|
|
e40344 |
- return 0;
|
|
|
e40344 |
+ int ret;
|
|
|
e40344 |
+ struct xfs_kern_dqblk xdqblk;
|
|
|
e40344 |
|
|
|
e40344 |
- return generic_scan_dquots(h, process_dquot, xfs_get_dquot);
|
|
|
e40344 |
+ ret = quotactl(QCMD(Q_XGETNEXTQUOTA, h->qh_type), h->qh_quotadev, 0,
|
|
|
e40344 |
+ (void *)&xdqblk);
|
|
|
e40344 |
+ if (ret < 0 && (errno == ENOSYS || errno == EINVAL)) {
|
|
|
e40344 |
+ if (!XFS_USRQUOTA(h) && !XFS_GRPQUOTA(h))
|
|
|
e40344 |
+ return 0;
|
|
|
e40344 |
+ return generic_scan_dquots(h, process_dquot, xfs_get_dquot);
|
|
|
e40344 |
+ }
|
|
|
e40344 |
+ return xfs_kernel_scan_dquots(h, process_dquot);
|
|
|
e40344 |
}
|
|
|
e40344 |
|
|
|
e40344 |
/*
|
|
|
e40344 |
diff --git a/quotaio_xfs.h b/quotaio_xfs.h
|
|
|
e40344 |
index 54725b0..2236da4 100644
|
|
|
e40344 |
--- a/quotaio_xfs.h
|
|
|
e40344 |
+++ b/quotaio_xfs.h
|
|
|
e40344 |
@@ -46,6 +46,7 @@
|
|
|
e40344 |
#define Q_XSETQLIM XQM_CMD(0x4) /* set disk limits only */
|
|
|
e40344 |
#define Q_XGETQSTAT XQM_CMD(0x5) /* returns fs_quota_stat_t struct */
|
|
|
e40344 |
#define Q_XQUOTARM XQM_CMD(0x6) /* free quota files' space */
|
|
|
e40344 |
+#define Q_XGETNEXTQUOTA XQM_CMD(0x9) /* get disk limits and usage >= ID */
|
|
|
e40344 |
|
|
|
e40344 |
/*
|
|
|
e40344 |
* fs_disk_quota structure:
|
|
|
e40344 |
--
|
|
|
e40344 |
2.5.0
|
|
|
e40344 |
|