summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src/libglusterfsclient-internals.h
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-05-11 18:22:29 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-05-18 19:12:37 +0530
commitaeda0a31977e8da295b913e6a306ff01ccf0ce0a (patch)
tree465b49ea3305583e06bf3ad24d49f338f7970118 /libglusterfsclient/src/libglusterfsclient-internals.h
parent4f1a87a245b960f1cd1fb4fe40b4254ac3793213 (diff)
libglusterfsclient: Revert and re-do readdir conformance
This commit basically reverts the previous readdir conformance patch I sent a few days back. That commit had a completely retarded and broken way of maintaining per-directory dirent. It was broken for two reasons: 1. Creating a wrapper structure around the directory's fd_t only for storing a struct dirent is not clean enough. This commit takes a better approach by storing the dirent in fd_t context. This dirent is valid only if the fd_t refers to a directory. 2. That commit was made and tested under the assumption (..stupidity is a better word..) that only opendir call is used for opening a directory. That is not correct. Directories are also opened using the open syscall. The point is, glusterfs_open returns an fd_t and so did glusterfs_opendir. The previous patch actually changed opendir to return a new wrapper structure. That is fine, if we go by the POSIX definition of open and opendir because, they're both supposed to return different types, an int and a DIR*. However, in libglusterfsclient, all other code assumes that directory handles corresponding to DIR* and file descriptors corresponding to int types are the same type, resulting in use of the same locking and fd context addition/extraction code. So a directory opened using opendir returned a wrapper structure which went down into the libglusterfsclient stack where some function called a lock on the handle assuming it was an fd_t, since it is not and dereferencing of the supposed fd->inode->lock results in a seg fault. Obviously, this didnt show up till unfs3 used open() to open a directory and not opendir. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient/src/libglusterfsclient-internals.h')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient-internals.h17
1 files changed, 5 insertions, 12 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient-internals.h b/libglusterfsclient/src/libglusterfsclient-internals.h
index 4cdde26e78b..40ad6f6929f 100755
--- a/libglusterfsclient/src/libglusterfsclient-internals.h
+++ b/libglusterfsclient/src/libglusterfsclient-internals.h
@@ -83,6 +83,11 @@ typedef struct {
pthread_mutex_t lock;
off_t offset;
libglusterfs_client_ctx_t *ctx;
+ /* `man readdir` says readdir is non-re-entrant
+ * only if two readdirs are racing on the same
+ * handle.
+ */
+ struct dirent dirp;
} libglusterfs_client_fd_ctx_t;
typedef struct libglusterfs_client_async_local {
@@ -231,16 +236,4 @@ struct vmp_entry {
};
-/* Internal directory handle inited in opendir.
- * This is needed in order to store a per-handle
- * dirent structure.
- */
-struct libgf_dir_handle {
- fd_t *dirfd;
- struct dirent dirp;
-};
-
-
-
-
#endif