[LU-9689] lfs getstripe does not print globbed file names when using options such as --stripe-count and --stripe-size Created: 19/Jun/17  Updated: 31/Jan/22  Resolved: 17/Dec/17

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.7.0
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Paul Kolano Assignee: Peter Jones
Resolution: Duplicate Votes: 0
Labels: None
Environment:

sles11sp4


Issue Links:
Duplicate
duplicates LU-15504 "lfs find" is missing "-ls" support Open
duplicates LU-10378 "lfs find" is missing "-printf" support Resolved
Rank (Obsolete): 9223372036854775807

 Description   

Apologies if duplicate (didn't see anything on quick search).

Normally, when using "lfs getstripe" on globbed files (e.g. "lfs getstripe dir/*") without any options, the stripe information will be prefaced with a file name:

$ lfs getstripe 64g.64/1g.[12]
64g.64/1g.1
lmm_stripe_count: 1
lmm_stripe_size: 1048576
lmm_pattern: 1
lmm_layout_gen: 0
lmm_stripe_offset: 28
obdidx objid objid group
28 22888 0x5968 0

64g.64/1g.2
lmm_stripe_count: 1
lmm_stripe_size: 1048576
lmm_pattern: 1
lmm_layout_gen: 0
lmm_stripe_offset: 41
obdidx objid objid group
41 22884 0x5964 0

If, however, you only want a subset of the information (e.g. just the count and size), it just spits out the count and size of every file without showing the associated file name:

$ lfs getstripe --stripe-count --stripe-size 64g.64/1g.[12]
lmm_stripe_count: 1
lmm_stripe_size: 1048576
lmm_stripe_count: 1
lmm_stripe_size: 1048576

For consistency and parseability, it would be nice if this was consistent and it would also print the file name like so when multiple files given:

$ lfs getstripe --stripe-count 64g.64/1g.[12] #### PROPOSED ####
64g.64/1g.1
lmm_stripe_count: 1
lmm_stripe_size: 1048576
64g.64/1g.2
lmm_stripe_count: 1
lmm_stripe_size: 1048576

Likewise, there is an inconsistency between when you give just one specifier vs. when you specify two or more. For instance, if you just specify --stripe-count, it does not give the "lmm_stripe_count:" prefix whereas it does when you also specify something else like --stripe-size above.

$ lfs getstripe --stripe-count 64g.64/1g.[12]
1
1

Ideally, it seems like you would want the options like --stripe-count to act just like the default no-option case except just printing the requested subset.

Thanks.



 Comments   
Comment by Paul Kolano [ 19/Jun/17 ]

oops, sorry, the "proposed output" command line should also have --stripe-size specified

Comment by Andreas Dilger [ 20/Jun/17 ]

The lack of field names and file names when fetching a specific attribute is intentional. This allows scripts to easily fetch a specific attribute such as the stripe count or stripe size for a file, without having to parse the output.

If you want to fetch multiple attributes at one time, and the script is already going to parse the field names, then it is easier to just print all of the fields and parse out the fields of interest from the output.

I can agree that in the unusual case where multiple fields are being fetched from multiple files that it may be desirable to have the file name separator, but there are two complications with this. It isn't necessarily known in advance whether multiple files will be matched, so making this conditional may be complex. Secondly, this changes the output format for a command that has been used for many years, so it could not be the default behavior.

I guess the larger question is what you want to do with the getstripe output? Is it for script use or human consumption?

Comment by Andreas Dilger [ 17/Dec/17 ]

The "lfs -printf" functionality will allow printing out arbitrarily-formatted output and fields, either for easier parsing and usage by other programs.

Generated at Sat Feb 10 02:28:22 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.