@@ -312,12 +312,12 @@ static void nvme_log_error(struct request *req)
312
312
struct nvme_request * nr = nvme_req (req );
313
313
314
314
if (ns ) {
315
- pr_err_ratelimited ("%s: %s(0x%x) @ LBA %llu, %llu blocks, %s (sct 0x%x / sc 0x%x) %s%s\n" ,
315
+ pr_err_ratelimited ("%s: %s(0x%x) @ LBA %llu, %u blocks, %s (sct 0x%x / sc 0x%x) %s%s\n" ,
316
316
ns -> disk ? ns -> disk -> disk_name : "?" ,
317
317
nvme_get_opcode_str (nr -> cmd -> common .opcode ),
318
318
nr -> cmd -> common .opcode ,
319
- ( unsigned long long ) nvme_sect_to_lba (ns , blk_rq_pos (req )),
320
- ( unsigned long long ) blk_rq_bytes (req ) >> ns -> lba_shift ,
319
+ nvme_sect_to_lba (ns , blk_rq_pos (req )),
320
+ blk_rq_bytes (req ) >> ns -> head -> lba_shift ,
321
321
nvme_get_error_status_str (nr -> status ),
322
322
nr -> status >> 8 & 7 , /* Status Code Type */
323
323
nr -> status & 0xff , /* Status Code */
@@ -792,7 +792,7 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
792
792
793
793
if (queue_max_discard_segments (req -> q ) == 1 ) {
794
794
u64 slba = nvme_sect_to_lba (ns , blk_rq_pos (req ));
795
- u32 nlb = blk_rq_sectors (req ) >> (ns -> lba_shift - 9 );
795
+ u32 nlb = blk_rq_sectors (req ) >> (ns -> head -> lba_shift - 9 );
796
796
797
797
range [0 ].cattr = cpu_to_le32 (0 );
798
798
range [0 ].nlb = cpu_to_le32 (nlb );
@@ -801,7 +801,7 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
801
801
} else {
802
802
__rq_for_each_bio (bio , req ) {
803
803
u64 slba = nvme_sect_to_lba (ns , bio -> bi_iter .bi_sector );
804
- u32 nlb = bio -> bi_iter .bi_size >> ns -> lba_shift ;
804
+ u32 nlb = bio -> bi_iter .bi_size >> ns -> head -> lba_shift ;
805
805
806
806
if (n < segments ) {
807
807
range [n ].cattr = cpu_to_le32 (0 );
@@ -839,7 +839,7 @@ static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd,
839
839
u64 ref48 ;
840
840
841
841
/* both rw and write zeroes share the same reftag format */
842
- switch (ns -> guard_type ) {
842
+ switch (ns -> head -> guard_type ) {
843
843
case NVME_NVM_NS_16B_GUARD :
844
844
cmnd -> rw .reftag = cpu_to_le32 (t10_pi_ref_tag (req ));
845
845
break ;
@@ -869,15 +869,16 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns,
869
869
cmnd -> write_zeroes .slba =
870
870
cpu_to_le64 (nvme_sect_to_lba (ns , blk_rq_pos (req )));
871
871
cmnd -> write_zeroes .length =
872
- cpu_to_le16 ((blk_rq_bytes (req ) >> ns -> lba_shift ) - 1 );
872
+ cpu_to_le16 ((blk_rq_bytes (req ) >> ns -> head -> lba_shift ) - 1 );
873
873
874
- if (!(req -> cmd_flags & REQ_NOUNMAP ) && (ns -> features & NVME_NS_DEAC ))
874
+ if (!(req -> cmd_flags & REQ_NOUNMAP ) &&
875
+ (ns -> head -> features & NVME_NS_DEAC ))
875
876
cmnd -> write_zeroes .control |= cpu_to_le16 (NVME_WZ_DEAC );
876
877
877
878
if (nvme_ns_has_pi (ns )) {
878
879
cmnd -> write_zeroes .control |= cpu_to_le16 (NVME_RW_PRINFO_PRACT );
879
880
880
- switch (ns -> pi_type ) {
881
+ switch (ns -> head -> pi_type ) {
881
882
case NVME_NS_DPS_PI_TYPE1 :
882
883
case NVME_NS_DPS_PI_TYPE2 :
883
884
nvme_set_ref_tag (ns , cmnd , req );
@@ -910,12 +911,13 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
910
911
cmnd -> rw .cdw3 = 0 ;
911
912
cmnd -> rw .metadata = 0 ;
912
913
cmnd -> rw .slba = cpu_to_le64 (nvme_sect_to_lba (ns , blk_rq_pos (req )));
913
- cmnd -> rw .length = cpu_to_le16 ((blk_rq_bytes (req ) >> ns -> lba_shift ) - 1 );
914
+ cmnd -> rw .length =
915
+ cpu_to_le16 ((blk_rq_bytes (req ) >> ns -> head -> lba_shift ) - 1 );
914
916
cmnd -> rw .reftag = 0 ;
915
917
cmnd -> rw .apptag = 0 ;
916
918
cmnd -> rw .appmask = 0 ;
917
919
918
- if (ns -> ms ) {
920
+ if (ns -> head -> ms ) {
919
921
/*
920
922
* If formated with metadata, the block layer always provides a
921
923
* metadata buffer if CONFIG_BLK_DEV_INTEGRITY is enabled. Else
@@ -928,7 +930,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
928
930
control |= NVME_RW_PRINFO_PRACT ;
929
931
}
930
932
931
- switch (ns -> pi_type ) {
933
+ switch (ns -> head -> pi_type ) {
932
934
case NVME_NS_DPS_PI_TYPE3 :
933
935
control |= NVME_RW_PRINFO_PRCHK_GUARD ;
934
936
break ;
@@ -1663,9 +1665,9 @@ static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns *ns,
1663
1665
{
1664
1666
struct blk_integrity integrity = { };
1665
1667
1666
- switch (ns -> pi_type ) {
1668
+ switch (ns -> head -> pi_type ) {
1667
1669
case NVME_NS_DPS_PI_TYPE3 :
1668
- switch (ns -> guard_type ) {
1670
+ switch (ns -> head -> guard_type ) {
1669
1671
case NVME_NVM_NS_16B_GUARD :
1670
1672
integrity .profile = & t10_pi_type3_crc ;
1671
1673
integrity .tag_size = sizeof (u16 ) + sizeof (u32 );
@@ -1683,7 +1685,7 @@ static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns *ns,
1683
1685
break ;
1684
1686
case NVME_NS_DPS_PI_TYPE1 :
1685
1687
case NVME_NS_DPS_PI_TYPE2 :
1686
- switch (ns -> guard_type ) {
1688
+ switch (ns -> head -> guard_type ) {
1687
1689
case NVME_NVM_NS_16B_GUARD :
1688
1690
integrity .profile = & t10_pi_type1_crc ;
1689
1691
integrity .tag_size = sizeof (u16 );
@@ -1704,7 +1706,7 @@ static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns *ns,
1704
1706
break ;
1705
1707
}
1706
1708
1707
- integrity .tuple_size = ns -> ms ;
1709
+ integrity .tuple_size = ns -> head -> ms ;
1708
1710
blk_integrity_register (disk , & integrity );
1709
1711
blk_queue_max_integrity_segments (disk -> queue , max_integrity_segments );
1710
1712
}
@@ -1763,11 +1765,11 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
1763
1765
int ret = 0 ;
1764
1766
u32 elbaf ;
1765
1767
1766
- ns -> pi_size = 0 ;
1767
- ns -> ms = le16_to_cpu (id -> lbaf [lbaf ].ms );
1768
+ ns -> head -> pi_size = 0 ;
1769
+ ns -> head -> ms = le16_to_cpu (id -> lbaf [lbaf ].ms );
1768
1770
if (!(ctrl -> ctratt & NVME_CTRL_ATTR_ELBAS )) {
1769
- ns -> pi_size = sizeof (struct t10_pi_tuple );
1770
- ns -> guard_type = NVME_NVM_NS_16B_GUARD ;
1771
+ ns -> head -> pi_size = sizeof (struct t10_pi_tuple );
1772
+ ns -> head -> guard_type = NVME_NVM_NS_16B_GUARD ;
1771
1773
goto set_pi ;
1772
1774
}
1773
1775
@@ -1790,13 +1792,13 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
1790
1792
if (nvme_elbaf_sts (elbaf ))
1791
1793
goto free_data ;
1792
1794
1793
- ns -> guard_type = nvme_elbaf_guard_type (elbaf );
1794
- switch (ns -> guard_type ) {
1795
+ ns -> head -> guard_type = nvme_elbaf_guard_type (elbaf );
1796
+ switch (ns -> head -> guard_type ) {
1795
1797
case NVME_NVM_NS_64B_GUARD :
1796
- ns -> pi_size = sizeof (struct crc64_pi_tuple );
1798
+ ns -> head -> pi_size = sizeof (struct crc64_pi_tuple );
1797
1799
break ;
1798
1800
case NVME_NVM_NS_16B_GUARD :
1799
- ns -> pi_size = sizeof (struct t10_pi_tuple );
1801
+ ns -> head -> pi_size = sizeof (struct t10_pi_tuple );
1800
1802
break ;
1801
1803
default :
1802
1804
break ;
@@ -1805,10 +1807,10 @@ static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)
1805
1807
free_data :
1806
1808
kfree (nvm );
1807
1809
set_pi :
1808
- if (ns -> pi_size && (first || ns -> ms == ns -> pi_size ))
1809
- ns -> pi_type = id -> dps & NVME_NS_DPS_PI_MASK ;
1810
+ if (ns -> head -> pi_size && (first || ns -> head -> ms == ns -> head -> pi_size ))
1811
+ ns -> head -> pi_type = id -> dps & NVME_NS_DPS_PI_MASK ;
1810
1812
else
1811
- ns -> pi_type = 0 ;
1813
+ ns -> head -> pi_type = 0 ;
1812
1814
1813
1815
return ret ;
1814
1816
}
@@ -1822,8 +1824,8 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1822
1824
if (ret )
1823
1825
return ret ;
1824
1826
1825
- ns -> features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS );
1826
- if (!ns -> ms || !(ctrl -> ops -> flags & NVME_F_METADATA_SUPPORTED ))
1827
+ ns -> head -> features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS );
1828
+ if (!ns -> head -> ms || !(ctrl -> ops -> flags & NVME_F_METADATA_SUPPORTED ))
1827
1829
return 0 ;
1828
1830
1829
1831
if (ctrl -> ops -> flags & NVME_F_FABRICS ) {
@@ -1835,7 +1837,7 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1835
1837
if (WARN_ON_ONCE (!(id -> flbas & NVME_NS_FLBAS_META_EXT )))
1836
1838
return 0 ;
1837
1839
1838
- ns -> features |= NVME_NS_EXT_LBAS ;
1840
+ ns -> head -> features |= NVME_NS_EXT_LBAS ;
1839
1841
1840
1842
/*
1841
1843
* The current fabrics transport drivers support namespace
@@ -1847,7 +1849,7 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1847
1849
* gain the ability to use other metadata formats.
1848
1850
*/
1849
1851
if (ctrl -> max_integrity_segments && nvme_ns_has_pi (ns ))
1850
- ns -> features |= NVME_NS_METADATA_SUPPORTED ;
1852
+ ns -> head -> features |= NVME_NS_METADATA_SUPPORTED ;
1851
1853
} else {
1852
1854
/*
1853
1855
* For PCIe controllers, we can't easily remap the separate
@@ -1856,9 +1858,9 @@ static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
1856
1858
* We allow extended LBAs for the passthrough interface, though.
1857
1859
*/
1858
1860
if (id -> flbas & NVME_NS_FLBAS_META_EXT )
1859
- ns -> features |= NVME_NS_EXT_LBAS ;
1861
+ ns -> head -> features |= NVME_NS_EXT_LBAS ;
1860
1862
else
1861
- ns -> features |= NVME_NS_METADATA_SUPPORTED ;
1863
+ ns -> head -> features |= NVME_NS_METADATA_SUPPORTED ;
1862
1864
}
1863
1865
return 0 ;
1864
1866
}
@@ -1885,14 +1887,14 @@ static void nvme_update_disk_info(struct gendisk *disk,
1885
1887
struct nvme_ns * ns , struct nvme_id_ns * id )
1886
1888
{
1887
1889
sector_t capacity = nvme_lba_to_sect (ns , le64_to_cpu (id -> nsze ));
1888
- u32 bs = 1U << ns -> lba_shift ;
1890
+ u32 bs = 1U << ns -> head -> lba_shift ;
1889
1891
u32 atomic_bs , phys_bs , io_opt = 0 ;
1890
1892
1891
1893
/*
1892
1894
* The block layer can't support LBA sizes larger than the page size
1893
1895
* yet, so catch this early and don't allow block I/O.
1894
1896
*/
1895
- if (ns -> lba_shift > PAGE_SHIFT ) {
1897
+ if (ns -> head -> lba_shift > PAGE_SHIFT ) {
1896
1898
capacity = 0 ;
1897
1899
bs = (1 << 9 );
1898
1900
}
@@ -1935,9 +1937,9 @@ static void nvme_update_disk_info(struct gendisk *disk,
1935
1937
* I/O to namespaces with metadata except when the namespace supports
1936
1938
* PI, as it can strip/insert in that case.
1937
1939
*/
1938
- if (ns -> ms ) {
1940
+ if (ns -> head -> ms ) {
1939
1941
if (IS_ENABLED (CONFIG_BLK_DEV_INTEGRITY ) &&
1940
- (ns -> features & NVME_NS_METADATA_SUPPORTED ))
1942
+ (ns -> head -> features & NVME_NS_METADATA_SUPPORTED ))
1941
1943
nvme_init_integrity (disk , ns ,
1942
1944
ns -> ctrl -> max_integrity_segments );
1943
1945
else if (!nvme_ns_has_pi (ns ))
@@ -2031,7 +2033,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
2031
2033
2032
2034
blk_mq_freeze_queue (ns -> disk -> queue );
2033
2035
lbaf = nvme_lbaf_index (id -> flbas );
2034
- ns -> lba_shift = id -> lbaf [lbaf ].ds ;
2036
+ ns -> head -> lba_shift = id -> lbaf [lbaf ].ds ;
2035
2037
nvme_set_queue_limits (ns -> ctrl , ns -> queue );
2036
2038
2037
2039
ret = nvme_configure_metadata (ns , id );
@@ -2057,7 +2059,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
2057
2059
* do not return zeroes.
2058
2060
*/
2059
2061
if ((id -> dlfeat & 0x7 ) == 0x1 && (id -> dlfeat & (1 << 3 )))
2060
- ns -> features |= NVME_NS_DEAC ;
2062
+ ns -> head -> features |= NVME_NS_DEAC ;
2061
2063
set_disk_ro (ns -> disk , nvme_ns_is_readonly (ns , info ));
2062
2064
set_bit (NVME_NS_READY , & ns -> flags );
2063
2065
blk_mq_unfreeze_queue (ns -> disk -> queue );
0 commit comments