node.jsrangeclonecephradosgw

What is the meaning of -95 error code that is returned from rados_clone_range?


I have Ceph rados client for node.js version 12.4.0.

I want to copy a portion of one object to another. And there is a method written for this operation. Its name is clone_range and it use rados_clone_range function of librados.

Error code -95 returns after giving parameters to this function(rados_clone_range).

What is the meaning of -95 error code that returned from rados_clone_range???

librados.h

 CEPH_RADOS_API int rados_clone_range(rados_ioctx_t io, const char       *dst,
                                           uint64_t dst_off, const char *src,
                                           uint64_t src_off, size_t len);

/* Efficiently copy a portion of one object to another If the underlying filesystem on the OSD supports it, this will be a copy-on-write clone. The src and dest objects must be in the same pg. To ensure this, the io context should have a locator key set (see rados_ioctx_locator_set_key()).

rados.cc

NAN_METHOD(Ioctx::clone_range) {
      if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsString()) {
        return Nan::ThrowError("Bad argument.");
      }

      Ioctx* obj = ObjectWrap::Unwrap<Ioctx>(info.Holder());
      if ( !obj->require_created() ) {
        info.GetReturnValue().Set(Nan::Null());
        return;
      }``

      Nan::Utf8String dst(info[0]);
      Nan::Utf8String src(info[1]);
      uint64_t dst_off = info[2]->IsNumber() ? info[2]->IntegerValue(Nan::GetCurrentContext()).FromJust() : 0;
      uint64_t src_off = info[3]->IsNumber() ? info[3]->IntegerValue(Nan::GetCurrentContext()).FromJust() : 0;
      size_t size = info[4]->IsNumber() ? info[4]->Uint32Value(Nan::GetCurrentContext()).FromJust() : 1;

      int err = rados_clone_range(obj->ioctx, *dst, dst_off, *src, src_off, size);
      //0 on success
      //my err is -95


      info.GetReturnValue().Set(Nan::New<Number>(err));

    }

example.js

var rados = require('./build/Release/rados');

 var cluster = new rados.Rados( "ceph", "client.admin", "/etc/ceph/ceph.conf");

console.log("RADOS - NEW " + cluster)
var err = cluster.connect();
if (err) {
    // On connection error
    console.log("Error " + err);
    throw err;
}

var ioctx = new rados.Ioctx(cluster, "testpool");


ioctx.write("dst_data", Buffer.from("1234567890ABCDE"));
ioctx.write("src_data", Buffer.from("12345CDE"));

console.log("\n" + "CLONE_RANGE = " + ioctx.clone_range("src_data", "dst_data"))          ///// output: -95

Solution

  • Original error code is (95) Operation not supported. Before returning, it negatives that value to avoid some confusion.

    Also as specified here, it says EOPNOTSUPP(-95, "Operation not supported on transport endpoint") . It is rados-java but probably error codes will be same.