Whamcloud - gitweb
LUDOC 299 protocol: Spell-check document
[doc/protocol.git] / statfs.txt
1 Statfs
2 ~~~~~~
3
4 The 'statfs' VFS method queries file-system-wide space and inode
5 usage. For details about the MDS_STATFS RPC see <<mds-statfs-rpc>>,
6 and for OST_STATFS see <<ost-statfs-rpc>>.
7
8 A client gets 'statfs' information for the file system as a whole by
9 first querying the individual storage targets (OSDs) for their
10 'statfs' information. The RPCs that flow are as shown in
11 <<statfs-rpcs>>. The values returned in the VFS call are built from
12 the results of the *_STATFS RPCs as follows:
13
14 .Statfs values
15 [options="header"]
16 |====
17 | field       | VFS value
18 | 'f_type'    | 0x0bd00bd0
19 | 'f_bsize'   | OST 'os_bsize'
20 | 'f_blocks'  | sum over OSTs 'os_blocks'
21 | 'f_bfree'   | sum over OSTs 'os_bfree'
22 | 'f_bavail'  | sum over OSTs 'os_bavail'
23 | 'f_files'   | sum over MDTs 'os_ffiles'
24 | 'f_ffree'   | sum over MDTs 'of_ffree'
25 | 'f_fsid'    | UUID
26 | 'f_namelen' | maximum filename length
27 |====
28
29 See the discussion in <<struct-obd-statfs>> for details about the
30 'obd_statfs' fields 'os_*'. In particular, the total and free objects
31 counts would normally be determined by the corresponding values on the
32 MDTs, but if the total objects available across all OSTs (respectively
33 free objects) happens to be fewer than the number on the MDTs, then
34 the smaller value is used.  The number of free objects is modified as
35 described below to ensure that at least this many new files can be
36 created.  The total number of objects is changed to preserve the
37 difference 'f_files' - 'f_ffree', which is the current number of
38 used objects. This is what "df" displays.
39
40 The number of OST free objects is divided by the file-system-wide
41 default stripe count (i.e. the expected number of OST objects used per
42 MDT file), so that 'f_ffree' represents the expected minimum number of
43 files that can be created at the current time.
44
45 The 'os_{bfree,bavail,blocks}' values are scaled down (in power-of-two
46 increments) to match the maximum 'os_bsize' returned from any OST so
47 that the sum of these fields makes sense, and potentially scaled down
48 again (also in power-of-two increments) to increase 'f_bsize' to fit
49 into the 'statfs' structure so that the 'f_blocks' field will fit into the
50 available field width (which may only be 2^32 blocks on a 32-bit
51 client).
52
53 For most possible error conditions directly related to processing
54 'statfs' information (ENOMEM, for instance) the error is propagated
55 back to the VFS and the 'struct statfs' does not have valid
56 information. In the case of an EAGAIN during an exchange of RPC
57 messages, that error is handled transparently to the 'statfs' itself.
58
59 .Statfs RPCs
60 [[statfs-rpcs]]
61 image::statfs_rpcs.png["statfs RPCs",height=150]
62
63 //////////////////////////////////////////////////////////////////////
64 The statfs_rpcs.png diagram resembles this text art:
65
66 Time
67 Step Client         MDT          OST
68      -------        -------      -------
69 1    MDS_STATFS------>
70 2             <------MDS_STATFS
71 3    OST_STATFS------>
72 4             <------OST_STATFS
73 //////////////////////////////////////////////////////////////////////
74
75 *1 - The client issues an MDS_STATFS request to each MDT.*
76
77 The MDS_STATFS request is a so-called 'empty' RPC in that it consists
78 only of the 'ptlrpc_body' (Lustre RPC descriptor) with the opcode set to
79 MDS_STATFS (41).
80
81 .MDS_STATFS Request Packet Structure
82 image::mds-statfs-request.png["MDS_STATFS Request Packet Structure",height=50]
83
84 //////////////////////////////////////////////////////////////////////
85 The mds-statfs-request.png diagram resembles this text art:
86
87        MDS_STATFS:
88       --request------
89       | ptlrpc_body |
90       ---------------
91 //////////////////////////////////////////////////////////////////////
92
93 See <<mds-statfs-rpc>>.
94
95 *2 - The MDS_STATFS reply returns 'statfs' info*
96
97 In addition to the 'ptlrpc_body' (Lustre RPC descriptor), the
98 MDS_STATFS reply to the client has the 'obd_statfs' structure. For a
99 detailed discussion of the fields in the 'obd_statfs' refer to
100 <<struct-obd-statfs>>.
101
102 .MDS_STATFS Reply Packet Structure
103 image::mds-statfs-reply.png["MDS_STATFS Reply Packet Structure",height=50]
104
105 //////////////////////////////////////////////////////////////////////
106 The mds-statfs-reply.png diagram resembles this text art:
107
108        MDS_STATFS:
109       --reply---------------------
110       | ptlrpc_body | obd_statfs |
111       ----------------------------
112 //////////////////////////////////////////////////////////////////////
113
114 *3 - The client issues an OST_STATFS request to each OST.*
115
116 The OST_STATFS RPC looks just like the MDS_STATFS, except the opcode
117 is 13 instead of 41 and the target of the RPC is an OST instead of an
118 MDT.
119
120 .OST_STATFS Request Packet Structure
121 image::ost-statfs-request.png["OST_STATFS Request Packet Structure",height=50]
122
123 //////////////////////////////////////////////////////////////////////
124 The ost-statfs-request.png diagram resembles this text art:
125
126        OST_STATFS:
127       --request------
128       | ptlrpc_body |
129       ---------------
130 //////////////////////////////////////////////////////////////////////
131
132 See <<mds-statfs-rpc>>.
133
134 *4 - The OST_STATFS reply returns 'statfs' info*
135
136 In addition to the 'ptlrpc_body' (Lustre RPC descriptor), the OST_STATFS
137 reply to the client has the 'obd_statfs' structure. For a detailed
138 discussion of the fields in the 'obd_statfs' refer to
139 <<struct-obd-statfs>>.
140
141 .OST_STATFS Reply Packet Structure
142 image::ost-statfs-reply.png["OST_STATFS Reply Packet Structure",height=50]
143
144 //////////////////////////////////////////////////////////////////////
145 The ost-statfs-reply.png diagram resembles this text art:
146
147        OST_STATFS:
148       --reply---------------------
149       | ptlrpc_body | obd_statfs |
150       ----------------------------
151 //////////////////////////////////////////////////////////////////////