Hi,
I have got the following error when doing free command in xfs_quota.
The free command tries to get the quota status though the project quota is off.
The man page for free command says:
if project quota are in use, it will also report utilisation for those projects.
So this patch checks if the file system is mounted with the quota option and
if the project quota is on.
Example:
# mount -t xfs -o prjquota /dev/sda6 mpnt/
# xfs_quota -c "free" /dev/sda6
Filesystem 1K-blocks Used Available Use% Pathname
/dev/sda6 10480128 4196084 6284044 41% /home/utako/mpnt
/dev/sda6 10480128 104 6284044 1% /home/utako/mpnt/pjq
/dev/sda6 10480128 0 6284044 0% /home/utako/mpnt/pjq2
# umount mpnt/
# mount -t xfs -o usrquota /dev/sda6 mpnt/
# xfs_quota -c "free" /dev/sda6
Filesystem 1K-blocks Used Available Use% Pathname
/dev/sda6 10480128 4196084 6284044 41% /home/utako/mpnt
XFS_GETQUOTA: No such process
XFS_GETQUOTA: No such process
# umount mpnt/
# mount -t xfs /dev/sda6 mpnt/
# xfs_quota -c "free" /dev/sda6
Filesystem 1K-blocks Used Available Use% Pathname
/dev/sda6 10480128 4196084 6284044 41% /home/utako/mpnt
XFS_GETQUOTA: Function not implemented
XFS_GETQUOTA: Function not implemented
Signed-off-by: Utako Kusaka <utako@xxxxxxxxxxxxxx>
---
--- xfsprogs-2.8.20/quota/free.orig 2007-05-09 10:36:01.000000000 +0900
+++ xfsprogs-2.8.20/quota/free.c 2007-05-10 17:18:16.000000000 +0900
@@ -116,12 +116,18 @@ projects_free_space_data(
__uint64_t *rused,
__uint64_t *rfree)
{
+ fs_quota_stat_t qfs;
fs_disk_quota_t d;
struct fsxattr fsx;
uint type = XFS_PROJ_QUOTA;
char *dev = path->fs_name;
int fd;
+ if ((xfsquotactl(XFS_GETQSTAT, dev, type, 0, &qfs) < 0) ||
+ !(qfs.qs_flags & XFS_QUOTA_PDQ_ACCT)) {
+ return 0;
+ }
+
if ((fd = open(path->fs_dir, O_RDONLY)) < 0) {
fprintf(stderr, "%s: cannot open %s: %s\n",
progname, path->fs_dir, strerror(errno));
|