Whamcloud - gitweb
0491cf25180a4ba0473f991ecb259ed85dfc5abc
[doc/protocol.git] / struct_obd_statfs.txt
1 OBD Statfs
2 ^^^^^^^^^^
3 [[struct-obd-statfs]]
4
5 An 'obd_statfs' structure conveys file-system-wide information for the
6 back-end file system of a given target (MDT or OST).
7
8 [source,c]
9 ----
10 struct obd_statfs {
11         __u64  os_type;
12         __u64  os_blocks;
13         __u64  os_bfree;
14         __u64  os_bavail;
15         __u64  os_files;
16         __u64  os_ffree;
17         __u8   os_fsid[40];
18         __u32  os_bsize;
19         __u32  os_namelen;
20         __u64  os_maxbytes;
21         __u32  os_state;
22         __u32  os_fprecreated;
23         __u32  os_spare2;
24         __u32  os_spare3;
25         __u32  os_spare4;
26         __u32  os_spare5;
27         __u32  os_spare6;
28         __u32  os_spare7;
29         __u32  os_spare8;
30         __u32  os_spare9;
31 };
32 ----
33
34 Most of the fields correspond directly to the 'struct statfs' fields
35 returned by a 'statfs()' system call and have the same meaning. The
36 values are for the back-end storage of the target in question (MDT or
37 OST).
38
39 Teh 'os_type' field gives the type of the target's back-end file
40 system:
41
42 .Back-end file types ('os_type') for Lustre targets
43 [options="header"]
44 |====
45 | f_type                     | value
46 | EXT4_SUPER_MAGIC (ldiskfs) | 0xEF53
47 | ZFS_SUPER_MAGIC            | 0x2fc12fc1
48 |====
49
50 The 'os_blocks' field is the total number of blocks in the target, in
51 units of os_bsize.
52
53 The 'os_bfree' field is the number of blocks not currently in use.
54
55 The 'os_bavail' is the number of blocks available to be allocated to
56 new files.  The number of available blocks is typically lower than
57 the number of free blocks due to <<grant>> and blocks reserved for
58 target internal usage such as metadata.
59
60 The 'os_files' field is the total number of files on the target, both
61 allocated and free.  For some OSD types this is a static number, and
62 for others this is dynamic based on os_ffree and the amount of free
63 space.
64
65 The 'os_ffree' field is the current number of files that could be
66 created based on current usage.  For some OSD types this is a function
67 of the free space in the device and may increase or decrease as free
68 space changes.
69
70 The 'os_fsid' is intended to be the target backing device UUID in
71 ASCII format.  The current osd-ldiskfs and osd-zfs implementations
72 do not fill this field in.
73
74 The 'os_bsize' field is the block size in bytes. This is for computing
75 the total, free, and available space in combination with 'os_blocks',
76 'os_bfree', and 'os_bavail' respectively.  It does not necessarily
77 represent the minimum or optimal IO size.
78
79 The 'os_namelen' field gives the maximum name length for files on the
80 back-end file system in bytes.
81
82 The 'os_maxbytes' field is the maximum size of a single object
83 (i.e. the maximum byte offset that can be written to).  This is the
84 same value as the 'ocd_maxbytes' field of the 'obd_connect_data'
85 structure.
86
87 The 'os_state' field encodes the status of the underlying back-end
88 file system. It can be:
89
90 .Back-end file system state
91 [options="header"]
92 |====
93 | os_state flag     | value
94 | OS_STATE_DEGRADED | 0x1
95 | OS_STATE_READONLY | 0x2
96 |====
97
98 In normal operation the 'os_state' value is returned as 0x0.  If the
99 back-end file system has a RAID configuration that is degraded or
100 rebuilding the state is returned with the OS_STATE_DEGRADED (0x1) flag
101 set. If the file system has been set to read-only, either manually at
102 mount or automatcially due to detected corruption of the underlying
103 target filesystem, then 'os_state' is returned with OS_STATE_READONLY (0x2)
104 set, for example if it was explicitly mounted read-only, or
105 corruption has been detected at runtime in the backing filesystem.
106
107 The 'os_fprecreated' field counts the number of pre-created objects
108 available on an OST. The 'os_fprecreated' value counts as "used"
109 inodes, so it reduces 'os_ffree'. Lustre places a hard limit of
110 2*OST_MAX_PRECREATE (2*20000) on the number of precreates it will
111 allow for an OST. There are currently no precreated objects on an MDT
112 so it is just 0 in that case.