Index: cpukit/libblock/include/rtems/bdbuf.h
===================================================================
--- cpukit/libblock/include/rtems/bdbuf.h	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ cpukit/libblock/include/rtems/bdbuf.h	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -364,12 +364,14 @@
   rtems_task_priority swapout_priority;        /**< Priority of the swap out
                                                 * task. */
-  uint32_t            swapout_period;          /**< Period swapout checks buf
+  uint32_t            swapout_period;          /**< Period swap-out checks buf
                                                 * timers. */
   uint32_t            swap_block_hold;         /**< Period a buffer is held. */
   size_t              swapout_workers;         /**< The number of worker
-                                                * threads for the swapout
+                                                * threads for the swap-out
                                                 * task. */
   rtems_task_priority swapout_worker_priority; /**< Priority of the swap out
                                                 * task. */
+  size_t              task_stack_size;         /**< Task stack size for swap-out
+                                                * task and worker threads. */
   size_t              size;                    /**< Size of memory in the
                                                 * cache */
@@ -419,8 +421,13 @@
 
 /**
- * Default swap-out worker task priority. The same as the swapout task.
+ * Default swap-out worker task priority. The same as the swap-out task.
  */
 #define RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT \
                              RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT
+
+/**
+ * Default task stack size for swap-out and worker tasks.
+ */
+#define RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT RTEMS_MINIMUM_STACK_SIZE
 
 /**
Index: cpukit/libblock/src/bdbuf.c
===================================================================
--- cpukit/libblock/src/bdbuf.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ cpukit/libblock/src/bdbuf.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -174,5 +174,4 @@
 #define RTEMS_BLKDEV_FATAL_BDBUF_SO_NOMEM      RTEMS_BLKDEV_FATAL_ERROR(21)
 #define RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_CREATE  RTEMS_BLKDEV_FATAL_ERROR(22)
-#define RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_START   RTEMS_BLKDEV_FATAL_ERROR(23)
 #define BLKDEV_FATAL_BDBUF_SWAPOUT_RE          RTEMS_BLKDEV_FATAL_ERROR(24)
 #define BLKDEV_FATAL_BDBUF_SWAPOUT_TS          RTEMS_BLKDEV_FATAL_ERROR(25)
@@ -189,10 +188,4 @@
 #define RTEMS_BDBUF_TRANSFER_SYNC  RTEMS_EVENT_1
 #define RTEMS_BDBUF_SWAPOUT_SYNC   RTEMS_EVENT_2
-
-/**
- * The swap out task size. Should be more than enough for most drivers with
- * tracing turned on.
- */
-#define SWAPOUT_TASK_STACK_SIZE (8 * 1024)
 
 /**
@@ -1288,4 +1281,33 @@
 }
 
+static rtems_status_code
+rtems_bdbuf_create_task(
+  rtems_name name,
+  rtems_task_priority priority,
+  rtems_task_priority default_priority,
+  rtems_task_entry entry,
+  rtems_task_argument arg,
+  rtems_id *id
+)
+{
+  rtems_status_code sc;
+  size_t stack_size = bdbuf_config.task_stack_size ?
+    bdbuf_config.task_stack_size : RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT;
+
+  priority = priority != 0 ? priority : default_priority;
+
+  sc = rtems_task_create (name,
+                          priority,
+                          stack_size,
+                          RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR,
+                          RTEMS_LOCAL | RTEMS_NO_FLOATING_POINT,
+                          id);
+
+  if (sc == RTEMS_SUCCESSFUL)
+    sc = rtems_task_start (*id, entry, arg);
+
+  return sc;
+}
+
 /**
  * Initialise the cache.
@@ -1457,18 +1479,10 @@
   bdbuf_cache.swapout_enabled = true;
 
-  sc = rtems_task_create (rtems_build_name('B', 'S', 'W', 'P'),
-                          bdbuf_config.swapout_priority ?
-                            bdbuf_config.swapout_priority :
-                            RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT,
-                          SWAPOUT_TASK_STACK_SIZE,
-                          RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR,
-                          RTEMS_LOCAL | RTEMS_NO_FLOATING_POINT,
-                          &bdbuf_cache.swapout);
-  if (sc != RTEMS_SUCCESSFUL)
-    goto error;
-
-  sc = rtems_task_start (bdbuf_cache.swapout,
-                         rtems_bdbuf_swapout_task,
-                         (rtems_task_argument) &bdbuf_cache);
+  sc = rtems_bdbuf_create_task (rtems_build_name('B', 'S', 'W', 'P'),
+                                bdbuf_config.swapout_priority,
+                                RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT,
+                                rtems_bdbuf_swapout_task,
+                                0,
+                                &bdbuf_cache.swapout);
   if (sc != RTEMS_SUCCESSFUL)
     goto error;
@@ -2640,20 +2654,12 @@
     worker->transfer.dd = BDBUF_INVALID_DEV;
 
-    sc = rtems_task_create (rtems_build_name('B', 'D', 'o', 'a' + w),
-                            (bdbuf_config.swapout_priority ?
-                             bdbuf_config.swapout_priority :
-                             RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT),
-                            SWAPOUT_TASK_STACK_SIZE,
-                            RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR,
-                            RTEMS_LOCAL | RTEMS_NO_FLOATING_POINT,
-                            &worker->id);
+    sc = rtems_bdbuf_create_task (rtems_build_name('B', 'D', 'o', 'a' + w),
+                                  bdbuf_config.swapout_worker_priority,
+                                  RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT,
+                                  rtems_bdbuf_swapout_worker_task,
+                                  (rtems_task_argument) worker,
+                                  &worker->id);
     if (sc != RTEMS_SUCCESSFUL)
       rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_CREATE);
-
-    sc = rtems_task_start (worker->id,
-                           rtems_bdbuf_swapout_worker_task,
-                           (rtems_task_argument) worker);
-    if (sc != RTEMS_SUCCESSFUL)
-      rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_START);
   }
 
Index: cpukit/sapi/include/confdefs.h
===================================================================
--- cpukit/sapi/include/confdefs.h	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ cpukit/sapi/include/confdefs.h	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -1226,4 +1226,8 @@
                               RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT
   #endif
+  #ifndef CONFIGURE_BDBUF_TASK_STACK_SIZE
+    #define CONFIGURE_BDBUF_TASK_STACK_SIZE \
+                              RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT
+  #endif
   #ifndef CONFIGURE_BDBUF_CACHE_MEMORY_SIZE
     #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE \
@@ -1247,4 +1251,5 @@
       CONFIGURE_SWAPOUT_WORKER_TASKS,
       CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY,
+      CONFIGURE_BDBUF_TASK_STACK_SIZE,
       CONFIGURE_BDBUF_CACHE_MEMORY_SIZE,
       CONFIGURE_BDBUF_BUFFER_MIN_SIZE,
@@ -1252,4 +1257,11 @@
     };
   #endif
+
+  #define CONFIGURE_LIBBLOCK_TASKS (1 + CONFIGURE_SWAPOUT_WORKER_TASKS)
+
+  #define CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS \
+    (CONFIGURE_LIBBLOCK_TASKS * \
+    (CONFIGURE_BDBUF_TASK_STACK_SIZE <= CONFIGURE_MINIMUM_TASK_STACK_SIZE ? \
+    0 : CONFIGURE_BDBUF_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE))
 
   /*
@@ -1270,4 +1282,6 @@
   #endif
 #else
+  #define CONFIGURE_LIBBLOCK_TASKS 0
+  #define CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS 0
   #define CONFIGURE_LIBBLOCK_SEMAPHORES 0
 #endif /* CONFIGURE_APPLICATION_NEEDS_LIBBLOCK */
