X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Fbench%2Fdumb_backend.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Fbench%2Fdumb_backend.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=5160532fc3e064b4986bb896a1191d5e68aca2e0;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/test/bench/dumb_backend.cc b/src/ceph/src/test/bench/dumb_backend.cc deleted file mode 100644 index 5160532..0000000 --- a/src/ceph/src/test/bench/dumb_backend.cc +++ /dev/null @@ -1,117 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- - -#include "acconfig.h" - -#include -#include "dumb_backend.h" - -string DumbBackend::get_full_path(const string &oid) -{ - return path + "/" + oid; -} - -void DumbBackend::_write( - const string &oid, - uint64_t offset, - const bufferlist &bl, - Context *on_applied, - Context *on_commit) -{ - string full_path(get_full_path(oid)); - int fd = ::open( - full_path.c_str(), O_CREAT|O_WRONLY, 0777); - if (fd < 0) { - std::cout << full_path << ": errno is " << errno << std::endl; - ceph_abort(); - } - - int r = ::lseek(fd, offset, SEEK_SET); - if (r < 0) { - r = errno; - std::cout << "lseek failed, errno is: " << r << std::endl; - ::close(fd); - return; - } - bl.write_fd(fd); - on_applied->complete(0); - if (do_fsync) - ::fsync(fd); -#ifdef HAVE_SYNC_FILE_RANGE - if (do_sync_file_range) - ::sync_file_range(fd, offset, bl.length(), - SYNC_FILE_RANGE_WAIT_AFTER); -#else -# warning "sync_file_range not supported!" -#endif -#ifdef HAVE_POSIX_FADVISE - if (do_fadvise) { - int fa_r = ::posix_fadvise(fd, offset, bl.length(), POSIX_FADV_DONTNEED); - if (fa_r) { - std::cout << "posix_fadvise failed, errno is: " << fa_r << std::endl; - } - } -#else -# warning "posix_fadvise not supported!" -#endif - ::close(fd); - { - Mutex::Locker l(pending_commit_mutex); - pending_commits.insert(on_commit); - } - sem.Put(); -} - -void DumbBackend::read( - const string &oid, - uint64_t offset, - uint64_t length, - bufferlist *bl, - Context *on_complete) -{ - string full_path(get_full_path(oid)); - int fd = ::open( - full_path.c_str(), 0, O_RDONLY); - if (fd < 0) return; - - int r = ::lseek(fd, offset, SEEK_SET); - if (r < 0) { - r = errno; - std::cout << "lseek failed, errno is: " << r << std::endl; - ::close(fd); - return; - } - - bl->read_fd(fd, length); - ::close(fd); - on_complete->complete(0); -} - -void DumbBackend::sync_loop() -{ - while (1) { - sleep(sync_interval); - { - Mutex::Locker l(sync_loop_mutex); - if (sync_loop_stop != 0) { - sync_loop_stop = 2; - sync_loop_cond.Signal(); - break; - } - } - tp.pause(); -#ifdef HAVE_SYS_SYNCFS - ::syncfs(sync_fd); -#else - ::sync(); -#endif - { - Mutex::Locker l(pending_commit_mutex); - for (set::iterator i = pending_commits.begin(); - i != pending_commits.end(); - pending_commits.erase(i++)) { - (*i)->complete(0); - } - } - tp.unpause(); - } -}