ceph: Fix incorrect statfs report
v2 cover ceph: Fix incorrect statfs report
From: Kotresh HR <[email protected]>
I have addressed the review comments.
For quota less than CEPH_BLOCK size, smaller block size of 4K is used.
But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.
Kotresh HR (1):
ceph: Fix incorrect statfs report for small quota
fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)
Signature · 1 line
2.31.1
PATCH v2 1/1 ceph: Fix incorrect statfs report for small quota
From: Kotresh HR <[email protected]>
Problem:
The statfs reports incorrect free/available space for quota less then CEPH_BLOCK size (4M).
Solution:
For quota less than CEPH_BLOCK size, smaller block size of 4K is used. But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.
--- fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)
fs/ceph/quota.c +14 -0
@@ -494,10 +494,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)if (ci->i_max_bytes) { total = ci->i_max_bytes >>CEPH_BLOCK_SHIFT ; used = ci->i_rbytes >>CEPH_BLOCK_SHIFT ; +/* For quota size less than 4MB, use 4KB block size */ +if (!total) { + total = ci->i_max_bytes >>CEPH_4K_BLOCK_SHIFT ; + used = ci->i_rbytes >>CEPH_4K_BLOCK_SHIFT ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + }/* It is possible for a quota to be exceeded. * Report 'zero' in that case */ free = total > used ? total - used :0 ; +/* For quota size less than 4KB, report the +* total=used=4KB,free=0 when quota is full +* and total=free=4KB, used=0 otherwise */ +if (!total) { + total =1 ; + free = ci->i_max_bytes > ci->i_rbytes ?1 :0 ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + } }spin_unlock (&ci->i_ceph_lock);if (total) {
fs/ceph/super.h +1 -0
@@ -32,6 +32,7 @@* large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22/* 4 MB */ #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) +#define CEPH_4K_BLOCK_SHIFT 12/* 4 KB */ #define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1)/* auto reonnect (clean mode) after blocklisted */ #define CEPH_MOUNT_OPT_DIRSTAT (1<<4)/* `cat dirname` for stats */
Signature · 1 line
2.31.1
Re: [PATCH v2 1/1] ceph: Fix incorrect statfs report for small quota
Quoted 36 lines · On Wed, 2021-11-10 at 23:30 +0530, [email protected] wrote:
From: Kotresh HR <[email protected]>
Problem:
The statfs reports incorrect free/available space for quota less thenCEPH_BLOCKsize (4M).Solution:
For quota less thanCEPH_BLOCKsize, smaller block size of 4K is used. But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.Signed-off-by Kotresh HR <[email protected]>--- fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)fs/ceph/quota.c +6
-0@@ -494,10 +494,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)if (ci->i_max_bytes) { total = ci->i_max_bytes >>CEPH_BLOCK_SHIFT ; used = ci->i_rbytes >>CEPH_BLOCK_SHIFT ; +/* For quota size less than 4MB, use 4KB block size */ +if (!total) { + total = ci->i_max_bytes >>CEPH_4K_BLOCK_SHIFT ; + used = ci->i_rbytes >>CEPH_4K_BLOCK_SHIFT ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + }/* It is possible for a quota to be exceeded. * Report 'zero' in that case
fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 514
Quoted 10 lines
fs/ceph/quota.c +8
-0*/ free = total > used ? total - used :0 ; +/* For quota size less than 4KB, report the +* total=used=4KB,free=0 when quota is full +* and total=free=4KB, used=0 otherwise */ +if (!total) { + total =1 ; + free = ci->i_max_bytes > ci->i_rbytes ?1 :0 ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + }
We really ought to have the MDS establish a floor for the quota size. <4k quota seems ridiculous.
Quoted 8 lines
fs/ceph/quota.c +0
-0}spin_unlock (&ci->i_ceph_lock);if (total) {fs/ceph/super.h +0
-0
fs/ceph/super.h line 38
Quoted 7 lines
fs/ceph/super.h +1
-0@@ -32,6 +32,7 @@* large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22/* 4 MB */ #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) +#define CEPH_4K_BLOCK_SHIFT 12/* 4 KB */ #define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1)/* auto reonnect (clean mode) after blocklisted */ #define CEPH_MOUNT_OPT_DIRSTAT (1<<4)/* `cat dirname` for stats */
This looks good, Kotresh. Nice work. I'll plan to merge this into testing in the near term.
Before we merge this into mainline though, it would be good to have a testcase that ensures that this works like we expect with these small quotas.
Could you write something for teuthology?
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH v2 1/1] ceph: Fix incorrect statfs report for small quota
Quoted 43 lines · Jeff Layton
Quoted 41 lines · On Wed, 2021-11-10 at 23:30 +0530, [email protected] wrote:
From: Kotresh HR <[email protected]>
Problem:
The statfs reports incorrect free/available space for quota less thenCEPH_BLOCKsize (4M).Solution:
For quota less thanCEPH_BLOCKsize, smaller block size of 4K is used. But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.Signed-off-by Kotresh HR <[email protected]>--- fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)fs/ceph/quota.c +9
-0@@ -494,10 +494,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)if (ci->i_max_bytes) { total = ci->i_max_bytes >>CEPH_BLOCK_SHIFT ; used = ci->i_rbytes >>CEPH_BLOCK_SHIFT ; +/* For quota size less than 4MB, use 4KB block size */ +if (!total) { + total = ci->i_max_bytes >>CEPH_4K_BLOCK_SHIFT ; + used = ci->i_rbytes >>CEPH_4K_BLOCK_SHIFT ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + }/* It is possible for a quota to be exceeded. * Report 'zero' in that case */ free = total > used ? total - used :0 ; +/* For quota size less than 4KB, report the +* total=used=4KB,free=0 when quota is full +* and total=free=4KB, used=0 otherwise */
Quoted 8 lines
fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 514
Quoted 5 lines
fs/ceph/quota.c +5
-0+if (!total) { + total =1 ; + free = ci->i_max_bytes > ci->i_rbytes ?1 :0 ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + }We really ought to have the MDS establish a floor for the quota size. <4k quota seems ridiculous.
Yes, I have opened a tracker for the same.
https://tracker.ceph.com/issues/53228
Quoted 21 lines
Quoted 10 lines
fs/ceph/quota.c +0
-0}spin_unlock (&ci->i_ceph_lock);if (total) {fs/ceph/super.h +0
-0fs/ceph/super.h line 38
Quoted 7 lines
fs/ceph/super.h +1
-0@@ -32,6 +32,7 @@* large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22/* 4 MB */ #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) +#define CEPH_4K_BLOCK_SHIFT 12/* 4 KB */ #define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1)/* auto reonnect (clean mode) after blocklisted */ #define CEPH_MOUNT_OPT_DIRSTAT (1<<4)/* `cat dirname` for stats */ This looks good, Kotresh. Nice work. I'll plan to merge this into testing in the near term.
Quoted 5 lines
Before we merge this into mainline though, it would be good to have a testcase that ensures that this works like we expect with these small quotas.
Could you write something for teuthology?
Sure, I will add a teuthology test for this.
Quoted 6 lines
Thanks,
--
Jeff Layton <[email protected]>
--
Thanks,
Kotresh HR
Re: [PATCH v2 1/1] ceph: Fix incorrect statfs report for small quota
In reply to [email protected]Quoted 5 lines · On 11/11/21 2:00 AM, [email protected] wrote:
From: Kotresh HR <[email protected]>
Problem:
The statfs reports incorrect free/available space for quota less thenCEPH_BLOCKsize (4M).
s/then/than/
Quoted 29 lines
Solution:
For quota less thanCEPH_BLOCKsize, smaller block size of 4K is used. But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.Signed-off-by Kotresh HR <[email protected]>--- fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)fs/ceph/quota.c +6
-0@@ -494,10 +494,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)if (ci->i_max_bytes) { total = ci->i_max_bytes >>CEPH_BLOCK_SHIFT ; used = ci->i_rbytes >>CEPH_BLOCK_SHIFT ; +/* For quota size less than 4MB, use 4KB block size */ +if (!total) { + total = ci->i_max_bytes >>CEPH_4K_BLOCK_SHIFT ; + used = ci->i_rbytes >>CEPH_4K_BLOCK_SHIFT ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + }/* It is possible for a quota to be exceeded.
fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 513
Quoted 10 lines
fs/ceph/quota.c +7
-0* Report 'zero' in that case */ free = total > used ? total - used :0 ; +/* For quota size less than 4KB, report the +* total=used=4KB,free=0 when quota is full +* and total=free=4KB, used=0 otherwise */ +if (!total) { + total =1 ; + free = ci->i_max_bytes > ci->i_rbytes ?1 :0 ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ;
The 'buf->f_frsize' has already been assigned above, this could be removed.
Thanks
-- Xiubo
Quoted 16 lines
fs/ceph/quota.c +1
-0+ } }spin_unlock (&ci->i_ceph_lock);if (total) {fs/ceph/super.h +1
-0@@ -32,6 +32,7 @@* large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22/* 4 MB */ #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) +#define CEPH_4K_BLOCK_SHIFT 12/* 4 KB */ #define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1)/* auto reonnect (clean mode) after blocklisted */ #define CEPH_MOUNT_OPT_DIRSTAT (1<<4)/* `cat dirname` for stats */
Re: [PATCH v2 1/1] ceph: Fix incorrect statfs report for small quota
Quoted 45 lines · Xiubo Li
Quoted 5 lines · On 11/11/21 2:00 AM, [email protected] wrote:
From: Kotresh HR <[email protected]>
Problem:
The statfs reports incorrect free/available space for quota less thenCEPH_BLOCKsize (4M).s/then/than/
Quoted 33 lines
Solution:
For quota less thanCEPH_BLOCKsize, smaller block size of 4K is used. But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.Signed-off-by Kotresh HR <[email protected]>--- fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)fs/ceph/quota.c +7
-0@@ -494,10 +494,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)if (ci->i_max_bytes) { total = ci->i_max_bytes >>CEPH_BLOCK_SHIFT ; used = ci->i_rbytes >>CEPH_BLOCK_SHIFT ; +/* For quota size less than 4MB, use 4KB block size */ +if (!total) { + total = ci->i_max_bytes >>CEPH_4K_BLOCK_SHIFT ; + used = ci->i_rbytes >>CEPH_4K_BLOCK_SHIFT ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ; + }/* It is possible for a quota to be exceeded. * Report 'zero' in that case */ free = total > used ? total - used :0 ; +/* For quota size less than 4KB, report the
Quoted 9 lines
fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 513
Quoted 6 lines
fs/ceph/quota.c +6
-0+* total=used=4KB,free=0 when quota is full +* and total=free=4KB, used=0 otherwise */ +if (!total) { + total =1 ; + free = ci->i_max_bytes > ci->i_rbytes ?1 :0 ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ;The '
buf->f_frsize' has already been assigned above, this could be removed.
If the quota size is less than 4KB, the above assignment is not hit. This is required.
Quoted 21 lines
Thanks
-- Xiubo
Quoted 16 lines
fs/ceph/quota.c +1
-0+ } }spin_unlock (&ci->i_ceph_lock);if (total) {fs/ceph/super.h +1
-0@@ -32,6 +32,7 @@* large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22/* 4 MB */ #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) +#define CEPH_4K_BLOCK_SHIFT 12/* 4 KB */ #define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1)/* auto reonnect (clean mode) after blocklisted */ #define CEPH_MOUNT_OPT_DIRSTAT (1<<4)/* `cat dirname` for stats */
Signature · 2 lines
Thanks and Regards, Kotresh H R
Re: [PATCH v2 1/1] ceph: Fix incorrect statfs report for small quota
Quoted 25 lines · Kotresh Hiremath Ravishankar
Quoted 24 lines · Xiubo Li
Quoted 5 lines · On 11/11/21 2:00 AM, [email protected] wrote:
From: Kotresh HR <[email protected]>
Problem:
The statfs reports incorrect free/available space for quota less thenCEPH_BLOCKsize (4M).s/then/than/
Quoted 14 lines
Solution:
For quota less thanCEPH_BLOCKsize, smaller block size of 4K is used. But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.Signed-off-by Kotresh HR <[email protected]>--- fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
fs/ceph/quota.c +0
-0@@ -494,10 +494,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)Quoted 8 lines
fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 501
Quoted 8 lines
fs/ceph/quota.c +5
-0if (ci->i_max_bytes) { total = ci->i_max_bytes >>CEPH_BLOCK_SHIFT ; used = ci->i_rbytes >>CEPH_BLOCK_SHIFT ; +/* For quota size less than 4MB, use 4KB block size */ +if (!total) { + total = ci->i_max_bytes >>CEPH_4K_BLOCK_SHIFT ; + used = ci->i_rbytes >>CEPH_4K_BLOCK_SHIFT ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ;
If the quota size is less than 4MB, the 'buf->f_frsize' will always be set here, including less than 4KB.
Quoted 38 lines
Quoted 12 lines
fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 513
Quoted 12 lines
fs/ceph/quota.c +8
-0+ }/* It is possible for a quota to be exceeded. * Report 'zero' in that case */ free = total > used ? total - used :0 ; +/* For quota size less than 4KB, report the +* total=used=4KB,free=0 when quota is full +* and total=free=4KB, used=0 otherwise */ +if (!total) { + total =1 ; + free = ci->i_max_bytes > ci->i_rbytes ?1 :0 ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ;Quoted 2 lines
The '
buf->f_frsize' has already been assigned above, this could be removed.If the quota size is less than 4KB, the above assignment is not hit. This is required.
Quoted 20 lines
Thanks
-- Xiubo
Quoted 16 lines
fs/ceph/quota.c +1
-0+ } }spin_unlock (&ci->i_ceph_lock);if (total) {fs/ceph/super.h +1
-0@@ -32,6 +32,7 @@* large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22/* 4 MB */ #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) +#define CEPH_4K_BLOCK_SHIFT 12/* 4 KB */ #define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1)/* auto reonnect (clean mode) after blocklisted */ #define CEPH_MOUNT_OPT_DIRSTAT (1<<4)/* `cat dirname` for stats */
Re: [PATCH v2 1/1] ceph: Fix incorrect statfs report for small quota
Quoted 28 lines · Xiubo Li
Quoted 25 lines · Kotresh Hiremath Ravishankar
Quoted 24 lines · Xiubo Li
Quoted 5 lines · On 11/11/21 2:00 AM, [email protected] wrote:
From: Kotresh HR <[email protected]>
Problem:
The statfs reports incorrect free/available space for quota less thenCEPH_BLOCKsize (4M).s/then/than/
Quoted 14 lines
Solution:
For quota less thanCEPH_BLOCKsize, smaller block size of 4K is used. But if quota is less than 4K, it is decided to go with binary use/free of 4K block. For quota size less than 4K size, report the total=used=4K,free=0 when quota is full and total=free=4K,used=0 otherwise.Signed-off-by Kotresh HR <[email protected]>--- fs/ceph/quota.c | 14 ++++++++++++++ fs/ceph/super.h | 1 + 2 files changed, 15 insertions(+)
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
fs/ceph/quota.c +0
-0@@ -494,10 +494,24 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)Quoted 8 lines
Quoted 8 lines
fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 501
Quoted 8 lines
fs/ceph/quota.c +5
-0if (ci->i_max_bytes) { total = ci->i_max_bytes >>CEPH_BLOCK_SHIFT ; used = ci->i_rbytes >>CEPH_BLOCK_SHIFT ; +/* For quota size less than 4MB, use 4KB block size */ +if (!total) { + total = ci->i_max_bytes >>CEPH_4K_BLOCK_SHIFT ; + used = ci->i_rbytes >>CEPH_4K_BLOCK_SHIFT ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ;If the quota size is less than 4MB, the '
buf->f_frsize' will always be set here, including less than 4KB.
Yes, sorry for the confusion. I will address this.
Quoted 41 lines
Quoted 40 lines
Quoted 14 lines
Quoted 4 lines
fs/ceph/quota.c +1
-0+ }/* It is possible for a quota to be exceeded. fs/ceph/quota.c bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf) · line 513
Quoted 10 lines
fs/ceph/quota.c +7
-0* Report 'zero' in that case */ free = total > used ? total - used :0 ; +/* For quota size less than 4KB, report the +* total=used=4KB,free=0 when quota is full +* and total=free=4KB, used=0 otherwise */ +if (!total) { + total =1 ; + free = ci->i_max_bytes > ci->i_rbytes ?1 :0 ; + buf->f_frsize =1 <<CEPH_4K_BLOCK_SHIFT ;Quoted 2 lines
The '
buf->f_frsize' has already been assigned above, this could be removed.If the quota size is less than 4KB, the above assignment is not hit. This is required.
Quoted 20 lines
Thanks
-- Xiubo
Quoted 16 lines
fs/ceph/quota.c +1
-0+ } }spin_unlock (&ci->i_ceph_lock);if (total) {fs/ceph/super.h +1
-0@@ -32,6 +32,7 @@* large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22/* 4 MB */ #define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT) +#define CEPH_4K_BLOCK_SHIFT 12/* 4 KB */ #define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1)/* auto reonnect (clean mode) after blocklisted */ #define CEPH_MOUNT_OPT_DIRSTAT (1<<4)/* `cat dirname` for stats */
Signature · 2 lines
Thanks and Regards, Kotresh H R