From: Jianpeng Ma Date: Mon, 16 May 2016 11:27:57 +0000 (+0800) Subject: common/blkdev: Add new api block_device_is_rotational. X-Git-Tag: v11.0.0~376^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5d4566e7bd655cb2715ae2d900431ceedbfa26b5;p=ceph.git common/blkdev: Add new api block_device_is_rotational. It use to judge device whether rotational device. Signed-off-by: Jianpeng Ma --- diff --git a/src/common/blkdev.cc b/src/common/blkdev.cc index 3a1a398b1ee..6df48656f84 100644 --- a/src/common/blkdev.cc +++ b/src/common/blkdev.cc @@ -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) { diff --git a/src/common/blkdev.h b/src/common/blkdev.h index 697e8a848ea..e37f5694e84 100644 --- a/src/common/blkdev.h +++ b/src/common/blkdev.h @@ -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);