From: Igor Fedotov Date: Wed, 19 Dec 2018 11:21:03 +0000 (+0300) Subject: os:enable ObjectStore::statfs() api to return OS alert list. X-Git-Tag: v14.1.0~227^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8c74ae6cf244ed319a41a2fb21bac7da0101bf16;p=ceph.git os:enable ObjectStore::statfs() api to return OS alert list. Signed-off-by: Igor Fedotov --- diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 86e070de6c38..6096b494bd6f 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -1558,7 +1558,8 @@ public: return false; // assume a backend cannot, unless it says otherwise } - virtual int statfs(struct store_statfs_t *buf) = 0; + virtual int statfs(struct store_statfs_t *buf, + osd_alert_list_t* alerts = nullptr) = 0; virtual int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) = 0; virtual void collect_metadata(map *pm) { } diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index f52b4868979b..8b0ae602f174 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4361,7 +4361,6 @@ void BlueStore::_init_logger() int BlueStore::_reload_logger() { struct store_statfs_t store_statfs; - int r = statfs(&store_statfs); if (r >= 0) { logger->set(l_bluestore_allocated, store_statfs.allocated); @@ -7987,8 +7986,12 @@ void BlueStore::_get_statfs_overall(struct store_statfs_t *buf) buf->available = bfree; } -int BlueStore::statfs(struct store_statfs_t *buf) +int BlueStore::statfs(struct store_statfs_t *buf, + osd_alert_list_t* alerts) { + if (alerts) { + alerts->clear(); + } _get_statfs_overall(buf); { std::lock_guard l(vstatfs_lock); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index fb717b89b5e1..8bf9f6f5effc 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2474,7 +2474,8 @@ public: string get_device_path(unsigned id); public: - int statfs(struct store_statfs_t *buf) override; + int statfs(struct store_statfs_t *buf, + osd_alert_list_t* alerts = nullptr) override; int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override; void collect_metadata(map *pm) override; @@ -2676,7 +2677,6 @@ private: debug_mdata_error_objects.erase(o); } } - private: // -------------------------------------------------------- diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index ef598d2d03e5..2b391e956d34 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -728,10 +728,13 @@ int FileStore::get_devices(set *ls) return 0; } -int FileStore::statfs(struct store_statfs_t *buf0) +int FileStore::statfs(struct store_statfs_t *buf0, osd_alert_list_t* alerts) { struct statfs buf; buf0->reset(); + if (alerts) { + alerts->clear(); // returns nothing for now + } if (::statfs(basedir.c_str(), &buf) < 0) { int r = -errno; ceph_assert(!m_filestore_fail_eio || r != -EIO); diff --git a/src/os/filestore/FileStore.h b/src/os/filestore/FileStore.h index 0687fcd5c503..f40a97689f85 100644 --- a/src/os/filestore/FileStore.h +++ b/src/os/filestore/FileStore.h @@ -517,7 +517,8 @@ public: void collect_metadata(map *pm) override; int get_devices(set *ls) override; - int statfs(struct store_statfs_t *buf) override; + int statfs(struct store_statfs_t *buf, + osd_alert_list_t* alerts = nullptr) override; int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override; int _do_transactions( diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index e0476c9a2894..2cf82e5efd0f 100644 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -1083,10 +1083,13 @@ void KStore::_sync() dout(10) << __func__ << " done" << dendl; } -int KStore::statfs(struct store_statfs_t* buf0) +int KStore::statfs(struct store_statfs_t* buf0, osd_alert_list_t* alerts) { struct statfs buf; buf0->reset(); + if (alerts) { + alerts->clear(); // returns nothing for now + } if (::statfs(basedir.c_str(), &buf) < 0) { int r = -errno; ceph_assert(r != -ENOENT); diff --git a/src/os/kstore/KStore.h b/src/os/kstore/KStore.h index dc00f7f1cc48..227227fb9be9 100644 --- a/src/os/kstore/KStore.h +++ b/src/os/kstore/KStore.h @@ -439,7 +439,8 @@ public: void get_db_statistics(Formatter *f) override { db->get_statistics(f); } - int statfs(struct store_statfs_t *buf) override; + int statfs(struct store_statfs_t *buf, + osd_alert_list_t* alerts = nullptr) override; int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override; CollectionHandle open_collection(const coll_t& c) override; diff --git a/src/os/memstore/MemStore.cc b/src/os/memstore/MemStore.cc index ea87c80cc84b..d71e335d8b01 100644 --- a/src/os/memstore/MemStore.cc +++ b/src/os/memstore/MemStore.cc @@ -220,9 +220,12 @@ int MemStore::mkfs() return 0; } -int MemStore::statfs(struct store_statfs_t *st) +int MemStore::statfs(struct store_statfs_t *st, osd_alert_list_t* alerts) { - dout(10) << __func__ << dendl; + dout(10) << __func__ << dendl; + if (alerts) { + alerts->clear(); // returns nothing for now + } st->reset(); st->total = cct->_conf->memstore_device_bytes; st->available = std::max(st->total - used_bytes, 0); diff --git a/src/os/memstore/MemStore.h b/src/os/memstore/MemStore.h index 77b2a32c6e7d..b4dad703a2db 100644 --- a/src/os/memstore/MemStore.h +++ b/src/os/memstore/MemStore.h @@ -290,7 +290,8 @@ public: return 0; } - int statfs(struct store_statfs_t *buf) override; + int statfs(struct store_statfs_t *buf, + osd_alert_list_t* alerts = nullptr) override; int pool_statfs(uint64_t pool_id, struct store_statfs_t *buf) override; bool exists(CollectionHandle &c, const ghobject_t& oid) override; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 0444aab500a8..84dd0c7c41c3 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2993,7 +2993,8 @@ int OSD::init() // prime osd stats { struct store_statfs_t stbuf; - int r = store->statfs(&stbuf); + osd_alert_list_t alerts; + int r = store->statfs(&stbuf, &alerts); ceph_assert(r == 0); service.set_statfs(stbuf); } @@ -3937,7 +3938,8 @@ int OSD::update_crush_location() snprintf(weight, sizeof(weight), "%.4lf", cct->_conf->osd_crush_initial_weight); } else { struct store_statfs_t st; - int r = store->statfs(&st); + osd_alert_list_t alerts; + int r = store->statfs(&st, &alerts); if (r < 0) { derr << "statfs: " << cpp_strerror(r) << dendl; return r; @@ -5279,7 +5281,8 @@ void OSD::tick_without_osd_lock() // refresh osd stats struct store_statfs_t stbuf; - int r = store->statfs(&stbuf); + osd_alert_list_t alerts; + int r = store->statfs(&stbuf, &alerts); ceph_assert(r == 0); service.set_statfs(stbuf); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 41a9f62a9cba..faae78bed8d8 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -112,6 +112,7 @@ string ceph_osd_op_flag_string(unsigned flags); /// conver CEPH_OSD_ALLOC_HINT_FLAG_* op flags to a string string ceph_osd_alloc_hint_flag_string(unsigned flags); +typedef map osd_alert_list_t; /** * osd request identifier