Whamcloud - gitweb
29fb105e241901cc89f08b3614729c4e701eecfa
[fs/lustre-release.git] / lustre / doc / lfs-find.1
1 .TH lfs-find 1 "2018-01-24" Lustre "user utilities"
2 .SH NAME
3 lfs-find \- Lustre client utility to list files with specific attributes
4 .SH SYNOPSIS
5 .B lfs find \fR<\fIdirectory\fR|\fIfilename \fR...>
6       [[\fB!\fR] \fB--atime\fR|\fB-A\fR [\fB-+\fR]\fIn[smhdwy]\fR]
7 [[\fB!\fR] \fB--blocks\fR|\fB-b\fR [\fB+-\fR]\fIn\fR]
8       [[\fB!\fR] \fB--ctime\fR|\fB-C\fR [\fB+-\fR]\fIn[smhdwy]\fR]
9       [[\fB!\fR] \fB--component-count|\fB--comp-count\fR [\fB+-\fR]\fIn\fR]
10       [[\fB!\fR] \fB--component-end|\fB--comp-end\fR|\fB-E\fR [\fB+-\fR]\fIn\fR[\fBKMGTPE\fR]]
11       [[\fB!\fR] \fB--component-flags|\fB--comp-flags\fR <[^]\fIflag\fB,\fR...>]
12       [[\fB!\fR] \fB--component-start|\fB--comp-start\fR [\fB+-\fR]\fIn\fR[\fBKMGTPE\fR]]
13       [[\fB!\fR] \fB--gid\fR|\fB-g\fR|\fB--group\fR|\fB-G\fR <\fIgname\fR>|<\fIgid\fR>]
14       [[\fB!\fR] \fB--layout\fR|\fB-L mdt\fR,\fBraid0\fR,\fBreleased\fR]
15 [\fB--maxdepth\fR|\fB-D\fI n\fR]
16       [[\fB!\fR] \fB--mdt\fR|\fB--mdt-index\fR|\fB-m\fR <\fIuuid\fR|\fIindex\fR,...>]
17       [[\fB!\fR] \fB--mdt-count\fR|\fB-T\fR [\fB+-\fR]\fIn\fR]
18 [[\fB!\fR] \fB--mdt-hash\fR|\fB-H <\fIhashtype\fR>]
19       [[\fB!\fR] \fB--mirror-count|\fB-N\fR [\fB+-\fR]\fIn\fR]
20 [[\fB!\fR] \fB--mirror-state\fR <[^]\fIstate\fR>]
21       [[\fB!\fR] \fB--mtime\fR|\fB-M\fR [\fB-+\fR]\fIn[smhdwy]\fR]
22 [[\fB!\fR] \fB--name\fR|\fB-n <\fIpattern\fR>]
23       [[\fB!\fR] \fB--ost\fR|\fB-O\fR <\fIindex\fR,...>]
24 [[\fB!\fR] \fB--pool\fR <\fIpool\fR>]
25 [\fB--print\fR|\fB-P\fR]
26       [\fB--print0\fR|\fB-0\fR]
27 [[\fB!\fR] \fB--projid\fR |<\fIprojid\fR>]
28       [[\fB!\fR] \fB--size|\fB-s\fR [\fB-+\fR]\fIn\fR[\fBKMGTPE\fR]]
29 [[\fB!\fR] \fB--stripe-count|\fB-c\fR [\fB+-\fR]\fIn\fR]
30       [[\fB!\fR] \fB--stripe-index|\fB-i\fR \fIn\fR,...]
31 [[\fB!\fR] \fB--stripe-size|\fB-S\fR [\fB+-\fR]\fIn\fR[\fBKMG\fR]]
32       [[\fB!\fR] \fB--type\fR|\fB-t\fR {\fBbcdflps\fR}]
33 [[\fB!\fR] \fB--uid\fR|\fB-u\fR|\fB--user\fR|\fB-U
34 <\fIuname\fR>|<\fIuid>\fR]
35 .SH DESCRIPTION
36 .B lfs find
37 is similar to the standard
38 .BR find (1)
39 utility and is used to list files and directories with specific attributes,
40 both regular POSIX attributes such as ownership, timestamps, and size using
41 the same options as
42 .BR find (1),
43 as well as Lustre-specific attributes such as stripe count and size,
44 OST and MDT location, and composite layout attributes.
45 .SH OPTIONS
46 .TP
47 .BR --atime | -A
48 File was last accessed \fIn\fR*24 hours ago (if no units are given),
49 or \fIn\fR*\fBs\fReconds, \fBm\fRinutes, \fBh\fRours, \fBd\fRays,
50 \fBw\fReeks, or \fBy\fRears ago within a margin of error of 24h,
51 or smaller if a unit is specified.  Multiple units can be specified,
52 for example \fB8h20m\fR is equivalent to \fB500m\fR.  If multipe units
53 are specified, the margin of error is based on the smallest unit used.
54 .TP
55 .BR --blocks | -b
56 Blocks allocated by the file is \fIn\fR Kibibytes (if no units are given),
57 \fIn\fR 512-byte \fBb\fRlocks, or \fBK\fRibi-, \fBM\fRebi-, \fBG\fRibi-,
58 \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if that suffix is given.
59 .TP
60 .BR --ctime | -C
61 File's status was last changed \fIn\fR*24 hours ago, see
62 --atime
63 for full details and options.
64 .TP
65 .BR --component-count | --comp-count
66 The file has \fIn\fR components in its layout.
67 .TP
68 .BR --component-end | --comp-end
69 The file has component end offset \fIn\fR (in bytes) for any component.
70 .TP
71 .BR --component-flags | --comp-flags
72 The file has components with the specified
73 .I flag
74 set.  If
75 .BI ^ flag
76 is used, print only components not matching
77 .IR flag .
78 Multiple flags can be specified, separated by commas.  Valid flag names are:
79 .RS 1.2i
80 .TP
81 .B init
82 Component has been initialized (has allocated OST objects).
83 .TP
84 .B stale
85 Replicated (mirrored) components that do not have up-to-date data.  Stale
86 components will not be used for read or write operations, and need to be
87 resynched using
88 .B lfs mirror resync
89 before they can be accessed again.
90 .TP
91 .B prefer
92 Replicated (mirrored) components that are preferred for read or write.
93 For example, because they are located on SSD-based OSTs, or are more
94 local on the network to clients.
95 .RE
96 .TP
97 .BR --component-start | --comp-start
98 The file has component start offset \fIn\fR (in bytes) for any component.
99 .TP
100 .BR --gid | -g
101 File has specified numeric group ID.
102 .TP
103 .BR --group | -G
104 File belongs to specified group, numeric group ID allowed.
105 .TP
106 .BR --layout
107 File has a layout of the given type, one of:
108 .RS 1.2i
109 .TP
110 .B raid0
111 Traditional Lustre RAID-0 striping format.
112 .TP
113 .B released
114 HSM-archived files that are not resident in the filesystem.
115 .TP
116 .B mdt
117 Files that have the first data component on an MDT.
118 .RE
119 .TP
120 .BR --maxdepth
121 Limits find to decend at most \fIn\fR levels of directory tree.
122 .TP
123 .BR --mdt | --mdt-index | -m
124 File or directory inode is located on the specified MDT(s).
125 .TP
126 .BR --mdt-hash | -H
127 DNE striped directory uses the given filename hashing function, one of:
128 .RS 1.2i
129 .TP
130 .B fnv_1a_64
131 The Fowler\-Noll\-Vo hash function, which is a simple and efficient hash.
132 .TP
133 .B all_char
134 Simple hash function that sums all of the characters in the filename.
135 This is mostly for testing, or if it is known that filenames will use
136 sequential filenames.
137 .RE
138 .TP
139 .BR --mdt-count | -T
140 The DNE striped directory has the given number of MDT shards.
141 .TP
142 .BR --mirror-count | -N
143 The file has \fIn\fR mirrors in its layout.
144 .TP
145 .BR --mirror-state
146 The file has a state of
147 .I state.
148 If
149 .BI ^ state
150 is used, print only files not matching
151 .IR state.
152 Only one state can be specified. Valid state name is:
153 .RS 1.2i
154 .TP
155 .B ro
156 The mirrored file is in read-only state. All of the mirrors contain
157 the up-to-date data.
158 .TP
159 .B wp
160 The mirrored file is in a state of being written.
161 .TP
162 .B sp
163 The mirrored file is in a state of being resynchronized.
164 .RE
165 .TP
166 .BR --mtime | -M
167 File's data was last modified \fIn\fR*24 hours ago, see
168 --atime
169 for full details and options.
170 .TP
171 .BR --name | -n
172 Filename matches the given filename, or regular expression using
173 standard
174 .BR glob (7)
175 file name regular expressions and wildcards.
176 .TP
177 .BR --ost | -O
178 File has an object on the specified OST(s).  The OST names can be specified
179 using the whole OST target name, or just the OST index number. If multiple
180 OSTs are given in a comma-separated list, the file may have an object on
181 any of the given OSTs.  Specifying multiple OSTs allows scanning the
182 filesystem only once when migrating objects off multiple OSTs for evacuation
183 and replacement using
184 .BR lfs-migrate (1).
185 .TP
186 .BR --pool
187 Layout was created with the specified
188 .I pool
189 name.  For composite files, this may match the pool of any component.
190 .TP
191 .BR --print | -P
192 Prints the file or directory name to standard output if it matches
193 all specified parameters, one file per line with a trailing linefeed.
194 This is the default behaviour for any matching files.
195 .TP
196 .BR --print0 | -0
197 Print full file name to standard output if it matches the specified
198 parameters, followed by a NUL character.  This is for use together with
199 .BR xargs (1)
200 with the
201 .B -0
202 option to handle filenames with embedded spaces or other special characters.
203 .TP
204 .BR --projid
205 File has specified numeric project ID.
206 .TP
207 .BR --size | -s
208 File size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
209 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if a
210 suffix is given.
211 .TP
212 .BR --stripe-count | -c
213 File has \fIn\fR stripes allocated.  For composite files, this
214 matches the stripe count of the last initialized component.
215 .TP
216 .BR --stripe-index | -i
217 File has stripe on OST index \fIn\fR.  Multiple OST indices can be
218 specified in a comma-separated list, which indicates that the file
219 has a stripe on \fIany\fR of the specified OSTs.  This allows a
220 single namespace scan for files on multiple different OSTs, if there
221 are multiple OSTs that are being replaced.
222 .TP
223 .BR --stripe-size | -S
224 Stripe size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
225 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-abytes if a
226 suffix is given.  For composite files, this matches the stripe
227 size of the last initialized component.
228 .TP
229 .BR --type | -t
230 File has type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory,
231 \fBf\fRile, \fBp\fRipe, sym\fBl\fRink, or \fBs\fRocket.
232 .TP
233 .BR --uid | -u
234 File has specified numeric user ID.
235 .TP
236 .BR --user | -U
237 File owned by specified user, numeric user ID also allowed.
238 .SH NOTES
239 Specifying \fB!\fR before an option negates its meaning (\fIfiles
240 NOT matching the parameter\fR). Using \fB+\fR before a numeric
241 value means 'more than \fIn\fR', while \fB-\fR before a numeric value
242 means 'less than \fIn\fR'.  If neither is used, it means 'equal to
243 \fIn\fR', within the bounds of the unit specified (if any).
244 .PP
245 Numeric suffixes are in binary SI (power-of-two) units.
246 .PP
247 For compatibility with
248 .BR find (1)
249 it is possible to specify long options with either a single or double
250 leading dash.
251 .PP
252 The order of parameters does not affect how the files are matched.
253 .B lfs find
254 will first scan the directory for any specified filename, and then fetch
255 MDT inode attributes for each matching filename.  If it can make a
256 positive or negative decision for a file based only on the MDT attributes
257 (e.g.  newer than specified time, user/group/project ID) it will not fetch
258 the OST object attributes for that file.
259 .SH EXAMPLES
260 .TP
261 .B $ lfs find /mnt/lustre
262 Efficiently lists all files in a given directory and its subdirectories,
263 without fetching any file attributes.
264 .TP
265 .B $ lfs find /mnt/lustre -mtime +30 -type f -print
266 Recursively list all regular files in given directory more than 30 days old.
267 .TP
268 .B $ lfs find /mnt/lustre/test -o OST0002,OST0003 -print0 | lfs_migrate -y
269 Recursively find all files in
270 .B test
271 that have objects on OST0002 or OST0003 and migrate them to other OSTs.  See
272 .BR lfs_migrate (1)
273 for more details.
274 .TP
275 .B $ lfs find -name "*.mpg" --component-count +3 /mnt/lustre
276 Recursively list all files ending with
277 .B .mpg
278 that have more than 3 components.
279 .TP
280 .B $ lfs find --component-flags=init,prefer,^stale /mnt/lustre
281 Recursively list all files that have at least one component with both 'init'
282 and 'prefer' flags set, and doesn't have flag 'stale' set.
283 .TP
284 .B $ lfs find --mirror-count +2 /mnt/lustre
285 Recursively list all mirrored files that have more than 2 mirrors.
286 .TP
287 .B $ lfs find ! --mirror-state=ro /mnt/lustre
288 Recursively list all out-of-sync mirrored files.
289 .SH BUGS
290 The
291 .B lfs find
292 command isn't as comprehensive as
293 .BR find (1).
294 In particular, it doesn't support complex boolean expressions with
295 .B -o
296 (logical OR), only logical AND of all expressions.  The order that parameters
297 are specified does not affect how the files are matched.
298 .SH AUTHOR
299 The
300 .B lfs
301 command is part of the Lustre filesystem.
302 .SH SEE ALSO
303 .BR lfs (1),
304 .BR lfs-getstripe (1),
305 .BR lfs-getdirstripe (1),
306 .BR lfs-migrate (1),
307 .BR lfs_migrate (1),
308 .BR lustre (7)
309 .BR xargs (1)