@@ -1665,14 +1665,14 @@ int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1665
1665
}
1666
1666
1667
1667
#ifdef CONFIG_BLK_DEV_INTEGRITY
1668
- static void nvme_init_integrity (struct gendisk * disk , struct nvme_ns * ns ,
1669
- u32 max_integrity_segments )
1668
+ static void nvme_init_integrity (struct gendisk * disk ,
1669
+ struct nvme_ns_head * head , u32 max_integrity_segments )
1670
1670
{
1671
1671
struct blk_integrity integrity = { };
1672
1672
1673
- switch (ns -> head -> pi_type ) {
1673
+ switch (head -> pi_type ) {
1674
1674
case NVME_NS_DPS_PI_TYPE3 :
1675
- switch (ns -> head -> guard_type ) {
1675
+ switch (head -> guard_type ) {
1676
1676
case NVME_NVM_NS_16B_GUARD :
1677
1677
integrity .profile = & t10_pi_type3_crc ;
1678
1678
integrity .tag_size = sizeof (u16 ) + sizeof (u32 );
@@ -1690,7 +1690,7 @@ static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns *ns,
1690
1690
break ;
1691
1691
case NVME_NS_DPS_PI_TYPE1 :
1692
1692
case NVME_NS_DPS_PI_TYPE2 :
1693
- switch (ns -> head -> guard_type ) {
1693
+ switch (head -> guard_type ) {
1694
1694
case NVME_NVM_NS_16B_GUARD :
1695
1695
integrity .profile = & t10_pi_type1_crc ;
1696
1696
integrity .tag_size = sizeof (u16 );
@@ -1711,26 +1711,26 @@ static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns *ns,
1711
1711
break ;
1712
1712
}
1713
1713
1714
- integrity .tuple_size = ns -> head -> ms ;
1714
+ integrity .tuple_size = head -> ms ;
1715
1715
blk_integrity_register (disk , & integrity );
1716
1716
blk_queue_max_integrity_segments (disk -> queue , max_integrity_segments );
1717
1717
}
1718
1718
#else
1719
- static void nvme_init_integrity (struct gendisk * disk , struct nvme_ns * ns ,
1720
- u32 max_integrity_segments )
1719
+ static void nvme_init_integrity (struct gendisk * disk ,
1720
+ struct nvme_ns_head * head , u32 max_integrity_segments )
1721
1721
{
1722
1722
}
1723
1723
#endif /* CONFIG_BLK_DEV_INTEGRITY */
1724
1724
1725
- static void nvme_config_discard (struct gendisk * disk , struct nvme_ns * ns )
1725
+ static void nvme_config_discard (struct nvme_ctrl * ctrl , struct gendisk * disk ,
1726
+ struct nvme_ns_head * head )
1726
1727
{
1727
- struct nvme_ctrl * ctrl = ns -> ctrl ;
1728
1728
struct request_queue * queue = disk -> queue ;
1729
1729
u32 size = queue_logical_block_size (queue );
1730
1730
1731
- if (ctrl -> dmrsl && ctrl -> dmrsl <= nvme_sect_to_lba (ns -> head , UINT_MAX ))
1731
+ if (ctrl -> dmrsl && ctrl -> dmrsl <= nvme_sect_to_lba (head , UINT_MAX ))
1732
1732
ctrl -> max_discard_sectors =
1733
- nvme_lba_to_sect (ns -> head , ctrl -> dmrsl );
1733
+ nvme_lba_to_sect (head , ctrl -> dmrsl );
1734
1734
1735
1735
if (ctrl -> max_discard_sectors == 0 ) {
1736
1736
blk_queue_max_discard_sectors (queue , 0 );
@@ -1761,21 +1761,21 @@ static bool nvme_ns_ids_equal(struct nvme_ns_ids *a, struct nvme_ns_ids *b)
1761
1761
a -> csi == b -> csi ;
1762
1762
}
1763
1763
1764
- static int nvme_init_ms (struct nvme_ns * ns , struct nvme_id_ns * id )
1764
+ static int nvme_init_ms (struct nvme_ctrl * ctrl , struct nvme_ns_head * head ,
1765
+ struct nvme_id_ns * id )
1765
1766
{
1766
1767
bool first = id -> dps & NVME_NS_DPS_PI_FIRST ;
1767
1768
unsigned lbaf = nvme_lbaf_index (id -> flbas );
1768
- struct nvme_ctrl * ctrl = ns -> ctrl ;
1769
1769
struct nvme_command c = { };
1770
1770
struct nvme_id_ns_nvm * nvm ;
1771
1771
int ret = 0 ;
1772
1772
u32 elbaf ;
1773
1773
1774
- ns -> head -> pi_size = 0 ;
1775
- ns -> head -> ms = le16_to_cpu (id -> lbaf [lbaf ].ms );
1774
+ head -> pi_size = 0 ;
1775
+ head -> ms = le16_to_cpu (id -> lbaf [lbaf ].ms );
1776
1776
if (!(ctrl -> ctratt & NVME_CTRL_ATTR_ELBAS )) {
1777
- ns -> head -> pi_size = sizeof (struct t10_pi_tuple );
1778
- ns -> head -> guard_type = NVME_NVM_NS_16B_GUARD ;
1777
+ head -> pi_size = sizeof (struct t10_pi_tuple );
1778
+ head -> guard_type = NVME_NVM_NS_16B_GUARD ;
1779
1779
goto set_pi ;
1780
1780
}
1781
1781
@@ -1784,11 +1784,11 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
1784
1784
return - ENOMEM ;
1785
1785
1786
1786
c .identify .opcode = nvme_admin_identify ;
1787
- c .identify .nsid = cpu_to_le32 (ns -> head -> ns_id );
1787
+ c .identify .nsid = cpu_to_le32 (head -> ns_id );
1788
1788
c .identify .cns = NVME_ID_CNS_CS_NS ;
1789
1789
c .identify .csi = NVME_CSI_NVM ;
1790
1790
1791
- ret = nvme_submit_sync_cmd (ns -> ctrl -> admin_q , & c , nvm , sizeof (* nvm ));
1791
+ ret = nvme_submit_sync_cmd (ctrl -> admin_q , & c , nvm , sizeof (* nvm ));
1792
1792
if (ret )
1793
1793
goto free_data ;
1794
1794
@@ -1798,13 +1798,13 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
1798
1798
if (nvme_elbaf_sts (elbaf ))
1799
1799
goto free_data ;
1800
1800
1801
- ns -> head -> guard_type = nvme_elbaf_guard_type (elbaf );
1802
- switch (ns -> head -> guard_type ) {
1801
+ head -> guard_type = nvme_elbaf_guard_type (elbaf );
1802
+ switch (head -> guard_type ) {
1803
1803
case NVME_NVM_NS_64B_GUARD :
1804
- ns -> head -> pi_size = sizeof (struct crc64_pi_tuple );
1804
+ head -> pi_size = sizeof (struct crc64_pi_tuple );
1805
1805
break ;
1806
1806
case NVME_NVM_NS_16B_GUARD :
1807
- ns -> head -> pi_size = sizeof (struct t10_pi_tuple );
1807
+ head -> pi_size = sizeof (struct t10_pi_tuple );
1808
1808
break ;
1809
1809
default :
1810
1810
break ;
@@ -1813,25 +1813,25 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
1813
1813
free_data :
1814
1814
kfree (nvm );
1815
1815
set_pi :
1816
- if (ns -> head -> pi_size && (first || ns -> head -> ms == ns -> head -> pi_size ))
1817
- ns -> head -> pi_type = id -> dps & NVME_NS_DPS_PI_MASK ;
1816
+ if (head -> pi_size && (first || head -> ms == head -> pi_size ))
1817
+ head -> pi_type = id -> dps & NVME_NS_DPS_PI_MASK ;
1818
1818
else
1819
- ns -> head -> pi_type = 0 ;
1819
+ head -> pi_type = 0 ;
1820
1820
1821
1821
return ret ;
1822
1822
}
1823
1823
1824
- static int nvme_configure_metadata (struct nvme_ns * ns , struct nvme_id_ns * id )
1824
+ static int nvme_configure_metadata (struct nvme_ctrl * ctrl ,
1825
+ struct nvme_ns_head * head , struct nvme_id_ns * id )
1825
1826
{
1826
- struct nvme_ctrl * ctrl = ns -> ctrl ;
1827
1827
int ret ;
1828
1828
1829
- ret = nvme_init_ms (ns , id );
1829
+ ret = nvme_init_ms (ctrl , head , id );
1830
1830
if (ret )
1831
1831
return ret ;
1832
1832
1833
- ns -> head -> features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS );
1834
- if (!ns -> head -> ms || !(ctrl -> ops -> flags & NVME_F_METADATA_SUPPORTED ))
1833
+ head -> features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS );
1834
+ if (!head -> ms || !(ctrl -> ops -> flags & NVME_F_METADATA_SUPPORTED ))
1835
1835
return 0 ;
1836
1836
1837
1837
if (ctrl -> ops -> flags & NVME_F_FABRICS ) {
@@ -1843,7 +1843,7 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1843
1843
if (WARN_ON_ONCE (!(id -> flbas & NVME_NS_FLBAS_META_EXT )))
1844
1844
return 0 ;
1845
1845
1846
- ns -> head -> features |= NVME_NS_EXT_LBAS ;
1846
+ head -> features |= NVME_NS_EXT_LBAS ;
1847
1847
1848
1848
/*
1849
1849
* The current fabrics transport drivers support namespace
@@ -1854,8 +1854,8 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1854
1854
* Note, this check will need to be modified if any drivers
1855
1855
* gain the ability to use other metadata formats.
1856
1856
*/
1857
- if (ctrl -> max_integrity_segments && nvme_ns_has_pi (ns -> head ))
1858
- ns -> head -> features |= NVME_NS_METADATA_SUPPORTED ;
1857
+ if (ctrl -> max_integrity_segments && nvme_ns_has_pi (head ))
1858
+ head -> features |= NVME_NS_METADATA_SUPPORTED ;
1859
1859
} else {
1860
1860
/*
1861
1861
* For PCIe controllers, we can't easily remap the separate
@@ -1864,9 +1864,9 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1864
1864
* We allow extended LBAs for the passthrough interface, though.
1865
1865
*/
1866
1866
if (id -> flbas & NVME_NS_FLBAS_META_EXT )
1867
- ns -> head -> features |= NVME_NS_EXT_LBAS ;
1867
+ head -> features |= NVME_NS_EXT_LBAS ;
1868
1868
else
1869
- ns -> head -> features |= NVME_NS_METADATA_SUPPORTED ;
1869
+ head -> features |= NVME_NS_METADATA_SUPPORTED ;
1870
1870
}
1871
1871
return 0 ;
1872
1872
}
@@ -1889,18 +1889,18 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
1889
1889
blk_queue_write_cache (q , vwc , vwc );
1890
1890
}
1891
1891
1892
- static void nvme_update_disk_info (struct gendisk * disk ,
1893
- struct nvme_ns * ns , struct nvme_id_ns * id )
1892
+ static void nvme_update_disk_info (struct nvme_ctrl * ctrl , struct gendisk * disk ,
1893
+ struct nvme_ns_head * head , struct nvme_id_ns * id )
1894
1894
{
1895
- sector_t capacity = nvme_lba_to_sect (ns -> head , le64_to_cpu (id -> nsze ));
1896
- u32 bs = 1U << ns -> head -> lba_shift ;
1895
+ sector_t capacity = nvme_lba_to_sect (head , le64_to_cpu (id -> nsze ));
1896
+ u32 bs = 1U << head -> lba_shift ;
1897
1897
u32 atomic_bs , phys_bs , io_opt = 0 ;
1898
1898
1899
1899
/*
1900
1900
* The block layer can't support LBA sizes larger than the page size
1901
1901
* yet, so catch this early and don't allow block I/O.
1902
1902
*/
1903
- if (ns -> head -> lba_shift > PAGE_SHIFT ) {
1903
+ if (head -> lba_shift > PAGE_SHIFT ) {
1904
1904
capacity = 0 ;
1905
1905
bs = (1 << 9 );
1906
1906
}
@@ -1917,7 +1917,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
1917
1917
if (id -> nsfeat & NVME_NS_FEAT_ATOMICS && id -> nawupf )
1918
1918
atomic_bs = (1 + le16_to_cpu (id -> nawupf )) * bs ;
1919
1919
else
1920
- atomic_bs = (1 + ns -> ctrl -> subsys -> awupf ) * bs ;
1920
+ atomic_bs = (1 + ctrl -> subsys -> awupf ) * bs ;
1921
1921
}
1922
1922
1923
1923
if (id -> nsfeat & NVME_NS_FEAT_IO_OPT ) {
@@ -1943,20 +1943,20 @@ static void nvme_update_disk_info(struct gendisk *disk,
1943
1943
* I/O to namespaces with metadata except when the namespace supports
1944
1944
* PI, as it can strip/insert in that case.
1945
1945
*/
1946
- if (ns -> head -> ms ) {
1946
+ if (head -> ms ) {
1947
1947
if (IS_ENABLED (CONFIG_BLK_DEV_INTEGRITY ) &&
1948
- (ns -> head -> features & NVME_NS_METADATA_SUPPORTED ))
1949
- nvme_init_integrity (disk , ns ,
1950
- ns -> ctrl -> max_integrity_segments );
1951
- else if (!nvme_ns_has_pi (ns -> head ))
1948
+ (head -> features & NVME_NS_METADATA_SUPPORTED ))
1949
+ nvme_init_integrity (disk , head ,
1950
+ ctrl -> max_integrity_segments );
1951
+ else if (!nvme_ns_has_pi (head ))
1952
1952
capacity = 0 ;
1953
1953
}
1954
1954
1955
1955
set_capacity_and_notify (disk , capacity );
1956
1956
1957
- nvme_config_discard (disk , ns );
1957
+ nvme_config_discard (ctrl , disk , head );
1958
1958
blk_queue_max_write_zeroes_sectors (disk -> queue ,
1959
- ns -> ctrl -> max_zeroes_sectors );
1959
+ ctrl -> max_zeroes_sectors );
1960
1960
}
1961
1961
1962
1962
static bool nvme_ns_is_readonly (struct nvme_ns * ns , struct nvme_ns_info * info )
@@ -2042,13 +2042,13 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
2042
2042
ns -> head -> lba_shift = id -> lbaf [lbaf ].ds ;
2043
2043
nvme_set_queue_limits (ns -> ctrl , ns -> queue );
2044
2044
2045
- ret = nvme_configure_metadata (ns , id );
2045
+ ret = nvme_configure_metadata (ns -> ctrl , ns -> head , id );
2046
2046
if (ret < 0 ) {
2047
2047
blk_mq_unfreeze_queue (ns -> disk -> queue );
2048
2048
goto out ;
2049
2049
}
2050
2050
nvme_set_chunk_sectors (ns , id );
2051
- nvme_update_disk_info (ns -> disk , ns , id );
2051
+ nvme_update_disk_info (ns -> ctrl , ns -> disk , ns -> head , id );
2052
2052
2053
2053
if (ns -> head -> ids .csi == NVME_CSI_ZNS ) {
2054
2054
ret = nvme_update_zone_info (ns , lbaf );
@@ -2078,7 +2078,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
2078
2078
2079
2079
if (nvme_ns_head_multipath (ns -> head )) {
2080
2080
blk_mq_freeze_queue (ns -> head -> disk -> queue );
2081
- nvme_update_disk_info (ns -> head -> disk , ns , id );
2081
+ nvme_update_disk_info (ns -> ctrl , ns -> head -> disk , ns -> head , id );
2082
2082
set_disk_ro (ns -> head -> disk , nvme_ns_is_readonly (ns , info ));
2083
2083
nvme_mpath_revalidate_paths (ns );
2084
2084
blk_stack_limits (& ns -> head -> disk -> queue -> limits ,
0 commit comments