From: Andreas Dilger Date: Tue, 21 Jan 2014 21:25:56 +0000 (-0700) Subject: LU-4397 utils: fix lfs_df loop for disconnected client X-Git-Tag: 2.5.58~9 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4f965b8cff863334d536ec8a9806dba5eb10c62f;p=fs%2Flustre-release.git LU-4397 utils: fix lfs_df loop for disconnected client If the client is disconnected from the MDT on which "lfs df" is run (typically MDT0 for the mountpoint), then the file open can fail with -ESHUTDOWN, causing mntdf() to loop forever trying to find other MDTs or OSTs to get statfs data from. The caller of llapi_obd_statfs() cannot tell the difference between an error from open() and ioctl(IOC_OBD_STATFS), so llapi_obd_statfs() should return a fatal error if the open failed since all of the later opens will fail as well. Signed-off-by: Andreas Dilger Change-Id: I05d48d5b6680c382c9e05c02fd82a9a200500c1e Reviewed-on: http://review.whamcloud.com/8949 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Emoly Liu Reviewed-by: Faccini Bruno Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 402c44e..ff20c9a 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -3429,18 +3429,20 @@ int llapi_obd_statfs(char *path, __u32 type, __u32 index, if (errno == EISDIR) fd = open(path, O_DIRECTORY | O_RDONLY); - if (fd < 0) { - rc = errno ? -errno : -EBADF; - llapi_error(LLAPI_MSG_ERROR, rc, "error: %s: opening '%s'", - __func__, path); - return rc; - } - rc = ioctl(fd, IOC_OBD_STATFS, (void *)rawbuf); - if (rc) - rc = errno ? -errno : -EINVAL; + if (fd < 0) { + rc = errno ? -errno : -EBADF; + llapi_error(LLAPI_MSG_ERROR, rc, "error: %s: opening '%s'", + __func__, path); + /* If we can't even open a file on the filesystem (e.g. with + * -ESHUTDOWN), force caller to exit or it will loop forever. */ + return -ENODEV; + } + rc = ioctl(fd, IOC_OBD_STATFS, (void *)rawbuf); + if (rc) + rc = errno ? -errno : -EINVAL; - close(fd); - return rc; + close(fd); + return rc; } #define MAX_STRING_SIZE 128