PROBLEM: wierdness with kernel nfsd

Matthew Grant (grantma@anathoth.gen.nz)
Mon, 01 Mar 1999 08:53:41 +1300


This is a multi-part message in MIME format.
--------------684CB50CD1018A43C8208ED5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Alan,

(For those repsonding to this on the kernel-list, please CC me as I am
not subscribed.)

For the fnctl and the fix for silently failing client side POSIX locks
see the other message.

2.2.2 NFS and kernel nfsd Wierdness
------------------------------------

I have found a problem with file locking with the new kernel NFS client
and there is a patch attached, but first I will deal with some real
WIERDNESS.

While I was doing the the fix for the first problem I noticed some real
WIERDNESS between the kernel nfsd and my Xterm NFS root client. I was
getting tons of messages about:

Feb 28 13:40:57 iona kernel: __nfs_fhget: inode 270473 busy, i_count=2,
i_nlink=
1
Feb 28 13:40:57 iona kernel: nfs_free_dentries: found run/syslogd.pid,
d_count=0
, hashed=1
Feb 28 13:40:57 iona kernel: nfs_dentry_delete: run/syslogd.pid:
ino=270473, cou
nt=2, nlink=1

Putting in the 2.2.2ac4 patch definitely improved matters, and going to
2.0.36 kernel on the XTerm client with nfsd on the server stopped the
problem or changing back to the old user space rpc.mountd and rpc.nfsd
on the server with a 2.2.2ac4 kernel also solved the problems. This
means there is some interesting things going on between the new server
nfsd and client. At one time the bug latched onto ypbind's constant
fnctl lock checking of its /var/run PID file and I got continuous log
messages... You mostly notice it on boot or shutdown or probably on any
intensive file operation. This REALLY needs a good look thru. Thoughts?
Ideas?

For those wanting to replicate this I am running Redhat 5.2 with the
patch set they posted and Linux 2.2.2ac4. The Xterm runs with an NFS
root mounted file system and the /sbin /bin /lib /usr /home and /opt
directories NFS mounted off the server as well.

Cheers,

Matthew Grant

-- 
-----------------------------------------------------------------------
Matthew Grant                        Email: grantma@anathoth.gen.nz
                                     Phone: +64 3 338-6287
--------------684CB50CD1018A43C8208ED5
Content-Type: text/plain; charset=us-ascii; name="linux-2.2.2-nfslck2.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="linux-2.2.2-nfslck2.patch"

--- linux-2.2.2.orig/include/linux/fs.h Tue Feb 23 11:50:24 1999 +++ linux/include/linux/fs.h Sat Feb 27 22:28:10 1999 @@ -650,6 +650,10 @@ extern int register_filesystem(struct file_system_type *); extern int unregister_filesystem(struct file_system_type *); +/* Return value for VFS lock functions - tells locks.c to lock conventionally + * REALLY kosha for root NFS and nfs_lock + */ +#define LOCK_USE_CLNT 1 #define FLOCK_VERIFY_READ 1 #define FLOCK_VERIFY_WRITE 2 --- linux-2.2.2.orig/fs/locks.c Thu Dec 24 09:11:45 1998 +++ linux/fs/locks.c Sat Feb 27 22:49:17 1999 @@ -339,7 +339,11 @@ error = filp->f_op->lock(filp, F_GETLK, &file_lock); if (error < 0) goto out_putf; - fl = &file_lock; + else if (error == LOCK_USE_CLNT) + /* Bypass for NFS with no locking - 2.0.36 compat */ + fl = posix_test_lock(filp, &file_lock); + else + fl = (file_lock.fl_type == F_UNLCK ? NULL : &file_lock); } else { fl = posix_test_lock(filp, &file_lock); } @@ -450,6 +454,10 @@ if (filp->f_op->lock != NULL) { error = filp->f_op->lock(filp, cmd, &file_lock); + /* + * FUTURE: Watch out for return of LOCK_USE_CLNT here! + * See nfs_lock in fs/nfs/file.c + */ if (error < 0) goto out_putf; } --- linux-2.2.2.orig/fs/nfs/file.c Wed Dec 2 10:34:51 1998 +++ linux/fs/nfs/file.c Sat Feb 27 23:10:41 1999 @@ -214,6 +214,18 @@ struct inode * inode = filp->f_dentry->d_inode; int status; + /* + * Do something for a FS mounted without NLM support + * Tell code in locks.c to lock in client-side kernel. + * This is here so that the nolock option to the NFS + * mount causes behaviour as in 2.0.x for compatibility + * and less FRIGHT. + * This REALLY helps with root NFS mounts. + */ + if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM) { + return LOCK_USE_CLNT; + } + dprintk("NFS: nfs_lock(f=%4x/%ld, t=%x, fl=%x, r=%ld:%ld)\n", inode->i_dev, inode->i_ino, fl->fl_type, fl->fl_flags, @@ -225,10 +237,6 @@ /* No mandatory locks over NFS */ if ((inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) return -ENOLCK; - - /* Fake OK code if mounted without NLM support */ - if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM) - return 0; /* * No BSD flocks over NFS allowed. --- linux-2.2.2.orig/fs/lockd/clntproc.c Thu Feb 18 06:44:33 1999 +++ linux/fs/lockd/clntproc.c Sat Feb 27 19:41:24 1999 @@ -328,7 +328,7 @@ status = req->a_res.status; if (status == NLM_LCK_GRANTED) { fl->fl_type = F_UNLCK; - } if (status == NLM_LCK_DENIED) { + } else if (status == NLM_LCK_DENIED) { /* * Report the conflicting lock back to the application. * FIXME: Is it OK to report the pid back as well?

--------------684CB50CD1018A43C8208ED5--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/