Skip to content

Commit 612aa98

Browse files
Christoph Hellwigtrondmypd
authored andcommitted
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>
1 parent 7c5d187 commit 612aa98

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

fs/nfs/file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "internal.h"
3737
#include "iostat.h"
3838
#include "fscache.h"
39+
#include "pnfs.h"
3940

4041
#include "nfstrace.h"
4142

@@ -327,6 +328,12 @@ static int nfs_want_read_modify_write(struct file *file, struct page *page,
327328
unsigned int offset = pos & (PAGE_CACHE_SIZE - 1);
328329
unsigned int end = offset + len;
329330

331+
if (pnfs_ld_read_whole_page(file->f_mapping->host)) {
332+
if (!PageUptodate(page))
333+
return 1;
334+
return 0;
335+
}
336+
330337
if ((file->f_mode & FMODE_READ) && /* open for read? */
331338
!PageUptodate(page) && /* Uptodate? */
332339
!PagePrivate(page) && /* i/o request already? */

fs/nfs/pnfs.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ enum layoutdriver_policy_flags {
7272
/* Should the pNFS client commit and return the layout upon a setattr */
7373
PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
7474
PNFS_LAYOUTRET_ON_ERROR = 1 << 1,
75+
PNFS_READ_WHOLE_PAGE = 1 << 2,
7576
};
7677

7778
struct nfs4_deviceid_node;
@@ -369,6 +370,14 @@ pnfs_ld_layoutret_on_setattr(struct inode *inode)
369370
PNFS_LAYOUTRET_ON_SETATTR;
370371
}
371372

373+
static inline bool
374+
pnfs_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+
372381
static inline bool
373382
pnfs_layoutcommit_outstanding(struct inode *inode)
374383
{
@@ -444,6 +453,12 @@ pnfs_ld_layoutret_on_setattr(struct inode *inode)
444453
return false;
445454
}
446455

456+
static inline bool
457+
pnfs_ld_read_whole_page(struct inode *inode)
458+
{
459+
return false;
460+
}
461+
447462
static inline bool
448463
pnfs_roc(struct inode *ino)
449464
{

0 commit comments

Comments
 (0)