linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -v2 0/3] xfs: change available ranges in quota check
@ 2012-02-06 12:49 Mitsuo Hayasaka
  2012-02-06 12:50 ` [PATCH -v2 1/3] xfs: change available ranges of softlimit and hardlimit " Mitsuo Hayasaka
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mitsuo Hayasaka @ 2012-02-06 12:49 UTC (permalink / raw)
  To: Ben Myers, Alex Elder, Christoph Hellwig
  Cc: xfs-masters, xfs, linux-kernel, yrl.pp-manager.tt

Hi,

This patch series changes available ranges of softlimit and
hardlimit in quota check. Currently xfs quota allows us to
use disk blocks up to lower than quota limits. They should
be used up to not beyond them.

Thanks.

---

Mitsuo Hayasaka (3):
      xfs: cleanup quota check on disk blocks and inodes reservations
      xfs: make inode quota check more general
      xfs: change available ranges of softlimit and hardlimit in quota check


 fs/xfs/xfs_dquot.c       |   24 ++++++++++++------------
 fs/xfs/xfs_log_recover.c |    6 +++---
 fs/xfs/xfs_qm_syscalls.c |    4 ++--
 fs/xfs/xfs_trans_dquot.c |   15 +++++++--------
 4 files changed, 24 insertions(+), 25 deletions(-)

-- 
Mitsuo Hayasaka (mitsuo.hayasaka.hu@hitachi.com)

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

* [PATCH -v2 1/3] xfs: change available ranges of softlimit and hardlimit in quota check
  2012-02-06 12:49 [PATCH -v2 0/3] xfs: change available ranges in quota check Mitsuo Hayasaka
@ 2012-02-06 12:50 ` Mitsuo Hayasaka
  2012-02-15  2:32   ` Christoph Hellwig
  2012-02-06 12:50 ` [PATCH -v2 2/3] xfs: make inode quota check more general Mitsuo Hayasaka
  2012-02-06 12:51 ` [PATCH -v2 3/3] xfs: cleanup quota check on disk blocks and inodes reservations Mitsuo Hayasaka
  2 siblings, 1 reply; 7+ messages in thread
From: Mitsuo Hayasaka @ 2012-02-06 12:50 UTC (permalink / raw)
  To: Ben Myers, Alex Elder, Christoph Hellwig
  Cc: xfs-masters, xfs, linux-kernel, yrl.pp-manager.tt,
	Mitsuo Hayasaka, Ben Myers, Alex Elder, Christoph Hellwig

In general, quota allows us to use disk blocks and inodes up to each
limit, that is, they are available if they don't exceed their limitations.
Current xfs sets their available ranges to lower than them except disk
inode quota check. So, this patch changes the ranges to not beyond them.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Ben Myers <bpm@sgi.com>
Cc: Alex Elder <elder@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
---

 fs/xfs/xfs_dquot.c       |   24 ++++++++++++------------
 fs/xfs/xfs_log_recover.c |    6 +++---
 fs/xfs/xfs_qm_syscalls.c |    4 ++--
 fs/xfs/xfs_trans_dquot.c |    4 ++--
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index b4ff40b..307e4a3 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -215,10 +215,10 @@ xfs_qm_adjust_dqtimers(
 
 	if (!d->d_btimer) {
 		if ((d->d_blk_softlimit &&
-		     (be64_to_cpu(d->d_bcount) >=
+		     (be64_to_cpu(d->d_bcount) >
 		      be64_to_cpu(d->d_blk_softlimit))) ||
 		    (d->d_blk_hardlimit &&
-		     (be64_to_cpu(d->d_bcount) >=
+		     (be64_to_cpu(d->d_bcount) >
 		      be64_to_cpu(d->d_blk_hardlimit)))) {
 			d->d_btimer = cpu_to_be32(get_seconds() +
 					mp->m_quotainfo->qi_btimelimit);
@@ -227,10 +227,10 @@ xfs_qm_adjust_dqtimers(
 		}
 	} else {
 		if ((!d->d_blk_softlimit ||
-		     (be64_to_cpu(d->d_bcount) <
+		     (be64_to_cpu(d->d_bcount) <=
 		      be64_to_cpu(d->d_blk_softlimit))) &&
 		    (!d->d_blk_hardlimit ||
-		    (be64_to_cpu(d->d_bcount) <
+		    (be64_to_cpu(d->d_bcount) <=
 		     be64_to_cpu(d->d_blk_hardlimit)))) {
 			d->d_btimer = 0;
 		}
@@ -238,10 +238,10 @@ xfs_qm_adjust_dqtimers(
 
 	if (!d->d_itimer) {
 		if ((d->d_ino_softlimit &&
-		     (be64_to_cpu(d->d_icount) >=
+		     (be64_to_cpu(d->d_icount) >
 		      be64_to_cpu(d->d_ino_softlimit))) ||
 		    (d->d_ino_hardlimit &&
-		     (be64_to_cpu(d->d_icount) >=
+		     (be64_to_cpu(d->d_icount) >
 		      be64_to_cpu(d->d_ino_hardlimit)))) {
 			d->d_itimer = cpu_to_be32(get_seconds() +
 					mp->m_quotainfo->qi_itimelimit);
@@ -250,10 +250,10 @@ xfs_qm_adjust_dqtimers(
 		}
 	} else {
 		if ((!d->d_ino_softlimit ||
-		     (be64_to_cpu(d->d_icount) <
+		     (be64_to_cpu(d->d_icount) <=
 		      be64_to_cpu(d->d_ino_softlimit)))  &&
 		    (!d->d_ino_hardlimit ||
-		     (be64_to_cpu(d->d_icount) <
+		     (be64_to_cpu(d->d_icount) <=
 		      be64_to_cpu(d->d_ino_hardlimit)))) {
 			d->d_itimer = 0;
 		}
@@ -261,10 +261,10 @@ xfs_qm_adjust_dqtimers(
 
 	if (!d->d_rtbtimer) {
 		if ((d->d_rtb_softlimit &&
-		     (be64_to_cpu(d->d_rtbcount) >=
+		     (be64_to_cpu(d->d_rtbcount) >
 		      be64_to_cpu(d->d_rtb_softlimit))) ||
 		    (d->d_rtb_hardlimit &&
-		     (be64_to_cpu(d->d_rtbcount) >=
+		     (be64_to_cpu(d->d_rtbcount) >
 		      be64_to_cpu(d->d_rtb_hardlimit)))) {
 			d->d_rtbtimer = cpu_to_be32(get_seconds() +
 					mp->m_quotainfo->qi_rtbtimelimit);
@@ -273,10 +273,10 @@ xfs_qm_adjust_dqtimers(
 		}
 	} else {
 		if ((!d->d_rtb_softlimit ||
-		     (be64_to_cpu(d->d_rtbcount) <
+		     (be64_to_cpu(d->d_rtbcount) <=
 		      be64_to_cpu(d->d_rtb_softlimit))) &&
 		    (!d->d_rtb_hardlimit ||
-		     (be64_to_cpu(d->d_rtbcount) <
+		     (be64_to_cpu(d->d_rtbcount) <=
 		      be64_to_cpu(d->d_rtb_hardlimit)))) {
 			d->d_rtbtimer = 0;
 		}
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 541a508..d3ce9ad 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1981,7 +1981,7 @@ xfs_qm_dqcheck(
 
 	if (!errs && ddq->d_id) {
 		if (ddq->d_blk_softlimit &&
-		    be64_to_cpu(ddq->d_bcount) >=
+		    be64_to_cpu(ddq->d_bcount) >
 				be64_to_cpu(ddq->d_blk_softlimit)) {
 			if (!ddq->d_btimer) {
 				if (flags & XFS_QMOPT_DOWARN)
@@ -1992,7 +1992,7 @@ xfs_qm_dqcheck(
 			}
 		}
 		if (ddq->d_ino_softlimit &&
-		    be64_to_cpu(ddq->d_icount) >=
+		    be64_to_cpu(ddq->d_icount) >
 				be64_to_cpu(ddq->d_ino_softlimit)) {
 			if (!ddq->d_itimer) {
 				if (flags & XFS_QMOPT_DOWARN)
@@ -2003,7 +2003,7 @@ xfs_qm_dqcheck(
 			}
 		}
 		if (ddq->d_rtb_softlimit &&
-		    be64_to_cpu(ddq->d_rtbcount) >=
+		    be64_to_cpu(ddq->d_rtbcount) >
 				be64_to_cpu(ddq->d_rtb_softlimit)) {
 			if (!ddq->d_rtbtimer) {
 				if (flags & XFS_QMOPT_DOWARN)
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index eafbcff..711a86e 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -813,11 +813,11 @@ xfs_qm_export_dquot(
 	     (XFS_IS_OQUOTA_ENFORCED(mp) &&
 			(dst->d_flags & (FS_PROJ_QUOTA | FS_GROUP_QUOTA)))) &&
 	    dst->d_id != 0) {
-		if (((int) dst->d_bcount >= (int) dst->d_blk_softlimit) &&
+		if (((int) dst->d_bcount > (int) dst->d_blk_softlimit) &&
 		    (dst->d_blk_softlimit > 0)) {
 			ASSERT(dst->d_btimer != 0);
 		}
-		if (((int) dst->d_icount >= (int) dst->d_ino_softlimit) &&
+		if (((int) dst->d_icount > (int) dst->d_ino_softlimit) &&
 		    (dst->d_ino_softlimit > 0)) {
 			ASSERT(dst->d_itimer != 0);
 		}
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 4d00ee6..8525553 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -649,12 +649,12 @@ xfs_trans_dqresv(
 			 * nblks.
 			 */
 			if (hardlimit > 0ULL &&
-			    hardlimit <= nblks + *resbcountp) {
+			    hardlimit < nblks + *resbcountp) {
 				xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN);
 				goto error_return;
 			}
 			if (softlimit > 0ULL &&
-			    softlimit <= nblks + *resbcountp) {
+			    softlimit < nblks + *resbcountp) {
 				if ((timer != 0 && get_seconds() > timer) ||
 				    (warns != 0 && warns >= warnlimit)) {
 					xfs_quota_warn(mp, dqp,


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

* [PATCH -v2 2/3] xfs: make inode quota check more general
  2012-02-06 12:49 [PATCH -v2 0/3] xfs: change available ranges in quota check Mitsuo Hayasaka
  2012-02-06 12:50 ` [PATCH -v2 1/3] xfs: change available ranges of softlimit and hardlimit " Mitsuo Hayasaka
