Whamcloud - gitweb
LU-15647 utils: 'lfs df' shouldn't loop forever 13/46813/2
authorAndreas Dilger <adilger@whamcloud.com>
Sun, 13 Mar 2022 02:35:45 +0000 (19:35 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 Jun 2022 05:49:49 +0000 (05:49 +0000)
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 <adilger@whamcloud.com>
Change-Id: I5110c7246cf53eb5c4d59424a44b73b9d23ebbe5
Reviewed-on: https://review.whamcloud.com/46813
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/lfs.c

index 3a82712..823cda2 100644 (file)
@@ -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)