Re: [PATCH v11 8/9] nvmet-passthru: Add enable/disable helpers

From: Logan Gunthorpe
Date: Thu Feb 27 2020 - 12:37:33 EST




On 2020-02-26 4:33 p.m., Sagi Grimberg wrote:
>
>> +ÂÂÂ if (subsys->ver < NVME_VS(1, 2, 1)) {
>> +ÂÂÂÂÂÂÂ pr_warn("nvme controller version is too old: %d.%d.%d,
>> advertising 1.2.1\n",
>> +ÂÂÂÂÂÂÂÂÂÂÂ (int)NVME_MAJOR(subsys->ver),
>> +ÂÂÂÂÂÂÂÂÂÂÂ (int)NVME_MINOR(subsys->ver),
>> +ÂÂÂÂÂÂÂÂÂÂÂ (int)NVME_TERTIARY(subsys->ver));
>> +ÂÂÂÂÂÂÂ subsys->ver = NVME_VS(1, 2, 1);
>
> Umm.. is this OK? do we implement the mandatory 1.2.1 features on behalf
> of the passthru device?

This was the approach that Christoph suggested. It seemed sensible to
me. However, it would also *probably* be ok to just reject these
devices. Unless you feel strongly about this, I'll probably leave it the
way it is.

>> +ÂÂÂ }
>> +
>> +ÂÂÂ mutex_unlock(&subsys->lock);
>> +ÂÂÂ return 0;
>> +
>> +out_put_ctrl:
>> +ÂÂÂ nvme_put_ctrl(ctrl);
>> +out_unlock:
>> +ÂÂÂ mutex_unlock(&subsys->lock);
>> +ÂÂÂ return ret;
>> +}
>> +
>> +static void __nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys)
>> +{
>> +ÂÂÂ if (subsys->passthru_ctrl) {
>> +ÂÂÂÂÂÂÂ xa_erase(&passthru_subsystems, subsys->passthru_ctrl->cntlid);
>> +ÂÂÂÂÂÂÂ nvme_put_ctrl(subsys->passthru_ctrl);
>> +ÂÂÂ }
>> +ÂÂÂ subsys->passthru_ctrl = NULL;
>> +ÂÂÂ subsys->ver = NVMET_DEFAULT_VS;
>> +}
>
> Isn't it strange that a subsystem changes its version in its lifetime?

It does seem strange. However, it's not at all unprecedented. See
nvmet_subsys_attr_version_store() which gives the user direct control of
the version through configfs.

>> +
>> +void nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys)
>> +{
>> +ÂÂÂ mutex_lock(&subsys->lock);
>> +ÂÂÂ __nvmet_passthru_ctrl_disable(subsys);
>> +ÂÂÂ mutex_unlock(&subsys->lock);
>> +}
>> +
>> +void nvmet_passthru_subsys_free(struct nvmet_subsys *subsys)
>> +{
>> +ÂÂÂ mutex_lock(&subsys->lock);
>> +ÂÂÂ __nvmet_passthru_ctrl_disable(subsys);
>> +ÂÂÂ kfree(subsys->passthru_ctrl_path);
>> +ÂÂÂ mutex_unlock(&subsys->lock);
>
> Nit, any reason why the free is in the mutex?

Nope. Will fix.