summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix/ngx_files.h (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-06-22Cache: introduced min_free cache clearing.Maxim Dounin1-0/+1
Clearing cache based on free space left on a file system is expected to allow better disk utilization in some cases, notably when disk space might be also used for something other than nginx cache (including nginx own temporary files) and while loading cache (when cache size might be inaccurate for a while, effectively disabling max_size cache clearing). Based on a patch by Adam Bambuch.
2020-06-22Too large st_blocks values are now ignored (ticket #157).Maxim Dounin1-1/+4
With XFS, using "allocsize=64m" mount option results in large preallocation being reported in the st_blocks as returned by fstat() till the file is closed. This in turn results in incorrect cache size calculations and wrong clearing based on max_size. To avoid too aggressive cache clearing on such volumes, st_blocks values which result in sizes larger than st_size and eight blocks (an arbitrary limit) are no longer trusted, and we use st_size instead. The ngx_de_fs_size() counterpart is intentionally not modified, as it is used on closed files and hence not affected by this problem.
2018-12-24Win32: removed NGX_DIR_MASK concept.Maxim Dounin1-3/+0
Previous interface of ngx_open_dir() assumed that passed directory name has a room for NGX_DIR_MASK at the end (NGX_DIR_MASK_LEN bytes). While all direct users of ngx_dir_open() followed this interface, this also implied similar requirements for indirect uses - in particular, via ngx_walk_tree(). Currently none of ngx_walk_tree() uses provides appropriate space, and fixing this does not look like a right way to go. Instead, ngx_dir_open() interface was changed to not require any additional space and use appropriate allocations instead.
2016-03-18Threads: offloading of temp files writing to thread pools.Maxim Dounin1-0/+2
The ngx_thread_write_chain_to_file() function introduced, which uses ngx_file_t thread_handler, thread_ctx and thread_task fields. The task context structure (ngx_thread_file_ctx_t) is the same for both reading and writing, and can be safely shared as long as operations are serialized. The task->handler field is now always set (and not only when task is allocated), as the same task can be used with different handlers. The thread_write flag is introduced in the ngx_temp_file_t structure to explicitly enable use of ngx_thread_write_chain_to_file() in ngx_write_chain_to_temp_file() when supported by caller. In collaboration with Valentin Bartenev.
2016-03-18Threads: task pointer stored in ngx_file_t.Maxim Dounin1-2/+2
This simplifies the interface of the ngx_thread_read() function. Additionally, most of the thread operations now explicitly set file->thread_task, file->thread_handler and file->thread_ctx, to facilitate use of thread operations in other places. (Potential problems remain with sendfile in threads though - it uses file->thread_handler as set in ngx_output_chain(), and it should not be overwritten to an incompatible one.) In collaboration with Valentin Bartenev.
2015-06-16Core: added support for writing to stdout.Vladimir Homutov1-0/+1
2015-03-14Added support for offloading read() in thread pools.Valentin Bartenev1-0/+5
2015-02-11Refactored sendfile() AIO preload.Valentin Bartenev1-0/+1
This reduces layering violation and simplifies the logic of AIO preread, since it's now triggered by the send chain function itself without falling back to the copy filter. The context of AIO operation is now stored per file buffer, which makes it possible to properly handle cases when multiple buffers come from different locations, each with its own configuration.
2014-03-31Added #ifndef around NGX_HAVE_CASELESS_FILESYSTEM define.Maxim Dounin1-0/+2
This brings Cygwin compilation in line with other case-insensitive systems (notably win32 and OS X) where one can force case sensitivity using -DNGX_HAVE_CASELESS_FILESYSTEM=0.
2013-09-23Added ngx_filename_cmp() with "/" sorted to the left.Maxim Dounin1-11/+0
This patch fixes incorrect handling of auto redirect in configurations like: location /0 { } location /a- { } location /a/ { proxy_pass ... } With previously used sorting, this resulted in the following locations tree (as "-" is less than "/"): "/a-" "/0" "/a/" and a request to "/a" didn't match "/a/" with auto_redirect, as it didn't traverse relevant tree node during lookup (it tested "/a-", then "/0", and then falled back to null location). To preserve locale use for non-ASCII characters on case-insensetive systems, libc's tolower() used.
2013-09-02Disable symlinks: use O_PATH to open path components.Valentin Bartenev1-0/+3
It was introduced in Linux 2.6.39, glibc 2.14 and allows to obtain file descriptors without actually opening files. Thus made it possible to traverse path with openat() syscalls without the need to have read permissions for path components. It is effectively emulates O_SEARCH which is missing on Linux. O_PATH is used in combination with O_RDONLY. The last one is ignored if O_PATH is used, but it allows nginx to not fail when it was built on modern system (i.e. glibc 2.14+) and run with a kernel older than 2.6.39. Then O_PATH is unknown to the kernel and ignored, while O_RDONLY is used. Sadly, fstat() is not working with O_PATH descriptors till Linux 3.6. As a workaround we fallback to fstatat() with the AT_EMPTY_PATH flag that was introduced at the same time as O_PATH.
2013-07-05Make macros safe.Gleb Smirnoff1-5/+5
2012-03-27Fixed unconditional MAX_PATH usage (ticket #22).Maxim Dounin1-1/+12
POSIX doesn't require it to be defined, and Debian GNU/Hurd doesn't define it. Note that if there is no MAX_PATH defined we have to use realpath() with NULL argument and free() the result.
2012-02-28Workaround for fs_size on ZFS (ticket #46).Maxim Dounin1-2/+3
ZFS reports incorrect st_blocks until file settles on disk, and this may take a while (i.e. just after creation of a file the st_blocks value is incorrect). As a workaround we now use st_blocks only if st_blocks * 512 > st_size, this should fix ZFS problems while still preserving accuracy for other filesystems. The problem had appeared in r3900 (1.0.1).
2012-02-21Disable symlinks: use O_SEARCH|O_DIRECTORY to open path components.Valentin Bartenev1-0/+17
2012-02-20Disable symlinks: added explicit cast of AT_FDCWD (ticket #111).Maxim Dounin1-0/+2
Solaris has AT_FDCWD defined to unsigned value, and comparison of a file descriptor with it causes warnings in modern versions of gcc. Explicitly cast AT_FDCWD to ngx_fd_t to resolve these warnings.
2012-02-13Added openat()/fstatat().Andrey Belov1-0/+19
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-11-14Introduction of simple ngx_write_stderr() instead of ngx_log_stderr()Igor Sysoev1-0/+1
for output of ./configure options, etc., since ngx_log_stderr() output length is limited by 2048 characters defined as NGX_MAX_ERROR_STR.
2011-07-24elimination of reading cache files by cache loaderIgor Sysoev1-0/+1
2011-04-22Use more precise stat.st_blocks to account cache size on UnixIgor Sysoev1-0/+1
instead of file length rounded to a file system block size. There is no similar way on Windows, so rounding to a cache->bsize is kept.
2010-06-29ngx_create_file_mapping()Igor Sysoev1-0/+13
2010-04-22use lstat() for WebDAV DELETE, COPY, and MOVE to handle symlinksIgor Sysoev1-0/+3
2010-04-21use non-blocking open() not to hang on FIFO files, etc.Igor Sysoev1-0/+1
2009-11-15fix posix_fadvise() error handlingIgor Sysoev1-1/+1
2009-11-05export aio presence knowledge to prevent using "aio sendfile",Igor Sysoev1-0/+2
if aio does not present
2009-11-03fix "if (!-x ...)"Igor Sysoev1-1/+1
2009-10-14*) reset cached dirent.d_type after stat()Igor Sysoev1-14/+13
this fixes slash after link to a directory in ngx_http_autoindex_module; *) use cached dirent.d_type as hint on all systems the issues has been introduced in r2235
2009-09-30read_aheadIgor Sysoev1-0/+22
2009-08-28FreeBSD and Linux AIO supportIgor Sysoev1-0/+8
2009-06-11style fixIgor Sysoev1-6/+6
2009-04-28introduce ngx_write_console() to support OEM code pagesIgor Sysoev1-0/+4
2009-04-27-p and --prefix=Igor Sysoev1-1/+1
2009-04-23ngx_path_separator()Igor Sysoev1-0/+2
2009-04-23issue start up errors and warning on both stderr and error_logIgor Sysoev1-1/+5
2009-04-08adopt NGX_FILE_TRUNCATE for win32Igor Sysoev1-1/+1
2009-03-31Win32 appends synchronized if only FILE_APPEND_DATA and SYNCHRONIZE are setIgor Sysoev1-1/+1
without any other flags. On the other hand, Unix requires at least the write flag to be set together with O_APPEND.
2009-03-30ngx_fs_bsize()Igor Sysoev1-0/+3
2009-03-23a prelimiary proxy cache supportIgor Sysoev1-0/+1
2009-03-06XFS on Linux does not set dirent.d_type,Igor Sysoev1-0/+15
therefore fallback to stat() if dirent.d_type is not set, this fixes slash after directory name in ngx_http_autoindex_module; the issue has been introduced in r2235
2008-11-11compatibility with glibc 2.3, warn_unused_result attribute for write()Igor Sysoev1-1/+11
2008-09-27$realpath_rootIgor Sysoev1-0/+2
2008-09-12disable directio for unaligned reads in LinuxIgor Sysoev1-8/+11
2008-09-05*) autoconfigure struct dirent capabilitiesIgor Sysoev1-12/+39
*) move src/os/.../ngx_types.h's content into src/os/.../ngx_files.h and delete src/os/.../ngx_types.h
2008-09-05style fixIgor Sysoev1-5/+5
2008-08-15fix log messageIgor Sysoev1-0/+4
2008-08-04Solaris directio()Igor Sysoev1-0/+5
2008-07-30directioIgor Sysoev1-0/+18
2008-07-29case insensitive file system location support provided by locale onlyIgor Sysoev1-0/+12
2008-04-29ignore glob no match errorIgor Sysoev1-4/+5