]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
gfs2: Add gfs2_holder_is_compatible helper
authorAndreas Gruenbacher <agruenba@redhat.com>
Sat, 15 May 2021 15:15:59 +0000 (17:15 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Wed, 2 Jun 2021 06:23:22 +0000 (08:23 +0200)
This function checks if a glock holder's locking state is compatible with
another locking state.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/glock.h

index 31a8f2f649b52fe69fb25585c657ea527acefa4e..f0ef6fd24ba4dba214b650acf1c6c211755c2e23 100644 (file)
@@ -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
  *