aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-bus-rbd7
-rw-r--r--drivers/block/rbd.c90
2 files changed, 0 insertions, 97 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-rbd b/Documentation/ABI/testing/sysfs-bus-rbd
index fa72ccb2282e..dbedafb095e2 100644
--- a/Documentation/ABI/testing/sysfs-bus-rbd
+++ b/Documentation/ABI/testing/sysfs-bus-rbd
@@ -57,13 +57,6 @@ create_snap
57 57
58 $ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_create 58 $ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_create
59 59
60rollback_snap
61
62 Rolls back data to the specified snapshot. This goes over the entire
63 list of rados blocks and sends a rollback command to each.
64
65 $ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_rollback
66
67snap_* 60snap_*
68 61
69 A directory per each snapshot 62 A directory per each snapshot
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a828c6a276a8..148ab944378d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -183,10 +183,6 @@ static LIST_HEAD(rbd_client_list); /* clients */
183 183
184static int __rbd_init_snaps_header(struct rbd_device *rbd_dev); 184static int __rbd_init_snaps_header(struct rbd_device *rbd_dev);
185static void rbd_dev_release(struct device *dev); 185static void rbd_dev_release(struct device *dev);
186static ssize_t rbd_snap_rollback(struct device *dev,
187 struct device_attribute *attr,
188 const char *buf,
189 size_t size);
190static ssize_t rbd_snap_add(struct device *dev, 186static ssize_t rbd_snap_add(struct device *dev,
191 struct device_attribute *attr, 187 struct device_attribute *attr,
192 const char *buf, 188 const char *buf,
@@ -1360,32 +1356,6 @@ fail:
1360} 1356}
1361 1357
1362/* 1358/*
1363 * Request sync osd rollback
1364 */
1365static int rbd_req_sync_rollback_obj(struct rbd_device *dev,
1366 u64 snapid,
1367 const char *obj)
1368{
1369 struct ceph_osd_req_op *ops;
1370 int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_ROLLBACK, 0);
1371 if (ret < 0)
1372 return ret;
1373
1374 ops[0].snap.snapid = snapid;
1375
1376 ret = rbd_req_sync_op(dev, NULL,
1377 CEPH_NOSNAP,
1378 0,
1379 CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
1380 ops,
1381 1, obj, 0, 0, NULL, NULL, NULL);
1382
1383 rbd_destroy_ops(ops);
1384
1385 return ret;
1386}
1387
1388/*
1389 * Request sync osd read 1359 * Request sync osd read
1390 */ 1360 */
1391static int rbd_req_sync_exec(struct rbd_device *dev, 1361static int rbd_req_sync_exec(struct rbd_device *dev,
@@ -1891,7 +1861,6 @@ static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
1891static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); 1861static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
1892static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); 1862static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
1893static DEVICE_ATTR(create_snap, S_IWUSR, NULL, rbd_snap_add); 1863static DEVICE_ATTR(create_snap, S_IWUSR, NULL, rbd_snap_add);
1894static DEVICE_ATTR(rollback_snap, S_IWUSR, NULL, rbd_snap_rollback);
1895 1864
1896static struct attribute *rbd_attrs[] = { 1865static struct attribute *rbd_attrs[] = {
1897 &dev_attr_size.attr, 1866 &dev_attr_size.attr,
@@ -1902,7 +1871,6 @@ static struct attribute *rbd_attrs[] = {
1902 &dev_attr_current_snap.attr, 1871 &dev_attr_current_snap.attr,
1903 &dev_attr_refresh.attr, 1872 &dev_attr_refresh.attr,
1904 &dev_attr_create_snap.attr, 1873 &dev_attr_create_snap.attr,
1905 &dev_attr_rollback_snap.attr,
1906 NULL 1874 NULL
1907}; 1875};
1908 1876
@@ -2433,64 +2401,6 @@ err_unlock:
2433 return ret; 2401 return ret;
2434} 2402}
2435 2403
2436static ssize_t rbd_snap_rollback(struct device *dev,
2437 struct device_attribute *attr,
2438 const char *buf,
2439 size_t count)
2440{
2441 struct rbd_device *rbd_dev = dev_to_rbd(dev);
2442 int ret;
2443 u64 snapid;
2444 u64 cur_ofs;
2445 char *seg_name = NULL;
2446 char *snap_name = kmalloc(count + 1, GFP_KERNEL);
2447 ret = -ENOMEM;
2448 if (!snap_name)
2449 return ret;
2450
2451 /* parse snaps add command */
2452 snprintf(snap_name, count, "%s", buf);
2453 seg_name = kmalloc(RBD_MAX_SEG_NAME_LEN + 1, GFP_NOIO);
2454 if (!seg_name)
2455 goto done;
2456
2457 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
2458
2459 ret = snap_by_name(&rbd_dev->header, snap_name, &snapid, NULL);
2460 if (ret < 0)
2461 goto done_unlock;
2462
2463 dout("snapid=%lld\n", snapid);
2464
2465 cur_ofs = 0;
2466 while (cur_ofs < rbd_dev->header.image_size) {
2467 cur_ofs += rbd_get_segment(&rbd_dev->header,
2468 rbd_dev->obj,
2469 cur_ofs, (u64)-1,
2470 seg_name, NULL);
2471 dout("seg_name=%s\n", seg_name);
2472
2473 ret = rbd_req_sync_rollback_obj(rbd_dev, snapid, seg_name);
2474 if (ret < 0)
2475 pr_warning("could not roll back obj %s err=%d\n",
2476 seg_name, ret);
2477 }
2478
2479 ret = __rbd_update_snaps(rbd_dev);
2480 if (ret < 0)
2481 goto done_unlock;
2482
2483 ret = count;
2484
2485done_unlock:
2486 mutex_unlock(&ctl_mutex);
2487done:
2488 kfree(seg_name);
2489 kfree(snap_name);
2490
2491 return ret;
2492}
2493
2494static struct bus_attribute rbd_bus_attrs[] = { 2404static struct bus_attribute rbd_bus_attrs[] = {
2495 __ATTR(add, S_IWUSR, NULL, rbd_add), 2405 __ATTR(add, S_IWUSR, NULL, rbd_add),
2496 __ATTR(remove, S_IWUSR, NULL, rbd_remove), 2406 __ATTR(remove, S_IWUSR, NULL, rbd_remove),