Skip to content

Commit cb0f32e

Browse files
Mike Christiemartinkpetersen
authored andcommitted
scsi: target: add helper to check if dev is configured
This just adds a helper function to check if a device is configured and it converts the target users to use it. The next patch will add a backend module user so those types of modules do not have to know the lio core details. Signed-off-by: Mike Christie <mchristi@redhat.com> Reviewed-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent ff07e4a commit cb0f32e

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎drivers/target/target_core_configfs.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ static ssize_t pi_prot_type_store(struct config_item *item,
810810
dev->transport->name);
811811
return -ENOSYS;
812812
}
813-
if (!(dev->dev_flags & DF_CONFIGURED)) {
813+
if (!target_dev_configured(dev)) {
814814
pr_err("DIF protection requires device to be configured\n");
815815
return -ENODEV;
816816
}
@@ -859,7 +859,7 @@ static ssize_t pi_prot_format_store(struct config_item *item,
859859
dev->transport->name);
860860
return -ENOSYS;
861861
}
862-
if (!(dev->dev_flags & DF_CONFIGURED)) {
862+
if (!target_dev_configured(dev)) {
863863
pr_err("DIF protection format requires device to be configured\n");
864864
return -ENODEV;
865865
}
@@ -1948,7 +1948,7 @@ static ssize_t target_dev_enable_show(struct config_item *item, char *page)
19481948
{
19491949
struct se_device *dev = to_device(item);
19501950

1951-
return snprintf(page, PAGE_SIZE, "%d\n", !!(dev->dev_flags & DF_CONFIGURED));
1951+
return snprintf(page, PAGE_SIZE, "%d\n", target_dev_configured(dev));
19521952
}
19531953

19541954
static ssize_t target_dev_enable_store(struct config_item *item,
@@ -2473,7 +2473,7 @@ static ssize_t target_tg_pt_gp_alua_access_state_store(struct config_item *item,
24732473
" tg_pt_gp ID: %hu\n", tg_pt_gp->tg_pt_gp_valid_id);
24742474
return -EINVAL;
24752475
}
2476-
if (!(dev->dev_flags & DF_CONFIGURED)) {
2476+
if (!target_dev_configured(dev)) {
24772477
pr_err("Unable to set alua_access_state while device is"
24782478
" not configured\n");
24792479
return -ENODEV;

‎drivers/target/target_core_device.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ static int target_devices_idr_iter(int id, void *p, void *data)
900900
* to allow other callers to access partially setup devices,
901901
* so we skip them here.
902902
*/
903-
if (!(dev->dev_flags & DF_CONFIGURED))
903+
if (!target_dev_configured(dev))
904904
return 0;
905905

906906
iter->prev_item = config_item_get_unless_zero(&dev->dev_group.cg_item);
@@ -940,7 +940,7 @@ int target_configure_device(struct se_device *dev)
940940
struct se_hba *hba = dev->se_hba;
941941
int ret, id;
942942

943-
if (dev->dev_flags & DF_CONFIGURED) {
943+
if (target_dev_configured(dev)) {
944944
pr_err("se_dev->se_dev_ptr already set for storage"
945945
" object\n");
946946
return -EEXIST;
@@ -1045,7 +1045,7 @@ void target_free_device(struct se_device *dev)
10451045

10461046
WARN_ON(!list_empty(&dev->dev_sep_list));
10471047

1048-
if (dev->dev_flags & DF_CONFIGURED) {
1048+
if (target_dev_configured(dev)) {
10491049
destroy_workqueue(dev->tmr_wq);
10501050

10511051
dev->transport->destroy_device(dev);

‎drivers/target/target_core_fabric_configfs.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/configfs.h>
3535

3636
#include <target/target_core_base.h>
37+
#include <target/target_core_backend.h>
3738
#include <target/target_core_fabric.h>
3839

3940
#include "target_core_internal.h"
@@ -642,7 +643,7 @@ static int target_fabric_port_link(
642643
}
643644
dev = container_of(to_config_group(se_dev_ci), struct se_device, dev_group);
644645

645-
if (!(dev->dev_flags & DF_CONFIGURED)) {
646+
if (!target_dev_configured(dev)) {
646647
pr_err("se_device not configured yet, cannot port link\n");
647648
return -ENODEV;
648649
}

‎include/target/target_core_backend.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ sector_t target_to_linux_sector(struct se_device *dev, sector_t lb);
111111
bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
112112
struct request_queue *q);
113113

114+
static inline bool target_dev_configured(struct se_device *se_dev)
115+
{
116+
return !!(se_dev->dev_flags & DF_CONFIGURED);
117+
}
114118

115119
/* Only use get_unaligned_be24() if reading p - 1 is allowed. */
116120
static inline uint32_t get_unaligned_be24(const uint8_t *const p)

0 commit comments

Comments
 (0)