Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 331661
b: refs/heads/master
c: 2ac4e75
h: refs/heads/master
i:
  331659: d115ced
v: v3
  • Loading branch information
Alex Elder committed Oct 1, 2012
1 parent 5f5271b commit a246621
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8836b995fd192dba23d312d2a4fba68dd8ca7183
refs/heads/master: 2ac4e75d89e9df8eea6390a759eac2b6df0ebff6
51 changes: 27 additions & 24 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,8 +1652,6 @@ static void rbd_free_disk(struct rbd_device *rbd_dev)
if (!disk)
return;

rbd_header_free(&rbd_dev->header);

if (disk->flags & GENHD_FL_UP)
del_gendisk(disk);
if (disk->queue)
Expand Down Expand Up @@ -1875,20 +1873,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
int rc;
u64 segment_size;

/* contact OSD, request size info about the object being mapped */
rc = rbd_read_header(rbd_dev, &rbd_dev->header);
if (rc)
return rc;

/* no need to lock here, as rbd_dev is not registered yet */
rc = rbd_dev_snap_devs_update(rbd_dev);
if (rc)
return rc;

rc = rbd_header_set_snap(rbd_dev, snap_name);
if (rc)
return rc;

/* create gendisk info */
rc = -ENOMEM;
disk = alloc_disk(RBD_MINORS_PER_MAJOR);
Expand Down Expand Up @@ -1925,12 +1909,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)

rbd_dev->disk = disk;

/* finally, announce the disk to the world */
set_capacity(disk, (sector_t) rbd_dev->mapping.size / SECTOR_SIZE);
add_disk(disk);

pr_info("%s: added with size 0x%llx\n",
disk->disk_name, (unsigned long long) rbd_dev->mapping.size);
return 0;

out_disk:
Expand Down Expand Up @@ -2622,13 +2600,35 @@ static ssize_t rbd_add(struct bus_type *bus,
/*
* At this point cleanup in the event of an error is the job
* of the sysfs code (initiated by rbd_bus_del_dev()).
*
* Set up and announce blkdev mapping.
*/

/* contact OSD, request size info about the object being mapped */
rc = rbd_read_header(rbd_dev, &rbd_dev->header);
if (rc)
goto err_out_bus;

/* no need to lock here, as rbd_dev is not registered yet */
rc = rbd_dev_snap_devs_update(rbd_dev);
if (rc)
goto err_out_bus;

rc = rbd_header_set_snap(rbd_dev, snap_name);
if (rc)
goto err_out_bus;

/* Set up the blkdev mapping. */

rc = rbd_init_disk(rbd_dev);
if (rc)
goto err_out_bus;

/* Everything's ready. Announce the disk to the world. */

set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
add_disk(rbd_dev->disk);
pr_info("%s: added with size 0x%llx\n", rbd_dev->disk->disk_name,
(unsigned long long) rbd_dev->mapping.size);

rc = rbd_init_watch_dev(rbd_dev);
if (rc)
goto err_out_bus;
Expand Down Expand Up @@ -2700,6 +2700,9 @@ static void rbd_dev_release(struct device *dev)
rbd_free_disk(rbd_dev);
unregister_blkdev(rbd_dev->major, rbd_dev->name);

/* release allocated disk header fields */
rbd_header_free(&rbd_dev->header);

/* done with the id, and with the rbd_dev */
kfree(rbd_dev->mapping.snap_name);
kfree(rbd_dev->header_name);
Expand Down

0 comments on commit a246621

Please sign in to comment.