Changeset 66fac03 in rtems


Ignore:
Timestamp:
Mar 16, 2017, 10:54:29 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
1becaa9
Parents:
191d39a
git-author:
Sebastian Huber <sebastian.huber@…> (03/16/17 10:54:29)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/16/17 14:33:56)
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().

Update #2936.

Files:
8 edited

Legend:

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

    r191d39a r66fac03  
    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

    r191d39a r66fac03  
    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

    r191d39a r66fac03  
    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

    r191d39a r66fac03  
    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

    r191d39a r66fac03  
    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

    r191d39a r66fac03  
    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

    r191d39a r66fac03  
    107107  rtems_filesystem_mt_entry_unlock(lock_context);
    108108
    109   rtems_filesystem_global_location_release(lhs_global_loc);
     109  rtems_filesystem_global_location_release(lhs_global_loc, true);
    110110}
    111111
     
    185185
    186186void rtems_filesystem_global_location_release(
    187   rtems_filesystem_global_location_t *global_loc
    188 )
    189 {
    190   if (_Thread_Dispatch_is_enabled()) {
     187  rtems_filesystem_global_location_t *global_loc,
     188  bool deferred
     189)
     190{
     191  if (!deferred) {
    191192    release_with_count(global_loc, 1);
    192193  } else {
     
    234235  rtems_chain_extract_unprotected(&mt_entry->mt_node);
    235236  rtems_filesystem_mt_unlock();
    236   rtems_filesystem_global_location_release(mt_entry->mt_point_node);
     237  rtems_filesystem_global_location_release(mt_entry->mt_point_node, false);
    237238  (*mt_entry->ops->fsunmount_me_h)(mt_entry);
    238239
  • testsuites/fstests/fsnofs01/init.c

    r191d39a r66fac03  
    7575  rtems_test_assert(!null_mt->mounted);
    7676  rtems_test_assert(!null_mt->writeable);
    77   rtems_test_assert(null_loc->reference_count == 6);
     77  rtems_test_assert(null_loc->reference_count == 4);
    7878  rtems_test_assert(null_loc->deferred_released_next == NULL);
    79   rtems_test_assert(null_loc->deferred_released_count == 2);
     79  rtems_test_assert(null_loc->deferred_released_count == 0);
    8080}
    8181
     
    9191  rtems_test_assert(null_loc->reference_count == 5);
    9292
    93   rtems_filesystem_global_location_release(null_loc);
     93  rtems_filesystem_global_location_release(null_loc, false);
    9494
    9595  rtems_test_assert(node_count(loc_chain) == 1);
     
    107107  rtems_test_assert(null_loc->reference_count == 5);
    108108
    109   rtems_filesystem_global_location_release(null_loc);
     109  rtems_filesystem_global_location_release(null_loc, false);
    110110
    111111  rtems_test_assert(node_count(loc_chain) == 1);
Note: See TracChangeset for help on using the changeset viewer.