Bug 783036

Summary: unlocking without holding the lock may lead to failures
Product: [Community] GlusterFS Reporter: Raghavendra Bhat <rabhat>
Component: replicateAssignee: Raghavendra Bhat <rabhat>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: mainlineCC: gluster-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-3.4.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-24 18:00:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 817967    

Description Raghavendra Bhat 2012-01-19 05:59:39 UTC
Description of problem:

        GF_ASSERT (local->fd);
        if (pause_fop)
                GF_ASSERT (local->fop_call_continue);

        ret = afr_prepare_loc (frame, local->fd);
        if (ret < 0) {
		//File does not exist we cant open it.                                                                                        
                ret = 0;
                goto out;
        }

        fd_ctx = afr_fd_ctx_get (local->fd, this);
        if (!fd_ctx) {
                ret = -EINVAL;
                goto unlock;
        }

In the above function call if we cannot get the fd context, then we are going to unlock where we are unlocking the local->fd->lock. But the locking itself is happening later (below piece of code.)

        LOCK (&local->fd->lock);
        {
                if (fd_ctx->up_count < priv->up_count) {
                        need_self_heal = _gf_true;
                        fd_ctx->up_count   = priv->up_count;
                        fd_ctx->down_count = priv->down_count;


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Anand Avati 2012-01-19 17:03:45 UTC
CHANGE: http://review.gluster.com/2658 (cluster/afr: do not unlock without holding the lock on the fd) merged in master by Vijay Bellur (vijay)

Comment 2 Raghavendra Bhat 2012-02-20 05:50:16 UTC
Tested with glusterfs-3.3.0qa22. Now it unlock is not happening without holding the lock.