[PATCH 2/2] avoid overwriting the header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



avoid overwriting the rbd header when doing qemu-img create
to resize a rbd image use rbdtool --resize instead
---
 block/rbd.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/block/rbd.c b/block/rbd.c
index a182d5e..11b7c10 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -163,6 +163,8 @@ static int rbd_create(const char *filename, QEMUOptionParameter * options)
 {
     int64_t bytes = 0;
     int64_t objsize;
+    uint64_t size;
+    time_t mtime;
     uint8_t obj_order = RBD_DEFAULT_OBJ_ORDER;
     char pool[RBD_MAX_SEG_NAME_SIZE];
     char n[RBD_MAX_SEG_NAME_SIZE];
@@ -227,6 +229,12 @@ static int rbd_create(const char *filename, QEMUOptionParameter * options)
         return -EIO;
     }
 
+    ret = rados_stat(p, n, &size, &mtime);
+    if (ret == 0) {
+        ret=-EEXIST;
+        goto done;
+    }
+
     ret = rados_write(p, n, 0, (const char *)&header, sizeof(header));
     if (ret < 0) {
         goto done;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux