3 minute read

NVMe spec 4.0

8.2 Metadata handling

  • logical block 단위로(마다) meatadata가 붙는다. 어떻게 이 metadata 영역을 쓸지는 Host의 자유이고, 가장 common 한 활용처 중 하나가 end-to-end protection information을 담는 것이다.
  • Metadata는 LBA data에 연속해서 오거나 별도 buffer에 담겨서 오는데, 어느 방식을 채택할지는 format 시에 결정된다. Format command의 MSET field가 1이면 extended. 0이면 separate buffer.

8.3 End-to-end Data Protection (Optional)

  • PI가 사용되는 경우 metadata 영역에 CRC와 같은 값드을 저장하게 됨.
  • PI는 metadata의 첫 8바이트거나 마지막 8바이트임. 대부분의 경우 CRC는 LBA data만으로 계산하지만, metadata가 8바이트보다 크면서 PI가 metadata의 마지막에 오는 경우, LBA데이터와 PI를 제외한 메타데이터를 모두 사용하여 CRC를 계산하게 됨.
  • extended metadata를 사용하는 경우를 DIF라고 부르고 seperate buffer를 사용하는 경우를 DIX라고 부름.
  • end-to-end protection type에는 3가지 종류가 있는데 Format Command의 PI 필드에 의해 결정됨. 0은 PI를 사용하지 않음. 1~3은 각각의 타입. 4 이상은 reserved.
Field Description
Protection Information (PI)[08:07] 000b Protection information is not enabled / 001b Protection information is enabled, Type 1 / 010b Protection information is enabled, Type 2 / 011b Protection information is enabled, Type 3 / 100b to 111b Reserved
Metadata Settings (MSET)[04:04] This bit is set to ‘1’ if the metadata is transferred as part of an extended data LBA. This bit is cleared to ‘0’ if the metadata is transferred as part of a separate buffer. The metadata may include protection information, based on the Protection Information (PI) field. If the Metadata Size for the LBA Format selected is 0h, then this bit is not applicable.
  • PI의 8바이트는 Guard(2B), Applicaton Tag(2B), Reference Tag(4B)로 구성된다. (SCSI Protection information model) Guard는 CRC-16값. Application tag는 특별히 정의되어 있지 않으나 Host가 특별하게 사용하거나 PI check를 disable하는데 사용. Reference tag는 LBA간의 순서 등을 체크하는 데 사용되거나 PI check를 disable 하는데 사용.

  • read/write 시의 prinfo field는 다시 PRACT와 PRCHK로 구분되고 이 비트들의 조합에 따라 PI의 동작이 달라진다.

Field Description
Protection Information Field (PRINFO)[29:26] Specifies the protection information action and check field, as defined in Figure 355.

6.5 End-to-end protection information

Field Description
Protection Information Action (PRACT)[03:03] The protection information action bit indicates the action to take for the protection information. This bit is only used if the namespace is formatted to use end-to-end protection information. Refer to section 8.3
Protection Information Check (PRCHK)[02:00] : The protection information check field specifies the fields that shall be checked as part of end-to-end data protection processing. This field is only used if the namespace is formatted to use end-to-end protection information. Refer to section 8.3.

8.3 End-to-end Data Protection (Optional) (Cont.)

8.3.1 the PRACT bit

이 아래로 모두 PI를 사용하도록 format 되었다고 가정한다.
PRACT는 controller가 PI를 만들 것인지를 설정하는 비트, PRCHK는 PI 중 어떤 필드를 체크할지 설정하는 비트라고 생각하면 편함.

Write Command

  • PRACT가 0일 때 Host는 PI 데이터를 만들어서 controller에 보낸다. controller는 이 PI가 valid 한지 check 한다. Error가 발견되었다면 command가 해당 status code와 함께 종료된다. (ex. End-to-end guard Check Error.)
  • PRACT가 1일 때
    • 해당 NS의 metadata size가 8이라면 host는 metadata를 만들지 않고 LBA 데이터만 보낸다. controller는 metadata를 만들어서 NAND에 저장한다.
    • 해당 NS의 metadata size가 8보다 크다면 host가 metadata를 만들어서 내려보낸다. (PI 외의 metadata도 있으니까) 다만 PI 부분은 controller가 만들어서 내려온 metadata에 덮어 씌워서 저장한다.

Read Command

  • PRACT가 0일 때 controller는 Nand에서 데이터를 읽어서 PI를 체크한 후 Host에 그대로 보낸다. Error가 발견되었다면 command가 해당 status code와 함께 종료된다. (ex. End-to-end guard Check Error)
  • PRACT가 1일 때
    • 해당 NS의 metadata size가 8이라면 Nand에서 데이터를 읽어 PI 체크를 한 후 이를 제거하고 host에는 LBA data만 보낸다.
    • 해당 NS의 metadata size가 8보다 크다면 PI를 체크한 후 metadata까지 host로 보낸다.

PRCHK

  • PRCHK[2] == 1 : Guard 정합성 체크
  • PRCHK[1] == 1 : app tag의 unmask 된 영역을 커맨드의 LBAT field와 비교. mask는 커맨드의 LBATM 필드에서 mask 하고 싶은 부분을 0으로 만들면 됨. (= LBATM이 1인 부분만 체크의 대상이 됨)
  • PRCHK[0] == 1
    • PI type == 1 : 첫 번째 metadata block의 ref tag 값이 slba의 least significant 4 bytes와 동일. 이 값은 다시 ILBRT(write command) / EILBRT(read command)와 동일. 두 번째 이후 metadata block은 앞 block의 ref tag 값 +1.
    • PI type == 2 : 첫 번째 metadata block의 ref tag 값은 host가 지정. 이 값은 command의 ILBRT / EILBRT와 동일. 두 번째 이후 metadata block은 앞 block의 ref tag 값 +1.
    • PI type == 3 : PI가 3인데 PRCHK[0] == 1이라면 Invalid protection information으로 해당 커맨드는 abort 됨.
  • PI type이 1이나 2인데 app tag 값이 0xFFFF라면 PRCHK 값과 상관없이 PI check를 하지 않는다.
  • PI type이 3인데 app tag 값이 0xFFFF이면서 ref tag 값이 0xFFFFFFFF이라면 PI check를 하지 않는다.