linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev][PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project()
@ 2020-01-04 14:20 Chengguang Xu
  2020-01-04 14:20 ` [f2fs-dev][PATCH 2/2] f2fs: code cleanup for f2fs_statfs_project() Chengguang Xu
  2020-01-07 11:28 ` [f2fs-dev] [PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project() Chao Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Chengguang Xu @ 2020-01-04 14:20 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Chengguang Xu

statfs calculates Total/Used/Avail disk space in block unit,
so we should translate soft/hard prjquota limit to block unit
as well.

Below testing result shows the block/inode numbers of
Total/Used/Avail from df command are all correct afer
applying this patch.

[root@localhost quota-tools]\# ./repquota -P /dev/sdb1
*** Report for project quotas on device /dev/sdb1
Block grace time: 7days; Inode grace time: 7days
              Block limits                File limits
Project   used soft    hard  grace  used  soft  hard  grace
-----------------------------------------------------------
\#0   --   4       0       0         1     0     0
\#101 --   0       0       0         2     0     0
\#102 --   0   10240       0         2    10     0
\#103 --   0       0   20480         2     0    20
\#104 --   0   10240   20480         2    10    20
\#105 --   0   20480   10240         2    20    10

[root@localhost sdb1]\# lsattr -p t{1,2,3,4,5}
  101 ----------------N-- t1/a1
  102 ----------------N-- t2/a2
  103 ----------------N-- t3/a3
  104 ----------------N-- t4/a4
  105 ----------------N-- t5/a5

[root@localhost sdb1]\# df -hi t{1,2,3,4,5}
Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/sdb1        2.4M    21  2.4M    1% /mnt/sdb1
/dev/sdb1          10     2     8   20% /mnt/sdb1
/dev/sdb1          20     2    18   10% /mnt/sdb1
/dev/sdb1          10     2     8   20% /mnt/sdb1
/dev/sdb1          10     2     8   20% /mnt/sdb1

[root@localhost sdb1]\# df -h t{1,2,3,4,5}
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1        10G  489M  9.6G   5% /mnt/sdb1
/dev/sdb1        10M     0   10M   0% /mnt/sdb1
/dev/sdb1        20M     0   20M   0% /mnt/sdb1
/dev/sdb1        10M     0   10M   0% /mnt/sdb1
/dev/sdb1        10M     0   10M   0% /mnt/sdb1

Fixes: 909110c060f2 ("f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project()")
Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/f2fs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 5111e1ffe58a..78efd0e76174 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1219,6 +1219,8 @@ static int f2fs_statfs_project(struct super_block *sb,
 	if (dquot->dq_dqb.dqb_bhardlimit &&
 			(!limit || dquot->dq_dqb.dqb_bhardlimit < limit))
 		limit = dquot->dq_dqb.dqb_bhardlimit;
+	if (limit)
+		limit >>= sb->s_blocksize_bits;
 
 	if (limit && buf->f_blocks > limit) {
 		curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits;
-- 
2.21.1




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

* [f2fs-dev][PATCH 2/2] f2fs: code cleanup for f2fs_statfs_project()
  2020-01-04 14:20 [f2fs-dev][PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project() Chengguang Xu
@ 2020-01-04 14:20 ` Chengguang Xu
  2020-01-07 11:37   ` [f2fs-dev] [PATCH " Chao Yu
  2020-01-07 11:28 ` [f2fs-dev] [PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project() Chao Yu
  1 sibling, 1 reply; 4+ messages in thread
From: Chengguang Xu @ 2020-01-04 14:20 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Chengguang Xu

Calling min_not_zero() to simplify complicated prjquota
limit comparison in f2fs_statfs_project().

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/f2fs/super.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 78efd0e76174..ac01c3f8863d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1213,12 +1213,8 @@ static int f2fs_statfs_project(struct super_block *sb,
 		return PTR_ERR(dquot);
 	spin_lock(&dquot->dq_dqb_lock);
 
-	limit = 0;
-	if (dquot->dq_dqb.dqb_bsoftlimit)
-		limit = dquot->dq_dqb.dqb_bsoftlimit;
-	if (dquot->dq_dqb.dqb_bhardlimit &&
-			(!limit || dquot->dq_dqb.dqb_bhardlimit < limit))
-		limit = dquot->dq_dqb.dqb_bhardlimit;
+	limit = min_not_zero(dquot->dq_dqb.dqb_bsoftlimit,
+					dquot->dq_dqb.dqb_bhardlimit);
 	if (limit)
 		limit >>= sb->s_blocksize_bits;
 
@@ -1230,12 +1226,8 @@ static int f2fs_statfs_project(struct super_block *sb,
 			 (buf->f_blocks - curblock) : 0;
 	}
 
-	limit = 0;
-	if (dquot->dq_dqb.dqb_isoftlimit)
-		limit = dquot->dq_dqb.dqb_isoftlimit;
-	if (dquot->dq_dqb.dqb_ihardlimit &&
-			(!limit || dquot->dq_dqb.dqb_ihardlimit < limit))
-		limit = dquot->dq_dqb.dqb_ihardlimit;
+	limit = min_not_zero(dquot->dq_dqb.dqb_isoftlimit,
+					dquot->dq_dqb.dqb_ihardlimit);
 
 	if (limit && buf->f_files > limit) {
 		buf->f_files = limit;
-- 
2.21.1




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

* Re: [f2fs-dev] [PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project()
  2020-01-04 14:20 [f2fs-dev][PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project() Chengguang Xu
  2020-01-04 14:20 ` [f2fs-dev][PATCH 2/2] f2fs: code cleanup for f2fs_statfs_project() Chengguang Xu
@ 2020-01-07 11:28 ` Chao Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2020-01-07 11:28 UTC (permalink / raw)
  To: Chengguang Xu, jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

On 2020/1/4 22:20, Chengguang Xu wrote:
> statfs calculates Total/Used/Avail disk space in block unit,
> so we should translate soft/hard prjquota limit to block unit
> as well.
> 
> Below testing result shows the block/inode numbers of
> Total/Used/Avail from df command are all correct afer
> applying this patch.
> 
> [root@localhost quota-tools]\# ./repquota -P /dev/sdb1
> *** Report for project quotas on device /dev/sdb1
> Block grace time: 7days; Inode grace time: 7days
>               Block limits                File limits
> Project   used soft    hard  grace  used  soft  hard  grace
> -----------------------------------------------------------
> \#0   --   4       0       0         1     0     0
> \#101 --   0       0       0         2     0     0
> \#102 --   0   10240       0         2    10     0
> \#103 --   0       0   20480         2     0    20
> \#104 --   0   10240   20480         2    10    20
> \#105 --   0   20480   10240         2    20    10
> 
> [root@localhost sdb1]\# lsattr -p t{1,2,3,4,5}
>   101 ----------------N-- t1/a1
>   102 ----------------N-- t2/a2
>   103 ----------------N-- t3/a3
>   104 ----------------N-- t4/a4
>   105 ----------------N-- t5/a5
> 
> [root@localhost sdb1]\# df -hi t{1,2,3,4,5}
> Filesystem     Inodes IUsed IFree IUse% Mounted on
> /dev/sdb1        2.4M    21  2.4M    1% /mnt/sdb1
> /dev/sdb1          10     2     8   20% /mnt/sdb1
> /dev/sdb1          20     2    18   10% /mnt/sdb1
> /dev/sdb1          10     2     8   20% /mnt/sdb1
> /dev/sdb1          10     2     8   20% /mnt/sdb1
> 
> [root@localhost sdb1]\# df -h t{1,2,3,4,5}
> Filesystem      Size  Used Avail Use% Mounted on
> /dev/sdb1        10G  489M  9.6G   5% /mnt/sdb1
> /dev/sdb1        10M     0   10M   0% /mnt/sdb1
> /dev/sdb1        20M     0   20M   0% /mnt/sdb1
> /dev/sdb1        10M     0   10M   0% /mnt/sdb1
> /dev/sdb1        10M     0   10M   0% /mnt/sdb1
> 
> Fixes: 909110c060f2 ("f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project()")
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [f2fs-dev] [PATCH 2/2] f2fs: code cleanup for f2fs_statfs_project()
  2020-01-04 14:20 ` [f2fs-dev][PATCH 2/2] f2fs: code cleanup for f2fs_statfs_project() Chengguang Xu
@ 2020-01-07 11:37   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2020-01-07 11:37 UTC (permalink / raw)
  To: Chengguang Xu, jaegeuk, chao; +Cc: linux-kernel, linux-f2fs-devel

On 2020/1/4 22:20, Chengguang Xu wrote:
> Calling min_not_zero() to simplify complicated prjquota
> limit comparison in f2fs_statfs_project().
> 
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

end of thread, other threads:[~2020-01-07 11:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-04 14:20 [f2fs-dev][PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project() Chengguang Xu
2020-01-04 14:20 ` [f2fs-dev][PATCH 2/2] f2fs: code cleanup for f2fs_statfs_project() Chengguang Xu
2020-01-07 11:37   ` [f2fs-dev] [PATCH " Chao Yu
2020-01-07 11:28 ` [f2fs-dev] [PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project() Chao Yu

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