Skip to content

Commit 356ba2a

Browse files
BStroessermartinkpetersen
authored andcommitted
scsi: target: tcmu: Make pgr_support and alua_support attributes writable
Currently in tcmu reservation commands are handled by core's pr implementation (default) or completely rejected (emulate_pr set to 0). We additionally want to be able to do full reservation handling in userspace. Therefore we need a way to set TRANSPORT_FLAG_PASSTHROUGH_PGR. The inverted flag is displayed by attribute pgr_support. Since we moved the flag from transport/backend to se_device in the previous commit, we now can make it changeable per device by allowing to write the attribute. The new field transport_flags_changeable in transport/backend is used to reject writing if not allowed for a backend. Regarding ALUA we also want to be able to passthrough commands to userspace in tcmu. Therefore we need TRANSPORT_FLAG_PASSTHROUGH_ALUA to be changeable, because by setting it we can switch off all ALUA checks in core. So we also set TRANSPORT_FLAG_PASSTHROUGH_ALUA in tcmu's transport_flags_changeable. Of course, ALUA and reservation handling in userspace will work only, if session/nexus information is sent to userspace along with every command. This will be object of a patch series announced by Mike Christie. Link: https://lore.kernel.org/r/20200427150823.15350-5-bstroesser@ts.fujitsu.com Reviewed-by: Mike Christie <mchristi@redhat.com> Signed-off-by: Bodo Stroesser <bstroesser@ts.fujitsu.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 69088a0 commit 356ba2a

3 files changed

Lines changed: 57 additions & 2 deletions

File tree

‎drivers/target/target_core_configfs.c‎

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,32 @@ static ssize_t alua_support_show(struct config_item *item, char *page)
11051105
flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ? 0 : 1);
11061106
}
11071107

1108+
static ssize_t alua_support_store(struct config_item *item,
1109+
const char *page, size_t count)
1110+
{
1111+
struct se_dev_attrib *da = to_attrib(item);
1112+
struct se_device *dev = da->da_dev;
1113+
bool flag;
1114+
int ret;
1115+
1116+
if (!(dev->transport->transport_flags_changeable &
1117+
TRANSPORT_FLAG_PASSTHROUGH_ALUA)) {
1118+
pr_err("dev[%p]: Unable to change SE Device alua_support:"
1119+
" alua_support has fixed value\n", dev);
1120+
return -EINVAL;
1121+
}
1122+
1123+
ret = strtobool(page, &flag);
1124+
if (ret < 0)
1125+
return ret;
1126+
1127+
if (flag)
1128+
dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_ALUA;
1129+
else
1130+
dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_ALUA;
1131+
return count;
1132+
}
1133+
11081134
static ssize_t pgr_support_show(struct config_item *item, char *page)
11091135
{
11101136
struct se_dev_attrib *da = to_attrib(item);
@@ -1114,6 +1140,32 @@ static ssize_t pgr_support_show(struct config_item *item, char *page)
11141140
flags & TRANSPORT_FLAG_PASSTHROUGH_PGR ? 0 : 1);
11151141
}
11161142

1143+
static ssize_t pgr_support_store(struct config_item *item,
1144+
const char *page, size_t count)
1145+
{
1146+
struct se_dev_attrib *da = to_attrib(item);
1147+
struct se_device *dev = da->da_dev;
1148+
bool flag;
1149+
int ret;
1150+
1151+
if (!(dev->transport->transport_flags_changeable &
1152+
TRANSPORT_FLAG_PASSTHROUGH_PGR)) {
1153+
pr_err("dev[%p]: Unable to change SE Device pgr_support:"
1154+
" pgr_support has fixed value\n", dev);
1155+
return -EINVAL;
1156+
}
1157+
1158+
ret = strtobool(page, &flag);
1159+
if (ret < 0)
1160+
return ret;
1161+
1162+
if (flag)
1163+
dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_PGR;
1164+
else
1165+
dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_PGR;
1166+
return count;
1167+
}
1168+
11171169
CONFIGFS_ATTR(, emulate_model_alias);
11181170
CONFIGFS_ATTR(, emulate_dpo);
11191171
CONFIGFS_ATTR(, emulate_fua_write);
@@ -1146,8 +1198,8 @@ CONFIGFS_ATTR(, unmap_granularity);
11461198
CONFIGFS_ATTR(, unmap_granularity_alignment);
11471199
CONFIGFS_ATTR(, unmap_zeroes_data);
11481200
CONFIGFS_ATTR(, max_write_same_len);
1149-
CONFIGFS_ATTR_RO(, alua_support);
1150-
CONFIGFS_ATTR_RO(, pgr_support);
1201+
CONFIGFS_ATTR(, alua_support);
1202+
CONFIGFS_ATTR(, pgr_support);
11511203

11521204
/*
11531205
* dev_attrib attributes for devices using the target core SBC/SPC

‎drivers/target/target_core_user.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,8 @@ static struct target_backend_ops tcmu_ops = {
26172617
.name = "user",
26182618
.owner = THIS_MODULE,
26192619
.transport_flags_default = TRANSPORT_FLAG_PASSTHROUGH,
2620+
.transport_flags_changeable = TRANSPORT_FLAG_PASSTHROUGH_PGR |
2621+
TRANSPORT_FLAG_PASSTHROUGH_ALUA,
26202622
.attach_hba = tcmu_attach_hba,
26212623
.detach_hba = tcmu_detach_hba,
26222624
.alloc_device = tcmu_alloc_device,

‎include/target/target_core_backend.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct target_backend_ops {
2424
struct module *owner;
2525

2626
u8 transport_flags_default;
27+
u8 transport_flags_changeable;
2728

2829
int (*attach_hba)(struct se_hba *, u32);
2930
void (*detach_hba)(struct se_hba *);

0 commit comments

Comments
 (0)