File tree Expand file tree Collapse file tree 7 files changed +69
-1
lines changed
Expand file tree Collapse file tree 7 files changed +69
-1
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,19 @@ seastar::future<> AlienStore::stop()
136136 });
137137}
138138
139+ AlienStore::base_errorator::future<bool >
140+ AlienStore::exists (
141+ CollectionRef ch,
142+ const ghobject_t & oid)
143+ {
144+ return seastar::with_gate (op_gate, [=, this ] {
145+ return tp->submit (ch->get_cid ().hash_to_shard (tp->size ()), [=, this ] {
146+ auto c = static_cast <AlienCollection*>(ch.get ());
147+ return store->exists (c->collection , oid);
148+ });
149+ });
150+ }
151+
139152AlienStore::mount_ertr::future<> AlienStore::mount ()
140153{
141154 logger ().debug (" {}" , __func__);
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ class AlienStore final : public FuturizedStore,
3333 mount_ertr::future<> mount () final ;
3434 seastar::future<> umount () final ;
3535
36+ base_errorator::future<bool > exists (
37+ CollectionRef c,
38+ const ghobject_t & oid) final ;
3639 mkfs_ertr::future<> mkfs (uuid_d new_osd_fsid) final ;
3740 read_errorator::future<ceph::bufferlist> read (CollectionRef c,
3841 const ghobject_t & oid,
Original file line number Diff line number Diff line change @@ -242,6 +242,22 @@ CyanStore::Shard::list_collections()
242242 return seastar::make_ready_future<std::vector<coll_core_t >>(std::move (collections));
243243}
244244
245+ CyanStore::Shard::base_errorator::future<bool >
246+ CyanStore::Shard::exists (
247+ CollectionRef ch,
248+ const ghobject_t &oid)
249+ {
250+ auto c = static_cast <Collection*>(ch.get ());
251+ if (!c->exists ) {
252+ return base_errorator::make_ready_future<bool >(false );
253+ }
254+ auto o = c->get_object (oid);
255+ if (!o) {
256+ return base_errorator::make_ready_future<bool >(false );
257+ }
258+ return base_errorator::make_ready_future<bool >(true );
259+ }
260+
245261CyanStore::Shard::read_errorator::future<ceph::bufferlist>
246262CyanStore::Shard::read (
247263 CollectionRef ch,
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class Transaction;
2626
2727namespace crimson ::os {
2828class CyanStore final : public FuturizedStore {
29+ public:
2930 class Shard : public FuturizedStore ::Shard {
3031 public:
3132 Shard (std::string path)
@@ -35,6 +36,10 @@ class CyanStore final : public FuturizedStore {
3536 CollectionRef c,
3637 const ghobject_t & oid) final ;
3738
39+ base_errorator::future<bool > exists (
40+ CollectionRef ch,
41+ const ghobject_t & oid) final ;
42+
3843 read_errorator::future<ceph::bufferlist> read (
3944 CollectionRef c,
4045 const ghobject_t & oid,
@@ -158,7 +163,6 @@ class CyanStore final : public FuturizedStore {
158163 std::map<coll_t , boost::intrusive_ptr<Collection>> new_coll_map;
159164 };
160165
161- public:
162166 CyanStore (const std::string& path);
163167 ~CyanStore () final ;
164168
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ class FuturizedStore {
3636 const Shard& operator =(const Shard& o) = delete ;
3737
3838 using CollectionRef = boost::intrusive_ptr<FuturizedCollection>;
39+ using base_errorator = crimson::errorator<crimson::ct_error::input_output_error>;
3940 using read_errorator = crimson::errorator<crimson::ct_error::enoent,
4041 crimson::ct_error::input_output_error>;
4142 virtual read_errorator::future<ceph::bufferlist> read (
@@ -51,6 +52,10 @@ class FuturizedStore {
5152 interval_set<uint64_t >& m,
5253 uint32_t op_flags = 0 ) = 0;
5354
55+ virtual base_errorator::future<bool > exists (
56+ CollectionRef c,
57+ const ghobject_t & oid) = 0;
58+
5459 using get_attr_errorator = crimson::errorator<
5560 crimson::ct_error::enoent,
5661 crimson::ct_error::enodata>;
Original file line number Diff line number Diff line change @@ -852,6 +852,29 @@ SeaStore::Shard::read(
852852 });
853853}
854854
855+ SeaStore::Shard::base_errorator::future<bool >
856+ SeaStore::Shard::exists (
857+ CollectionRef c,
858+ const ghobject_t & oid)
859+ {
860+ LOG_PREFIX (SeaStore::exists);
861+ DEBUG (" oid {}" , oid);
862+ return repeat_with_onode<bool >(
863+ c,
864+ oid,
865+ Transaction::src_t ::READ,
866+ " oid_exists" ,
867+ op_type_t ::READ,
868+ [](auto &, auto &) {
869+ return seastar::make_ready_future<bool >(true );
870+ }).handle_error (
871+ crimson::ct_error::enoent::handle ([] {
872+ return seastar::make_ready_future<bool >(false );
873+ }),
874+ crimson::ct_error::assert_all{" unexpected error" }
875+ );
876+ }
877+
855878SeaStore::Shard::read_errorator::future<ceph::bufferlist>
856879SeaStore::Shard::readv (
857880 CollectionRef ch,
Original file line number Diff line number Diff line change @@ -116,6 +116,10 @@ class SeaStore final : public FuturizedStore {
116116 interval_set<uint64_t >& m,
117117 uint32_t op_flags = 0 ) final ;
118118
119+ base_errorator::future<bool > exists (
120+ CollectionRef c,
121+ const ghobject_t & oid) final ;
122+
119123 get_attr_errorator::future<ceph::bufferlist> get_attr (
120124 CollectionRef c,
121125 const ghobject_t & oid,
You can’t perform that action at this time.
0 commit comments