@@ -1456,4 +1470,7 @@
     #define CONFIGURE_MAXIMUM_TASKS               0
   #endif
+
+  #define CONFIGURE_TASKS \
+    (CONFIGURE_MAXIMUM_TASKS + CONFIGURE_LIBBLOCK_TASKS)
 
   #ifndef CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS
@@ -2074,5 +2091,5 @@
  */
 #define CONFIGURE_TOTAL_TASKS_AND_THREADS \
-   (CONFIGURE_MAXIMUM_TASKS + \
+   (CONFIGURE_TASKS + \
     CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_ADA_TASKS + \
     CONFIGURE_MAXIMUM_GOROUTINES)
@@ -2177,5 +2194,5 @@
 
 #define CONFIGURE_TASKS_STACK \
-  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_TASKS ) * \
+  (_Configure_Max_Objects( CONFIGURE_TASKS ) * \
     _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) )
 
@@ -2220,4 +2237,5 @@
     CONFIGURE_ADA_TASKS_STACK + \
     CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK + \
+    CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS + \
     CONFIGURE_EXTRA_TASK_STACKS \
   )
@@ -2228,5 +2246,5 @@
    */
   rtems_api_configuration_table Configuration_RTEMS_API = {
-    CONFIGURE_MAXIMUM_TASKS,
+    CONFIGURE_TASKS,
     CONFIGURE_NOTEPADS_ENABLED,
     CONFIGURE_MAXIMUM_TIMERS + CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER,
Index: testsuites/libtests/block01/init.c
===================================================================
--- testsuites/libtests/block01/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block01/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -254,7 +254,6 @@
 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
 
-#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_TASKS 1
 #define CONFIGURE_MAXIMUM_DRIVERS 2
-#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
Index: testsuites/libtests/block02/init.c
===================================================================
--- testsuites/libtests/block02/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block02/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -200,5 +200,5 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 5
+#define CONFIGURE_MAXIMUM_TASKS 3
 #define CONFIGURE_MAXIMUM_DRIVERS 3
 
Index: testsuites/libtests/block03/init.c
===================================================================
--- testsuites/libtests/block03/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block03/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -187,5 +187,5 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 5
+#define CONFIGURE_MAXIMUM_TASKS 3
 #define CONFIGURE_MAXIMUM_DRIVERS 2
 
Index: testsuites/libtests/block04/init.c
===================================================================
--- testsuites/libtests/block04/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block04/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -159,5 +159,5 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 5
+#define CONFIGURE_MAXIMUM_TASKS 3
 #define CONFIGURE_MAXIMUM_DRIVERS 2
 
Index: testsuites/libtests/block05/init.c
===================================================================
--- testsuites/libtests/block05/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block05/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -517,5 +517,5 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 6
+#define CONFIGURE_MAXIMUM_TASKS 4
 #define CONFIGURE_MAXIMUM_DRIVERS 4
 
Index: testsuites/libtests/block06/init.c
===================================================================
--- testsuites/libtests/block06/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block06/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -113,4 +113,6 @@
 
 #define BDBUF_TEST_TASKS (3)
+
+#define BDBUF_TEST_STACK_SIZE (2 * RTEMS_MINIMUM_STACK_SIZE)
 
 /**
@@ -650,5 +652,5 @@
                                             tc->name[2], tc->name[3]),
                           priority,
-                          8 * 1024,
+                          BDBUF_TEST_STACK_SIZE,
                           RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
                           RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR,
@@ -1843,10 +1845,12 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 8
+#define CONFIGURE_MAXIMUM_TASKS (1 + BDBUF_TEST_TASKS)
 #define CONFIGURE_MAXIMUM_DRIVERS 3
 #define CONFIGURE_MAXIMUM_SEMAPHORES 2
 
-#define CONFIGURE_INIT_TASK_STACK_SIZE (2 * RTEMS_MINIMUM_STACK_SIZE)
-
+#define CONFIGURE_EXTRA_TASK_STACKS \
+  (BDBUF_TEST_TASKS * BDBUF_TEST_STACK_SIZE)
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE BDBUF_TEST_STACK_SIZE
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
Index: testsuites/libtests/block07/init.c
===================================================================
--- testsuites/libtests/block07/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block07/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -263,5 +263,5 @@
 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
 
-#define CONFIGURE_MAXIMUM_TASKS 6
+#define CONFIGURE_MAXIMUM_TASKS 4
 #define CONFIGURE_MAXIMUM_DRIVERS 2
 
Index: testsuites/libtests/block09/init.c
===================================================================
--- testsuites/libtests/block09/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block09/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -229,5 +229,5 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 3
+#define CONFIGURE_MAXIMUM_TASKS 1
 #define CONFIGURE_MAXIMUM_DRIVERS 4
 
Index: testsuites/libtests/block10/init.c
===================================================================
--- testsuites/libtests/block10/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block10/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -474,5 +474,5 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 5
+#define CONFIGURE_MAXIMUM_TASKS 3
 #define CONFIGURE_MAXIMUM_DRIVERS 4
 
Index: testsuites/libtests/block11/init.c
===================================================================
--- testsuites/libtests/block11/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block11/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -397,7 +397,6 @@
 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
 
-#define CONFIGURE_MAXIMUM_TASKS 2
+#define CONFIGURE_MAXIMUM_TASKS 1
 #define CONFIGURE_MAXIMUM_DRIVERS 2
-#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
Index: testsuites/libtests/block12/init.c
===================================================================
--- testsuites/libtests/block12/init.c	(revision bb08c0c8fb6615d3fb062799a9d3bb38818f07f6)
+++ testsuites/libtests/block12/init.c	(revision b6911069d42381b89505803e2c699b4271c25e96)
@@ -143,7 +143,5 @@
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
 
-#define CONFIGURE_MAXIMUM_TASKS 2
-
-#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
+#define CONFIGURE_MAXIMUM_TASKS 1
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
