RTEMS  5.0.0
bdbuf.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
10  * Author: Victor V. Vengerov <vvv@oktet.ru>
11  *
12  * Copyright (C) 2008,2009 Chris Johns <chrisj@rtems.org>
13  * Rewritten to remove score mutex access. Fixes many performance
14  * issues.
15  * Change to support demand driven variable buffer sizes.
16  *
17  * Copyright (c) 2009-2012 embedded brains GmbH.
18  */
19 
20 #ifndef _RTEMS_BDBUF_H
21 #define _RTEMS_BDBUF_H
22 
23 #include <rtems.h>
24 #include <rtems/libio.h>
25 #include <rtems/chain.h>
26 
27 #include <rtems/blkdev.h>
28 #include <rtems/diskdevs.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
235 typedef enum
236 {
241 
246 
251 
256 
261 
266 
271 
276 
281 
286 
292 
296 struct rtems_bdbuf_group;
297 typedef struct rtems_bdbuf_group rtems_bdbuf_group;
298 
305 typedef struct rtems_bdbuf_buffer
306 {
310  {
313  signed char cache;
314  signed char bal;
315  } avl;
316 
321  unsigned char* buffer;
323  rtems_bdbuf_buf_state state;
325  uint32_t waiters;
329  uint32_t hold_timer;
333  void* user;
335 
344 {
347  size_t bds_per_group;
350  uint32_t users;
352 };
353 
358 typedef struct rtems_bdbuf_config {
361  uint32_t max_write_blocks;
365  uint32_t swapout_period;
367  uint32_t swap_block_hold;
375  size_t size;
377  uint32_t buffer_min;
378  uint32_t buffer_max;
384 
391 
396 #define RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT 0
397 
401 #define RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT 16
402 
406 #define RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT 15
407 
411 #define RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT 250
412 
416 #define RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT 1000
417 
421 #define RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT 0
422 
426 #define RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT \
427  RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT
428 
432 #define RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT \
433  RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT
434 
438 #define RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT RTEMS_MINIMUM_STACK_SIZE
439 
443 #define RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT (64 * 512)
444 
448 #define RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT (512)
449 
453 #define RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT (4096)
454 
468 rtems_bdbuf_init (void);
469 
502  rtems_bdbuf_buffer** bd
503 );
504 
536  rtems_bdbuf_buffer** bd
537 );
538 
560 
584 
607 
627 
639 void
641 
668  uint32_t block_size,
669  bool sync);
670 
674 void
676  rtems_blkdev_stats *stats);
677 
681 void
683 
686 #ifdef __cplusplus
687 }
688 #endif
689 
690 #endif
void rtems_bdbuf_purge_dev(rtems_disk_device *dd)
Purges all buffers corresponding to the disk device dd.
Definition: bdbuf.c:2861
Definition: chain.h:65
void * user
Definition: bdbuf.h:333
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
rtems_bdbuf_group * group
Definition: bdbuf.h:327
Accessed by upper layer with modified data.
Definition: bdbuf.h:260
Basic IO API.
rtems_task_priority swapout_priority
Definition: bdbuf.h:363
void rtems_bdbuf_get_device_stats(const rtems_disk_device *dd, rtems_blkdev_stats *stats)
Returns the block device statistics.
Definition: bdbuf.c:2985
int references
Definition: bdbuf.h:332
uint32_t waiters
Definition: bdbuf.h:325
Definition: bdbuf.h:343
rtems_status_code rtems_bdbuf_syncdev(rtems_disk_device *dd)
Definition: bdbuf.c:2229
signed char cache
Definition: bdbuf.h:313
In transfer by block device driver and purged.
Definition: bdbuf.h:290
size_t swapout_workers
Definition: bdbuf.h:368
struct rtems_bdbuf_buffer * left
Definition: bdbuf.h:311
void sync(void)
Definition: sync.c:85
Scheduled for synchronization.
Definition: bdbuf.h:280
Empty.
Definition: bdbuf.h:245
void rtems_bdbuf_reset_device_stats(rtems_disk_device *dd)
Resets the block device statistics.
Definition: bdbuf.c:2993
size_t size
Definition: bdbuf.h:375
rtems_task_priority swapout_worker_priority
Definition: bdbuf.h:371
size_t task_stack_size
Definition: bdbuf.h:373
rtems_status_code rtems_bdbuf_init(void)
Definition: bdbuf.c:1509
Definition: bdbuf.h:358
uint32_t max_write_blocks
Definition: bdbuf.h:361
unsigned char * buffer
Definition: bdbuf.h:321
Cached.
Definition: bdbuf.h:250
signed char bal
Definition: bdbuf.h:314
rtems_status_code rtems_bdbuf_read(rtems_disk_device *dd, rtems_blkdev_bnum block, rtems_bdbuf_buffer **bd)
Definition: bdbuf.c:2057
size_t bds_per_group
Definition: bdbuf.h:347
Block device statistics.
Definition: diskdevs.h:92
struct rtems_bdbuf_buffer rtems_bdbuf_buffer
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:157
uint32_t max_read_ahead_blocks
Definition: bdbuf.h:359
uint32_t swap_block_hold
Definition: bdbuf.h:367
Modified by upper layer.
Definition: bdbuf.h:275
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_task_priority read_ahead_priority
Definition: bdbuf.h:381
rtems_status_code rtems_bdbuf_set_block_size(rtems_disk_device *dd, uint32_t block_size, bool sync)
Sets the block size of a disk device.
Definition: bdbuf.c:2869
uint32_t hold_timer
Definition: bdbuf.h:329
rtems_bdbuf_buffer * bdbuf
Definition: bdbuf.h:351
rtems_disk_device * dd
Definition: bdbuf.h:317
Block Device Disk Management API.
rtems_status_code rtems_bdbuf_release(rtems_bdbuf_buffer *bd)
Definition: bdbuf.c:2131
rtems_chain_node link
Definition: bdbuf.h:345
Definition: bdbuf.h:305
struct rtems_bdbuf_buffer * right
Definition: bdbuf.h:312
Chain API.
rtems_status_code rtems_bdbuf_get(rtems_disk_device *dd, rtems_blkdev_bnum block, rtems_bdbuf_buffer **bd)
Definition: bdbuf.c:1789
const rtems_bdbuf_config rtems_bdbuf_configuration
Accessed by upper layer with cached data.
Definition: bdbuf.h:255
rtems_bdbuf_buf_state
State of a buffer of the cache.
Definition: bdbuf.h:235
uint32_t buffer_max
Definition: bdbuf.h:378
rtems_bdbuf_buf_state state
Definition: bdbuf.h:323
Free.
Definition: bdbuf.h:240
rtems_status_code rtems_bdbuf_sync(rtems_bdbuf_buffer *bd)
Definition: bdbuf.c:2197
Accessed by upper layer with purged data.
Definition: bdbuf.h:270
struct rtems_bdbuf_config rtems_bdbuf_config
rtems_blkdev_bnum block
Definition: bdbuf.h:319
uint32_t users
Definition: bdbuf.h:350
uint32_t buffer_min
Definition: bdbuf.h:377
rtems_status_code rtems_bdbuf_release_modified(rtems_bdbuf_buffer *bd)
Definition: bdbuf.c:2165
rtems_chain_node link
Definition: bdbuf.h:307
Block Device Management.
Accessed by upper layer with invalid data.
Definition: bdbuf.h:265
In transfer by block device driver.
Definition: bdbuf.h:285
uint32_t swapout_period
Definition: bdbuf.h:365
uint32_t rtems_task_priority
Definition: tasks.h:54