From 4e6fb304ce41acbaf7c9ba67c06bf443e65082e8 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Fri, 17 Sep 2010 06:32:01 +0000 Subject: nfs3: Unref & unbind dir fd with inode lock on EOF ..so that when EOF is reached on this fd, any further requests on the same inode do not get handled through this fd but result in a new fd being opened. Unbinding results in the fd getting deleted from the inode's fd list. Signed-off-by: Shehjar Tikoo Signed-off-by: Vijay Bellur BUG: 1619 (glusterfs nfs server crashed on dht+replica(2x2)) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1619 --- libglusterfs/src/fd.c | 24 ++++++++++++++++++++++++ libglusterfs/src/fd.h | 2 ++ 2 files changed, 26 insertions(+) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index 9e91cdb8341..5e25b59cf91 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -499,6 +499,30 @@ fd_bind (fd_t *fd) return fd; } + +void +fd_unref_unbind (fd_t *fd) +{ + 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. + */ + 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 4ea7fc165e3..48037b72267 100644 --- a/libglusterfs/src/fd.h +++ b/libglusterfs/src/fd.h @@ -170,4 +170,6 @@ _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