Skip to content

Commit 909110c

Browse files
cgxu519Jaegeuk Kim
authored and
Jaegeuk Kim
committed
f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project()
Setting softlimit larger than hardlimit seems meaningless for disk quota but currently it is allowed. In this case, there may be a bit of comfusion for users when they run df comamnd to directory which has project quota. For example, we set 20M softlimit and 10M hardlimit of block usage limit for project quota of test_dir(project id 123). [root@hades f2fs]# repquota -P -a *** Report for project quotas on device /dev/nvme0n1p8 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 123 +- 10248 20480 10240 2 0 0 The result of df command as below: [root@hades f2fs]# df -h /mnt/f2fs/test Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p8 20M 11M 10M 51% /mnt/f2fs Even though it looks like there is another 10M free space to use, if we write new data to diretory test(inherit project id), the write will fail with errno(-EDQUOT). After this patch, the df result looks like below. [root@hades f2fs]# df -h /mnt/f2fs/test Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p8 10M 10M 0 100% /mnt/f2fs Signed-off-by: Chengguang Xu <cgxu519@mykernel.net> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 677017d commit 909110c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

fs/f2fs/super.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -1213,9 +1213,13 @@ static int f2fs_statfs_project(struct super_block *sb,
12131213
return PTR_ERR(dquot);
12141214
spin_lock(&dquot->dq_dqb_lock);
12151215

1216-
limit = (dquot->dq_dqb.dqb_bsoftlimit ?
1217-
dquot->dq_dqb.dqb_bsoftlimit :
1218-
dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits;
1216+
limit = 0;
1217+
if (dquot->dq_dqb.dqb_bsoftlimit)
1218+
limit = dquot->dq_dqb.dqb_bsoftlimit;
1219+
if (dquot->dq_dqb.dqb_bhardlimit &&
1220+
(!limit || dquot->dq_dqb.dqb_bhardlimit < limit))
1221+
limit = dquot->dq_dqb.dqb_bhardlimit;
1222+
12191223
if (limit && buf->f_blocks > limit) {
12201224
curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits;
12211225
buf->f_blocks = limit;
@@ -1224,9 +1228,13 @@ static int f2fs_statfs_project(struct super_block *sb,
12241228
(buf->f_blocks - curblock) : 0;
12251229
}
12261230

1227-
limit = dquot->dq_dqb.dqb_isoftlimit ?
1228-
dquot->dq_dqb.dqb_isoftlimit :
1229-
dquot->dq_dqb.dqb_ihardlimit;
1231+
limit = 0;
1232+
if (dquot->dq_dqb.dqb_isoftlimit)
1233+
limit = dquot->dq_dqb.dqb_isoftlimit;
1234+
if (dquot->dq_dqb.dqb_ihardlimit &&
1235+
(!limit || dquot->dq_dqb.dqb_ihardlimit < limit))
1236+
limit = dquot->dq_dqb.dqb_ihardlimit;
1237+
12301238
if (limit && buf->f_files > limit) {
12311239
buf->f_files = limit;
12321240
buf->f_ffree =

0 commit comments

Comments
 (0)