@@ -76,7 +76,7 @@ bool PageCacheSlot::is_pinned() const noexcept
76
76
77
77
// ==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
78
78
//
79
- u32 PageCacheSlot::pin_count () const noexcept
79
+ u64 PageCacheSlot::pin_count () const noexcept
80
80
{
81
81
return Self::get_pin_count (this ->state_ .load (std::memory_order_acquire));
82
82
}
@@ -116,11 +116,11 @@ auto PageCacheSlot::acquire_pin(PageId key, bool ignore_key) noexcept -> PinnedR
116
116
{
117
117
const auto old_state = this ->state_ .fetch_add (kPinCountDelta , std::memory_order_acquire);
118
118
const auto new_state = old_state + kPinCountDelta ;
119
- const bool newly_pinned = !this -> is_pinned (old_state);
119
+ const bool newly_pinned = !Self:: is_pinned (old_state);
120
120
121
121
BATT_CHECK_EQ (new_state & Self::kOverflowMask , 0 );
122
122
123
- BATT_CHECK (this -> is_pinned (new_state));
123
+ BATT_CHECK (Self:: is_pinned (new_state));
124
124
125
125
BATT_SUPPRESS_IF_GCC (" -Wmaybe-uninitialized" )
126
126
@@ -134,7 +134,7 @@ auto PageCacheSlot::acquire_pin(PageId key, bool ignore_key) noexcept -> PinnedR
134
134
// If the pin_count > 1 (because of the fetch_add above) and the slot is valid, it is safe to read
135
135
// the key. If the key doesn't match, release the ref and return failure.
136
136
//
137
- if (!this -> is_valid (old_state) ||
137
+ if (!Self:: is_valid (old_state) ||
138
138
(!ignore_key && (!this ->key_ .is_valid () || this ->key_ != key))) {
139
139
this ->release_pin ();
140
140
return PinnedRef{};
@@ -149,7 +149,7 @@ auto PageCacheSlot::acquire_pin(PageId key, bool ignore_key) noexcept -> PinnedR
149
149
BATT_CHECK (this ->value_ );
150
150
}
151
151
152
- return PinnedRef{this };
152
+ return PinnedRef{this , CallerPromisesTheyAcquiredPinCount{} };
153
153
}
154
154
155
155
// ==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
@@ -199,7 +199,7 @@ void PageCacheSlot::release_pin() noexcept
199
199
<< BATT_INSPECT (old_state);
200
200
201
201
const auto new_state = old_state - kPinCountDelta ;
202
- const bool newly_unpinned = !this -> is_pinned (new_state);
202
+ const bool newly_unpinned = !Self:: is_pinned (new_state);
203
203
204
204
BATT_CHECK_EQ (new_state & Self::kOverflowMask , 0 );
205
205
@@ -221,7 +221,7 @@ bool PageCacheSlot::evict() noexcept
221
221
//
222
222
auto observed_state = this ->state_ .load (std::memory_order_acquire);
223
223
for (;;) {
224
- if (Self::is_pinned (observed_state) || !this -> is_valid (observed_state)) {
224
+ if (Self::is_pinned (observed_state) || !Self:: is_valid (observed_state)) {
225
225
return false ;
226
226
}
227
227
@@ -244,7 +244,7 @@ bool PageCacheSlot::evict_if_key_equals(PageId key) noexcept
244
244
const auto old_state = this ->state_ .fetch_add (kPinCountDelta , std::memory_order_acquire);
245
245
auto observed_state = old_state + kPinCountDelta ;
246
246
247
- const bool newly_pinned = !this -> is_pinned (old_state);
247
+ const bool newly_pinned = !Self:: is_pinned (old_state);
248
248
if (newly_pinned) {
249
249
this ->add_ref ();
250
250
}
@@ -257,7 +257,7 @@ bool PageCacheSlot::evict_if_key_equals(PageId key) noexcept
257
257
for (;;) {
258
258
// To succeed, we must be holding the only pin, the slot must be valid, and the key must match.
259
259
//
260
- if (!(Self::get_pin_count (observed_state) == 1 && this -> is_valid (observed_state) &&
260
+ if (!(Self::get_pin_count (observed_state) == 1 && Self:: is_valid (observed_state) &&
261
261
this ->key_ == key)) {
262
262
this ->release_pin ();
263
263
return false ;
@@ -300,7 +300,7 @@ auto PageCacheSlot::fill(PageId key) noexcept -> PinnedRef
300
300
this ->add_ref ();
301
301
this ->set_valid ();
302
302
303
- return PinnedRef{this };
303
+ return PinnedRef{this , CallerPromisesTheyAcquiredPinCount{} };
304
304
}
305
305
306
306
// ==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
@@ -333,7 +333,7 @@ void PageCacheSlot::notify_last_ref_released()
333
333
void PageCacheSlot::set_valid ()
334
334
{
335
335
const auto observed_state = this ->state_ .fetch_or (kValidMask , std::memory_order_release);
336
- BATT_CHECK (!this -> is_valid (observed_state)) << " Must go from an invalid state to valid!" ;
336
+ BATT_CHECK (!Self:: is_valid (observed_state)) << " Must go from an invalid state to valid!" ;
337
337
}
338
338
339
339
} // namespace llfs
0 commit comments