Skip to contentSkip to conversation

Let's get rid of those annoying "VFS is out of sync with lock manager" messages (includes proposed patch)

PATCH Jesper Juhl 2 participants 4 messages Dec 7, 2006 – Dec 8, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

A while back I reported that I had a bunch of servers that started complaining about VFS being out of sync with lock manager -
the thread title was
"[NFS] 2.6.17.8 - do_vfs_lock: VFS is out of sync with lock manager!"
During the course of that thread Neil Brown proposed a patch to resolve the issue with the following description:

"
- do_vfs_lock is only called when the filesystem was mounted with -o nolock EXCEPT
- If a lock request to the server in interrupted (when mounted with -o intr) then do_vfs_lock is called to try to get the lock locally. Normally equivalent code will be called inside fs/lockd/clntproc.c when the server replies that the lock has been gained. In the case of an interrupt though this doesn't happen but the lock may still have happened on the server. So we record locally that the lock was gained, to ensure that it gets unlocked when the process exits.

As you don't have '-o nolocks' you must be hitting the second case. The lock call to the server returns -EINTR or -ERESTARTSYS and do_vfs_lock is called just-in-case.
As this is a just-in-case call, it is quite possible that the lock is held by some other process, so getting an error is entirely possible. So printing the message in this case seems wrong.

On the other hand, printing the message in any other case seems wrong too, as server locking is not being used, so there is nothing to get out of sync with.

As a further complication, I don't think that in the just-in-case situation that it should risk waiting for the lock.
Now maybe we can be sure there is a pending signal which will break out of any wait (though I'm worried about -ERESTARTSYS - that doesn't imply a signal does it?), but I would feel more comfortable if FL_SLEEP were turned off in that path.
"

To which Trond Myklebust replied:

"
Could we instead replace it with a dprintk() that returns the value of "res"? That will keep it useful for debugging purposes.
"

So I took Neils patch, made the change Trond suggested and the result is below.

Comments? Ok to merge?

---

 fs/nfs/file.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
fs/nfs/file.c +7 -4
index cc93865..22572af 100644
@@ -428,8 +428,8 @@ static int do_vfs_lock(struct file *file
 			BUG();
 	}
 	if (res < 0)
-		printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n",
-				__FUNCTION__);
+		dprintk("%s: VFS is out of sync with lock manager (res = %d)!\n",
+				__FUNCTION__, res);
 	return res;
 }
 
@@ -479,10 +479,13 @@ static int do_setlk(struct file *filp, i
 		 * we clean up any state on the server. We therefore
 		 * record the lock call as having succeeded in order to
 		 * ensure that locks_remove_posix() cleans it out when
-		 * the process exits.
+		 * the process exits. Make sure not to sleep if
+		 * someone else holds the lock.
 		 */
-		if (status == -EINTR || status == -ERESTARTSYS)
+		if (status == -EINTR || status == -ERESTARTSYS) {
+			fl->fl_flags &= ~FL_SLEEP;
 			do_vfs_lock(filp, fl);
+		}
 	} else
 		status = do_vfs_lock(filp, fl);
 	unlock_kernel();

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#1 lore raw
Quoted 5 lines · On Thursday December 7, [email protected] wrote:

So I took Neils patch, made the change Trond suggested and the result is below.

Comments? Ok to merge?

Yes, except that you need a changelog comment at the top. Possibly based very heavily on the text I wrote, but written to justify the patch rather than to explain the bug.

NeilBrown

Quoted 31 lines

---

 fs/nfs/file.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
fs/nfs/file.c +3 -3
index cc93865..22572af 100644
@@ -428,8 +428,8 @@ static int do_vfs_lock(struct file *file
 			BUG();
 	}
 	if (res < 0)
-		printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n",
-				__FUNCTION__);
+		dprintk("%s: VFS is out of sync with lock manager (res = %d)!\n",
+				__FUNCTION__, res);
 	return res;
 }
 
@@ -479,10 +479,13 @@ static int do_setlk(struct file *filp, i
 		 * we clean up any state on the server. We therefore
 		 * record the lock call as having succeeded in order to
 		 * ensure that locks_remove_posix() cleans it out when
-		 * the process exits.
+		 * the process exits. Make sure not to sleep if

fs/nfs/file.c static int do_setlk(struct file *filp, i · line 491

Quoted 10 lines
fs/nfs/file.c +4 -1
+		 * someone else holds the lock.
 		 */
-		if (status == -EINTR || status == -ERESTARTSYS)
+		if (status == -EINTR || status == -ERESTARTSYS) {
+			fl->fl_flags &= ~FL_SLEEP;
 			do_vfs_lock(filp, fl);
+		}
 	} else
 		status = do_vfs_lock(filp, fl);
 	unlock_kernel();

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#2 lore raw
Quoted 5 lines · Neil Brown
Quoted 4 lines · On Thursday December 7, [email protected] wrote:

So I took Neils patch, made the change Trond suggested and the result is below.

Quoted 8 lines
Quoted 1 line

Comments? Ok to merge?

Yes, except that you need a changelog comment at the top. Possibly based very heavily on the text I wrote, but written to justify the patch rather than to explain the bug.

NeilBrown

How about this for a changelog entry? :

Convert "VFS is out of sync with lock manager!" printk in do_vfs_lock() to dprintk() since the message is useless in normal use but could possibly be useful as a debugging aid.
Also turn off FL_SLEEP when calling do_vfs_lock() just in case after getting -EINTR or -ERESTARTSYS.

Quoted 42 lines
Quoted 41 lines

---

 fs/nfs/file.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
fs/nfs/file.c +7 -4
index cc93865..22572af 100644
@@ -428,8 +428,8 @@ static int do_vfs_lock(struct file *file
                      BUG();
      }
      if (res < 0)
-             printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n",
-                             __FUNCTION__);
+             dprintk("%s: VFS is out of sync with lock manager (res = %d)!\n",
+                             __FUNCTION__, res);
      return res;
 }
 
@@ -479,10 +479,13 @@ static int do_setlk(struct file *filp, i
               * we clean up any state on the server. We therefore
               * record the lock call as having succeeded in order to
               * ensure that locks_remove_posix() cleans it out when
-              * the process exits.
+              * the process exits. Make sure not to sleep if
+              * someone else holds the lock.
               */
-             if (status == -EINTR || status == -ERESTARTSYS)
+             if (status == -EINTR || status == -ERESTARTSYS) {
+                     fl->fl_flags &= ~FL_SLEEP;
                      do_vfs_lock(filp, fl);
+             }
      } else
              status = do_vfs_lock(filp, fl);
      unlock_kernel();
Signature · 12 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
#3 lore raw
Quoted 15 lines · Jesper Juhl
Quoted 5 lines · Neil Brown
Quoted 4 lines · On Thursday December 7, [email protected] wrote:

So I took Neils patch, made the change Trond suggested and the result is below.

Quoted 8 lines
Quoted 1 line

Comments? Ok to merge?

Yes, except that you need a changelog comment at the top. Possibly based very heavily on the text I wrote, but written to justify the patch rather than to explain the bug.

NeilBrown

Quoted 9 lines

How about this for a changelog entry? :

Convert "VFS is out of sync with lock manager!" printk in do_vfs_lock() to dprintk() since the message is useless in normal use but could possibly be useful as a debugging aid.
Also turn off FL_SLEEP when calling do_vfs_lock() just in case after getting -EINTR or -ERESTARTSYS.

Ohh and btw, I forgot to mention that the patch has been tested and resolves my original issue.

Signature · 12 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs