aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/dev.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-04-11 15:14:26 -0400
committerMiklos Szeredi <miklos@szeredi.hu>2006-04-11 15:14:26 -0400
commit73ce8355c243a434524a34c05cc417dd0467996e (patch)
treea5bc5bfb31c41a5806caf763533943e7411e6543 /fs/fuse/dev.c
parent2514395ef88b46e895726a8d40966cb83de7940c (diff)
[fuse] fix deadlock between fuse_put_super() and request_end()
A deadlock was possible, when the last reference to the superblock was held due to a background request containing a file reference. Releasing the file would release the vfsmount which in turn would release the superblock. Since sbput_sem is held during the fput() and fuse_put_super() tries to acquire this same semaphore, a deadlock results. The chosen soltuion is to get rid of sbput_sem, and instead use the spinlock to ensure the referenced inodes/file are released only once. Since the actual release may sleep, defer these outside the locked region, but using local variables instead of the structure members. This is a much more rubust solution. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Diffstat (limited to 'fs/fuse/dev.c')
-rw-r--r--fs/fuse/dev.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 6c740f860665..d4efb6223e2c 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -120,20 +120,14 @@ void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req)
120 } 120 }
121} 121}
122 122
123void fuse_release_background(struct fuse_conn *fc, struct fuse_req *req) 123void fuse_remove_background(struct fuse_conn *fc, struct fuse_req *req)
124{ 124{
125 iput(req->inode); 125 list_del_init(&req->bg_entry);
126 iput(req->inode2);
127 if (req->file)
128 fput(req->file);
129 spin_lock(&fc->lock);
130 list_del(&req->bg_entry);
131 if (fc->num_background == FUSE_MAX_BACKGROUND) { 126 if (fc->num_background == FUSE_MAX_BACKGROUND) {
132 fc->blocked = 0; 127 fc->blocked = 0;
133 wake_up_all(&fc->blocked_waitq); 128 wake_up_all(&fc->blocked_waitq);
134 } 129 }
135 fc->num_background--; 130 fc->num_background--;
136 spin_unlock(&fc->lock);
137} 131}
138 132
139/* 133/*
@@ -163,17 +157,27 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
163 wake_up(&req->waitq); 157 wake_up(&req->waitq);
164 fuse_put_request(fc, req); 158 fuse_put_request(fc, req);
165 } else { 159 } else {
160 struct inode *inode = req->inode;
161 struct inode *inode2 = req->inode2;
162 struct file *file = req->file;
166 void (*end) (struct fuse_conn *, struct fuse_req *) = req->end; 163 void (*end) (struct fuse_conn *, struct fuse_req *) = req->end;
167 req->end = NULL; 164 req->end = NULL;
165 req->inode = NULL;
166 req->inode2 = NULL;
167 req->file = NULL;
168 if (!list_empty(&req->bg_entry))
169 fuse_remove_background(fc, req);
168 spin_unlock(&fc->lock); 170 spin_unlock(&fc->lock);
169 down_read(&fc->sbput_sem); 171
170 if (fc->mounted)
171 fuse_release_background(fc, req);
172 up_read(&fc->sbput_sem);
173 if (end) 172 if (end)
174 end(fc, req); 173 end(fc, req);
175 else 174 else
176 fuse_put_request(fc, req); 175 fuse_put_request(fc, req);
176
177 if (file)
178 fput(file);
179 iput(inode);
180 iput(inode2);
177 } 181 }
178} 182}
179 183