* [PATCH] xfs_quota: fix free command for foreign fs
@ 2016-09-15 23:23 Eric Sandeen
2016-09-16 13:32 ` Bill O'Donnell
0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2016-09-15 23:23 UTC (permalink / raw)
To: xfs-oss, linux-xfs
The "free" command is really just a fancy df that knows about
log space and realtime blocks for an xfs filesystem.
We can simply use statfs to get more or less the same thing
on a non-xfs filesystem, so, ah, do that I guess, and re-enable
it.
# quota/xfs_quota -f -x -c path -c free /mnt/test
Filesystem Pathname
[000] (F) /mnt/test /dev/sdb1 (uquota)
Filesystem 1K-blocks Used Available Use% Pathname
/dev/sdb1 20511356 45000 20466356 0% /mnt/test
Fix the short help text for -N while we're at it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/quota/free.c b/quota/free.c
index 3c8a5ce..cee15ee 100644
--- a/quota/free.c
+++ b/quota/free.c
@@ -77,34 +77,50 @@ mount_free_space_data(
close(fd);
return 0;
}
- if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSGEOMETRY_V1, &fsgeo)) < 0) {
- perror("XFS_IOC_FSGEOMETRY_V1");
- close(fd);
- return 0;
- }
- if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSCOUNTS, &fscounts)) < 0) {
- perror("XFS_IOC_FSCOUNTS");
- close(fd);
- return 0;
+
+ if (!(mount->fs_flags & FS_FOREIGN)) {
+ if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSGEOMETRY_V1,
+ &fsgeo)) < 0) {
+ perror("XFS_IOC_FSGEOMETRY_V1");
+ close(fd);
+ return 0;
+ }
+ if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSCOUNTS,
+ &fscounts)) < 0) {
+ perror("XFS_IOC_FSCOUNTS");
+ close(fd);
+ return 0;
+ }
+
+ logsize = fsgeo.logstart ? fsgeo.logblocks : 0;
+ count = (fsgeo.datablocks - logsize) * fsgeo.blocksize;
+ free = fscounts.freedata * fsgeo.blocksize;
+ *bcount = BTOBB(count);
+ *bfree = BTOBB(free);
+ *bused = BTOBB(count - free);
+
+ count = fsgeo.rtextents * fsgeo.rtextsize * fsgeo.blocksize;
+ free = fscounts.freertx * fsgeo.rtextsize * fsgeo.blocksize;
+ *rcount = BTOBB(count);
+ *rfree = BTOBB(free);
+ *rused = BTOBB(count - free);
+ } else {
+ count = st.f_blocks * st.f_bsize;
+ free = st.f_bfree * st.f_bsize;
+ *bcount = BTOBB(count);
+ *bfree = BTOBB(free);
+ *bused = BTOBB(count - free);
+
+ *rcount = BTOBB(0);
+ *rfree = BTOBB(0);
+ *rused = BTOBB(0);
}
- logsize = fsgeo.logstart ? fsgeo.logblocks : 0;
- count = (fsgeo.datablocks - logsize) * fsgeo.blocksize;
- free = fscounts.freedata * fsgeo.blocksize;
- *bcount = BTOBB(count);
- *bfree = BTOBB(free);
- *bused = BTOBB(count - free);
*icount = st.f_files;
*ifree = st.f_ffree;
*iused = st.f_files - st.f_ffree;
- count = fsgeo.rtextents * fsgeo.rtextsize * fsgeo.blocksize;
- free = fscounts.freertx * fsgeo.rtextsize * fsgeo.blocksize;
- *rcount = BTOBB(count);
- *rfree = BTOBB(free);
- *rused = BTOBB(count - free);
-
close(fd);
return 1;
}
@@ -369,9 +385,10 @@ free_init(void)
free_cmd.cfunc = free_f;
free_cmd.argmin = 0;
free_cmd.argmax = -1;
- free_cmd.args = _("[-bir] [-hn] [-f file]");
+ free_cmd.args = _("[-bir] [-hN] [-f file]");
free_cmd.oneline = _("show free and used counts for blocks and inodes");
free_cmd.help = free_help;
+ free_cmd.flags = CMD_FLAG_FOREIGN_OK;
add_command(&free_cmd);
}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs_quota: fix free command for foreign fs
2016-09-15 23:23 [PATCH] xfs_quota: fix free command for foreign fs Eric Sandeen
@ 2016-09-16 13:32 ` Bill O'Donnell
0 siblings, 0 replies; 2+ messages in thread
From: Bill O'Donnell @ 2016-09-16 13:32 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs-oss, linux-xfs
On Thu, Sep 15, 2016 at 06:23:58PM -0500, Eric Sandeen wrote:
> The "free" command is really just a fancy df that knows about
> log space and realtime blocks for an xfs filesystem.
>
> We can simply use statfs to get more or less the same thing
> on a non-xfs filesystem, so, ah, do that I guess, and re-enable
> it.
>
> # quota/xfs_quota -f -x -c path -c free /mnt/test
> Filesystem Pathname
> [000] (F) /mnt/test /dev/sdb1 (uquota)
>
> Filesystem 1K-blocks Used Available Use% Pathname
> /dev/sdb1 20511356 45000 20466356 0% /mnt/test
>
> Fix the short help text for -N while we're at it.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
> ---
>
> diff --git a/quota/free.c b/quota/free.c
> index 3c8a5ce..cee15ee 100644
> --- a/quota/free.c
> +++ b/quota/free.c
> @@ -77,34 +77,50 @@ mount_free_space_data(
> close(fd);
> return 0;
> }
> - if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSGEOMETRY_V1, &fsgeo)) < 0) {
> - perror("XFS_IOC_FSGEOMETRY_V1");
> - close(fd);
> - return 0;
> - }
> - if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSCOUNTS, &fscounts)) < 0) {
> - perror("XFS_IOC_FSCOUNTS");
> - close(fd);
> - return 0;
> +
> + if (!(mount->fs_flags & FS_FOREIGN)) {
> + if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSGEOMETRY_V1,
> + &fsgeo)) < 0) {
> + perror("XFS_IOC_FSGEOMETRY_V1");
> + close(fd);
> + return 0;
> + }
> + if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSCOUNTS,
> + &fscounts)) < 0) {
> + perror("XFS_IOC_FSCOUNTS");
> + close(fd);
> + return 0;
> + }
> +
> + logsize = fsgeo.logstart ? fsgeo.logblocks : 0;
> + count = (fsgeo.datablocks - logsize) * fsgeo.blocksize;
> + free = fscounts.freedata * fsgeo.blocksize;
> + *bcount = BTOBB(count);
> + *bfree = BTOBB(free);
> + *bused = BTOBB(count - free);
> +
> + count = fsgeo.rtextents * fsgeo.rtextsize * fsgeo.blocksize;
> + free = fscounts.freertx * fsgeo.rtextsize * fsgeo.blocksize;
> + *rcount = BTOBB(count);
> + *rfree = BTOBB(free);
> + *rused = BTOBB(count - free);
> + } else {
> + count = st.f_blocks * st.f_bsize;
> + free = st.f_bfree * st.f_bsize;
> + *bcount = BTOBB(count);
> + *bfree = BTOBB(free);
> + *bused = BTOBB(count - free);
> +
> + *rcount = BTOBB(0);
> + *rfree = BTOBB(0);
> + *rused = BTOBB(0);
> }
>
> - logsize = fsgeo.logstart ? fsgeo.logblocks : 0;
> - count = (fsgeo.datablocks - logsize) * fsgeo.blocksize;
> - free = fscounts.freedata * fsgeo.blocksize;
> - *bcount = BTOBB(count);
> - *bfree = BTOBB(free);
> - *bused = BTOBB(count - free);
>
> *icount = st.f_files;
> *ifree = st.f_ffree;
> *iused = st.f_files - st.f_ffree;
>
> - count = fsgeo.rtextents * fsgeo.rtextsize * fsgeo.blocksize;
> - free = fscounts.freertx * fsgeo.rtextsize * fsgeo.blocksize;
> - *rcount = BTOBB(count);
> - *rfree = BTOBB(free);
> - *rused = BTOBB(count - free);
> -
> close(fd);
> return 1;
> }
> @@ -369,9 +385,10 @@ free_init(void)
> free_cmd.cfunc = free_f;
> free_cmd.argmin = 0;
> free_cmd.argmax = -1;
> - free_cmd.args = _("[-bir] [-hn] [-f file]");
> + free_cmd.args = _("[-bir] [-hN] [-f file]");
> free_cmd.oneline = _("show free and used counts for blocks and inodes");
> free_cmd.help = free_help;
> + free_cmd.flags = CMD_FLAG_FOREIGN_OK;
>
> add_command(&free_cmd);
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-16 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-15 23:23 [PATCH] xfs_quota: fix free command for foreign fs Eric Sandeen
2016-09-16 13:32 ` Bill O'Donnell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).