@ 2012-02-06 12:50 ` Mitsuo Hayasaka
  2012-02-15  2:32   ` Christoph Hellwig
  2012-02-06 12:51 ` [PATCH -v2 3/3] xfs: cleanup quota check on disk blocks and inodes reservations Mitsuo Hayasaka
  2 siblings, 1 reply; 7+ messages in thread
From: Mitsuo Hayasaka @ 2012-02-06 12:50 UTC (permalink / raw)
  To: Ben Myers, Alex Elder, Christoph Hellwig
  Cc: xfs-masters, xfs, linux-kernel, yrl.pp-manager.tt,
	Mitsuo Hayasaka, Ben Myers, Alex Elder, Christoph Hellwig

The xfs checks quota when reserving disk blocks and inodes. In the block
reservation, it checks if the total number of blocks including current
usage and new reservation exceed quota. In the inode reservation,
it checks using the total number of inodes including only current usage
without new reservation. However, this inode quota check works well
since the caller of xfs_trans_dquot() always sets the argument of the
number of new inode reservation to 1 or 0 and inode is reserved one by
one in current xfs.

To make it more general, this patch changes it to the same way as the
block quota check.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Ben Myers <bpm@sgi.com>
Cc: Alex Elder <elder@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
---

 fs/xfs/xfs_trans_dquot.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 8525553..c4ba366 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -677,11 +677,13 @@ xfs_trans_dqresv(
 			if (!softlimit)
 				softlimit = q->qi_isoftlimit;
 
-			if (hardlimit > 0ULL && count >= hardlimit) {
+			if (hardlimit > 0ULL &&
+			    hardlimit < ninos + count) {
 				xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN);
 				goto error_return;
 			}
-			if (softlimit > 0ULL && count >= softlimit) {
+			if (softlimit > 0ULL &&
+			    softlimit < ninos + count) {
 				if  ((timer != 0 && get_seconds() > timer) ||
 				     (warns != 0 && warns >= warnlimit)) {
 					xfs_quota_warn(mp, dqp,


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

* [PATCH -v2 3/3] xfs: cleanup quota check on disk blocks and inodes reservations
  2012-02-06 12:49 [PATCH -v2 0/3] xfs: change available ranges in quota check Mitsuo Hayasaka
  2012-02-06 12:50 ` [PATCH -v2 1/3] xfs: change available ranges of softlimit and hardlimit " Mitsuo Hayasaka
  2012-02-06 12:50 ` [PATCH -v2 2/3] xfs: make inode quota check more general Mitsuo Hayasaka
@ 2012-02-06 12:51 ` Mitsuo Hayasaka
  2012-02-15  2:33   ` Christoph Hellwig
  2 siblings, 1 reply; 7+ messages in thread
From: Mitsuo Hayasaka @ 2012-02-06 12:51 UTC (permalink / raw)
  To: Ben Myers, Alex Elder, Christoph Hellwig
  Cc: xfs-masters, xfs, linux-kernel, yrl.pp-manager.tt,
	Mitsuo Hayasaka, Ben Myers, Alex Elder, Christoph Hellwig

This patch is a cleanup of quota check on disk blocks and inodes
reservations, and changes it as follows.

(1) add a total_count variable to store the total number of
    current usages and new reservations for disk blocks and inodes,
    respectively.

(2) make it more readable to check if the local variables softlimit
    and hardlimit are positive. It has been changed as follows.
	    if (softlimit > 0ULL) -> if (softlimit)
	    if (hardlimit > 0ULL) -> if (hardlimit)
    This is because they are defined as xfs_qcnt_t which is unsigned.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Ben Myers <bpm@sgi.com>
Cc: Alex Elder <elder@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
---

 fs/xfs/xfs_trans_dquot.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index c4ba366..877fe63 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -605,7 +605,7 @@ xfs_trans_dqresv(
 	time_t		timer;
 	xfs_qwarncnt_t	warns;
 	xfs_qwarncnt_t	warnlimit;
-	xfs_qcnt_t	count;
+	xfs_qcnt_t	total_count;
 	xfs_qcnt_t	*resbcountp;
 	xfs_quotainfo_t	*q = mp->m_quotainfo;
 
@@ -648,13 +648,12 @@ xfs_trans_dqresv(
 			 * hardlimit or exceed the timelimit if we allocate
 			 * nblks.
 			 */
-			if (hardlimit > 0ULL &&
-			    hardlimit < nblks + *resbcountp) {
+			total_count = *resbcountp + nblks;
+			if (hardlimit && total_count > hardlimit) {
 				xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN);
 				goto error_return;
 			}
-			if (softlimit > 0ULL &&
-			    softlimit < nblks + *resbcountp) {
+			if (softlimit && total_count > softlimit) {
 				if ((timer != 0 && get_seconds() > timer) ||
 				    (warns != 0 && warns >= warnlimit)) {
 					xfs_quota_warn(mp, dqp,
@@ -666,7 +665,7 @@ xfs_trans_dqresv(
 			}
 		}
 		if (ninos > 0) {
-			count = be64_to_cpu(dqp->q_core.d_icount);
+			total_count = be64_to_cpu(dqp->q_core.d_icount) + ninos;
 			timer = be32_to_cpu(dqp->q_core.d_itimer);
 			warns = be16_to_cpu(dqp->q_core.d_iwarns);
 			warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit;
@@ -677,13 +676,11 @@ xfs_trans_dqresv(
 			if (!softlimit)
 				softlimit = q->qi_isoftlimit;
 
-			if (hardlimit > 0ULL &&
-			    hardlimit < ninos + count) {
+			if (hardlimit && total_count > hardlimit) {
 				xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN);
 				goto error_return;
 			}
-			if (softlimit > 0ULL &&
-			    softlimit < ninos + count) {
+			if (softlimit && total_count > softlimit) {
 				if  ((timer != 0 && get_seconds() > timer) ||
 				     (warns != 0 && warns >= warnlimit)) {
 					xfs_quota_warn(mp, dqp,


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

* Re: [PATCH -v2 1/3] xfs: change available ranges of softlimit and hardlimit in quota check
  2012-02-06 12:50 ` [PATCH -v2 1/3] xfs: change available ranges of softlimit and hardlimit " Mitsuo Hayasaka
