From: Andreas Gruenbacher Date: Sat, 15 May 2021 15:15:59 +0000 (+0200) Subject: gfs2: Add gfs2_holder_is_compatible helper X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=04264450d3cb6f54620b2884fa83882c13d4a8e7;p=users%2Fjedix%2Flinux-maple.git gfs2: Add gfs2_holder_is_compatible helper This function checks if a glock holder's locking state is compatible with another locking state. Signed-off-by: Andreas Gruenbacher --- diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 31a8f2f649b52..f0ef6fd24ba4d 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -49,6 +49,20 @@ enum { #define LM_ST_DEFERRED 2 #define LM_ST_SHARED 3 +static inline bool gfs2_holder_is_compatible(struct gfs2_holder *gh, int state) { + BUG_ON(state == LM_ST_UNLOCKED); + switch(gh->gh_state) { + case LM_ST_EXCLUSIVE: + return state != LM_ST_DEFERRED; + case LM_ST_DEFERRED: + return state == LM_ST_DEFERRED; + case LM_ST_SHARED: + return state == LM_ST_SHARED; + default: + return false; + } +} + /* * lm_lock() flags *