Whamcloud - gitweb
LU-17646 llapi: lustreapi: add FID in error messages
authorAlexandre Ioffe <aioffe@ddn.com>
Sat, 11 May 2024 01:28:05 +0000 (18:28 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 6 Jun 2024 08:18:00 +0000 (08:18 +0000)
Use llapi_fd2fid() to print FID in llapi_lease_set() and
llapi_lease_check() error messages.

Lustre-change: https://review.whamcloud.com/55074
Lustre-commit: 8920e024cbc5d7db094f06e757e07c50524928e6

Test-Parameters: trivial
Signed-off-by: Alexandre Ioffe <aioffe@ddn.com>
Change-Id: Iac97ea721860652e304c674007ac7646d183e2fd
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55237
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/utils/liblustreapi_lease.c

index 60ad9bc..f46db89 100644 (file)
@@ -58,16 +58,28 @@ static inline const char *lease_mode2str(enum ll_lease_mode mode)
  * \retval >= 0 on success.
  * \retval -errno on error.
  */
+#define FMT_STR_LEASE_SET "cannot get %s lease, ext %x"
 int llapi_lease_set(int fd, const struct ll_ioc_lease *data)
 {
        int rc;
 
        rc = ioctl(fd, LL_IOC_SET_LEASE, data);
        if (rc < 0) {
-               rc = -errno;
+               struct lu_fid fid;
+               int rc2;
 
-               llapi_error(LLAPI_MSG_ERROR, rc, "cannot get %s lease, ext %x",
-                           lease_mode2str(data->lil_mode), data->lil_flags);
+               rc = -errno;
+               rc2 = llapi_fd2fid(fd, &fid);
+               if (rc2 == 0)
+                       llapi_error(LLAPI_MSG_ERROR, rc,
+                                   FMT_STR_LEASE_SET" for "DFID,
+                                   lease_mode2str(data->lil_mode),
+                                   data->lil_flags, PFID(&fid));
+               else
+                       llapi_error(LLAPI_MSG_ERROR, rc,
+                                   FMT_STR_LEASE_SET,
+                                   lease_mode2str(data->lil_mode),
+                                   data->lil_flags);
        }
        return rc;
 }
@@ -151,8 +163,16 @@ int llapi_lease_check(int fd)
 
        rc = ioctl(fd, LL_IOC_GET_LEASE);
        if (rc < 0) {
+               int rc2;
+               struct lu_fid fid;
+
                rc = -errno;
-               llapi_error(LLAPI_MSG_ERROR, rc, "cannot check lease");
+               rc2 = llapi_fd2fid(fd, &fid);
+               if (rc2 == 0)
+                       llapi_error(LLAPI_MSG_ERROR, rc,
+                                   "cannot check lease for "DFID, PFID(&fid));
+               else
+                       llapi_error(LLAPI_MSG_ERROR, rc, "cannot check lease");
        }
        return rc;
 }