Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 260860
b: refs/heads/master
c: dce8129
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Jul 15, 2011
1 parent 94cafa0 commit c3ae498
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 38 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 493292ddc78d18ee2ad2d5c24c2b7dd6a24641d2
refs/heads/master: dce81290eed64d24493989bb7a08f9e20495e184
4 changes: 4 additions & 0 deletions trunk/fs/nfs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,12 @@ extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio);
extern void nfs_readdata_release(struct nfs_read_data *rdata);

/* write.c */
extern int nfs_generic_flush(struct nfs_pageio_descriptor *desc,
struct list_head *head);
extern void nfs_pageio_init_write_mds(struct nfs_pageio_descriptor *pgio,
struct inode *inode, int ioflags);
extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio);
extern void nfs_writedata_release(struct nfs_write_data *wdata);
extern void nfs_commit_free(struct nfs_write_data *p);
extern int nfs_initiate_write(struct nfs_write_data *data,
struct rpc_clnt *clnt,
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/nfs/nfs4filelayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ static const struct nfs_pageio_ops filelayout_pg_read_ops = {
static const struct nfs_pageio_ops filelayout_pg_write_ops = {
.pg_init = filelayout_pg_init_write,
.pg_test = filelayout_pg_test,
.pg_doio = nfs_generic_pg_writepages,
.pg_doio = pnfs_generic_pg_writepages,
};

static bool filelayout_mark_pnfs_commit(struct pnfs_layout_segment *lseg)
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/nfs/objlayout/objio_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ static const struct nfs_pageio_ops objio_pg_read_ops = {
static const struct nfs_pageio_ops objio_pg_write_ops = {
.pg_init = pnfs_generic_pg_init_write,
.pg_test = objio_pg_test,
.pg_doio = nfs_generic_pg_writepages,
.pg_doio = pnfs_generic_pg_writepages,
};

static struct pnfs_layoutdriver_type objlayout_type = {
Expand Down
57 changes: 55 additions & 2 deletions trunk/fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,15 +1170,30 @@ pnfs_ld_write_done(struct nfs_write_data *data)
}
EXPORT_SYMBOL_GPL(pnfs_ld_write_done);

enum pnfs_try_status
static void
pnfs_write_through_mds(struct nfs_pageio_descriptor *desc,
struct nfs_write_data *data)
{
list_splice_tail_init(&data->pages, &desc->pg_list);
if (data->req && list_empty(&data->req->wb_list))
nfs_list_add_request(data->req, &desc->pg_list);
nfs_pageio_reset_write_mds(desc);
desc->pg_recoalesce = 1;
nfs_writedata_release(data);
}

static enum pnfs_try_status
pnfs_try_to_write_data(struct nfs_write_data *wdata,
const struct rpc_call_ops *call_ops, int how)
const struct rpc_call_ops *call_ops,
struct pnfs_layout_segment *lseg,
int how)
{
struct inode *inode = wdata->inode;
enum pnfs_try_status trypnfs;
struct nfs_server *nfss = NFS_SERVER(inode);

wdata->mds_ops = call_ops;
wdata->lseg = get_lseg(lseg);

dprintk("%s: Writing ino:%lu %u@%llu (how %d)\n", __func__,
inode->i_ino, wdata->args.count, wdata->args.offset, how);
Expand All @@ -1194,6 +1209,44 @@ pnfs_try_to_write_data(struct nfs_write_data *wdata,
return trypnfs;
}

static void
pnfs_do_multiple_writes(struct nfs_pageio_descriptor *desc, struct list_head *head, int how)
{
struct nfs_write_data *data;
const struct rpc_call_ops *call_ops = desc->pg_rpc_callops;
struct pnfs_layout_segment *lseg = desc->pg_lseg;

desc->pg_lseg = NULL;
while (!list_empty(head)) {
enum pnfs_try_status trypnfs;

data = list_entry(head->next, struct nfs_write_data, list);
list_del_init(&data->list);

trypnfs = pnfs_try_to_write_data(data, call_ops, lseg, how);
if (trypnfs == PNFS_NOT_ATTEMPTED)
pnfs_write_through_mds(desc, data);
}
put_lseg(lseg);
}

int
pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
{
LIST_HEAD(head);
int ret;

ret = nfs_generic_flush(desc, &head);
if (ret != 0) {
put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL;
return ret;
}
pnfs_do_multiple_writes(desc, &head, desc->pg_ioflags);
return 0;
}
EXPORT_SYMBOL_GPL(pnfs_generic_pg_writepages);

/*
* Called by non rpc-based layout drivers
*/
Expand Down
10 changes: 1 addition & 9 deletions trunk/fs/nfs/pnfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,10 @@ bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *, int)

void set_pnfs_layoutdriver(struct nfs_server *, u32 id);
void unset_pnfs_layoutdriver(struct nfs_server *);
enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
const struct rpc_call_ops *, int);
void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *);
int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc);
void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *, struct nfs_page *);
int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc);
bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
int pnfs_layout_process(struct nfs4_layoutget *lgp);
void pnfs_free_lseg_list(struct list_head *tmp_list);
Expand Down Expand Up @@ -328,13 +327,6 @@ static inline void put_lseg(struct pnfs_layout_segment *lseg)
{
}

static inline enum pnfs_try_status
pnfs_try_to_write_data(struct nfs_write_data *data,
const struct rpc_call_ops *call_ops, int how)
{
return PNFS_NOT_ATTEMPTED;
}

static inline int pnfs_return_layout(struct inode *ino)
{
return 0;
Expand Down
39 changes: 18 additions & 21 deletions trunk/fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void nfs_writedata_free(struct nfs_write_data *p)
mempool_free(p, nfs_wdata_mempool);
}

static void nfs_writedata_release(struct nfs_write_data *wdata)
void nfs_writedata_release(struct nfs_write_data *wdata)
{
put_lseg(wdata->lseg);
put_nfs_open_context(wdata->args.context);
Expand Down Expand Up @@ -887,25 +887,15 @@ static void nfs_write_rpcsetup(struct nfs_page *req,

static int nfs_do_write(struct nfs_write_data *data,
const struct rpc_call_ops *call_ops,
struct pnfs_layout_segment *lseg,
int how)
{
struct inode *inode = data->args.context->path.dentry->d_inode;

if (lseg != NULL) {
data->lseg = get_lseg(lseg);
if (pnfs_try_to_write_data(data, call_ops, how) == PNFS_ATTEMPTED)
return 0;
put_lseg(data->lseg);
data->lseg = NULL;
}

return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how);
}

static int nfs_do_multiple_writes(struct list_head *head,
const struct rpc_call_ops *call_ops,
struct pnfs_layout_segment *lseg,
int how)
{
struct nfs_write_data *data;
Expand All @@ -917,7 +907,7 @@ static int nfs_do_multiple_writes(struct list_head *head,
data = list_entry(head->next, struct nfs_write_data, list);
list_del_init(&data->list);

ret2 = nfs_do_write(data, call_ops, lseg, how);
ret2 = nfs_do_write(data, call_ops, how);
if (ret == 0)
ret = ret2;
}
Expand Down Expand Up @@ -1037,23 +1027,24 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc, struct list_head *r
return ret;
}

int nfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
int nfs_generic_flush(struct nfs_pageio_descriptor *desc, struct list_head *head)
{
if (desc->pg_bsize < PAGE_CACHE_SIZE)
return nfs_flush_multi(desc, head);
return nfs_flush_one(desc, head);
}

static int nfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
{
LIST_HEAD(head);
int ret;

if (desc->pg_bsize < PAGE_CACHE_SIZE)
ret = nfs_flush_multi(desc, &head);
else
ret = nfs_flush_one(desc, &head);
ret = nfs_generic_flush(desc, &head);
if (ret == 0)
ret = nfs_do_multiple_writes(&head, desc->pg_rpc_callops,
desc->pg_lseg, desc->pg_ioflags);
put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL;
desc->pg_ioflags);
return ret;
}
EXPORT_SYMBOL_GPL(nfs_generic_pg_writepages);

static const struct nfs_pageio_ops nfs_pageio_write_ops = {
.pg_test = nfs_generic_pg_test,
Expand All @@ -1068,6 +1059,12 @@ void nfs_pageio_init_write_mds(struct nfs_pageio_descriptor *pgio,
}
EXPORT_SYMBOL_GPL(nfs_pageio_init_write_mds);

void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio)
{
pgio->pg_ops = &nfs_pageio_write_ops;
pgio->pg_bsize = NFS_SERVER(pgio->pg_inode)->wsize;
}

static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
struct inode *inode, int ioflags)
{
Expand Down
3 changes: 0 additions & 3 deletions trunk/include/linux/nfs_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ extern void nfs_unlock_request(struct nfs_page *req);
extern int nfs_set_page_tag_locked(struct nfs_page *req);
extern void nfs_clear_page_tag_locked(struct nfs_page *req);

extern int nfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc);


/*
* Lock the page of an asynchronous request without getting a new reference
*/
Expand Down

0 comments on commit c3ae498

Please sign in to comment.