fuse: hold inode instead of path after release
authorMiklos Szeredi <mszeredi@suse.cz>
Fri, 12 Dec 2014 08:49:04 +0000 (09:49 +0100)
committerMiklos Szeredi <mszeredi@suse.cz>
Fri, 12 Dec 2014 08:49:04 +0000 (09:49 +0100)
path_put() in release could trigger a DESTROY request in fuseblk.  The
possible deadlock was worked around by doing the path_put() with
schedule_work().

This complexity isn't needed if we just hold the inode instead of the path.
Since we now flush all requests before destroying the super block we can be
sure that all held inodes will be dropped.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
fs/fuse/file.c
fs/fuse/fuse_i.h

index caa8d95b24e843581342c80c2552b69d6cfd223f..2d4ae68943bb70687a411d8c6f5c05e12492040c 100644 (file)
@@ -89,37 +89,9 @@ struct fuse_file *fuse_file_get(struct fuse_file *ff)
        return ff;
 }
 
-static void fuse_release_async(struct work_struct *work)
-{
-       struct fuse_req *req;
-       struct fuse_conn *fc;
-       struct path path;
-
-       req = container_of(work, struct fuse_req, misc.release.work);
-       path = req->misc.release.path;
-       fc = get_fuse_conn(path.dentry->d_inode);
-
-       fuse_put_request(fc, req);
-       path_put(&path);
-}
-
 static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req)
 {
-       if (fc->destroy_req) {
-               /*
-                * If this is a fuseblk mount, then it's possible that
-                * releasing the path will result in releasing the
-                * super block and sending the DESTROY request.  If
-                * the server is single threaded, this would hang.
-                * For this reason do the path_put() in a separate
-                * thread.
-                */
-               atomic_inc(&req->count);
-               INIT_WORK(&req->misc.release.work, fuse_release_async);
-               schedule_work(&req->misc.release.work);
-       } else {
-               path_put(&req->misc.release.path);
-       }
+       iput(req->misc.release.inode);
 }
 
 static void fuse_file_put(struct fuse_file *ff, bool sync)
@@ -133,12 +105,12 @@ static void fuse_file_put(struct fuse_file *ff, bool sync)
                         * implement 'open'
                         */
                        req->background = 0;
-                       path_put(&req->misc.release.path);
+                       iput(req->misc.release.inode);
                        fuse_put_request(ff->fc, req);
                } else if (sync) {
                        req->background = 0;
                        fuse_request_send(ff->fc, req);
-                       path_put(&req->misc.release.path);
+                       iput(req->misc.release.inode);
                        fuse_put_request(ff->fc, req);
                } else {
                        req->end = fuse_release_end;
@@ -297,9 +269,8 @@ void fuse_release_common(struct file *file, int opcode)
                inarg->lock_owner = fuse_lock_owner_id(ff->fc,
                                                       (fl_owner_t) file);
        }
-       /* Hold vfsmount and dentry until release is finished */
-       path_get(&file->f_path);
-       req->misc.release.path = file->f_path;
+       /* Hold inode until release is finished */
+       req->misc.release.inode = igrab(file_inode(file));
 
        /*
         * Normally this will send the RELEASE request, however if
index fbc63ab149b64c3eb2bb1a9ea8aa92913206ffbf..416fee2ee1bc13821be4dc07b256d6aae328949b 100644 (file)
@@ -305,11 +305,8 @@ struct fuse_req {
        /** Data for asynchronous requests */
        union {
                struct {
-                       union {
-                               struct fuse_release_in in;
-                               struct work_struct work;
-                       };
-                       struct path path;
+                       struct fuse_release_in in;
+                       struct inode *inode;
                } release;
                struct fuse_init_in init_in;
                struct fuse_init_out init_out;