Whamcloud - gitweb
LU-16786 utils: Replace open call to WANT_FD 64/50764/11
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Wed, 26 Apr 2023 05:51:15 +0000 (11:21 +0530)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Jul 2023 16:42:43 +0000 (16:42 +0000)
Replace open call to WANT_FD with newly added API
llapi_root_path_open() which was added under LU-16427

Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: I97d55321cf32e40eaf7d6284c47f313199a6c406
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50764
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/utils/liblustreapi_fid.c
lustre/utils/liblustreapi_hsm.c
lustre/utils/liblustreapi_pcc.c

index d6fb8b5..827d8ad 100644 (file)
@@ -233,18 +233,13 @@ int llapi_fid2path(const char *path_or_device, const char *fidstr, char *path,
                goto out;
        }
 
-       if (path_or_device[0] == '/')
-               rc = get_root_path(WANT_FD, NULL, &mnt_fd,
-                                  (char *)path_or_device, -1, NULL, NULL);
-       else
-               rc = get_root_path(WANT_FD, (char *)path_or_device,
-                                  &mnt_fd, NULL, -1, NULL, NULL);
-
+       rc = llapi_root_path_open(path_or_device, &mnt_fd);
        if (rc < 0)
                goto out;
 
        /* mnt_fd is cached internally, no need to close it */
        rc = llapi_fid2path_at(mnt_fd, &fid, path, pathlen, recno, linkno);
+       close(mnt_fd);
 
 out:
        return rc;
@@ -479,8 +474,8 @@ int llapi_open_by_fid(const char *lustre_dir, const struct lu_fid *fid,
 
        /* this will return a cached FD if available, so only one open needed.
         * WANT_FD doesn't modify lustre_dir so casting away "const" is OK */
-       rc = get_root_path(WANT_FD, NULL, &mnt_fd, (char *)lustre_dir, 0, NULL,
-                          NULL);
+
+       rc = llapi_root_path_open(lustre_dir, &mnt_fd);
        if (rc)
                goto out;
 
index 6c42607..5726730 100644 (file)
@@ -1647,7 +1647,7 @@ int llapi_hsm_request(const char *path, const struct hsm_user_request *request)
        int rc;
        int fd;
 
-       rc = get_root_path(WANT_FD, NULL, &fd, (char *)path, -1, NULL, NULL);
+       rc = llapi_root_path_open(path, &fd);
        if (rc)
                return rc;
 
@@ -1655,7 +1655,7 @@ int llapi_hsm_request(const char *path, const struct hsm_user_request *request)
        /* If error, save errno value */
        rc = rc ? -errno : 0;
 
-       /* fd is cached internally, no need to close it */
+       close(fd);
        return rc;
 }
 
index 0045d7e..47192e5 100644 (file)
@@ -215,7 +215,7 @@ int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid,
        int fd;
        struct lu_pcc_detach_fid detach;
 
-       rc = get_root_path(WANT_FD, NULL, &fd, (char *)mntpath, -1, NULL, NULL);
+       rc = llapi_root_path_open(mntpath, &fd);
        if (rc) {
                llapi_error(LLAPI_MSG_ERROR, rc, "cannot get root path: %s",
                            mntpath);
@@ -232,10 +232,10 @@ int llapi_pcc_detach_fid(const char *mntpath, const struct lu_fid *fid,
        detach.pccd_fid = *fid;
        detach.pccd_opt = option;
 
-       /* fd is cached internally, no need to close */
        rc = ioctl(fd, LL_IOC_PCC_DETACH_BY_FID, &detach);
        rc = rc ? -errno : 0;
 
+       close(fd);
        return rc;
 }