Whamcloud - gitweb
LU-17646 llapi: lustreapi: add FID in error messages 74/55074/2
authorAlexandre Ioffe <aioffe@ddn.com>
Sat, 11 May 2024 01:28:05 +0000 (18:28 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 29 May 2024 04:50:27 +0000 (04:50 +0000)
Use llapi_fd2fid() to print FID in llapi_lease_set() and
llapi_lease_check() error messages.

Test-Parameters: trivial
Signed-off-by: Alexandre Ioffe <aioffe@ddn.com>
Change-Id: Iac97ea721860652e304c674007ac7646d183e2fd
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55074
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@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;
 }