direct-io.hg

changeset 11652:5f5e3b4c6fba

[BLKTAP] Fix SMP debugging assert failures in blktap
blktap is calling non-atomic kernel functions with irqs disabled, which
hits various kernel debug traps if those are enabled. The problem is
req_increase(), which takes the pending_free_lock.

This function is currently only ever called from module initialiation,
where it is impossible for it to race against anything else. Its
companion, req_decrease(), is not called at all.

Fix by removing the offending locking from req_increase() and, while
we're at it, remove req_decrease() entirely.

Signed-off-by: Stephen Tweedie <sct@redhat.com>
author Andrew Warfield <andy@xensource.com>
date Thu Sep 28 12:03:01 2006 -0700 (2006-09-28)
parents 460f2c954cca
children 3b7e11cbeb94
files linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Sep 28 11:52:17 2006 -0700
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Sep 28 12:03:01 2006 -0700
     1.3 @@ -694,11 +694,8 @@ static int req_increase(void)
     1.4  {
     1.5  	int i, j;
     1.6  	struct page *page;
     1.7 -	unsigned long flags;
     1.8  	int ret;
     1.9  
    1.10 -	spin_lock_irqsave(&pending_free_lock, flags);
    1.11 -
    1.12  	ret = -EINVAL;
    1.13  	if (mmap_alloc >= MAX_PENDING_REQS || mmap_lock) 
    1.14  		goto done;
    1.15 @@ -763,8 +760,7 @@ static int req_increase(void)
    1.16  
    1.17  	mmap_alloc++;
    1.18  	DPRINTK("# MMAPs increased to %d\n",mmap_alloc);
    1.19 - done:
    1.20 -	spin_unlock_irqrestore(&pending_free_lock, flags);
    1.21 +done:
    1.22  	return ret;
    1.23  }
    1.24  
    1.25 @@ -794,37 +790,6 @@ static void mmap_req_del(int mmap)
    1.26  	mmap_alloc--;
    1.27  }
    1.28  
    1.29 -/*N.B. Currently unused - will be accessed via sysfs*/
    1.30 -static void req_decrease(void)
    1.31 -{
    1.32 -	pending_req_t *req;
    1.33 -	int i;
    1.34 -	unsigned long flags;
    1.35 -
    1.36 -	spin_lock_irqsave(&pending_free_lock, flags);
    1.37 -
    1.38 -	DPRINTK("Req decrease called.\n");
    1.39 -	if (mmap_lock || mmap_alloc == 1) 
    1.40 -		goto done;
    1.41 -
    1.42 -	mmap_lock = 1;
    1.43 -	mmap_inuse = MAX_PENDING_REQS;
    1.44 -	
    1.45 -        /*Go through reqs and remove any that aren't in use*/
    1.46 -	for (i = 0; i < MAX_PENDING_REQS ; i++) {
    1.47 -		req = &pending_reqs[mmap_alloc-1][i];
    1.48 -		if (req->inuse == 0) {
    1.49 -			list_del(&req->free_list);
    1.50 -			mmap_inuse--;
    1.51 -		}
    1.52 -	}
    1.53 -	if (mmap_inuse == 0)
    1.54 -		mmap_req_del(mmap_alloc-1);
    1.55 - done:
    1.56 -	spin_unlock_irqrestore(&pending_free_lock, flags);
    1.57 -	return;
    1.58 -}
    1.59 -
    1.60  static pending_req_t* alloc_req(void)
    1.61  {
    1.62  	pending_req_t *req = NULL;