Monday, 10 September 2018

Mapping NetApp's inode (hexadecimal) to Linux inode (decimal)

OS: ONTAP 9.4
LINUX:Linux centos7 3.10.0-693.el7.x86_64


vserver :SVM_NFS
Volume  :vol_NFS
Protocol: NFSv3


First mount the NFS vol to Linux: [Assuming you have already exported the NFS vol to the Linux client(s)]
[root@centos7 /]# mount -t nfs 192.168.0.215:/vol_NFS /mnt/nfs-mount/


Create a text file using touch command:
[root@centos7 nfs-mount]# touch test

Use vi editor to write something inside the file, I have written 'NetApp is fun to work with!!!'


Use cat command to verify what you wrote:
[root@centos7 nfs-mount]# cat test
NetApp is fun to work with!!!


Next : Lets identify the inode or a file-handle in ONTAP:

Go to advanced Cluster shell level: set adv
Use the following command: 'file show-filehandle' ; as shown below.


ONTAP94::*> file show-filehandle -vserver SVM_NFS -path /vol/vol_NFS/test
 Vserver                    Path
 ----------------------     ---------------------------
 SVM_NFS                     /vol/vol_NFS/test

 flags   snapid  fileid     generation      fsid             msid          dsid
 ------- ------  ---------      ----------  ----------  ------------  ------------
 0x0     0       0x5d09     0x1b15bd    0x402       0x80024296    0x402

ONTAP94::*>



There is an additional command at the 'node' level to view the file-handle (inode) is called 'showfh':

ONTAP94::*> node run -node ONTAP94-01 -command showfh /vol/vol_NFS/test
flags=0x00 snapid=0 fileid=0x005d09 gen=0x1b15bd fsid=0x000402 dsid=0x00000000000402 msid=0x00000080024296
ONTAP94::*>


At Linux OS, use the command 'stat and file name' to view the inode of the file:

[root@centos7 /]# stat /mnt/nfs-mount/test
  File: ‘/mnt/nfs-mount/test’
  Size: 30              Blocks: 0          IO Block: 1048576 regular file
Device: 2bh/43d Inode: 1117150473  Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:nfs_t:s0
Access: 2018-09-10 09:28:40.581214000 +0100
Modify: 2018-09-10 09:28:40.581249000 +0100
Change: 2018-09-10 09:28:40.581294000 +0100
 Birth: -
[root@centos7 /]#

We found the inode for the file 'test' from Linux side: Inode: 1117150473

Inode: 1117150473 <---Convert this from decimal into hexadecimal (use google) and you obtain = 42965D09

Now, split this [42965D09] into two halfs = 4296 & 5D09 and compare the two with the output from the 'show-filehandle'command:

NetApp -> fileid (inode) = 0x5d09
Linux    -> inode             = 5D09

NetApp -> msid               = 0x80024296
Linux   -> part of inode   = 4296


This confirms they match as expected.


TIP: In Cluster ONTAP - Every volume has MSID and DSID [Master Data Set ID & Data Set ID], like Parent & Child relation of a object. Please remember, this will be unique for each new volume, exception if it's a Cloned volume or load sharing Mirrored volume, in which case the MSID will remain the same but DSID will be unique.


Now, let's use the hexdump to view the contents of the file 'test', remember what we wrote - 'NetApp is fun to work with!!!'

This command basically prints the output in hexadump format and contains an additional column shows the corresponding ASCII text translation.

Node level : priv set diag;

This output clearly shows - Where exactly the 'data' is stored, the actual disk, and the disk's block number and the Physical block (vbn or pvbn) which belongs to aggregate. Do not confuse vbn mentioned below with flex-vol block number which is represented by vvbn (virtual volume block number) and is used to represent blocks at flex-vol level (logical container) a way to virtualize storage.

ONTAP94-01*> dumpblock ifile -V vol_NFS 0x005d09
disk v2.19, dbn 63351, vbn 2874103
0x0000: 0x4946424d 0x000007ce 0x000006a5 0x00000000     <MBFI............>
0x0010: 0x00000004 0x00000000 0x00000000 0x00000000     <................>
0x0020: 0x00000000 0x00000000 0x00000000 0x00000000     <................>
0x0030: 0x00000000 0x00000000 0x00000000 0x00000000     <................>
0x0040: 0x00000004 0x00000000 0x00000000 0x00000000     <................>
0x0130: 0x00000000 0x00000000 0x00000000 0x00000000     <................>
0x0140: 0x00000000 0x00000000 0x00000000 0x00000000     <................>
0x0150: 0x00000000 0x00000000 0x00000000 0x00000000     <................>
0x0160: 0x00000104 0x00000000 0x00000000 0x00000001     <................>
0x0170: 0x00000002 0x00000000 0x00000000 0x00000000     <................>
0x0180: 0x5b9629be 0x1ae87168 0x5b9629be 0x1ae909c0     <.).[hq...).[....>
0x0190: 0x5b9629be 0x1ae99a48 0x5b9629be 0x1ae87168     <.).[H....).[hq..>
0x01a0: 0x0000001e 0x00000000 0x00000000 0x00000000     <................>
0x01b0: 0x4174654e 0x69207070 0x75662073 0x6f74206e     <NetApp is fun to>
0x01c0: 0x726f7720 0x6977206b 0x21216874 0x00000a21     < work with!!!...>

Please note: Even though Machine only understands  binary '0' & '1' at the lowest level, it is much efficient to save them in hexadecimal format in order to save space and it also makes it easy to read, interpret & debug for humans.

No comments:

Post a Comment