On Fri, Oct 13 2006, Mark Fasheh wrote: > /* > + * We rarely want to lock two inodes that do not have a parent/child > + * relationship (such as directory, child inode) simultaneously. The > + * vast majority of file systems should be able to get along fine > + * without this. Do not use these functions except as a last resort. > + */ > +static inline 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); > + } > +} 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. The function should work for any of the inodes to be NULL, if exported as a helper. -- 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