Whamcloud - gitweb
LU-17744 ldiskfs: mballoc stats fixes
[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--attrs\fR=\fI[^]ATTR[,...]\fR]
8 [[\fB!\fR] \fB--blocks\fR|\fB-b\fR [\fB+-\fR]\fIn\fR]
9       [[\fB!\fR] \fB--btime\fR|\fB-B\fR [\fB+-\fR]\fIn[smhdwy]\fR]
10 [[\fB!\fR] \fB--ctime\fR|\fB-C\fR [\fB+-\fR]\fIn[smhdwy]\fR]
11       [[\fB!\fR] \fB--component-count|\fB--comp-count\fR [\fB+-\fR]\fIn\fR]
12       [[\fB!\fR] \fB--component-end|\fB--comp-end\fR|\fB-E\fR [\fB+-\fR]\fIn\fR[\fBKMGTPE\fR]]
13       [[\fB!\fR] \fB--component-flags|\fB--comp-flags\fR [^]\fIFLAG\fB,\fR...]
14       [[\fB!\fR] \fB--component-start|\fB--comp-start\fR [\fB+-\fR]\fIn\fR[\fBKMGTPE\fR]]
15       [[\fB!\fR] \fB--extension-size|\fB-z\fR [\fB+-\fR]\fIn\fR[\fBKMG\fR]]
16       [[\fB!\fR] \fB--foreign\fR [\fITYPE\fR]]
17 [[\fB!\fR] \fB--gid\fR|\fB-g\fR|\fB--group\fR|\fB-G\fR \fIGNAME\fR|\fIGID\fR>]
18       [\fB--help\fR|\fB-h\fR]
19 [[\fB!\fR] \fB--layout\fR|\fB-L mdt\fR,\fBraid0\fR,\fBreleased\fR]
20 [\fB--lazy|-l\fR]
21       [[\fB!\fR] \fB--links\fR [\fB+-\fR]\fIn\fR] [\fB--maxdepth\fR|\fB-D\fI n\fR]
22       [[\fB!\fR] \fB--mdt\fR|\fB--mdt-index\fR|\fB-m\fR \fIUUID\fR|\fIINDEX\fR,...]
23       [[\fB!\fR] \fB--mdt-count\fR|\fB-T\fR [\fB+-\fR]\fIn\fR]
24 [[\fB!\fR] \fB--mdt-hash\fR|\fB-H \fR<[^]\fIHASHFLAG\fR,[^]\fIHASHTYPE\fR,...>]
25       [[\fB!\fR] \fB--mirror-count|\fB-N\fR [\fB+-\fR]\fIn\fR]
26 [[\fB!\fR] \fB--mirror-state\fR [^]\fISTATE\fR]
27       [[\fB!\fR] \fB--mtime\fR|\fB-M\fR [\fB-+\fR]\fIn[smhdwy]\fR]
28 [[\fB!\fR] \fB--name\fR|\fB-n \fIPATTERN\fR]
29       [[\fB!\fR] \fB--newer\fR[\fBXY\fR] \fIREFERENCE\fR]
30       [[\fB!\fR] \fB--ost\fR|\fB-O\fR \fIINDEX\fR,...]
31       [[\fB!\fR] \fB--perm\fR [\fB/-\fR]\fIMODE\fR ]
32 [[\fB!\fR] \fB--pool\fR \fIPOOL\fR]
33 [\fB--print\fR|\fB-P\fR]
34       [\fB--print0\fR|\fB-0\fR]
35 [\fB--printf\fR \fIFORMAT\fR]
36 [[\fB!\fR] \fB--projid\fR \fIPROJID\fR]
37       [[\fB!\fR] \fB--size|\fB-s\fR [\fB-+\fR]\fIn\fR[\fBKMGTPE\fR]]
38 [[\fB!\fR] \fB--stripe-count|\fB-c\fR [\fB+-\fR]\fIn\fR]
39       [[\fB!\fR] \fB--stripe-index|\fB-i\fR \fIn\fR,...]
40 [[\fB!\fR] \fB--stripe-size|\fB-S\fR [\fB+-\fR]\fIn\fR[\fBKMG\fR]]
41       [[\fB!\fR] \fB--type\fR|\fB-t\fR {\fBbcdflps\fR}]
42 [[\fB!\fR] \fB--uid\fR|\fB-u\fR|\fB--user\fR|\fB-U  \fIUNAME\fR|\fIUID\fR]
43       [[\fB!\fR] \fB--xattr\fR \fINAME\fR[\fB=\fIVALUE\fR]]
44 .SH DESCRIPTION
45 .B lfs find
46 is similar to the standard
47 .BR find (1)
48 utility and is used to list files and directories with specific attributes,
49 both regular POSIX attributes such as ownership, timestamps, and size using
50 the same options as
51 .BR find (1),
52 as well as Lustre-specific attributes such as stripe count and size,
53 OST and MDT location, and composite layout attributes.
54 .SH OPTIONS
55 .TP
56 .BR --atime | -A
57 File was last accessed \fIn\fR*24 hours ago (if no units are given),
58 or \fIn\fR*\fBs\fReconds, \fBm\fRinutes, \fBh\fRours, \fBd\fRays,
59 \fBw\fReeks, or \fBy\fRears ago within a margin of error of 24h
60 if no unit is specified.  Multiple units can be specified,
61 for example \fB8h20m\fR is equivalent to \fB500m\fR.  If multiple units
62 are specified, the margin of error is based on the smallest unit used, so
63 .B -atime 3d
64 has a margin of error of one day, while
65 .B -atime 72h
66 has a margin of error of one hour.
67 .TP
68 .BR --attrs
69 File has ATTRS attribute flags. Supported attributes are (non exhaustive list):
70 Compressed (c), Immutable (i), Append_Only (a), No_Dump (d), Encrypted (E),
71 Automount (M)
72 .TP
73 .BR --blocks | -b
74 Blocks allocated by the file is \fIn\fR 512-byte \fBb\fRlocks (if no units
75 are given), or \fBc\fRhars (bytes), \fBK\fRibi-, \fBM\fRebi-, \fBG\fRibi-,
76 \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if that suffix is given.
77 .TP
78 .BR --btime | --Btime | -B
79 File was created \fIn\fR*24 hours ago, see
80 --atime
81 for full details and options.
82 .TP
83 .BR --ctime | -C
84 File's status was last changed \fIn\fR*24 hours ago, see
85 --atime
86 for full details and options.
87 .TP
88 .BR --component-count | --comp-count
89 The file has \fIn\fR components in its layout.
90 .TP
91 .BR --component-end | --comp-end
92 The file has component end offset \fIn\fR (in bytes) for any component.
93 .TP
94 .BR --component-flags | --comp-flags
95 The file has components with the specified
96 .I flag
97 set.  If
98 .BI ^ flag
99 is used, print only components not matching
100 .IR flag .
101 Multiple flags can be specified, separated by commas.  Valid flag names are:
102 .RS 1.2i
103 .TP
104 .B init
105 Component has been initialized (has allocated OST objects).
106 .TP
107 .B stale
108 Replicated (mirrored) components that do not have up-to-date data.  Stale
109 components will not be used for read or write operations, and need to be
110 resynched using
111 .B lfs mirror resync
112 before they can be accessed again.
113 .TP
114 .B prefer
115 Replicated (mirrored) components that are preferred for read or write.
116 For example, because they are located on SSD-based OSTs, or are more
117 local on the network to clients.
118 .TP
119 .B prefrd
120 Replicated (mirrored) components that are preferred for read.
121 .TP
122 .B prefwr
123 Replicated (mirrored) components that are preferred for write.
124 .RE
125 .TP
126 .BR --component-start | --comp-start
127 The file has component start offset \fIn\fR (in bytes) for any component.
128 .TP
129 .BR --foreign
130 File has a foreign (non-Lustre/free format) layout and is of the given
131 .IR type ,
132 if specified.  Presently only
133 .B none
134 or
135 .B symlink
136 are defined types, though 32-bit numeric types can also be used.
137 .TP
138 .BR --gid | -g
139 File has specified numeric group ID.
140 .TP
141 .BR --group | -G
142 File belongs to specified group, numeric group ID allowed.
143 .TP
144 .BR --help | -h
145 Print usage message.
146 .TP
147 .BR --layout | -L
148 File has a layout of the given type, one of:
149 .RS 1.2i
150 .TP
151 .B raid0
152 Traditional Lustre RAID-0 striping format.
153 .TP
154 .B released
155 HSM-archived files that are not resident in the filesystem.
156 .TP
157 .B mdt
158 Files that have the first data component on an MDT.
159 .RE
160 .TP
161 .BR --lazy|-l
162 Use file size and blocks from MDT, if available, to avoid extra RPCs.
163 .TP
164 .BR --links
165 File has \fIn\fR links.
166 .TP
167 .BR --maxdepth
168 Limits find to decend at most \fIn\fR levels of directory tree.
169 .TP
170 .BR --mdt | --mdt-index | -m
171 File or directory inode is located on the specified MDT(s).
172 .TP
173 .BR --mdt-hash | -H
174 DNE striped directory uses the given filename hashing function, one of:
175 .RS 1.2i
176 .TP
177 .B crush
178 The CRUSH consistent hash function, added in Lustre 2.14, minimizes
179 entry migration if the directory stripe count changes during migration.
180 .TP
181 .B fnv_1a_64
182 The Fowler\-Noll\-Vo hash function, which is a simple and efficient hash.
183 .TP
184 .B all_char
185 Simple hash function that sums all of the characters in the filename.
186 This is mostly for testing, or if it is known that filenames will use
187 sequential filenames.
188 .RE
189 This implicitly selects only directories to be matched, like
190 .B -type d
191 and not other file types.
192 .TP
193 .BR --mdt-count | -T
194 The DNE striped directory has the given number of MDT shards.  This
195 implicitly selects only directories to be matched, like
196 .B -type d
197 and not other file types.
198 .TP
199 .BR --mirror-count | -N
200 The file has \fIn\fR mirrors in its layout.
201 .TP
202 .BR --mirror-state
203 The file has a state of
204 .I state.
205 If
206 .BI ^ state
207 is used, print only files not matching
208 .IR state.
209 Only one state can be specified. Valid state name is:
210 .RS 1.2i
211 .TP
212 .B ro
213 The mirrored file is in read-only state. All of the mirrors contain
214 the up-to-date data.
215 .TP
216 .B wp
217 The mirrored file is in a state of being written.
218 .TP
219 .B sp
220 The mirrored file is in a state of being resynchronized.
221 .RE
222 .TP
223 .BR --mtime | -M
224 File's data was last modified \fIn\fR*24 hours ago, see
225 --atime
226 for full details and options.
227 .TP
228 .BR --name | -n
229 Filename matches the given filename, or regular expression using
230 standard
231 .BR glob (7)
232 file name regular expressions and wildcards.
233 .TP
234 .BR --newer [ XY "] " \fIreference
235 Succeeds if timestamp \fIX\fR of the file being considered is newer
236 than timestamp \fIY\fR of the file
237 .IR reference .
238 The letters \fIX\fR and \fIY\fR can be any of the following letters:
239
240 .TS
241 ll
242 ll
243 ll
244 ll
245 llw(2i).
246 a       The access time of the file \fIreference\fR
247 b|B     The birth time of the file \fIreference\fR
248 c       The inode status change time of \fIreference\fR
249 m       The modification time of the file \fIreference\fR
250 t       \fIreference\fR is interpreted directly as a time
251 .TE
252
253 Some combinations are invalid; for example, it is invalid for
254 .I X
255 to be
256 .IR t .
257 Specifying
258 .B -newer
259 is equivalent to
260 .BR -newermm .
261 When
262 .IR reference
263 is interpreted directly as a time, currently it must be in one of the
264 following formats: "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M", "%Y-%m-%d",
265 "%H:%M:%S", "%H:%M", to represent year, month, day, hour, minute, seconds,
266 with unspecified times at the start of that minute or day, unspecified dates
267 being "today", and "@%s" or "%s" the seconds since the Unix epoch (see
268 .BR strftime (3)
269 for details of the time formats).  Otherwise, it will report an error.
270 If you try to use the birth time of a reference file, and the birth
271 time cannot be determined, a fatal error message results.  If you
272 specify a test which refers to the birth time of files being examined,
273 this test will fail for any files where the birth time is unknown.
274 .TP
275 .BR --ost | -O
276 File has an object on the specified OST(s).  The OST names can be specified
277 using the whole OST target name, or just the OST index number. If multiple
278 OSTs are given in a comma-separated list, the file may have an object on
279 any of the given OSTs.  Specifying multiple OSTs allows scanning the
280 filesystem only once when migrating objects off multiple OSTs for evacuation
281 and replacement using
282 .BR lfs-migrate (1).
283 .TP
284 .BR "--perm \fImode\fR"
285 File's permission are exactly \fImode\fR (octal or symbolic).
286 .TP
287 .BR "--perm /\fImode\fR"
288 All of the permission bits \fImode\fR are set for the file.
289 .TP
290 .BR "--perm -\fImode\fR"
291 Any of the permission bits \fImode\fR are set for the file. If no permission
292 bits in \fImode\fR are set, this test matches any file.
293 .TP
294 .BR --pool
295 Layout was created with the specified
296 .I pool
297 name.  For composite files, this may match the pool of any component.
298 .BR --print | -P
299 Prints the file or directory name to standard output if it matches
300 all specified parameters, one file per line with a trailing linefeed.
301 This is the default behaviour for any matching files.
302 .TP
303 .BR --print0 | -0
304 Print full file name to standard output if it matches the specified
305 parameters, followed by a NUL character.  This is for use together with
306 .BR xargs (1)
307 with the
308 .B -0
309 option to handle filenames with embedded spaces or other special characters.
310 .TP
311 .BR "--printf \fIformat\fR"
312 Print \fIformat\fR to standard output for each matching file, interpreting
313 `\' escapes and `%' directives.  Unlike \fB--print\fR, the \fB--printf\fR option
314 does not automatically add a newline to the end of the string. The escapes and
315 directives are:
316 .RS 1.2i
317 .TP
318 .B \en
319 Newline.
320 .TP
321 .B \et
322 Horizontal tab.
323 .TP
324 .B \e\e
325 A literal backslash.
326 .TP
327 .B %%
328 A literal percent sign.
329 .TP
330 .B %a
331 File\'s last access time in the format returned by the C \`ctime\' function.
332 .TP
333 .B %A@
334 File\'s last access time in seconds since Jan. 1, 1970, 00:00 GMT.
335 .TP
336 .B %b
337 The amount of disk space used for the file (in 512-byte blocks).
338 .TP
339 .B %c
340 File\'s last status change time in the format returned by the C \`ctime\' function.
341 .TP
342 .B %C@
343 File\'s last status change time in seconds since Jan. 1, 1970, 00:00 GMT.
344 .TP
345 .B %G
346 File\'s numeric group ID.
347 .TP
348 .B %m
349 File permission bits (in octal).
350 .TP
351 .B %n
352 Number of hard links to file.
353 .TP
354 .B %p
355 File's name.
356 .TP
357 .B %s
358 File size in bytes.
359 .TP
360 .B %t
361 File\'s last modification time in the format returned by the C \`ctime\' function.
362 .TP
363 .B %T@
364 File\'s last modification time in seconds since Jan. 1, 1970, 00:00 GMT.
365 .TP
366 .B %U
367 File's numeric user ID.
368 .TP
369 .B %w
370 File\'s birth time in the format returned by the C \`ctime\' function.
371 .TP
372 .B %W@
373 File\'s birth time in seconds since Jan. 1, 1970, 00:00 GMT.
374 .TP
375 .B %y
376 File's type (f=file, d=directory, p=pipe, b=block device, c=character device,
377 s=socket l=symbolic link)
378 .TP
379 Lustre-specific information about a file can be printed using these directives:
380 .TP
381 .B %La
382 Comma-separated list of file's named attribute flags in short form (letter), or
383 hex value of any unknown attributes.
384 .RE
385 .TP
386 .B %LA
387 Comma-separated list of file's named attribute flags, or hex value of any
388 unknown attributes.
389 .RE
390 .TP
391 .B %Lc
392 File\'s stripe count.  For a composite file, this is the stripe count of the last
393 instantiated component.
394 .TP
395 .B %LF
396 File Identifier (FID) associated with the file.
397 .TP
398 .B %Lh
399 Directory's hash type (or \`none\' for an unstriped directory).
400 .TP
401 .B %Li
402 File\'s starting OST index (or starting MDT index for a directory).
403 For a composite file, this is the starting OST index of the last instantiated
404 component.
405 .TP
406 .B %Lo
407 List of all OST/MDT indices associated with a file or directory.
408 .TP
409 .B %Lp
410 File\'s OST pool name.  For a composite file, this is the pool associated
411 with the last instantiated component.  (NOTE: This can also be used for
412 directories, but since MDT pools are not currently implemented, nothing will
413 be printed.)
414 .TP
415 .B %LP
416 Numeric project ID assigned to the file or directory.
417 .TP
418 .B %LS
419 File's stripe size.  For a composite file, this is the stripe size of the last
420 instantiated component.
421 .TP
422 .BR --projid
423 File has specified numeric project ID.
424 .TP
425 .BR --size | -s
426 File size is \fIn\fR 512-byte blocks (if no unit is given), or
427 \fIn\fR \fBc\fRhars (bytes), \fBK\fRibi-, \fBM\fRebi-,
428 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if a
429 suffix is given.
430 .TP
431 .BR --stripe-count | -c
432 File has \fIn\fR stripes allocated.  For composite files, this
433 matches the stripe count of the last initialized component.
434 .TP
435 .BR --stripe-index | -i
436 File has stripe on OST index \fIn\fR.  Multiple OST indices can be
437 specified in a comma-separated list, which indicates that the file
438 has a stripe on \fIany\fR of the specified OSTs.  This allows a
439 single namespace scan for files on multiple different OSTs, if there
440 are multiple OSTs that are being replaced.
441 .TP
442 .BR --stripe-size | -S
443 Stripe size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
444 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-abytes if a
445 suffix is given.  For composite files, this matches the stripe
446 size of the last initialized non-extension component.
447 .TP
448 .BR --extension-size | --ext-size | -z
449 Extension size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
450 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-abytes if a
451 suffix is given.  For composite files, this matches the extension
452 size of any extension component.
453 .TP
454 .BR --type | -t
455 File has type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory,
456 \fBf\fRile, \fBp\fRipe, sym\fBl\fRink, or \fBs\fRocket.
457 .TP
458 .BR --uid | -u
459 File has specified numeric user ID.
460 .TP
461 .BR --user | -U
462 File owned by specified user, numeric user ID also allowed.
463 .TP
464 \fB--xattr \fINAME\fR[\fB=\fIVALUE\fR]
465 File has an extended attribute with name matching the regular expression
466 .RB ( regex (7))
467 \fINAME\fR, and optionally value matching the regular expression \fIVALUE\fR.
468 The regular expressions must match the complete attribute names and values,
469 and not just a substring.
470 This option may be specified multiple times, and the file must match all
471 provided arguments.
472 .SH NOTES
473 Specifying \fB!\fR before an option negates its meaning (\fIfiles
474 NOT matching the parameter\fR). Using \fB+\fR before a numeric
475 value means 'more than \fIn\fR', while \fB-\fR before a numeric value
476 means 'less than \fIn\fR'.  If neither is used, it means 'equal to
477 \fIn\fR', within the bounds of the unit specified (if any).
478 .PP
479 Numeric suffixes are in binary SI (power-of-two) units.
480 .PP
481 For compatibility with
482 .BR find (1)
483 it is possible to specify long options with either a single or double
484 leading dash.
485 .PP
486 The order of parameters does not affect how the files are matched.
487 .B lfs find
488 will first scan the directory for any specified filename, and then fetch
489 MDT inode attributes for each matching filename.  If it can make a
490 positive or negative decision for a file based only on the MDT attributes
491 (e.g.  newer than specified time, user/group/project ID) it will not fetch
492 the OST object attributes for that file.
493 .SH EXAMPLES
494 .TP
495 .B $ lfs find /mnt/lustre
496 Efficiently lists all files in a given directory and its subdirectories,
497 without fetching any file attributes.
498 .TP
499 .B $ lfs find /mnt/lustre -mtime +30 -type f -print
500 Recursively list all regular files in given directory more than 30 days old.
501 .TP
502 .B $ lfs find /mnt/lustre/test -o OST0002,OST0003 -print0 | lfs_migrate -y
503 Recursively find all files in
504 .B test
505 that have objects on OST0002 or OST0003 and migrate them to other OSTs.  See
506 .BR lfs_migrate (1)
507 for more details.
508 .TP
509 .B $ lfs find -name "*.mpg" --component-count +3 /mnt/lustre
510 Recursively list all files ending with
511 .B .mpg
512 that have more than 3 components.
513 .TP
514 .B $ lfs find --component-flags=init,prefer,^stale /mnt/lustre
515 Recursively list all files that have at least one component with both 'init'
516 and 'prefer' flags set, and doesn't have flag 'stale' set.
517 .TP
518 .B $ lfs find --mirror-count +2 /mnt/lustre
519 Recursively list all mirrored files that have more than 2 mirrors.
520 .TP
521 .B $ lfs find ! --mirror-state=ro /mnt/lustre
522 Recursively list all out-of-sync mirrored files.
523 .TP
524 .B $ lfs find ! --foreign=symlink /mnt/lustre
525 Recursively list all but foreign files/dirs of
526 .B symlink
527 type.
528 .TP
529 .B $ lfs find -xattr user.job=202310.* /mnt/lustre
530 Recursively list all files with the specified "user.job" extended attribute.
531 .TP
532 .B $ lfs find -xattr security.selinux ! -xattr security.selinux=.*httpd.* /var/www
533 Recursively list all files in /var/www that have any SELinux extended attribute,
534 but that do NOT have an SELinux extended attribute with a value containing
535 "httpd".
536 .SH BUGS
537 The
538 .B lfs find
539 command isn't as comprehensive as
540 .BR find (1).
541 In particular, it doesn't support complex boolean expressions with
542 .B -o
543 (logical OR), only logical AND of all expressions.  The order that parameters
544 are specified does not affect how the files are matched.
545 .SH AUTHOR
546 The
547 .B lfs
548 command is part of the Lustre filesystem.
549 .SH SEE ALSO
550 .BR lfs (1),
551 .BR lfs-getstripe (1),
552 .BR lfs-getdirstripe (1),
553 .BR lfs-migrate (1),
554 .BR lfs_migrate (1),
555 .BR lustre (7),
556 .BR regex (7),
557 .BR xargs (1)