From d1c623b450aec1f370cfbe00cf8d4dcca2f57cdf Mon Sep 17 00:00:00 2001 From: jkar8572 Date: Mon, 12 Mar 2007 11:12:40 +0000 Subject: Fixed some more problems in XFS quotaon (Kouta Ooizumi, Jan Kara) --- Changelog | 2 ++ quotaon.8 | 11 +++++++---- quotaon_xfs.c | 62 +++++++++++++++++++++++++++++++++++------------------------ 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/Changelog b/Changelog index e015242..67603b4 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ Changes in quota-tools from 3.14 to 3.15 +* fixed some more problems XFS quotaon (Kouta Ooizumi, Jan Kara) +* fixed two mistakes in quotaon(8) manpage (Utako Kusaka) * added option -A to quota(1) to report all NFS mountpoints (Jan Kara) * fixed XFS handling to work with loopback mounted devices (Jan Kara) * fixed mountpoints scanning to make XFS -x delete command work (Jan Kara) diff --git a/quotaon.8 b/quotaon.8 index 3b199dd..26319f7 100644 --- a/quotaon.8 +++ b/quotaon.8 @@ -152,7 +152,7 @@ ignored for other filesystem types. It can only be used on a filesystem with quota previously turned off. .TP .B -x, --xfs-command enforce -Switch off limit enforcement for XFS filesystems (perform +Switch on/off limit enforcement for XFS filesystems (perform quota accounting only). This option is only applicable to XFS, and is silently ignored for other filesystem types. @@ -172,15 +172,18 @@ boot option. .PP To turn off quota limit enforcement on any XFS filesystem, first make sure that quota accounting and enforcement are both turned on using -.BR "repquota -s" . +.B "repquota -v" +.IR filesystem . Then, use -.B "quotaoff -vo" +.B "quotaoff -v +.I filesystem to disable limit enforcement. This may be done while the filesystem is mounted. .PP Turning on quota limit enforcement on an XFS filesystem is achieved using -.BR "quotaon -v" . +.B "quotaon -v" +.IR filesystem . This may be done while the filesystem is mounted. .SH FILES .PD 0 diff --git a/quotaon_xfs.c b/quotaon_xfs.c index a9aed6f..5707619 100644 --- a/quotaon_xfs.c +++ b/quotaon_xfs.c @@ -21,10 +21,11 @@ * Ensure we don't attempt to go into a dodgey state. */ -static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothack, int *xopts) +static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothack, int xopts) { struct xfs_mem_dqinfo info; int state; + char *acctstr = ""; /* we never want to operate via -a in XFS quota */ if (flags & STATEFLAG_ALL) @@ -57,13 +58,11 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothac return 1; case Q_XFS_QUOTAON: if (roothack) { - *xopts |= (type == USRQUOTA) ? - XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT; printf(_("Enabling %s quota on root filesystem" " (reboot to take effect)\n"), type2name(type)); return 1; } - errstr(_("Enable XFS %s quota during mount\n"), + errstr(_("Enable XFS %s quota accounting during mount\n"), type2name(type)); return -1; case Q_XFS_QUOTAOFF: @@ -79,20 +78,26 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothac return -1; case Q_XFS_QUOTAON: if (roothack) { - *xopts |= (type == USRQUOTA) ? - XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT; printf(_("Enabling %s quota on root filesystem" " (reboot to take effect)\n"), type2name(type)); return 1; } - printf(_("Enabling %s quota accounting on %s\n"), type2name(type), dev); - *xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT; - return 1; + if (xopts & XFS_QUOTA_UDQ_ENFD || xopts & XFS_QUOTA_GDQ_ENFD) { + printf(_("Enabling %s quota enforcement on %s\n"), type2name(type), dev); + return 1; + } + errstr(_("Already accounting %s quota on %s\n"), + type2name(type), dev); + return -1; case Q_XFS_QUOTAOFF: - printf(_("Disabling %s quota accounting on %s\n"), - type2name(type), dev); - *xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT; - return 1; + if (xopts & XFS_QUOTA_UDQ_ACCT || xopts & XFS_QUOTA_GDQ_ACCT) { + printf(_("Disabling %s quota accounting on %s\n"), + type2name(type), dev); + return 1; + } + errstr(_("Quota enforcement already disabled for %s on %s\n"), + type2name(type), dev); + return -1; } break; @@ -100,7 +105,7 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothac switch (qcmd) { case Q_XFS_QUOTARM: errstr(_("Cannot delete %s quota on %s - " - "switch quota enforcement off first\n"), + "switch quota enforcement and accounting off first\n"), type2name(type), dev); return -1; case Q_XFS_QUOTAON: @@ -108,9 +113,16 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothac type2name(type), dev); return -1; case Q_XFS_QUOTAOFF: - printf(_("Disabling %s quota enforcement on %s\n"), - type2name(type), dev); - *xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ENFD : XFS_QUOTA_GDQ_ENFD; + if (xopts == XFS_QUOTA_UDQ_ACCT || xopts == XFS_QUOTA_GDQ_ACCT) { + errstr(_("Cannot switch off %s quota" + "accounting on %s when enforcement is on\n"), + type2name(type), dev); + return -1; + } + if (xopts & XFS_QUOTA_UDQ_ACCT || xopts & XFS_QUOTA_GDQ_ACCT) + acctstr = _("and accounting "); + printf(_("Disabling %s quota enforcement %son %s\n"), + type2name(type), acctstr, dev); return 1; } break; @@ -119,7 +131,7 @@ static int xfs_state_check(int qcmd, int type, int flags, char *dev, int roothac return -1; } -static int xfs_onoff(char *dev, int type, int flags, int roothack, int *xopts) +static int xfs_onoff(char *dev, int type, int flags, int roothack, int xopts) { int qoff, qcmd, check; @@ -129,7 +141,7 @@ static int xfs_onoff(char *dev, int type, int flags, int roothack, int *xopts) if (check != 1) return (check < 0); - if (quotactl(QCMD(qcmd, type), dev, 0, (void *)xopts) < 0) { + if (quotactl(QCMD(qcmd, type), dev, 0, (void *)&xopts) < 0) { errstr(_("quotactl on %s: %s\n"), dev, strerror(errno)); return 1; } @@ -140,7 +152,7 @@ static int xfs_onoff(char *dev, int type, int flags, int roothack, int *xopts) return 0; } -static int xfs_delete(char *dev, int type, int flags, int roothack, int *xopts) +static int xfs_delete(char *dev, int type, int flags, int roothack, int xopts) { int qcmd, check; @@ -149,7 +161,7 @@ static int xfs_delete(char *dev, int type, int flags, int roothack, int *xopts) if (check != 1) return (check < 0); - if (quotactl(QCMD(qcmd, type), dev, 0, (void *)xopts) < 0) { + if (quotactl(QCMD(qcmd, type), dev, 0, (void *)&xopts) < 0) { errstr(_("Failed to delete quota: %s\n"), strerror(errno)); return 1; @@ -199,22 +211,22 @@ int xfs_newstate(struct mntent *mnt, int type, char *xarg, int flags) xopts |= (type == USRQUOTA) ? (XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_UDQ_ENFD) : (XFS_QUOTA_GDQ_ACCT | XFS_QUOTA_GDQ_ENFD); - err = xfs_onoff((char *)dev, type, flags, roothack, &xopts); + err = xfs_onoff((char *)dev, type, flags, roothack, xopts); } else if (strcmp(xarg, "account") == 0) { /* only useful if we want root accounting only */ if (!roothack || !(flags & STATEFLAG_ON)) goto done; xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT; - err = xfs_onoff((char *)dev, type, flags, roothack, &xopts); + err = xfs_onoff((char *)dev, type, flags, roothack, xopts); } else if (strcmp(xarg, "enforce") == 0) { xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ENFD : XFS_QUOTA_GDQ_ENFD; - err = xfs_onoff((char *)dev, type, flags, roothack, &xopts); + err = xfs_onoff((char *)dev, type, flags, roothack, xopts); } else if (strcmp(xarg, "delete") == 0) { xopts |= (type == USRQUOTA) ? XFS_USER_QUOTA : XFS_GROUP_QUOTA; - err = xfs_delete((char *)dev, type, flags, roothack, &xopts); + err = xfs_delete((char *)dev, type, flags, roothack, xopts); } else die(1, _("Invalid argument \"%s\"\n"), xarg); -- cgit v1.2.3