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

'lfs find -printf %w' does not print birth time

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      I was using "lfs find -printf" to generate output similar to "find -ls" until LU-15504 is implemented, and incorrectly used "%w" instead of "%t" to print the timestamp.

      This showed that the birth time is not being printed properly, always printing the epoch zero time for the birth time:

      $ lfs find /myth/tmp/adilger  -size +512k -printf "%Li %LF %b %U %G %s %w %p\n"
      4 0x20003b551:0xb:0x0 266240 1000 1000 136314880 Wed Dec 31 17:00:00 1969 /myth/tmp/adilger/pflfile2
      1 0x200035f67:0xd55:0x0 16384 1000 1000 8388608 Wed Dec 31 17:00:00 1969 /myth/tmp/adilger/pflfile8
      

      Using the "%t" format showed that it is printing the mtime properly:

      $ lfs find /myth/tmp/adilger  -size +512k -printf "%Li %LF %b %U %G %s %t %p\n"
      4 0x20003b551:0xb:0x0 266240 1000 1000 136314880 Fri Jul 29 16:28:17 2022 /myth/tmp/adilger/pflfile2
      1 0x200035f67:0xd55:0x0 16384 1000 1000 8388608 Fri Aug 12 19:16:28 2022 /myth/tmp/adilger/pflfile8
      

      Running the statx tool on the file showed that the birth time was correctly set on the inode and being returned by statx() syscall to userspace, so the problem appears to be in the "lfs find -printf" handling for this attribute:

      $ ./lustre/tests/statx /myth/tmp/adilger/pflfile{2,8}
        File: /myth/tmp/adilger/pflfile2
        Size: 136314880 	Blocks: 266240     IO Block: 4194304 regular file
      Device: 9a6023aeh/2589991854d	Inode: 144119265358774283  Links: 1
      Access: (0664/-rw-rw-r--)  Uid: ( 1000/ adilger)   Gid: ( 1000/ adilger)
      Context: unconfined_u:object_r:unlabeled_t:s0
      Access: 2022-07-29 16:28:48.000000000 -0600
      Modify: 2022-07-29 16:28:17.000000000 -0600
      Change: 2022-07-29 16:28:48.000000000 -0600
       Birth: 2022-07-29 16:27:51.000000000 -0600
        File: /myth/tmp/adilger/pflfile8
        Size: 8388608   	Blocks: 16384      IO Block: 4194304 regular file
      Device: 9a6023aeh/2589991854d	Inode: 144118896360688981  Links: 1
      Access: (0664/-rw-rw-r--)  Uid: ( 1000/ adilger)   Gid: ( 1000/ adilger)
      Context: system_u:object_r:unlabeled_t:s0
      Access: 2022-08-12 19:21:46.000000000 -0600
      Modify: 2022-08-12 19:16:28.000000000 -0600
      Change: 2022-08-12 19:21:46.000000000 -0600
       Birth: 2022-08-12 19:16:28.000000000 -0600
      

      Attachments

        Issue Links

          Activity

            [LU-16560] 'lfs find -printf %w' does not print birth time

            It appears that this is now working properly on my local system:

            $ stat /myth/tmp/adilger/acl
            :
            Access: 2024-04-17 19:39:26.000000000 -0600
            Modify: 2024-04-17 19:39:26.000000000 -0600
            Change: 2024-04-17 19:39:26.000000000 -0600
             Birth: 2021-01-27 10:19:21.000000000 -0700
            $ lfs find /myth/tmp/adilger/acl -type f -printf "%w %p\n" 
            Wed Jan 27 10:19:21 2021 /myth/tmp/adilger/acl
            

            It still makes sense to add the test case, to verify this is working, but it looks like nothing needs to be fixed in the code. Thanks for looking into this.

            adilger Andreas Dilger added a comment - It appears that this is now working properly on my local system: $ stat /myth/tmp/adilger/acl : Access: 2024-04-17 19:39:26.000000000 -0600 Modify: 2024-04-17 19:39:26.000000000 -0600 Change: 2024-04-17 19:39:26.000000000 -0600 Birth: 2021-01-27 10:19:21.000000000 -0700 $ lfs find /myth/tmp/adilger/acl -type f -printf "%w %p\n" Wed Jan 27 10:19:21 2021 /myth/tmp/adilger/acl It still makes sense to add the test case, to verify this is working, but it looks like nothing needs to be fixed in the code. Thanks for looking into this.

            "Anjus George <georgea@ornl.gov>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50958
            Subject: LU-16560 utils: correct lfs find printf btime
            Project: fs/lustre-release
            Branch: master
            Current Patch Set: 1
            Commit: 8f598c273443a4af654cade5407c0857bb514989

            gerrit Gerrit Updater added a comment - "Anjus George <georgea@ornl.gov>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50958 Subject: LU-16560 utils: correct lfs find printf btime Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: 8f598c273443a4af654cade5407c0857bb514989
            georgea Anjus George added a comment -

            Andreas, thanks for reporting. This is interesting. And yes I will take a look at it.

            georgea Anjus George added a comment - Andreas, thanks for reporting. This is interesting. And yes I will take a look at it.

            Anjus, would you be able to take a look at this issue?

            adilger Andreas Dilger added a comment - Anjus, would you be able to take a look at this issue?

            People

              georgea Anjus George
              adilger Andreas Dilger
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: