Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-9689

lfs getstripe does not print globbed file names when using options such as --stripe-count and --stripe-size

Details

    • Improvement
    • Resolution: Duplicate
    • Minor
    • None
    • Lustre 2.7.0
    • None
    • sles11sp4
    • 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.

      Attachments

        Issue Links

          Activity

            [LU-9689] lfs getstripe does not print globbed file names when using options such as --stripe-count and --stripe-size

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

            adilger Andreas Dilger added a comment - The " lfs -printf " functionality will allow printing out arbitrarily-formatted output and fields, either for easier parsing and usage by other programs.
            adilger Andreas Dilger added a comment - - edited

            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?

            adilger Andreas Dilger added a comment - - edited 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?

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

            kolano Paul Kolano (Inactive) added a comment - oops, sorry, the "proposed output" command line should also have --stripe-size specified

            People

              pjones Peter Jones
              kolano Paul Kolano (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: