linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] quota: fill in Q_XGETQSTAT inode information for inactive quotas
@ 2016-08-12 22:40 Eric Sandeen
  2016-08-15  8:44 ` Jan Kara
  2016-08-15 13:51 ` Bill O'Donnell
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Sandeen @ 2016-08-12 22:40 UTC (permalink / raw)
  To: fsdevel, Jan Kara

The manpage for quotactl says that the Q_XGETQSTAT command is
"useful in finding out how much space is spent to store quota
information," but the current implementation does not report this
info if the inode is allocated, but its quota type is not enabled.

This is a change from the earlier XFS implementation, which
reported information about allocated quota inodes even if their
quota type was not currently active.

Change quota_getstate() and quota_getstatev() to copy out the inode
information if the filesystem has provided it, even if the quota
type for that inode is not currently active.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 0f10ee9..ec8f13f 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -341,6 +341,7 @@ static int quota_getstate(struct super_block *sb, struct fs_quota_stat *fqs)
 	struct qc_state state;
 	int ret;
 
+	memset(&state, 0, sizeof (struct qc_state));
 	ret = sb->s_qcop->get_state(sb, &state);
 	if (ret < 0)
 		return ret;
@@ -365,17 +366,19 @@ static int quota_getstate(struct super_block *sb, struct fs_quota_stat *fqs)
 	fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit;
 	fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit;
 	fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit;
-	if (state.s_state[USRQUOTA].flags & QCI_ACCT_ENABLED) {
+
+	/* Inodes may be allocated even if inactive; copy out if present */
+	if (state.s_state[USRQUOTA].ino) {
 		fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA].ino;
 		fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA].blocks;
 		fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA].nextents;
 	}
-	if (state.s_state[GRPQUOTA].flags & QCI_ACCT_ENABLED) {
+	if (state.s_state[GRPQUOTA].ino) {
 		fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA].ino;
 		fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA].blocks;
 		fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA].nextents;
 	}
-	if (state.s_state[PRJQUOTA].flags & QCI_ACCT_ENABLED) {
+	if (state.s_state[PRJQUOTA].ino) {
 		/*
 		 * Q_XGETQSTAT doesn't have room for both group and project
 		 * quotas.  So, allow the project quota values to be copied out
@@ -411,6 +414,7 @@ static int quota_getstatev(struct super_block *sb, struct fs_quota_statv *fqs)
 	struct qc_state state;
 	int ret;
 
+	memset(&state, 0, sizeof (struct qc_state));
 	ret = sb->s_qcop->get_state(sb, &state);
 	if (ret < 0)
 		return ret;
@@ -435,17 +439,19 @@ static int quota_getstatev(struct super_block *sb, struct fs_quota_statv *fqs)
 	fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit;
 	fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit;
 	fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit;
-	if (state.s_state[USRQUOTA].flags & QCI_ACCT_ENABLED) {
+
+	/* Inodes may be allocated even if inactive; copy out if present */
+	if (state.s_state[USRQUOTA].ino) {
 		fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA].ino;
 		fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA].blocks;
 		fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA].nextents;
 	}
-	if (state.s_state[GRPQUOTA].flags & QCI_ACCT_ENABLED) {
+	if (state.s_state[GRPQUOTA].ino) {
 		fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA].ino;
 		fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA].blocks;
 		fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA].nextents;
 	}
