Whamcloud - gitweb
LU-6134 utils: lfs should only open/stat files if needed 22/13822/3
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 20 Feb 2015 12:25:43 +0000 (05:25 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 18 Mar 2015 11:30:41 +0000 (11:30 +0000)
commit9c4783a744f27da813b9c5be9c530f7772eec203
treefc25ce15ce040a0e800d3621c16c6c6485698f3b
parent79020798bdcc09477b0b4d05b1d35e2432909aab
LU-6134 utils: lfs should only open/stat files if needed

Since (commit 322968acf183) "lfs find" would needlessly open() and
fstat() every file if the --ost, -uid/user, -gid/group, -[amc]time,
or -size options were used, to get the MDT index for each file.
This was causing "lfs find --ost" to fail if an OST was offline, and
added needless overhead that "lfs find" was meant to avoid.

The MDT index is only needed if --mdt is used, so only get it in
that case.  It also wasn't necessary to call fstat() in this case
either because the file type was already known at this point.

Some other minor cleanups related to fetching the MDT index:
- don't use ret in cb_get_dirstripe() as it is isn't needed
- fix cb_get_mdt_index() to avoid a Coverity false positive due to
  initializing rc and having a conditional branch that is always taken
- convert spaces to tabs for related code, other minor style fixes

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Ib41ced742fe5068f504f540479e6b4718d2540e5
Reviewed-on: http://review.whamcloud.com/13822
Reviewed-by: wangdi <di.wang@intel.com>
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/liblustreapi.c