From e37992e9a03c54e0fc928ccc1ca31cd8bdf8e1d9 Mon Sep 17 00:00:00 2001 From: Kumar Amit Date: Mon, 21 Oct 2024 06:15:11 -0700 Subject: [PATCH] Facebook: [hypernode][oly2] nvme format with T10-DIX enabled if supported by device Summary: We want to enable T10-DIX support during nvme format for drives that support it. As of today, we were doing it only for a list of specific model Ids (currently all OLY2.0). As different models for OLY2.x are added to the fleet, we need to keep updating this list with model Ids that support T10-DIX. This diff checks if a drive supports t10dix in the way we want and enables it if it does. Differential Revision: D64211281 fbshipit-source-id: 17c6a0be38b9c8cc15cfef5e7b632334099e66b4 --- cookbooks/fb_storage/libraries/storage.rb | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cookbooks/fb_storage/libraries/storage.rb b/cookbooks/fb_storage/libraries/storage.rb index 09cddf8f..5fb38b62 100644 --- a/cookbooks/fb_storage/libraries/storage.rb +++ b/cookbooks/fb_storage/libraries/storage.rb @@ -1350,6 +1350,32 @@ def gen_fb_fstab(node) fstab end + def self.oly2_host?(node) + node.in_fbwhoami?('server_type', 'TYPE_VIII_MATER') && node.in_fbwhoami?('CPU_ARCHITECTURE', 'sierraforest') + end + + def self.get_t10dix_lbaf(device) + nsid_out = Mixlib::ShellOut.new("nvme id-ns #{device} -ojson").run_command + nsid_out.error! + nsid_json = JSON.parse(nsid_out.stdout) + + # Details about output of the nvme id-ns command and it's associated structures/sub-structures can be found here: + # https://manpages.ubuntu.com/manpages/oracular/en/man2/nvme_id_ns.2.html + # More details about the bitmask values used can be bound here: + # https://github.com/torvalds/linux/blob/master/include/linux/nvme.h + + # Find LBA format with metadata size 64 bytes and data size 2^12 = 4KB + lbaf = nsid_json['lbafs'].find_index { |item| item['ms'] == 64 && item['ds'] == 12 } + # Ensure Protection Information (PI) Type 3 is supported and PI is transferred as the last 8 bytes of the metadata + dpc_valid = (nsid_json['dpc'] & (1 << 2) != 0 && nsid_json['dpc'] & (1 << 4) != 0) + + if lbaf != -1 && dpc_valid + return lbaf + else + return -1 + end + end + private # we make an instance method that calls a class method for easier testing