aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-09-10 11:23:30 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-09-10 15:47:02 -0400
commit612aa983a041056c3368aacfdc9febd406d245a8 (patch)
tree61607917bd96095c5f35784593298fd7581b8b6c /fs/nfs
parent7c5d187581f57657de79e795602d9f1a0254c88c (diff)
pnfs: add flag to force read-modify-write in ->write_begin
Like all block based filesystems, the pNFS block layout driver can't read or write at a byte granularity and thus has to perform read-modify-write cycles on writes smaller than this granularity. Add a flag so that the core NFS code always reads a whole page when starting a smaller write, so that we can do it in the place where the VFS expects it instead of doing in very deadlock prone way in the writeback handler. Note that in theory we could do less than page size reads here for disks that have a smaller sector size which are served by a server with a smaller pnfs block size. But so far that doesn't seem like a worthwhile optimization. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/file.c7
-rw-r--r--fs/nfs/pnfs.h15
2 files changed, 22 insertions, 0 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 524dd80d1898..05ef7dcc5f21 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -36,6 +36,7 @@
36#include "internal.h" 36#include "internal.h"
37#include "iostat.h" 37#include "iostat.h"
38#include "fscache.h" 38#include "fscache.h"
39#include "pnfs.h"
39 40
40#include "nfstrace.h" 41#include "nfstrace.h"
41 42
@@ -327,6 +328,12 @@ static int nfs_want_read_modify_write(struct file *file, struct page *page,
327 unsigned int offset = pos & (PAGE_CACHE_SIZE - 1); 328 unsigned int offset = pos & (PAGE_CACHE_SIZE - 1);
328 unsigned int end = offset + len; 329 unsigned int end = offset + len;
329 330
331 if (pnfs_ld_read_whole_page(file->f_mapping->host)) {
332 if (!PageUptodate(page))
333 return 1;
334 return 0;
335 }
336
330 if ((file->f_mode & FMODE_READ) && /* open for read? */ 337 if ((file->f_mode & FMODE_READ) && /* open for read? */
331 !PageUptodate(page) && /* Uptodate? */ 338 !PageUptodate(page) && /* Uptodate? */
332 !PagePrivate(page) && /* i/o request already? */ 339 !PagePrivate(page) && /* i/o request already? */
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 8835b5a320cc..a4c530e52149 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -72,6 +72,7 @@ enum layoutdriver_policy_flags {
72 /* Should the pNFS client commit and return the layout upon a setattr */ 72 /* Should the pNFS client commit and return the layout upon a setattr */
73 PNFS_LAYOUTRET_ON_SETATTR = 1 << 0, 73 PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
74 PNFS_LAYOUTRET_ON_ERROR = 1 << 1, 74 PNFS_LAYOUTRET_ON_ERROR = 1 << 1,
75 PNFS_READ_WHOLE_PAGE = 1 << 2,
75}; 76};
76 77
77struct nfs4_deviceid_node; 78struct nfs4_deviceid_node;
@@ -370,6 +371,14 @@ pnfs_ld_layoutret_on_setattr(struct inode *inode)
370} 371}
371 372
372static inline bool 373static inline bool
374pnfs_ld_read_whole_page(struct inode *inode)
375{
376 if (!pnfs_enabled_sb(NFS_SERVER(inode)))
377 return false;
378 return NFS_SERVER(inode)->pnfs_curr_ld->flags & PNFS_READ_WHOLE_PAGE;
379}
380
381static inline bool
373pnfs_layoutcommit_outstanding(struct inode *inode) 382pnfs_layoutcommit_outstanding(struct inode *inode)
374{ 383{
375 struct nfs_inode *nfsi = NFS_I(inode); 384 struct nfs_inode *nfsi = NFS_I(inode);
@@ -445,6 +454,12 @@ pnfs_ld_layoutret_on_setattr(struct inode *inode)
445} 454}
446 455
447static inline bool 456static inline bool
457pnfs_ld_read_whole_page(struct inode *inode)
458{
459 return false;
460}
461
462static inline bool
448pnfs_roc(struct inode *ino) 463pnfs_roc(struct inode *ino)
449{ 464{
450 return false; 465 return false;