]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
Revert "UBUNTU: SAUCE: (noup) fuse: Add reference counting for fuse_io_priv"
authorTim Gardner <tim.gardner@canonical.com>
Wed, 20 Apr 2016 20:35:31 +0000 (14:35 -0600)
committerTim Gardner <tim.gardner@canonical.com>
Thu, 21 Apr 2016 12:53:21 +0000 (06:53 -0600)
BugLink: http://bugs.launchpad.net/bugs/1572722
This reverts commit 5163592db4a3fbb9ab90f07093fb2c2c6d55527b.

use upstream stable patch.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
fs/fuse/cuse.c
fs/fuse/file.c
fs/fuse/fuse_i.h

index 98ebd0f4fd4c7dacf03b42eda804f6172677bcb5..37e6b1b2d7a5fb6f033201e23dd1e006b4ca8b1f 100644 (file)
@@ -91,7 +91,7 @@ static struct list_head *cuse_conntbl_head(dev_t devt)
 
 static ssize_t cuse_read_iter(struct kiocb *kiocb, struct iov_iter *to)
 {
-       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(kiocb->ki_filp);
+       struct fuse_io_priv io = { .async = 0, .file = kiocb->ki_filp };
        loff_t pos = 0;
 
        return fuse_direct_io(&io, to, &pos, FUSE_DIO_CUSE);
@@ -99,7 +99,7 @@ static ssize_t cuse_read_iter(struct kiocb *kiocb, struct iov_iter *to)
 
 static ssize_t cuse_write_iter(struct kiocb *kiocb, struct iov_iter *from)
 {
-       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(kiocb->ki_filp);
+       struct fuse_io_priv io = { .async = 0, .file = kiocb->ki_filp };
        loff_t pos = 0;
        /*
         * No locking or generic_write_checks(), the server is
index c05e9963eef02747bb66a30065cb82f88ad1c1fd..65ca924ef41c17102a724901f23a0bddf736f168 100644 (file)
@@ -528,11 +528,6 @@ static void fuse_release_user_pages(struct fuse_req *req, int write)
        }
 }
 
-static void fuse_io_release(struct kref *kref)
-{
-       kfree(container_of(kref, struct fuse_io_priv, refcnt));
-}
-
 static ssize_t fuse_get_res_by_io(struct fuse_io_priv *io)
 {
        if (io->err)
@@ -590,9 +585,8 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos)
                }
 
                io->iocb->ki_complete(io->iocb, res, 0);
+               kfree(io);
        }
-
-       kref_put(&io->refcnt, fuse_io_release);
 }
 
 static void fuse_aio_complete_req(struct fuse_conn *fc, struct fuse_req *req)
@@ -619,7 +613,6 @@ static size_t fuse_async_req_send(struct fuse_conn *fc, struct fuse_req *req,
                size_t num_bytes, struct fuse_io_priv *io)
 {
        spin_lock(&io->lock);
-       kref_get(&io->refcnt);
        io->size += num_bytes;
        io->reqs++;
        spin_unlock(&io->lock);
@@ -698,7 +691,7 @@ static void fuse_short_read(struct fuse_req *req, struct inode *inode,
 
 static int fuse_do_readpage(struct file *file, struct page *page)
 {
-       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(file);
+       struct fuse_io_priv io = { .async = 0, .file = file };
        struct inode *inode = page->mapping->host;
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_req *req;
@@ -991,7 +984,7 @@ static size_t fuse_send_write_pages(struct fuse_req *req, struct file *file,
        size_t res;
        unsigned offset;
        unsigned i;
-       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(file);
+       struct fuse_io_priv io = { .async = 0, .file = file };
 
        for (i = 0; i < req->num_pages; i++)
                fuse_wait_on_page_writeback(inode, req->pages[i]->index);
@@ -1405,7 +1398,7 @@ static ssize_t __fuse_direct_read(struct fuse_io_priv *io,
 
 static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb->ki_filp);
+       struct fuse_io_priv io = { .async = 0, .file = iocb->ki_filp };
        return __fuse_direct_read(&io, to, &iocb->ki_pos);
 }
 
@@ -1413,7 +1406,7 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file_inode(file);
-       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(file);
+       struct fuse_io_priv io = { .async = 0, .file = file };
        ssize_t res;
 
        if (is_bad_inode(inode))
@@ -2826,7 +2819,6 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
        if (!io)
                return -ENOMEM;
        spin_lock_init(&io->lock);
-       kref_init(&io->refcnt);
        io->reqs = 1;
        io->bytes = -1;
        io->size = 0;
@@ -2850,14 +2842,8 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
            iov_iter_rw(iter) == WRITE)
                io->async = false;
 
-       if (io->async && is_sync) {
-               /*
-                * Additional reference to keep io around after
-                * calling fuse_aio_complete()
-                */
-               kref_get(&io->refcnt);
+       if (io->async && is_sync)
                io->done = &wait;
-       }
 
        if (iov_iter_rw(iter) == WRITE) {
                ret = fuse_direct_io(io, iter, &pos, FUSE_DIO_WRITE);
@@ -2877,7 +2863,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
                ret = fuse_get_res_by_io(io);
        }
 
-       kref_put(&io->refcnt, fuse_io_release);
+       kfree(io);
 
        if (iov_iter_rw(iter) == WRITE) {
                if (ret > 0)
index d761934f7ec1a962253621030272cb68e0756f4b..5897805405ba8969c6ac9258b2c38fa7fa111724 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/workqueue.h>
 #include <linux/pid_namespace.h>
 #include <linux/user_namespace.h>
-#include <linux/kref.h>
 
 /** Max number of pages that can be used in a single read request */
 #define FUSE_MAX_PAGES_PER_REQ 32
@@ -246,7 +245,6 @@ struct fuse_args {
 
 /** The request IO state (for asynchronous processing) */
 struct fuse_io_priv {
-       struct kref refcnt;
        int async;
        spinlock_t lock;
        unsigned reqs;
@@ -260,13 +258,6 @@ struct fuse_io_priv {
        struct completion *done;
 };
 
-#define FUSE_IO_PRIV_SYNC(f) \
-{                                      \
-       .refcnt = { ATOMIC_INIT(1) },   \
-       .async = 0,                     \
-       .file = f,                      \
-}
-
 /**
  * Request flags
  *