Whamcloud - gitweb
LU-12967 tgt: clean up sync_on_cancel references 54/36754/3
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 14 Nov 2019 02:49:23 +0000 (19:49 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Dec 2019 05:59:41 +0000 (05:59 +0000)
Clean up the use of "sync_on_cancel" in the code, since the tunable
parameter is named "sync_lock_cancel" and using the same name in
the code makes it easier to find the related parts.

Rename constants to be more consistent:
  NEVER_SYNC_ON_CANCEL    -> SYNC_LOCK_CANCEL_NEVER
  BLOCKING_SYNC_ON_CANCEL -> SYNC_LOCK_CANCEL_BLOCKING
  ALWAYS_SYNC_ON_CANCEL   -> SYNC_LOCK_CANCEL_ALWAYS

Initialize sync_lock_cancel_states[] with designated initializers
so that the state names always match the declared values.

Use ARRAY_SIZE() instead of needing NUM_SYNC_ON_CANCEL_STATES.

Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: If7c6015420a5c3266a13798fd8b96539323ebbe5
Reviewed-on: https://review.whamcloud.com/36754
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd.h
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/ofd/ofd_internal.h
lustre/target/tgt_handler.c
lustre/target/tgt_main.c

index e560a8c..c84980b 100644 (file)
@@ -136,11 +136,10 @@ struct timeout_item {
 #define OSC_DEFAULT_RESENDS    10
 
 /* possible values for lut_sync_lock_cancel */
 #define OSC_DEFAULT_RESENDS    10
 
 /* possible values for lut_sync_lock_cancel */
-enum {
-        NEVER_SYNC_ON_CANCEL = 0,
-        BLOCKING_SYNC_ON_CANCEL = 1,
-        ALWAYS_SYNC_ON_CANCEL = 2,
-        NUM_SYNC_ON_CANCEL_STATES
+enum tgt_sync_lock_cancel {
+       SYNC_LOCK_CANCEL_NEVER    = 0,
+       SYNC_LOCK_CANCEL_BLOCKING = 1,
+       SYNC_LOCK_CANCEL_ALWAYS   = 2,
 };
 
 /*
 };
 
 /*
index 50191b3..9213c45 100644 (file)
@@ -6153,14 +6153,14 @@ static int mdt_export_cleanup(struct obd_export *exp)
 
 static inline void mdt_enable_slc(struct mdt_device *mdt)
 {
 
 static inline void mdt_enable_slc(struct mdt_device *mdt)
 {
-       if (mdt->mdt_lut.lut_sync_lock_cancel == NEVER_SYNC_ON_CANCEL)
-               mdt->mdt_lut.lut_sync_lock_cancel = BLOCKING_SYNC_ON_CANCEL;
+       if (mdt->mdt_lut.lut_sync_lock_cancel == SYNC_LOCK_CANCEL_NEVER)
+               mdt->mdt_lut.lut_sync_lock_cancel = SYNC_LOCK_CANCEL_BLOCKING;
 }
 
 static inline void mdt_disable_slc(struct mdt_device *mdt)
 {
 }
 
 static inline void mdt_disable_slc(struct mdt_device *mdt)
 {
-       if (mdt->mdt_lut.lut_sync_lock_cancel == BLOCKING_SYNC_ON_CANCEL)
-               mdt->mdt_lut.lut_sync_lock_cancel = NEVER_SYNC_ON_CANCEL;
+       if (mdt->mdt_lut.lut_sync_lock_cancel == SYNC_LOCK_CANCEL_BLOCKING)
+               mdt->mdt_lut.lut_sync_lock_cancel = SYNC_LOCK_CANCEL_NEVER;
 }
 
 static int mdt_obd_disconnect(struct obd_export *exp)
 }
 
 static int mdt_obd_disconnect(struct obd_export *exp)
index 1e1d6da..6083c9b 100644 (file)
@@ -1213,7 +1213,7 @@ static inline void mdt_fid_unlock(struct lustre_handle *lh, enum ldlm_mode mode)
 
 static inline bool mdt_slc_is_enabled(struct mdt_device *mdt)
 {
 
 static inline bool mdt_slc_is_enabled(struct mdt_device *mdt)
 {
-       return mdt->mdt_lut.lut_sync_lock_cancel == BLOCKING_SYNC_ON_CANCEL;
+       return mdt->mdt_lut.lut_sync_lock_cancel == SYNC_LOCK_CANCEL_BLOCKING;
 }
 
 extern mdl_mode_t mdt_mdl_lock_modes[];
 }
 
 extern mdl_mode_t mdt_mdl_lock_modes[];
index 7a9a152..779aea5 100644 (file)
@@ -456,9 +456,9 @@ static inline struct ofd_thread_info *tsi2ofd_info(struct tgt_session_info *tsi)
 static inline void ofd_slc_set(struct ofd_device *ofd)
 {
        if (ofd->ofd_sync_journal == 1)
 static inline void ofd_slc_set(struct ofd_device *ofd)
 {
        if (ofd->ofd_sync_journal == 1)
-               ofd->ofd_lut.lut_sync_lock_cancel = NEVER_SYNC_ON_CANCEL;
-       else if (ofd->ofd_lut.lut_sync_lock_cancel == NEVER_SYNC_ON_CANCEL)
-               ofd->ofd_lut.lut_sync_lock_cancel = ALWAYS_SYNC_ON_CANCEL;
+               ofd->ofd_lut.lut_sync_lock_cancel = SYNC_LOCK_CANCEL_NEVER;
+       else if (ofd->ofd_lut.lut_sync_lock_cancel == SYNC_LOCK_CANCEL_NEVER)
+               ofd->ofd_lut.lut_sync_lock_cancel = SYNC_LOCK_CANCEL_ALWAYS;
 }
 
 static inline int ofd_validate_seq(struct obd_export *exp, __u64 seq)
 }
 
 static inline int ofd_validate_seq(struct obd_export *exp, __u64 seq)
index 4a6443e..bc3f7eb 100644 (file)
@@ -1280,8 +1280,8 @@ static int tgt_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 
        if (flag == LDLM_CB_CANCELING &&
            (lock->l_granted_mode & (LCK_EX | LCK_PW | LCK_GROUP)) &&
 
        if (flag == LDLM_CB_CANCELING &&
            (lock->l_granted_mode & (LCK_EX | LCK_PW | LCK_GROUP)) &&
-           (tgt->lut_sync_lock_cancel == ALWAYS_SYNC_ON_CANCEL ||
-            (tgt->lut_sync_lock_cancel == BLOCKING_SYNC_ON_CANCEL &&
+           (tgt->lut_sync_lock_cancel == SYNC_LOCK_CANCEL_ALWAYS ||
+            (tgt->lut_sync_lock_cancel == SYNC_LOCK_CANCEL_BLOCKING &&
              ldlm_is_cbpending(lock))) &&
            ((exp_connect_flags(lock->l_export) & OBD_CONNECT_MDS_MDS) ||
             lock->l_resource->lr_type == LDLM_EXTENT)) {
              ldlm_is_cbpending(lock))) &&
            ((exp_connect_flags(lock->l_export) & OBD_CONNECT_MDS_MDS) ||
             lock->l_resource->lr_type == LDLM_EXTENT)) {
index ef02f05..ce15894 100644 (file)
 
 /* This must be longer than the longest string below */
 #define SYNC_STATES_MAXLEN 16
 
 /* This must be longer than the longest string below */
 #define SYNC_STATES_MAXLEN 16
-static char *sync_on_cancel_states[] = {"never",
-                                       "blocking",
-                                       "always" };
+static char *sync_lock_cancel_states[] = {
+       [SYNC_LOCK_CANCEL_NEVER]        = "never",
+       [SYNC_LOCK_CANCEL_BLOCKING]     = "blocking",
+       [SYNC_LOCK_CANCEL_ALWAYS]       = "always",
+};
 
 /**
  * Show policy for handling dirty data under a lock being cancelled.
 
 /**
  * Show policy for handling dirty data under a lock being cancelled.
@@ -61,7 +63,7 @@ ssize_t sync_lock_cancel_show(struct kobject *kobj,
        struct lu_target *tgt = obd->u.obt.obt_lut;
 
        return sprintf(buf, "%s\n",
        struct lu_target *tgt = obd->u.obt.obt_lut;
 
        return sprintf(buf, "%s\n",
-                      sync_on_cancel_states[tgt->lut_sync_lock_cancel]);
+                      sync_lock_cancel_states[tgt->lut_sync_lock_cancel]);
 }
 EXPORT_SYMBOL(sync_lock_cancel_show);
 
 }
 EXPORT_SYMBOL(sync_lock_cancel_show);
 
@@ -93,14 +95,14 @@ ssize_t sync_lock_cancel_store(struct kobject *kobj, struct attribute *attr,
                                              obd_kset.kobj);
        struct lu_target *tgt = obd->u.obt.obt_lut;
        int val = -1;
                                              obd_kset.kobj);
        struct lu_target *tgt = obd->u.obt.obt_lut;
        int val = -1;
-       int i;
+       enum tgt_sync_lock_cancel slc;
 
        if (count == 0 || count >= SYNC_STATES_MAXLEN)
                return -EINVAL;
 
 
        if (count == 0 || count >= SYNC_STATES_MAXLEN)
                return -EINVAL;
 
-       for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) {
-               if (strcmp(buffer, sync_on_cancel_states[i]) == 0) {
-                       val = i;
+       for (slc = 0; slc < ARRAY_SIZE(sync_lock_cancel_states); slc++) {
+               if (strcmp(buffer, sync_lock_cancel_states[slc]) == 0) {
+                       val = slc;
                        break;
                }
        }
                        break;
                }
        }
@@ -416,7 +418,7 @@ int tgt_init(const struct lu_env *env, struct lu_target *lut,
        sptlrpc_rule_set_init(&lut->lut_sptlrpc_rset);
 
        spin_lock_init(&lut->lut_flags_lock);
        sptlrpc_rule_set_init(&lut->lut_sptlrpc_rset);
 
        spin_lock_init(&lut->lut_flags_lock);
-       lut->lut_sync_lock_cancel = NEVER_SYNC_ON_CANCEL;
+       lut->lut_sync_lock_cancel = SYNC_LOCK_CANCEL_NEVER;
 
        spin_lock_init(&lut->lut_slc_locks_guard);
        INIT_LIST_HEAD(&lut->lut_slc_locks);
 
        spin_lock_init(&lut->lut_slc_locks_guard);
        INIT_LIST_HEAD(&lut->lut_slc_locks);