Whamcloud - gitweb
LU-14462 gss: fix support for namespace in lgss_keyring
[fs/lustre-release.git] / lustre / utils / liblustreapi_pcc.c
index 8e52b8f..f538e02 100644 (file)
@@ -182,14 +182,17 @@ int llapi_pcc_attach_fid_str(const char *mntpath, const char *fidstr,
  * detach PCC cache of a file by using fd.
  *
  * \param fd           File handle.
+ * \param option       Detach option
  *
  * \return 0 on success, an error code otherwise.
  */
-int llapi_pcc_detach_fd(int fd)
+int llapi_pcc_detach_fd(int fd, __u32 option)
 {
+       struct lu_pcc_detach detach;
        int rc;
 
-       rc = ioctl(fd, LL_IOC_PCC_DETACH);
+       detach.pccd_opt = option;
+       rc = ioctl(fd, LL_IOC_PCC_DETACH, &detach);
        return rc;
 }
 
@@ -198,14 +201,16 @@ int llapi_pcc_detach_fd(int fd)
  *
  * \param mntpath      Fullpath to the client mount point.
  * \param fid          FID of the file.
+ * \param option       Detach option.
  *
  * \return 0 on success, an error code otherwise.
  */
-int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid)
+int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid,
+                        __u32 option)
 {
        int rc;
        int fd;
-       struct lu_pcc_detach detach;
+       struct lu_pcc_detach_fid detach;
 
        rc = get_root_path(WANT_FD, NULL, &fd, (char *)mntpath, -1);
        if (rc) {
@@ -222,6 +227,7 @@ int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid)
         * files.
         */
        detach.pccd_fid = *fid;
+       detach.pccd_opt = option;
        rc = ioctl(fd, LL_IOC_PCC_DETACH_BY_FID, &detach);
        close(fd);
        return rc;
@@ -231,11 +237,13 @@ int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid)
  * detach PCC cache of a file via FID.
  *
  * \param mntpath      Fullpath to the client mount point.
- * \param fid          FID string of the file.
+ * \param fidstr       FID string of the file.
+ * \param option       Detach option.
  *
  * \return 0 on success, an error code otherwise.
  */
-int llapi_pcc_detach_fid_str(const char *mntpath, const char *fidstr)
+int llapi_pcc_detach_fid_str(const char *mntpath, const char *fidstr,
+                            __u32 option)
 {
        int rc;
        struct lu_fid fid;
@@ -252,7 +260,7 @@ int llapi_pcc_detach_fid_str(const char *mntpath, const char *fidstr)
                return -EINVAL;
        }
 
-       rc = llapi_pcc_detach_fid(mntpath, &fid);
+       rc = llapi_pcc_detach_fid(mntpath, &fid, option);
 
        return rc;
 }
@@ -260,11 +268,12 @@ int llapi_pcc_detach_fid_str(const char *mntpath, const char *fidstr)
 /**
  * detach PCC cache of a file.
  *
- * \param path   Fullpath to the file to operate on.
+ * \param path         Fullpath to the file to operate on.
+ * \param option       Detach option.
  *
  * \return 0 on success, an error code otherwise.
  */
-int llapi_pcc_detach_file(const char *path)
+int llapi_pcc_detach_file(const char *path, __u32 option)
 {
        int rc;
        int fd;
@@ -277,7 +286,7 @@ int llapi_pcc_detach_file(const char *path)
                return rc;
        }
 
-       rc = llapi_pcc_detach_fd(fd);
+       rc = llapi_pcc_detach_fd(fd, option);
        close(fd);
        return rc;
 }
@@ -335,7 +344,7 @@ int llapi_pccdev_set(const char *mntpath, const char *cmd)
        rc = llapi_getname(mntpath, buf, sizeof(buf));
        if (rc < 0) {
                llapi_error(LLAPI_MSG_ERROR, rc,
-                           "cannot get name for '%s'\n", mntpath);
+                           "cannot get name for '%s'", mntpath);
                return rc;
        }
 
@@ -356,12 +365,12 @@ int llapi_pccdev_set(const char *mntpath, const char *cmd)
                rc = errno;
                if (errno != EIO)
                        llapi_error(LLAPI_MSG_ERROR, rc,
-                                   "error: setting llite.%s.pcc=\"%s\"\n",
+                                   "error: setting llite.%s.pcc='%s'",
                                    buf, cmd);
        } else if (count < strlen(cmd)) { /* Truncate case */
                rc = -EINVAL;
                llapi_error(LLAPI_MSG_ERROR, rc,
-                           "setting llite.%s.pcc=\"%s\": wrote only %zd\n",
+                           "setting llite.%s.pcc='%s': wrote only %zd",
                            buf, cmd, count);
        }
        close(fd);
@@ -385,7 +394,7 @@ int llapi_pccdev_get(const char *mntpath)
        rc = llapi_getname(mntpath, pathbuf, sizeof(pathbuf));
        if (rc < 0) {
                llapi_error(LLAPI_MSG_ERROR, rc,
-                           "cannot get name for '%s'\n", mntpath);
+                           "cannot get name for '%s'", mntpath);
                return rc;
        }
 
@@ -398,7 +407,7 @@ int llapi_pccdev_get(const char *mntpath)
        if (fd < 0) {
                rc = -errno;
                llapi_error(LLAPI_MSG_ERROR, rc,
-                           "error: pccdev_get: opening '%s'\n",
+                           "error: pccdev_get: opening '%s'",
                            path.gl_pathv[0]);
                goto out_free_param;
        }
@@ -407,7 +416,7 @@ int llapi_pccdev_get(const char *mntpath)
        if (buf == NULL) {
                rc = -ENOMEM;
                llapi_error(LLAPI_MSG_ERROR, rc,
-                           "error: pccdev_get: allocating '%s' buffer\n",
+                           "error: pccdev_get: allocating '%s' buffer",
                            path.gl_pathv[0]);
                goto out_close;
        }
@@ -421,8 +430,7 @@ int llapi_pccdev_get(const char *mntpath)
                        rc = -errno;
                        if (errno != EIO) {
                                llapi_error(LLAPI_MSG_ERROR, rc,
-                                           "error: pccdev_get: "
-                                           "reading failed\n");
+                                          "error: pccdev_get: reading failed");
                        }
                        break;
                }
@@ -430,7 +438,7 @@ int llapi_pccdev_get(const char *mntpath)
                if (fwrite(buf, 1, count, stdout) != count) {
                        rc = -errno;
                        llapi_error(LLAPI_MSG_ERROR, rc,
-                                   "error: get_param: write to stdout\n");
+                                   "error: get_param: write to stdout");
                        break;
                }
        }