]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
FS: Use stable writes when not doing a bulk flush
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Mon, 21 Mar 2011 21:02:00 +0000 (17:02 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 22 Mar 2011 01:08:17 +0000 (21:08 -0400)
If we're only doing a single write, and there are no other unstable
writes being queued up, we might want to just flip to using a stable
write RPC call.

Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/pagelist.c
fs/nfs/write.c
include/linux/nfs_fs.h
include/linux/nfs_page.h

index 23e7944106692a99a15118667a7d21820de3c1be..fd85618149a1fe6754d1cdfe4d2c1e2b2829ca04 100644 (file)
@@ -223,6 +223,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
        desc->pg_count = 0;
        desc->pg_bsize = bsize;
        desc->pg_base = 0;
+       desc->pg_moreio = 0;
        desc->pg_inode = inode;
        desc->pg_doio = doio;
        desc->pg_ioflags = io_flags;
@@ -335,9 +336,11 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
                           struct nfs_page *req)
 {
        while (!nfs_pageio_do_add_request(desc, req)) {
+               desc->pg_moreio = 1;
                nfs_pageio_doio(desc);
                if (desc->pg_error < 0)
                        return 0;
+               desc->pg_moreio = 0;
        }
        return 1;
 }
index 47a3ad63e0d573b1211560bc20f5e7fe612d74fb..4d686ee53244b60ef0e3ebc8a63100afacbc2b05 100644 (file)
@@ -179,8 +179,8 @@ static int wb_priority(struct writeback_control *wbc)
        if (wbc->for_reclaim)
                return FLUSH_HIGHPRI | FLUSH_STABLE;
        if (wbc->for_kupdate || wbc->for_background)
-               return FLUSH_LOWPRI;
-       return 0;
+               return FLUSH_LOWPRI | FLUSH_COND_STABLE;
+       return FLUSH_COND_STABLE;
 }
 
 /*
@@ -863,7 +863,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
        data->args.context = get_nfs_open_context(req->wb_context);
        data->args.lock_context = req->wb_lock_context;
        data->args.stable  = NFS_UNSTABLE;
-       if (how & FLUSH_STABLE) {
+       if (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) {
                data->args.stable = NFS_DATA_SYNC;
                if (!nfs_need_commit(NFS_I(inode)))
                        data->args.stable = NFS_FILE_SYNC;
@@ -912,6 +912,12 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc)
 
        nfs_list_remove_request(req);
 
+       if ((desc->pg_ioflags & FLUSH_COND_STABLE) &&
+           (desc->pg_moreio || NFS_I(desc->pg_inode)->ncommit ||
+            desc->pg_count > wsize))
+               desc->pg_ioflags &= ~FLUSH_COND_STABLE;
+
+
        nbytes = desc->pg_count;
        do {
                size_t len = min(nbytes, wsize);
@@ -1002,6 +1008,10 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc)
        if ((!lseg) && list_is_singular(&data->pages))
                lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW);
 
+       if ((desc->pg_ioflags & FLUSH_COND_STABLE) &&
+           (desc->pg_moreio || NFS_I(desc->pg_inode)->ncommit))
+               desc->pg_ioflags &= ~FLUSH_COND_STABLE;
+
        /* Set up the argument struct */
        ret = nfs_write_rpcsetup(req, data, &nfs_write_full_ops, desc->pg_count, 0, lseg, desc->pg_ioflags);
 out:
index f88522b10a384b5864ecf57ce4d76fdd23b19319..cb2add401f253c3920b347d1b5cf766bce9a5761 100644 (file)
@@ -33,6 +33,8 @@
 #define FLUSH_STABLE           4       /* commit to stable storage */
 #define FLUSH_LOWPRI           8       /* low priority background flush */
 #define FLUSH_HIGHPRI          16      /* high priority memory reclaim flush */
+#define FLUSH_COND_STABLE      32      /* conditional stable write - only stable
+                                        * if everything fits in one RPC */
 
 #ifdef __KERNEL__
 
index 90907ada6d52dac63cbcfb7712f97e3a3a8853d3..92d54c81f51ecc3cc91549760fd51bcaf931aff0 100644 (file)
@@ -57,6 +57,7 @@ struct nfs_pageio_descriptor {
        size_t                  pg_count;
        size_t                  pg_bsize;
        unsigned int            pg_base;
+       char                    pg_moreio;
 
        struct inode            *pg_inode;
        int                     (*pg_doio)(struct nfs_pageio_descriptor *);