Skip to content

Commit

Permalink
Merge pull request #477 from mikechristie/lock-bounce-fixes
Browse files Browse the repository at this point in the history
Lock bounce fixes
  • Loading branch information
mikechristie authored Sep 18, 2018
2 parents aeef9ce + bb42f20 commit 97a4efd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 1 addition & 3 deletions alua.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include "target.h"
#include "alua.h"

#define TCMU_ALUA_INVALID_GROUP_ID USHRT_MAX

static char *tcmu_get_alua_str_setting(struct alua_grp *group,
const char *setting)
{
Expand Down Expand Up @@ -412,7 +410,7 @@ static int alua_sync_state(struct tcmu_device *dev,

ret = tcmu_get_lock_tag(dev, &ao_group_id);
if (ret == TCMU_STS_NO_LOCK_HOLDERS) {
ao_group_id = TCMU_ALUA_INVALID_GROUP_ID;
ao_group_id = TCMU_INVALID_LOCK_TAG;
} else if (ret != TCMU_STS_OK)
return ret;

Expand Down
3 changes: 2 additions & 1 deletion rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ static int tcmu_rbd_lock(struct tcmu_device *dev, uint16_t tag)

set_lock_tag:
tcmu_dev_warn(dev, "Acquired exclusive lock.\n");
ret = tcmu_rbd_set_lock_tag(dev, tag);
if (tag != TCMU_INVALID_LOCK_TAG)
ret = tcmu_rbd_set_lock_tag(dev, tag);

done:
tcmu_rbd_service_status_update(dev, ret == 0 ? true : false);
Expand Down
6 changes: 3 additions & 3 deletions tcmu-runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ struct tcmur_handler {
unmap_fn_t unmap;

/*
* If the lock is acquired and the tag is non-NULL, it must be
* associated with the lock and returned by get_lock_tag on local
* and remote nodes. When unlock is successful, the tag
* If the lock is acquired and the tag is not TCMU_INVALID_LOCK_TAG,
* it must be associated with the lock and returned by get_lock_tag on
* local and remote nodes. When unlock is successful, the tag
* associated with the lock must be deleted.
*
* Returns a TCMU_STS indicating success/failure.
Expand Down
13 changes: 6 additions & 7 deletions tcmur_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,15 @@ int tcmu_acquire_dev_lock(struct tcmu_device *dev, bool is_sync,
retries++;
goto retry;
}
/*
* If we can't unfence ourself the lock is probably bouncing
* due to path initialization. Allow the other node to hold the
* lock for now, and the initiator will drive retries.
*/
}

drop_conn:
/*
* If we cannot unfence ourself or we cannot reach the backend,
* disable the tpg until we can reopen the device. The initiator
* can try another path while we try to fix things up in the
* background.
*/
if (ret == TCMU_STS_TIMEOUT || ret == TCMU_STS_FENCED) {
if (ret == TCMU_STS_TIMEOUT) {
tcmu_dev_dbg(dev, "Fail handler device connection.\n");
tcmu_notify_conn_lost(dev);
}
Expand Down
2 changes: 2 additions & 0 deletions tcmur_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "tcmur_aio.h"

#define TCMU_INVALID_LOCK_TAG USHRT_MAX

#define TCMUR_DEV_FLAG_FORMATTING (1 << 0)
#define TCMUR_DEV_FLAG_IN_RECOVERY (1 << 1)
#define TCMUR_DEV_FLAG_IS_OPEN (1 << 2)
Expand Down

0 comments on commit 97a4efd

Please sign in to comment.