ceph: add ceph_has_realms_with_quotas() check into ceph_quota_update_statfs()
Subsystems (2)
Viacheslav Dubeyko
maintainerPATCH 1/1 ceph: add ceph_has_realms_with_quotas() check into ceph_quota_update_statfs()
From: Viacheslav Dubeyko <[email protected]>
When MDS rejects a session, remove_session_caps() -> __ceph_remove_cap() -> ceph_change_snap_realm() clears i_snap_realm for every inode that loses its last cap. The realm is restored once caps are re-granted after reconnect. It is not a real error and thsi patch changes pr_err_ratelimited_client() on doutc().
Every quota methods ceph_quota_is_max_files_exceeded(), ceph_quota_is_max_bytes_exceeded(), ceph_quota_is_max_bytes_approaching() calls ceph_has_realms_with_quotas() check. This patch adds the missing ceph_has_realms_with_quotas() call into ceph_quota_update_statfs().
--- fs/ceph/quota.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
fs/ceph/quota.c +19 -6
@@ -231,9 +231,14 @@ static int get_quota_realm(struct ceph_mds_client *mdsc, struct inode *inode,if (realm)ceph_get_snap_realm (mdsc, realm);else -pr_err_ratelimited_client (cl, -"%p %llx.%llx null i_snap_realm\n" , - inode,ceph_vinop (inode)); +/* +* i_snap_realm is NULL when all caps have been released, e.g. +* after an MDS session rejection. This is a transient state; +* the realm will be restored once caps are re-granted. Treat +* it as "no quota realm found" and return gracefully. +*/ +doutc (cl,"%p %llx.%llx null i_snap_realm\n" , + inode,ceph_vinop (inode));while (realm) {bool has_inode;
@@ -343,9 +348,14 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,if (realm)ceph_get_snap_realm (mdsc, realm);else -pr_err_ratelimited_client (cl, -"%p %llx.%llx null i_snap_realm\n" , - inode,ceph_vinop (inode)); +/* +* i_snap_realm is NULL when all caps have been released, e.g. +* after an MDS session rejection. This is a transient state; +* the realm will be restored once caps are re-granted. Treat +* it as "quota not exceeded" and return gracefully. +*/ +doutc (cl,"%p %llx.%llx null i_snap_realm\n" , + inode,ceph_vinop (inode));while (realm) {bool has_inode;
@@ -496,6 +506,9 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)u64 total =0 , used, free;bool is_updated = false; +if (!ceph_has_realms_with_quotas (d_inode (fsc->sb->s_root))) +return false; +down_read (&mdsc->snap_rwsem);get_quota_realm (mdsc,d_inode (fsc->sb->s_root),QUOTA_GET_MAX_BYTES , &realm, true);
Signature · 1 line
2.53.0
Alex Markuze
maintainerGood catch. Please add braces for multiline if-else statements; braces are needed even if it is only a comment braces are now needed. Small nit, please change the comment to * Treat it as "no quota realm found" and fall through gracefully. you are not returning.
Quoted 79 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
When MDS rejects a session,
remove_session_caps()->__ceph_remove_cap()->ceph_change_snap_realm()clearsi_snap_realmfor every inode that loses its last cap. The realm is restored once caps are re-granted after reconnect. It is not a real error and thsi patch changespr_err_ratelimited_client()ondoutc().Every quota methods
ceph_quota_is_max_files_exceeded(),ceph_quota_is_max_bytes_exceeded(),ceph_quota_is_max_bytes_approaching()callsceph_has_realms_with_quotas()check. This patch adds the missingceph_has_realms_with_quotas()call intoceph_quota_update_statfs().Signed-off-by Viacheslav Dubeyko <[email protected]>cc Alex Markuze <[email protected]>cc Ilya Dryomov <[email protected]>cc Patrick Donnelly <[email protected]>cc Ceph Development <[email protected]>--- fs/ceph/quota.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)fs/ceph/quota.c +19
-7@@ -231,9 +231,14 @@ static int get_quota_realm(struct ceph_mds_client *mdsc, struct inode *inode,if (realm)ceph_get_snap_realm (mdsc, realm);else -pr_err_ratelimited_client (cl, -"%p %llx.%llx null i_snap_realm\n" , - inode,ceph_vinop (inode)); +/* +* i_snap_realm is NULL when all caps have been released, e.g. +* after an MDS session rejection. This is a transient state; +* the realm will be restored once caps are re-granted. Treat +* it as "no quota realm found" and return gracefully. +*/ +doutc (cl,"%p %llx.%llx null i_snap_realm\n" , + inode,ceph_vinop (inode));while (realm) {bool has_inode;@@ -343,9 +348,14 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,if (realm)ceph_get_snap_realm (mdsc, realm);else -pr_err_ratelimited_client (cl, -"%p %llx.%llx null i_snap_realm\n" , - inode,ceph_vinop (inode)); +/* +* i_snap_realm is NULL when all caps have been released, e.g. +* after an MDS session rejection. This is a transient state; +* the realm will be restored once caps are re-granted. Treat +* it as "quota not exceeded" and return gracefully. +*/ +doutc (cl,"%p %llx.%llx null i_snap_realm\n" , + inode,ceph_vinop (inode));while (realm) {bool has_inode;@@ -496,6 +506,9 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)u64 total =0 , used, free;bool is_updated = false; +if (!ceph_has_realms_with_quotas (d_inode (fsc->sb->s_root))) +return false; +down_read (&mdsc->snap_rwsem);get_quota_realm (mdsc,d_inode (fsc->sb->s_root),QUOTA_GET_MAX_BYTES , &realm, true); --2.53.0
Quoted 4 lines · Alex Markuze
Good catch. Please add braces for multiline if-else statements; braces are needed even if it is only a comment braces are now needed. Small nit, please change the comment to * Treat it as "no quota realm found" and fall through gracefully. you are not returning.
Makes sense. Let me rework my patch.
Thanks,
Slava.