forked from vitalif/vitastor
Ignore "readonly" flag when merging snapshots
parent
065dfef683
commit
6d307d5391
|
@ -458,6 +458,7 @@ struct snap_merger_t
|
||||||
subop->offset = rwo->offset+start;
|
subop->offset = rwo->offset+start;
|
||||||
subop->len = end-start;
|
subop->len = end-start;
|
||||||
subop->version = version;
|
subop->version = version;
|
||||||
|
subop->flags = OSD_OP_IGNORE_READONLY;
|
||||||
subop->iov.push_back(rwo->buf+start, end-start);
|
subop->iov.push_back(rwo->buf+start, end-start);
|
||||||
subop->callback = [this, rwo](cluster_op_t *subop)
|
subop->callback = [this, rwo](cluster_op_t *subop)
|
||||||
{
|
{
|
||||||
|
@ -493,6 +494,7 @@ struct snap_merger_t
|
||||||
subop->inode = inode_num;
|
subop->inode = inode_num;
|
||||||
subop->offset = offset;
|
subop->offset = offset;
|
||||||
subop->len = 0;
|
subop->len = 0;
|
||||||
|
subop->flags = OSD_OP_IGNORE_READONLY;
|
||||||
subop->callback = [this](cluster_op_t *subop)
|
subop->callback = [this](cluster_op_t *subop)
|
||||||
{
|
{
|
||||||
if (subop->retval != 0)
|
if (subop->retval != 0)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#define CACHE_DIRTY 1
|
#define CACHE_DIRTY 1
|
||||||
#define CACHE_FLUSHING 2
|
#define CACHE_FLUSHING 2
|
||||||
#define CACHE_REPEATING 3
|
#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)
|
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;
|
wr->state = CACHE_REPEATING;
|
||||||
cluster_op_t *op = new cluster_op_t;
|
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->opcode = OSD_OP_WRITE;
|
||||||
op->cur_inode = op->inode = oid.inode;
|
op->cur_inode = op->inode = oid.inode;
|
||||||
op->offset = oid.stripe;
|
op->offset = oid.stripe;
|
||||||
|
@ -620,12 +620,15 @@ resume_0:
|
||||||
}
|
}
|
||||||
if (op->opcode == OSD_OP_WRITE || op->opcode == OSD_OP_DELETE)
|
if (op->opcode == OSD_OP_WRITE || op->opcode == OSD_OP_DELETE)
|
||||||
{
|
{
|
||||||
auto ino_it = st_cli.inode_config.find(op->inode);
|
if (!(op->flags & OSD_OP_IGNORE_READONLY))
|
||||||
if (ino_it != st_cli.inode_config.end() && ino_it->second.readonly)
|
|
||||||
{
|
{
|
||||||
op->retval = -EINVAL;
|
auto ino_it = st_cli.inode_config.find(op->inode);
|
||||||
erase_op(op);
|
if (ino_it != st_cli.inode_config.end() && ino_it->second.readonly)
|
||||||
return 1;
|
{
|
||||||
|
op->retval = -EINVAL;
|
||||||
|
erase_op(op);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (op->opcode == OSD_OP_WRITE && !immediate_commit && !(op->flags & OP_FLUSH_BUFFER))
|
if (op->opcode == OSD_OP_WRITE && !immediate_commit && !(op->flags & OP_FLUSH_BUFFER))
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#define INODE_LIST_HAS_UNSTABLE 2
|
#define INODE_LIST_HAS_UNSTABLE 2
|
||||||
#define OSD_OP_READ_BITMAP OSD_OP_SEC_READ_BMP
|
#define OSD_OP_READ_BITMAP OSD_OP_SEC_READ_BMP
|
||||||
|
|
||||||
|
#define OSD_OP_IGNORE_READONLY 0x08
|
||||||
|
|
||||||
struct cluster_op_t;
|
struct cluster_op_t;
|
||||||
|
|
||||||
struct cluster_op_part_t
|
struct cluster_op_part_t
|
||||||
|
@ -37,6 +39,8 @@ struct cluster_op_t
|
||||||
// for reads and writes within a single object (stripe),
|
// for reads and writes within a single object (stripe),
|
||||||
// reads can return current version and writes can use "CAS" semantics
|
// reads can return current version and writes can use "CAS" semantics
|
||||||
uint64_t version = 0;
|
uint64_t version = 0;
|
||||||
|
// now only OSD_OP_IGNORE_READONLY is supported
|
||||||
|
uint64_t flags = 0;
|
||||||
int retval;
|
int retval;
|
||||||
osd_op_buf_list_t iov;
|
osd_op_buf_list_t iov;
|
||||||
// READ and READ_BITMAP return the bitmap here
|
// READ and READ_BITMAP return the bitmap here
|
||||||
|
@ -44,7 +48,6 @@ struct cluster_op_t
|
||||||
std::function<void(cluster_op_t*)> callback;
|
std::function<void(cluster_op_t*)> callback;
|
||||||
~cluster_op_t();
|
~cluster_op_t();
|
||||||
protected:
|
protected:
|
||||||
uint64_t flags = 0;
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
uint64_t cur_inode; // for snapshot reads
|
uint64_t cur_inode; // for snapshot reads
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
|
|
Loading…
Reference in New Issue