-	if (state.s_state[PRJQUOTA].flags & QCI_ACCT_ENABLED) {
+	if (state.s_state[PRJQUOTA].ino) {
 		fqs->qs_pquota.qfs_ino = state.s_state[PRJQUOTA].ino;
 		fqs->qs_pquota.qfs_nblks = state.s_state[PRJQUOTA].blocks;
 		fqs->qs_pquota.qfs_nextents = state.s_state[PRJQUOTA].nextents;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] quota: fill in Q_XGETQSTAT inode information for inactive quotas
  2016-08-12 22:40 [PATCH] quota: fill in Q_XGETQSTAT inode information for inactive quotas Eric Sandeen
@ 2016-08-15  8:44 ` Jan Kara
  2016-08-15 13:51 ` Bill O'Donnell
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2016-08-15  8:44 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: fsdevel, Jan Kara

On Fri 12-08-16 17:40:09, Eric Sandeen wrote:
> The manpage for quotactl says that the Q_XGETQSTAT command is
> "useful in finding out how much space is spent to store quota
> information," but the current implementation does not report this
> info if the inode is allocated, but its quota type is not enabled.
> 
> This is a change from the earlier XFS implementation, which
> reported information about allocated quota inodes even if their
> quota type was not currently active.
> 
> Change quota_getstate() and quota_getstatev() to copy out the inode
> information if the filesystem has provided it, even if the quota
> type for that inode is not currently active.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Thanks. I've added this patch to my tree.

								Honza

> ---
> 
> diff --git a/fs/quota/quota.c b/fs/quota/quota.c
> index 0f10ee9..ec8f13f 100644
> --- a/fs/quota/quota.c
> +++ b/fs/quota/quota.c
> @@ -341,6 +341,7 @@ static int quota_getstate(struct super_block *sb, struct fs_quota_stat *fqs)
>  	struct qc_state state;
>  	int ret;
>  
> +	memset(&state, 0, sizeof (struct qc_state));
>  	ret = sb->s_qcop->get_state(sb, &state);
>  	if (ret < 0)
>  		return ret;
> @@ -365,17 +366,19 @@ static int quota_getstate(struct super_block *sb, struct fs_quota_stat *fqs)
>  	fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit;
>  	fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit;
>  	fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit;
> -	if (state.s_state[USRQUOTA].flags & QCI_ACCT_ENABLED) {
> +
> +	/* Inodes may be allocated even if inactive; copy out if present */
> +	if (state.s_state[USRQUOTA].ino) {
>  		fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA].ino;
>  		fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA].blocks;
>  		fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA].nextents;
>  	}
> -	if (state.s_state[GRPQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[GRPQUOTA].ino) {
>  		fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA].ino;
>  		fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA].blocks;
>  		fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA].nextents;
>  	}
> -	if (state.s_state[PRJQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[PRJQUOTA].ino) {
>  		/*
>  		 * Q_XGETQSTAT doesn't have room for both group and project
>  		 * quotas.  So, allow the project quota values to be copied out
> @@ -411,6 +414,7 @@ static int quota_getstatev(struct super_block *sb, struct fs_quota_statv *fqs)
>  	struct qc_state state;
>  	int ret;
>  
> +	memset(&state, 0, sizeof (struct qc_state));
>  	ret = sb->s_qcop->get_state(sb, &state);
>  	if (ret < 0)
>  		return ret;
> @@ -435,17 +439,19 @@ static int quota_getstatev(struct super_block *sb, struct fs_quota_statv *fqs)
>  	fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit;
>  	fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit;
>  	fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit;
> -	if (state.s_state[USRQUOTA].flags & QCI_ACCT_ENABLED) {
> +
> +	/* Inodes may be allocated even if inactive; copy out if present */
> +	if (state.s_state[USRQUOTA].ino) {
>  		fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA].ino;
>  		fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA].blocks;
>  		fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA].nextents;
>  	}
> -	if (state.s_state[GRPQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[GRPQUOTA].ino) {
>  		fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA].ino;
>  		fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA].blocks;
>  		fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA].nextents;
>  	}
> -	if (state.s_state[PRJQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[PRJQUOTA].ino) {
>  		fqs->qs_pquota.qfs_ino = state.s_state[PRJQUOTA].ino;
>  		fqs->qs_pquota.qfs_nblks = state.s_state[PRJQUOTA].blocks;
>  		fqs->qs_pquota.qfs_nextents = state.s_state[PRJQUOTA].nextents;
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] quota: fill in Q_XGETQSTAT inode information for inactive quotas
  2016-08-12 22:40 [PATCH] quota: fill in Q_XGETQSTAT inode information for inactive quotas Eric Sandeen
  2016-08-15  8:44 ` Jan Kara
@ 2016-08-15 13:51 ` Bill O'Donnell
  1 sibling, 0 replies; 3+ messages in thread
From: Bill O'Donnell @ 2016-08-15 13:51 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: fsdevel, Jan Kara

On Fri, Aug 12, 2016 at 05:40:09PM -0500, Eric Sandeen wrote:
> The manpage for quotactl says that the Q_XGETQSTAT command is
> "useful in finding out how much space is spent to store quota
> information," but the current implementation does not report this
> info if the inode is allocated, but its quota type is not enabled.
> 
> This is a change from the earlier XFS implementation, which
> reported information about allocated quota inodes even if their
> quota type was not currently active.
> 
> Change quota_getstate() and quota_getstatev() to copy out the inode
> information if the filesystem has provided it, even if the quota
> type for that inode is not currently active.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Reviewed-by: Bill O'Donnell <billodo@redhat.com>

> ---
> 
> diff --git a/fs/quota/quota.c b/fs/quota/quota.c
> index 0f10ee9..ec8f13f 100644
> --- a/fs/quota/quota.c
> +++ b/fs/quota/quota.c
> @@ -341,6 +341,7 @@ static int quota_getstate(struct super_block *sb, struct fs_quota_stat *fqs)
>  	struct qc_state state;
>  	int ret;
>  
> +	memset(&state, 0, sizeof (struct qc_state));
>  	ret = sb->s_qcop->get_state(sb, &state);
>  	if (ret < 0)
>  		return ret;
> @@ -365,17 +366,19 @@ static int quota_getstate(struct super_block *sb, struct fs_quota_stat *fqs)
>  	fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit;
>  	fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit;
>  	fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit;
> -	if (state.s_state[USRQUOTA].flags & QCI_ACCT_ENABLED) {
> +
> +	/* Inodes may be allocated even if inactive; copy out if present */
> +	if (state.s_state[USRQUOTA].ino) {
>  		fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA].ino;
>  		fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA].blocks;
>  		fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA].nextents;
>  	}
> -	if (state.s_state[GRPQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[GRPQUOTA].ino) {
>  		fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA].ino;
>  		fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA].blocks;
>  		fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA].nextents;
>  	}
> -	if (state.s_state[PRJQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[PRJQUOTA].ino) {
>  		/*
>  		 * Q_XGETQSTAT doesn't have room for both group and project
>  		 * quotas.  So, allow the project quota values to be copied out
> @@ -411,6 +414,7 @@ static int quota_getstatev(struct super_block *sb, struct fs_quota_statv *fqs)
>  	struct qc_state state;
>  	int ret;
>  
> +	memset(&state, 0, sizeof (struct qc_state));
>  	ret = sb->s_qcop->get_state(sb, &state);
>  	if (ret < 0)
>  		return ret;
> @@ -435,17 +439,19 @@ static int quota_getstatev(struct super_block *sb, struct fs_quota_statv *fqs)
>  	fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit;
>  	fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit;
>  	fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit;
> -	if (state.s_state[USRQUOTA].flags & QCI_ACCT_ENABLED) {
> +
> +	/* Inodes may be allocated even if inactive; copy out if present */
> +	if (state.s_state[USRQUOTA].ino) {
>  		fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA].ino;
>  		fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA].blocks;
>  		fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA].nextents;
>  	}
> -	if (state.s_state[GRPQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[GRPQUOTA].ino) {
>  		fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA].ino;
>  		fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA].blocks;
>  		fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA].nextents;
>  	}
> -	if (state.s_state[PRJQUOTA].flags & QCI_ACCT_ENABLED) {
> +	if (state.s_state[PRJQUOTA].ino) {
>  		fqs->qs_pquota.qfs_ino = state.s_state[PRJQUOTA].ino;
>  		fqs->qs_pquota.qfs_nblks = state.s_state[PRJQUOTA].blocks;
>  		fqs->qs_pquota.qfs_nextents = state.s_state[PRJQUOTA].nextents;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" 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] 3+ messages in thread

end of thread, other threads:[~2016-08-15 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-12 22:40 [PATCH] quota: fill in Q_XGETQSTAT inode information for inactive quotas Eric Sandeen
2016-08-15  8:44 ` Jan Kara
2016-08-15 13:51 ` 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).