return true;
}
+ /**
+ * is_journal_rotational
+ *
+ * Check whether journal is backed by a rotational (HDD) or non-rotational
+ * (SSD) device.
+ *
+ *
+ * @return true for HDD, false for SSD
+ */
+ virtual bool is_journal_rotational() {
+ return true;
+ }
+
virtual string get_default_device_class() {
return is_rotational() ? "hdd" : "ssd";
}
_drop_link(file);
return 0;
}
+
+bool BlueFS::wal_is_rotational()
+{
+ if (!bdev[BDEV_WAL] || bdev[BDEV_WAL]->is_rotational())
+ return true;
+ return false;
+}
int unlink(const string& dirname, const string& filename);
int mkdir(const string& dirname);
int rmdir(const string& dirname);
+ bool wal_is_rotational();
bool dir_exists(const string& dirname);
int stat(const string& dirname, const string& filename,
return rotational;
}
+bool BlueStore::is_journal_rotational()
+{
+ assert(bluefs);
+ dout(10) << __func__ << " " << (int)bluefs->wal_is_rotational() << dendl;
+ return bluefs->wal_is_rotational();
+}
+
bool BlueStore::test_mount_in_use()
{
// most error conditions mean the mount is not in use (e.g., because
bool allows_journal() override { return false; };
bool is_rotational() override;
+ bool is_journal_rotational() override;
string get_default_device_class() override {
string device_class;
return rotational;
}
+bool FileStore::is_journal_rotational()
+{
+ bool journal_rotational;
+ if (backend) {
+ journal_rotational = backend->is_journal_rotational();
+ } else {
+ int fd = ::open(journalpath.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);
+ journal_rotational = backend->is_journal_rotational();
+ delete backend;
+ backend = NULL;
+ }
+ dout(10) << __func__ << " " << (int)journal_rotational << dendl;
+ return journal_rotational;
+}
+
int FileStore::_detect_fs()
{
struct statfs st;
}
bool is_rotational() override;
+ bool is_journal_rotational() override;
void dump_perf_counters(Formatter *f) override {
f->open_object_section("perf_counters");
const string& get_basedir_path() {
return filestore->basedir;
}
+ const string& get_journal_path() {
+ return filestore->journalpath;
+ }
const string& get_current_path() {
return filestore->current_fn;
}
virtual bool has_fiemap() = 0;
virtual bool has_seek_data_hole() = 0;
virtual bool is_rotational() = 0;
+ virtual bool is_journal_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;
}
::close(fd);
}
+ // journal rotational?
+ {
+ // NOTE: the below won't work on btrfs; we'll assume rotational.
+ string fn = get_journal_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 journal device name for "
+ << get_journal_path() << ": " << cpp_strerror(r) << dendl;
+ m_journal_rotational = true;
+ } else {
+ m_journal_rotational = block_device_is_rotational(devname);
+ dout(20) << __func__ << " journal devname " << devname
+ << " journal rotational " << (int)m_journal_rotational << dendl;
+ }
+ ::close(fd);
+ }
}
int GenericFileStoreBackend::detect_features()
bool m_filestore_fsync_flushes_journal_data;
bool m_filestore_splice;
bool m_rotational = true;
+ bool m_journal_rotational = true;
public:
explicit GenericFileStoreBackend(FileStore *fs);
~GenericFileStoreBackend() override {}
bool is_rotational() override {
return m_rotational;
}
+ bool is_journal_rotational() override {
+ return m_journal_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; }
dout(2) << "init " << dev_path
<< " (looks like " << (store_is_rotational ? "hdd" : "ssd") << ")"
<< dendl;
+ dout(2) << "journal " << journal_path << dendl;
assert(store); // call pre_init() first!
store->set_cache_shards(get_num_op_shards());
derr << "OSD:init: unable to mount object store" << dendl;
return r;
}
+ journal_is_rotational = store->is_journal_rotational();
+ dout(2) << "journal looks like " << (journal_is_rotational ? "hdd" : "ssd")
+ << dendl;
enable_disable_fuse(false);
// backend
(*pm)["osd_objectstore"] = store->get_type();
(*pm)["rotational"] = store_is_rotational ? "1" : "0";
+ (*pm)["journal_rotational"] = journal_is_rotational ? "1" : "0";
(*pm)["default_device_class"] = store->get_default_device_class();
store->collect_metadata(pm);
std::string dev_path, journal_path;
bool store_is_rotational = true;
+ bool journal_is_rotational = true;
ZTracer::Endpoint trace_endpoint;
void create_logger();