diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2019-04-12 11:35:55 +0800 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2019-05-08 14:20:13 +0000 |
commit | 515866cd49aadf52c9949f8745fd2ba1ea9c99c3 (patch) | |
tree | 09be90400272b3760eb4f3e5de34d6685b08523e /xlators | |
parent | 09cb7406c28052c4643b2cb6e0ab986331b9576b (diff) |
ec: fix truncate lock to cover the write in tuncate clean
ec_truncate_clean does writing under the lock granted for truncate,
but the lock is calculated by ec_adjust_offset_up, so that,
the write in ec_truncate_clean is out of lock.
Updates: bz#1699500
Change-Id: I15ed1b0807d75c5eb817323f1c227e97d03e0e7c
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
(cherry picked from commit 0e1223491e964096384edfae5032ed0d50d028ad)
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/ec/src/ec-inode-write.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c index ffdac632683..4583dbd622b 100644 --- a/xlators/cluster/ec/src/ec-inode-write.c +++ b/xlators/cluster/ec/src/ec-inode-write.c @@ -1405,6 +1405,7 @@ int32_t ec_manager_truncate(ec_fop_data_t *fop, int32_t state) { ec_cbk_data_t *cbk; + off_t offset_down; switch (state) { case EC_STATE_INIT: @@ -1416,16 +1417,19 @@ ec_manager_truncate(ec_fop_data_t *fop, int32_t state) /* Fall through */ case EC_STATE_LOCK: + offset_down = fop->user_size; + ec_adjust_offset_down(fop->xl->private, &offset_down, _gf_true); + if (fop->id == GF_FOP_TRUNCATE) { ec_lock_prepare_inode( fop, &fop->loc[0], EC_UPDATE_DATA | EC_UPDATE_META | EC_QUERY_INFO, - fop->offset, LLONG_MAX); + offset_down, LLONG_MAX); } else { ec_lock_prepare_fd( fop, fop->fd, EC_UPDATE_DATA | EC_UPDATE_META | EC_QUERY_INFO, - fop->offset, LLONG_MAX); + offset_down, LLONG_MAX); } ec_lock(fop); |