[PATCH] Make most file operations structs in fs/ const
[linux-2.6-block.git] / fs / fuse / file.c
index a7ef5e716f3c3dd9a36ae9fd72fc8cf987c2e610..975f2697e866388d5c9e5ad9f80fc75f6e0953a1 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/slab.h>
 #include <linux/kernel.h>
 
-static struct file_operations fuse_direct_io_file_operations;
+static const struct file_operations fuse_direct_io_file_operations;
 
 static int fuse_send_open(struct inode *inode, struct file *file, int isdir,
                          struct fuse_open_out *outargp)
@@ -116,9 +116,14 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir)
 /* Special case for failed iget in CREATE */
 static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req)
 {
-       u64 nodeid = req->in.h.nodeid;
-       fuse_reset_request(req);
-       fuse_send_forget(fc, req, nodeid, 1);
+       /* If called from end_io_requests(), req has more than one
+          reference and fuse_reset_request() cannot work */
+       if (fc->connected) {
+               u64 nodeid = req->in.h.nodeid;
+               fuse_reset_request(req);
+               fuse_send_forget(fc, req, nodeid, 1);
+       } else
+               fuse_put_request(fc, req);
 }
 
 void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff,
@@ -335,9 +340,14 @@ static void fuse_send_readpages(struct fuse_req *req, struct file *file,
        loff_t pos = page_offset(req->pages[0]);
        size_t count = req->num_pages << PAGE_CACHE_SHIFT;
        req->out.page_zeroing = 1;
-       req->end = fuse_readpages_end;
        fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
-       request_send_background(fc, req);
+       if (fc->async_read) {
+               req->end = fuse_readpages_end;
+               request_send_background(fc, req);
+       } else {
+               request_send(fc, req);
+               fuse_readpages_end(fc, req);
+       }
 }
 
 struct fuse_readpages_data {
@@ -601,7 +611,7 @@ static int fuse_set_page_dirty(struct page *page)
        return 0;
 }
 
-static struct file_operations fuse_file_operations = {
+static const struct file_operations fuse_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = generic_file_read,
        .write          = generic_file_write,
@@ -613,7 +623,7 @@ static struct file_operations fuse_file_operations = {
        .sendfile       = generic_file_sendfile,
 };
 
-static struct file_operations fuse_direct_io_file_operations = {
+static const struct file_operations fuse_direct_io_file_operations = {
        .llseek         = generic_file_llseek,
        .read           = fuse_direct_read,
        .write          = fuse_direct_write,