gfs2: do not evict glocks with populated address spaces
PATCH 1/1 gfs2: do not evict glocks with populated address spaces
Metadata glocks may have associated address spaces used as caches. Avoid reclaiming such glocks under memory pressure while their mappings are still populated or their state is not unlocked, as this can lead to invalid page cache state and GLOCK_BUG_ON().
Signed-off-by Guilherme Giacomo Simoes <[email protected]>
--- fs/gfs2/glock.h | 30 ++++++++++++++++++++++++++++++ fs/gfs2/super.c | 3 +++ 2 files changed, 33 insertions(+)
fs/gfs2/glock.h +30 -0
@@ -305,4 +305,34 @@ static inline bool glock_needs_demote(struct gfs2_glock *gl) test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags)); } +/* +* gfs2_glock_not_evictable - check if a glock is not evictable +* @gl: The glock to check +* +* Glocks which do not represent normal filesystem inodes (e.g. statfs, quota, rindex) +* may have associated address spaces used as metadata caches. These glocks must not +* be reclaimed under memory pressure while their mappings are still populated or their +* state is not unlocked. +*/ + +static inline bool gfs2_glock_not_evictable (struct gfs2_glock *gl) +{ +if (gl->gl_name.ln_type ==LM_TYPE_INODE ) +return false; + +if (gl->gl_ops->go_flags &GLOF_ASPACE ) { +struct gfs2_glock_aspace *gla; + + gla = container_of(gl, struct gfs2_glock_aspace, glock); + +if (!mapping_empty (&gla->mapping)) +return true; + } + +if (gl->gl_state !=LM_ST_UNLOCKED ) +return true; + +return false; +} +#endif /* __GLOCK_DOT_H__ */
fs/gfs2/super.c +3 -0
@@ -1164,6 +1164,9 @@ static int gfs2_show_options(struct seq_file *s, struct dentry *root)static void gfs2_glock_put_eventually (struct gfs2_glock *gl) { +if (gfs2_glock_not_evictable (gl)) +return ; +if (current->flags &PF_MEMALLOC )gfs2_glock_put_async (gl);else
Signature · 1 line
2.34.1