Changeset 8aa608df in rtems for cpukit/libblock
- Timestamp:
- 05/18/10 02:14:05 (14 years ago)
- Branches:
- 4.10, 4.11, 5, master
- Children:
- 9020491
- Parents:
- baf64cdb
- Location:
- cpukit/libblock
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libblock/include/rtems/blkdev.h
rbaf64cdb r8aa608df 43 43 /** 44 44 * Block device request type. 45 * 46 * @warning The sync request is an IO one and only used from the cache. Use the 47 * Block IO when operating at the device level. We need a sync request 48 * to avoid requests looping for ever. 45 49 */ 46 50 typedef enum rtems_blkdev_request_op { 47 51 RTEMS_BLKDEV_REQ_READ, /**< Read the requested blocks of data. */ 48 52 RTEMS_BLKDEV_REQ_WRITE, /**< Write the requested blocks of data. */ 49 RTEMS_BLKDEV_ CAPABILITIES /**< Return the driver capabilities set. */53 RTEMS_BLKDEV_REQ_SYNC /**< Sync any data with the media. */ 50 54 } rtems_blkdev_request_op; 51 52 /**53 * Only consecutive multi-sector buffer requests are supported.54 *55 * This option means the cache will only supply multiple buffers that are56 * inorder so the ATA multi-sector command for example can be used. This is a57 * hack to work around the current ATA driver.58 */59 #define RTEMS_BLKDEV_CAP_MULTISECTOR_CONT (1 << 0)60 55 61 56 /** … … 148 143 * The start block in a request. 149 144 * 150 * Only valid if the driver has returned the @ref RTEMS_BLK DEV_CAPABILITIES of145 * Only valid if the driver has returned the @ref RTEMS_BLKIO_CAPABILITIES of 151 146 * @ref RTEMS_BLKDEV_CAP_MULTISECTOR_CONT. 152 147 */ … … 166 161 #define RTEMS_BLKIO_SYNCDEV _IO('B', 6) 167 162 #define RTEMS_BLKIO_DELETED _IO('B', 7) 163 #define RTEMS_BLKIO_CAPABILITIES _IO('B', 8) 168 164 169 165 /** @} */ 166 167 /** 168 * Only consecutive multi-sector buffer requests are supported. 169 * 170 * This option means the cache will only supply multiple buffers that are 171 * inorder so the ATA multi-sector command for example can be used. This is a 172 * hack to work around the current ATA driver. 173 */ 174 #define RTEMS_BLKDEV_CAP_MULTISECTOR_CONT (1 << 0) 175 176 /** 177 * The driver will accept a sync call. A sync call is made to a driver 178 * after a bdbuf cache sync has finished. 179 */ 180 #define RTEMS_BLKDEV_CAP_SYNC (1 << 1) 170 181 171 182 /** -
cpukit/libblock/src/bdbuf.c
rbaf64cdb r8aa608df 61 61 rtems_chain_control bds; /**< The transfer list of BDs. */ 62 62 dev_t dev; /**< The device the transfer is for. */ 63 bool syncing; /**< The data is a sync'ing. */ 63 64 rtems_blkdev_request* write_req; /**< The write request array. */ 64 65 uint32_t bufs_per_bd; /**< Number of buffers per bd. */ … … 75 76 rtems_id id; /**< The id of the task so we can wake 76 77 * it. */ 77 volatile bool enabled; /**< The worke dis enabled. */78 volatile bool enabled; /**< The worker is enabled. */ 78 79 rtems_bdbuf_swapout_transfer transfer; /**< The transfer data for this 79 80 * thread. */ … … 1320 1321 { 1321 1322 rtems_bdbuf_restore_preemption (prev_mode); 1322 1323 1323 return RTEMS_RESOURCE_IN_USE; 1324 1324 } 1325 1325 1326 memset(&bdbuf_cache, 0, sizeof(bdbuf_cache)); 1326 1327 bdbuf_cache.initialised = true; … … 2043 2044 2044 2045 req = bdbuf_alloc (sizeof (rtems_blkdev_request) + 2045 sizeof ( 2046 sizeof (rtems_blkdev_sg_buffer) * 2046 2047 (bdbuf_config.max_read_ahead_blocks + 1)); 2047 2048 … … 2261 2262 * Swapout transfer to the driver. The driver will break this I/O into groups 2262 2263 * of consecutive write requests is multiple consecutive buffers are required 2263 * by the driver. 2264 * by the driver. The cache is not locked. 2264 2265 * 2265 2266 * @param transfer The transfer transaction. … … 2374 2375 2375 2376 if (dd != &null_disk) 2377 { 2378 /* 2379 * If sync'ing and the deivce is capability of handling a sync IO control 2380 * call perform the call. 2381 */ 2382 if (transfer->syncing && 2383 (dd->phys_dev->capabilities & RTEMS_BLKDEV_CAP_SYNC)) 2384 { 2385 /* int result = */ dd->ioctl (dd->phys_dev, RTEMS_BLKDEV_REQ_SYNC, NULL); 2386 /* How should the error be handled ? */ 2387 } 2388 2376 2389 rtems_disk_release (dd); 2390 } 2377 2391 } 2378 2392 } … … 2402 2416 { 2403 2417 rtems_chain_node* node = rtems_chain_head (chain); 2418 bool sync_all; 2419 2404 2420 node = node->next; 2405 2421 2422 /* 2423 * A sync active with no valid dev means sync all. 2424 */ 2425 if (sync_active && (*dev == BDBUF_INVALID_DEV)) 2426 sync_all = true; 2427 else 2428 sync_all = false; 2429 2406 2430 while (!rtems_chain_is_tail (chain, node)) 2407 2431 { … … 2410 2434 /* 2411 2435 * Check if the buffer's hold timer has reached 0. If a sync is active 2412 * or someone waits for a buffer force all the timers to 0.2436 * or someone waits for a buffer written force all the timers to 0. 2413 2437 * 2414 2438 * @note Lots of sync requests will skew this timer. It should be based 2415 2439 * on TOD to be accurate. Does it matter ? 2416 2440 */ 2417 if (sync_active || rtems_bdbuf_has_buffer_waiters ()) 2441 if (sync_all || (sync_active && (*dev == bd->dev)) 2442 || rtems_bdbuf_has_buffer_waiters ()) 2418 2443 bd->hold_timer = 0; 2419 2444 … … 2516 2541 * If a sync is active do not use a worker because the current code does not 2517 2542 * cleaning up after. We need to know the buffers have been written when 2518 * syncing to the release sync lock and currently worker threads do not2519 * return to here. We do not know the worker is the last in a sequence of2520 * sync writes until after we have it running so we do not know to tell it to2521 * release the lock. The simplest solution is to get the main swap out task2522 * perform allsync operations.2543 * syncing to release sync lock and currently worker threads do not return to 2544 * here. We do not know the worker is the last in a sequence of sync writes 2545 * until after we have it running so we do not know to tell it to release the 2546 * lock. The simplest solution is to get the main swap out task perform all 2547 * sync operations. 2523 2548 */ 2524 2549 if (bdbuf_cache.sync_active) … … 2534 2559 rtems_chain_initialize_empty (&transfer->bds); 2535 2560 transfer->dev = BDBUF_INVALID_DEV; 2536 2561 transfer->syncing = bdbuf_cache.sync_active; 2562 2537 2563 /* 2538 2564 * When the sync is for a device limit the sync to that device. If the sync … … 2542 2568 if (bdbuf_cache.sync_active) 2543 2569 transfer->dev = bdbuf_cache.sync_device; 2544 2570 2545 2571 /* 2546 2572 * If we have any buffers in the sync queue move them to the modified … … 2754 2780 rtems_chain_initialize_empty (&transfer.bds); 2755 2781 transfer.dev = BDBUF_INVALID_DEV; 2782 transfer.syncing = false; 2756 2783 2757 2784 /* -
cpukit/libblock/src/diskdevs.c
rbaf64cdb r8aa608df 260 260 dd->driver_data = driver_data; 261 261 262 if ((*handler)(dd, RTEMS_BLK DEV_CAPABILITIES, &dd->capabilities) < 0) {262 if ((*handler)(dd, RTEMS_BLKIO_CAPABILITIES, &dd->capabilities) < 0) { 263 263 dd->capabilities = 0; 264 264 }
Note: See TracChangeset
for help on using the changeset viewer.