]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/blkdev: Add new api block_device_is_rotational.
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 16 May 2016 11:27:57 +0000 (19:27 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 24 May 2016 12:04:12 +0000 (20:04 +0800)
It use to judge device whether rotational device.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/common/blkdev.cc
src/common/blkdev.h

index 3a1a398b1ee5d3452b0e3d112683ba056f4f57ec..6df48656f840a6dc544234eeaee15e9e4f88e960 100644 (file)
@@ -185,6 +185,11 @@ int block_device_discard(int fd, int64_t offset, int64_t len)
   return ioctl(fd, BLKDISCARD, range);
 }
 
+bool block_device_is_rotational(const char *devname)
+{
+  return get_block_device_int_property(devname, "rotational") > 0;
+}
+
 int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition,
        char* device)
 {
@@ -251,6 +256,11 @@ int block_device_discard(int fd, int64_t offset, int64_t len)
   return -EOPNOTSUPP;
 }
 
+bool block_device_is_rotational(const char *devname)
+{
+  return false;
+}
+
 int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition,
        char* device)
 {
@@ -277,6 +287,11 @@ int block_device_discard(int fd, int64_t offset, int64_t len)
   return -EOPNOTSUPP;
 }
 
+bool block_device_is_rotational(const char *devname)
+{
+  return false;
+}
+
 int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition,
        char* device)
 {
@@ -298,6 +313,11 @@ int block_device_discard(int fd, int64_t offset, int64_t len)
   return -EOPNOTSUPP;
 }
 
+bool block_device_is_rotational(const char *devname)
+{
+  return false;
+}
+
 int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition,
        char* device)
 {
index 697e8a848eafd3999cebfdf84ab1b3d204881e98..e37f5694e84a79987fcbf4a196635242ea18e52c 100644 (file)
@@ -8,6 +8,7 @@ extern int get_block_device_base(const char *dev, char *out, size_t out_len);
 extern int get_block_device_size(int fd, int64_t *psize);
 extern int64_t get_block_device_int_property(const char *devname, const char *property);
 extern bool block_device_support_discard(const char *devname);
+extern bool block_device_is_rotational(const char *devname);
 extern int block_device_discard(int fd, int64_t offset, int64_t len);
 extern int get_device_by_uuid(uuid_d dev_uuid, const char* label,
                char* partition, char* device);