Skip to content

Commit 7255b25

Browse files
Kumar Amitfacebook-github-bot
authored andcommitted
fix nvme format for oly2 hosts with non-t10dix drives
Differential Revision: D65310133 fbshipit-source-id: 9a09f6073a189cbdb407ffec3115fc06bffc710c
1 parent 615eca2 commit 7255b25

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

cookbooks/fb_storage/libraries/storage.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,25 @@ def self.get_t10dix_lbaf(device)
13831383
end
13841384
end
13851385

1386+
def self.get_non_t10dix_lbaf(device)
1387+
nsid_out = Mixlib::ShellOut.new("nvme id-ns #{device} -ojson").run_command
1388+
nsid_out.error!
1389+
nsid_json = JSON.parse(nsid_out.stdout)
1390+
1391+
# Details about output of the nvme id-ns command and it's associated structures/sub-structures can be found here:
1392+
# https://manpages.ubuntu.com/manpages/oracular/en/man2/nvme_id_ns.2.html
1393+
# More details about the bitmask values used can be bound here:
1394+
# https://github.com/torvalds/linux/blob/master/include/linux/nvme.h
1395+
1396+
# Find LBA format with data size 2^12 = 4KB
1397+
lbaf = nsid_json['lbafs'].find_index { |item| item['ds'] == 12 }
1398+
1399+
if !lbaf.nil?
1400+
return lbaf
1401+
end
1402+
return -1
1403+
end
1404+
13861405
def self.t10dix_enabled?(device)
13871406
nsid_out = Mixlib::ShellOut.new("nvme id-ns #{device} -ojson").run_command
13881407
nsid_out.error!

0 commit comments

Comments
 (0)