]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: stat to test for file type if d_type is unsupported
authorJosh Durgin <josh.durgin@dreamhost.com>
Thu, 2 Jun 2011 23:59:22 +0000 (16:59 -0700)
committerJosh Durgin <josh.durgin@dreamhost.com>
Fri, 3 Jun 2011 01:10:53 +0000 (18:10 -0700)
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 <yoshi@midokura.jp>
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/os/FileStore.cc

index 3c9ec18883bdd39c9866e0e5d276f83fe4e50b9a..0c64bcf21df343eec3e610d92100177b994b5279 100644 (file)
@@ -3650,8 +3650,24 @@ int FileStore::list_collections(vector<coll_t>& 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] == '.' &&