In lfs_mirror_extend() use buffered IO to read from the source
file. Mirror resync will continue to use direct IO on the source.
Call posix_fadvise() at the end of mirroring to discard cached data
from the old and new mirrors.
Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Change-Id: I7703ae9e30cf30a7e6fbf274114d5986a80d4d3a
Reviewed-on: https://review.whamcloud.com/40275
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Patrick Farrell <farr0186@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
if (check_file) {
rc = check_file(fd_src);
if (rc < 0)
if (check_file) {
rc = check_file(fd_src);
if (rc < 0)
}
rsize = read(fd_src, buf, buf_size);
if (rsize < 0) {
rc = -errno;
}
rsize = read(fd_src, buf, buf_size);
if (rsize < 0) {
rc = -errno;
rpos += rsize;
bufoff = 0;
}
rpos += rsize;
bufoff = 0;
}
/* eof ? */
if (rsize == 0)
break;
/* eof ? */
if (rsize == 0)
break;
- if (rc == 0) {
- rc = fsync(fd_dst);
- if (rc < 0)
- rc = -errno;
- }
+ rc = fsync(fd_dst);
+ if (rc < 0)
+ rc = -errno;
+out:
+ /* Try to avoid page cache pollution after migration. */
+ (void)posix_fadvise(fd_src, 0, 0, POSIX_FADV_DONTNEED);
+ (void)posix_fadvise(fd_dst, 0, 0, POSIX_FADV_DONTNEED);
}
}
llapi_layout_comp_flags_set(m_layout, flags);
}
}
llapi_layout_comp_flags_set(m_layout, flags);
- rc = migrate_open_files(name, 0, NULL, m_layout, &fd, &fdv);
+ rc = migrate_open_files(name, MIGRATION_NONDIRECT, NULL, m_layout, &fd,
+ &fdv);