From 3f53a96a8bd0cd4a18f819b6857e6a764706ede5 Mon Sep 17 00:00:00 2001 From: Filipe David Manana Date: Thu, 22 Apr 2010 23:40:26 +0100 Subject: Add file:datasync/1 for syncing file contents only file:datasync/1 invokes the POSIX system call "int fdatasync(int fd)". This system call is similar to "fsync" but, unlike fsync, it does not update the metadata associated with the file (like the access time for example). It's used by many DBMSs (MySQL and SQLite of example) to increase disk IO performance, as it avoids disk seeks and disk write operations compared to fsync. More details on it at: http://linux.die.net/man/2/fdatasync An example, from the MySQL source: http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1-telco-6.1/annotate/head%3A/mysys/my_sync.c#L61 This new function just calls fsync on systems not implementing fdatasync. --- lib/kernel/doc/src/file.xml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml index 50f9722a1c..c94df62d1f 100644 --- a/lib/kernel/doc/src/file.xml +++ b/lib/kernel/doc/src/file.xml @@ -1640,6 +1640,33 @@ f.txt: {person, "kalle", 25}. + + datasync(IoDevice) -> ok | {error, Reason} + Synchronizes the in-memory data of a file, ignoring most of its metadata, with that on the physical medium + + IoDevice = io_device() + Reason = ext_posix() | terminated + + +

Makes sure that any buffers kept by the operating system + (not by the Erlang runtime system) are written to disk. In + many ways it's resembles fsync but it not requires to update + some of file's metadata such as the access time. On + some platforms, this function might have no effect.

+

Applications that access databases or log files often write + a tiny data fragment (e.g., one line in a log file) and then + call fsync() immediately in order to ensure that the written + data is physically stored on the harddisk. Unfortunately, fsync() + will always initiate two write operations: one for the newly + written data and another one in order to update the modification + time stored in the inode. If the modification time is not a part + of the transaction concept fdatasync() can be used to avoid + unnecessary inode disk write operations.

+

Available only in some POSIX systems. This call results in a + call to fsync(), or has no effect, in systems not implementing + the fdatasync syscall.

+
+
truncate(IoDevice) -> ok | {error, Reason} Truncate a file -- cgit v1.2.3 From 21a67b797e40df930b83bd407ffc165b3f4b91b2 Mon Sep 17 00:00:00 2001 From: Filipe David Manana Date: Mon, 26 Apr 2010 13:04:40 +0200 Subject: Add file:advise/4 - a wrapper to the POSIX syscall posix_fadvise Useful for informing the Operating System about the access pattern for a file's data, so that it can adapt the caching strategy to maximize disk IO performance. --- lib/kernel/doc/src/file.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml index c94df62d1f..382262d1ee 100644 --- a/lib/kernel/doc/src/file.xml +++ b/lib/kernel/doc/src/file.xml @@ -61,6 +61,25 @@ time() = {{Year, Month, Day}, {Hour, Minute, Second}} Must denote a valid date and time + + advise(IoDevice, Offset, Length, Advise) -> ok | {error, Reason} + Predeclare an access pattern for file data + + IoDevice = io_device() + Offset = int() + Length = int() + Advise = posix_file_advise() + posix_file_advise() = normal | sequential | random | no_reuse + | will_need | dont_need + Reason = ext_posix() + + +

advise/4 can be used to announce an intention to access file + data in a specific pattern in the future, thus allowing the + operating system to perform appropriate optimizations.

+

On some platforms, this function might have no effect.

+
+
change_group(Filename, Gid) -> ok | {error, Reason} Change group of a file -- cgit v1.2.3