Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock bounce fixes #477

Merged
merged 2 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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