* [PATCH 0/3] xfsprogs: xfs_quota: a few fixes @ 2011-08-24 21:53 Alex Elder 2011-08-24 21:53 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Alex Elder 2011-08-25 4:58 ` [PATCH 0/3] xfsprogs: xfs_quota: a few fixes Christoph Hellwig 0 siblings, 2 replies; 9+ messages in thread From: Alex Elder @ 2011-08-24 21:53 UTC (permalink / raw) To: xfs 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/test xfs_quota -x -c 'project -s test' /qmnt # Assign block quota limits xfs_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" output xfs_quota -x -c 'report -h' /qmnt xfs_quota -x -c 'df -h' /qmnt # Clean up umount /qmnt rmdir /qmnt rm /etc/projid /etc/projects _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended 2011-08-24 21:53 [PATCH 0/3] xfsprogs: xfs_quota: a few fixes Alex Elder @ 2011-08-24 21:53 ` Alex Elder 2011-08-24 21:53 ` [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts Alex Elder ` (2 more replies) 2011-08-25 4:58 ` [PATCH 0/3] xfsprogs: xfs_quota: a few fixes Christoph Hellwig 1 sibling, 3 replies; 9+ messages in thread From: Alex Elder @ 2011-08-24 21:53 UTC (permalink / raw) To: xfs; +Cc: 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. Signed-off-by: Alex Elder <aelder@sgi.com> --- quota/free.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/quota/free.c b/quota/free.c index 825ce34..26ec293 100644 --- a/quota/free.c +++ b/quota/free.c @@ -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; -- 1.7.6 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts 2011-08-24 21:53 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Alex Elder @ 2011-08-24 21:53 ` Alex Elder 2011-08-25 5:01 ` Christoph Hellwig 2011-08-24 21:53 ` [PATCH 3/3] xfsprogs: xfs_quota: improve calculation for percentage display Alex Elder 2011-08-25 4:59 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Christoph Hellwig 2 siblings, 1 reply; 9+ messages in thread From: Alex Elder @ 2011-08-24 21:53 UTC (permalink / raw) To: xfs; +Cc: 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 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 Signed-off-by: Alex Elder <aelder@sgi.com> --- quota/free.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/quota/free.c b/quota/free.c index 26ec293..71a7cb2 100644 --- a/quota/free.c +++ b/quota/free.c @@ -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; -- 1.7.6 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts 2011-08-24 21:53 ` [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts Alex Elder @ 2011-08-25 5:01 ` Christoph Hellwig 0 siblings, 0 replies; 9+ messages in thread From: Christoph Hellwig @ 2011-08-25 5:01 UTC (permalink / raw) To: Alex Elder; +Cc: xfs On Wed, Aug 24, 2011 at 04:53:42PM -0500, Alex Elder wrote: > 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 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 > > Signed-off-by: Alex Elder <aelder@sgi.com> Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de> _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] xfsprogs: xfs_quota: improve calculation for percentage display 2011-08-24 21:53 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Alex Elder 2011-08-24 21:53 ` [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts Alex Elder @ 2011-08-24 21:53 ` Alex Elder 2011-08-25 5:02 ` Christoph Hellwig 2011-08-25 4:59 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Christoph Hellwig 2 siblings, 1 reply; 9+ messages in thread From: Alex Elder @ 2011-08-24 21:53 UTC (permalink / raw) To: xfs; +Cc: 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 from snprintf() as well. Signed-off-by: Alex Elder <aelder@sgi.com> --- quota/util.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/quota/util.c b/quota/util.c index 18ccae2..179aafd 100644 --- a/quota/util.c +++ b/quota/util.c @@ -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 * -- 1.7.6 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] xfsprogs: xfs_quota: improve calculation for percentage display 2011-08-24 21:53 ` [PATCH 3/3] xfsprogs: xfs_quota: improve calculation for percentage display Alex Elder @ 2011-08-25 5:02 ` Christoph Hellwig 0 siblings, 0 replies; 9+ messages in thread From: Christoph Hellwig @ 2011-08-25 5:02 UTC (permalink / raw) To: Alex Elder; +Cc: xfs On Wed, Aug 24, 2011 at 04:53:43PM -0500, Alex Elder wrote: > 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 from snprintf() as well. Looks fine, Reviewed-by: Christoph Hellwig <hch@lst.de> _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended 2011-08-24 21:53 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Alex Elder 2011-08-24 21:53 ` [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts Alex Elder 2011-08-24 21:53 ` [PATCH 3/3] xfsprogs: xfs_quota: improve calculation for percentage display Alex Elder @ 2011-08-25 4:59 ` Christoph Hellwig 2 siblings, 0 replies; 9+ messages in thread From: Christoph Hellwig @ 2011-08-25 4:59 UTC (permalink / raw) To: Alex Elder; +Cc: xfs On Wed, Aug 24, 2011 at 04:53:41PM -0500, Alex Elder wrote: > 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, Reviewed-by: Christoph Hellwig <hch@lst.de> _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] xfsprogs: xfs_quota: a few fixes 2011-08-24 21:53 [PATCH 0/3] xfsprogs: xfs_quota: a few fixes Alex Elder 2011-08-24 21:53 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Alex Elder @ 2011-08-25 4:58 ` Christoph Hellwig 2011-08-25 13:19 ` Alex Elder 1 sibling, 1 reply; 9+ messages in thread From: Christoph Hellwig @ 2011-08-25 4:58 UTC (permalink / raw) To: Alex Elder; +Cc: xfs On Wed, Aug 24, 2011 at 04:53:40PM -0500, Alex Elder wrote: > 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 xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] xfsprogs: xfs_quota: a few fixes 2011-08-25 4:58 ` [PATCH 0/3] xfsprogs: xfs_quota: a few fixes Christoph Hellwig @ 2011-08-25 13:19 ` Alex Elder 0 siblings, 0 replies; 9+ messages in thread From: Alex Elder @ 2011-08-25 13:19 UTC (permalink / raw) To: Christoph Hellwig; +Cc: xfs On Thu, 2011-08-25 at 00:58 -0400, Christoph Hellwig wrote: > On Wed, Aug 24, 2011 at 04:53:40PM -0500, Alex Elder wrote: > > 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 xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-08-25 13:19 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-08-24 21:53 [PATCH 0/3] xfsprogs: xfs_quota: a few fixes Alex Elder 2011-08-24 21:53 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Alex Elder 2011-08-24 21:53 ` [PATCH 2/3] xfsprogs: xfs_quota: don't double project block counts Alex Elder 2011-08-25 5:01 ` Christoph Hellwig 2011-08-24 21:53 ` [PATCH 3/3] xfsprogs: xfs_quota: improve calculation for percentage display Alex Elder 2011-08-25 5:02 ` Christoph Hellwig 2011-08-25 4:59 ` [PATCH 1/3] xfsprogs: xfs_quota: return real-time used data as intended Christoph Hellwig 2011-08-25 4:58 ` [PATCH 0/3] xfsprogs: xfs_quota: a few fixes Christoph Hellwig 2011-08-25 13:19 ` Alex Elder
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox