From: Sage Weil Date: Sun, 8 Aug 2010 15:59:59 +0000 (-0700) Subject: filestore: flush using sync(2) hammer X-Git-Tag: v0.22~301 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b93dc97753c9991d8cce59a783ee64ea441150c;p=ceph.git filestore: flush using sync(2) hammer 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. --- diff --git a/src/config.cc b/src/config.cc index b5aa64d8f046..e29a968014a5 100644 --- a/src/config.cc +++ b/src/config.cc @@ -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), diff --git a/src/config.h b/src/config.h index 3d42a347d45e..2809d2c7d355 100644 --- a/src/config.h +++ b/src/config.h @@ -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; diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 22c53594d890..061126596e31 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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(); } }