@@ -912,14 +912,12 @@ class Fil_shard {
912912
913913 /* * Check pending operations on a tablespace.
914914 @param[in] space_id Tablespace ID
915- @param[in] operation File operation
916915 @param[out] space tablespace instance in memory
917916 @param[out] path tablespace path
918917 @return DB_SUCCESS or DB_TABLESPACE_NOT_FOUND. */
919918 dberr_t space_check_pending_operations (
920919 space_id_t space_id,
921- fil_operation_t operation,
922- fil_space_t ** space,
920+ fil_space_t *& space,
923921 char ** path) const
924922 MY_ATTRIBUTE((warn_unused_result));
925923
@@ -1126,9 +1124,9 @@ class Fil_shard {
11261124
11271125 /* * We are going to do a rename file and want to stop new I/O
11281126 for a while.
1129- @param[in,out ] space Tablespace for which we want to
1127+ @param[in] space Tablespace for which we want to
11301128 wait for IO to stop */
1131- static void wait_for_io_to_stop (fil_space_t * space);
1129+ static void wait_for_io_to_stop (const fil_space_t * space);
11321130
11331131private:
11341132
@@ -1170,15 +1168,14 @@ class Fil_shard {
11701168
11711169 /* * Check for pending IO.
11721170 @param[in] operation File operation
1173- @param[in,out ] space Tablespace to check
1174- @param[out ] file File in space list
1171+ @param[in] space Tablespace to check
1172+ @param[in ] file File in space list
11751173 @param[in] count number of attempts so far
11761174 @return 0 if no pending else count + 1. */
11771175 ulint check_pending_io (
1178- fil_operation_t operation,
1179- fil_space_t * space,
1180- fil_node_t ** file,
1181- ulint count) const
1176+ const fil_space_t * space,
1177+ const fil_node_t & file,
1178+ ulint count) const
11821179 MY_ATTRIBUTE((warn_unused_result));
11831180
11841181 /* * Flushes to disk possible writes cached by the OS. */
@@ -2876,10 +2873,10 @@ Fil_system::close_file_in_all_LRU(bool print_info)
28762873}
28772874
28782875/* * We are going to do a rename file and want to stop new I/O for a while.
2879- @param[in,out ] space Tablespace for which we want to wait for IO
2876+ @param[in] space Tablespace for which we want to wait for IO
28802877 to stop */
28812878void
2882- Fil_shard::wait_for_io_to_stop (fil_space_t * space)
2879+ Fil_shard::wait_for_io_to_stop (const fil_space_t * space)
28832880{
28842881 /* Note: We are reading the value of space->stop_ios without the
28852882 cover of the Fil_shard::mutex. We incremented the in_use counter
@@ -4112,44 +4109,32 @@ Fil_shard::space_check_pending_operations(fil_space_t* space, ulint count) const
41124109}
41134110
41144111/* * Check for pending IO.
4115- @param[in] operation File operation
4116- @param[in,out] space Tablespace to check
4117- @param[out] file File in space list
4112+ @param[in] space Tablespace to check
4113+ @param[in] file File in space list
41184114@param[in] count number of attempts so far
41194115@return 0 if no pending else count + 1. */
41204116ulint
41214117Fil_shard::check_pending_io (
4122- fil_operation_t operation,
4123- fil_space_t * space,
4124- fil_node_t ** file,
4125- ulint count) const
4118+ const fil_space_t * space,
4119+ const fil_node_t & file,
4120+ ulint count) const
41264121{
41274122 ut_ad (mutex_owned ());
41284123 ut_a (space->n_pending_ops == 0 );
41294124
4130- switch (operation) {
4131- case FIL_OPERATION_CLOSE:
4132- case FIL_OPERATION_DELETE:
4133- break ;
4134- }
4135-
41364125 ut_a (space->id == TRX_SYS_SPACE
41374126 || space->purpose == FIL_TYPE_TEMPORARY
41384127 || space->id == dict_sys_t ::s_log_space_first_id
41394128 || space->files .size () == 1 );
41404129
4141- *file = &space->files .front ();
4142-
4143- if (space->n_pending_flushes > 0 || (*file)->n_pending > 0 ) {
4144-
4145- ut_a ((*file)->in_use == 0 );
4130+ if (space->n_pending_flushes > 0 || file.n_pending > 0 ) {
41464131
41474132 if (count > 1000 ) {
41484133 ib::warn () << " Trying to delete/close"
41494134 " tablespace '" << space->name
41504135 << " ' but there are "
41514136 << space->n_pending_flushes
4152- << " flushes and " << (* file)-> n_pending
4137+ << " flushes and " << file. n_pending
41534138 << " pending I/O's on it." ;
41544139 }
41554140
@@ -4161,20 +4146,18 @@ Fil_shard::check_pending_io(
41614146
41624147/* * Check pending operations on a tablespace.
41634148@param[in] space_id Tablespace ID
4164- @param[in] operation File operation
41654149@param[out] space tablespace instance in memory
41664150@param[out] path tablespace path
41674151@return DB_SUCCESS or DB_TABLESPACE_NOT_FOUND. */
41684152dberr_t
41694153Fil_shard::space_check_pending_operations (
41704154 space_id_t space_id,
4171- fil_operation_t operation,
4172- fil_space_t ** space,
4155+ fil_space_t *& space,
41734156 char ** path) const
41744157{
41754158 ut_ad (!fsp_is_system_or_temp_tablespace (space_id));
41764159
4177- * space = nullptr ;
4160+ space = nullptr ;
41784161
41794162 mutex_acquire ();
41804163
@@ -4221,12 +4204,12 @@ Fil_shard::space_check_pending_operations(
42214204 return (DB_TABLESPACE_NOT_FOUND);
42224205 }
42234206
4224- fil_node_t * file;
4207+ const fil_node_t & file = sp-> files . front () ;
42254208
4226- count = check_pending_io (operation, sp, & file, count);
4209+ count = check_pending_io (sp, file, count);
42274210
42284211 if (count == 0 ) {
4229- *path = mem_strdup (file-> name );
4212+ *path = mem_strdup (file. name );
42304213 }
42314214
42324215 mutex_release ();
@@ -4239,7 +4222,7 @@ Fil_shard::space_check_pending_operations(
42394222
42404223 ut_ad (sp != nullptr );
42414224
4242- * space = sp;
4225+ space = sp;
42434226
42444227 return (DB_SUCCESS);
42454228}
@@ -4311,8 +4294,9 @@ fil_close_tablespace(trx_t* trx, space_id_t space_id)
43114294
43124295 auto shard = fil_system->shard_by_id (space_id);
43134296
4314- dberr_t err = shard->space_check_pending_operations (
4315- space_id, FIL_OPERATION_CLOSE, &space, &path);
4297+ dberr_t err;
4298+
4299+ err = shard->space_check_pending_operations (space_id, space, &path);
43164300
43174301 if (err != DB_SUCCESS) {
43184302 return (err);
@@ -4481,8 +4465,7 @@ Fil_shard::space_delete(
44814465 ut_ad (!fsp_is_system_or_temp_tablespace (space_id));
44824466 ut_ad (!fsp_is_undo_tablespace (space_id));
44834467
4484- dberr_t err = space_check_pending_operations (
4485- space_id, FIL_OPERATION_DELETE, &space, &path);
4468+ dberr_t err = space_check_pending_operations (space_id, space, &path);
44864469
44874470 if (err != DB_SUCCESS) {
44884471
@@ -4650,8 +4633,7 @@ Fil_shard::space_prepare_for_truncate(space_id_t space_id)
46504633 ut_ad (!fsp_is_system_or_temp_tablespace (space_id));
46514634 ut_ad (fsp_is_undo_tablespace (space_id));
46524635
4653- dberr_t err = space_check_pending_operations (
4654- space_id, FIL_OPERATION_CLOSE, &space, &path);
4636+ dberr_t err = space_check_pending_operations (space_id, space, &path);
46554637
46564638 ut_free (path);
46574639
0 commit comments