avoid overwriting the header
PATCH 2/2 avoid overwriting the header
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(-)
block/rbd.c +8 -0
@@ -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;
Signature · 1 line
1.7.0.4
Thanks. Pushed both patches.
Yehuda
Quoted 36 lines · Christian Brunner
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(-)block/rbd.c +8
-1@@ -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
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html