aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-bus-rbd7
-rw-r--r--drivers/block/rbd.c43
2 files changed, 48 insertions, 2 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-rbd b/Documentation/ABI/testing/sysfs-bus-rbd
index 6fe4224cc5bd..1cf2adf46b11 100644
--- a/Documentation/ABI/testing/sysfs-bus-rbd
+++ b/Documentation/ABI/testing/sysfs-bus-rbd
@@ -25,6 +25,10 @@ client_id
25 25
26 The ceph unique client id that was assigned for this specific session. 26 The ceph unique client id that was assigned for this specific session.
27 27
28features
29
30 A hexadecimal encoding of the feature bits for this image.
31
28major 32major
29 33
30 The block device major number. 34 The block device major number.
@@ -78,4 +82,7 @@ snap_size
78 82
79 The size of the image when this snapshot was taken. 83 The size of the image when this snapshot was taken.
80 84
85snap_features
86
87 A hexadecimal encoding of the feature bits for this snapshot.
81 88
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 8ac193ff4849..463f8b264c6f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -85,6 +85,7 @@
85struct rbd_image_header { 85struct rbd_image_header {
86 /* These four fields never change for a given rbd image */ 86 /* These four fields never change for a given rbd image */
87 char *object_prefix; 87 char *object_prefix;
88 u64 features;
88 __u8 obj_order; 89 __u8 obj_order;
89 __u8 crypt_type; 90 __u8 crypt_type;
90 __u8 comp_type; 91 __u8 comp_type;
@@ -148,12 +149,14 @@ struct rbd_snap {
148 u64 size; 149 u64 size;
149 struct list_head node; 150 struct list_head node;
150 u64 id; 151 u64 id;
152 u64 features;
151}; 153};
152 154
153struct rbd_mapping { 155struct rbd_mapping {
154 char *snap_name; 156 char *snap_name;
155 u64 snap_id; 157 u64 snap_id;
156 u64 size; 158 u64 size;
159 u64 features;
157 bool snap_exists; 160 bool snap_exists;
158 bool read_only; 161 bool read_only;
159}; 162};
@@ -590,6 +593,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
590 header->snap_sizes = NULL; 593 header->snap_sizes = NULL;
591 } 594 }
592 595
596 header->features = 0; /* No features support in v1 images */
593 header->obj_order = ondisk->options.order; 597 header->obj_order = ondisk->options.order;
594 header->crypt_type = ondisk->options.crypt_type; 598 header->crypt_type = ondisk->options.crypt_type;
595 header->comp_type = ondisk->options.comp_type; 599 header->comp_type = ondisk->options.comp_type;
@@ -632,6 +636,7 @@ static int snap_by_name(struct rbd_device *rbd_dev, const char *snap_name)
632 if (!strcmp(snap_name, snap->name)) { 636 if (!strcmp(snap_name, snap->name)) {
633 rbd_dev->mapping.snap_id = snap->id; 637 rbd_dev->mapping.snap_id = snap->id;
634 rbd_dev->mapping.size = snap->size; 638 rbd_dev->mapping.size = snap->size;
639 rbd_dev->mapping.features = snap->features;
635 640
636 return 0; 641 return 0;
637 } 642 }
@@ -648,6 +653,7 @@ static int rbd_dev_set_mapping(struct rbd_device *rbd_dev, char *snap_name)
648 sizeof (RBD_SNAP_HEAD_NAME))) { 653 sizeof (RBD_SNAP_HEAD_NAME))) {
649 rbd_dev->mapping.snap_id = CEPH_NOSNAP; 654 rbd_dev->mapping.snap_id = CEPH_NOSNAP;
650 rbd_dev->mapping.size = rbd_dev->header.image_size; 655 rbd_dev->mapping.size = rbd_dev->header.image_size;
656 rbd_dev->mapping.features = rbd_dev->header.features;
651 rbd_dev->mapping.snap_exists = false; 657 rbd_dev->mapping.snap_exists = false;
652 rbd_dev->mapping.read_only = rbd_dev->rbd_opts.read_only; 658 rbd_dev->mapping.read_only = rbd_dev->rbd_opts.read_only;
653 ret = 0; 659 ret = 0;
@@ -1835,6 +1841,19 @@ static ssize_t rbd_size_show(struct device *dev,
1835 return sprintf(buf, "%llu\n", (unsigned long long) size * SECTOR_SIZE); 1841 return sprintf(buf, "%llu\n", (unsigned long long) size * SECTOR_SIZE);
1836} 1842}
1837 1843
1844/*
1845 * Note this shows the features for whatever's mapped, which is not
1846 * necessarily the base image.
1847 */
1848static ssize_t rbd_features_show(struct device *dev,
1849 struct device_attribute *attr, char *buf)
1850{
1851 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
1852
1853 return sprintf(buf, "0x%016llx\n",
1854 (unsigned long long) rbd_dev->mapping.features);
1855}
1856
1838static ssize_t rbd_major_show(struct device *dev, 1857static ssize_t rbd_major_show(struct device *dev,
1839 struct device_attribute *attr, char *buf) 1858 struct device_attribute *attr, char *buf)
1840{ 1859{
@@ -1884,6 +1903,10 @@ static ssize_t rbd_image_id_show(struct device *dev,
1884 return sprintf(buf, "%s\n", rbd_dev->image_id); 1903 return sprintf(buf, "%s\n", rbd_dev->image_id);
1885} 1904}
1886 1905
1906/*
1907 * Shows the name of the currently-mapped snapshot (or
1908 * RBD_SNAP_HEAD_NAME for the base image).
1909 */
1887static ssize_t rbd_snap_show(struct device *dev, 1910static ssize_t rbd_snap_show(struct device *dev,
1888 struct device_attribute *attr, 1911 struct device_attribute *attr,
1889 char *buf) 1912 char *buf)
@@ -1907,6 +1930,7 @@ static ssize_t rbd_image_refresh(struct device *dev,
1907} 1930}
1908 1931
1909static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL); 1932static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL);
1933static DEVICE_ATTR(features, S_IRUGO, rbd_features_show, NULL);
1910static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL); 1934static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL);
1911static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL); 1935static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL);
1912static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL); 1936static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL);
@@ -1918,6 +1942,7 @@ static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
1918 1942
1919static struct attribute *rbd_attrs[] = { 1943static struct attribute *rbd_attrs[] = {
1920 &dev_attr_size.attr, 1944 &dev_attr_size.attr,
1945 &dev_attr_features.attr,
1921 &dev_attr_major.attr, 1946 &dev_attr_major.attr,
1922 &dev_attr_client_id.attr, 1947 &dev_attr_client_id.attr,
1923 &dev_attr_pool.attr, 1948 &dev_attr_pool.attr,
@@ -1971,12 +1996,24 @@ static ssize_t rbd_snap_id_show(struct device *dev,
1971 return sprintf(buf, "%llu\n", (unsigned long long)snap->id); 1996 return sprintf(buf, "%llu\n", (unsigned long long)snap->id);
1972} 1997}
1973 1998
1999static ssize_t rbd_snap_features_show(struct device *dev,
2000 struct device_attribute *attr,
2001 char *buf)
2002{
2003 struct rbd_snap *snap = container_of(dev, struct rbd_snap, dev);
2004
2005 return sprintf(buf, "0x%016llx\n",
2006 (unsigned long long) snap->features);
2007}
2008
1974static DEVICE_ATTR(snap_size, S_IRUGO, rbd_snap_size_show, NULL); 2009static DEVICE_ATTR(snap_size, S_IRUGO, rbd_snap_size_show, NULL);
1975static DEVICE_ATTR(snap_id, S_IRUGO, rbd_snap_id_show, NULL); 2010static DEVICE_ATTR(snap_id, S_IRUGO, rbd_snap_id_show, NULL);
2011static DEVICE_ATTR(snap_features, S_IRUGO, rbd_snap_features_show, NULL);
1976 2012
1977static struct attribute *rbd_snap_attrs[] = { 2013static struct attribute *rbd_snap_attrs[] = {
1978 &dev_attr_snap_size.attr, 2014 &dev_attr_snap_size.attr,
1979 &dev_attr_snap_id.attr, 2015 &dev_attr_snap_id.attr,
2016 &dev_attr_snap_features.attr,
1980 NULL, 2017 NULL,
1981}; 2018};
1982 2019
@@ -2037,7 +2074,8 @@ static int rbd_register_snap_dev(struct rbd_snap *snap,
2037 2074
2038static struct rbd_snap *__rbd_add_snap_dev(struct rbd_device *rbd_dev, 2075static struct rbd_snap *__rbd_add_snap_dev(struct rbd_device *rbd_dev,
2039 const char *snap_name, 2076 const char *snap_name,
2040 u64 snap_id, u64 snap_size) 2077 u64 snap_id, u64 snap_size,
2078 u64 snap_features)
2041{ 2079{
2042 struct rbd_snap *snap; 2080 struct rbd_snap *snap;
2043 int ret; 2081 int ret;
@@ -2053,6 +2091,7 @@ static struct rbd_snap *__rbd_add_snap_dev(struct rbd_device *rbd_dev,
2053 2091
2054 snap->id = snap_id; 2092 snap->id = snap_id;
2055 snap->size = snap_size; 2093 snap->size = snap_size;
2094 snap->features = snap_features;
2056 2095
2057 return snap; 2096 return snap;
2058 2097
@@ -2123,7 +2162,7 @@ static int rbd_dev_snaps_update(struct rbd_device *rbd_dev)
2123 /* We haven't seen this snapshot before */ 2162 /* We haven't seen this snapshot before */
2124 2163
2125 new_snap = __rbd_add_snap_dev(rbd_dev, snap_name, 2164 new_snap = __rbd_add_snap_dev(rbd_dev, snap_name,
2126 snap_id, header->snap_sizes[index]); 2165 snap_id, header->snap_sizes[index], 0);
2127 if (IS_ERR(new_snap)) { 2166 if (IS_ERR(new_snap)) {
2128 int err = PTR_ERR(new_snap); 2167 int err = PTR_ERR(new_snap);
2129 2168