File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -494,8 +494,9 @@ class Cache {
494494 } else {
495495 // stable from trans-view
496496 assert (!p_extent->is_pending_in_trans (t.get_trans_id ()));
497- t.add_to_read_set (p_extent);
498- touch_extent (*p_extent);
497+ if (t.maybe_add_to_read_set (p_extent)) {
498+ touch_extent (*p_extent);
499+ }
499500 }
500501 } else {
501502 assert (!extent->is_stable_writting ());
Original file line number Diff line number Diff line change @@ -137,14 +137,37 @@ class Transaction {
137137 }
138138 }
139139
140+ // Returns true if added, false if already added or weak
141+ bool maybe_add_to_read_set (CachedExtentRef ref) {
142+ if (is_weak ()) {
143+ return false ;
144+ }
145+
146+ assert (ref->is_valid ());
147+
148+ auto it = ref->transactions .lower_bound (
149+ this , read_set_item_t <Transaction>::trans_cmp_t ());
150+ if (it != ref->transactions .end () && it->t == this ) {
151+ return false ;
152+ }
153+
154+ auto [iter, inserted] = read_set.emplace (this , ref);
155+ ceph_assert (inserted);
156+ ref->transactions .insert_before (
157+ it, const_cast <read_set_item_t <Transaction>&>(*iter));
158+ return true ;
159+ }
160+
140161 void add_to_read_set (CachedExtentRef ref) {
141- if (is_weak ()) return ;
162+ if (is_weak ()) {
163+ return ;
164+ }
142165
143166 assert (ref->is_valid ());
144167
145168 auto it = ref->transactions .lower_bound (
146169 this , read_set_item_t <Transaction>::trans_cmp_t ());
147- if (it != ref->transactions .end () && it->t == this ) return ;
170+ assert (it == ref->transactions .end () || it->t != this );
148171
149172 auto [iter, inserted] = read_set.emplace (this , ref);
150173 ceph_assert (inserted);
You can’t perform that action at this time.
0 commit comments