Re: [PATCH 13/15] cifs: convert cifsFileInfo->count to non-atomic counter

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

 



On Thu, 7 Oct 2010 12:59:32 -0400
Jeff Layton <jlayton@xxxxxxxxxx> wrote:
> 
> For instance:
> 
> +	if (!atomic_dec_and_lock(&cifs_file->count, &cifs_file_list_lock))
> +		return;
> +
> +	/* count can be incremented inside the lock, so must check again */
> +	if (atomic_read(&cifs_file->count) > 0) {
> +		spin_unlock(&cifs_file_list_lock);
> +		return;
> +	}
> 

...oh and to make matters worse, the above code is still racy if the
count can be incremented outside the lock too.

I think we need to try to keep this code as simple as possible with
clear, unambiguous locking rules around a simple counter.

-- 
Jeff Layton <jlayton@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux