]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: flush using sync(2) hammer
authorSage Weil <sage@newdream.net>
Sun, 8 Aug 2010 15:59:59 +0000 (08:59 -0700)
committerSage Weil <sage@newdream.net>
Sun, 8 Aug 2010 15:59:59 +0000 (08:59 -0700)
Since we can't easily detect ext3 (let alone whether we have data=journal),
by default use sync(2) as an overly large hammer to flush all prior applied
ops to disk.  If the option is explicitly enabled, use fsync(2) on a
file to implicitly flush the journal and prior writes.  Admins should only
enable this if they have ext2 in data=journal mode.

src/config.cc
src/config.h
src/os/FileStore.cc

index b5aa64d8f046fdc967ac83ccf1382da307e80c30..e29a968014a5efceeaa209f6b6ef7b19ebfa005b 100644 (file)
@@ -503,6 +503,7 @@ static struct config_option config_optionsp[] = {
        OPTION(filestore_btrfs_trans, 0, OPT_BOOL, true),
        OPTION(filestore_btrfs_snap, 0, OPT_BOOL, false),
        OPTION(filestore_btrfs_clone_range, 0, OPT_BOOL, true),
+       OPTION(filestore_fsync_flushes_journal_data, 0, OPT_BOOL, false),
        OPTION(filestore_flusher, 0, OPT_BOOL, true),
        OPTION(filestore_flusher_max_fds, 0, OPT_INT, 512),
        OPTION(filestore_sync_flush, 0, OPT_BOOL, false),
index 3d42a347d45eb70c25ec0ee0a1236319c113f1f8..2809d2c7d35500b2c382cbc4583bff6b0375a4d7 100644 (file)
@@ -370,6 +370,7 @@ struct md_config_t {
   bool filestore_btrfs_trans;
   bool filestore_btrfs_snap;
   bool filestore_btrfs_clone_range;
+  bool filestore_fsync_flushes_journal_data;
   bool filestore_flusher;
   int filestore_flusher_max_fds;
   bool filestore_sync_flush;
index 22c53594d890571c7a7efa7c6b888ea820b1f38f..061126596e3196b5b356166d287498acde85a72a 100644 (file)
@@ -459,14 +459,16 @@ int FileStore::_detect_fs()
     }
   }
 
-  // btrfs?
   int fd = ::open(basedir.c_str(), O_RDONLY);
   if (fd < 0)
     return -errno;
 
   struct statfs st;
   int r = ::fstatfs(fd, &st);
-  if (r == 0 && st.f_type == 0x9123683E) {
+  if (r < 0)
+    return -errno;
+
+  if (st.f_type == 0x9123683E) {
     dout(0) << "mount detected btrfs" << dendl;      
     btrfs = true;
 
@@ -1719,11 +1721,14 @@ void FileStore::sync_entry()
          dout(15) << "sync_entry doing btrfs sync" << dendl;
          // do a full btrfs commit
          ::ioctl(op_fd, BTRFS_IOC_SYNC);
-       } else {
+       } else if (g_conf.filestore_fsync_flushes_journal_data) {
          dout(15) << "sync_entry doing fsync on " << current_op_seq_fn << dendl;
          // make the file system's journal commit.
          //  this works with ext3, but NOT ext4
          ::fsync(op_fd);  
+       } else {
+         dout(15) << "sync_entry doing a full sync (!)" << dendl;
+         ::sync();
        }
       }