From 41703e9b5fe7061b313805384b08372d4fe82cec Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sat, 12 Mar 2022 19:35:45 -0700 Subject: [PATCH] LU-15647 utils: 'lfs df' shouldn't loop forever Don't loop forever in "lfs df" if there is a problem fetching the target statfs information from the kernel and -ENODEV is not returned for whatever reason. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I5110c7246cf53eb5c4d59424a44b73b9d23ebbe5 Reviewed-on: https://review.whamcloud.com/46813 Tested-by: jenkins Reviewed-by: Jian Yu Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/utils/lfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3a82712..823cda2 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -6522,13 +6522,14 @@ static int mntdf(char *mntdir, char *fsname, char *pool, enum mntdf_flags flags, if (!(tp->st_op & ops)) continue; - for (index = 0; ; index++) { + for (index = 0; index < LOV_ALL_STRIPES && + (!lsb || lsb->sb_count < LL_STATFS_MAX); index++) { memset(&stat_buf, 0, sizeof(struct obd_statfs)); memset(&uuid_buf, 0, sizeof(struct obd_uuid)); type = flags & MNTDF_LAZY ? tp->st_op | LL_STATFS_NODELAY : tp->st_op; rc2 = llapi_obd_fstatfs(fd, type, index, - &stat_buf, &uuid_buf); + &stat_buf, &uuid_buf); if (rc2 == -ENODEV) break; if (rc2 == -EAGAIN) -- 1.8.3.1