nvme/opal: consolidate two get_locking_ranges APIs into one
Actually we can just use one API to finish the requirement. Change-Id: Ia0d3d589755e8c92f636d3d090ec642299511401 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1280 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
366fc57724
commit
a3363de3c2
@ -1151,13 +1151,13 @@ opal_list_locking_ranges(struct dev *iter)
|
||||
printf("\n");
|
||||
if (passwd_p) {
|
||||
ret = spdk_opal_cmd_get_max_ranges(iter->opal_dev, passwd_p);
|
||||
if (ret) {
|
||||
if (ret <= 0) {
|
||||
printf("get max ranges failure: %d\n", ret);
|
||||
spdk_opal_dev_destruct(iter->opal_dev);
|
||||
return;
|
||||
}
|
||||
|
||||
max_ranges = spdk_opal_get_max_locking_ranges(iter->opal_dev);
|
||||
max_ranges = ret;
|
||||
for (i = 0; i < max_ranges; i++) {
|
||||
ret = spdk_opal_cmd_get_locking_range_info(iter->opal_dev,
|
||||
passwd_p, OPAL_ADMIN1, i);
|
||||
|
@ -142,7 +142,4 @@ int spdk_opal_cmd_secure_erase_locking_range(struct spdk_opal_dev *dev, enum spd
|
||||
struct spdk_opal_locking_range_info *spdk_opal_get_locking_range_info(struct spdk_opal_dev *dev,
|
||||
enum spdk_opal_locking_range id);
|
||||
void spdk_opal_free_locking_range_info(struct spdk_opal_dev *dev, enum spdk_opal_locking_range id);
|
||||
|
||||
uint8_t spdk_opal_get_max_locking_ranges(struct spdk_opal_dev *dev);
|
||||
|
||||
#endif
|
||||
|
@ -2116,6 +2116,10 @@ spdk_opal_cmd_get_max_ranges(struct spdk_opal_dev *dev, const char *passwd)
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (dev->max_ranges) {
|
||||
return dev->max_ranges;
|
||||
}
|
||||
|
||||
ret = opal_init_key(&session.opal_key, passwd, OPAL_LOCKING_RANGE_GLOBAL);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
@ -2134,17 +2138,16 @@ spdk_opal_cmd_get_max_ranges(struct spdk_opal_dev *dev, const char *passwd)
|
||||
ret = opal_get_max_ranges(dev);
|
||||
if (ret) {
|
||||
SPDK_ERRLOG("get max ranges error %d\n", ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
ret += opal_end_session(dev);
|
||||
if (ret) {
|
||||
SPDK_ERRLOG("end session error %d\n", ret);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&dev->mutex_lock);
|
||||
return ret;
|
||||
|
||||
return (ret == 0 ? dev->max_ranges : ret);
|
||||
}
|
||||
|
||||
int
|
||||
@ -2444,11 +2447,5 @@ spdk_opal_free_locking_range_info(struct spdk_opal_dev *dev, enum spdk_opal_lock
|
||||
memset(info, 0, sizeof(*info));
|
||||
}
|
||||
|
||||
uint8_t
|
||||
spdk_opal_get_max_locking_ranges(struct spdk_opal_dev *dev)
|
||||
{
|
||||
return dev->max_ranges;
|
||||
}
|
||||
|
||||
/* Log component for opal submodule */
|
||||
SPDK_LOG_REGISTER_COMPONENT("opal", SPDK_LOG_OPAL)
|
||||
|
@ -252,14 +252,6 @@ spdk_vbdev_opal_get_info_from_bdev(const char *opal_bdev_name, const char *passw
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (spdk_opal_get_max_locking_ranges(nvme_ctrlr->opal_dev) == 0) {
|
||||
rc = spdk_opal_cmd_get_max_ranges(nvme_ctrlr->opal_dev, password);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Get locking range number failure: %d\n", rc);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
locking_range_id = vbdev->cfg.locking_range_id;
|
||||
rc = spdk_opal_cmd_get_locking_range_info(nvme_ctrlr->opal_dev, password,
|
||||
OPAL_ADMIN1, locking_range_id);
|
||||
|
Loading…
Reference in New Issue
Block a user