From e8b4e119e00f3599acb0ea95f8237cf9b07546a3 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Thu, 8 Dec 2016 14:53:04 +0530 Subject: cluster/ec: Fix lk-owner set race in ec_unlock Problem: Rename does two locks. There is a case where when it tries to unlock it sends xattrop of the directory with new version, callback of these two xattrops can be picked up by two separate epoll threads. Both of them will try to set the lk-owner for unlock in parallel on the same frame so one of these unlocks will fail because the lk-owner doesn't match. Fix: Specify the lk-owner which will be set on inodelk frame which will not be over written by any other thread/operation. >BUG: 1402710 >Change-Id: I666ffc931440dc5253d72df666efe0ef1d73f99a >Signed-off-by: Pranith Kumar K >Reviewed-on: http://review.gluster.org/16074 >Reviewed-by: Xavier Hernandez >Smoke: Gluster Build System >NetBSD-regression: NetBSD Build System >CentOS-regression: Gluster Build System BUG: 1404572 Change-Id: Iff4f0c1364e6533f3c07f192138bcd321789b4cd Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/16130 Reviewed-by: Xavier Hernandez Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- xlators/cluster/ec/src/ec-common.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'xlators/cluster/ec/src/ec-common.c') diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c index 28177bb98e1..431de280175 100644 --- a/xlators/cluster/ec/src/ec-common.c +++ b/xlators/cluster/ec/src/ec-common.c @@ -1473,20 +1473,21 @@ gf_boolean_t ec_lock_acquire(ec_lock_link_t *link) { ec_lock_t *lock; ec_fop_data_t *fop; + gf_lkowner_t lk_owner; lock = link->lock; fop = link->fop; if (!lock->acquired) { - ec_owner_set(fop->frame, lock); + set_lk_owner_from_ptr(&lk_owner, lock); ec_trace("LOCK_ACQUIRE", fop, "lock=%p, inode=%p", lock, lock->loc.inode); lock->flock.l_type = F_WRLCK; - ec_inodelk(fop->frame, fop->xl, -1, EC_MINIMUM_ALL, ec_locked, - link, fop->xl->name, &lock->loc, F_SETLKW, &lock->flock, - NULL); + ec_inodelk(fop->frame, fop->xl, &lk_owner, -1, EC_MINIMUM_ALL, + ec_locked, link, fop->xl->name, &lock->loc, F_SETLKW, + &lock->flock, NULL); return _gf_false; } @@ -1785,6 +1786,7 @@ void ec_unlock_lock(ec_lock_link_t *link) { ec_lock_t *lock; ec_fop_data_t *fop; + gf_lkowner_t lk_owner; lock = link->lock; fop = link->fop; @@ -1793,12 +1795,12 @@ void ec_unlock_lock(ec_lock_link_t *link) ec_clear_inode_info(fop, lock->loc.inode); if ((lock->mask != 0) && lock->acquired) { - ec_owner_set(fop->frame, lock); + set_lk_owner_from_ptr(&lk_owner, lock); lock->flock.l_type = F_UNLCK; ec_trace("UNLOCK_INODELK", fop, "lock=%p, inode=%p", lock, lock->loc.inode); - ec_inodelk(fop->frame, fop->xl, lock->mask, EC_MINIMUM_ONE, + ec_inodelk(fop->frame, fop->xl, &lk_owner, lock->mask, EC_MINIMUM_ONE, ec_unlocked, link, fop->xl->name, &lock->loc, F_SETLK, &lock->flock, NULL); } else { -- cgit