0

I successfully use xfs project (or directory) quota. However I just discovered that I am unable to remove quota information once I don't need it anymore. For example, I had 3 projects with project id 1, 2, 3. I removed the directory of the project with id 2, and now xfs_quota continues to tell me that there is is a project with id 2, and it has quota. The reported used space is 0, which is correct since the directory was removed. This is not a real problem. Whenever I reuse project id 2 I will set new quota, but I'd still like to remove this useless information from the filesystem.

/etc/projects

1:/web/perso/usera
3:/web/perso/userc

/etc/projid

usera:1
userc:3

And here is what xfs_quota reports.

root@server # xfs_quota -xc "report -a -p -h" 
Project quota on /web (/dev/vdb1)
                        Blocks              
Project ID   Used   Soft   Hard Warn/Grace   
---------- --------------------------------- 
#0         588.3M      0      0  00 [------]
usera        5.5M    14G    14G  00 [------]
#2              0   980M     1G  00 [------]
userc      574.6M    14G    14G  00 [------]

How can I tell xfs that it does not need anymore to keep track of project id 2 ?

exore
  • 408
  • 4
  • 10

3 Answers3

5

Setting limits to 0 while the project is still in /etc/{projid,projects}removes the project from metadata. After that it can be removed from /etc/{projid,projects}.

xfs_quota -x -c 'limit -p bsoft=0 bhard=0 foo' /path

I came across this by chance.

Patrick Mevzek
  • 9,921
  • 7
  • 32
  • 43
mathrock
  • 66
  • 1
  • Since the project was already removed from /etc/projid, I had to recreate a name:number line in projid before I could set the limit to 0. It was not necessary to add a line into /etc/projects. – exore Jun 29 '18 at 20:52
  • I had trouble removing project quota entries, quota names would still be printed in quota report after setting bsoft=0 and bhard=0, turns out the system also have inode limits set so I also have to set isoft=0 and ihard=0. – Angelos Jan 07 '22 at 07:17
1

It seems you'd need to switch the quota off before you could do that:

remove [ -gpu ] [ -v ]

Remove any space allocated to quota metadata from the filesystem identified by the current path. Quota must not be enabled on the filesystem, else this operation will report an error.

You could try disable first, but I'm afraid you'd need to use off.

disable [ -gpu ] [ -v ]

Disables quota enforcement, while leaving quota accounting active. The -v option (verbose) displays the state after the operation has completed.

off [ -gpu ] [ -v ]

Permanently switches quota off for the filesystem identified by the current path. Quota can only be switched back on subsequently by unmounting and then mounting again.

As you said, it's possible to set the quota again when the ID is reused, so this is not a real problem. Permanently switching off the quota seems like burning down a house to kill a rat.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
  • The problem is that the remove commands suppresses all metadata information from the filesystem. If used, limits for other projects are lost, and, since it cannot be used while quotas are on, an unmount and a fresh mount is necessary to get quota back on. So while this answers strictly answers the question, il does not answer the implied question : "How can I tell xfs that it does not need anymore to keep track of project id 2 without perturbing other projects and without beeing forced to umount the FS ?" – exore Jun 24 '18 at 13:59
  • I understand. For that it seems, unfortunately, you can't. – Esa Jokinen Jun 24 '18 at 15:14
-1

You should use xfs_quota -x -c "project -C foo" /path to clear the directory tree at first. Then use xfs_quota -x -c "off -up" /path and xfs_quota -x -c "remove -p" /path to remove the quota metadata.

Pay attention that this operation will delete all project quota limitation.