mirror of https://github.com/vitalif/e2fsprogs
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 <tytso@mit.edu>debian
parent
e695c12892
commit
7719e69a5c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue