Whamcloud - gitweb
EX-5249 utils: show pin information in 'lfs pcc state' command
authorLei Feng <flei@whamcloud.com>
Wed, 11 May 2022 01:51:26 +0000 (21:51 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 31 May 2022 15:51:28 +0000 (15:51 +0000)
If xattr lustre.pin exists, show its content in 'lfs pcc state'
command.

Change-Id: I867ea3b246fc3b7d10e166d754c081c8afc462d5
Signed-off-by: Lei Feng <flei@whamcloud.com>
Test-Parameters: trivial
Reviewed-on: https://review.whamcloud.com/47287
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/doc/lfs-pcc-state.1
lustre/utils/lfs.c

index f3ee271..89f5df0 100644 (file)
@@ -2,7 +2,7 @@
 .SH NAME
 lfs pcc state \- display current PCC state of file
 .SH SYNOPSIS
-.BR "lfs pcc state " "\fIFILE \fR...>"
+.BR "lfs pcc state " "<\fIFILE\fR ...>"
 .SH DESCRIPTION
 Display the current PCC cache state of
 .I FILE
@@ -23,7 +23,10 @@ is the number of processes that have the local cache file open, and
 .B flags
 shows additional file states, including
 .B attaching
-for files that are not fully copied into cache,
+for files that are not fully copied into cache.
+The
+.B pin
+shows the pin information if they exist.
 .SH EXAMPLES
 .TP
 .B $ lfs pcc state /mnt/lustre/file
index 58f4eae..27c207e 100644 (file)
@@ -12474,6 +12474,7 @@ static int lfs_pcc_state(int argc, char **argv)
        const char              *path;
        char                     fullpath[PATH_MAX];
        struct lu_pcc_state      state;
+       char                     buff[XATTR_SIZE_MAX];
 
        optind = 1;
 
@@ -12505,21 +12506,37 @@ static int lfs_pcc_state(int argc, char **argv)
                        continue;
                }
 
+               rc2 = getxattr(path, XATTR_LUSTRE_PIN, buff, sizeof(buff));
+               if (rc2 < 0) {
+                       if (errno != ENODATA) {
+                               if (rc == 0)
+                                       rc = -errno;
+                               fprintf(stderr,
+                                       "%s: cannot get PCC pin xattr of '%s': %s\n",
+                                       argv[0], path, strerror(errno));
+                               continue;
+                       } else {
+                               rc2 = 0;
+                       }
+               }
+               buff[rc2] = '\0';
+
                printf("file: %s", path);
                printf(", type: %s", pcc_type2string(state.pccs_type));
                if (state.pccs_type == LU_PCC_NONE &&
                    state.pccs_open_count == 0) {
                        if (state.pccs_flags & PCC_STATE_FL_ATTACHING)
                                printf(", flags: attaching");
-                       printf("\n");
-                       continue;
+               } else {
+                       printf(", PCC_file: %s", state.pccs_path);
+                       if (state.pccs_flags & PCC_STATE_FL_UNLINKED)
+                               printf(" (unlinked)");
+                       printf(", open_count: %u", state.pccs_open_count);
+                       printf(", flags: %x", state.pccs_flags);
                }
 
-               printf(", PCC_file: %s", state.pccs_path);
-               if (state.pccs_flags & PCC_STATE_FL_UNLINKED)
-                       printf(" (unlinked)");
-               printf(", open_count: %u", state.pccs_open_count);
-               printf(", flags: %x", state.pccs_flags);
+               if (buff[0] != '\0')
+                       printf(", pin: %s", buff);
                printf("\n");
        }
        return rc;