diff options
author | Amar Tumballi <amar@gluster.com> | 2012-02-06 17:49:14 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-02-14 01:09:02 -0800 |
commit | 0e6df0100e13123fe38f28c5a090777e894d8f52 (patch) | |
tree | 517c60cc953302172cb51f22f4b7aa52e557c1e9 /xlators | |
parent | e17ac220e4bff53fb89f5bea636acb61e347cf50 (diff) |
core: add an extra flag to readv()/writev() API
needed to implement a proper handling of open flag alterations
using fcntl() on fd.
Change-Id: Ic280d5db6f1dc0418d5c439abb8db1d3ac21ced0
Signed-off-by: Amar Tumballi <amar@gluster.com>
BUG: 782265
Reviewed-on: http://review.gluster.com/2723
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators')
40 files changed, 261 insertions, 241 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c index 5b534cf3742..0ef0f4f8642 100644 --- a/xlators/cluster/afr/src/afr-inode-read.c +++ b/xlators/cluster/afr/src/afr-inode-read.c @@ -1083,7 +1083,8 @@ afr_readv_cbk (call_frame_t *frame, void *cookie, children[next_call_child], children[next_call_child]->fops->readv, local->fd, local->cont.readv.size, - local->cont.readv.offset); + local->cont.readv.offset, + local->cont.readv.flags); } out: @@ -1098,7 +1099,7 @@ out: int32_t afr_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, uint32_t flags) { afr_private_t * priv = NULL; afr_local_t * local = NULL; @@ -1143,6 +1144,7 @@ afr_readv (call_frame_t *frame, xlator_t *this, local->cont.readv.size = size; local->cont.readv.offset = offset; + local->cont.readv.flags = flags; ret = afr_open_fd_fix (frame, this, _gf_false); if (ret) { @@ -1153,7 +1155,7 @@ afr_readv (call_frame_t *frame, xlator_t *this, (void *) (long) call_child, children[call_child], children[call_child]->fops->readv, - fd, size, offset); + fd, size, offset, flags); ret = 0; out: diff --git a/xlators/cluster/afr/src/afr-inode-read.h b/xlators/cluster/afr/src/afr-inode-read.h index 8af3ed1b503..5ec7411b11d 100644 --- a/xlators/cluster/afr/src/afr-inode-read.h +++ b/xlators/cluster/afr/src/afr-inode-read.h @@ -38,7 +38,7 @@ afr_readlink (call_frame_t *frame, xlator_t *this, int32_t afr_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset); + fd_t *fd, size_t size, off_t offset, uint32_t flags); int32_t afr_getxattr (call_frame_t *frame, xlator_t *this, diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c index 2a7e0e736a5..72dcdc4785b 100644 --- a/xlators/cluster/afr/src/afr-inode-write.c +++ b/xlators/cluster/afr/src/afr-inode-write.c @@ -157,6 +157,7 @@ afr_writev_wind (call_frame_t *frame, xlator_t *this) local->cont.writev.vector, local->cont.writev.count, local->cont.writev.offset, + local->cont.writev.flags, local->cont.writev.iobref); if (!--call_count) @@ -441,7 +442,7 @@ out: int afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { afr_private_t * priv = NULL; afr_local_t * local = NULL; @@ -466,6 +467,7 @@ afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, local->cont.writev.vector = iov_dup (vector, count); local->cont.writev.count = count; local->cont.writev.offset = offset; + local->cont.writev.flags = flags; local->cont.writev.iobref = iobref_ref (iobref); local->fd = fd_ref (fd); diff --git a/xlators/cluster/afr/src/afr-inode-write.h b/xlators/cluster/afr/src/afr-inode-write.h index bdd0b48669d..729a490d562 100644 --- a/xlators/cluster/afr/src/afr-inode-write.h +++ b/xlators/cluster/afr/src/afr-inode-write.h @@ -37,9 +37,9 @@ afr_fchmod (call_frame_t *frame, xlator_t *this, fd_t *fd, mode_t mode); int32_t -afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, +afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref); + uint32_t flags, struct iobref *iobref); int32_t afr_truncate (call_frame_t *frame, xlator_t *this, diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c index cb1516d8473..629822a8e60 100644 --- a/xlators/cluster/afr/src/afr-self-heal-algorithm.c +++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.c @@ -519,7 +519,7 @@ sh_loop_read_cbk (call_frame_t *loop_frame, void *cookie, priv->children[i], priv->children[i]->fops->writev, loop_sh->healing_fd, vector, count, - loop_sh->offset, iobref); + loop_sh->offset, 0, iobref); if (!--call_count) break; @@ -546,7 +546,7 @@ sh_loop_read (call_frame_t *loop_frame, xlator_t *this) priv->children[loop_sh->source], priv->children[loop_sh->source]->fops->readv, loop_sh->healing_fd, loop_sh->block_size, - loop_sh->offset); + loop_sh->offset, 0); return 0; } diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index 0c4bf5f6385..003d666e00d 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -475,6 +475,7 @@ typedef struct _afr_local { size_t size; off_t offset; int last_index; + uint32_t flags; } readv; /* dir read */ @@ -508,6 +509,7 @@ typedef struct _afr_local { struct iobref *iobref; int32_t count; off_t offset; + uint32_t flags; } writev; struct { diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c index 8ef30edbaf4..df0b31166ef 100644 --- a/xlators/cluster/afr/src/pump.c +++ b/xlators/cluster/afr/src/pump.c @@ -1987,7 +1987,7 @@ pump_writev (call_frame_t *frame, fd_t *fd, struct iovec *vector, int32_t count, - off_t off, + off_t off, uint32_t flags, struct iobref *iobref) { afr_private_t *priv = NULL; @@ -2000,11 +2000,11 @@ pump_writev (call_frame_t *frame, fd, vector, count, - off, + off, flags, iobref); return 0; } - afr_writev (frame, this, fd, vector, count, off, iobref); + afr_writev (frame, this, fd, vector, count, off, flags, iobref); return 0; } diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index ef78892eb04..749abe5380d 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -466,7 +466,7 @@ int32_t dht_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset); + off_t offset, uint32_t flags); int32_t dht_writev (call_frame_t *frame, xlator_t *this, @@ -474,6 +474,7 @@ int32_t dht_writev (call_frame_t *frame, struct iovec *vector, int32_t count, off_t offset, + uint32_t flags, struct iobref *iobref); int32_t dht_flush (call_frame_t *frame, diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c index 7352e47bd62..3ec6f4ba243 100644 --- a/xlators/cluster/dht/src/dht-inode-read.c +++ b/xlators/cluster/dht/src/dht-inode-read.c @@ -448,7 +448,8 @@ dht_readv2 (xlator_t *this, call_frame_t *frame, int op_ret) subvol = local->cached_subvol; STACK_WIND (frame, dht_readv_cbk, subvol, subvol->fops->readv, - local->fd, local->rebalance.size, local->rebalance.offset); + local->fd, local->rebalance.size, local->rebalance.offset, + local->rebalance.flags); return 0; @@ -459,7 +460,7 @@ out: int dht_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t off) + fd_t *fd, size_t size, off_t off, uint32_t flags) { xlator_t *subvol = NULL; int op_errno = -1; @@ -485,11 +486,12 @@ dht_readv (call_frame_t *frame, xlator_t *this, local->rebalance.offset = off; local->rebalance.size = size; + local->rebalance.flags = flags; local->call_cnt = 1; STACK_WIND (frame, dht_readv_cbk, subvol, subvol->fops->readv, - fd, size, off); + fd, size, off, flags); return 0; diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c index 4f65b46713c..2f59e7c94f6 100644 --- a/xlators/cluster/dht/src/dht-inode-write.c +++ b/xlators/cluster/dht/src/dht-inode-write.c @@ -112,14 +112,15 @@ dht_writev2 (xlator_t *this, call_frame_t *frame, int op_ret) STACK_WIND (frame, dht_writev_cbk, subvol, subvol->fops->writev, local->fd, local->rebalance.vector, local->rebalance.count, - local->rebalance.offset, local->rebalance.iobref); + local->rebalance.offset, local->rebalance.flags, + local->rebalance.iobref); return 0; } int -dht_writev (call_frame_t *frame, xlator_t *this, - fd_t *fd, struct iovec *vector, int count, off_t off, +dht_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + struct iovec *vector, int count, off_t off, uint32_t flags, struct iobref *iobref) { xlator_t *subvol = NULL; @@ -149,12 +150,13 @@ dht_writev (call_frame_t *frame, xlator_t *this, local->rebalance.vector = iov_dup (vector, count); local->rebalance.offset = off; local->rebalance.count = count; + local->rebalance.flags = flags; local->rebalance.iobref = iobref_ref (iobref); local->call_cnt = 1; STACK_WIND (frame, dht_writev_cbk, subvol, subvol->fops->writev, - fd, vector, count, off, iobref); + fd, vector, count, off, flags, iobref); return 0; diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 6c91baaaccb..dfd6f3b6ecc 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -60,7 +60,7 @@ dht_write_with_holes (xlator_t *to, fd_t *fd, struct iovec *vec, int count, ret = syncop_write (to, fd, (buf + tmp_offset), (start_idx - tmp_offset), (offset + tmp_offset), - iobref); + iobref, 0); /* 'path' will be logged in calling function */ if (ret < 0) { gf_log (THIS->name, GF_LOG_WARNING, @@ -78,7 +78,7 @@ dht_write_with_holes (xlator_t *to, fd_t *fd, struct iovec *vec, int count, /* This means, last chunk is not yet written.. write it */ ret = syncop_write (to, fd, (buf + tmp_offset), (buf_len - tmp_offset), - (offset + tmp_offset), iobref); + (offset + tmp_offset), iobref, 0); if (ret < 0) { /* 'path' will be logged in calling function */ gf_log (THIS->name, GF_LOG_WARNING, @@ -263,7 +263,7 @@ __dht_rebalance_migrate_data (xlator_t *from, xlator_t *to, fd_t *src, fd_t *dst read_size = (((ia_size - total) > DHT_REBALANCE_BLKSIZE) ? DHT_REBALANCE_BLKSIZE : (ia_size - total)); ret = syncop_readv (from, src, read_size, - offset, &vector, &count, &iobref); + offset, 0, &vector, &count, &iobref); if (!ret || (ret < 0)) { break; } @@ -273,7 +273,7 @@ __dht_rebalance_migrate_data (xlator_t *from, xlator_t *to, fd_t *src, fd_t *dst ret, offset, iobref); else ret = syncop_writev (to, dst, vector, count, - offset, iobref); + offset, iobref, 0); if (ret < 0) { break; } diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index 086f07f92ca..5385fb359e9 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -3692,7 +3692,7 @@ end: int32_t stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, - size_t size, off_t offset) + size_t size, off_t offset, uint32_t flags) { int32_t op_errno = EINVAL; int32_t idx = 0; @@ -3779,7 +3779,7 @@ stripe_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, idx = (index % fctx->stripe_count); STACK_WIND (rframe, stripe_readv_cbk, fctx->xl_array[idx], fctx->xl_array[idx]->fops->readv, - fd, frame_size, frame_offset); + fd, frame_size, frame_offset, flags); frame_offset += frame_size; } @@ -3842,7 +3842,7 @@ out: int32_t stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { struct iovec *tmp_vec = NULL; stripe_local_t *local = NULL; @@ -3915,7 +3915,7 @@ stripe_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, STACK_WIND (frame, stripe_writev_cbk, fctx->xl_array[idx], fctx->xl_array[idx]->fops->writev, fd, tmp_vec, - tmp_count, offset + offset_offset, iobref); + tmp_count, offset + offset_offset, flags, iobref); GF_FREE (tmp_vec); offset_offset += fill_size; if (remaining_size == 0) diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c index ca2ce488fa9..e44baf5b78d 100644 --- a/xlators/debug/error-gen/src/error-gen.c +++ b/xlators/debug/error-gen/src/error-gen.c @@ -1065,7 +1065,7 @@ error_gen_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int error_gen_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, uint32_t flags) { int op_errno = 0; eg_t *egp = NULL; @@ -1088,7 +1088,7 @@ error_gen_readv (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, error_gen_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; } @@ -1106,7 +1106,7 @@ error_gen_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int error_gen_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, - off_t off, struct iobref *iobref) + off_t off, uint32_t flags, struct iobref *iobref) { int op_errno = 0; eg_t *egp = NULL; @@ -1127,7 +1127,7 @@ error_gen_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, STACK_WIND (frame, error_gen_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, off, iobref); + fd, vector, count, off, flags, iobref); return 0; } diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index e47b062eebf..888c36dfbf2 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -2055,7 +2055,7 @@ io_stats_create (call_frame_t *frame, xlator_t *this, int io_stats_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, uint32_t flags) { frame->local = fd; @@ -2064,7 +2064,7 @@ io_stats_readv (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; } @@ -2073,7 +2073,7 @@ int io_stats_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { int len = 0; @@ -2081,14 +2081,13 @@ io_stats_writev (call_frame_t *frame, xlator_t *this, frame->local = fd->inode; len = iov_length (vector, count); - BUMP_WRITE (fd, len); START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); return 0; } diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index 91d069fd1eb..09c58bdfdc3 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -1813,19 +1813,21 @@ trace_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int trace_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, - size_t size, off_t offset) + size_t size, off_t offset, uint32_t flags) { if (trace_fop_names[GF_FOP_READ].enabled) { gf_log (this->name, GF_LOG_INFO, - "%"PRId64": gfid=%s fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")", - frame->root->unique, uuid_utoa (fd->inode->gfid), fd, size, offset); + "%"PRId64": gfid=%s fd=%p, size=%"GF_PRI_SIZET", " + "offset=%"PRId64" flags=0%x)", + frame->root->unique, uuid_utoa (fd->inode->gfid), + fd, size, offset, flags); frame->local = fd->inode->gfid; } STACK_WIND (frame, trace_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; } @@ -1833,20 +1835,21 @@ trace_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, int trace_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, - off_t offset, struct iobref *iobref) + off_t offset, uint32_t flags, struct iobref *iobref) { if (trace_fop_names[GF_FOP_WRITE].enabled) { gf_log (this->name, GF_LOG_INFO, - "%"PRId64": gfid=%s fd=%p, count=%d, offset=%"PRId64")", + "%"PRId64": gfid=%s fd=%p, count=%d, offset=%"PRId64 + " flag=0%x)", frame->root->unique, uuid_utoa (fd->inode->gfid), - fd, count, offset); + fd, count, offset, flags); frame->local = fd->inode->gfid; } STACK_WIND (frame, trace_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); return 0; } diff --git a/xlators/encryption/rot-13/src/rot-13.c b/xlators/encryption/rot-13/src/rot-13.c index 3cf925ed877..5e682020617 100644 --- a/xlators/encryption/rot-13/src/rot-13.c +++ b/xlators/encryption/rot-13/src/rot-13.c @@ -84,13 +84,13 @@ rot13_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { STACK_WIND (frame, rot13_readv_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; } @@ -112,19 +112,19 @@ rot13_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, - off_t offset, + int32_t count, + off_t offset, uint32_t flags, struct iobref *iobref) { rot_13_private_t *priv = (rot_13_private_t *)this->private; if (priv->encrypt_write) rot13_iovec (vector, count); - STACK_WIND (frame, + STACK_WIND (frame, rot13_writev_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev, - fd, vector, count, offset, + fd, vector, count, offset, flags, iobref); return 0; } diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 9025feb950a..7ce4ec942be 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -598,11 +598,11 @@ __rw_allowable (pl_inode_t *pl_inode, posix_lock_t *region, int pl_readv_cont (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, uint32_t flags) { STACK_WIND (frame, pl_readv_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; } @@ -610,7 +610,7 @@ pl_readv_cont (call_frame_t *frame, xlator_t *this, int pl_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, uint32_t flags) { posix_locks_private_t *priv = NULL; pl_inode_t *pl_inode = NULL; @@ -657,7 +657,7 @@ pl_readv (call_frame_t *frame, xlator_t *this, } rw->stub = fop_readv_stub (frame, pl_readv_cont, - fd, size, offset); + fd, size, offset, flags); if (!rw->stub) { op_errno = ENOMEM; op_ret = -1; @@ -677,7 +677,7 @@ pl_readv (call_frame_t *frame, xlator_t *this, if (wind_needed) { STACK_WIND (frame, pl_readv_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); } if (op_ret == -1) @@ -691,11 +691,11 @@ pl_readv (call_frame_t *frame, xlator_t *this, int pl_writev_cont (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { STACK_WIND (frame, pl_writev_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); return 0; } @@ -704,7 +704,7 @@ pl_writev_cont (call_frame_t *frame, xlator_t *this, fd_t *fd, int pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { posix_locks_private_t *priv = NULL; pl_inode_t *pl_inode = NULL; @@ -714,7 +714,6 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, int op_errno = 0; char wind_needed = 1; - priv = this->private; pl_inode = pl_inode_get (this, fd->inode); @@ -752,7 +751,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, rw->stub = fop_writev_stub (frame, pl_writev_cont, fd, vector, count, offset, - iobref); + flags, iobref); if (!rw->stub) { op_errno = ENOMEM; op_ret = -1; @@ -772,7 +771,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, if (wind_needed) STACK_WIND (frame, pl_writev_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); if (op_ret == -1) STACK_UNWIND_STRICT (writev, frame, -1, op_errno, NULL, NULL); diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index bbd448871d4..0a99740e97e 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -627,7 +627,7 @@ marker_writev (call_frame_t *frame, fd_t *fd, struct iovec *vector, int32_t count, - off_t offset, + off_t offset, uint32_t flags, struct iobref *iobref) { int32_t ret = 0; @@ -650,7 +650,7 @@ marker_writev (call_frame_t *frame, wind: STACK_WIND (frame, marker_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, fd, vector, count, offset, - iobref); + flags, iobref); return 0; err: STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL); diff --git a/xlators/features/quiesce/src/quiesce.c b/xlators/features/quiesce/src/quiesce.c index 57b2cdeacb0..1b150b21558 100644 --- a/xlators/features/quiesce/src/quiesce.c +++ b/xlators/features/quiesce/src/quiesce.c @@ -323,7 +323,8 @@ quiesce_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_ret == -1) && (op_errno == ENOTCONN)) { /* Re-transmit (by putting in the queue) */ stub = fop_readv_stub (frame, default_readv_resume, - local->fd, local->size, local->offset); + local->fd, local->size, local->offset, + local->io_flag); if (!stub) { STACK_UNWIND_STRICT (readv, frame, -1, ENOMEM, NULL, 0, NULL, NULL); @@ -700,7 +701,8 @@ quiesce_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* Re-transmit (by putting in the queue) */ stub = fop_writev_stub (frame, default_writev_resume, local->fd, local->vector, local->flag, - local->offset, local->iobref); + local->offset, local->io_flags, + local->iobref); if (!stub) { STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL); @@ -1786,7 +1788,7 @@ quiesce_writev (call_frame_t *frame, fd_t *fd, struct iovec *vector, int32_t count, - off_t off, + off_t off, uint32_t flags, struct iobref *iobref) { quiesce_priv_t *priv = NULL; @@ -1802,13 +1804,13 @@ quiesce_writev (call_frame_t *frame, fd, vector, count, - off, + off, flags, iobref); return 0; } stub = fop_writev_stub (frame, default_writev_resume, - fd, vector, count, off, iobref); + fd, vector, count, off, flags, iobref); if (!stub) { STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL); return 0; @@ -1824,7 +1826,7 @@ quiesce_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { quiesce_priv_t *priv = NULL; call_stub_t *stub = NULL; @@ -1837,6 +1839,7 @@ quiesce_readv (call_frame_t *frame, local->fd = fd_ref (fd); local->size = size; local->offset = offset; + local->io_flag = flags; frame->local = local; STACK_WIND (frame, @@ -1845,11 +1848,12 @@ quiesce_readv (call_frame_t *frame, FIRST_CHILD(this)->fops->readv, fd, size, - offset); + offset, flags); return 0; } - stub = fop_readv_stub (frame, default_readv_resume, fd, size, offset); + stub = fop_readv_stub (frame, default_readv_resume, fd, size, offset, + flags); if (!stub) { STACK_UNWIND_STRICT (readv, frame, -1, ENOMEM, NULL, 0, NULL, NULL); diff --git a/xlators/features/quiesce/src/quiesce.h b/xlators/features/quiesce/src/quiesce.h index 32b1935d979..1adb70ebe1f 100644 --- a/xlators/features/quiesce/src/quiesce.h +++ b/xlators/features/quiesce/src/quiesce.h @@ -55,6 +55,7 @@ typedef struct { entrylk_type type; gf_xattrop_flags_t xattrop_flags; int32_t wbflags; + uint32_t io_flag; } quiesce_local_t; #endif diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 32144c633bb..8df51bbbbfe 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -857,7 +857,7 @@ out: int32_t quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t off, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { quota_local_t *local = NULL; int32_t op_errno = EINVAL; @@ -875,7 +875,7 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, STACK_WIND (frame, quota_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, fd, vector, count, off, - iobref); + flags, iobref); return 0; unwind: @@ -887,7 +887,7 @@ unwind: int32_t quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t off, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { int32_t ret = -1, op_errno = EINVAL; int32_t parents = 0; @@ -919,7 +919,7 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, } stub = fop_writev_stub (frame, quota_writev_helper, fd, vector, count, - off, iobref); + off, flags, iobref); if (stub == NULL) { op_errno = ENOMEM; goto unwind; @@ -2295,7 +2295,7 @@ out: int32_t quota_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { quota_local_t *local = NULL; @@ -2309,7 +2309,7 @@ quota_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, local->loc.inode = inode_ref (fd->inode); STACK_WIND (frame, quota_readv_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readv, fd, size, offset); + FIRST_CHILD(this)->fops->readv, fd, size, offset, flags); return 0; unwind: diff --git a/xlators/features/read-only/src/read-only-common.c b/xlators/features/read-only/src/read-only-common.c index 5e4949ee0c2..efd1750811f 100644 --- a/xlators/features/read-only/src/read-only-common.c +++ b/xlators/features/read-only/src/read-only-common.c @@ -222,7 +222,7 @@ ro_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags) int32_t ro_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t off, struct iobref *iobref) + int32_t count, off_t off, uint32_t flags, struct iobref *iobref) { STACK_UNWIND_STRICT (writev, frame, -1, EROFS, NULL, NULL); return 0; diff --git a/xlators/features/read-only/src/read-only-common.h b/xlators/features/read-only/src/read-only-common.h index 3bc008e5978..8c89e88ce68 100644 --- a/xlators/features/read-only/src/read-only-common.h +++ b/xlators/features/read-only/src/read-only-common.h @@ -112,7 +112,7 @@ ro_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags); int32_t ro_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t off, struct iobref *iobref); + int32_t count, off_t off, uint32_t flags, struct iobref *iobref); int32_t ro_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index 42ee79a9691..38920db6c71 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -690,7 +690,7 @@ trash_truncate_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->fsize = stbuf->ia_size; STACK_WIND (frame, trash_truncate_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - local->newfd, vector, count, local->cur_offset, iobuf); + local->newfd, vector, count, local->cur_offset, 0, iobuf); out: return 0; @@ -723,7 +723,7 @@ trash_truncate_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, STACK_WIND (frame, trash_truncate_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, local->fd, (size_t)GF_BLOCK_READV_SIZE, - local->cur_offset); + local->cur_offset, 0); goto out; } @@ -763,7 +763,7 @@ trash_truncate_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, STACK_WIND (frame, trash_truncate_readv_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv, - local->fd, (size_t)GF_BLOCK_READV_SIZE, local->cur_offset); + local->fd, (size_t)GF_BLOCK_READV_SIZE, local->cur_offset, 0); out: return 0; @@ -1110,7 +1110,7 @@ trash_ftruncate_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, STACK_WIND (frame, trash_ftruncate_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, local->fd, (size_t)GF_BLOCK_READV_SIZE, - local->cur_offset); + local->cur_offset, 0); return 0; } @@ -1142,7 +1142,7 @@ trash_ftruncate_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, STACK_WIND (frame, trash_ftruncate_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - local->newfd, vector, count, local->cur_offset, NULL); + local->newfd, vector, count, local->cur_offset, 0, NULL); return 0; } @@ -1194,7 +1194,7 @@ trash_ftruncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, STACK_WIND (frame, trash_ftruncate_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, local->fd, - (size_t)GF_BLOCK_READV_SIZE, local->cur_offset); + (size_t)GF_BLOCK_READV_SIZE, local->cur_offset, 0); return 0; } diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 6537c0bcc83..1da2dcdb223 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -1902,7 +1902,7 @@ fuse_readv_resume (fuse_state_t *state) state->finh->unique, state->fd, state->size, state->off); FUSE_FOP (state, fuse_readv_cbk, GF_FOP_READ, - readv, state->fd, state->size, state->off); + readv, state->fd, state->size, state->off, state->io_flags); } static void @@ -1930,6 +1930,8 @@ fuse_readv (xlator_t *this, fuse_in_header_t *finh, void *msg) state->size = fri->size; state->off = fri->offset; + /* lets ignore 'fri->read_flags', but just consider 'fri->flags' */ + state->io_flags = fri->flags; fuse_resolve_and_resume (state, fuse_readv_resume); } @@ -1995,7 +1997,7 @@ fuse_write_resume (fuse_state_t *state) state->finh->unique, state->fd, state->size, state->off); FUSE_FOP (state, fuse_writev_cbk, GF_FOP_WRITE, writev, state->fd, - &state->vector, 1, state->off, iobref); + &state->vector, 1, state->off, state->io_flags, iobref); iobref_unref (iobref); } @@ -2021,6 +2023,13 @@ fuse_write (xlator_t *this, fuse_in_header_t *finh, void *msg) state->size = fwi->size; state->off = fwi->offset; + /* lets ignore 'fwi->write_flags', but just consider 'fwi->flags' */ + state->io_flags = fwi->flags; + /* TODO: may need to handle below flag + (fwi->write_flags & FUSE_WRITE_CACHE); + */ + + fuse_resolve_fd_init (state, &state->resolve, fd); /* See comment by similar code in fuse_settatr */ diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index 489e6d6456d..d9783f2e054 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -292,6 +292,7 @@ typedef struct { struct iovec vector; uuid_t gfid; + uint32_t io_flags; } fuse_state_t; typedef struct fuse_fd_ctx { diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c index 5c4ce2f96f4..8774da07581 100644 --- a/xlators/nfs/server/src/nfs-fops.c +++ b/xlators/nfs/server/src/nfs-fops.c @@ -1257,8 +1257,8 @@ nfs_fop_write (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, iobref_add (nfl->iobref, srciob); */ - STACK_WIND_COOKIE (frame, nfs_fop_writev_cbk, xl, xl,xl->fops->writev - , fd, vector, count, offset, srciobref); + STACK_WIND_COOKIE (frame, nfs_fop_writev_cbk, xl, xl,xl->fops->writev, + fd, vector, count, offset, 0, srciobref); ret = 0; err: if (ret < 0) { @@ -1351,7 +1351,7 @@ nfs_fop_read (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, nfs_fop_save_root_fd_ino (nfl, fd); STACK_WIND_COOKIE (frame, nfs_fop_readv_cbk, xl, xl, xl->fops->readv, - fd, size, offset); + fd, size, offset, 0); ret = 0; err: if (ret < 0) { diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 65df006cfe4..0ab36454c86 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -1087,7 +1087,7 @@ out: */ int32_t ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, - size_t size, off_t offset) + size_t size, off_t offset, uint32_t flags) { uint64_t tmp_ioc_inode = 0; ioc_inode_t *ioc_inode = NULL; @@ -1108,7 +1108,7 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, STACK_WIND (frame, ioc_readv_disabled_cbk, FIRST_CHILD (frame->this), FIRST_CHILD (frame->this)->fops->readv, fd, size, - offset); + offset, flags); return 0; } @@ -1167,7 +1167,7 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, STACK_WIND (frame, ioc_readv_disabled_cbk, FIRST_CHILD (frame->this), FIRST_CHILD (frame->this)->fops->readv, fd, size, - offset); + offset, flags); return 0; } @@ -1251,7 +1251,7 @@ ioc_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { ioc_local_t *local = NULL; uint64_t ioc_inode = 0; @@ -1274,7 +1274,7 @@ ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, STACK_WIND (frame, ioc_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, fd, vector, count, offset, - iobref); + flags, iobref); return 0; } diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c index 9afaf306235..93c4a51de3e 100644 --- a/xlators/performance/io-cache/src/page.c +++ b/xlators/performance/io-cache/src/page.c @@ -630,7 +630,7 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd, STACK_WIND (fault_frame, ioc_fault_cbk, FIRST_CHILD(fault_frame->this), FIRST_CHILD(fault_frame->this)->fops->readv, fd, - table->page_size, offset); + table->page_size, offset, 0); return; err: diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c index 2402f86d9f6..d3196d50b03 100644 --- a/xlators/performance/io-threads/src/io-threads.c +++ b/xlators/performance/io-threads/src/io-threads.c @@ -904,24 +904,24 @@ iot_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int iot_readv_wrapper (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { STACK_WIND (frame, iot_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; } int iot_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { call_stub_t *stub = NULL; int ret = -1; - stub = fop_readv_stub (frame, iot_readv_wrapper, fd, size, offset); + stub = fop_readv_stub (frame, iot_readv_wrapper, fd, size, offset, flags); if (!stub) { gf_log (this->name, GF_LOG_ERROR, "cannot create readv call stub" @@ -1056,12 +1056,12 @@ iot_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int iot_writev_wrapper (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, - off_t offset, struct iobref *iobref) + off_t offset, uint32_t flags, struct iobref *iobref) { STACK_WIND (frame, iot_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); return 0; } @@ -1069,13 +1069,13 @@ iot_writev_wrapper (call_frame_t *frame, xlator_t *this, fd_t *fd, int iot_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { call_stub_t *stub = NULL; int ret = -1; stub = fop_writev_stub (frame, iot_writev_wrapper, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); if (!stub) { gf_log (this->name, GF_LOG_ERROR, diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 6c9a0f0e5b5..14ff58b5157 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -48,7 +48,7 @@ out: int32_t qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset); + off_t offset, uint32_t flags); static void @@ -1026,7 +1026,7 @@ qr_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t qr_readv_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { qr_local_t *local = NULL; int32_t op_errno = EINVAL, ret = 0; @@ -1055,7 +1055,7 @@ qr_readv_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, } STACK_WIND (frame, qr_readv_cbk, FIRST_CHILD (this), - FIRST_CHILD (this)->fops->readv, fd, size, offset); + FIRST_CHILD (this)->fops->readv, fd, size, offset, flags); return 0; unwind: @@ -1066,7 +1066,7 @@ unwind: int32_t qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t read_flags) { qr_inode_t *qr_inode = NULL; int32_t ret = -1, op_ret = -1, op_errno = -1; @@ -1120,108 +1120,91 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, LOCK (&table->lock); { ret = inode_ctx_get (fd->inode, this, &value); - if (ret == 0) { - qr_inode = (qr_inode_t *)(long)value; - if (qr_inode) { - if (qr_inode->xattr){ - if (!just_validated - && qr_need_validation (conf, - qr_inode)) { - need_validation = 1; - goto unlock; - } + if (ret) + goto unlock; - content = dict_get (qr_inode->xattr, - GF_CONTENT_KEY); + qr_inode = (qr_inode_t *)(long)value; + if (!qr_inode || !qr_inode->xattr) + goto unlock; - stbuf = qr_inode->stbuf; - content_cached = 1; - list_move_tail (&qr_inode->lru, - &table->lru[qr_inode->priority]); - - if (offset > content->len) { - op_ret = 0; - end = content->len; - } else { - if ((offset + size) - > content->len) { - op_ret = content->len - - offset; - end = content->len; - } else { - op_ret = size; - end = offset + size; - } - } + if (!just_validated + && qr_need_validation (conf, qr_inode)) { + need_validation = 1; + goto unlock; + } - count = (op_ret - / iobuf_pool->default_page_size); - if ((op_ret % iobuf_pool->default_page_size) - != 0) { - count++; - } + content = dict_get (qr_inode->xattr, GF_CONTENT_KEY); - if (count == 0) { - op_ret = 0; - goto unlock; - } + stbuf = qr_inode->stbuf; + content_cached = 1; + list_move_tail (&qr_inode->lru, + &table->lru[qr_inode->priority]); - vector = GF_CALLOC (count, - sizeof (*vector), - gf_qr_mt_iovec); - if (vector == NULL) { - op_ret = -1; - op_errno = ENOMEM; - need_unwind = 1; - goto unlock; - } + if (offset > content->len) { + op_ret = 0; + end = content->len; + } else { + if ((offset + size) > content->len) { + op_ret = content->len - offset; + end = content->len; + } else { + op_ret = size; + end = offset + size; + } + } - iobref = iobref_new (); - if (iobref == NULL) { - op_ret = -1; - op_errno = ENOMEM; - need_unwind = 1; - goto unlock; - } + count = (op_ret / iobuf_pool->default_page_size); + if ((op_ret % iobuf_pool->default_page_size) != 0) { + count++; + } - for (i = 0; i < count; i++) { - iobuf = iobuf_get (iobuf_pool); - if (iobuf == NULL) { - op_ret = -1; - op_errno = ENOMEM; - need_unwind = 1; - goto unlock; - } + if (count == 0) { + op_ret = 0; + goto unlock; + } - start = offset - + - (iobuf_pool->default_page_size - * i); - - if (start > end) { - len = 0; - } else { - len = - (iobuf_pool->default_page_size - > (end - start)) - ? (end - start) - : - iobuf_pool->default_page_size; - - memcpy (iobuf->ptr, - content->data - + start, - len); - } + vector = GF_CALLOC (count, sizeof (*vector), gf_qr_mt_iovec); + if (vector == NULL) { + op_ret = -1; + op_errno = ENOMEM; + need_unwind = 1; + goto unlock; + } - iobref_add (iobref, iobuf); - iobuf_unref (iobuf); + iobref = iobref_new (); + if (iobref == NULL) { + op_ret = -1; + op_errno = ENOMEM; + need_unwind = 1; + goto unlock; + } - vector[i].iov_base = iobuf->ptr; - vector[i].iov_len = len; - } - } + for (i = 0; i < count; i++) { + iobuf = iobuf_get (iobuf_pool); + if (iobuf == NULL) { + op_ret = -1; + op_errno = ENOMEM; + need_unwind = 1; + goto unlock; + } + + start = offset + (iobuf_pool->default_page_size * i); + + if (start > end) { + len = 0; + } else { + len = (iobuf_pool->default_page_size > + ((end - start)) ? (end - start) : + iobuf_pool->default_page_size); + + memcpy (iobuf->ptr, content->data + start, len); } + + iobref_add (iobref, iobuf); + iobuf_unref (iobuf); + + vector[i].iov_base = iobuf->ptr; + vector[i].iov_len = len; } } unlock: @@ -1233,7 +1216,8 @@ out: count, &stbuf, iobref); } else if (need_validation) { - stub = fop_readv_stub (frame, qr_readv, fd, size, offset); + stub = fop_readv_stub (frame, qr_readv, fd, size, offset, + read_flags); if (stub == NULL) { op_ret = -1; op_errno = ENOMEM; @@ -1273,7 +1257,8 @@ out: stub = fop_readv_stub (frame, qr_readv_helper, fd, size, - offset); + offset, + read_flags); if (stub == NULL) { op_ret = -1; op_errno = ENOMEM; @@ -1319,9 +1304,8 @@ out: } else if (can_wind) { STACK_WIND (frame, qr_readv_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv, fd, size, - offset); + offset, read_flags); } - } ret: @@ -1351,7 +1335,7 @@ qr_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t qr_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t off, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { qr_local_t *local = NULL; qr_fd_ctx_t *fdctx = NULL; @@ -1382,7 +1366,7 @@ qr_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, STACK_WIND (frame, qr_writev_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev, fd, vector, count, off, - iobref); + flags, iobref); return 0; unwind: @@ -1393,7 +1377,7 @@ unwind: int32_t qr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t off, struct iobref *iobref) + int32_t count, off_t off, uint32_t wr_flags, struct iobref *iobref) { uint64_t value = 0; int flags = 0; @@ -1458,7 +1442,7 @@ qr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, stub = fop_writev_stub (frame, qr_writev_helper, fd, vector, count, off, - iobref); + wr_flags, iobref); if (stub == NULL) { op_ret = -1; op_errno = ENOMEM; @@ -1482,7 +1466,7 @@ qr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, } else if (can_wind) { STACK_WIND (frame, qr_writev_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev, fd, vector, count, - off, iobref); + off, wr_flags, iobref); } else if (need_open) { op_ret = qr_loc_fill (&loc, fd->inode, path); if (op_ret == -1) { diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c index 0c9a61853c8..8aa55c065c5 100644 --- a/xlators/performance/read-ahead/src/page.c +++ b/xlators/performance/read-ahead/src/page.c @@ -278,7 +278,7 @@ ra_page_fault (ra_file_t *file, call_frame_t *frame, off_t offset) STACK_WIND (fault_frame, ra_fault_cbk, FIRST_CHILD (fault_frame->this), FIRST_CHILD (fault_frame->this)->fops->readv, - file->fd, file->page_size, offset); + file->fd, file->page_size, offset, 0); return; diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c index b77715490fe..f58c4078db9 100644 --- a/xlators/performance/read-ahead/src/read-ahead.c +++ b/xlators/performance/read-ahead/src/read-ahead.c @@ -449,7 +449,7 @@ dispatch_requests (call_frame_t *frame, ra_file_t *file) STACK_WIND (ra_frame, ra_need_atime_cbk, FIRST_CHILD (frame->this), FIRST_CHILD (frame->this)->fops->readv, - file->fd, 1, 1); + file->fd, 1, 1, 0); } out: @@ -473,7 +473,7 @@ ra_readv_disabled_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { ra_file_t *file = NULL; ra_local_t *local = NULL; @@ -561,7 +561,7 @@ disabled: STACK_WIND (frame, ra_readv_disabled_cbk, FIRST_CHILD (frame->this), FIRST_CHILD (frame->this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; } @@ -666,7 +666,7 @@ ra_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int ra_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t offset, struct iobref *iobref) + int32_t count, off_t offset, uint32_t flags, struct iobref *iobref) { ra_file_t *file = NULL; uint64_t tmp_file = 0; @@ -688,7 +688,7 @@ ra_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, STACK_WIND (frame, ra_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); return 0; @@ -1030,12 +1030,10 @@ int init (xlator_t *this) { ra_conf_t *conf = NULL; - dict_t *options = NULL; int32_t ret = -1; GF_VALIDATE_OR_GOTO ("read-ahead", this, out); - options = this->options; if (!this->children || this->children->next) { gf_log (this->name, GF_LOG_ERROR, "FATAL: read-ahead not configured with exactly one" diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index a760e97a9a5..25ed6fa57b9 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -2793,7 +2793,7 @@ sp_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t sp_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { sp_fd_ctx_t *fd_ctx = NULL; uint64_t value = 0; @@ -2820,7 +2820,7 @@ sp_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, sp_remove_caches_from_all_fds_opened (this, parent, (char *)name); STACK_WIND (frame, sp_readv_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readv, fd, size, offset); + FIRST_CHILD(this)->fops->readv, fd, size, offset, flags); return 0; unwind: @@ -2831,7 +2831,7 @@ unwind: int32_t sp_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t off, struct iobref *iobref) + int32_t count, off_t off, uint32_t flags, struct iobref *iobref) { sp_fd_ctx_t *fd_ctx = NULL; uint64_t value = 0; @@ -2859,7 +2859,7 @@ sp_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, STACK_WIND (frame, sp_unlink_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, fd, vector, count, off, - iobref); + flags, iobref); return 0; unwind: diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index 52e03872026..7c666b40339 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -550,6 +550,7 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds) FIRST_CHILD(sync_frame->this)->fops->writev, fd, vector, count, first_request->stub->args.writev.off, + first_request->stub->args.writev.flags, iobref); iobref_unref (iobref); @@ -2071,7 +2072,7 @@ wb_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t offset, struct iobref *iobref) + int32_t count, off_t offset, uint32_t flags, struct iobref *iobref) { wb_file_t *file = NULL; char wb_disabled = 0; @@ -2139,7 +2140,7 @@ wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, if (wb_disabled) { STACK_WIND (frame, wb_writev_cbk, FIRST_CHILD (frame->this), FIRST_CHILD (frame->this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); return 0; } @@ -2159,7 +2160,8 @@ wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, frame->local = local; local->file = file; - stub = fop_writev_stub (frame, NULL, fd, vector, count, offset, iobref); + stub = fop_writev_stub (frame, NULL, fd, vector, count, offset, flags, + iobref); if (stub == NULL) { op_errno = ENOMEM; goto unwind; @@ -2236,10 +2238,10 @@ wb_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, static int32_t wb_readv_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { STACK_WIND (frame, wb_readv_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readv, fd, size, offset); + FIRST_CHILD(this)->fops->readv, fd, size, offset, flags); return 0; } @@ -2247,7 +2249,7 @@ wb_readv_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, int32_t wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { wb_file_t *file = NULL; wb_local_t *local = NULL; @@ -2286,7 +2288,7 @@ wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, frame->local = local; if (file) { stub = fop_readv_stub (frame, wb_readv_helper, fd, size, - offset); + offset, flags); if (stub == NULL) { op_errno = ENOMEM; goto unwind; @@ -2307,7 +2309,7 @@ wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, } else { STACK_WIND (frame, wb_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); } return 0; diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 5f11987034d..229e0191725 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -753,7 +753,7 @@ out: int32_t client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, uint32_t flags) { int ret = -1; clnt_conf_t *conf = NULL; @@ -767,6 +767,7 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, args.fd = fd; args.size = size; args.offset = offset; + args.flags = flags; proc = &conf->fops->proctable[GF_FOP_READ]; if (!proc) { @@ -792,7 +793,7 @@ out: int32_t client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t off, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { int ret = -1; clnt_conf_t *conf = NULL; @@ -807,6 +808,7 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, args.vector = vector; args.count = count; args.offset = off; + args.flags = flags; args.iobref = iobref; proc = &conf->fops->proctable[GF_FOP_WRITE]; diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index fe928aecd19..6ad646409bb 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -3420,6 +3420,8 @@ client3_1_readv (call_frame_t *frame, xlator_t *this, req.size = args->size; req.offset = args->offset; req.fd = remote_fd; + req.flag = args->flags; + memcpy (req.gfid, args->fd->inode->gfid, 16); /* TODO: what is the size we should send ? */ @@ -3508,6 +3510,8 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data) req.size = args->size; req.offset = args->offset; req.fd = remote_fd; + req.flag = args->flags; + memcpy (req.gfid, args->fd->inode->gfid, 16); ret = client_submit_vec_request (this, &req, frame, conf->fops, GFS3_OP_WRITE, diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index 62aca398dae..90f70256943 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -2389,7 +2389,7 @@ server_writev_resume (call_frame_t *frame, xlator_t *bound_xl) STACK_WIND (frame, server_writev_cbk, bound_xl, bound_xl->fops->writev, state->fd, state->payload_vector, state->payload_count, - state->offset, state->iobref); + state->offset, state->flags, state->iobref); return 0; err: @@ -2411,7 +2411,7 @@ server_readv_resume (call_frame_t *frame, xlator_t *bound_xl) STACK_WIND (frame, server_readv_cbk, bound_xl, bound_xl->fops->readv, - state->fd, state->size, state->offset); + state->fd, state->size, state->offset, state->flags); return 0; err: @@ -2937,6 +2937,8 @@ server_readv (rpcsvc_request_t *req) state->resolve.fd_no = args.fd; state->size = args.size; state->offset = args.offset; + state->flags = args.flag; + memcpy (state->resolve.gfid, args.gfid, 16); ret = 0; @@ -2984,6 +2986,7 @@ server_writev (rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; state->resolve.fd_no = args.fd; state->offset = args.offset; + state->flags = args.flag; state->iobref = iobref_ref (req->iobref); memcpy (state->resolve.gfid, args.gfid, 16); diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index b5957e4e9c6..7a66cd8c83e 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1820,7 +1820,7 @@ out: int posix_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, uint32_t flags) { int32_t op_ret = -1; int32_t op_errno = 0; @@ -2004,9 +2004,9 @@ err: int32_t -posix_writev (call_frame_t *frame, xlator_t *this, - fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) +posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, + struct iovec *vector, int32_t count, off_t offset, + uint32_t flags, struct iobref *iobref) { int32_t op_ret = -1; int32_t op_errno = 0; diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c index 8c84231476e..517af1f5bc9 100644 --- a/xlators/system/posix-acl/src/posix-acl.c +++ b/xlators/system/posix-acl/src/posix-acl.c @@ -955,7 +955,7 @@ posix_acl_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int posix_acl_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, - size_t size, off_t offset) + size_t size, off_t offset, uint32_t flags) { if (__is_fuse_call (frame)) goto green; @@ -968,7 +968,7 @@ posix_acl_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, green: STACK_WIND (frame, posix_acl_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset); + fd, size, offset, flags); return 0; red: STACK_UNWIND_STRICT (readv, frame, -1, EACCES, NULL, 0, NULL, NULL); @@ -990,7 +990,7 @@ posix_acl_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int posix_acl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref) { if (__is_fuse_call (frame)) goto green; @@ -1003,7 +1003,7 @@ posix_acl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, green: STACK_WIND (frame, posix_acl_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref); return 0; red: STACK_UNWIND_STRICT (writev, frame, -1, EACCES, NULL, NULL); |