Skip to content

Commit c6adada

Browse files
mikechristieMike Snitzer
authored andcommitted
dm: Start pr_preempt from the same starting path
pr_preempt has a similar issue as reserve where for all the reservation types except the All Registrants ones the preempt can create a reservation. And a follow up reservation or release needs to go down the same path the preempt did. This has the pr_preempt work like reserve and release where we always start from the first path in the first group. This commit has been tested with windows failover clustering's validation test and libiscsi's PGR tests to check for regressions. They both don't have tests to verify this case, so I tested it manually. Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 08a3c33 commit c6adada

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

drivers/md/dm.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ struct dm_pr {
30763076
u64 old_key;
30773077
u64 new_key;
30783078
u32 flags;
3079+
bool abort;
30793080
bool fail_early;
30803081
int ret;
30813082
enum pr_type type;
@@ -3254,25 +3255,41 @@ static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
32543255
return pr.ret;
32553256
}
32563257

3258+
static int __dm_pr_preempt(struct dm_target *ti, struct dm_dev *dev,
3259+
sector_t start, sector_t len, void *data)
3260+
{
3261+
struct dm_pr *pr = data;
3262+
const struct pr_ops *ops = dev->bdev->bd_disk->fops->pr_ops;
3263+
3264+
if (!ops || !ops->pr_preempt) {
3265+
pr->ret = -EOPNOTSUPP;
3266+
return -1;
3267+
}
3268+
3269+
pr->ret = ops->pr_preempt(dev->bdev, pr->old_key, pr->new_key, pr->type,
3270+
pr->abort);
3271+
if (!pr->ret)
3272+
return -1;
3273+
3274+
return 0;
3275+
}
3276+
32573277
static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key,
32583278
enum pr_type type, bool abort)
32593279
{
3260-
struct mapped_device *md = bdev->bd_disk->private_data;
3261-
const struct pr_ops *ops;
3262-
int r, srcu_idx;
3280+
struct dm_pr pr = {
3281+
.new_key = new_key,
3282+
.old_key = old_key,
3283+
.type = type,
3284+
.fail_early = false,
3285+
};
3286+
int ret;
32633287

3264-
r = dm_prepare_ioctl(md, &srcu_idx, &bdev);
3265-
if (r < 0)
3266-
goto out;
3288+
ret = dm_call_pr(bdev, __dm_pr_preempt, &pr);
3289+
if (ret)
3290+
return ret;
32673291

3268-
ops = bdev->bd_disk->fops->pr_ops;
3269-
if (ops && ops->pr_preempt)
3270-
r = ops->pr_preempt(bdev, old_key, new_key, type, abort);
3271-
else
3272-
r = -EOPNOTSUPP;
3273-
out:
3274-
dm_unprepare_ioctl(md, srcu_idx);
3275-
return r;
3292+
return pr.ret;
32763293
}
32773294

32783295
static int dm_pr_clear(struct block_device *bdev, u64 key)

0 commit comments

Comments
 (0)