diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-10-26 21:31:45 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-10-26 22:03:22 +0200 |
commit | 9dffa384e1ce14ab110a30737051c4e8c98d7fc3 (patch) | |
tree | b0e9c4143e20c18d5a4742700157eca6dd64636d /cpukit/libblock/src/bdbuf.c | |
parent | libblock: ramdisk documentation (diff) | |
download | rtems-9dffa384e1ce14ab110a30737051c4e8c98d7fc3.tar.bz2 |
libblock: rtems_bdbuf_set_block_size() API change
The set block size must synchronize and purge the disk to avoid an
inconsistent cache state and data corruption. The synchronization is
optional depending on the new sync parameter. In some contexts a
synchronization must not be performed, e.g. during disk creation.
Diffstat (limited to 'cpukit/libblock/src/bdbuf.c')
-rw-r--r-- | cpukit/libblock/src/bdbuf.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c index 3f4915be43..c4336cd8cd 100644 --- a/cpukit/libblock/src/bdbuf.c +++ b/cpukit/libblock/src/bdbuf.c @@ -2948,10 +2948,19 @@ rtems_bdbuf_purge_dev (rtems_disk_device *dd) } rtems_status_code -rtems_bdbuf_set_block_size (rtems_disk_device *dd, uint32_t block_size) +rtems_bdbuf_set_block_size (rtems_disk_device *dd, + uint32_t block_size, + bool sync) { rtems_status_code sc = RTEMS_SUCCESSFUL; + /* + * We do not care about the synchronization status since we will purge the + * device later. + */ + if (sync) + rtems_bdbuf_syncdev (dd); + rtems_bdbuf_lock_cache (); if (block_size > 0) @@ -2978,7 +2987,7 @@ rtems_bdbuf_set_block_size (rtems_disk_device *dd, uint32_t block_size) dd->block_to_media_block_shift = block_to_media_block_shift; dd->bds_per_group = bds_per_group; - rtems_bdbuf_read_ahead_reset (dd); + rtems_bdbuf_purge_dev (dd); } else { |