@ 2012-02-15  2:32   ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2012-02-15  2:32 UTC (permalink / raw)
  To: Mitsuo Hayasaka
  Cc: Ben Myers, Alex Elder, Christoph Hellwig, Alex Elder,
	linux-kernel, xfs, xfs-masters, yrl.pp-manager.tt

On Mon, Feb 06, 2012 at 09:50:07PM +0900, Mitsuo Hayasaka wrote:
> In general, quota allows us to use disk blocks and inodes up to each
> limit, that is, they are available if they don't exceed their limitations.
> Current xfs sets their available ranges to lower than them except disk
> inode quota check. So, this patch changes the ranges to not beyond them.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH -v2 2/3] xfs: make inode quota check more general
  2012-02-06 12:50 ` [PATCH -v2 2/3] xfs: make inode quota check more general Mitsuo Hayasaka
@ 2012-02-15  2:32   ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2012-02-15  2:32 UTC (permalink / raw)
  To: Mitsuo Hayasaka
  Cc: Ben Myers, Alex Elder, Christoph Hellwig, Alex Elder,
	linux-kernel, xfs, xfs-masters, yrl.pp-manager.tt

On Mon, Feb 06, 2012 at 09:50:30PM +0900, Mitsuo Hayasaka wrote:
> The xfs checks quota when reserving disk blocks and inodes. In the block
> reservation, it checks if the total number of blocks including current
> usage and new reservation exceed quota. In the inode reservation,
> it checks using the total number of inodes including only current usage
> without new reservation. However, this inode quota check works well
> since the caller of xfs_trans_dquot() always sets the argument of the
> number of new inode reservation to 1 or 0 and inode is reserved one by
> one in current xfs.
> 
> To make it more general, this patch changes it to the same way as the
> block quota check.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH -v2 3/3] xfs: cleanup quota check on disk blocks and inodes reservations
  2012-02-06 12:51 ` [PATCH -v2 3/3] xfs: cleanup quota check on disk blocks and inodes reservations Mitsuo Hayasaka
