Skip to content

rbd-target-api: get image's exclusive lock owner and break it - #70

Open
xiubli wants to merge 1 commit into
ceph:masterfrom
xiubli:fix_snapshot
Open

xiubli wants to merge 1 commit into
ceph:masterfrom
xiubli:fix_snapshot

Conversation

@xiubli

@xiubli xiubli commented Jan 5, 2018

Copy link
Copy Markdown
Member

Once the client logged in and IOs are done, one of the iscsi
gateway nodes will hold the exclusive lock and be the lock
owner in tcmu-runner.

When we try rollback the snap shot of the image, it will become
readonly and failed even DELETE the LUN from the client host.

This patch will just get the lock owner and break it when doing
the LUN's DELETE opration.

Signed-off-by: Zhang Zhuoyu zhangzhuoyu@cmss.chinamobile.com
Signed-off-by: Xiubo Li lixiubo@cmss.chinamobile.com

Once the client logged in and IOs are done, one of the iscsi
gateway nodes will hold the exclusive lock and be the lock
owner in tcmu-runner.

When we try rollback the snap shot of the image, it will become
readonly and failed even DELETE the LUN from the client host.

This patch will just get the lock owner and break it when doing
the LUN's DELETE opration.

Signed-off-by: Zhang Zhuoyu <zhangzhuoyu@cmss.chinamobile.com>
Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
@zhuozh

zhuozh commented Jan 5, 2018

Copy link
Copy Markdown

Creating snapshot fail like this:
image

Comment thread rbd-target-api.py
with cluster.open_ioctx(pool_name) as ioctx:
with rbd.Image(ioctx, image_name) as image:

if len(image.list_lockers()):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no need, just invoke the line below but wrap it w/ a try/except clause to catch rbd.ImageNotFound and rbd.InvalidArgument.

Comment thread rbd-target-api.py
lun_list.remove(disk)

pool_name, image_name = disk.split('.')
with rados.Rados(conffile=settings.config.cephconf) as cluster:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could collapse into a single with:

with rados.Rados(conffile=settings.config.cephconf) as cluster, \
        cluster.open_ioctx(pool_name) as ioctx, \
        rbd.Image(ioctx, image_name) as image:

Comment thread rbd-target-api.py
lock_owners = list(image.lock_get_owners())
eq(1, len(lock_owners))
eq(rbd.RBD_LOCK_MODE_EXCLUSIVE, lock_owners[0]['mode'])
image.lock_break(rbd.RBD_LOCK_MODE_EXCLUSIVE, lock_owners[0]['owner'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: wrap w/ try/except to avoid race conditions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants