提交 b31268ac 编写于 作者: T Trond Myklebust

FS: Use stable writes when not doing a bulk flush

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: NNeilBrown <neilb@suse.de>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 8e26de23
...@@ -223,6 +223,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc, ...@@ -223,6 +223,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
desc->pg_count = 0; desc->pg_count = 0;
desc->pg_bsize = bsize; desc->pg_bsize = bsize;
desc->pg_base = 0; desc->pg_base = 0;
desc->pg_moreio = 0;
desc->pg_inode = inode; desc->pg_inode = inode;
desc->pg_doio = doio; desc->pg_doio = doio;
desc->pg_ioflags = io_flags; desc->pg_ioflags = io_flags;
...@@ -335,9 +336,11 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, ...@@ -335,9 +336,11 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
struct nfs_page *req) struct nfs_page *req)
{ {
while (!nfs_pageio_do_add_request(desc, req)) { while (!nfs_pageio_do_add_request(desc, req)) {
desc->pg_moreio = 1;
nfs_pageio_doio(desc); nfs_pageio_doio(desc);
if (desc->pg_error < 0) if (desc->pg_error < 0)
return 0; return 0;
desc->pg_moreio = 0;
} }
return 1; return 1;
} }
......
...@@ -179,8 +179,8 @@ static int wb_priority(struct writeback_control *wbc) ...@@ -179,8 +179,8 @@ static int wb_priority(struct writeback_control *wbc)
if (wbc->for_reclaim) if (wbc->for_reclaim)
return FLUSH_HIGHPRI | FLUSH_STABLE; return FLUSH_HIGHPRI | FLUSH_STABLE;
if (wbc->for_kupdate || wbc->for_background) if (wbc->for_kupdate || wbc->for_background)
return FLUSH_LOWPRI; return FLUSH_LOWPRI | FLUSH_COND_STABLE;
return 0; return FLUSH_COND_STABLE;
} }
/* /*
...@@ -863,7 +863,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req, ...@@ -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.context = get_nfs_open_context(req->wb_context);
data->args.lock_context = req->wb_lock_context; data->args.lock_context = req->wb_lock_context;
data->args.stable = NFS_UNSTABLE; data->args.stable = NFS_UNSTABLE;
if (how & FLUSH_STABLE) { if (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) {
data->args.stable = NFS_DATA_SYNC; data->args.stable = NFS_DATA_SYNC;
if (!nfs_need_commit(NFS_I(inode))) if (!nfs_need_commit(NFS_I(inode)))
data->args.stable = NFS_FILE_SYNC; data->args.stable = NFS_FILE_SYNC;
...@@ -912,6 +912,12 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc) ...@@ -912,6 +912,12 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc)
nfs_list_remove_request(req); 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; nbytes = desc->pg_count;
do { do {
size_t len = min(nbytes, wsize); size_t len = min(nbytes, wsize);
...@@ -1002,6 +1008,10 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc) ...@@ -1002,6 +1008,10 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc)
if ((!lseg) && list_is_singular(&data->pages)) if ((!lseg) && list_is_singular(&data->pages))
lseg = pnfs_update_layout(desc->pg_inode, req->wb_context, IOMODE_RW); 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 */ /* Set up the argument struct */
ret = nfs_write_rpcsetup(req, data, &nfs_write_full_ops, desc->pg_count, 0, lseg, desc->pg_ioflags); ret = nfs_write_rpcsetup(req, data, &nfs_write_full_ops, desc->pg_count, 0, lseg, desc->pg_ioflags);
out: out:
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#define FLUSH_STABLE 4 /* commit to stable storage */ #define FLUSH_STABLE 4 /* commit to stable storage */
#define FLUSH_LOWPRI 8 /* low priority background flush */ #define FLUSH_LOWPRI 8 /* low priority background flush */
#define FLUSH_HIGHPRI 16 /* high priority memory reclaim 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__ #ifdef __KERNEL__
......
...@@ -57,6 +57,7 @@ struct nfs_pageio_descriptor { ...@@ -57,6 +57,7 @@ struct nfs_pageio_descriptor {
size_t pg_count; size_t pg_count;
size_t pg_bsize; size_t pg_bsize;
unsigned int pg_base; unsigned int pg_base;
char pg_moreio;
struct inode *pg_inode; struct inode *pg_inode;
int (*pg_doio)(struct nfs_pageio_descriptor *); int (*pg_doio)(struct nfs_pageio_descriptor *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册