From 0ee0cfae80f7b17115b78d76610b995edb1bfa8b Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Wed, 10 Sep 2014 23:43:07 +0200 Subject: ec: Fix invalid inode lock in ftruncate The fops 'truncate' and 'ftruncate' share some code and inodelk() was always made against the inode inside the loc_t structure instead of that of fd_t. Since ftruncate has the loc initialized to NULL, this fop was executed without any lock, allowing some concurrent modifications in the file size. Also changed the way in which 'fop' and 'ffop' are differentiated in shared code. Now it uses 'id' field instead of checking if 'fd' is NULL. Change-Id: Ibd18accf2652193b395a841b9029729e5f4867c6 BUG: 1140396 Signed-off-by: Xavier Hernandez Reviewed-on: http://review.gluster.org/8695 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/ec/src/ec-inode-write.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'xlators/cluster/ec/src/ec-inode-write.c') diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c index edc7409854d..7e557f12aa3 100644 --- a/xlators/cluster/ec/src/ec-inode-write.c +++ b/xlators/cluster/ec/src/ec-inode-write.c @@ -138,7 +138,7 @@ int32_t ec_manager_removexattr(ec_fop_data_t * fop, int32_t state) GF_ASSERT(cbk != NULL); - if (fop->fd == NULL) + if (fop->id == GF_FOP_REMOVEXATTR) { if (fop->cbks.removexattr != NULL) { @@ -165,7 +165,7 @@ int32_t ec_manager_removexattr(ec_fop_data_t * fop, int32_t state) case -EC_STATE_REPORT: GF_ASSERT(fop->error != 0); - if (fop->fd == NULL) + if (fop->id == GF_FOP_REMOVEXATTR) { if (fop->cbks.removexattr != NULL) { @@ -547,7 +547,7 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state) GF_ASSERT(cbk != NULL); - if (fop->fd == NULL) + if (fop->id == GF_FOP_SETATTR) { if (fop->cbks.setattr != NULL) { @@ -577,7 +577,7 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state) case -EC_STATE_REPORT: GF_ASSERT(fop->error != 0); - if (fop->fd == NULL) + if (fop->id == GF_FOP_SETATTR) { if (fop->cbks.setattr != NULL) { @@ -924,7 +924,7 @@ int32_t ec_manager_setxattr(ec_fop_data_t * fop, int32_t state) GF_ASSERT(cbk != NULL); - if (fop->fd == NULL) + if (fop->id == GF_FOP_SETXATTR) { if (fop->cbks.setxattr != NULL) { @@ -950,7 +950,7 @@ int32_t ec_manager_setxattr(ec_fop_data_t * fop, int32_t state) case -EC_STATE_REPORT: GF_ASSERT(fop->error != 0); - if (fop->fd == NULL) + if (fop->id == GF_FOP_SETXATTR) { if (fop->cbks.setxattr != NULL) { @@ -1378,7 +1378,7 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state) /* Fall through */ case EC_STATE_LOCK: - if (fop->fd == NULL) + if (fop->id == GF_FOP_TRUNCATE) { ec_lock_prepare_inode(fop, &fop->loc[0]); } @@ -1446,7 +1446,7 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state) GF_ASSERT(cbk != NULL); - if (fop->fd == NULL) + if (fop->id == GF_FOP_TRUNCATE) { if (fop->cbks.truncate != NULL) { @@ -1476,7 +1476,7 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state) case -EC_STATE_REPORT: GF_ASSERT(fop->error != 0); - if (fop->fd == NULL) + if (fop->id == GF_FOP_TRUNCATE) { if (fop->cbks.truncate != NULL) { -- cgit