From 7719e69a5c3308f383babb9abde7cf60ebec0027 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 5 Sep 2015 22:18:29 -0400 Subject: [PATCH] e4defrag: fix build failure if libc doesn't have sync_file_range() The posix_fadvise() to hint to the system that the file can be removed from memory will probably not work well without the sync_file_range(2) call, but e4defrag should still fundamentally work, and this will allow e4defrag to compile if the C library doesn't happen this system call exposed. Signed-off-by: Theodore Ts'o --- misc/e4defrag.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/misc/e4defrag.c b/misc/e4defrag.c index 3f949d08..1d1b4f41 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -193,10 +193,6 @@ static struct frag_statistic_ino frag_rank[SHOW_FRAG_FILES]; #error posix_fadvise not available! #endif -#ifndef HAVE_SYNC_FILE_RANGE -#error sync_file_range not available! -#endif /* ! HAVE_SYNC_FILE_RANGE */ - #ifndef HAVE_FALLOCATE64 #error fallocate64 not available! #endif /* ! HAVE_FALLOCATE64 */ @@ -428,10 +424,12 @@ static int defrag_fadvise(int fd, struct move_extent defrag_data, offset = (loff_t)defrag_data.orig_start * block_size; offset = (offset / pagesize) * pagesize; +#ifdef HAVE_SYNC_FILE_RANGE /* Sync file for fadvise process */ if (sync_file_range(fd, offset, (loff_t)pagesize * page_num, sync_flag) < 0) return -1; +#endif /* Try to release buffer cache which this process used, * then other process can use the released buffer