summaryrefslogtreecommitdiffstats
path: root/xlators/mount/fuse/src/fuse-bridge.h
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2015-10-20 16:27:14 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-10-26 03:45:04 -0700
commit4f65f894ab1c19618383ba212dc0f0df48675823 (patch)
tree0c4cb83eb0b46070ab4fe3261bb0a74f7f0272c3 /xlators/mount/fuse/src/fuse-bridge.h
parentffc39c9d8807464b5c78959bc43dc12b22f5a37b (diff)
mount/fuse: use a queue instead of pipe to communicate with thread
doing inode/entry invalidations. Writing to pipe can block if pipe is full. This can lead to deadlocks in some situations. Consider following situation: 1. Kernel sends a write on an inode. Client is waiting for a response to write from brick. 2. A lookup happens on behalf of different application/thread on the same inode. In response, mdc tries to invalidate the inode. 3. fuse_invalidate_inode is called. It writes a invalidation request to pipe. Another thread which reads from this pipe writes the request to /dev/fuse. The invalidate code in fuse-kernel-module, tries to acquire lock on all pages for the inode and is blocked as a write is in progress on same inode (step 1) 4. Now, poller thread is blocked in invalidate notification and cannot receive any messages from same socket (on which lookup response came). But client is expecting a response for write from same socket (again step1) and we've a deadlock. The deadlock can be solved in two ways: 1. Use a queue (and a conditional variable for notifications) to pass invalidation requests from poller to invalidate thread. This is a variant of using non-blocking pipe, but doesn't have any limit on the amount of data (worst case we run out of memory and error out). 2. Allow events from sockets, immediately after we read one rpc-msg. Currently we disallow events till that rpc-msg is read from socket, processed and handled by higher layers. That way we won't run into these kind of issues. Also, it'll increase parallelism in way of reading from sockets. This patch implements solution 1 above. Change-Id: I8e8199fd7f4da9eab46a719d9292f35c039967e1 BUG: 1273387 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-on: http://review.gluster.org/12402
Diffstat (limited to 'xlators/mount/fuse/src/fuse-bridge.h')
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h
index ea346c05f9e..08af454be63 100644
--- a/xlators/mount/fuse/src/fuse-bridge.h
+++ b/xlators/mount/fuse/src/fuse-bridge.h
@@ -110,8 +110,9 @@ struct fuse_private {
char *fuse_mountopts;
/* For fuse-reverse-validation */
- int revchan_in;
- int revchan_out;
+ struct list_head invalidate_list;
+ pthread_cond_t invalidate_cond;
+ pthread_mutex_t invalidate_mutex;
gf_boolean_t reverse_fuse_thread_started;
/* For communicating with separate mount thread. */
@@ -133,6 +134,18 @@ struct fuse_private {
};
typedef struct fuse_private fuse_private_t;
+#define INVAL_BUF_SIZE (sizeof (struct fuse_out_header) + \
+ max (sizeof (struct fuse_notify_inval_inode_out), \
+ sizeof (struct fuse_notify_inval_entry_out) + \
+ NAME_MAX + 1))
+
+
+struct fuse_invalidate_node {
+ char inval_buf[INVAL_BUF_SIZE];
+ struct list_head next;
+};
+typedef struct fuse_invalidate_node fuse_invalidate_node_t;
+
struct fuse_graph_switch_args {
xlator_t *this;
xlator_t *old_subvol;
@@ -140,11 +153,6 @@ struct fuse_graph_switch_args {
};
typedef struct fuse_graph_switch_args fuse_graph_switch_args_t;
-#define INVAL_BUF_SIZE (sizeof (struct fuse_out_header) + \
- max (sizeof (struct fuse_notify_inval_inode_out), \
- sizeof (struct fuse_notify_inval_entry_out) + \
- NAME_MAX + 1))
-
#define FUSE_EVENT_HISTORY_SIZE 1024
#define _FH_TO_FD(fh) ((fd_t *)(uintptr_t)(fh))