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>
#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,
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)
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[];
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)
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)) {
/* 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.
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);
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;
+ 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;
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);