[PATCH 1/3] nvmet: add helper to set ns->blkshift value

Chaitanya Kulkarni chaitanyak at nvidia.com
Sun Jan 23 15:37:48 PST 2022


Sagi,

On 1/23/22 1:18 AM, Sagi Grimberg wrote:
> External email: Use caution opening links or attachments
> 
> 
>>   void nvmet_file_ns_disable(struct nvmet_ns *ns)
>>   {
>>       if (ns->file) {
>> @@ -57,17 +67,14 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)
>>               return ret;
>>       }
>>
>> +     ret = nvmet_file_ns_set_blkshift(ns);
>> +     if (ret)
>> +             return ret;
>> +
>>       ret = nvmet_file_ns_revalidate(ns);
>>       if (ret)
>>               goto err;
>>
>> -     /*
>> -      * i_blkbits can be greater than the universally accepted upper 
>> bound,
>> -      * so make sure we export a sane namespace lba_shift.
>> -      */
>> -     ns->blksize_shift = min_t(u8,
>> -                     file_inode(ns->file)->i_blkbits, 12);
>> -
> 
> Any particular reason for the change in location?

So third patch in this series sets ns->bdev if file type is block
device in nvmet_file_ns_set_blkshift(). Based on ns->bdev is NULL
or not NULL that is used to determine how we calculate ns->size
in the nvmet_file_ns_revalidate(), see last patch.

Hence move blksize_shift setting before nvmet_file_ns_revalidate().

-ck



More information about the Linux-nvme mailing list