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

lfs find with --printf prints incorrect projid on special files

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • Lustre 2.16.0
    • Lustre 2.16.0
    • None
    • 3
    • 9223372036854775807

    Description

      Summary

      When using lfs find with the --printf option, some special files like character files fail their ioctl() call resulting in returning -1 for the projid field.

      Test Environment

      I've got two directories, each with a regular file, a symbolic link, and a character special file (created using mknod). The project ids on everything in p0 were left default (0), and everything in p1234 was set to a project id of 1234.

      /mnt/lustre-o2ib/caleb
      ├── p0
      │   ├── char0
      │   ├── link0 -> /mnt/lustre-o2ib/caleb/p0/reg_file0
      │   └── reg_file0
      └── p1234
          ├── char1234
          ├── link1234 -> /mnt/lustre-o2ib/caleb/p1234/reg_file1234
          └── reg_file1234
      
      2 directories, 6 files
      
      mawenzi-06:~/lustre-wc-rel # for FILE in $(find /mnt/lustre-o2ib/caleb); do file $FILE; done
      /mnt/lustre-o2ib/caleb: directory
      /mnt/lustre-o2ib/caleb/p0: directory
      /mnt/lustre-o2ib/caleb/p0/char0: character special (1/3)
      /mnt/lustre-o2ib/caleb/p0/link0: symbolic link to /mnt/lustre-o2ib/caleb/p0/reg_file0
      /mnt/lustre-o2ib/caleb/p0/reg_file0: empty
      /mnt/lustre-o2ib/caleb/p1234: directory
      /mnt/lustre-o2ib/caleb/p1234/char1234: character special (1/3)
      /mnt/lustre-o2ib/caleb/p1234/link1234: symbolic link to /mnt/lustre-o2ib/caleb/p1234/reg_file1234
      /mnt/lustre-o2ib/caleb/p1234/reg_file1234: empty
      
      mawenzi-06:~/lustre-wc-rel # lfs project -r /mnt/lustre-o2ib/caleb
          0 - /mnt/lustre-o2ib/caleb/p0
       1234 P /mnt/lustre-o2ib/caleb/p1234
          0 - /mnt/lustre-o2ib/caleb/p0/char0
          0 - /mnt/lustre-o2ib/caleb/p0/link0
          0 - /mnt/lustre-o2ib/caleb/p0/reg_file0
       1234 P /mnt/lustre-o2ib/caleb/p1234/char1234
       1234 P /mnt/lustre-o2ib/caleb/p1234/link1234
       1234 P /mnt/lustre-o2ib/caleb/p1234/reg_file1234
      

      Bug Symptoms

      Whenever using lfs find with the --printf option to print each file's project id (%LP formatter), the special files return -1 (INVALID_PROJID) due to a failed ioctl call in fget_projid.

      mawenzi-06:~/lustre-wc-rel # lfs find /mnt/lustre-o2ib/caleb --printf "%LP: %p\n"
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb
      DEBUG: ret: 0, projid: 0
      0: /mnt/lustre-o2ib/caleb
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p0
      DEBUG: ret: 0, projid: 0
      0: /mnt/lustre-o2ib/caleb/p0
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p0/char0
      DEBUG: ret: -25, projid: -1
      -1: /mnt/lustre-o2ib/caleb/p0/char0
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p0/link0
      DEBUG: ret: 0, projid: 0
      0: /mnt/lustre-o2ib/caleb/p0/link0
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p0/reg_file0
      DEBUG: ret: 0, projid: 0
      0: /mnt/lustre-o2ib/caleb/p0/reg_file0
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p1234
      DEBUG: ret: 0, projid: 1234
      1234: /mnt/lustre-o2ib/caleb/p1234
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p1234/char1234
      DEBUG: ret: -25, projid: -1
      -1: /mnt/lustre-o2ib/caleb/p1234/char1234
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p1234/link1234
      DEBUG: ret: 0, projid: 1234
      1234: /mnt/lustre-o2ib/caleb/p1234/link1234
      DEBUG: Checking projid on path: /mnt/lustre-o2ib/caleb/p1234/reg_file1234
      DEBUG: ret: 0, projid: 1234
      1234: /mnt/lustre-o2ib/caleb/p1234/reg_file1234
      

      Proposed Fix

      Adopt a variation of the logic in lfs_project.c's project_get_fsxattr() function, which checks if a path is a regular file, a directory, or some sort of special file. Special files have their metadata retrieved through their containing directory.

      Link to project_get_fsxattr function

      Evidence of Proposed Fix Working

      mawenzi-06:~/lustre-wc-rel # lfs find /mnt/lustre-o2ib/caleb --printf "%LP: %p\n"
      DEBUG: path=/mnt/lustre-o2ib/caleb, ret=0, projid=0
      0: /mnt/lustre-o2ib/caleb
      DEBUG: path=/mnt/lustre-o2ib/caleb/p0, ret=0, projid=0
      0: /mnt/lustre-o2ib/caleb/p0
      DEBUG: path=/mnt/lustre-o2ib/caleb/p0/char0, ret=0, projid=0
      0: /mnt/lustre-o2ib/caleb/p0/char0
      DEBUG: path=/mnt/lustre-o2ib/caleb/p0/link0, ret=0, projid=0
      0: /mnt/lustre-o2ib/caleb/p0/link0
      DEBUG: path=/mnt/lustre-o2ib/caleb/p0/reg_file0, ret=0, projid=0
      0: /mnt/lustre-o2ib/caleb/p0/reg_file0
      DEBUG: path=/mnt/lustre-o2ib/caleb/p1234, ret=0, projid=1234
      1234: /mnt/lustre-o2ib/caleb/p1234
      DEBUG: path=/mnt/lustre-o2ib/caleb/p1234/char1234, ret=0, projid=1234
      1234: /mnt/lustre-o2ib/caleb/p1234/char1234
      DEBUG: path=/mnt/lustre-o2ib/caleb/p1234/link1234, ret=0, projid=1234
      1234: /mnt/lustre-o2ib/caleb/p1234/link1234
      DEBUG: path=/mnt/lustre-o2ib/caleb/p1234/reg_file1234, ret=0, projid=1234
      1234: /mnt/lustre-o2ib/caleb/p1234/reg_file1234
      

      Attachments

        Issue Links

          Activity

            People

              carlson Caleb Carlson
              carlson Caleb Carlson
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: