diff options
-rw-r--r-- | fs/nfs/objlayout/objio_osd.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index 3161da654a9b..c807ab93140e 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c | |||
@@ -459,6 +459,43 @@ static void _write_done(struct ore_io_state *ios, void *private) | |||
459 | objlayout_write_done(&objios->oir, status, objios->sync); | 459 | objlayout_write_done(&objios->oir, status, objios->sync); |
460 | } | 460 | } |
461 | 461 | ||
462 | static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) | ||
463 | { | ||
464 | struct objio_state *objios = priv; | ||
465 | struct nfs_write_data *wdata = objios->oir.rpcdata; | ||
466 | pgoff_t index = offset / PAGE_SIZE; | ||
467 | struct page *page = find_get_page(wdata->inode->i_mapping, index); | ||
468 | |||
469 | if (!page) { | ||
470 | page = find_or_create_page(wdata->inode->i_mapping, | ||
471 | index, GFP_NOFS); | ||
472 | if (unlikely(!page)) { | ||
473 | dprintk("%s: grab_cache_page Failed index=0x%lx\n", | ||
474 | __func__, index); | ||
475 | return NULL; | ||
476 | } | ||
477 | unlock_page(page); | ||
478 | } | ||
479 | if (PageDirty(page) || PageWriteback(page)) | ||
480 | *uptodate = true; | ||
481 | else | ||
482 | *uptodate = PageUptodate(page); | ||
483 | dprintk("%s: index=0x%lx uptodate=%d\n", __func__, index, *uptodate); | ||
484 | return page; | ||
485 | } | ||
486 | |||
487 | static void __r4w_put_page(void *priv, struct page *page) | ||
488 | { | ||
489 | dprintk("%s: index=0x%lx\n", __func__, page->index); | ||
490 | page_cache_release(page); | ||
491 | return; | ||
492 | } | ||
493 | |||
494 | static const struct _ore_r4w_op _r4w_op = { | ||
495 | .get_page = &__r4w_get_page, | ||
496 | .put_page = &__r4w_put_page, | ||
497 | }; | ||
498 | |||
462 | int objio_write_pagelist(struct nfs_write_data *wdata, int how) | 499 | int objio_write_pagelist(struct nfs_write_data *wdata, int how) |
463 | { | 500 | { |
464 | struct objio_state *objios; | 501 | struct objio_state *objios; |
@@ -472,6 +509,7 @@ int objio_write_pagelist(struct nfs_write_data *wdata, int how) | |||
472 | return ret; | 509 | return ret; |
473 | 510 | ||
474 | objios->sync = 0 != (how & FLUSH_SYNC); | 511 | objios->sync = 0 != (how & FLUSH_SYNC); |
512 | objios->ios->r4w = &_r4w_op; | ||
475 | 513 | ||
476 | if (!objios->sync) | 514 | if (!objios->sync) |
477 | objios->ios->done = _write_done; | 515 | objios->ios->done = _write_done; |