aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/unix/unix_efile.c
AgeCommit message (Collapse)Author
2015-08-27Fix ethread events with timeoutRickard Green
Lots of pthread platforms unnecessarily falled back on the pipe/select solution. This since we tried to use the same monotonic clock source for pthread_cond_timedwait() as used by OS monotonic time. This has been fixed on most platforms by using another clock source. Darwin can however not use pthread_cond_timedwait() with monotonic clock source and has to use the pipe/select solution. On darwin we now use select with _DARWIN_UNLIMITED_SELECT in order to be able to handle a large amount of file descriptors.
2015-06-18Change license text to APLv2Bruce Yinhe
2014-05-14Fix efile_openfile() to handle stat() failureMikael Pettersson
If the initial stat() fails then efile_openfile() will still proceed to open() the file. If that succeeds and the caller passed a non-NULL pSize, then it will copy bogus data from the statbuf into *pSize. This has been observed to cause file:read_file/1 to return truncated file data with no error indication. The use case involved a large file system mounted via NFS, with some directories containing large number of files, and NFS mount options that allow the NFS client to return EIO if the NFS server does not respond quickly enough. Depending on the caching state of the client and server machines, a few stat() calls (fewer than 1 per 10 million) would take long enough to trigger EIO errors, but subsequent open() calls would succeed, and read_file/1 would return truncated data. This sequence of events has been observed via "strace" on beam.smp. Signed-off-by: Mikael Pettersson <[email protected]>
2014-02-24erts: Fix unix efile assertLukas Larsson
If writev return an error (eg ENOSPC) we do not want to abort here but instead propagate upwards into erlang.
2014-02-24ose: efile driver updates.Jonas Karlsson
2013-11-15Add sync option to file:open/2Joseph Blomstedt
The sync option adds the POSIX O_SYNC flag to the open system call on platforms that support the flag or its equivalent, e.g., FILE_FLAG_WRITE_THROUGH on Windows. For platforms that don't support it, file:open/2 returns {error, enotsup} if the sync option is passed in. The semantics of O_SYNC are platform-specific. For example, not all platforms guarantee that all file metadata are written to the disk along with the file data when the flag is in effect. This issue is noted in the documentation this commit adds for the sync option. Add a test for the sync option. Note however that the underlying OS semantics for O_SYNC can't be tested automatically in any practical way, so the test assumes the OS does the right thing with the flag when present. For manual verification, dtruss on OS X and strace on Linux were both run against beam processes to watch calls to open(), and file:open/2 was called in Erlang shells to open files for writing, both with and without the sync option. Both the dtruss output and the strace output showed that the O_SYNC flag was present in the open() calls when sync was specified and was clear when sync was not specified.
2013-06-12Update copyright yearsBjörn-Egil Dahlberg
2013-03-04erts: Fix void * arithmeticBjörn-Egil Dahlberg
2013-01-09Add file:allocate/3 operationFilipe David Manana
This operation allows pre-allocation of space for files. It succeeds only on systems that support such operation. The POSIX standard defines the optional system call posix_fallocate() to implement this feature. However, some systems implement more specific functions to accomplish the same operation. On Linux, if the more specific function fallocate() is implemented, it is used instead of posix_fallocate(), falling back to posix_fallocate() if the fallocate() call failed (it's only supported for the ext4, ocfs2, xfs and btrfs file systems at the moment). On Mac OS X it uses the specific fcntl() operation F_PREALLOCATE, falling back to posix_fallocate() if it's available (at the moment Mac OS X doesn't provide posix_fallocate()). On any other UNIX system, it uses posix_fallocate() if it's available. Any other system not providing this system call or any function to pre-allocate space for files, this operation always fails with the ENOTSUP POSIX error.
2012-11-02Fix oracle solaris bug in sendfileLukas Larsson
When using values of sfv_len and sfv_off which are larger than the file in question, sendfilev can sometimes return -1 and send data. It seems to be only Oracle SunOS which this happens on.
2012-07-19erts: Remove VxWorks from driversBjörn-Egil Dahlberg
2012-05-09Correct formating in exit error messagesMichael Santos
Ensure displayed sizes are not negative.
2012-03-30Update copyright yearsBjörn-Egil Dahlberg
2012-03-20Fix bug when sending long files using selectLukas Larsson
The return value from efile_sendfile was not consistent inbetween platforms. The API should now be working as it was intended. OTP-9994
2012-01-23Merge branch 'jz/error-logic-efile_sendfile' into maintHenrik Nord
* jz/error-logic-efile_sendfile: erts: minor fix for unnecessary condition OTP-9872
2012-01-23Merge branch 'jz/sendfile_chunk_size' into maintHenrik Nord
* jz/sendfile_chunk_size: erts: change SENDFILE_CHUNK_SIZE from signed to unsigned Conflicts: erts/emulator/drivers/unix/unix_efile.c OTP-9872
2011-12-20erts: rewrite efile_writev to handle partial writes correctlyRaimo Niskanen
2011-12-09Update copyright yearsBjörn-Egil Dahlberg
2011-12-08Merge branch 'ta/sendfile/OTP-9240'Lukas Larsson
* ta/sendfile/OTP-9240: Do not use async threads on DARWIN Fix cleanup when sendfile process crashes Return {error,closed} from sendfile if closed Do not use SFV_NOWAIT as it does not exist on all solaris Clarify some code comments Make solaris use sendfilev
2011-12-08Fix compiler warning in unix_efile.cBjörn-Egil Dahlberg
2011-12-08unix_efile: Zero is a valid number in utimeBjörn-Egil Dahlberg
Both mtime and atime were incorrectly checked for zero
2011-12-07Do not use SFV_NOWAIT as it does not exist on all solarisLukas Larsson
2011-12-06erts: minor fix for unnecessary conditionJovi Zhang
In "while (retval != -1 && retval == SENDFILE_CHUNK_SIZE)", "retval != -1" is pointless.
2011-12-06erts: change SENDFILE_CHUNK_SIZE from signed to unsignedJovi Zhang
It's reasonable to use UL in SENDFILE_CHUNK_SIZE
2011-12-05Clarify some code commentsLukas Larsson
Thanks Tuncer Ayaz
2011-12-05Make solaris use sendfilevLukas Larsson
sendfilev is a richer API which allows us to do non blocking TCP on solaris. The normal sendfile API seems to have some issue with non blocking sockets and the return value of sendfile.
2011-12-02Use epoch seconds instead of datetime()Björn-Egil Dahlberg
First stage in utc-time for prim_file.
2011-12-02Remove header/trailer supportLukas Larsson
Since the API for headers/trailers seem to be very awkward to work with when using non-blocking io the feature is dropped for now. See unix_efile.c for more details.
2011-12-01Preliminary work on header/trailerLukas Larsson
Have to figure out how to represent progress in header writing when using non-blocking, not sure how to do this.
2011-12-01Remove debug printoutsLukas Larsson
2011-12-01Set chunk size to 3 GBLukas Larsson
It is not possible to use the maximum size_t/off_t for the chunks as that causes sendfile to return einval. 3GB seems to work on all *nix platforms.
2011-12-01Add ifdef's for HAVE_SENDFILELukas Larsson
2011-12-01Fix freebsd support for sendfileLukas Larsson
2011-12-01Change nbytes to 64 bitLukas Larsson
2011-12-01Fix offset calculation for darwinLukas Larsson
2011-12-01Implement sendfile when there are no async threadsLukas Larsson
When there are no async threads sendfile will use the ready_output select on the socket fd to know when to send data. The file_desc will also be put in the sending sendfile_state which buffers all other commands to that file until the sendfile is done.
2011-12-01Implement blocking calls for sendfileLukas Larsson
Move sendfile data to invoke data instead of file_descr. Remove usage of ready_output when doing a send. If told to send 0 bytes, file_sendfile now sends the entire file for linux.
2011-12-01Implement sendfile using blocking io in asynch threadsLukas Larsson
Move the command handling to outputv in preparation for header and trailer inclusion in the sendfile api. Use the standard efile communication functions for sendfile.
2011-11-29Implement file:sendfileTuncer Ayaz
Allow Erlang code to use sendfile() where available by wrapping it as file:sendfile/4 and file:sendfile/2. sendfile(2) - Linux man page: "sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space."
2010-12-17Correct usage of pointer-to-size in unix_efilePatrik Nyblom
2010-11-30Make Unicode filenames work on WindowsPatrik Nyblom
2010-08-17erts: Remove stray pre-ISO-C compatibility macrosBjörn Gustavsson
A long time ago, the Erlang run-time system could be build with pre-ANSI/ISO-C (K&R) C compilers, but that is no longer possible. Remove the remaining uses of the compatibility macros that made it possible that possible.
2010-06-04Support opening files in exclusive modeMichael Santos
Add an option that atomically tests for the existence of a file and creates it if the file does not exist, by passing the O_EXCL flag to open() on Unix and CREATE_NEW flag on Windows. Support for O_EXCL varies across platforms and filesystems. {ok, Fd} = file:open("/tmp/foo", [write,exclusive]), {error, eexist} = file:open("/tmp/foo", [write,exclusive]).
2010-05-20Add file:advise/4 - a wrapper to the POSIX syscall posix_fadviseFilipe David Manana
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.
2010-05-20Add file:datasync/1 for syncing file contents onlyFilipe David Manana
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.
2010-05-02Merge branch 'bg/remove-stray-ose-support' into devErlang/OTP
* bg/remove-stray-ose-support: configure: Remove stray OSE/Delta support Makefiles: Remove stray OSE/Delta support kernel tests: Remove stray OSE/Delta support system tests: Remove stray OSE/Delta support erl_interface tests: Remove stray OSE/Delta support epmd: Remove stray OSE/Delta support epmd: #ifdef out start_epmd() for other platforms than VxWorks emulator tests: Remove stray OSE/Delta support emulator: Remove stray OSE/Delta support emulator: Eliminate #ifdef for sys_tty_reset() test_server: Remove stray support for OSE/Delta OTP-8585 bg/remove-stray-ose-support
2010-04-30emulator: Remove stray OSE/Delta supportBjörn Gustavsson
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP