From 40efd8ccc7fb128d7cdfa4db503ed0526cc2c8cc Mon Sep 17 00:00:00 2001 From: sageweil Date: Fri, 20 Oct 2006 21:43:07 +0000 Subject: [PATCH] zero op (tho inactive) git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@942 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/osd/OSD.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ceph/osd/OSD.cc b/ceph/osd/OSD.cc index bd266eb17c97c..20579166d5a0c 100644 --- a/ceph/osd/OSD.cc +++ b/ceph/osd/OSD.cc @@ -3197,6 +3197,33 @@ void OSD::prepare_op_transaction(ObjectStore::Transaction& t, } break; + case OSD_OP_ZERO: + { + assert(0); // are you sure this is what you want? + // zero, remove, or truncate? + struct stat st; + int r = store->stat(oid, &st); + if (r >= 0) { + if (op->get_offset() + op->get_length() >= st.st_size) { + if (op->get_offset()) + t.truncate(oid, op->get_length() + op->get_offset()); + else + t.remove(oid); + } else { + // zero. the dumb way. FIXME. + bufferptr bp(op->get_length()); + bp.zero(); + bufferlist bl; + bl.push_back(bp); + t.write(oid, op->get_offset(), op->get_length(), bl); + } + } else { + // noop? + dout(10) << "apply_transaction zero on " << oid << ", but dne? stat returns " << r << endl; + } + } + break; + case OSD_OP_TRUNCATE: { // truncate //r = store->truncate(oid, op->get_offset()); -- 2.39.5