diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-09 14:33:51 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-11 13:58:43 +0200 |
commit | 86ef0df976faf1b060347a07744814458aa42619 (patch) | |
tree | d001b836005d059b5aa11cf541093f5027c50d28 /testsuites | |
parent | libblock: Add RTEMS_BLKIO_PURGEDEV (diff) | |
download | rtems-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 'testsuites')
-rw-r--r-- | testsuites/fstests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/fstests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/fstests/fsdosfssync01/Makefile.am | 19 | ||||
-rw-r--r-- | testsuites/fstests/fsdosfssync01/fsdosfssync01.doc | 11 | ||||
-rw-r--r-- | testsuites/fstests/fsdosfssync01/fsdosfssync01.scn | 2 | ||||
-rw-r--r-- | testsuites/fstests/fsdosfssync01/init.c | 171 |
6 files changed, 205 insertions, 0 deletions
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am index f765a89af4..43832760a0 100644 --- a/testsuites/fstests/Makefile.am +++ b/testsuites/fstests/Makefile.am @@ -5,6 +5,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal SUBDIRS = +SUBDIRS += fsdosfssync01 SUBDIRS += imfs_fserror SUBDIRS += imfs_fslink SUBDIRS += imfs_fspatheval diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac index 833a85c21a..ccf9ee0bcf 100644 --- a/testsuites/fstests/configure.ac +++ b/testsuites/fstests/configure.ac @@ -79,6 +79,7 @@ AC_CHECK_SIZEOF([blkcnt_t]) # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile +fsdosfssync01/Makefile imfs_fserror/Makefile imfs_fslink/Makefile imfs_fspatheval/Makefile diff --git a/testsuites/fstests/fsdosfssync01/Makefile.am b/testsuites/fstests/fsdosfssync01/Makefile.am new file mode 100644 index 0000000000..eb557f11e2 --- /dev/null +++ b/testsuites/fstests/fsdosfssync01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = fsdosfssync01 +fsdosfssync01_SOURCES = init.c + +dist_rtems_tests_DATA = fsdosfssync01.scn fsdosfssync01.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(fsdosfssync01_OBJECTS) +LINK_LIBS = $(fsdosfssync01_LDLIBS) + +fsdosfssync01$(EXEEXT): $(fsdosfssync01_OBJECTS) $(fsdosfssync01_DEPENDENCIES) + @rm -f fsdosfssync01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/fstests/fsdosfssync01/fsdosfssync01.doc b/testsuites/fstests/fsdosfssync01/fsdosfssync01.doc new file mode 100644 index 0000000000..98b558a4f5 --- /dev/null +++ b/testsuites/fstests/fsdosfssync01/fsdosfssync01.doc @@ -0,0 +1,11 @@ +This file describes the directives and concepts tested by this test set. + +test set name: fsdosfssync01 + +directives: + + TBD + +concepts: + + TBD diff --git a/testsuites/fstests/fsdosfssync01/fsdosfssync01.scn b/testsuites/fstests/fsdosfssync01/fsdosfssync01.scn new file mode 100644 index 0000000000..c181dbf72c --- /dev/null +++ b/testsuites/fstests/fsdosfssync01/fsdosfssync01.scn @@ -0,0 +1,2 @@ +*** TEST FSDOSFSSYNC 1 *** +*** END OF TEST FSDOSFSSYNC 1 *** diff --git a/testsuites/fstests/fsdosfssync01/init.c b/testsuites/fstests/fsdosfssync01/init.c new file mode 100644 index 0000000000..72481b29b8 --- /dev/null +++ b/testsuites/fstests/fsdosfssync01/init.c @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "tmacros.h" + +#include <sys/stat.h> +#include <errno.h> +#include <string.h> +#include <stdint.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rtems/libio.h> +#include <rtems/blkdev.h> +#include <rtems/dosfs.h> +#include <rtems/ramdisk.h> + +static void create_file(const char *file) +{ + int fd; + int rv; + + fd = creat(file, S_IRWXU | S_IRWXG | S_IRWXO); + rtems_test_assert(fd >= 0); + + rv = fsync(fd); + rtems_test_assert(rv == 0); + + rv = close(fd); + rtems_test_assert(rv == 0); +} + +static void write_to_file(const char *file, bool sync) +{ + int fd; + char buf [1]; + ssize_t n; + off_t pos; + int rv; + + fd = open(file, O_RDWR); + rtems_test_assert(fd >= 0); + + n = write(fd, buf, sizeof(buf)); + rtems_test_assert(n == (ssize_t) sizeof(buf)); + + pos = lseek(fd, 0, SEEK_END); + rtems_test_assert(pos == sizeof(buf)); + + if (sync) { + rv = fsync(fd); + rtems_test_assert(rv == 0); + } + + rv = close(fd); + rtems_test_assert(rv == 0); +} + +static void check_file_size(const char *file, off_t size) +{ + int fd; + off_t pos; + int rv; + + fd = open(file, O_RDWR); + rtems_test_assert(fd >= 0); + + pos = lseek(fd, 0, SEEK_END); + rtems_test_assert(pos == size); + + rv = close(fd); + rtems_test_assert(rv == 0); +} + +static void test(const char *rda, const char *mnt, const char *file) +{ + rtems_status_code sc; + int disk_fd; + int rv; + + sc = rtems_disk_io_initialize(); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + disk_fd = open(rda, O_RDWR); + rtems_test_assert(disk_fd >= 0); + + rv = msdos_format(rda, NULL); + rtems_test_assert(rv == 0); + + rv = mount_and_make_target_path( + rda, + mnt, + RTEMS_FILESYSTEM_TYPE_DOSFS, + RTEMS_FILESYSTEM_READ_WRITE, + NULL + ); + rtems_test_assert(rv == 0); + + create_file(file); + rv = rtems_disk_fd_purge(disk_fd); + rtems_test_assert(rv == 0); + + write_to_file(file, false); + rv = rtems_disk_fd_purge(disk_fd); + rtems_test_assert(rv == 0); + check_file_size(file, 0); + + write_to_file(file, true); + rv = rtems_disk_fd_purge(disk_fd); + rtems_test_assert(rv == 0); + check_file_size(file, 1); + + rv = unmount(mnt); + rtems_test_assert(rv == 0); + + rv = close(disk_fd); + rtems_test_assert(rv == 0); +} + +static void Init(rtems_task_argument arg) +{ + puts("\n\n*** TEST FSDOSFSSYNC 1 ***"); + + test("/dev/rda", "/mnt", "/mnt/file"); + + puts("*** END OF TEST FSDOSFSSYNC 1 ***"); + + rtems_test_exit(0); +} + +rtems_ramdisk_config rtems_ramdisk_configuration [] = { + { .block_size = 512, .block_num = 1024 } +}; + +size_t rtems_ramdisk_configuration_size = 1; + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_EXTRA_DRIVERS RAMDISK_DRIVER_TABLE_ENTRY +#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK + +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 6 + +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM + +#define CONFIGURE_FILESYSTEM_DOSFS + +#define CONFIGURE_MAXIMUM_TASKS 2 + +#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024) + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> |