]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/FileStore: automatically enable 'filestore xattr use omap' as needed 386/head
authorSage Weil <sage@inktank.com>
Sat, 29 Jun 2013 01:26:31 +0000 (18:26 -0700)
committerSage Weil <sage@inktank.com>
Mon, 1 Jul 2013 20:45:25 +0000 (13:45 -0700)
Automatically enable the 'filestore xattr use omap' option if the fs
does not appear to handle large xattrs on its own.

This makes for a more pleasant use experience as they are not told to
enable something that we already know they must enable in order to
continue.

Fixes: #5137
Signed-off-by: Sage Weil <sage@inktank.com>
src/os/FileStore.cc
src/vstart.sh

index 9c7d6c77ea3582d897d69d7830f089259df94103..70f182a61e00c56304be403dc94dbde659cd8b17 100644 (file)
@@ -1000,16 +1000,39 @@ int FileStore::_test_fiemap()
 
 int FileStore::_detect_fs()
 {
+  int fd = ::open(basedir.c_str(), O_RDONLY);
+  if (fd < 0)
+    return -errno;
+
+  struct statfs st;
+  int r = ::fstatfs(fd, &st);
+  if (r < 0) {
+    TEMP_FAILURE_RETRY(::close(fd));
+    return -errno;
+  }
+
+#if defined(__linux__)
+  if (st.f_type == XFS_SUPER_MAGIC) {
+    dout(1) << "mount detected xfs" << dendl;
+    if (m_filestore_replica_fadvise) {
+      dout(1) << " disabling 'filestore replica fadvise' due to known issues with fadvise(DONTNEED) on xfs" << dendl;
+      g_conf->set_val("filestore_replica_fadvise", "false");
+      g_conf->apply_changes(NULL);
+      assert(m_filestore_replica_fadvise == false);
+    }
+  }
+#endif
+
+  // test xattrs
   char fn[PATH_MAX];
   int x = rand();
   int y = x+1;
-
   snprintf(fn, sizeof(fn), "%s/xattr_test", basedir.c_str());
-
   int tmpfd = ::open(fn, O_CREAT|O_WRONLY|O_TRUNC, 0700);
   if (tmpfd < 0) {
     int ret = -errno;
     derr << "_detect_fs unable to create " << fn << ": " << cpp_strerror(ret) << dendl;
+    TEMP_FAILURE_RETRY(::close(fd));
     return ret;
   }
 
@@ -1024,6 +1047,7 @@ int FileStore::_detect_fs()
           << "file system with the 'user_xattr' option." << dendl;
     ::unlink(fn);
     TEMP_FAILURE_RETRY(::close(tmpfd));
+    TEMP_FAILURE_RETRY(::close(fd));
     return -ENOTSUP;
   }
 
@@ -1036,12 +1060,12 @@ int FileStore::_detect_fs()
   ret = chain_fsetxattr(tmpfd, "user.test5", &buf, sizeof(buf));
   if (ret == -ENOSPC) {
     if (!g_conf->filestore_xattr_use_omap) {
-      derr << "limited size xattrs -- enable filestore_xattr_use_omap" << dendl;
-      ::unlink(fn);
-      TEMP_FAILURE_RETRY(::close(tmpfd));
-      return -ENOTSUP;
+      dout(0) << "limited size xattrs -- automatically enabling filestore_xattr_use_omap" << dendl;
+      g_conf->set_val("filestore_xattr_use_omap", "true");
+      g_conf->apply_changes(NULL);
+      assert(g_conf->filestore_xattr_use_omap == true);
     } else {
-      derr << "limited size xattrs -- filestore_xattr_use_omap enabled" << dendl;
+      dout(0) << "limited size xattrs -- filestore_xattr_use_omap already enabled" << dendl;
     }
   }
   chain_fremovexattr(tmpfd, "user.test");
@@ -1053,36 +1077,14 @@ int FileStore::_detect_fs()
   ::unlink(fn);
   TEMP_FAILURE_RETRY(::close(tmpfd));
 
-  int fd = ::open(basedir.c_str(), O_RDONLY);
-  if (fd < 0)
-    return -errno;
-
-  int r = _test_fiemap();
+  r = _test_fiemap();
   if (r < 0) {
     TEMP_FAILURE_RETRY(::close(fd));
     return -r;
   }
 
-  struct statfs st;
-  r = ::fstatfs(fd, &st);
-  if (r < 0) {
-    TEMP_FAILURE_RETRY(::close(fd));
-    return -errno;
-  }
   blk_size = st.f_bsize;
 
-#if defined(__linux__)
-  if (st.f_type == XFS_SUPER_MAGIC) {
-    dout(1) << "mount detected xfs" << dendl;
-    if (m_filestore_replica_fadvise) {
-      dout(1) << " disabling 'filestore replica fadvise' due to known issues with fadvise(DONTNEED) on xfs" << dendl;
-      g_conf->set_val("filestore_replica_fadvise", "false");
-      g_conf->apply_changes(NULL);
-      assert(m_filestore_replica_fadvise == false);
-    }
-  }
-#endif
-
 #if defined(__linux__)
   if (st.f_type == BTRFS_SUPER_MAGIC) {
     dout(0) << "mount detected btrfs" << dendl;      
index f179b0b1bf1c1c5346ae19334c7454c8a4b581e8..577ea4c843d1a0239007270bfc07f630020e1864 100755 (executable)
@@ -329,7 +329,6 @@ $DAEMONOPTS
         osd class tmp = out
         osd class dir = .libs
         osd scrub load threshold = 5.0
-        filestore xattr use omap = true
         osd debug op order = true
 $COSDDEBUG
 $extra_conf