aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-08-10 16:12:10 -0400
committerAlex Elder <elder@inktank.com>2012-10-01 15:30:53 -0400
commit02cdb02ceab1f3dd9ac2bc899fc51f0e0e744782 (patch)
tree0f9d8c79fa2eaab44a969592d5cf189bd82bf7c7 /drivers/block
parent589d30e0b3e649e2660f9a67be88e235b28bc319 (diff)
rbd: kill create_snap sysfs entry
Josh proposed the following change, and I don't think I could explain it any better than he did: From: Josh Durgin <josh.durgin@inktank.com> Date: Tue, 24 Jul 2012 14:22:11 -0700 To: ceph-devel <ceph-devel@vger.kernel.org> Message-ID: <500F1203.9050605@inktank.com> Right now the kernel still has one piece of rbd management duplicated from the rbd command line tool: snapshot creation. There's nothing special about snapshot creation that makes it advantageous to do from the kernel, so I'd like to remove the create_snap sysfs interface. That is, /sys/bus/rbd/devices/<id>/create_snap would be removed. Does anyone rely on the sysfs interface for creating rbd snapshots? If so, how hard would it be to replace with: rbd snap create pool/image@snap Is there any benefit to the sysfs interface that I'm missing? Josh This patch implements this proposal, removing the code that implements the "snap_create" sysfs interface for rbd images. As a result, quite a lot of other supporting code goes away. Suggested-by: Josh Durgin <josh.durgin@inktank.com> Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c158
1 files changed, 0 insertions, 158 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 34f46c3b188f..e453f8cc8949 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -212,10 +212,6 @@ static int rbd_dev_snaps_update(struct rbd_device *rbd_dev);
212static int rbd_dev_snaps_register(struct rbd_device *rbd_dev); 212static int rbd_dev_snaps_register(struct rbd_device *rbd_dev);
213 213
214static void rbd_dev_release(struct device *dev); 214static void rbd_dev_release(struct device *dev);
215static ssize_t rbd_snap_add(struct device *dev,
216 struct device_attribute *attr,
217 const char *buf,
218 size_t count);
219static void __rbd_remove_snap_dev(struct rbd_snap *snap); 215static void __rbd_remove_snap_dev(struct rbd_snap *snap);
220 216
221static ssize_t rbd_add(struct bus_type *bus, const char *buf, 217static ssize_t rbd_add(struct bus_type *bus, const char *buf,
@@ -1375,71 +1371,6 @@ static int rbd_req_sync_unwatch(struct rbd_device *rbd_dev)
1375 return ret; 1371 return ret;
1376} 1372}
1377 1373
1378struct rbd_notify_info {
1379 struct rbd_device *rbd_dev;
1380};
1381
1382static void rbd_notify_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
1383{
1384 struct rbd_device *rbd_dev = (struct rbd_device *)data;
1385 if (!rbd_dev)
1386 return;
1387
1388 dout("rbd_notify_cb %s notify_id=%llu opcode=%u\n",
1389 rbd_dev->header_name, (unsigned long long) notify_id,
1390 (unsigned int) opcode);
1391}
1392
1393/*
1394 * Request sync osd notify
1395 */
1396static int rbd_req_sync_notify(struct rbd_device *rbd_dev)
1397{
1398 struct ceph_osd_req_op *ops;
1399 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
1400 struct ceph_osd_event *event;
1401 struct rbd_notify_info info;
1402 int payload_len = sizeof(u32) + sizeof(u32);
1403 int ret;
1404
1405 ops = rbd_create_rw_ops(1, CEPH_OSD_OP_NOTIFY, payload_len);
1406 if (!ops)
1407 return -ENOMEM;
1408
1409 info.rbd_dev = rbd_dev;
1410
1411 ret = ceph_osdc_create_event(osdc, rbd_notify_cb, 1,
1412 (void *)&info, &event);
1413 if (ret < 0)
1414 goto fail;
1415
1416 ops[0].watch.ver = 1;
1417 ops[0].watch.flag = 1;
1418 ops[0].watch.cookie = event->cookie;
1419 ops[0].watch.prot_ver = RADOS_NOTIFY_VER;
1420 ops[0].watch.timeout = 12;
1421
1422 ret = rbd_req_sync_op(rbd_dev, NULL,
1423 CEPH_NOSNAP,
1424 CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
1425 ops,
1426 rbd_dev->header_name,
1427 0, 0, NULL, NULL, NULL);
1428 if (ret < 0)
1429 goto fail_event;
1430
1431 ret = ceph_osdc_wait_event(event, CEPH_OSD_TIMEOUT_DEFAULT);
1432 dout("ceph_osdc_wait_event returned %d\n", ret);
1433 rbd_destroy_ops(ops);
1434 return 0;
1435
1436fail_event:
1437 ceph_osdc_cancel_event(event);
1438fail:
1439 rbd_destroy_ops(ops);
1440 return ret;
1441}
1442
1443/* 1374/*
1444 * Synchronous osd object method call 1375 * Synchronous osd object method call
1445 */ 1376 */
@@ -1761,52 +1692,6 @@ static int rbd_read_header(struct rbd_device *rbd_dev,
1761 return ret; 1692 return ret;
1762} 1693}
1763 1694
1764/*
1765 * create a snapshot
1766 */
1767static int rbd_header_add_snap(struct rbd_device *rbd_dev,
1768 const char *snap_name,
1769 gfp_t gfp_flags)
1770{
1771 int name_len = strlen(snap_name);
1772 u64 new_snapid;
1773 int ret;
1774 void *data, *p, *e;
1775 struct ceph_mon_client *monc;
1776
1777 /* we should create a snapshot only if we're pointing at the head */
1778 if (rbd_dev->mapping.snap_id != CEPH_NOSNAP)
1779 return -EINVAL;
1780
1781 monc = &rbd_dev->rbd_client->client->monc;
1782 ret = ceph_monc_create_snapid(monc, rbd_dev->pool_id, &new_snapid);
1783 dout("created snapid=%llu\n", (unsigned long long) new_snapid);
1784 if (ret < 0)
1785 return ret;
1786
1787 data = kmalloc(name_len + 16, gfp_flags);
1788 if (!data)
1789 return -ENOMEM;
1790
1791 p = data;
1792 e = data + name_len + 16;
1793
1794 ceph_encode_string_safe(&p, e, snap_name, name_len, bad);
1795 ceph_encode_64_safe(&p, e, new_snapid, bad);
1796
1797 ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
1798 "rbd", "snap_add",
1799 data, (size_t) (p - data), NULL, 0,
1800 CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
1801 NULL);
1802
1803 kfree(data);
1804
1805 return ret < 0 ? ret : 0;
1806bad:
1807 return -ERANGE;
1808}
1809
1810static void __rbd_remove_all_snaps(struct rbd_device *rbd_dev) 1695static void __rbd_remove_all_snaps(struct rbd_device *rbd_dev)
1811{ 1696{
1812 struct rbd_snap *snap; 1697 struct rbd_snap *snap;
@@ -2030,7 +1915,6 @@ static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
2030static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL); 1915static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL);
2031static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); 1916static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
2032static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); 1917static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
2033static DEVICE_ATTR(create_snap, S_IWUSR, NULL, rbd_snap_add);
2034 1918
2035static struct attribute *rbd_attrs[] = { 1919static struct attribute *rbd_attrs[] = {
2036 &dev_attr_size.attr, 1920 &dev_attr_size.attr,
@@ -2042,7 +1926,6 @@ static struct attribute *rbd_attrs[] = {
2042 &dev_attr_image_id.attr, 1926 &dev_attr_image_id.attr,
2043 &dev_attr_current_snap.attr, 1927 &dev_attr_current_snap.attr,
2044 &dev_attr_refresh.attr, 1928 &dev_attr_refresh.attr,
2045 &dev_attr_create_snap.attr,
2046 NULL 1929 NULL
2047}; 1930};
2048 1931
@@ -2891,47 +2774,6 @@ done:
2891 return ret; 2774 return ret;
2892} 2775}
2893 2776
2894static ssize_t rbd_snap_add(struct device *dev,
2895 struct device_attribute *attr,
2896 const char *buf,
2897 size_t count)
2898{
2899 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
2900 int ret;
2901 char *name = kmalloc(count + 1, GFP_KERNEL);
2902 if (!name)
2903 return -ENOMEM;
2904
2905 snprintf(name, count, "%s", buf);
2906
2907 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
2908
2909 ret = rbd_header_add_snap(rbd_dev,
2910 name, GFP_KERNEL);
2911 if (ret < 0)
2912 goto err_unlock;
2913
2914 ret = __rbd_refresh_header(rbd_dev, NULL);
2915 if (ret < 0)
2916 goto err_unlock;
2917
2918 /* shouldn't hold ctl_mutex when notifying.. notify might
2919 trigger a watch callback that would need to get that mutex */
2920 mutex_unlock(&ctl_mutex);
2921
2922 /* make a best effort, don't error if failed */
2923 rbd_req_sync_notify(rbd_dev);
2924
2925 ret = count;
2926 kfree(name);
2927 return ret;
2928
2929err_unlock:
2930 mutex_unlock(&ctl_mutex);
2931 kfree(name);
2932 return ret;
2933}
2934
2935/* 2777/*
2936 * create control files in sysfs 2778 * create control files in sysfs
2937 * /sys/bus/rbd/... 2779 * /sys/bus/rbd/...