return inuse;
}
+bool FileStore::is_rotational()
+{
+ bool rotational;
+ if (backend) {
+ rotational = backend->is_rotational();
+ } else {
+ int fd = ::open(basedir.c_str(), O_RDONLY);
+ if (fd < 0)
+ return true;
+ struct statfs st;
+ int r = ::fstatfs(fd, &st);
+ ::close(fd);
+ if (r < 0) {
+ return true;
+ }
+ create_backend(st.f_type);
+ rotational = backend->is_rotational();
+ delete backend;
+ backend = NULL;
+ }
+ dout(10) << __func__ << " " << (int)rotational << dendl;
+ return rotational;
+}
+
int FileStore::_detect_fs()
{
struct statfs st;
bool needs_journal() override {
return false;
}
+
+ bool is_rotational() override;
+
void dump_perf_counters(Formatter *f) override {
f->open_object_section("perf_counters");
logger->dump_formatted(f, false);
virtual int syncfs() = 0;
virtual bool has_fiemap() = 0;
virtual bool has_seek_data_hole() = 0;
+ virtual bool is_rotational() = 0;
virtual int do_fiemap(int fd, off_t start, size_t len, struct fiemap **pfiemap) = 0;
virtual int clone_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff) = 0;
virtual int set_alloc_hint(int fd, uint64_t hint) = 0;
#include "common/errno.h"
#include "common/config.h"
#include "common/sync_filesystem.h"
+#include "common/blkdev.h"
#include "common/SloppyCRCMap.h"
#include "os/filestore/chain_xattr.h"
m_filestore_fiemap(cct()->_conf->filestore_fiemap),
m_filestore_seek_data_hole(cct()->_conf->filestore_seek_data_hole),
m_filestore_fsync_flushes_journal_data(cct()->_conf->filestore_fsync_flushes_journal_data),
- m_filestore_splice(cct()->_conf->filestore_splice) {}
+ m_filestore_splice(cct()->_conf->filestore_splice)
+{
+ // rotational?
+ {
+ // NOTE: the below won't work on btrfs; we'll assume rotational.
+ string fn = get_basedir_path();
+ int fd = ::open(fn.c_str(), O_RDONLY);
+ if (fd < 0) {
+ return;
+ }
+ char partition[PATH_MAX], devname[PATH_MAX];
+ int r = get_device_by_fd(fd, partition, devname, sizeof(devname));
+ if (r < 0) {
+ dout(1) << "unable to get device name for " << get_basedir_path() << ": "
+ << cpp_strerror(r) << dendl;
+ m_rotational = true;
+ } else {
+ m_rotational = block_device_is_rotational(devname);
+ dout(20) << __func__ << " devname " << devname
+ << " rotational " << (int)m_rotational << dendl;
+ }
+ ::close(fd);
+ }
+}
int GenericFileStoreBackend::detect_features()
{
bool m_filestore_seek_data_hole;
bool m_filestore_fsync_flushes_journal_data;
bool m_filestore_splice;
+ bool m_rotational = true;
public:
explicit GenericFileStoreBackend(FileStore *fs);
~GenericFileStoreBackend() override {}
int detect_features() override;
int create_current() override;
bool can_checkpoint() override { return false; }
+ bool is_rotational() override {
+ return m_rotational;
+ }
int list_checkpoints(list<string>& ls) override { return 0; }
int create_checkpoint(const string& name, uint64_t *cid) override { return -EOPNOTSUPP; }
int sync_checkpoint(uint64_t id) override { return -EOPNOTSUPP; }