Skip to contentSkip to conversation

cifs: fix fh_mutex locking in cifs_reopen_file

PATCH In review Jeff Layton 2 participants 6 messages Jun 27, 2009 – Jun 28, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: fix fh_mutex locking in cifs_reopen_file

Fixes a regression caused by commit a6ce4932fbdbcd8f8e8c6df76812014351c32892

When this lock was converted to a mutex, the locks were turned into unlocks and vice-versa.

---
 fs/cifs/file.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
fs/cifs/file.c +5 -5
index ebdbe62..97ce4bf 100644
@@ -493,9 +493,9 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
 		return -EBADF;
 
 	xid = GetXid();
-	mutex_unlock(&pCifsFile->fh_mutex);
+	mutex_lock(&pCifsFile->fh_mutex);
 	if (!pCifsFile->invalidHandle) {
-		mutex_lock(&pCifsFile->fh_mutex);
+		mutex_unlock(&pCifsFile->fh_mutex);
 		rc = 0;
 		FreeXid(xid);
 		return rc;
@@ -527,7 +527,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
 	if (full_path == NULL) {
 		rc = -ENOMEM;
 reopen_error_exit:
-		mutex_lock(&pCifsFile->fh_mutex);
+		mutex_unlock(&pCifsFile->fh_mutex);
 		FreeXid(xid);
 		return rc;
 	}
@@ -569,14 +569,14 @@ reopen_error_exit:
 			 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
 				CIFS_MOUNT_MAP_SPECIAL_CHR);
 	if (rc) {
-		mutex_lock(&pCifsFile->fh_mutex);
+		mutex_unlock(&pCifsFile->fh_mutex);
 		cFYI(1, ("cifs_open returned 0x%x", rc));
 		cFYI(1, ("oplock: %d", oplock));
 	} else {
 reopen_success:
 		pCifsFile->netfid = netfid;
 		pCifsFile->invalidHandle = false;
-		mutex_lock(&pCifsFile->fh_mutex);
+		mutex_unlock(&pCifsFile->fh_mutex);
 		pCifsInode = CIFS_I(inode);
 		if (pCifsInode) {
 			if (can_flush) {
Signature · 1 line
1.6.0.6
#1 lore raw

Good catch .

I have reviewed and merged into cifs-2.6.git. Merge requested for upstream.

Quoted 57 lines · Jeff Layton

Fixes a regression caused by commit a6ce4932fbdbcd8f8e8c6df76812014351c32892

When this lock was converted to a mutex, the locks were turned into unlocks and vice-versa.

---
 fs/cifs/file.c |   10 +++++-----

 1 files changed, 5 insertions(+), 5 deletions(-)
fs/cifs/file.c +2 -2
index ebdbe62..97ce4bf 100644
@@ -493,9 +493,9 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
                return -EBADF;
 
        xid = GetXid();
-       mutex_unlock(&pCifsFile->fh_mutex);
+       mutex_lock(&pCifsFile->fh_mutex);
        if (!pCifsFile->invalidHandle) {
-               mutex_lock(&pCifsFile->fh_mutex);
+               mutex_unlock(&pCifsFile->fh_mutex);
                rc = 0;
                FreeXid(xid);
                return rc;
@@ -527,7 +527,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
        if (full_path == NULL) {
                rc = -ENOMEM;

 reopen_error_exit:
-               mutex_lock(&pCifsFile->fh_mutex);
+               mutex_unlock(&pCifsFile->fh_mutex); FreeXid(xid);
               return rc;
       }

fs/cifs/file.c +0 -0
@@ -569,14 +569,14 @@ reopen_error_exit:

                        cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); if (rc) {
-               mutex_lock(&pCifsFile->fh_mutex);
+               mutex_unlock(&pCifsFile->fh_mutex); cFYI(1, ("cifs_open returned 0x%x", rc)); cFYI(1, ("oplock: %d", oplock));
       } else {
 reopen_success:
               pCifsFile->netfid = netfid; pCifsFile->invalidHandle = false;
-               mutex_lock(&pCifsFile->fh_mutex);
+               mutex_unlock(&pCifsFile->fh_mutex); pCifsInode = CIFS_I(inode);
               if (pCifsInode) {
                       if (can_flush) {
--
1.6.0.6

Signature · 3 lines
Thanks,

Steve
#2 lore raw
Quoted 4 lines · Steve French

Good catch .

I have reviewed and merged into cifs-2.6.git. Merge requested for upstream.

Great. Did it fix the problems you were seeing when testing with dbench?

Signature · 1 line
Jeff Layton <[email protected]>
#3 lore raw
Quoted 6 lines · Jeff Layton
Quoted 4 lines · Steve French

Good catch .

I have reviewed and merged into cifs-2.6.git. Merge requested for upstream.

Great. Did it fix the problems you were seeing when testing with dbench?

I doubt that this patch would affect my dbench runs because I wasn't getting any network
reconnections (they would have logged a warning to dmesg) and the fix is in reopen_file (which is invoked on reconnections).

I am updating and building current samba3 on a different machine (the one I more frequently run dbench test runs on) to check on whether this is an Ubuntu specific limit which I had not seen before (I usually run dbench with 50 rather than 60 processes). The Samba handle limit should (and was) be quite large.

In any case, as long as we are sure we are hitting a Samba server limit (or server side
per-process limit), we are ok and can continue to review/merge the very large inode patches. I am verifying with one additional pair of temporary stats (counters of successful opens) in the exit path of cifs_open and cifs_close)
to make sure that those match what I have already verified that we are seeing with smbstatus and the client side counters on number of successful posix_opens.

Signature · 3 lines
Thanks,

Steve
#4 lore raw
Quoted 9 lines · Steve French

On Sat, Jun 27, 2009 at 8:23 PM, Jeff Layton<[email protected]> wrote:
In any case, as long as we are sure we are hitting a Samba server limit (or server side
per-process limit), we are ok and can continue to review/merge the very large inode patches.  I am verifying with one additional pair of temporary stats (counters of successful opens) in the exit path of cifs_open and cifs_close)
to make sure that those match what I have already verified that we are seeing with smbstatus and the client side counters on number of successful posix_opens.

I am puzzled about the Samba 3.4 max files limit (I am seeing it at 1014 opens) and seems
strange that dbench would open so many files, but with counters in cifs_open and cifs_close - I see 1014 more opens than closes (from the vfs) which matches what I see at the SMB level and what I see in Samba server.
dbench 4 fails even faster. This also fails on other OS (opensuse,
Ubuntu etc.),
but worked on Samba 3.0.28. Is it possible that Samba 3.4 changed their max open file limit?

Signature · 3 lines
Thanks,

Steve
#5 lore raw
Quoted 11 lines · Steve French
Quoted 9 lines · Steve French

On Sat, Jun 27, 2009 at 8:23 PM, Jeff Layton<[email protected]> wrote:
In any case, as long as we are sure we are hitting a Samba server limit (or server side
per-process limit), we are ok and can continue to review/merge the very large inode patches. I am verifying with one additional pair of temporary stats (counters of successful opens) in the exit path of cifs_open and cifs_close)
to make sure that those match what I have already verified that we are seeing with smbstatus and the client side counters on number of successful posix_opens.

Quoted 11 lines

I am puzzled about the Samba 3.4 max files limit (I am seeing it at 1014 opens) and seems
strange that dbench would open so many files, but with counters in cifs_open and cifs_close - I see 1014 more opens than closes (from the vfs) which matches what I see at the SMB level and what I see in Samba server.
dbench 4 fails even faster. This also fails on other OS (opensuse,
Ubuntu etc.),
but worked on Samba 3.0.28. Is it possible that Samba 3.4 changed their max open file limit?

Doesn't 3.0.28 have broken POSIX open calls? That may account for the difference. I can't be certain I was seeing the same failures you were with dbench, but I never got a passing run until I applied that patch to fix the reopen locking.

Signature · 1 line
Jeff Layton <[email protected]>