xfsprogs: xfs_quota: a few fixes
cover xfsprogs: xfs_quota: a few fixes
The main problem solved in this series is that for project quotas, the numbers of blocks reported by the xfs_quota "df" subcommand is twice what it should be. While looking at this I also noticed two other problems that I corrected.
Below is a script that demonstrates the problem.
-Alex
#!/bin/bash
############################################################
# Note that the following clobbers whatever is on /dev/sdk # It also clobbers files /etc/project and /etc/projid. # And it uses and then removes /qmnt.
############################################################
# Initialize the filesystem and mount it with project quotas mkfs.xfs -f /dev/sdk
mkdir -p /qmnt
mount -t xfs -o prjquota /dev/sdk /qmnt
# Set up the project quota configuration files
echo test:1 > /etc/projid
echo 1:/qmnt/test > /etc/projects
# Make the top-level directory, set up quotas on it mkdir /qmnt/testxfs_quota -x -c 'project -s test' /qmnt
# Assign block quota limitsxfs_quota -x -c 'limit -p bsoft=500m bhard=500m test' /qmnt
# The "report" command will show the right numbers xfs_quota -x -c report /qmnt
# But the "df" command will show doubled block counts xfs_quota -x -c df /qmnt
# This time using "human readable" outputxfs_quota -x -c 'report -h' /qmntxfs_quota -x -c 'df -h' /qmnt
# Clean up
umount /qmnt
rmdir /qmnt
rm /etc/projid /etc/projects
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/3 xfsprogs: xfs_quota: return real-time used data as intended
In projects_free_space_data() the real-time used space consumption is never set. Instead, that value is returned in the field that should hold the quota limit.
Found by inspection. Never seen/noticed because we currently don't support quotas when a filesystem has a realtime volume.
--- quota/free.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
quota/free.c +3 -1
@@ -177,16 +177,18 @@ projects_free_space_data( *bfree = (d.d_blk_softlimit - d.d_bcount) <<1 ; } *bused = d.d_bcount <<1 ; +if (d.d_ino_softlimit) { *icount = d.d_ino_softlimit; *ifree = (d.d_ino_softlimit - d.d_icount); } *iused = d.d_icount; +if (d.d_rtb_softlimit) { *rcount = d.d_rtb_softlimit <<1 ; *rfree = (d.d_rtb_softlimit - d.d_rtbcount) <<1 ; } - *rcount = d.d_rtbcount <<1 ; + *rused = d.d_rtbcount <<1 ;close (fd);return 1 ;
Signature · 6 lines
1.7.6 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended
Quoted 6 lines · Alex Elder
In
projects_free_space_data()the real-time used space consumption is never set. Instead, that value is returned in the field that should hold the quota limit.Found by inspection. Never seen/noticed because we currently don't support quotas when a filesystem has a realtime volume.
Looks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/3 xfsprogs: xfs_quota: don't double project block counts
In reply to Alex ElderIn projects_free_space_data() all of the block counts returned are doubled. This was probably a mistaken attempt to convert to or from 512-byte basic block units. The caller expects the value returned to be in 512-byte units, which is exactly what the fs_disk_quota structure holds, so there should be no doubling.
The effect of this bug is that the disk space used by the "df" xfs_quota command shows block counts twice what they should be.
SGI PV 1015651
--- quota/free.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-)
quota/free.c +14 -6
@@ -41,6 +41,10 @@ free_help(void) "\n")); } +/* +* The data and realtime block counts returned (count, used, and +* free) are all in basic block units. +*/ static int mount_free_space_data( struct fs_path *mount,
@@ -104,6 +108,10 @@ mount_free_space_data(return 1 ; } +/* +* The data and realtime block counts returned (count, used, and +* free) are all in basic block units. +*/ static int projects_free_space_data( struct fs_path *path,
@@ -173,10 +181,10 @@ projects_free_space_data( }if (d.d_blk_softlimit) { - *bcount = d.d_blk_softlimit <<1 ; - *bfree = (d.d_blk_softlimit - d.d_bcount) <<1 ; + *bcount = d.d_blk_softlimit; + *bfree = (d.d_blk_softlimit - d.d_bcount); } - *bused = d.d_bcount <<1 ; + *bused = d.d_bcount;if (d.d_ino_softlimit) { *icount = d.d_ino_softlimit;
@@ -185,10 +193,10 @@ projects_free_space_data( *iused = d.d_icount;if (d.d_rtb_softlimit) { - *rcount = d.d_rtb_softlimit <<1 ; - *rfree = (d.d_rtb_softlimit - d.d_rtbcount) <<1 ; + *rcount = d.d_rtb_softlimit; + *rfree = (d.d_rtb_softlimit - d.d_rtbcount); } - *rused = d.d_rtbcount <<1 ; + *rused = d.d_rtbcount;close (fd);return 1 ;
Signature · 6 lines
1.7.6 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts
Quoted 6 lines · Alex Elder
In
projects_free_space_data()all of the block counts returned are doubled. This was probably a mistaken attempt to convert to or from 512-byte basic block units. The caller expects the value returned to be in 512-byte units, which is exactly what thefs_disk_quotastructure holds, so there should be no doubling.
Quoted 6 lines
The effect of this bug is that the disk space used by the "df"
xfs_quotacommand shows block counts twice what they should be.SGI PV 1015651
Signed-off-by Alex Elder <[email protected]>
Looks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/3 xfsprogs: xfs_quota: improve calculation for percentage display
In reply to Alex ElderThe pct_to_string() function determines the percentage it produces in a strange way. Simplify the function, and make it return the simple rounded percentage value. Handle the case of an error return from snprintf() as well.
--- quota/util.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
quota/util.c +10 -10
@@ -172,18 +172,18 @@ num_to_string(char *pct_to_string ( -__uint64_t v, -__uint64_t t, -char *sp, +__uint64_t portion, +__uint64_t whole, +char *buf,uint size) { -if (t ==0 || v ==0 ) -snprintf (sp, size,"%3u" , (uint )0 ); -else if (t == v) -snprintf (sp, size,"%3u" , (uint )100 ); -else -snprintf (sp, size,"%3u" , (uint)(((double )v / t) *100 +1 )); -return sp; +uint percent; + + percent = whole ? (uint) (100.0 * portion / whole +0.5 ) :0 ; +if (snprintf (buf, size,"%3u" , percent) <0 ) +return "???" ; + +return buf; } char *
Signature · 6 lines
1.7.6 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 3/3] xfsprogs: xfs_quota: improve calculation for percentage display
Quoted 4 lines · Alex Elder
The
pct_to_string()function determines the percentage it produces in a strange way. Simplify the function, and make it return the simple rounded percentage value. Handle the case of an error return fromsnprintf()as well.
Looks fine,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Alex Elder
The main problem solved in this series is that for project quotas, the numbers of blocks reported by the
xfs_quota"df" subcommand is twice what it should be. While looking at this I also noticed two other problems that I corrected.Below is a script that demonstrates the problem.
This script should be turned into an xfsqa testcase.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Alex Elder
The main problem solved in this series is that for project quotas, the numbers of blocks reported by the
xfs_quota"df" subcommand is twice what it should be. While looking at this I also noticed two other problems that I corrected.Below is a script that demonstrates the problem.
This script should be turned into an xfsqa testcase.
I knew someone would say that (but was hoping
I would not hear it)...
I will do it.
-Alex
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs