2576c2576
< static struct dentry *__kern_path_locked(int dfd, struct filename *name, struct path *path)
---
> static struct dentry *__kern_path_locked(struct filename *name, struct path *path)
2582c2582
< error = filename_parentat(dfd, name, 0, path, &last, &type);
---
> error = filename_parentat(AT_FDCWD, name, 0, path, &last, &type);
2601c2601
< struct dentry *res = __kern_path_locked(AT_FDCWD, filename, path);
---
> struct dentry *res = __kern_path_locked(filename, path);
2607,2616d2606
< struct dentry *user_path_locked_at(int dfd, const char __user *name, struct path *path)
< {
< struct filename *filename = getname(name);
< struct dentry *res = __kern_path_locked(dfd, filename, path);
<
< putname(filename);
< return res;
< }
< EXPORT_SYMBOL(user_path_locked_at);
<
3034c3024
< inode_lock_nested(p1->d_inode, I_MUTEX_CHILD);
---
> inode_lock_nested(p1->d_inode, I_MUTEX_PARENT2);
3039,3047c3029,3031
< if (p) {
< inode_lock_nested(p1->d_inode, I_MUTEX_PARENT);
< inode_lock_nested(p2->d_inode, I_MUTEX_CHILD);
< return p;
< }
<
< lock_two_inodes(p1->d_inode, p2->d_inode,
< I_MUTEX_PARENT, I_MUTEX_PARENT2);
< return NULL;
---
> inode_lock_nested(p1->d_inode, I_MUTEX_PARENT);
> inode_lock_nested(p2->d_inode, I_MUTEX_PARENT2);
> return p;
4729c4713
< * That's where 4.4 screws up. Current fix: serialization on
---
> * That's where 4.4BSD screws up. Current fix: serialization on
4732,4733c4716,4718
< * c) we have to lock _four_ objects - parents and victim (if it exists),
< * and source.
---
> * c) we may have to lock up to _four_ objects - parents and victim (if it exists),
> * and source (if it's a non-directory or a subdirectory that moves to
> * different parent).
4764a4750
> bool lock_old_subdir, lock_new_subdir;
4818,4824c4804,4814
< * Lock all moved children. Moved directories may need to change parent
< * pointer so they need the lock to prevent against concurrent
< * directory changes moving parent pointer. For regular files we've
< * historically always done this. The lockdep locking subclasses are
< * somewhat arbitrary but RENAME_EXCHANGE in particular can swap
< * regular files and directories so it's difficult to tell which
< * subclasses to use.
---
> * Lock children.
> * The source subdirectory needs to be locked on cross-directory
> * rename or cross-directory exchange since its parent changes.
> * The target subdirectory needs to be locked on cross-directory
> * exchange due to parent change and on any rename due to becoming
> * a victim.
> * Non-directories need locking in all cases (for NFS reasons);
> * they get locked after any subdirectories (in inode address order).
> *
> * NOTE: WE ONLY LOCK UNRELATED DIRECTORIES IN CROSS-DIRECTORY CASE.
> * NEVER, EVER DO THAT WITHOUT ->s_vfs_rename_mutex.
4826c4816,4829
< lock_two_inodes(source, target, I_MUTEX_NORMAL, I_MUTEX_NONDIR2);
---
> lock_old_subdir = new_dir != old_dir;
> lock_new_subdir = new_dir != old_dir || !(flags & RENAME_EXCHANGE);
> if (is_dir) {
> if (lock_old_subdir)
> inode_lock_nested(source, I_MUTEX_CHILD);
> if (target && (!new_is_dir || lock_new_subdir))
> inode_lock(target);
> } else if (new_is_dir) {
> if (lock_new_subdir)
> inode_lock_nested(target, I_MUTEX_CHILD);
> inode_lock(source);
> } else {
> lock_two_nondirectories(source, target);
> }
4874,4875c4877,4879
< inode_unlock(source);
< if (target)
---
> if (!is_dir || lock_old_subdir)
> inode_unlock(source);
> if (target && (!new_is_dir || lock_new_subdir))