diff options
Diffstat (limited to 'fs/fuse/dev.c')
-rw-r--r-- | fs/fuse/dev.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index cc750c68fe70..104a62dadb94 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -128,14 +128,24 @@ void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req) | |||
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | void fuse_remove_background(struct fuse_conn *fc, struct fuse_req *req) | 131 | /* |
132 | * Called with sbput_sem held for read (request_end) or write | ||
133 | * (fuse_put_super). By the time fuse_put_super() is finished, all | ||
134 | * inodes belonging to background requests must be released, so the | ||
135 | * iputs have to be done within the locked region. | ||
136 | */ | ||
137 | void fuse_release_background(struct fuse_conn *fc, struct fuse_req *req) | ||
132 | { | 138 | { |
133 | list_del_init(&req->bg_entry); | 139 | iput(req->inode); |
140 | iput(req->inode2); | ||
141 | spin_lock(&fc->lock); | ||
142 | list_del(&req->bg_entry); | ||
134 | if (fc->num_background == FUSE_MAX_BACKGROUND) { | 143 | if (fc->num_background == FUSE_MAX_BACKGROUND) { |
135 | fc->blocked = 0; | 144 | fc->blocked = 0; |
136 | wake_up_all(&fc->blocked_waitq); | 145 | wake_up_all(&fc->blocked_waitq); |
137 | } | 146 | } |
138 | fc->num_background--; | 147 | fc->num_background--; |
148 | spin_unlock(&fc->lock); | ||
139 | } | 149 | } |
140 | 150 | ||
141 | /* | 151 | /* |
@@ -165,27 +175,22 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) | |||
165 | wake_up(&req->waitq); | 175 | wake_up(&req->waitq); |
166 | fuse_put_request(fc, req); | 176 | fuse_put_request(fc, req); |
167 | } else { | 177 | } else { |
168 | struct inode *inode = req->inode; | ||
169 | struct inode *inode2 = req->inode2; | ||
170 | struct file *file = req->file; | ||
171 | void (*end) (struct fuse_conn *, struct fuse_req *) = req->end; | 178 | void (*end) (struct fuse_conn *, struct fuse_req *) = req->end; |
172 | req->end = NULL; | 179 | req->end = NULL; |
173 | req->inode = NULL; | ||
174 | req->inode2 = NULL; | ||
175 | req->file = NULL; | ||
176 | if (!list_empty(&req->bg_entry)) | ||
177 | fuse_remove_background(fc, req); | ||
178 | spin_unlock(&fc->lock); | 180 | spin_unlock(&fc->lock); |
181 | down_read(&fc->sbput_sem); | ||
182 | if (fc->mounted) | ||
183 | fuse_release_background(fc, req); | ||
184 | up_read(&fc->sbput_sem); | ||
185 | |||
186 | /* fput must go outside sbput_sem, otherwise it can deadlock */ | ||
187 | if (req->file) | ||
188 | fput(req->file); | ||
179 | 189 | ||
180 | if (end) | 190 | if (end) |
181 | end(fc, req); | 191 | end(fc, req); |
182 | else | 192 | else |
183 | fuse_put_request(fc, req); | 193 | fuse_put_request(fc, req); |
184 | |||
185 | if (file) | ||
186 | fput(file); | ||
187 | iput(inode); | ||
188 | iput(inode2); | ||
189 | } | 194 | } |
190 | } | 195 | } |
191 | 196 | ||