From b015927e7bb700caac9bd95376513db9345f46ef Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 25 Jan 2018 16:01:52 -0800 Subject: [PATCH] scoutfs: add debug check for scout-107 We have a bug filed where the fs got stuck spinning in scoutfs_dir_get_backref_path(). There's been enough changes lately that we're not sure if this issue still exists. Catch if we have an excessive number of iterations through our loop there and exit with some debug info. Signed-off-by: Mark Fasheh --- kmod/src/dir.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kmod/src/dir.c b/kmod/src/dir.c index 1c9a8b8c..12a4d90f 100644 --- a/kmod/src/dir.c +++ b/kmod/src/dir.c @@ -24,6 +24,7 @@ #include "inode.h" #include "ioctl.h" #include "key.h" +#include "msg.h" #include "super.h" #include "trans.h" #include "xattr.h" @@ -1209,8 +1210,20 @@ int scoutfs_dir_get_backref_path(struct super_block *sb, u64 ino, u64 dir_ino, { u64 par_ino; int ret; + int iters = 0; retry: + /* + * Debugging for SCOUT-107, can be removed later when we're + * confident we won't hit an endless loop here again. + */ + if (WARN_ONCE(++iters >= 4000, "scoutfs: Excessive retries in " + "dir_get_backref_path. ino %llu dir_ino %llu name %.*s\n", + ino, dir_ino, name_len, name)) { + ret = -EINVAL; + goto out; + } + /* get the next link name to the given inode */ ret = add_next_linkref(sb, ino, dir_ino, name, name_len, list); if (ret < 0)