Skip to content

Commit 9e37537

Browse files
committed
MDEV-17441 - InnoDB transition to C++11 atomics
Trivial fil_space_t::n_pending_ops transition. Since it is not obvious which memory barriers are supposed to be issued, seq_cst memory order was preserved.
1 parent e2d96e8 commit 9e37537

File tree

3 files changed

+6
-33
lines changed

3 files changed

+6
-33
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@ fil_check_pending_ops(const fil_space_t* space, ulint count)
22972297
return 0;
22982298
}
22992299

2300-
if (ulint n_pending_ops = my_atomic_loadlint(&space->n_pending_ops)) {
2300+
if (ulint n_pending_ops = space->n_pending_ops) {
23012301

23022302
if (count > 5000) {
23032303
ib::warn() << "Trying to close/delete/truncate"

storage/innobase/include/fil0fil.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ struct fil_space_t {
133133
dropped. An example is change buffer merge.
134134
The tablespace cannot be dropped while this is nonzero,
135135
or while fil_node_t::n_pending is nonzero.
136-
Protected by fil_system.mutex and my_atomic_loadlint() and friends. */
137-
ulint n_pending_ops;
136+
Protected by fil_system.mutex and std::atomic. */
137+
std::atomic<ulint> n_pending_ops;
138138
/** Number of pending block read or write operations
139139
(when a write is imminent or a read has recently completed).
140140
The tablespace object cannot be freed while this is nonzero,
@@ -244,20 +244,11 @@ struct fil_space_t {
244244
void close();
245245

246246
/** Acquire a tablespace reference. */
247-
void acquire() { my_atomic_addlint(&n_pending_ops, 1); }
247+
void acquire() { n_pending_ops++; }
248248
/** Release a tablespace reference. */
249-
void release()
250-
{
251-
ut_ad(referenced());
252-
my_atomic_addlint(&n_pending_ops, ulint(-1));
253-
}
249+
void release() { ut_ad(referenced()); n_pending_ops--; }
254250
/** @return whether references are being held */
255-
bool referenced() { return my_atomic_loadlint(&n_pending_ops); }
256-
/** @return whether references are being held */
257-
bool referenced() const
258-
{
259-
return const_cast<fil_space_t*>(this)->referenced();
260-
}
251+
bool referenced() const { return n_pending_ops; }
261252

262253
/** Acquire a tablespace reference for I/O. */
263254
void acquire_for_io() { n_pending_ios++; }

storage/innobase/include/sync0types.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,15 +1117,6 @@ enum rw_lock_flag_t {
11171117

11181118
#endif /* UNIV_INNOCHECKSUM */
11191119

1120-
static inline ulint my_atomic_addlint(ulint *A, ulint B)
1121-
{
1122-
#ifdef _WIN64
1123-
return ulint(my_atomic_add64((volatile int64*)A, B));
1124-
#else
1125-
return ulint(my_atomic_addlong(A, B));
1126-
#endif
1127-
}
1128-
11291120
static inline ulint my_atomic_loadlint(const ulint *A)
11301121
{
11311122
#ifdef _WIN64
@@ -1135,15 +1126,6 @@ static inline ulint my_atomic_loadlint(const ulint *A)
11351126
#endif
11361127
}
11371128

1138-
static inline lint my_atomic_addlint(volatile lint *A, lint B)
1139-
{
1140-
#ifdef _WIN64
1141-
return my_atomic_add64((volatile int64*)A, B);
1142-
#else
1143-
return my_atomic_addlong(A, B);
1144-
#endif
1145-
}
1146-
11471129
static inline lint my_atomic_loadlint(const lint *A)
11481130
{
11491131
#ifdef _WIN64

0 commit comments

Comments
 (0)