Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions plugins/in_tail/tail_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1698,15 +1698,6 @@ int flb_tail_file_chunk(struct flb_tail_file *file)
file_buffer_capacity = (file->buf_size - file->buf_len) - 1;
}

#ifdef __linux__
if (ctx->file_cache_advise) {
if (posix_fadvise(file->fd, 0, 0, POSIX_FADV_DONTNEED) == -1) {
flb_errno();
flb_plg_error(ctx->ins, "error during posix_fadvise");
}
}
#endif

read_size = file_buffer_capacity;

if (file->decompression_context != NULL) {
Expand Down Expand Up @@ -1822,6 +1813,15 @@ int flb_tail_file_chunk(struct flb_tail_file *file)
file->buf_len -= processed_bytes;
file->buf_data[file->buf_len] = '\0';

#ifdef __linux__
/* Evict only the already-processed byte range from the page cache
* so that kernel readahead for upcoming reads is preserved. */
if (ctx->file_cache_advise && file->stream_offset > 0) {
posix_fadvise(file->fd, 0, file->stream_offset,
POSIX_FADV_DONTNEED);
}
#endif

#ifdef FLB_HAVE_SQLDB
if (file->config->db) {
flb_tail_db_file_offset(file, file->config);
Expand Down
Loading