From: Sage Weil Date: Thu, 1 Jun 2017 20:47:37 +0000 (-0400) Subject: os/bluestore: implement is_rotational() X-Git-Tag: v12.1.0~249^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=45fceb27de8ccbeb3c3ca9fcba63954420b6025b;p=ceph.git os/bluestore: implement is_rotational() Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 13d1882e80f6..d76ce63bfb98 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4128,6 +4128,38 @@ int BlueStore::_lock_fsid() return 0; } +bool BlueStore::is_rotational() +{ + if (bdev) { + return bdev->is_rotational(); + } + + bool rotational = true; + int r = _open_path(); + if (r < 0) + goto out; + r = _open_fsid(false); + if (r < 0) + goto out_path; + r = _read_fsid(&fsid); + if (r < 0) + goto out_fsid; + r = _lock_fsid(); + if (r < 0) + goto out_fsid; + r = _open_bdev(false); + if (r < 0) + goto out_fsid; + rotational = bdev->is_rotational(); + _close_bdev(); + out_fsid: + _close_fsid(); + out_path: + _close_path(); + out: + return rotational; +} + bool BlueStore::test_mount_in_use() { // most error conditions mean the mount is not in use (e.g., because diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index cc096450c7ed..2b5eabe44b02 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2086,6 +2086,8 @@ public: bool wants_journal() override { return false; }; bool allows_journal() override { return false; }; + bool is_rotational() override; + static int get_block_device_fsid(CephContext* cct, const string& path, uuid_d *fsid);