scsi: target: sbp: Replace enable attr with ops.enable
Remove tpg/enable attribute. Add fabric ops enable_tpg implementation instead. Link: https://lore.kernel.org/r/20210910084133.17956-5-d.bogdanov@yadro.com Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
cb8717a720
commit
fb00af92e5
@@ -2125,32 +2125,13 @@ static ssize_t sbp_tpg_directory_id_store(struct config_item *item,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t sbp_tpg_enable_show(struct config_item *item, char *page)
|
static int sbp_enable_tpg(struct se_portal_group *se_tpg, bool enable)
|
||||||
{
|
{
|
||||||
struct se_portal_group *se_tpg = to_tpg(item);
|
|
||||||
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
|
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
|
||||||
struct sbp_tport *tport = tpg->tport;
|
struct sbp_tport *tport = tpg->tport;
|
||||||
return sprintf(page, "%d\n", tport->enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t sbp_tpg_enable_store(struct config_item *item,
|
|
||||||
const char *page, size_t count)
|
|
||||||
{
|
|
||||||
struct se_portal_group *se_tpg = to_tpg(item);
|
|
||||||
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
|
|
||||||
struct sbp_tport *tport = tpg->tport;
|
|
||||||
unsigned long val;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (kstrtoul(page, 0, &val) < 0)
|
if (enable) {
|
||||||
return -EINVAL;
|
|
||||||
if ((val != 0) && (val != 1))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (tport->enable == val)
|
|
||||||
return count;
|
|
||||||
|
|
||||||
if (val) {
|
|
||||||
if (sbp_count_se_tpg_luns(&tpg->se_tpg) == 0) {
|
if (sbp_count_se_tpg_luns(&tpg->se_tpg) == 0) {
|
||||||
pr_err("Cannot enable a target with no LUNs!\n");
|
pr_err("Cannot enable a target with no LUNs!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -2165,7 +2146,7 @@ static ssize_t sbp_tpg_enable_store(struct config_item *item,
|
|||||||
spin_unlock_bh(&se_tpg->session_lock);
|
spin_unlock_bh(&se_tpg->session_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
tport->enable = val;
|
tport->enable = enable;
|
||||||
|
|
||||||
ret = sbp_update_unit_directory(tport);
|
ret = sbp_update_unit_directory(tport);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -2173,15 +2154,13 @@ static ssize_t sbp_tpg_enable_store(struct config_item *item,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIGFS_ATTR(sbp_tpg_, directory_id);
|
CONFIGFS_ATTR(sbp_tpg_, directory_id);
|
||||||
CONFIGFS_ATTR(sbp_tpg_, enable);
|
|
||||||
|
|
||||||
static struct configfs_attribute *sbp_tpg_base_attrs[] = {
|
static struct configfs_attribute *sbp_tpg_base_attrs[] = {
|
||||||
&sbp_tpg_attr_directory_id,
|
&sbp_tpg_attr_directory_id,
|
||||||
&sbp_tpg_attr_enable,
|
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2319,6 +2298,7 @@ static const struct target_core_fabric_ops sbp_ops = {
|
|||||||
.fabric_make_wwn = sbp_make_tport,
|
.fabric_make_wwn = sbp_make_tport,
|
||||||
.fabric_drop_wwn = sbp_drop_tport,
|
.fabric_drop_wwn = sbp_drop_tport,
|
||||||
.fabric_make_tpg = sbp_make_tpg,
|
.fabric_make_tpg = sbp_make_tpg,
|
||||||
|
.fabric_enable_tpg = sbp_enable_tpg,
|
||||||
.fabric_drop_tpg = sbp_drop_tpg,
|
.fabric_drop_tpg = sbp_drop_tpg,
|
||||||
.fabric_post_link = sbp_post_link_lun,
|
.fabric_post_link = sbp_post_link_lun,
|
||||||
.fabric_pre_unlink = sbp_pre_unlink_lun,
|
.fabric_pre_unlink = sbp_pre_unlink_lun,
|
||||||
|
|||||||
Reference in New Issue
Block a user