Skip to content

Commit 08a3c33

Browse files
mikechristieMike Snitzer
authored andcommitted
dm: Fix PR release handling for non All Registrants
This commit fixes a bug where we are leaving the reservation in place even though pr_release has run and returned success. If we have a Write Exclusive, Exclusive Access, or Write/Exclusive Registrants only reservation, the release must be sent down the path that is the reservation holder. The problem is multipath_prepare_ioctl most likely selected path N for the reservation, then later when we do the release multipath_prepare_ioctl will select a completely different path. The device will then return success becuase the nvme and scsi specs say to return success if there is no reservation or if the release is sent down from a path that is not the holder. We then think we have released the reservation. This commit has us loop over each path and send a release so we can make sure the release is executed on the correct path. It has been tested with windows failover clustering's validation test which checks this case, and it has been tested manually (the libiscsi PGR tests don't have a test case for this yet, but I will be adding one). Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 7015108 commit 08a3c33

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

drivers/md/dm.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,24 +3214,44 @@ static int dm_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type,
32143214
return pr.ret;
32153215
}
32163216

3217+
/*
3218+
* If there is a non-All Registrants type of reservation, the release must be
3219+
* sent down the holding path. For the cases where there is no reservation or
3220+
* the path is not the holder the device will also return success, so we must
3221+
* try each path to make sure we got the correct path.
3222+
*/
3223+
static int __dm_pr_release(struct dm_target *ti, struct dm_dev *dev,
3224+
sector_t start, sector_t len, void *data)
3225+
{
3226+
struct dm_pr *pr = data;
3227+
const struct pr_ops *ops = dev->bdev->bd_disk->fops->pr_ops;
3228+
3229+
if (!ops || !ops->pr_release) {
3230+
pr->ret = -EOPNOTSUPP;
3231+
return -1;
3232+
}
3233+
3234+
pr->ret = ops->pr_release(dev->bdev, pr->old_key, pr->type);
3235+
if (pr->ret)
3236+
return -1;
3237+
3238+
return 0;
3239+
}
3240+
32173241
static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
32183242
{
3219-
struct mapped_device *md = bdev->bd_disk->private_data;
3220-
const struct pr_ops *ops;
3221-
int r, srcu_idx;
3243+
struct dm_pr pr = {
3244+
.old_key = key,
3245+
.type = type,
3246+
.fail_early = false,
3247+
};
3248+
int ret;
32223249

3223-
r = dm_prepare_ioctl(md, &srcu_idx, &bdev);
3224-
if (r < 0)
3225-
goto out;
3250+
ret = dm_call_pr(bdev, __dm_pr_release, &pr);
3251+
if (ret)
3252+
return ret;
32263253

3227-
ops = bdev->bd_disk->fops->pr_ops;
3228-
if (ops && ops->pr_release)
3229-
r = ops->pr_release(bdev, key, type);
3230-
else
3231-
r = -EOPNOTSUPP;
3232-
out:
3233-
dm_unprepare_ioctl(md, srcu_idx);
3234-
return r;
3254+
return pr.ret;
32353255
}
32363256

32373257
static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key,

0 commit comments

Comments
 (0)