From 8920e024cbc5d7db094f06e757e07c50524928e6 Mon Sep 17 00:00:00 2001 From: Alexandre Ioffe Date: Fri, 10 May 2024 18:28:05 -0700 Subject: [PATCH] LU-17646 llapi: lustreapi: add FID in error messages Use llapi_fd2fid() to print FID in llapi_lease_set() and llapi_lease_check() error messages. Test-Parameters: trivial Signed-off-by: Alexandre Ioffe Change-Id: Iac97ea721860652e304c674007ac7646d183e2fd Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55074 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin --- lustre/utils/liblustreapi_lease.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lustre/utils/liblustreapi_lease.c b/lustre/utils/liblustreapi_lease.c index 60ad9bc..f46db89 100644 --- a/lustre/utils/liblustreapi_lease.c +++ b/lustre/utils/liblustreapi_lease.c @@ -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; } -- 1.8.3.1