@ 2012-02-15  2:33   ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2012-02-15  2:33 UTC (permalink / raw)
  To: Mitsuo Hayasaka
  Cc: Ben Myers, Alex Elder, Christoph Hellwig, Alex Elder,
	linux-kernel, xfs, xfs-masters, yrl.pp-manager.tt

On Mon, Feb 06, 2012 at 09:51:05PM +0900, Mitsuo Hayasaka wrote:
> This patch is a cleanup of quota check on disk blocks and inodes
> reservations, and changes it as follows.
> 
> (1) add a total_count variable to store the total number of
>     current usages and new reservations for disk blocks and inodes,
>     respectively.
> 
> (2) make it more readable to check if the local variables softlimit
>     and hardlimit are positive. It has been changed as follows.
> 	    if (softlimit > 0ULL) -> if (softlimit)
> 	    if (hardlimit > 0ULL) -> if (hardlimit)
>     This is because they are defined as xfs_qcnt_t which is unsigned.
> 
> Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
> Cc: Ben Myers <bpm@sgi.com>
> Cc: Alex Elder <elder@kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

end of thread, other threads:[~2012-02-15  2:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-06 12:49 [PATCH -v2 0/3] xfs: change available ranges in quota check Mitsuo Hayasaka
2012-02-06 12:50 ` [PATCH -v2 1/3] xfs: change available ranges of softlimit and hardlimit " Mitsuo Hayasaka
2012-02-15  2:32   ` Christoph Hellwig
2012-02-06 12:50 ` [PATCH -v2 2/3] xfs: make inode quota check more general Mitsuo Hayasaka
2012-02-15  2:32   ` Christoph Hellwig
2012-02-06 12:51 ` [PATCH -v2 3/3] xfs: cleanup quota check on disk blocks and inodes reservations Mitsuo Hayasaka
2012-02-15  2:33   ` Christoph Hellwig

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).