From 1419f0021827f374abf449ae68e4fd6fda421cd0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 23 Dec 2008 12:29:04 -0800 Subject: [PATCH] os: start_sync osd operation If a client has a time sensitive operation, it can include a start_sync in the op vector to start an immediate commit to disk. It should then get the ONDISK ack sooner. --- src/ebofs/Ebofs.cc | 5 +++++ src/include/ceph_fs.h | 1 + src/os/FileStore.cc | 10 ++++++++++ src/os/FileStore.h | 2 ++ src/os/ObjectStore.h | 7 +++++++ src/osd/ReplicatedPG.cc | 3 +++ 6 files changed, 28 insertions(+) diff --git a/src/ebofs/Ebofs.cc b/src/ebofs/Ebofs.cc index da753a710a9f8..17d34f34aa2ac 100644 --- a/src/ebofs/Ebofs.cc +++ b/src/ebofs/Ebofs.cc @@ -2493,6 +2493,11 @@ unsigned Ebofs::_apply_transaction(Transaction& t) int op = t.get_op(); switch (op) { + case Transaction::OP_STARTSYNC: + dirty = true; + commit_cond.Signal(); + break; + case Transaction::OP_TOUCH: { coll_t cid = t.get_cid(); diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index e2190f6e2a8f2..ed96845754077 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -1112,6 +1112,7 @@ enum { /* fancy write */ CEPH_OSD_OP_APPEND = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 6, + CEPH_OSD_OP_STARTSYNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 7, }; static inline int ceph_osd_op_type_lock(int op) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index bdc3a850f25b1..c5e46e7100563 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -694,6 +694,10 @@ unsigned FileStore::_apply_transaction(Transaction& t) _collection_rmattr(t.get_cid(), t.get_attrname()); break; + case Transaction::OP_STARTSYNC: + _start_sync(); + break; + default: cerr << "bad op " << op << std::endl; assert(0); @@ -1431,6 +1435,12 @@ void FileStore::sync_entry() lock.Unlock(); } +void FileStore::_start_sync() +{ + dout(10) << "start_sync" << dendl; + sync_cond.Signal(); +} + void FileStore::sync() { Mutex::Locker l(lock); diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 9f6fabc136902..69ede33204bca 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -115,6 +115,8 @@ class FileStore : public JournalingObjectStore { int _do_clone_range(int from, int to, __u64 off, __u64 len); int _remove(coll_t cid, pobject_t oid); + void _start_sync(); + void sync(); void sync(Context *onsafe); diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 3877d50aec2e2..ac077d449fda3 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -98,6 +98,9 @@ public: static const int OP_COLL_RMATTR = 25; // cid, attrname static const int OP_COLL_SETATTRS = 26; // cid, attrset + static const int OP_STARTSYNC = 27; // start a sync + + private: /* int len; @@ -158,6 +161,10 @@ public: return attrsets[attrsetp++]; } + void start_sync() { + int op = OP_STARTSYNC; + ops.push_back(op); + } void touch(coll_t cid, pobject_t oid) { int op = OP_TOUCH; ops.push_back(op); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 46f519f2156dc..dbb4777dc3916 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1131,6 +1131,9 @@ int ReplicatedPG::prepare_simple_op(ObjectStore::Transaction& t, osd_reqid_t req } break; + case CEPH_OSD_OP_STARTSYNC: + t.start_sync(); + break; default: return -EINVAL; -- 2.47.3