Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs

Pull filesystem fixes from Al Viro:
 "Several bugfixes (all of them -stable fodder).

  Alexey's one deals with double mutex_lock() in UFS (apparently, nobody
  has tried to test "ufs: sb mutex merge + mutex_destroy" on something
  like file creation/removal on ufs).  Mine deal with two kinds of
  umount bugs, in umount propagation and in handling of automounted
  submounts, both resulting in bogus transient EBUSY from umount"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  ufs: fix deadlocks introduced by sb mutex merge
  fix EBUSY on umount() from MNT_SHRINKABLE
  get rid of propagate_umount() mistakenly treating slaves as busy.
  • Loading branch information
torvalds committed Sep 7, 2014
2 parents 81368f8 + 9ef7db7 commit 9142ead
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
10 changes: 9 additions & 1 deletion fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,11 @@ static void namespace_unlock(void)
head.first->pprev = &head.first;
INIT_HLIST_HEAD(&unmounted);

/* undo decrements we'd done in umount_tree() */
hlist_for_each_entry(mnt, &head, mnt_hash)
if (mnt->mnt_ex_mountpoint.mnt)
mntget(mnt->mnt_ex_mountpoint.mnt);

up_write(&namespace_sem);

synchronize_rcu();
Expand Down Expand Up @@ -1253,6 +1258,9 @@ void umount_tree(struct mount *mnt, int how)
hlist_add_head(&p->mnt_hash, &tmp_list);
}

hlist_for_each_entry(p, &tmp_list, mnt_hash)
list_del_init(&p->mnt_child);

if (how)
propagate_umount(&tmp_list);

Expand All @@ -1263,9 +1271,9 @@ void umount_tree(struct mount *mnt, int how)
p->mnt_ns = NULL;
if (how < 2)
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
list_del_init(&p->mnt_child);
if (mnt_has_parent(p)) {
put_mountpoint(p->mnt_mp);
mnt_add_count(p->mnt_parent, -1);
/* move the reference to mountpoint into ->mnt_ex_mountpoint */
p->mnt_ex_mountpoint.dentry = p->mnt_mountpoint;
p->mnt_ex_mountpoint.mnt = &p->mnt_parent->mnt;
Expand Down
1 change: 1 addition & 0 deletions fs/pnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ static void __propagate_umount(struct mount *mnt)
* other children
*/
if (child && list_empty(&child->mnt_mounts)) {
list_del_init(&child->mnt_child);
hlist_del_init_rcu(&child->mnt_hash);
hlist_add_before_rcu(&child->mnt_hash, &mnt->mnt_hash);
}
Expand Down
7 changes: 2 additions & 5 deletions fs/ufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,6 @@ void ufs_evict_inode(struct inode * inode)
invalidate_inode_buffers(inode);
clear_inode(inode);

if (want_delete) {
lock_ufs(inode->i_sb);
ufs_free_inode (inode);
unlock_ufs(inode->i_sb);
}
if (want_delete)
ufs_free_inode(inode);
}
14 changes: 6 additions & 8 deletions fs/ufs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
if (l > sb->s_blocksize)
goto out_notlocked;

lock_ufs(dir->i_sb);
inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out;
goto out_notlocked;

lock_ufs(dir->i_sb);
if (l > UFS_SB(sb)->s_uspi->s_maxsymlinklen) {
/* slow symlink */
inode->i_op = &ufs_symlink_inode_operations;
Expand Down Expand Up @@ -181,20 +181,19 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
struct inode * inode;
int err;

lock_ufs(dir->i_sb);
inode_inc_link_count(dir);

inode = ufs_new_inode(dir, S_IFDIR|mode);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_dir;
return PTR_ERR(inode);

inode->i_op = &ufs_dir_inode_operations;
inode->i_fop = &ufs_dir_operations;
inode->i_mapping->a_ops = &ufs_aops;

inode_inc_link_count(inode);

lock_ufs(dir->i_sb);
inode_inc_link_count(dir);

err = ufs_make_empty(inode, dir);
if (err)
goto out_fail;
Expand All @@ -212,7 +211,6 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
inode_dec_link_count(inode);
inode_dec_link_count(inode);
iput (inode);
out_dir:
inode_dec_link_count(dir);
unlock_ufs(dir->i_sb);
goto out;
Expand Down

0 comments on commit 9142ead

Please sign in to comment.