bdbuf
1# This file was automatically generated by SWIG (https://www.swig.org). 2# Version 4.2.1 3# 4# Do not make changes to this file unless you know what you are doing - modify 5# the SWIG interface file instead. 6 7from sys import version_info as _swig_python_version_info 8from mock_rtems import _bdbuf as _bdbuf 9 10try: 11 import builtins as __builtin__ 12except ImportError: 13 import __builtin__ 14 15def _swig_repr(self): 16 try: 17 strthis = "proxy of " + self.this.__repr__() 18 except __builtin__.Exception: 19 strthis = "" 20 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) 21 22 23def _swig_setattr_nondynamic_instance_variable(set): 24 def set_instance_attr(self, name, value): 25 if name == "this": 26 set(self, name, value) 27 elif name == "thisown": 28 self.this.own(value) 29 elif hasattr(self, name) and isinstance(getattr(type(self), name), property): 30 set(self, name, value) 31 else: 32 raise AttributeError("You cannot add instance attributes to %s" % self) 33 return set_instance_attr 34 35 36def _swig_setattr_nondynamic_class_variable(set): 37 def set_class_attr(cls, name, value): 38 if hasattr(cls, name) and not isinstance(getattr(cls, name), property): 39 set(cls, name, value) 40 else: 41 raise AttributeError("You cannot add class attributes to %s" % cls) 42 return set_class_attr 43 44 45def _swig_add_metaclass(metaclass): 46 """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" 47 def wrapper(cls): 48 return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) 49 return wrapper 50 51 52class _SwigNonDynamicMeta(type): 53 """Meta class to enforce nondynamic attributes (no new attributes) for a class""" 54 __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) 55 56 57RTEMS_BDBUF_STATE_FREE = _bdbuf.RTEMS_BDBUF_STATE_FREE 58r"""Free.""" 59RTEMS_BDBUF_STATE_EMPTY = _bdbuf.RTEMS_BDBUF_STATE_EMPTY 60r"""Empty.""" 61RTEMS_BDBUF_STATE_CACHED = _bdbuf.RTEMS_BDBUF_STATE_CACHED 62r"""Cached.""" 63RTEMS_BDBUF_STATE_ACCESS_CACHED = _bdbuf.RTEMS_BDBUF_STATE_ACCESS_CACHED 64r"""Accessed by upper layer with cached data.""" 65RTEMS_BDBUF_STATE_ACCESS_MODIFIED = _bdbuf.RTEMS_BDBUF_STATE_ACCESS_MODIFIED 66r"""Accessed by upper layer with modified data.""" 67RTEMS_BDBUF_STATE_ACCESS_EMPTY = _bdbuf.RTEMS_BDBUF_STATE_ACCESS_EMPTY 68r"""Accessed by upper layer with invalid data.""" 69RTEMS_BDBUF_STATE_ACCESS_PURGED = _bdbuf.RTEMS_BDBUF_STATE_ACCESS_PURGED 70r"""Accessed by upper layer with purged data.""" 71RTEMS_BDBUF_STATE_MODIFIED = _bdbuf.RTEMS_BDBUF_STATE_MODIFIED 72r"""Modified by upper layer.""" 73RTEMS_BDBUF_STATE_SYNC = _bdbuf.RTEMS_BDBUF_STATE_SYNC 74r"""Scheduled for synchronization.""" 75RTEMS_BDBUF_STATE_TRANSFER = _bdbuf.RTEMS_BDBUF_STATE_TRANSFER 76r"""In transfer by block device driver.""" 77RTEMS_BDBUF_STATE_TRANSFER_PURGED = _bdbuf.RTEMS_BDBUF_STATE_TRANSFER_PURGED 78r"""In transfer by block device driver and purged.""" 79class rtems_bdbuf_buffer(object): 80 r""" 81 To manage buffers we using buffer descriptors (BD). A BD holds a buffer plus 82 a range of other information related to managing the buffer in the cache. To 83 speed-up buffer lookup descriptors are organized in AVL-Tree. The fields 84 'dd' and 'block' are search keys. 85 """ 86 87 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 88 __repr__ = _swig_repr 89 avl = property(_bdbuf.rtems_bdbuf_buffer_avl_get, _bdbuf.rtems_bdbuf_buffer_avl_set, doc=r"""avl : struct rtems_bdbuf_avl_node""") 90 link = property(_bdbuf.rtems_bdbuf_buffer_link_get, _bdbuf.rtems_bdbuf_buffer_link_set, doc=r""" Link the BD onto a number of lists.""") 91 dd = property(_bdbuf.rtems_bdbuf_buffer_dd_get, _bdbuf.rtems_bdbuf_buffer_dd_set, doc=r""" disk device""") 92 block = property(_bdbuf.rtems_bdbuf_buffer_block_get, _bdbuf.rtems_bdbuf_buffer_block_set, doc=r""" block number on the device""") 93 buffer = property(_bdbuf.rtems_bdbuf_buffer_buffer_get, _bdbuf.rtems_bdbuf_buffer_buffer_set, doc=r""" Pointer to the buffer memory area""") 94 state = property(_bdbuf.rtems_bdbuf_buffer_state_get, _bdbuf.rtems_bdbuf_buffer_state_set, doc=r""" State of the buffer.""") 95 waiters = property(_bdbuf.rtems_bdbuf_buffer_waiters_get, _bdbuf.rtems_bdbuf_buffer_waiters_set, doc=r""" 96 The number of threads waiting on this 97 buffer. 98 """) 99 group = property(_bdbuf.rtems_bdbuf_buffer_group_get, _bdbuf.rtems_bdbuf_buffer_group_set, doc=r""" 100 Pointer to the group of BDs this BD is 101 part of. 102 """) 103 hold_timer = property(_bdbuf.rtems_bdbuf_buffer_hold_timer_get, _bdbuf.rtems_bdbuf_buffer_hold_timer_set, doc=r""" 104 Timer to indicate how long a buffer 105 has been held in the cache modified. 106 """) 107 references = property(_bdbuf.rtems_bdbuf_buffer_references_get, _bdbuf.rtems_bdbuf_buffer_references_set, doc=r""" Allow reference counting by owner.""") 108 user = property(_bdbuf.rtems_bdbuf_buffer_user_get, _bdbuf.rtems_bdbuf_buffer_user_set, doc=r""" User data.""") 109 110 def __init__(self): 111 r"""__init__(rtems_bdbuf_buffer self) -> rtems_bdbuf_buffer""" 112 _bdbuf.rtems_bdbuf_buffer_swiginit(self, _bdbuf.new_rtems_bdbuf_buffer()) 113 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_buffer 114 115# Register rtems_bdbuf_buffer in _bdbuf: 116_bdbuf.rtems_bdbuf_buffer_swigregister(rtems_bdbuf_buffer) 117class rtems_bdbuf_avl_node(object): 118 r"""Proxy of C rtems_bdbuf_avl_node struct.""" 119 120 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 121 __repr__ = _swig_repr 122 left = property(_bdbuf.rtems_bdbuf_avl_node_left_get, _bdbuf.rtems_bdbuf_avl_node_left_set, doc=r""" Left Child""") 123 right = property(_bdbuf.rtems_bdbuf_avl_node_right_get, _bdbuf.rtems_bdbuf_avl_node_right_set, doc=r""" Right Child""") 124 cache = property(_bdbuf.rtems_bdbuf_avl_node_cache_get, _bdbuf.rtems_bdbuf_avl_node_cache_set, doc=r""" Cache""") 125 bal = property(_bdbuf.rtems_bdbuf_avl_node_bal_get, _bdbuf.rtems_bdbuf_avl_node_bal_set, doc=r""" The balance of the sub-tree""") 126 127 def __init__(self): 128 r"""__init__(rtems_bdbuf_avl_node self) -> rtems_bdbuf_avl_node""" 129 _bdbuf.rtems_bdbuf_avl_node_swiginit(self, _bdbuf.new_rtems_bdbuf_avl_node()) 130 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_avl_node 131 132# Register rtems_bdbuf_avl_node in _bdbuf: 133_bdbuf.rtems_bdbuf_avl_node_swigregister(rtems_bdbuf_avl_node) 134class rtems_bdbuf_group(object): 135 r""" 136 A group is a continuous block of buffer descriptors. A group covers the 137 maximum configured buffer size and is the allocation size for the buffers to 138 a specific buffer size. If you allocate a buffer to be a specific size, all 139 buffers in the group, if there are more than 1 will also be that size. The 140 number of buffers in a group is a multiple of 2, ie 1, 2, 4, 8, etc. 141 """ 142 143 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 144 __repr__ = _swig_repr 145 link = property(_bdbuf.rtems_bdbuf_group_link_get, _bdbuf.rtems_bdbuf_group_link_set, doc=r""" 146 Link the groups on a LRU list if they 147 have no buffers in use. 148 """) 149 bds_per_group = property(_bdbuf.rtems_bdbuf_group_bds_per_group_get, _bdbuf.rtems_bdbuf_group_bds_per_group_set, doc=r""" 150 The number of BD allocated to this 151 group. This value must be a multiple of 152 2. 153 """) 154 users = property(_bdbuf.rtems_bdbuf_group_users_get, _bdbuf.rtems_bdbuf_group_users_set, doc=r""" How many users the block has.""") 155 bdbuf = property(_bdbuf.rtems_bdbuf_group_bdbuf_get, _bdbuf.rtems_bdbuf_group_bdbuf_set, doc=r""" First BD this block covers.""") 156 157 def __init__(self): 158 r"""__init__(rtems_bdbuf_group self) -> rtems_bdbuf_group""" 159 _bdbuf.rtems_bdbuf_group_swiginit(self, _bdbuf.new_rtems_bdbuf_group()) 160 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_group 161 162# Register rtems_bdbuf_group in _bdbuf: 163_bdbuf.rtems_bdbuf_group_swigregister(rtems_bdbuf_group) 164class rtems_bdbuf_config(object): 165 r""" 166 Buffering configuration definition. See confdefs.h for support on using this 167 structure. 168 """ 169 170 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 171 __repr__ = _swig_repr 172 max_read_ahead_blocks = property(_bdbuf.rtems_bdbuf_config_max_read_ahead_blocks_get, _bdbuf.rtems_bdbuf_config_max_read_ahead_blocks_set, doc=r""" 173 Number of blocks to read 174 ahead. 175 """) 176 max_write_blocks = property(_bdbuf.rtems_bdbuf_config_max_write_blocks_get, _bdbuf.rtems_bdbuf_config_max_write_blocks_set, doc=r""" 177 Number of blocks to write 178 at once. 179 """) 180 swapout_priority = property(_bdbuf.rtems_bdbuf_config_swapout_priority_get, _bdbuf.rtems_bdbuf_config_swapout_priority_set, doc=r""" 181 Priority of the swap out 182 task. 183 """) 184 swapout_period = property(_bdbuf.rtems_bdbuf_config_swapout_period_get, _bdbuf.rtems_bdbuf_config_swapout_period_set, doc=r""" 185 Period swap-out checks buf 186 timers. 187 """) 188 swap_block_hold = property(_bdbuf.rtems_bdbuf_config_swap_block_hold_get, _bdbuf.rtems_bdbuf_config_swap_block_hold_set, doc=r""" Period a buffer is held.""") 189 swapout_workers = property(_bdbuf.rtems_bdbuf_config_swapout_workers_get, _bdbuf.rtems_bdbuf_config_swapout_workers_set, doc=r""" 190 The number of worker 191 threads for the swap-out 192 task. 193 """) 194 swapout_worker_priority = property(_bdbuf.rtems_bdbuf_config_swapout_worker_priority_get, _bdbuf.rtems_bdbuf_config_swapout_worker_priority_set, doc=r""" 195 Priority of the swap out 196 task. 197 """) 198 task_stack_size = property(_bdbuf.rtems_bdbuf_config_task_stack_size_get, _bdbuf.rtems_bdbuf_config_task_stack_size_set, doc=r""" 199 Task stack size for swap-out 200 task and worker threads. 201 """) 202 size = property(_bdbuf.rtems_bdbuf_config_size_get, _bdbuf.rtems_bdbuf_config_size_set, doc=r""" 203 Size of memory in the 204 cache 205 """) 206 buffer_min = property(_bdbuf.rtems_bdbuf_config_buffer_min_get, _bdbuf.rtems_bdbuf_config_buffer_min_set, doc=r""" Minimum buffer size.""") 207 buffer_max = property(_bdbuf.rtems_bdbuf_config_buffer_max_get, _bdbuf.rtems_bdbuf_config_buffer_max_set, doc=r""" 208 Maximum buffer size 209 supported. It is also the 210 allocation size. 211 """) 212 read_ahead_priority = property(_bdbuf.rtems_bdbuf_config_read_ahead_priority_get, _bdbuf.rtems_bdbuf_config_read_ahead_priority_set, doc=r""" 213 Priority of the read-ahead 214 task. 215 """) 216 217 def __init__(self): 218 r"""__init__(rtems_bdbuf_config self) -> rtems_bdbuf_config""" 219 _bdbuf.rtems_bdbuf_config_swiginit(self, _bdbuf.new_rtems_bdbuf_config()) 220 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_config 221 222# Register rtems_bdbuf_config in _bdbuf: 223_bdbuf.rtems_bdbuf_config_swigregister(rtems_bdbuf_config) 224RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT = _bdbuf.RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT 225r""" 226 The default value for the maximum read-ahead blocks disables the read-ahead 227 feature. 228 """ 229RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT = _bdbuf.RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT 230r"""Default maximum number of blocks to write at once.""" 231RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT = _bdbuf.RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT 232r"""Default swap-out task priority.""" 233RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT = _bdbuf.RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT 234r"""Default swap-out task swap period in milli seconds.""" 235RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT = _bdbuf.RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT 236r"""Default swap-out task block hold time in milli seconds.""" 237RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT = _bdbuf.RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT 238r"""Default swap-out worker tasks. Currently disabled.""" 239RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT = _bdbuf.RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT 240r"""Default swap-out worker task priority. The same as the swap-out task.""" 241RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT = _bdbuf.RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT 242r"""Default read-ahead task priority. The same as the swap-out task.""" 243RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT = _bdbuf.RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT 244r""" 245 Default task stack size for swap-out and worker tasks. 246 247 Default size of memory allocated to the cache. 248 """ 249RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT = _bdbuf.RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT 250r"""Default minimum size of buffers.""" 251RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT = _bdbuf.RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT 252r"""Default maximum size of buffers.""" 253 254def rtems_bdbuf_init(): 255 r""" 256 Prepare buffering layer to work - initialize buffer descritors and (if it is 257 neccessary) buffers. After initialization all blocks is placed into the 258 ready state. 259 """ 260 return _bdbuf.rtems_bdbuf_init() 261 262def rtems_bdbuf_get(dd, block, bd): 263 r""" 264 Get block buffer for data to be written into. The buffers is set to the 265 access or modified access state. If the buffer is in the cache and modified 266 the state is access modified else the state is access. This buffer contents 267 are not initialised if the buffer is not already in the cache. If the block 268 is already resident in memory it is returned how-ever if not in memory the 269 buffer is not read from disk. This call is used when writing the whole block 270 on a disk rather than just changing a part of it. If there is no buffers 271 available this call will block. A buffer obtained with this call will not be 272 involved in a transfer request and will not be returned to another user 273 until released. If the buffer is already with a user when this call is made 274 the call is blocked until the buffer is returned. The highest priority 275 waiter will obtain the buffer first. 276 277 The block number is the linear block number. This is relative to the start 278 of the partition on the media. 279 280 Before you can use this function, the rtems_bdbuf_init() routine must be 281 called at least once to initialize the cache, otherwise a fatal error will 282 occur. 283 284 :type dd: rtems_disk_device 285 :param dd: [in] The disk device. 286 :type block: rtems_blkdev_bnum 287 :param block: [in] Linear media block number. 288 :type bd: :py:class:`rtems_bdbuf_buffer` 289 :param bd: [out] Reference to the buffer descriptor pointer. 290 """ 291 return _bdbuf.rtems_bdbuf_get(dd, block, bd) 292 293def rtems_bdbuf_read(dd, block, bd): 294 r""" 295 Get the block buffer and if not already in the cache read from the disk. If 296 specified block already cached return. The buffer is set to the access or 297 modified access state. If the buffer is in the cache and modified the state 298 is access modified else the state is access. If block is already being read 299 from disk for being written to disk this call blocks. If the buffer is 300 waiting to be written it is removed from modified queue and returned to the 301 user. If the buffer is not in the cache a new buffer is obtained and the 302 data read from disk. The call may block until these operations complete. A 303 buffer obtained with this call will not be involved in a transfer request 304 and will not be returned to another user until released. If the buffer is 305 already with a user when this call is made the call is blocked until the 306 buffer is returned. The highest priority waiter will obtain the buffer 307 first. 308 309 Before you can use this function, the rtems_bdbuf_init() routine must be 310 called at least once to initialize the cache, otherwise a fatal error will 311 occur. 312 313 :type dd: rtems_disk_device 314 :param dd: [in] The disk device. 315 :type block: rtems_blkdev_bnum 316 :param block: [in] Linear media block number. 317 :type bd: :py:class:`rtems_bdbuf_buffer` 318 :param bd: [out] Reference to the buffer descriptor pointer. 319 """ 320 return _bdbuf.rtems_bdbuf_read(dd, block, bd) 321 322def rtems_bdbuf_peek(dd, block, nr_blocks): 323 r""" 324 Give a hint which blocks should be cached next. 325 326 Provide a hint to the read ahead mechanism which blocks should be cached 327 next. This overwrites the default linear pattern. You should use it in (for 328 example) a file system to tell bdbuf where the next part of a fragmented file 329 is. If you know the length of the file, you can provide that too. 330 331 Before you can use this function, the rtems_bdbuf_init() routine must be 332 called at least once to initialize everything. Otherwise you might get 333 unexpected results. 334 335 :type dd: rtems_disk_device 336 :param dd: [in] The disk device. 337 :type block: rtems_blkdev_bnum 338 :param block: [in] Linear media block number. 339 :type nr_blocks: uint32_t 340 :param nr_blocks: [in] Number of consecutive blocks that can be pre-fetched. 341 """ 342 return _bdbuf.rtems_bdbuf_peek(dd, block, nr_blocks) 343 344def rtems_bdbuf_release(bd): 345 r""" 346 Release the buffer obtained by a read call back to the cache. If the buffer 347 was obtained by a get call and was not already in the cache the release 348 modified call should be used. A buffer released with this call obtained by a 349 get call may not be in sync with the contents on disk. If the buffer was in 350 the cache and modified before this call it will be returned to the modified 351 queue. The buffers is returned to the end of the LRU list. 352 353 Before you can use this function, the rtems_bdbuf_init() routine must be 354 called at least once to initialize the cache, otherwise a fatal error will 355 occur. 356 357 :type bd: :py:class:`rtems_bdbuf_buffer` 358 :param bd: [in] Reference to the buffer descriptor. The buffer descriptor 359 reference must not be ``NULL`` and must be obtained via rtems_bdbuf_get() or 360 rtems_bdbuf_read(). 361 """ 362 return _bdbuf.rtems_bdbuf_release(bd) 363 364def rtems_bdbuf_release_modified(bd): 365 r""" 366 Release the buffer allocated with a get or read call placing it on the 367 modified list. If the buffer was not released modified before the hold 368 timer is set to the configuration value. If the buffer had been released 369 modified before but not written to disk the hold timer is not updated. The 370 buffer will be written to disk when the hold timer has expired, there are 371 not more buffers available in the cache and a get or read buffer needs one 372 or a sync call has been made. If the buffer is obtained with a get or read 373 before the hold timer has expired the buffer will be returned to the user. 374 375 Before you can use this function, the rtems_bdbuf_init() routine must be 376 called at least once to initialize the cache, otherwise a fatal error will 377 occur. 378 379 :type bd: :py:class:`rtems_bdbuf_buffer` 380 :param bd: [in] Reference to the buffer descriptor. The buffer descriptor 381 reference must not be ``NULL`` and must be obtained via rtems_bdbuf_get() or 382 rtems_bdbuf_read(). 383 """ 384 return _bdbuf.rtems_bdbuf_release_modified(bd) 385 386def rtems_bdbuf_sync(bd): 387 r""" 388 Release the buffer as modified and wait until it has been synchronized with 389 the disk by writing it. This buffer will be the first to be transfer to disk 390 and other buffers may also be written if the maximum number of blocks in a 391 requests allows it. 392 393 Notes: This code does not lock the sync mutex and stop additions to the 394 modified queue. 395 396 Before you can use this function, the rtems_bdbuf_init() routine must be 397 called at least once to initialize the cache, otherwise a fatal error will 398 occur. 399 400 :type bd: :py:class:`rtems_bdbuf_buffer` 401 :param bd: [in] Reference to the buffer descriptor. The buffer descriptor 402 reference must not be ``NULL`` and must be obtained via rtems_bdbuf_get() or 403 rtems_bdbuf_read(). 404 """ 405 return _bdbuf.rtems_bdbuf_sync(bd) 406 407def rtems_bdbuf_syncdev(dd): 408 r""" 409 Synchronize all modified buffers for this device with the disk and wait 410 until the transfers have completed. The sync mutex for the cache is locked 411 stopping the addition of any further modified buffers. It is only the 412 currently modified buffers that are written. 413 414 Notes: Nesting calls to sync multiple devices will be handled sequentially. A 415 nested call will be blocked until the first sync request has complete. 416 417 Before you can use this function, the rtems_bdbuf_init() routine must be 418 called at least once to initialize the cache, otherwise a fatal error will 419 occur. 420 421 :type dd: rtems_disk_device 422 :param dd: [in] The disk device. 423 """ 424 return _bdbuf.rtems_bdbuf_syncdev(dd) 425 426def rtems_bdbuf_purge_dev(dd): 427 r""" 428 Purges all buffers corresponding to the disk device *dd*. 429 430 This may result in loss of data. The read-ahead state of this device is reset. 431 432 Before you can use this function, the rtems_bdbuf_init() routine must be 433 called at least once to initialize the cache, otherwise a fatal error will 434 occur. 435 436 :type dd: rtems_disk_device 437 :param dd: [in] The disk device. 438 """ 439 return _bdbuf.rtems_bdbuf_purge_dev(dd) 440 441def rtems_bdbuf_set_block_size(dd, block_size, sync): 442 r""" 443 Sets the block size of a disk device. 444 445 This will set the block size derived fields of the disk device. If 446 requested the disk device is synchronized before the block size change 447 occurs. Since the cache is unlocked during the synchronization operation 448 some tasks may access the disk device in the meantime. This may result in 449 loss of data. After the synchronization the disk device is purged to ensure 450 a consistent cache state and the block size change occurs. This also resets 451 the read-ahead state of this disk device. Due to the purge operation this 452 may result in loss of data. 453 454 Before you can use this function, the rtems_bdbuf_init() routine must be 455 called at least once to initialize the cache, otherwise a fatal error will 456 occur. 457 458 :type dd: rtems_disk_device 459 :param dd: [in, out] The disk device. 460 :type block_size: uint32_t 461 :param block_size: [in] The new block size in bytes. 462 :type sync: boolean 463 :param sync: [in] If ``true``, then synchronize the disk device before the 464 block size change. 465 """ 466 return _bdbuf.rtems_bdbuf_set_block_size(dd, block_size, sync) 467 468def rtems_bdbuf_get_device_stats(dd, stats): 469 r"""Returns the block device statistics.""" 470 return _bdbuf.rtems_bdbuf_get_device_stats(dd, stats) 471 472def rtems_bdbuf_reset_device_stats(dd): 473 r"""Resets the block device statistics.""" 474 return _bdbuf.rtems_bdbuf_reset_device_stats(dd) 475 476cvar = _bdbuf.cvar 477rtems_bdbuf_configuration = cvar.rtems_bdbuf_configuration
Free.
Empty.
Cached.
Accessed by upper layer with cached data.
Accessed by upper layer with modified data.
Accessed by upper layer with invalid data.
Accessed by upper layer with purged data.
Modified by upper layer.
Scheduled for synchronization.
In transfer by block device driver.
In transfer by block device driver and purged.
80class rtems_bdbuf_buffer(object): 81 r""" 82 To manage buffers we using buffer descriptors (BD). A BD holds a buffer plus 83 a range of other information related to managing the buffer in the cache. To 84 speed-up buffer lookup descriptors are organized in AVL-Tree. The fields 85 'dd' and 'block' are search keys. 86 """ 87 88 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 89 __repr__ = _swig_repr 90 avl = property(_bdbuf.rtems_bdbuf_buffer_avl_get, _bdbuf.rtems_bdbuf_buffer_avl_set, doc=r"""avl : struct rtems_bdbuf_avl_node""") 91 link = property(_bdbuf.rtems_bdbuf_buffer_link_get, _bdbuf.rtems_bdbuf_buffer_link_set, doc=r""" Link the BD onto a number of lists.""") 92 dd = property(_bdbuf.rtems_bdbuf_buffer_dd_get, _bdbuf.rtems_bdbuf_buffer_dd_set, doc=r""" disk device""") 93 block = property(_bdbuf.rtems_bdbuf_buffer_block_get, _bdbuf.rtems_bdbuf_buffer_block_set, doc=r""" block number on the device""") 94 buffer = property(_bdbuf.rtems_bdbuf_buffer_buffer_get, _bdbuf.rtems_bdbuf_buffer_buffer_set, doc=r""" Pointer to the buffer memory area""") 95 state = property(_bdbuf.rtems_bdbuf_buffer_state_get, _bdbuf.rtems_bdbuf_buffer_state_set, doc=r""" State of the buffer.""") 96 waiters = property(_bdbuf.rtems_bdbuf_buffer_waiters_get, _bdbuf.rtems_bdbuf_buffer_waiters_set, doc=r""" 97 The number of threads waiting on this 98 buffer. 99 """) 100 group = property(_bdbuf.rtems_bdbuf_buffer_group_get, _bdbuf.rtems_bdbuf_buffer_group_set, doc=r""" 101 Pointer to the group of BDs this BD is 102 part of. 103 """) 104 hold_timer = property(_bdbuf.rtems_bdbuf_buffer_hold_timer_get, _bdbuf.rtems_bdbuf_buffer_hold_timer_set, doc=r""" 105 Timer to indicate how long a buffer 106 has been held in the cache modified. 107 """) 108 references = property(_bdbuf.rtems_bdbuf_buffer_references_get, _bdbuf.rtems_bdbuf_buffer_references_set, doc=r""" Allow reference counting by owner.""") 109 user = property(_bdbuf.rtems_bdbuf_buffer_user_get, _bdbuf.rtems_bdbuf_buffer_user_set, doc=r""" User data.""") 110 111 def __init__(self): 112 r"""__init__(rtems_bdbuf_buffer self) -> rtems_bdbuf_buffer""" 113 _bdbuf.rtems_bdbuf_buffer_swiginit(self, _bdbuf.new_rtems_bdbuf_buffer()) 114 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_buffer
To manage buffers we using buffer descriptors (BD). A BD holds a buffer plus a range of other information related to managing the buffer in the cache. To speed-up buffer lookup descriptors are organized in AVL-Tree. The fields 'dd' and 'block' are search keys.
111 def __init__(self): 112 r"""__init__(rtems_bdbuf_buffer self) -> rtems_bdbuf_buffer""" 113 _bdbuf.rtems_bdbuf_buffer_swiginit(self, _bdbuf.new_rtems_bdbuf_buffer())
__init__(rtems_bdbuf_buffer self) -> rtems_bdbuf_buffer
88 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
The membership flag
118class rtems_bdbuf_avl_node(object): 119 r"""Proxy of C rtems_bdbuf_avl_node struct.""" 120 121 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 122 __repr__ = _swig_repr 123 left = property(_bdbuf.rtems_bdbuf_avl_node_left_get, _bdbuf.rtems_bdbuf_avl_node_left_set, doc=r""" Left Child""") 124 right = property(_bdbuf.rtems_bdbuf_avl_node_right_get, _bdbuf.rtems_bdbuf_avl_node_right_set, doc=r""" Right Child""") 125 cache = property(_bdbuf.rtems_bdbuf_avl_node_cache_get, _bdbuf.rtems_bdbuf_avl_node_cache_set, doc=r""" Cache""") 126 bal = property(_bdbuf.rtems_bdbuf_avl_node_bal_get, _bdbuf.rtems_bdbuf_avl_node_bal_set, doc=r""" The balance of the sub-tree""") 127 128 def __init__(self): 129 r"""__init__(rtems_bdbuf_avl_node self) -> rtems_bdbuf_avl_node""" 130 _bdbuf.rtems_bdbuf_avl_node_swiginit(self, _bdbuf.new_rtems_bdbuf_avl_node()) 131 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_avl_node
Proxy of C rtems_bdbuf_avl_node struct.
128 def __init__(self): 129 r"""__init__(rtems_bdbuf_avl_node self) -> rtems_bdbuf_avl_node""" 130 _bdbuf.rtems_bdbuf_avl_node_swiginit(self, _bdbuf.new_rtems_bdbuf_avl_node())
__init__(rtems_bdbuf_avl_node self) -> rtems_bdbuf_avl_node
121 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
The membership flag
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
135class rtems_bdbuf_group(object): 136 r""" 137 A group is a continuous block of buffer descriptors. A group covers the 138 maximum configured buffer size and is the allocation size for the buffers to 139 a specific buffer size. If you allocate a buffer to be a specific size, all 140 buffers in the group, if there are more than 1 will also be that size. The 141 number of buffers in a group is a multiple of 2, ie 1, 2, 4, 8, etc. 142 """ 143 144 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 145 __repr__ = _swig_repr 146 link = property(_bdbuf.rtems_bdbuf_group_link_get, _bdbuf.rtems_bdbuf_group_link_set, doc=r""" 147 Link the groups on a LRU list if they 148 have no buffers in use. 149 """) 150 bds_per_group = property(_bdbuf.rtems_bdbuf_group_bds_per_group_get, _bdbuf.rtems_bdbuf_group_bds_per_group_set, doc=r""" 151 The number of BD allocated to this 152 group. This value must be a multiple of 153 2. 154 """) 155 users = property(_bdbuf.rtems_bdbuf_group_users_get, _bdbuf.rtems_bdbuf_group_users_set, doc=r""" How many users the block has.""") 156 bdbuf = property(_bdbuf.rtems_bdbuf_group_bdbuf_get, _bdbuf.rtems_bdbuf_group_bdbuf_set, doc=r""" First BD this block covers.""") 157 158 def __init__(self): 159 r"""__init__(rtems_bdbuf_group self) -> rtems_bdbuf_group""" 160 _bdbuf.rtems_bdbuf_group_swiginit(self, _bdbuf.new_rtems_bdbuf_group()) 161 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_group
A group is a continuous block of buffer descriptors. A group covers the maximum configured buffer size and is the allocation size for the buffers to a specific buffer size. If you allocate a buffer to be a specific size, all buffers in the group, if there are more than 1 will also be that size. The number of buffers in a group is a multiple of 2, ie 1, 2, 4, 8, etc.
158 def __init__(self): 159 r"""__init__(rtems_bdbuf_group self) -> rtems_bdbuf_group""" 160 _bdbuf.rtems_bdbuf_group_swiginit(self, _bdbuf.new_rtems_bdbuf_group())
__init__(rtems_bdbuf_group self) -> rtems_bdbuf_group
144 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
The membership flag
165class rtems_bdbuf_config(object): 166 r""" 167 Buffering configuration definition. See confdefs.h for support on using this 168 structure. 169 """ 170 171 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 172 __repr__ = _swig_repr 173 max_read_ahead_blocks = property(_bdbuf.rtems_bdbuf_config_max_read_ahead_blocks_get, _bdbuf.rtems_bdbuf_config_max_read_ahead_blocks_set, doc=r""" 174 Number of blocks to read 175 ahead. 176 """) 177 max_write_blocks = property(_bdbuf.rtems_bdbuf_config_max_write_blocks_get, _bdbuf.rtems_bdbuf_config_max_write_blocks_set, doc=r""" 178 Number of blocks to write 179 at once. 180 """) 181 swapout_priority = property(_bdbuf.rtems_bdbuf_config_swapout_priority_get, _bdbuf.rtems_bdbuf_config_swapout_priority_set, doc=r""" 182 Priority of the swap out 183 task. 184 """) 185 swapout_period = property(_bdbuf.rtems_bdbuf_config_swapout_period_get, _bdbuf.rtems_bdbuf_config_swapout_period_set, doc=r""" 186 Period swap-out checks buf 187 timers. 188 """) 189 swap_block_hold = property(_bdbuf.rtems_bdbuf_config_swap_block_hold_get, _bdbuf.rtems_bdbuf_config_swap_block_hold_set, doc=r""" Period a buffer is held.""") 190 swapout_workers = property(_bdbuf.rtems_bdbuf_config_swapout_workers_get, _bdbuf.rtems_bdbuf_config_swapout_workers_set, doc=r""" 191 The number of worker 192 threads for the swap-out 193 task. 194 """) 195 swapout_worker_priority = property(_bdbuf.rtems_bdbuf_config_swapout_worker_priority_get, _bdbuf.rtems_bdbuf_config_swapout_worker_priority_set, doc=r""" 196 Priority of the swap out 197 task. 198 """) 199 task_stack_size = property(_bdbuf.rtems_bdbuf_config_task_stack_size_get, _bdbuf.rtems_bdbuf_config_task_stack_size_set, doc=r""" 200 Task stack size for swap-out 201 task and worker threads. 202 """) 203 size = property(_bdbuf.rtems_bdbuf_config_size_get, _bdbuf.rtems_bdbuf_config_size_set, doc=r""" 204 Size of memory in the 205 cache 206 """) 207 buffer_min = property(_bdbuf.rtems_bdbuf_config_buffer_min_get, _bdbuf.rtems_bdbuf_config_buffer_min_set, doc=r""" Minimum buffer size.""") 208 buffer_max = property(_bdbuf.rtems_bdbuf_config_buffer_max_get, _bdbuf.rtems_bdbuf_config_buffer_max_set, doc=r""" 209 Maximum buffer size 210 supported. It is also the 211 allocation size. 212 """) 213 read_ahead_priority = property(_bdbuf.rtems_bdbuf_config_read_ahead_priority_get, _bdbuf.rtems_bdbuf_config_read_ahead_priority_set, doc=r""" 214 Priority of the read-ahead 215 task. 216 """) 217 218 def __init__(self): 219 r"""__init__(rtems_bdbuf_config self) -> rtems_bdbuf_config""" 220 _bdbuf.rtems_bdbuf_config_swiginit(self, _bdbuf.new_rtems_bdbuf_config()) 221 __swig_destroy__ = _bdbuf.delete_rtems_bdbuf_config
Buffering configuration definition. See confdefs.h for support on using this structure.
218 def __init__(self): 219 r"""__init__(rtems_bdbuf_config self) -> rtems_bdbuf_config""" 220 _bdbuf.rtems_bdbuf_config_swiginit(self, _bdbuf.new_rtems_bdbuf_config())
__init__(rtems_bdbuf_config self) -> rtems_bdbuf_config
171 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
The membership flag
The default value for the maximum read-ahead blocks disables the read-ahead feature.
Default maximum number of blocks to write at once.
Default swap-out task priority.
Default swap-out task swap period in milli seconds.
Default swap-out task block hold time in milli seconds.
Default swap-out worker tasks. Currently disabled.
Default swap-out worker task priority. The same as the swap-out task.
Default read-ahead task priority. The same as the swap-out task.
Default task stack size for swap-out and worker tasks.
Default size of memory allocated to the cache.
Default minimum size of buffers.
Default maximum size of buffers.
255def rtems_bdbuf_init(): 256 r""" 257 Prepare buffering layer to work - initialize buffer descritors and (if it is 258 neccessary) buffers. After initialization all blocks is placed into the 259 ready state. 260 """ 261 return _bdbuf.rtems_bdbuf_init()
Prepare buffering layer to work - initialize buffer descritors and (if it is neccessary) buffers. After initialization all blocks is placed into the ready state.
263def rtems_bdbuf_get(dd, block, bd): 264 r""" 265 Get block buffer for data to be written into. The buffers is set to the 266 access or modified access state. If the buffer is in the cache and modified 267 the state is access modified else the state is access. This buffer contents 268 are not initialised if the buffer is not already in the cache. If the block 269 is already resident in memory it is returned how-ever if not in memory the 270 buffer is not read from disk. This call is used when writing the whole block 271 on a disk rather than just changing a part of it. If there is no buffers 272 available this call will block. A buffer obtained with this call will not be 273 involved in a transfer request and will not be returned to another user 274 until released. If the buffer is already with a user when this call is made 275 the call is blocked until the buffer is returned. The highest priority 276 waiter will obtain the buffer first. 277 278 The block number is the linear block number. This is relative to the start 279 of the partition on the media. 280 281 Before you can use this function, the rtems_bdbuf_init() routine must be 282 called at least once to initialize the cache, otherwise a fatal error will 283 occur. 284 285 :type dd: rtems_disk_device 286 :param dd: [in] The disk device. 287 :type block: rtems_blkdev_bnum 288 :param block: [in] Linear media block number. 289 :type bd: :py:class:`rtems_bdbuf_buffer` 290 :param bd: [out] Reference to the buffer descriptor pointer. 291 """ 292 return _bdbuf.rtems_bdbuf_get(dd, block, bd)
Get block buffer for data to be written into. The buffers is set to the access or modified access state. If the buffer is in the cache and modified the state is access modified else the state is access. This buffer contents are not initialised if the buffer is not already in the cache. If the block is already resident in memory it is returned how-ever if not in memory the buffer is not read from disk. This call is used when writing the whole block on a disk rather than just changing a part of it. If there is no buffers available this call will block. A buffer obtained with this call will not be involved in a transfer request and will not be returned to another user until released. If the buffer is already with a user when this call is made the call is blocked until the buffer is returned. The highest priority waiter will obtain the buffer first.
The block number is the linear block number. This is relative to the start of the partition on the media.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- dd: [in] The disk device.
- block: [in] Linear media block number.
- bd: [out] Reference to the buffer descriptor pointer.
294def rtems_bdbuf_read(dd, block, bd): 295 r""" 296 Get the block buffer and if not already in the cache read from the disk. If 297 specified block already cached return. The buffer is set to the access or 298 modified access state. If the buffer is in the cache and modified the state 299 is access modified else the state is access. If block is already being read 300 from disk for being written to disk this call blocks. If the buffer is 301 waiting to be written it is removed from modified queue and returned to the 302 user. If the buffer is not in the cache a new buffer is obtained and the 303 data read from disk. The call may block until these operations complete. A 304 buffer obtained with this call will not be involved in a transfer request 305 and will not be returned to another user until released. If the buffer is 306 already with a user when this call is made the call is blocked until the 307 buffer is returned. The highest priority waiter will obtain the buffer 308 first. 309 310 Before you can use this function, the rtems_bdbuf_init() routine must be 311 called at least once to initialize the cache, otherwise a fatal error will 312 occur. 313 314 :type dd: rtems_disk_device 315 :param dd: [in] The disk device. 316 :type block: rtems_blkdev_bnum 317 :param block: [in] Linear media block number. 318 :type bd: :py:class:`rtems_bdbuf_buffer` 319 :param bd: [out] Reference to the buffer descriptor pointer. 320 """ 321 return _bdbuf.rtems_bdbuf_read(dd, block, bd)
Get the block buffer and if not already in the cache read from the disk. If specified block already cached return. The buffer is set to the access or modified access state. If the buffer is in the cache and modified the state is access modified else the state is access. If block is already being read from disk for being written to disk this call blocks. If the buffer is waiting to be written it is removed from modified queue and returned to the user. If the buffer is not in the cache a new buffer is obtained and the data read from disk. The call may block until these operations complete. A buffer obtained with this call will not be involved in a transfer request and will not be returned to another user until released. If the buffer is already with a user when this call is made the call is blocked until the buffer is returned. The highest priority waiter will obtain the buffer first.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- dd: [in] The disk device.
- block: [in] Linear media block number.
- bd: [out] Reference to the buffer descriptor pointer.
323def rtems_bdbuf_peek(dd, block, nr_blocks): 324 r""" 325 Give a hint which blocks should be cached next. 326 327 Provide a hint to the read ahead mechanism which blocks should be cached 328 next. This overwrites the default linear pattern. You should use it in (for 329 example) a file system to tell bdbuf where the next part of a fragmented file 330 is. If you know the length of the file, you can provide that too. 331 332 Before you can use this function, the rtems_bdbuf_init() routine must be 333 called at least once to initialize everything. Otherwise you might get 334 unexpected results. 335 336 :type dd: rtems_disk_device 337 :param dd: [in] The disk device. 338 :type block: rtems_blkdev_bnum 339 :param block: [in] Linear media block number. 340 :type nr_blocks: uint32_t 341 :param nr_blocks: [in] Number of consecutive blocks that can be pre-fetched. 342 """ 343 return _bdbuf.rtems_bdbuf_peek(dd, block, nr_blocks)
Give a hint which blocks should be cached next.
Provide a hint to the read ahead mechanism which blocks should be cached next. This overwrites the default linear pattern. You should use it in (for example) a file system to tell bdbuf where the next part of a fragmented file is. If you know the length of the file, you can provide that too.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize everything. Otherwise you might get unexpected results.
Parameters
- dd: [in] The disk device.
- block: [in] Linear media block number.
- nr_blocks: [in] Number of consecutive blocks that can be pre-fetched.
345def rtems_bdbuf_release(bd): 346 r""" 347 Release the buffer obtained by a read call back to the cache. If the buffer 348 was obtained by a get call and was not already in the cache the release 349 modified call should be used. A buffer released with this call obtained by a 350 get call may not be in sync with the contents on disk. If the buffer was in 351 the cache and modified before this call it will be returned to the modified 352 queue. The buffers is returned to the end of the LRU list. 353 354 Before you can use this function, the rtems_bdbuf_init() routine must be 355 called at least once to initialize the cache, otherwise a fatal error will 356 occur. 357 358 :type bd: :py:class:`rtems_bdbuf_buffer` 359 :param bd: [in] Reference to the buffer descriptor. The buffer descriptor 360 reference must not be ``NULL`` and must be obtained via rtems_bdbuf_get() or 361 rtems_bdbuf_read(). 362 """ 363 return _bdbuf.rtems_bdbuf_release(bd)
Release the buffer obtained by a read call back to the cache. If the buffer was obtained by a get call and was not already in the cache the release modified call should be used. A buffer released with this call obtained by a get call may not be in sync with the contents on disk. If the buffer was in the cache and modified before this call it will be returned to the modified queue. The buffers is returned to the end of the LRU list.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- bd: [in] Reference to the buffer descriptor. The buffer descriptor
reference must not be
NULLand must be obtained via rtems_bdbuf_get() or rtems_bdbuf_read().
365def rtems_bdbuf_release_modified(bd): 366 r""" 367 Release the buffer allocated with a get or read call placing it on the 368 modified list. If the buffer was not released modified before the hold 369 timer is set to the configuration value. If the buffer had been released 370 modified before but not written to disk the hold timer is not updated. The 371 buffer will be written to disk when the hold timer has expired, there are 372 not more buffers available in the cache and a get or read buffer needs one 373 or a sync call has been made. If the buffer is obtained with a get or read 374 before the hold timer has expired the buffer will be returned to the user. 375 376 Before you can use this function, the rtems_bdbuf_init() routine must be 377 called at least once to initialize the cache, otherwise a fatal error will 378 occur. 379 380 :type bd: :py:class:`rtems_bdbuf_buffer` 381 :param bd: [in] Reference to the buffer descriptor. The buffer descriptor 382 reference must not be ``NULL`` and must be obtained via rtems_bdbuf_get() or 383 rtems_bdbuf_read(). 384 """ 385 return _bdbuf.rtems_bdbuf_release_modified(bd)
Release the buffer allocated with a get or read call placing it on the modified list. If the buffer was not released modified before the hold timer is set to the configuration value. If the buffer had been released modified before but not written to disk the hold timer is not updated. The buffer will be written to disk when the hold timer has expired, there are not more buffers available in the cache and a get or read buffer needs one or a sync call has been made. If the buffer is obtained with a get or read before the hold timer has expired the buffer will be returned to the user.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- bd: [in] Reference to the buffer descriptor. The buffer descriptor
reference must not be
NULLand must be obtained via rtems_bdbuf_get() or rtems_bdbuf_read().
387def rtems_bdbuf_sync(bd): 388 r""" 389 Release the buffer as modified and wait until it has been synchronized with 390 the disk by writing it. This buffer will be the first to be transfer to disk 391 and other buffers may also be written if the maximum number of blocks in a 392 requests allows it. 393 394 Notes: This code does not lock the sync mutex and stop additions to the 395 modified queue. 396 397 Before you can use this function, the rtems_bdbuf_init() routine must be 398 called at least once to initialize the cache, otherwise a fatal error will 399 occur. 400 401 :type bd: :py:class:`rtems_bdbuf_buffer` 402 :param bd: [in] Reference to the buffer descriptor. The buffer descriptor 403 reference must not be ``NULL`` and must be obtained via rtems_bdbuf_get() or 404 rtems_bdbuf_read(). 405 """ 406 return _bdbuf.rtems_bdbuf_sync(bd)
Release the buffer as modified and wait until it has been synchronized with the disk by writing it. This buffer will be the first to be transfer to disk and other buffers may also be written if the maximum number of blocks in a requests allows it.
Notes: This code does not lock the sync mutex and stop additions to the modified queue.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- bd: [in] Reference to the buffer descriptor. The buffer descriptor
reference must not be
NULLand must be obtained via rtems_bdbuf_get() or rtems_bdbuf_read().
408def rtems_bdbuf_syncdev(dd): 409 r""" 410 Synchronize all modified buffers for this device with the disk and wait 411 until the transfers have completed. The sync mutex for the cache is locked 412 stopping the addition of any further modified buffers. It is only the 413 currently modified buffers that are written. 414 415 Notes: Nesting calls to sync multiple devices will be handled sequentially. A 416 nested call will be blocked until the first sync request has complete. 417 418 Before you can use this function, the rtems_bdbuf_init() routine must be 419 called at least once to initialize the cache, otherwise a fatal error will 420 occur. 421 422 :type dd: rtems_disk_device 423 :param dd: [in] The disk device. 424 """ 425 return _bdbuf.rtems_bdbuf_syncdev(dd)
Synchronize all modified buffers for this device with the disk and wait until the transfers have completed. The sync mutex for the cache is locked stopping the addition of any further modified buffers. It is only the currently modified buffers that are written.
Notes: Nesting calls to sync multiple devices will be handled sequentially. A nested call will be blocked until the first sync request has complete.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- dd: [in] The disk device.
427def rtems_bdbuf_purge_dev(dd): 428 r""" 429 Purges all buffers corresponding to the disk device *dd*. 430 431 This may result in loss of data. The read-ahead state of this device is reset. 432 433 Before you can use this function, the rtems_bdbuf_init() routine must be 434 called at least once to initialize the cache, otherwise a fatal error will 435 occur. 436 437 :type dd: rtems_disk_device 438 :param dd: [in] The disk device. 439 """ 440 return _bdbuf.rtems_bdbuf_purge_dev(dd)
Purges all buffers corresponding to the disk device dd.
This may result in loss of data. The read-ahead state of this device is reset.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- dd: [in] The disk device.
442def rtems_bdbuf_set_block_size(dd, block_size, sync): 443 r""" 444 Sets the block size of a disk device. 445 446 This will set the block size derived fields of the disk device. If 447 requested the disk device is synchronized before the block size change 448 occurs. Since the cache is unlocked during the synchronization operation 449 some tasks may access the disk device in the meantime. This may result in 450 loss of data. After the synchronization the disk device is purged to ensure 451 a consistent cache state and the block size change occurs. This also resets 452 the read-ahead state of this disk device. Due to the purge operation this 453 may result in loss of data. 454 455 Before you can use this function, the rtems_bdbuf_init() routine must be 456 called at least once to initialize the cache, otherwise a fatal error will 457 occur. 458 459 :type dd: rtems_disk_device 460 :param dd: [in, out] The disk device. 461 :type block_size: uint32_t 462 :param block_size: [in] The new block size in bytes. 463 :type sync: boolean 464 :param sync: [in] If ``true``, then synchronize the disk device before the 465 block size change. 466 """ 467 return _bdbuf.rtems_bdbuf_set_block_size(dd, block_size, sync)
Sets the block size of a disk device.
This will set the block size derived fields of the disk device. If requested the disk device is synchronized before the block size change occurs. Since the cache is unlocked during the synchronization operation some tasks may access the disk device in the meantime. This may result in loss of data. After the synchronization the disk device is purged to ensure a consistent cache state and the block size change occurs. This also resets the read-ahead state of this disk device. Due to the purge operation this may result in loss of data.
Before you can use this function, the rtems_bdbuf_init() routine must be called at least once to initialize the cache, otherwise a fatal error will occur.
Parameters
- dd: [in, out] The disk device.
- block_size: [in] The new block size in bytes.
- sync: [in] If
true, then synchronize the disk device before the block size change.
469def rtems_bdbuf_get_device_stats(dd, stats): 470 r"""Returns the block device statistics.""" 471 return _bdbuf.rtems_bdbuf_get_device_stats(dd, stats)
Returns the block device statistics.
473def rtems_bdbuf_reset_device_stats(dd): 474 r"""Resets the block device statistics.""" 475 return _bdbuf.rtems_bdbuf_reset_device_stats(dd)
Resets the block device statistics.