[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [dm-devel] [PATCH] multipath: fix multipath locking



Benjamin Marzinski [bmarzins redhat com] wrote:
> @@ -294,12 +295,25 @@ lock_multipath (struct multipath * mpp, 
>  		vector_foreach_slot(pgp->paths, pp, j) {
>  			if (lock && flock(pp->fd, LOCK_EX | LOCK_NB) &&
>  			    errno == EWOULDBLOCK)
> -				return 1;
> +				goto fail;
>  			else if (!lock)
>  				flock(pp->fd, LOCK_UN);
>  		}
>  	}
>  	return 0;
> +fail:
> +	vector_foreach_slot (mpp->pg, pgp, x) {
> +		if (x > i)
> +			return 1;
> +		if (!pgp->paths)
> +			continue;
> +		vector_foreach_slot(pgp->paths, pp, y) {
> +			if (x == i && y > j)

Path 'j' has failed to get the lock dropping us to the fail label.
We should NOT be unlocking for path "j", so the above if expression
should be "(x ==i && y >= j)" instead.

Otherwise, it looks good.

> +				return 1;
> +			flock(pp->fd, LOCK_UN);
> +		}
> +	}
> +	return 1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]