@@ -1855,26 +1855,14 @@ static int nvme_identify_ns_nvm(struct nvme_ctrl *ctrl, unsigned int nsid,
1855
1855
return ret ;
1856
1856
}
1857
1857
1858
- static void nvme_init_ms ( struct nvme_ctrl * ctrl , struct nvme_ns_head * head ,
1858
+ static void nvme_configure_pi_elbas ( struct nvme_ns_head * head ,
1859
1859
struct nvme_id_ns * id , struct nvme_id_ns_nvm * nvm )
1860
1860
{
1861
- bool first = id -> dps & NVME_NS_DPS_PI_FIRST ;
1862
- unsigned lbaf = nvme_lbaf_index (id -> flbas );
1863
- u32 elbaf ;
1864
-
1865
- head -> pi_size = 0 ;
1866
- head -> ms = le16_to_cpu (id -> lbaf [lbaf ].ms );
1867
- if (!nvm || !(ctrl -> ctratt & NVME_CTRL_ATTR_ELBAS )) {
1868
- head -> pi_size = sizeof (struct t10_pi_tuple );
1869
- head -> guard_type = NVME_NVM_NS_16B_GUARD ;
1870
- goto set_pi ;
1871
- }
1872
-
1873
- elbaf = le32_to_cpu (nvm -> elbaf [lbaf ]);
1861
+ u32 elbaf = le32_to_cpu (nvm -> elbaf [nvme_lbaf_index (id -> flbas )]);
1874
1862
1875
1863
/* no support for storage tag formats right now */
1876
1864
if (nvme_elbaf_sts (elbaf ))
1877
- goto set_pi ;
1865
+ return ;
1878
1866
1879
1867
head -> guard_type = nvme_elbaf_guard_type (elbaf );
1880
1868
switch (head -> guard_type ) {
@@ -1887,29 +1875,32 @@ static void nvme_init_ms(struct nvme_ctrl *ctrl, struct nvme_ns_head *head,
1887
1875
default :
1888
1876
break ;
1889
1877
}
1890
-
1891
- set_pi :
1892
- if (head -> pi_size && head -> ms >= head -> pi_size )
1893
- head -> pi_type = id -> dps & NVME_NS_DPS_PI_MASK ;
1894
- else
1895
- head -> pi_type = 0 ;
1896
-
1897
- if (first )
1898
- head -> pi_offset = 0 ;
1899
- else
1900
- head -> pi_offset = head -> ms - head -> pi_size ;
1901
1878
}
1902
1879
1903
1880
static void nvme_configure_metadata (struct nvme_ctrl * ctrl ,
1904
1881
struct nvme_ns_head * head , struct nvme_id_ns * id ,
1905
1882
struct nvme_id_ns_nvm * nvm )
1906
1883
{
1907
- nvme_init_ms (ctrl , head , id , nvm );
1908
-
1909
1884
head -> features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS );
1885
+ head -> pi_type = 0 ;
1886
+ head -> pi_size = 0 ;
1887
+ head -> pi_offset = 0 ;
1888
+ head -> ms = le16_to_cpu (id -> lbaf [nvme_lbaf_index (id -> flbas )].ms );
1910
1889
if (!head -> ms || !(ctrl -> ops -> flags & NVME_F_METADATA_SUPPORTED ))
1911
1890
return ;
1912
1891
1892
+ if (nvm && (ctrl -> ctratt & NVME_CTRL_ATTR_ELBAS )) {
1893
+ nvme_configure_pi_elbas (head , id , nvm );
1894
+ } else {
1895
+ head -> pi_size = sizeof (struct t10_pi_tuple );
1896
+ head -> guard_type = NVME_NVM_NS_16B_GUARD ;
1897
+ }
1898
+
1899
+ if (head -> pi_size && head -> ms >= head -> pi_size )
1900
+ head -> pi_type = id -> dps & NVME_NS_DPS_PI_MASK ;
1901
+ if (!(id -> dps & NVME_NS_DPS_PI_FIRST ))
1902
+ head -> pi_offset = head -> ms - head -> pi_size ;
1903
+
1913
1904
if (ctrl -> ops -> flags & NVME_F_FABRICS ) {
1914
1905
/*
1915
1906
* The NVMe over Fabrics specification only supports metadata as
0 commit comments