gfs2: convert quota data hash table to an rhashtable
Subsystems (2)
PATCH 1/1 gfs2: convert quota data hash table to an rhashtable
qd_hash_table is an array of hlist_bl heads whose per-bucket lock is a bit-spinlock (hlist_bl_lock()). On PREEMPT_RT a bit-spinlock is not turned into an rtmutex and keeps preemption disabled, and lockref_get_not_dead() may take the sleeping qd_lockref.lock, so the reference-taking lookup in qd_get() is not allowed while the bucket lock is held.
Convert qd_hash_table to an rhashtable, like gl_hash_table. rhashtable lookups only need rcu_read_lock(), which does not disable preemption on PREEMPT_RT, so a reference-taking lookup is safe in any context. This removes the bucket bit-spinlock, the per-object qd_hash field, gfs2_qd_hash() and the no-ref lookup variant that only existed to avoid taking a reference under the bucket lock.
As rhashtable does not allow duplicate keys, qd_get() now follows find_insert_glock(): if it finds a quota_data that is being disposed of, it waits for gfs2_qd_dispose() to remove it and retries the insertion.
--- fs/gfs2/incore.h | 12 ++- fs/gfs2/main.c | 10 +- fs/gfs2/quota.c | 247 ++++++++++++++++++++++++----------------------- fs/gfs2/quota.h | 3 +- 4 files changed, 145 insertions(+), 127 deletions(-)
fs/gfs2/incore.h +8 -4
@@ -441,14 +441,18 @@ enum { QDF_QMSG_QUIET = 4, }; +/* rhashtable key, hashed by value; keep it free of padding. */ +struct gfs2_qd_hash_key { +struct gfs2_sbd *qd_sbd; +struct kqid qd_id; +}; +struct gfs2_quota_data { -struct hlist_bl_node qd_hlist; +struct rhash_head qd_node; +struct gfs2_qd_hash_key qd_key;struct list_head qd_list; -struct kqid qd_id; -struct gfs2_sbd *qd_sbd;struct lockref qd_lockref;struct list_head qd_lru; -unsigned qd_hash;unsigned long qd_flags;/* QDF_... */
fs/gfs2/main.c +8 -2
@@ -78,12 +78,15 @@ static int __init init_gfs2_fs(void)gfs2_str2qstr (&gfs2_qdot,"." );gfs2_str2qstr (&gfs2_qdotdot,".." ); -gfs2_quota_hash_init (); - error =gfs2_sys_init (); + error =gfs2_quota_hash_init ();if (error)return error; + error =gfs2_sys_init (); +if (error) + goto fail_sys; + error =list_lru_init (&gfs2_qd_lru);if (error) goto fail_lru;
@@ -218,6 +221,8 @@ static int __init init_gfs2_fs(void)list_lru_destroy (&gfs2_qd_lru); fail_lru:gfs2_sys_uninit (); +fail_sys: +gfs2_quota_hash_exit ();return error; }
@@ -251,6 +256,7 @@ static void __exit exit_gfs2_fs(void)kmem_cache_destroy (gfs2_glock_cachep);gfs2_sys_uninit (); +gfs2_quota_hash_exit (); }MODULE_DESCRIPTION ("Global File System" );
fs/gfs2/quota.c +127 -120
494 lines not on this page · raw message
fs/gfs2/quota.h +2 -1
@@ -63,6 +63,7 @@ int __init gfs2_qd_shrinker_init(void);void gfs2_qd_shrinker_exit (void );extern struct list_lru gfs2_qd_lru; -void __init gfs2_quota_hash_init (void ); +int __init gfs2_quota_hash_init (void ); +void gfs2_quota_hash_exit (void );#endif /* __QUOTA_DOT_H__ */
Signature · 1 line
2.34.1