@@ -35,6 +35,7 @@
#define SD_OP_GET_VDI_INFO 0x14
#define SD_OP_READ_VDIS 0x15
#define SD_OP_FLUSH_VDI 0x16
+#define SD_OP_DISCARD 0x17
#define SD_FLAG_CMD_WRITE 0x01
#define SD_FLAG_CMD_COW 0x02
@@ -741,6 +741,20 @@ static int local_flush_vdi(struct request *req)
return ret;
}
+static int local_discard(struct request *req)
+{
+ uint64_t oid = req->rq.obj.oid;
+ uint32_t vid = oid_to_vid(oid), zero = 0;
+ int ret, cp = get_vdi_copy_number(vid), idx = data_oid_to_idx(oid);
+
+ sd_dprintf("%"PRIx64, oid);
+ ret = remove_object(oid, cp);
+ if (ret != SD_RES_SUCCESS)
+ return ret;
+ return write_object(vid_to_vdi_oid(vid), (char *)&zero, sizeof(zero),
+ SD_INODE_HEADER_SIZE + sizeof(vid) * idx, 0, cp);
+}
+
static int local_flush_and_del(struct request *req)
{
if (!sys->enable_object_cache)
@@ -1109,6 +1123,12 @@ static struct sd_op_template sd_ops[] = {
.process_work = local_flush_vdi,
},
+ [SD_OP_DISCARD] = {
+ .name = "DISCARD",
+ .type = SD_OP_TYPE_LOCAL,
+ .process_work = local_discard,
+ },
+
[SD_OP_FLUSH_DEL_CACHE] = {
.name = "DEL_CACHE",
.type = SD_OP_TYPE_LOCAL,