From: Josh Durgin Date: Thu, 2 Jun 2011 23:59:22 +0000 (-0700) Subject: filestore: stat to test for file type if d_type is unsupported X-Git-Tag: v0.29~3^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea76ea502b78962b75837d8b26c11cd60b085a55;p=ceph.git filestore: stat to test for file type if d_type is unsupported This only affects list_collections. Previously, when using an FS that does not support d_type, like xfs, load_pgs would fail to find any pgs, since list_collections skipped all files. This made clients hang because all pgs were considered non-existent by the osd. Reported-by: Yoshiaki Tamura Signed-off-by: Josh Durgin --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 3c9ec18883bd..0c64bcf21df3 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -3650,8 +3650,24 @@ int FileStore::list_collections(vector& ls) while ((r = ::readdir_r(dir, &sde, &de)) == 0) { if (!de) break; - if (!S_ISDIR(de->d_type << 12)) + if (de->d_type == DT_UNKNOWN) { + // d_type not supported (non-ext[234], btrfs), must stat + struct stat sb; + char filename[PATH_MAX]; + snprintf(filename, sizeof(filename), "%s/%s", fn, de->d_name); + + r = ::stat(filename, &sb); + if (r == -1) { + r = -errno; + derr << "stat on " << filename << ": " << cpp_strerror(-r) << dendl; + break; + } + if (!S_ISDIR(sb.st_mode)) { + continue; + } + } else if (!S_ISDIR(de->d_type << 12)) { continue; + } if (de->d_name[0] == '.' && (de->d_name[1] == '\0' || (de->d_name[1] == '.' &&