summaryrefslogtreecommitdiffstats
path: root/storage/innobase/include/fil0fil.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--storage/innobase/include/fil0fil.h60
1 files changed, 34 insertions, 26 deletions
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index cdc32515..dfda1178 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -63,7 +63,7 @@ enum srv_flush_t
SRV_LITTLESYNC,
/** do not flush after writing */
SRV_NOSYNC,
- /** invoke os_file_set_nocache() on data files. This implies using
+ /** Open or create files with O_DIRECT. This implies using
unbuffered I/O but still fdatasync(), because some filesystems might
not flush meta-data on write completion */
SRV_O_DIRECT,
@@ -347,7 +347,6 @@ struct fil_space_t final
~fil_space_t()
{
ut_ad(!latch_owner);
- ut_ad(!latch_count);
latch.destroy();
}
@@ -411,9 +410,9 @@ private:
/** The reference count */
static constexpr uint32_t PENDING= ~(STOPPING | CLOSING | NEEDS_FSYNC);
/** latch protecting all page allocation bitmap pages */
- srw_lock latch;
+ IF_DBUG(srw_lock_debug, srw_lock) latch;
+ /** the thread that holds the exclusive latch, or 0 */
pthread_t latch_owner;
- ut_d(Atomic_relaxed<uint32_t> latch_count;)
public:
/** MariaDB encryption data */
fil_space_crypt_t *crypt_data;
@@ -1004,40 +1003,32 @@ public:
bool recheck, bool encrypt);
#ifdef UNIV_DEBUG
- bool is_latched() const { return latch_count != 0; }
+ bool is_latched() const { return latch.have_any(); }
#endif
- bool is_owner() const { return latch_owner == pthread_self(); }
+ bool is_owner() const
+ {
+ const bool owner{latch_owner == pthread_self()};
+ ut_ad(owner == latch.have_wr());
+ return owner;
+ }
/** Acquire the allocation latch in exclusive mode */
void x_lock()
{
latch.wr_lock(SRW_LOCK_CALL);
ut_ad(!latch_owner);
latch_owner= pthread_self();
- ut_ad(!latch_count.fetch_add(1));
}
/** Release the allocation latch from exclusive mode */
void x_unlock()
{
- ut_ad(latch_count.fetch_sub(1) == 1);
ut_ad(latch_owner == pthread_self());
latch_owner= 0;
latch.wr_unlock();
}
/** Acquire the allocation latch in shared mode */
- void s_lock()
- {
- ut_ad(!is_owner());
- latch.rd_lock(SRW_LOCK_CALL);
- ut_ad(!latch_owner);
- ut_d(latch_count.fetch_add(1));
- }
+ void s_lock() { latch.rd_lock(SRW_LOCK_CALL); }
/** Release the allocation latch from shared mode */
- void s_unlock()
- {
- ut_ad(latch_count.fetch_sub(1));
- ut_ad(!latch_owner);
- latch.rd_unlock();
- }
+ void s_unlock() { latch.rd_unlock(); }
typedef span<const char> name_type;
@@ -1637,17 +1628,34 @@ void fil_close_tablespace(uint32_t id);
/*******************************************************************//**
Allocates and builds a file name from a path, a table or tablespace name
and a suffix. The string must be freed by caller with ut_free().
-@param[in] path NULL or the directory path or the full path and filename.
+@param[in] path nullptr or the directory path or the full path and filename
@param[in] name {} if path is full, or Table/Tablespace name
-@param[in] ext the file extension to use
-@param[in] trim_name true if the last name on the path should be trimmed.
+@param[in] extension the file extension to use
+@param[in] trim_name true if the last name on the path should be trimmed
@return own: file name */
-char* fil_make_filepath(const char *path, const fil_space_t::name_type &name,
- ib_extention ext, bool trim_name);
+char* fil_make_filepath_low(const char *path,
+ const fil_space_t::name_type &name,
+ ib_extention extension, bool trim_name);
char *fil_make_filepath(const char* path, const table_name_t name,
ib_extention suffix, bool strip_name);
+/** Wrapper function over fil_make_filepath_low to build file name.
+@param path nullptr or the directory path or the full path and filename
+@param name {} if path is full, or Table/Tablespace name
+@param extension the file extension to use
+@param trim_name true if the last name on the path should be trimmed
+@return own: file name */
+static inline char*
+fil_make_filepath(const char* path, const fil_space_t::name_type &name,
+ ib_extention extension, bool trim_name)
+{
+ /* If we are going to strip a name off the path, there better be a
+ path and a new name to put back on. */
+ ut_ad(!trim_name || (path && name.data()));
+ return fil_make_filepath_low(path, name, extension, trim_name);
+}
+
/** Create a tablespace file.
@param[in] space_id Tablespace ID
@param[in] name Tablespace name in dbname/tablename format.