From 6d307d5391ba58cf3d058a97e6aa7b6a68f63399 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 26 Sep 2021 11:32:42 +0300 Subject: [PATCH] Ignore "readonly" flag when merging snapshots --- src/cli_merge.cpp | 2 ++ src/cluster_client.cpp | 17 ++++++++++------- src/cluster_client.h | 5 ++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/cli_merge.cpp b/src/cli_merge.cpp index 50066d46e..4d2649e70 100644 --- a/src/cli_merge.cpp +++ b/src/cli_merge.cpp @@ -458,6 +458,7 @@ struct snap_merger_t subop->offset = rwo->offset+start; subop->len = end-start; subop->version = version; + subop->flags = OSD_OP_IGNORE_READONLY; subop->iov.push_back(rwo->buf+start, end-start); subop->callback = [this, rwo](cluster_op_t *subop) { @@ -493,6 +494,7 @@ struct snap_merger_t subop->inode = inode_num; subop->offset = offset; subop->len = 0; + subop->flags = OSD_OP_IGNORE_READONLY; subop->callback = [this](cluster_op_t *subop) { if (subop->retval != 0) diff --git a/src/cluster_client.cpp b/src/cluster_client.cpp index b6e077eed..45688c246 100644 --- a/src/cluster_client.cpp +++ b/src/cluster_client.cpp @@ -12,7 +12,7 @@ #define CACHE_DIRTY 1 #define CACHE_FLUSHING 2 #define CACHE_REPEATING 3 -#define OP_FLUSH_BUFFER 2 +#define OP_FLUSH_BUFFER 0x02 cluster_client_t::cluster_client_t(ring_loop_t *ringloop, timerfd_manager_t *tfd, json11::Json & config) { @@ -559,7 +559,7 @@ void cluster_client_t::flush_buffer(const object_id & oid, cluster_buffer_t *wr) { wr->state = CACHE_REPEATING; cluster_op_t *op = new cluster_op_t; - op->flags = OP_FLUSH_BUFFER; + op->flags = OSD_OP_IGNORE_READONLY|OP_FLUSH_BUFFER; op->opcode = OSD_OP_WRITE; op->cur_inode = op->inode = oid.inode; op->offset = oid.stripe; @@ -620,12 +620,15 @@ resume_0: } if (op->opcode == OSD_OP_WRITE || op->opcode == OSD_OP_DELETE) { - auto ino_it = st_cli.inode_config.find(op->inode); - if (ino_it != st_cli.inode_config.end() && ino_it->second.readonly) + if (!(op->flags & OSD_OP_IGNORE_READONLY)) { - op->retval = -EINVAL; - erase_op(op); - return 1; + auto ino_it = st_cli.inode_config.find(op->inode); + if (ino_it != st_cli.inode_config.end() && ino_it->second.readonly) + { + op->retval = -EINVAL; + erase_op(op); + return 1; + } } if (op->opcode == OSD_OP_WRITE && !immediate_commit && !(op->flags & OP_FLUSH_BUFFER)) { diff --git a/src/cluster_client.h b/src/cluster_client.h index 08b543d76..77b1b63d1 100644 --- a/src/cluster_client.h +++ b/src/cluster_client.h @@ -14,6 +14,8 @@ #define INODE_LIST_HAS_UNSTABLE 2 #define OSD_OP_READ_BITMAP OSD_OP_SEC_READ_BMP +#define OSD_OP_IGNORE_READONLY 0x08 + struct cluster_op_t; struct cluster_op_part_t @@ -37,6 +39,8 @@ struct cluster_op_t // for reads and writes within a single object (stripe), // reads can return current version and writes can use "CAS" semantics uint64_t version = 0; + // now only OSD_OP_IGNORE_READONLY is supported + uint64_t flags = 0; int retval; osd_op_buf_list_t iov; // READ and READ_BITMAP return the bitmap here @@ -44,7 +48,6 @@ struct cluster_op_t std::function callback; ~cluster_op_t(); protected: - uint64_t flags = 0; int state = 0; uint64_t cur_inode; // for snapshot reads void *buf = NULL;