Re: i_mutex locking in generic_file_splice_write()

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

 



On Sun, Oct 15 2006, Mark Fasheh wrote:
> On Sun, Oct 15, 2006 at 08:05:20PM +0200, Jens Axboe wrote:
> > This wont fly, it's completely tailored to splice in that one one inode
> > can be NULL. It also requires the 2nd inode to be that potentially NULL
> > pointer.
> *shrug* from my memory, 1st pointer always valid, 2nd possibly NULL seemed
> to be a common paradigm, though I can't really point to any code, now that I
> think of it.
> 
> 
> > The function should work for any of the inodes to be NULL, if exported
> > as a helper.
> Here's a version that also handles both inodes being the same. We're quickly
> approaching an elevated level of scariness in inode_double_lock :) Also,
> things have been un-inlined.

Hmm, it doesn't seem any different :-). Bad diff attached?

> +void inode_double_lock(struct inode *inode1, struct inode *inode2)
> +{
> +	if (!inode2) {
> +		mutex_lock(&inode1->i_mutex);
> +		return;
> +	}
> +
> +	if (inode1 < inode2) {
> +		mutex_lock_nested(&inode1->i_mutex, I_MUTEX_PARENT);
> +		mutex_lock_nested(&inode2->i_mutex, I_MUTEX_CHILD);
> +	} else {
> +		mutex_lock_nested(&inode2->i_mutex, I_MUTEX_PARENT);
> +		mutex_lock_nested(&inode1->i_mutex, I_MUTEX_CHILD);
> +	}
> +}

-- 
Jens Axboe

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux