[PATCH 12/45] Filesystem: Use lock for deferred release

Sebastian Huber sebastian.huber at embedded-brains.de
Fri May 15 11:41:12 UTC 2015


---
 cpukit/libcsupport/src/sup_fs_location.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/cpukit/libcsupport/src/sup_fs_location.c b/cpukit/libcsupport/src/sup_fs_location.c
index 545dfe1..ddda4d1 100644
--- a/cpukit/libcsupport/src/sup_fs_location.c
+++ b/cpukit/libcsupport/src/sup_fs_location.c
@@ -6,10 +6,10 @@
  */
 
 /*
- * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012-2015 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
- *  Obere Lagerstr. 30
+ *  Dornierstr. 4
  *  82178 Puchheim
  *  Germany
  *  <rtems at embedded-brains.de>
@@ -31,6 +31,12 @@
 rtems_interrupt_lock rtems_filesystem_mt_entry_lock_control =
   RTEMS_INTERRUPT_LOCK_INITIALIZER("mount table entry");
 
+RTEMS_INTERRUPT_LOCK_DEFINE(
+  static,
+  deferred_release_lock,
+  "Filesystem Deferred Release"
+)
+
 static rtems_filesystem_global_location_t *deferred_released_global_locations;
 
 rtems_filesystem_location_info_t *rtems_filesystem_location_copy(
@@ -134,9 +140,10 @@ static void deferred_release(void)
   rtems_filesystem_global_location_t *current = NULL;
 
   do {
+    rtems_interrupt_lock_context lock_context;
     int count = 0;
 
-    _Thread_Disable_dispatch();
+    rtems_interrupt_lock_acquire(&deferred_release_lock, &lock_context);
     current = deferred_released_global_locations;
     if (current != NULL) {
       deferred_released_global_locations = current->deferred_released_next;
@@ -144,7 +151,7 @@ static void deferred_release(void)
       current->deferred_released_next = NULL;
       current->deferred_released_count = 0;
     }
-    _Thread_Enable_dispatch();
+    rtems_interrupt_lock_release(&deferred_release_lock, &lock_context);
 
     if (current != NULL) {
       release_with_count(current, count);
@@ -182,6 +189,10 @@ void rtems_filesystem_global_location_release(
   if (_Thread_Dispatch_is_enabled()) {
     release_with_count(global_loc, 1);
   } else {
+    rtems_interrupt_lock_context lock_context;
+
+    rtems_interrupt_lock_acquire(&deferred_release_lock, &lock_context);
+
     if (global_loc->deferred_released_count == 0) {
       rtems_filesystem_global_location_t *head =
         deferred_released_global_locations;
@@ -192,6 +203,8 @@ void rtems_filesystem_global_location_release(
     } else {
       ++global_loc->deferred_released_count;
     }
+
+    rtems_interrupt_lock_release(&deferred_release_lock, &lock_context);
   }
 }
 
-- 
1.8.4.5



More information about the devel mailing list