From: Colin Patrick McCabe Date: Tue, 24 May 2011 19:34:56 +0000 (-0700) Subject: radostool: rados put should use write_full X-Git-Tag: v0.29~42^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e42736ae7e8cbfcde66d8de53ee356200ac228a4;p=ceph.git radostool: rados put should use write_full If "rados put" uses write instead of write_full, the resulting object on the server may be a mismash of old and new objects, if the old object was longer than the new one. This is fairly counterintuitive behavior for radostool, so remove it. Signed-off-by: Colin McCabe --- diff --git a/src/rados.cc b/src/rados.cc index e262c6a74248..4540a5d6004c 100644 --- a/src/rados.cc +++ b/src/rados.cc @@ -127,7 +127,7 @@ static int do_put(IoCtx& io_ctx, const char *objname, const char *infile, int op indata.append('\n'); } } else { - int fd = open(infile, O_RDONLY); + int ret, fd = open(infile, O_RDONLY); if (fd < 0) { char buf[80]; cerr << "error reading input file " << infile << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl; @@ -147,7 +147,10 @@ static int do_put(IoCtx& io_ctx, const char *objname, const char *infile, int op continue; } indata.append(buf, count); - int ret = io_ctx.write(oid, indata, count, offset); + if (offset == 0) + ret = io_ctx.write_full(oid, indata); + else + ret = io_ctx.write(oid, indata, count, offset); indata.clear(); if (ret < 0) {