]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
radostool: rados put should use write_full
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 24 May 2011 19:34:56 +0000 (12:34 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 24 May 2011 19:34:56 +0000 (12:34 -0700)
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 <colin.mccabe@dreamhost.com>
src/rados.cc

index e262c6a74248c7f850df95fe4d9dc67ac5ae4910..4540a5d6004c55c44d444a914412c699155167a9 100644 (file)
@@ -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) {