From: Jianpeng Ma Date: Mon, 1 Dec 2014 02:38:00 +0000 (+0800) Subject: FileStore: Implement fadvise handle for read-operation. X-Git-Tag: v0.91~55^2~3^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c9d15b0aa3052f44d5c5af8bc8aee5ced32ef2e5;p=ceph.git FileStore: Implement fadvise handle for read-operation. Signed-off-by: Jianpeng Ma --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 7812b924b2487..84f512c651f98 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -2819,6 +2819,13 @@ int FileStore::read( len = st.st_size; } +#ifdef HAVE_POSIX_FADVISE + if (op_flags & CEPH_OSD_OP_FLAG_FADVISE_RANDOM) + posix_fadvise(**fd, offset, len, POSIX_FADV_RANDOM); + if (op_flags & CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL) + posix_fadvise(**fd, offset, len, POSIX_FADV_SEQUENTIAL); +#endif + bufferptr bptr(len); // prealloc space for entire read got = safe_pread(**fd, bptr.c_str(), len, offset); if (got < 0) { @@ -2830,6 +2837,13 @@ int FileStore::read( bptr.set_length(got); // properly size the buffer bl.push_back(bptr); // put it in the target bufferlist +#ifdef HAVE_POSIX_FADVISE + if (op_flags & CEPH_OSD_OP_FLAG_FADVISE_DONTNEED) + posix_fadvise(**fd, offset, len, POSIX_FADV_DONTNEED); + if (op_flags & (CEPH_OSD_OP_FLAG_FADVISE_RANDOM | CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL)) + posix_fadvise(**fd, offset, len, POSIX_FADV_NORMAL); +#endif + if (m_filestore_sloppy_crc && (!replaying || backend->can_checkpoint())) { ostringstream ss; int errors = backend->_crc_verify_read(**fd, offset, got, bl, &ss);