comparison src/core/ngx_open_file_cache.c @ 3178:975f0558aab3

read_ahead
author Igor Sysoev <igor@sysoev.ru>
date Wed, 30 Sep 2009 13:21:52 +0000
parents b1b1775698d5
children ac281bc4c187
comparison
equal deleted inserted replaced
3177:adc4fc0c3cc3 3178:975f0558aab3
13 * open file cache caches 13 * open file cache caches
14 * open file handles with stat() info; 14 * open file handles with stat() info;
15 * directories stat() info; 15 * directories stat() info;
16 * files and directories errors: not found, access denied, etc. 16 * files and directories errors: not found, access denied, etc.
17 */ 17 */
18
19
20 #define NGX_MIN_READ_AHEAD (128 * 1024)
18 21
19 22
20 static void ngx_open_file_cache_cleanup(void *data); 23 static void ngx_open_file_cache_cleanup(void *data);
21 static ngx_int_t ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, 24 static ngx_int_t ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of,
22 ngx_log_t *log); 25 ngx_log_t *log);
522 of->fd = NGX_INVALID_FILE; 525 of->fd = NGX_INVALID_FILE;
523 526
524 } else { 527 } else {
525 of->fd = fd; 528 of->fd = fd;
526 529
530 if (of->read_ahead && ngx_file_size(&fi) > NGX_MIN_READ_AHEAD) {
531 if (ngx_read_ahead(fd, of->read_ahead) == NGX_ERROR) {
532 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
533 ngx_read_ahead_n " \"%s\" failed", name);
534 }
535 }
536
527 if (of->directio <= ngx_file_size(&fi)) { 537 if (of->directio <= ngx_file_size(&fi)) {
528 if (ngx_directio_on(fd) == NGX_FILE_ERROR) { 538 if (ngx_directio_on(fd) == NGX_FILE_ERROR) {
529 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, 539 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
530 ngx_directio_on_n " \"%s\" failed", name); 540 ngx_directio_on_n " \"%s\" failed", name);
531 541