Skip to contentSkip to conversation

Btrfs: remove mnt_want_write call in btrfs_mksubvol

PATCH In review Alexander Block 4 participants 5 messages Aug 2, 2012 – Aug 8, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: remove mnt_want_write call in btrfs_mksubvol

We got a recursive lock in mksubvol because the caller already held a lock. I think we got into this due to a merge error. Commit a874a63 removed the mnt_want_write call from btrfs_mksubvol and added a replacement call to mnt_want_write_file in btrfs_ioctl_snap_create_transid. Commit e7848683 however tried to move all calls to mnt_want_write above i_mutex. So somewhere while merging this, it got mixed up. The solution is to remove the mnt_want_write call completely from mksubvol.

---
 fs/btrfs/ioctl.c |    5 -----
 1 file changed, 5 deletions(-)
fs/btrfs/ioctl.c +0 -5
index 00ddf22..9df50fa 100644
@@ -664,10 +664,6 @@ static noinline int btrfs_mksubvol(struct path *parent,
 	struct dentry *dentry;
 	int error;
 
-	error = mnt_want_write(parent->mnt);
-	if (error)
-		return error;
-
 	mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
 
 	dentry = lookup_one_len(name, parent->dentry, namelen);
@@ -703,7 +699,6 @@ out_dput:
 	dput(dentry);
 out_unlock:
 	mutex_unlock(&dir->i_mutex);
-	mnt_drop_write(parent->mnt);
 	return error;
 }
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 31 lines · Alexander Block

We got a recursive lock in mksubvol because the caller already held a lock. I think we got into this due to a merge error. Commit a874a63 removed the mnt_want_write call from btrfs_mksubvol and added a replacement call to mnt_want_write_file in btrfs_ioctl_snap_create_transid. Commit e7848683 however tried to move all calls to mnt_want_write above i_mutex. So somewhere while merging this, it got mixed up. The solution is to remove the mnt_want_write call completely from mksubvol.

---
 fs/btrfs/ioctl.c |    5 -----
 1 file changed, 5 deletions(-)
fs/btrfs/ioctl.c +0 -4
index 00ddf22..9df50fa 100644
@@ -664,10 +664,6 @@ static noinline int btrfs_mksubvol(struct path *parent,
 	struct dentry *dentry;
 	int error;
 
-	error = mnt_want_write(parent->mnt);
-	if (error)
-		return error;
-
 	mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
 
 	dentry = lookup_one_len(name, parent->dentry, namelen);

fs/btrfs/ioctl.c out_dput: · line 704

Quoted 7 lines
fs/btrfs/ioctl.c +0 -1
@@ -703,7 +699,6 @@ out_dput:
 	dput(dentry);
 out_unlock:
 	mutex_unlock(&dir->i_mutex);
-	mnt_drop_write(parent->mnt);
 	return error;
 }
 

I'm confused, this isn't here in btrfs-next, so is this a problem still? Thanks,

Josef

#2 lore raw
Quoted 30 lines · Josef Bacik
Quoted 29 lines · Alexander Block

We got a recursive lock in mksubvol because the caller already held a lock. I think we got into this due to a merge error. Commit a874a63 removed the mnt_want_write call from btrfs_mksubvol and added a replacement call to mnt_want_write_file in btrfs_ioctl_snap_create_transid. Commit e7848683 however tried to move all calls to mnt_want_write above i_mutex. So somewhere while merging this, it got mixed up. The solution is to remove the mnt_want_write call completely from mksubvol.

---
 fs/btrfs/ioctl.c |    5 -----
 1 file changed, 5 deletions(-)
fs/btrfs/ioctl.c +0 -4
index 00ddf22..9df50fa 100644
@@ -664,10 +664,6 @@ static noinline int btrfs_mksubvol(struct path *parent,
      struct dentry *dentry;
      int error;
 
-     error = mnt_want_write(parent->mnt);
-     if (error)
-             return error;
-
      mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
 
Quoted 11 lines

fs/btrfs/ioctl.c out_dput: · line 704

Quoted 9 lines
fs/btrfs/ioctl.c +0 -1
      dentry = lookup_one_len(name, parent->dentry, namelen);
@@ -703,7 +699,6 @@ out_dput:
      dput(dentry);
 out_unlock:
      mutex_unlock(&dir->i_mutex);
-     mnt_drop_write(parent->mnt);
      return error;
 }
 

I'm confused, this isn't here in btrfs-next, so is this a problem still?

It's in linus current master. Lio Bo moved the call out of btrfs_mksubvol into the caller. Later a commit from Jan Kara tried to move the call inside mksubvol below i_mutex. If I understand the logs correctly, It was then merged incorrectly.

Quoted 3 lines

Thanks,

Josef

#3 lore raw
Quoted 7 lines · Alexander Block
Quoted 1 line · Josef Bacik

I'm confused, this isn't here in btrfs-next, so is this a problem still?

It's in linus current master. Lio Bo moved the call out of btrfs_mksubvol into the caller. Later a commit from Jan Kara tried to move the call inside mksubvol below i_mutex. If I understand the logs correctly, It was then merged incorrectly.

How should we resolve this? The patch has to be pulled via a separate branch, based on top of linus/master, as cmason/for-linus does not have the clashing freezer patches. And I do want to see the fix in master rather soon as it makes testing tedious.

david

#4 lore raw
Quoted 9 lines · David Sterba
Quoted 7 lines · Alexander Block
Quoted 1 line · Josef Bacik

I'm confused, this isn't here in btrfs-next, so is this a problem still?

It's in linus current master. Lio Bo moved the call out of btrfs_mksubvol into the caller. Later a commit from Jan Kara tried to move the call inside mksubvol below i_mutex. If I understand the logs correctly, It was then merged incorrectly.

Quoted 4 lines

How should we resolve this? The patch has to be pulled via a separate branch, based on top of linus/master, as cmason/for-linus does not have the clashing freezer patches. And I do want to see the fix in master rather soon as it makes testing tedious.

Right, I'll fix this up in a separate send to Linus. I thought I had this fixed in my original merge, but either way I'll send a pull to fix it.

-chris