I can see one issue but i don't know which would be the way to correct this:
chxid -URx -c "$1" "$DIRECTORY";
is done AFTER the usage is recorded with USED_SPACE=$(vdu --xid
"$1" --space "$DIRECTORY" | cut -d" " -f2); so we will miss the
file that would have been tagged by the chxid and therefor be inacurate.
But if i do the reverse and that the tagged files exceed the limit
then i will make the guest crash as it will not be able to write any
files to this directory and if this directory is the root or any system
important directory we can loose data. Then to get accurate result you
will need to run it two times and be ready in case of warning to quickly
do something about it.