aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/blocklayout/blocklayout.c38
-rw-r--r--fs/nfs/direct.c7
-rw-r--r--fs/nfs/internal.h1
-rw-r--r--fs/nfs/objlayout/objio_osd.c9
-rw-r--r--fs/nfs/pnfs.c6
-rw-r--r--fs/nfs/pnfs.h3
6 files changed, 57 insertions, 7 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index a34014a7f9a5..f1027b06a1a9 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -37,6 +37,7 @@
37#include <linux/bio.h> /* struct bio */ 37#include <linux/bio.h> /* struct bio */
38#include <linux/buffer_head.h> /* various write calls */ 38#include <linux/buffer_head.h> /* various write calls */
39#include <linux/prefetch.h> 39#include <linux/prefetch.h>
40#include <linux/pagevec.h>
40 41
41#include "../pnfs.h" 42#include "../pnfs.h"
42#include "../internal.h" 43#include "../internal.h"
@@ -1204,14 +1205,45 @@ bl_pg_test_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
1204 return pnfs_generic_pg_test(pgio, prev, req); 1205 return pnfs_generic_pg_test(pgio, prev, req);
1205} 1206}
1206 1207
1208/*
1209 * Return the number of contiguous bytes for a given inode
1210 * starting at page frame idx.
1211 */
1212static u64 pnfs_num_cont_bytes(struct inode *inode, pgoff_t idx)
1213{
1214 struct address_space *mapping = inode->i_mapping;
1215 pgoff_t end;
1216
1217 /* Optimize common case that writes from 0 to end of file */
1218 end = DIV_ROUND_UP(i_size_read(inode), PAGE_CACHE_SIZE);
1219 if (end != NFS_I(inode)->npages) {
1220 rcu_read_lock();
1221 end = radix_tree_next_hole(&mapping->page_tree, idx + 1, ULONG_MAX);
1222 rcu_read_unlock();
1223 }
1224
1225 if (!end)
1226 return i_size_read(inode) - (idx << PAGE_CACHE_SHIFT);
1227 else
1228 return (end - idx) << PAGE_CACHE_SHIFT;
1229}
1230
1207static void 1231static void
1208bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) 1232bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
1209{ 1233{
1210 if (pgio->pg_dreq != NULL && 1234 if (pgio->pg_dreq != NULL &&
1211 !is_aligned_req(req, PAGE_CACHE_SIZE)) 1235 !is_aligned_req(req, PAGE_CACHE_SIZE)) {
1212 nfs_pageio_reset_write_mds(pgio); 1236 nfs_pageio_reset_write_mds(pgio);
1213 else 1237 } else {
1214 pnfs_generic_pg_init_write(pgio, req); 1238 u64 wb_size;
1239 if (pgio->pg_dreq == NULL)
1240 wb_size = pnfs_num_cont_bytes(pgio->pg_inode,
1241 req->wb_index);
1242 else
1243 wb_size = nfs_dreq_bytes_left(pgio->pg_dreq);
1244
1245 pnfs_generic_pg_init_write(pgio, req, wb_size);
1246 }
1215} 1247}
1216 1248
1217static bool 1249static bool
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 4be8673ee18d..cae26cbd59ee 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -46,6 +46,7 @@
46#include <linux/kref.h> 46#include <linux/kref.h>
47#include <linux/slab.h> 47#include <linux/slab.h>
48#include <linux/task_io_accounting_ops.h> 48#include <linux/task_io_accounting_ops.h>
49#include <linux/module.h>
49 50
50#include <linux/nfs_fs.h> 51#include <linux/nfs_fs.h>
51#include <linux/nfs_page.h> 52#include <linux/nfs_page.h>
@@ -191,6 +192,12 @@ static void nfs_direct_req_release(struct nfs_direct_req *dreq)
191 kref_put(&dreq->kref, nfs_direct_req_free); 192 kref_put(&dreq->kref, nfs_direct_req_free);
192} 193}
193 194
195ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq)
196{
197 return dreq->bytes_left;
198}
199EXPORT_SYMBOL_GPL(nfs_dreq_bytes_left);
200
194/* 201/*
195 * Collects and returns the final error value/byte-count. 202 * Collects and returns the final error value/byte-count.
196 */ 203 */
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 89a795dc3027..59b133c5d652 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -464,6 +464,7 @@ static inline void nfs_inode_dio_wait(struct inode *inode)
464{ 464{
465 inode_dio_wait(inode); 465 inode_dio_wait(inode);
466} 466}
467extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq);
467 468
468/* nfs4proc.c */ 469/* nfs4proc.c */
469extern void __nfs4_read_done_cb(struct nfs_read_data *); 470extern void __nfs4_read_done_cb(struct nfs_read_data *);
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
index ea6d111b03e9..be731e6b7b9c 100644
--- a/fs/nfs/objlayout/objio_osd.c
+++ b/fs/nfs/objlayout/objio_osd.c
@@ -41,6 +41,7 @@
41#include <scsi/osd_ore.h> 41#include <scsi/osd_ore.h>
42 42
43#include "objlayout.h" 43#include "objlayout.h"
44#include "../internal.h"
44 45
45#define NFSDBG_FACILITY NFSDBG_PNFS_LD 46#define NFSDBG_FACILITY NFSDBG_PNFS_LD
46 47
@@ -606,8 +607,14 @@ static bool aligned_on_raid_stripe(u64 offset, struct ore_layout *layout,
606void objio_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) 607void objio_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
607{ 608{
608 unsigned long stripe_end = 0; 609 unsigned long stripe_end = 0;
610 u64 wb_size;
609 611
610 pnfs_generic_pg_init_write(pgio, req); 612 if (pgio->pg_dreq == NULL)
613 wb_size = i_size_read(pgio->pg_inode) - req_offset(req);
614 else
615 wb_size = nfs_dreq_bytes_left(pgio->pg_dreq);
616
617 pnfs_generic_pg_init_write(pgio, req, wb_size);
611 if (unlikely(pgio->pg_lseg == NULL)) 618 if (unlikely(pgio->pg_lseg == NULL))
612 return; /* Not pNFS */ 619 return; /* Not pNFS */
613 620
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index bd9769296e4e..9a2bcce45282 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1240,7 +1240,8 @@ pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *r
1240EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_read); 1240EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_read);
1241 1241
1242void 1242void
1243pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) 1243pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
1244 struct nfs_page *req, u64 wb_size)
1244{ 1245{
1245 BUG_ON(pgio->pg_lseg != NULL); 1246 BUG_ON(pgio->pg_lseg != NULL);
1246 1247
@@ -1248,10 +1249,11 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *
1248 nfs_pageio_reset_write_mds(pgio); 1249 nfs_pageio_reset_write_mds(pgio);
1249 return; 1250 return;
1250 } 1251 }
1252
1251 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, 1253 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
1252 req->wb_context, 1254 req->wb_context,
1253 req_offset(req), 1255 req_offset(req),
1254 req->wb_bytes, 1256 wb_size,
1255 IOMODE_RW, 1257 IOMODE_RW,
1256 GFP_NOFS); 1258 GFP_NOFS);
1257 /* If no lseg, fall back to write through mds */ 1259 /* If no lseg, fall back to write through mds */
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 6cede2c6c961..2d722dba1111 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -186,7 +186,8 @@ void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32);
186void unset_pnfs_layoutdriver(struct nfs_server *); 186void unset_pnfs_layoutdriver(struct nfs_server *);
187void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *); 187void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *);
188int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc); 188int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc);
189void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *, struct nfs_page *); 189void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
190 struct nfs_page *req, u64 wb_size);
190int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); 191int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc);
191bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req); 192bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
192void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg); 193void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg);