diff options
author | Xavier Hernandez <xhernandez@datalab.es> | 2017-05-09 19:40:21 +0200 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2017-07-06 06:17:44 +0000 |
commit | eb96dd45f8e583c6bad84bf32ca17e2bb01dd38f (patch) | |
tree | 05ac9509ce817c6364ee6e278b3ffd322db686ea /xlators/cluster/ec/src/ec-inode-read.c | |
parent | b25bf64f3a3520a96ad557daa4903c0ceba96d72 (diff) |
cluster/ec: correctly handle end of file for seek
When a SEEK_HOLE was issued near to the end of file, sometimes an
offset beyond the end of file was returned. Another problem was that
using some offsets greater than the end of file returned successfully
instead of failing with ENXIO.
Change-Id: I238d2884ba02fd19a78116b0f8f8e8d6338fb3f5
BUG: 1449348
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: https://review.gluster.org/17228
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/cluster/ec/src/ec-inode-read.c')
-rw-r--r-- | xlators/cluster/ec/src/ec-inode-read.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c index d03b4483a67..d925e82ba36 100644 --- a/xlators/cluster/ec/src/ec-inode-read.c +++ b/xlators/cluster/ec/src/ec-inode-read.c @@ -1556,6 +1556,7 @@ void ec_wind_seek(ec_t *ec, ec_fop_data_t *fop, int32_t idx) int32_t ec_manager_seek(ec_fop_data_t *fop, int32_t state) { ec_cbk_data_t *cbk; + size_t size; switch (state) { case EC_STATE_INIT: @@ -1571,6 +1572,16 @@ int32_t ec_manager_seek(ec_fop_data_t *fop, int32_t state) return EC_STATE_DISPATCH; case EC_STATE_DISPATCH: + /* This shouldn't fail because we have the inode locked. */ + GF_ASSERT(ec_get_inode_size(fop, fop->locks[0].lock->loc.inode, + &size)); + + if (fop->user_size >= size) { + ec_fop_set_error(fop, ENXIO); + + return EC_STATE_REPORT; + } + ec_dispatch_one(fop); return EC_STATE_PREPARE_ANSWER; @@ -1582,10 +1593,17 @@ int32_t ec_manager_seek(ec_fop_data_t *fop, int32_t state) if ((cbk != NULL) && (cbk->op_ret >= 0)) { ec_t *ec = fop->xl->private; + /* This shouldn't fail because we have the inode locked. */ + GF_ASSERT(ec_get_inode_size(fop, fop->locks[0].lock->loc.inode, + &size)); + cbk->offset *= ec->fragments; if (cbk->offset < fop->user_size) { cbk->offset = fop->user_size; } + if (cbk->offset > size) { + cbk->offset = size; + } } return EC_STATE_REPORT; |