Whamcloud - gitweb
e4defrag: fix build failure if libc doesn't have sync_file_range()
authorTheodore Ts'o <tytso@mit.edu>
Sun, 6 Sep 2015 02:18:29 +0000 (22:18 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 6 Sep 2015 02:18:29 +0000 (22:18 -0400)
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 <tytso@mit.edu>
misc/e4defrag.c

index 3f949d0..1d1b4f4 100644 (file)
@@ -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