Changeset f08c7133 in rtems


Ignore:
Timestamp:
Mar 16, 2017, 10:54:29 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11
Children:
21d7154b
Parents:
2ea436a
git-author:
Sebastian Huber <sebastian.huber@…> (03/16/17 10:54:29)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/21/17 15:13:11)
Message:

libio: Fix deadlock in location management

Perform a context-dependent deferred location release to avoid a
deadlock on the file system instance locks, for example during a
chdir().

Close #2936.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/libio_.h

    r2ea436a rf08c7133  
    508508 *
    509509 * @param[in] global_loc The global file system location.  It must not be NULL.
     510 * @param[in] deferred If true, then do a deferred release, otherwise release
     511 *   it immediately.
    510512 *
    511513 * @see rtems_filesystem_global_location_obtain().
    512514 */
    513515void rtems_filesystem_global_location_release(
    514   rtems_filesystem_global_location_t *global_loc
     516  rtems_filesystem_global_location_t *global_loc,
     517  bool deferred
    515518);
    516519
  • cpukit/libcsupport/src/chdir.c

    r2ea436a rf08c7133  
    4040  } else {
    4141    rtems_filesystem_location_error( &global_loc->location, ENOTDIR );
    42     rtems_filesystem_global_location_release( global_loc );
     42    rtems_filesystem_global_location_release( global_loc, true );
    4343    rv = -1;
    4444  }
  • cpukit/libcsupport/src/chroot.c

    r2ea436a rf08c7133  
    8181
    8282    if ( rv != 0 ) {
    83       rtems_filesystem_global_location_release( new_root_loc );
     83      rtems_filesystem_global_location_release( new_root_loc, true );
    8484    }
    8585  } else {
     
    9090
    9191  if ( rv != 0 ) {
    92     rtems_filesystem_global_location_release( new_current_loc );
     92    rtems_filesystem_global_location_release( new_current_loc, false );
    9393  }
    9494
  • cpukit/libcsupport/src/mount.c

    r2ea436a rf08c7133  
    127127      rtems_filesystem_mt_unlock();
    128128    } else {
    129       rtems_filesystem_global_location_release( mt_point_node );
     129      rtems_filesystem_global_location_release( mt_point_node, true );
    130130    }
    131131  } else {
  • cpukit/libcsupport/src/privateenv.c

    r2ea436a rf08c7133  
    4545
    4646  if (!uses_global_env) {
    47     rtems_filesystem_global_location_release(env->current_directory);
    48     rtems_filesystem_global_location_release(env->root_directory);
     47    rtems_filesystem_global_location_release(env->current_directory, false);
     48    rtems_filesystem_global_location_release(env->root_directory, false);
    4949    free(env);
    5050  }
  • cpukit/libcsupport/src/sup_fs_eval_path.c

    r2ea436a rf08c7133  
    302302  free_location(&ctx->currentloc);
    303303  rtems_filesystem_instance_unlock(&ctx->startloc->location);
    304   rtems_filesystem_global_location_release(ctx->startloc);
    305   rtems_filesystem_global_location_release(ctx->rootloc);
     304  rtems_filesystem_global_location_release(ctx->startloc, false);
     305  rtems_filesystem_global_location_release(ctx->rootloc, false);
    306306}
    307307
  • cpukit/libcsupport/src/sup_fs_location.c

    r2ea436a rf08c7133  
    106106  rtems_filesystem_mt_entry_unlock(lock_context);
    107107
    108   rtems_filesystem_global_location_release(lhs_global_loc);
     108  rtems_filesystem_global_location_release(lhs_global_loc, true);
    109109}
    110110
     
    184184
    185185void rtems_filesystem_global_location_release(
    186   rtems_filesystem_global_location_t *global_loc
    187 )
    188 {
    189   if (_Thread_Dispatch_is_enabled()) {
     186  rtems_filesystem_global_location_t *global_loc,
     187  bool deferred
     188)
     189{
     190  if (!deferred) {
    190191    release_with_count(global_loc, 1);
    191192  } else {
     
    233234  rtems_chain_extract_unprotected(&mt_entry->mt_node);
    234235  rtems_filesystem_mt_unlock();
    235   rtems_filesystem_global_location_release(mt_entry->mt_point_node);
     236  rtems_filesystem_global_location_release(mt_entry->mt_point_node, false);
    236237  (*mt_entry->ops->fsunmount_me_h)(mt_entry);
    237238
  • testsuites/fstests/fsnofs01/init.c

    r2ea436a rf08c7133  
    8989  rtems_test_assert(null_loc->reference_count == 5);
    9090
    91   rtems_filesystem_global_location_release(null_loc);
     91  rtems_filesystem_global_location_release(null_loc, false);
    9292
    9393  rtems_test_assert(node_count(loc_chain) == 1);
     
    105105  rtems_test_assert(null_loc->reference_count == 5);
    106106
    107   rtems_filesystem_global_location_release(null_loc);
     107  rtems_filesystem_global_location_release(null_loc, false);
    108108
    109109  rtems_test_assert(node_count(loc_chain) == 1);
Note: See TracChangeset for help on using the changeset viewer.