Whamcloud - gitweb
LUDOC-296 protocol: Rearrange presentation to be more top-down
[doc/protocol.git] / struct_obd_statfs.txt
diff --git a/struct_obd_statfs.txt b/struct_obd_statfs.txt
new file mode 100644 (file)
index 0000000..0491cf2
--- /dev/null
@@ -0,0 +1,112 @@
+OBD Statfs
+^^^^^^^^^^
+[[struct-obd-statfs]]
+
+An 'obd_statfs' structure conveys file-system-wide information for the
+back-end file system of a given target (MDT or OST).
+
+[source,c]
+----
+struct obd_statfs {
+        __u64  os_type;
+        __u64  os_blocks;
+        __u64  os_bfree;
+        __u64  os_bavail;
+        __u64  os_files;
+        __u64  os_ffree;
+        __u8   os_fsid[40];
+        __u32  os_bsize;
+        __u32  os_namelen;
+        __u64  os_maxbytes;
+        __u32  os_state;
+        __u32  os_fprecreated;
+        __u32  os_spare2;
+        __u32  os_spare3;
+        __u32  os_spare4;
+        __u32  os_spare5;
+        __u32  os_spare6;
+        __u32  os_spare7;
+        __u32  os_spare8;
+        __u32  os_spare9;
+};
+----
+
+Most of the fields correspond directly to the 'struct statfs' fields
+returned by a 'statfs()' system call and have the same meaning. The
+values are for the back-end storage of the target in question (MDT or
+OST).
+
+Teh 'os_type' field gives the type of the target's back-end file
+system:
+
+.Back-end file types ('os_type') for Lustre targets
+[options="header"]
+|====
+| f_type                     | value
+| EXT4_SUPER_MAGIC (ldiskfs) | 0xEF53
+| ZFS_SUPER_MAGIC            | 0x2fc12fc1
+|====
+
+The 'os_blocks' field is the total number of blocks in the target, in
+units of os_bsize.
+
+The 'os_bfree' field is the number of blocks not currently in use.
+
+The 'os_bavail' is the number of blocks available to be allocated to
+new files.  The number of available blocks is typically lower than
+the number of free blocks due to <<grant>> and blocks reserved for
+target internal usage such as metadata.
+
+The 'os_files' field is the total number of files on the target, both
+allocated and free.  For some OSD types this is a static number, and
+for others this is dynamic based on os_ffree and the amount of free
+space.
+
+The 'os_ffree' field is the current number of files that could be
+created based on current usage.  For some OSD types this is a function
+of the free space in the device and may increase or decrease as free
+space changes.
+
+The 'os_fsid' is intended to be the target backing device UUID in
+ASCII format.  The current osd-ldiskfs and osd-zfs implementations
+do not fill this field in.
+
+The 'os_bsize' field is the block size in bytes. This is for computing
+the total, free, and available space in combination with 'os_blocks',
+'os_bfree', and 'os_bavail' respectively.  It does not necessarily
+represent the minimum or optimal IO size.
+
+The 'os_namelen' field gives the maximum name length for files on the
+back-end file system in bytes.
+
+The 'os_maxbytes' field is the maximum size of a single object
+(i.e. the maximum byte offset that can be written to).  This is the
+same value as the 'ocd_maxbytes' field of the 'obd_connect_data'
+structure.
+
+The 'os_state' field encodes the status of the underlying back-end
+file system. It can be:
+
+.Back-end file system state
+[options="header"]
+|====
+| os_state flag     | value
+| OS_STATE_DEGRADED | 0x1
+| OS_STATE_READONLY | 0x2
+|====
+
+In normal operation the 'os_state' value is returned as 0x0.  If the
+back-end file system has a RAID configuration that is degraded or
+rebuilding the state is returned with the OS_STATE_DEGRADED (0x1) flag
+set. If the file system has been set to read-only, either manually at
+mount or automatcially due to detected corruption of the underlying
+target filesystem, then 'os_state' is returned with OS_STATE_READONLY (0x2)
+set, for example if it was explicitly mounted read-only, or
+corruption has been detected at runtime in the backing filesystem.
+
+The 'os_fprecreated' field counts the number of pre-created objects
+available on an OST. The 'os_fprecreated' value counts as "used"
+inodes, so it reduces 'os_ffree'. Lustre places a hard limit of
+2*OST_MAX_PRECREATE (2*20000) on the number of precreates it will
+allow for an OST. There are currently no precreated objects on an MDT
+so it is just 0 in that case.