summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/msdos_misc.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-09 14:33:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-11 13:58:43 +0200
commit86ef0df976faf1b060347a07744814458aa42619 (patch)
treed001b836005d059b5aa11cf541093f5027c50d28 /cpukit/libfs/src/dosfs/msdos_misc.c
parentlibblock: Add RTEMS_BLKIO_PURGEDEV (diff)
downloadrtems-86ef0df976faf1b060347a07744814458aa42619.tar.bz2
dosfs: Remove fat_file_datasync()
The fat_file_datasync() read every cluster of the file into the cache and then synchronized it step-by-step. For unmodified buffers this is a non-operation. For modified buffers this will wake-up the swapout task which performs then a single buffer write operation. This is usually quite inefficient. Firstly we do single buffer writes, secondly we may perform a lot of unnecessary read operations (for huge files this is really bad), and thirdly this leads likely to cache evictions. The synchronization procedure is replaced by a simple rtems_bdbuf_sync_dev(). This has the side-effect that also buffers not related to the file are synchronized, but since the modified list is normally short this should be acceptable.
Diffstat (limited to 'cpukit/libfs/src/dosfs/msdos_misc.c')
-rw-r--r--cpukit/libfs/src/dosfs/msdos_misc.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/cpukit/libfs/src/dosfs/msdos_misc.c b/cpukit/libfs/src/dosfs/msdos_misc.c
index d11bd83f52..511ac44dda 100644
--- a/cpukit/libfs/src/dosfs/msdos_misc.c
+++ b/cpukit/libfs/src/dosfs/msdos_misc.c
@@ -1646,3 +1646,34 @@ int msdos_find_node_by_cluster_num_in_fat_file(
}
return MSDOS_NAME_NOT_FOUND_ERR;
}
+
+int
+msdos_sync_unprotected(msdos_fs_info_t *fs_info)
+{
+ int rc = fat_buf_release(&fs_info->fat);
+ rtems_status_code sc = rtems_bdbuf_syncdev(fs_info->fat.vol.dd);
+ if (sc != RTEMS_SUCCESSFUL) {
+ errno = EIO;
+ rc = -1;
+ }
+
+ return rc;
+}
+
+int
+msdos_sync(rtems_libio_t *iop)
+{
+ int rc = RC_OK;
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
+
+ sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
+ MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
+ if (sc != RTEMS_SUCCESSFUL)
+ rtems_set_errno_and_return_minus_one(EIO);
+
+ rc = msdos_sync_unprotected(fs_info);
+
+ rtems_semaphore_release(fs_info->vol_sema);
+ return rc;
+}