@@ -2076,6 +2076,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
20762076 bool vwc = ns -> ctrl -> vwc & NVME_CTRL_VWC_PRESENT ;
20772077 struct queue_limits lim ;
20782078 struct nvme_id_ns_nvm * nvm = NULL ;
2079+ struct nvme_zone_info zi = {};
20792080 struct nvme_id_ns * id ;
20802081 sector_t capacity ;
20812082 unsigned lbaf ;
@@ -2088,18 +2089,25 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
20882089 if (id -> ncap == 0 ) {
20892090 /* namespace not allocated or attached */
20902091 info -> is_removed = true;
2091- ret = - ENODEV ;
2092+ ret = - ENXIO ;
20922093 goto out ;
20932094 }
2095+ lbaf = nvme_lbaf_index (id -> flbas );
20942096
20952097 if (ns -> ctrl -> ctratt & NVME_CTRL_ATTR_ELBAS ) {
20962098 ret = nvme_identify_ns_nvm (ns -> ctrl , info -> nsid , & nvm );
20972099 if (ret < 0 )
20982100 goto out ;
20992101 }
21002102
2103+ if (IS_ENABLED (CONFIG_BLK_DEV_ZONED ) &&
2104+ ns -> head -> ids .csi == NVME_CSI_ZNS ) {
2105+ ret = nvme_query_zone_info (ns , lbaf , & zi );
2106+ if (ret < 0 )
2107+ goto out ;
2108+ }
2109+
21012110 blk_mq_freeze_queue (ns -> disk -> queue );
2102- lbaf = nvme_lbaf_index (id -> flbas );
21032111 ns -> head -> lba_shift = id -> lbaf [lbaf ].ds ;
21042112 ns -> head -> nuse = le64_to_cpu (id -> nuse );
21052113 capacity = nvme_lba_to_sect (ns -> head , le64_to_cpu (id -> nsze ));
@@ -2112,13 +2120,8 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21122120 capacity = 0 ;
21132121 nvme_config_discard (ns , & lim );
21142122 if (IS_ENABLED (CONFIG_BLK_DEV_ZONED ) &&
2115- ns -> head -> ids .csi == NVME_CSI_ZNS ) {
2116- ret = nvme_update_zone_info (ns , lbaf , & lim );
2117- if (ret ) {
2118- blk_mq_unfreeze_queue (ns -> disk -> queue );
2119- goto out ;
2120- }
2121- }
2123+ ns -> head -> ids .csi == NVME_CSI_ZNS )
2124+ nvme_update_zone_info (ns , & lim , & zi );
21222125 ret = queue_limits_commit_update (ns -> disk -> queue , & lim );
21232126 if (ret ) {
21242127 blk_mq_unfreeze_queue (ns -> disk -> queue );
@@ -2201,6 +2204,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
22012204 }
22022205
22032206 if (!ret && nvme_ns_head_multipath (ns -> head )) {
2207+ struct queue_limits * ns_lim = & ns -> disk -> queue -> limits ;
22042208 struct queue_limits lim ;
22052209
22062210 blk_mq_freeze_queue (ns -> head -> disk -> queue );
@@ -2212,7 +2216,26 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
22122216 set_disk_ro (ns -> head -> disk , nvme_ns_is_readonly (ns , info ));
22132217 nvme_mpath_revalidate_paths (ns );
22142218
2219+ /*
2220+ * queue_limits mixes values that are the hardware limitations
2221+ * for bio splitting with what is the device configuration.
2222+ *
2223+ * For NVMe the device configuration can change after e.g. a
2224+ * Format command, and we really want to pick up the new format
2225+ * value here. But we must still stack the queue limits to the
2226+ * least common denominator for multipathing to split the bios
2227+ * properly.
2228+ *
2229+ * To work around this, we explicitly set the device
2230+ * configuration to those that we just queried, but only stack
2231+ * the splitting limits in to make sure we still obey possibly
2232+ * lower limitations of other controllers.
2233+ */
22152234 lim = queue_limits_start_update (ns -> head -> disk -> queue );
2235+ lim .logical_block_size = ns_lim -> logical_block_size ;
2236+ lim .physical_block_size = ns_lim -> physical_block_size ;
2237+ lim .io_min = ns_lim -> io_min ;
2238+ lim .io_opt = ns_lim -> io_opt ;
22162239 queue_limits_stack_bdev (& lim , ns -> disk -> part0 , 0 ,
22172240 ns -> head -> disk -> disk_name );
22182241 ret = queue_limits_commit_update (ns -> head -> disk -> queue , & lim );
0 commit comments