From 78654d270cde028c5d7f9da29b2790b90c19e11f Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Mon, 15 Nov 2010 05:34:00 +0000 Subject: nfs: opendir/closedir for every readdir Revert "nfs3: Unref & unbind dir fd with inode lock on EOF" This reverts commit 4e6fb304ce41acbaf7c9ba67c06bf443e65082e8. The above commit (which unbinds fds at EOF) does not fix the original bug (1619) because a readdir from a second app could have already started before the readdir_cbk of the first app's readdir reaches NFS code. Hence the race still exists. Performing extra unrefs when EOF is received is not a reliable way of detecting that a client has performed a closedir (and to close the fd ourselves). Neither is interpreting a 0 cookies a new opendir. Clients can always use telldir/seekdir and hit EOFs twice. Due to the way NFS3 protocol is designed, it is just not possible for the server to reliably detect opendirs/closedirs performed by the client and map the corresponding readdirs to the same dir fd on the server side. The only reliable way of fixing this is to perform opendir/closedir at the cost of performance. Any optimization towards keeping dir fds open attempting to map them with application's opendir/closedir will either result in fd leaks or extra fd unrefs. Signed-off-by: Anand V. Avati Signed-off-by: Anand V. Avati BUG: 2061 (NFS server crashes in readdir_fstat_cbk due to extra fd unref) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2061 --- libglusterfs/src/fd.c | 23 ----------------------- libglusterfs/src/fd.h | 2 -- 2 files changed, 25 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index e4e75d8040f..def15255728 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -500,29 +500,6 @@ fd_bind (fd_t *fd) } -void -fd_unref_unbind (fd_t *fd) -{ - GF_ASSERT (fd->refcount); - - LOCK (&fd->inode->lock); - { - --fd->refcount; - /* Better know what you're doing with this function - * because it does not do what fd_destroy does when - * refcount goes to 0. - * Make sure you only call this when you know there are - * pending refs on the fd. - */ - GF_ASSERT (fd->refcount); - list_del_init (&fd->inode_list); - } - UNLOCK (&fd->inode->lock); - - return; -} - - fd_t * fd_create (inode_t *inode, pid_t pid) { diff --git a/libglusterfs/src/fd.h b/libglusterfs/src/fd.h index d3efeb91372..d19b0724f61 100644 --- a/libglusterfs/src/fd.h +++ b/libglusterfs/src/fd.h @@ -169,6 +169,4 @@ _fd_ref (fd_t *fd); void fd_ctx_dump (fd_t *fd, char *prefix); -extern void -fd_unref_unbind (fd_t *fd); #endif /* _FD_H */ -- cgit