Skip to content

Commit d56b4dd

Browse files
Mel Gormantorvalds
authored andcommitted
nfs: teach the NFS client how to treat PG_swapcache pages
Replace all relevant occurences of page->index and page->mapping in the NFS client with the new page_file_index() and page_file_mapping() functions. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: Rik van Riel <riel@redhat.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: David S. Miller <davem@davemloft.net> Cc: Eric B Munson <emunson@mgebm.net> Cc: Eric Paris <eparis@redhat.com> Cc: James Morris <jmorris@namei.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Mike Christie <michaelc@cs.wisc.edu> Cc: Neil Brown <neilb@suse.de> Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: Xiaotian Feng <dfeng@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5a17811 commit d56b4dd

5 files changed

Lines changed: 29 additions & 28 deletions

File tree

‎fs/nfs/file.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset)
430430
if (offset != 0)
431431
return;
432432
/* Cancel any unstarted writes on this page */
433-
nfs_wb_page_cancel(page->mapping->host, page);
433+
nfs_wb_page_cancel(page_file_mapping(page)->host, page);
434434

435435
nfs_fscache_invalidate_page(page, page->mapping->host);
436436
}
@@ -472,7 +472,7 @@ static int nfs_release_page(struct page *page, gfp_t gfp)
472472
*/
473473
static int nfs_launder_page(struct page *page)
474474
{
475-
struct inode *inode = page->mapping->host;
475+
struct inode *inode = page_file_mapping(page)->host;
476476
struct nfs_inode *nfsi = NFS_I(inode);
477477

478478
dfprintk(PAGECACHE, "NFS: launder_page(%ld, %llu)\n",
@@ -521,7 +521,7 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
521521
nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page);
522522

523523
lock_page(page);
524-
mapping = page->mapping;
524+
mapping = page_file_mapping(page);
525525
if (mapping != dentry->d_inode->i_mapping)
526526
goto out_unlock;
527527

‎fs/nfs/internal.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,13 +546,14 @@ void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
546546
static inline
547547
unsigned int nfs_page_length(struct page *page)
548548
{
549-
loff_t i_size = i_size_read(page->mapping->host);
549+
loff_t i_size = i_size_read(page_file_mapping(page)->host);
550550

551551
if (i_size > 0) {
552+
pgoff_t page_index = page_file_index(page);
552553
pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
553-
if (page->index < end_index)
554+
if (page_index < end_index)
554555
return PAGE_CACHE_SIZE;
555-
if (page->index == end_index)
556+
if (page_index == end_index)
556557
return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1;
557558
}
558559
return 0;

‎fs/nfs/pagelist.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
117117
* long write-back delay. This will be adjusted in
118118
* update_nfs_request below if the region is not locked. */
119119
req->wb_page = page;
120-
req->wb_index = page->index;
120+
req->wb_index = page_file_index(page);
121121
page_cache_get(page);
122122
req->wb_offset = offset;
123123
req->wb_pgbase = offset;

‎fs/nfs/read.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,11 @@ static const struct rpc_call_ops nfs_read_common_ops = {
522522
int nfs_readpage(struct file *file, struct page *page)
523523
{
524524
struct nfs_open_context *ctx;
525-
struct inode *inode = page->mapping->host;
525+
struct inode *inode = page_file_mapping(page)->host;
526526
int error;
527527

528528
dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
529-
page, PAGE_CACHE_SIZE, page->index);
529+
page, PAGE_CACHE_SIZE, page_file_index(page));
530530
nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
531531
nfs_add_stats(inode, NFSIOS_READPAGES, 1);
532532

@@ -580,7 +580,7 @@ static int
580580
readpage_async_filler(void *data, struct page *page)
581581
{
582582
struct nfs_readdesc *desc = (struct nfs_readdesc *)data;
583-
struct inode *inode = page->mapping->host;
583+
struct inode *inode = page_file_mapping(page)->host;
584584
struct nfs_page *new;
585585
unsigned int len;
586586
int error;

‎fs/nfs/write.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static struct nfs_page *nfs_page_find_request_locked(struct page *page)
153153

154154
static struct nfs_page *nfs_page_find_request(struct page *page)
155155
{
156-
struct inode *inode = page->mapping->host;
156+
struct inode *inode = page_file_mapping(page)->host;
157157
struct nfs_page *req = NULL;
158158

159159
spin_lock(&inode->i_lock);
@@ -165,16 +165,16 @@ static struct nfs_page *nfs_page_find_request(struct page *page)
165165
/* Adjust the file length if we're writing beyond the end */
166166
static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count)
167167
{
168-
struct inode *inode = page->mapping->host;
168+
struct inode *inode = page_file_mapping(page)->host;
169169
loff_t end, i_size;
170170
pgoff_t end_index;
171171

172172
spin_lock(&inode->i_lock);
173173
i_size = i_size_read(inode);
174174
end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
175-
if (i_size > 0 && page->index < end_index)
175+
if (i_size > 0 && page_file_index(page) < end_index)
176176
goto out;
177-
end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count);
177+
end = page_file_offset(page) + ((loff_t)offset+count);
178178
if (i_size >= end)
179179
goto out;
180180
i_size_write(inode, end);
@@ -187,7 +187,7 @@ static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int c
187187
static void nfs_set_pageerror(struct page *page)
188188
{
189189
SetPageError(page);
190-
nfs_zap_mapping(page->mapping->host, page->mapping);
190+
nfs_zap_mapping(page_file_mapping(page)->host, page_file_mapping(page));
191191
}
192192

193193
/* We can set the PG_uptodate flag if we see that a write request
@@ -228,7 +228,7 @@ static int nfs_set_page_writeback(struct page *page)
228228
int ret = test_set_page_writeback(page);
229229

230230
if (!ret) {
231-
struct inode *inode = page->mapping->host;
231+
struct inode *inode = page_file_mapping(page)->host;
232232
struct nfs_server *nfss = NFS_SERVER(inode);
233233

234234
if (atomic_long_inc_return(&nfss->writeback) >
@@ -242,7 +242,7 @@ static int nfs_set_page_writeback(struct page *page)
242242

243243
static void nfs_end_page_writeback(struct page *page)
244244
{
245-
struct inode *inode = page->mapping->host;
245+
struct inode *inode = page_file_mapping(page)->host;
246246
struct nfs_server *nfss = NFS_SERVER(inode);
247247

248248
end_page_writeback(page);
@@ -252,7 +252,7 @@ static void nfs_end_page_writeback(struct page *page)
252252

253253
static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblock)
254254
{
255-
struct inode *inode = page->mapping->host;
255+
struct inode *inode = page_file_mapping(page)->host;
256256
struct nfs_page *req;
257257
int ret;
258258

@@ -313,13 +313,13 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
313313

314314
static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
315315
{
316-
struct inode *inode = page->mapping->host;
316+
struct inode *inode = page_file_mapping(page)->host;
317317
int ret;
318318

319319
nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
320320
nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
321321

322-
nfs_pageio_cond_complete(pgio, page->index);
322+
nfs_pageio_cond_complete(pgio, page_file_index(page));
323323
ret = nfs_page_async_flush(pgio, page, wbc->sync_mode == WB_SYNC_NONE);
324324
if (ret == -EAGAIN) {
325325
redirty_page_for_writepage(wbc, page);
@@ -336,7 +336,7 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
336336
struct nfs_pageio_descriptor pgio;
337337
int err;
338338

339-
NFS_PROTO(page->mapping->host)->write_pageio_init(&pgio,
339+
NFS_PROTO(page_file_mapping(page)->host)->write_pageio_init(&pgio,
340340
page->mapping->host,
341341
wb_priority(wbc),
342342
&nfs_async_write_completion_ops);
@@ -471,7 +471,7 @@ nfs_request_add_commit_list(struct nfs_page *req, struct list_head *dst,
471471
spin_unlock(cinfo->lock);
472472
if (!cinfo->dreq) {
473473
inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
474-
inc_bdi_stat(req->wb_page->mapping->backing_dev_info,
474+
inc_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info,
475475
BDI_RECLAIMABLE);
476476
__mark_inode_dirty(req->wb_context->dentry->d_inode,
477477
I_DIRTY_DATASYNC);
@@ -538,7 +538,7 @@ static void
538538
nfs_clear_page_commit(struct page *page)
539539
{
540540
dec_zone_page_state(page, NR_UNSTABLE_NFS);
541-
dec_bdi_stat(page->mapping->backing_dev_info, BDI_RECLAIMABLE);
541+
dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE);
542542
}
543543

544544
static void
@@ -789,7 +789,7 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
789789
static struct nfs_page * nfs_setup_write_request(struct nfs_open_context* ctx,
790790
struct page *page, unsigned int offset, unsigned int bytes)
791791
{
792-
struct inode *inode = page->mapping->host;
792+
struct inode *inode = page_file_mapping(page)->host;
793793
struct nfs_page *req;
794794

795795
req = nfs_try_to_update_request(inode, page, offset, bytes);
@@ -842,7 +842,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page)
842842
nfs_release_request(req);
843843
if (!do_flush)
844844
return 0;
845-
status = nfs_wb_page(page->mapping->host, page);
845+
status = nfs_wb_page(page_file_mapping(page)->host, page);
846846
} while (status == 0);
847847
return status;
848848
}
@@ -872,15 +872,15 @@ int nfs_updatepage(struct file *file, struct page *page,
872872
unsigned int offset, unsigned int count)
873873
{
874874
struct nfs_open_context *ctx = nfs_file_open_context(file);
875-
struct inode *inode = page->mapping->host;
875+
struct inode *inode = page_file_mapping(page)->host;
876876
int status = 0;
877877

878878
nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
879879

880880
dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n",
881881
file->f_path.dentry->d_parent->d_name.name,
882882
file->f_path.dentry->d_name.name, count,
883-
(long long)(page_offset(page) + offset));
883+
(long long)(page_file_offset(page) + offset));
884884

885885
/* If we're not using byte range locks, and we know the page
886886
* is up to date, it may be more efficient to extend the write
@@ -1469,7 +1469,7 @@ void nfs_retry_commit(struct list_head *page_list,
14691469
nfs_mark_request_commit(req, lseg, cinfo);
14701470
if (!cinfo->dreq) {
14711471
dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
1472-
dec_bdi_stat(req->wb_page->mapping->backing_dev_info,
1472+
dec_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info,
14731473
BDI_RECLAIMABLE);
14741474
}
14751475
nfs_unlock_and_release_request(req);

0 commit comments

Comments
 (0)