Skip to content

Commit 0c493b5

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
NFS: Convert buffered writes to use folios
Mostly mechanical conversion of struct page and functions into struct folio equivalents. The lack of support for folios in write_cache_pages(), means we still only support order 0 folio allocations. However the rest of the writeback code should now be ready for order n > 0. Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 5241060 commit 0c493b5

File tree

6 files changed

+210
-200
lines changed

6 files changed

+210
-200
lines changed

fs/nfs/file.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
319319
int ret;
320320
pgoff_t index = pos >> PAGE_SHIFT;
321321
struct page *page;
322+
struct folio *folio;
322323
int once_thru = 0;
323324

324325
dfprintk(PAGECACHE, "NFS: write_begin(%pD2(%lu), %u@%lld)\n",
@@ -329,15 +330,16 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
329330
if (!page)
330331
return -ENOMEM;
331332
*pagep = page;
333+
folio = page_folio(page);
332334

333-
ret = nfs_flush_incompatible(file, page);
335+
ret = nfs_flush_incompatible(file, folio);
334336
if (ret) {
335337
unlock_page(page);
336338
put_page(page);
337339
} else if (!once_thru &&
338340
nfs_want_read_modify_write(file, page, pos, len)) {
339341
once_thru = 1;
340-
ret = nfs_read_folio(file, page_folio(page));
342+
ret = nfs_read_folio(file, folio);
341343
put_page(page);
342344
if (!ret)
343345
goto start;
@@ -351,6 +353,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
351353
{
352354
unsigned offset = pos & (PAGE_SIZE - 1);
353355
struct nfs_open_context *ctx = nfs_file_open_context(file);
356+
struct folio *folio = page_folio(page);
354357
int status;
355358

356359
dfprintk(PAGECACHE, "NFS: write_end(%pD2(%lu), %u@%lld)\n",
@@ -376,7 +379,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
376379
zero_user_segment(page, pglen, PAGE_SIZE);
377380
}
378381

379-
status = nfs_updatepage(file, page, offset, copied);
382+
status = nfs_update_folio(file, folio, offset, copied);
380383

381384
unlock_page(page);
382385
put_page(page);
@@ -552,6 +555,7 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
552555
unsigned pagelen;
553556
vm_fault_t ret = VM_FAULT_NOPAGE;
554557
struct address_space *mapping;
558+
struct folio *folio = page_folio(page);
555559

556560
dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%pD2(%lu), offset %lld)\n",
557561
filp, filp->f_mapping->host->i_ino,
@@ -582,8 +586,8 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
582586
goto out_unlock;
583587

584588
ret = VM_FAULT_LOCKED;
585-
if (nfs_flush_incompatible(filp, page) == 0 &&
586-
nfs_updatepage(filp, page, 0, pagelen) == 0)
589+
if (nfs_flush_incompatible(filp, folio) == 0 &&
590+
nfs_update_folio(filp, folio, 0, pagelen) == 0)
587591
goto out;
588592

589593
ret = VM_FAULT_SIGBUS;

fs/nfs/internal.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -760,17 +760,18 @@ void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
760760
* Record the page as unstable (an extra writeback period) and mark its
761761
* inode as dirty.
762762
*/
763-
static inline
764-
void nfs_mark_page_unstable(struct page *page, struct nfs_commit_info *cinfo)
763+
static inline void nfs_folio_mark_unstable(struct folio *folio,
764+
struct nfs_commit_info *cinfo)
765765
{
766-
if (!cinfo->dreq) {
767-
struct inode *inode = page_file_mapping(page)->host;
766+
if (folio && !cinfo->dreq) {
767+
struct inode *inode = folio_file_mapping(folio)->host;
768+
long nr = folio_nr_pages(folio);
768769

769770
/* This page is really still in write-back - just that the
770771
* writeback is happening on the server now.
771772
*/
772-
inc_node_page_state(page, NR_WRITEBACK);
773-
inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);
773+
node_stat_mod_folio(folio, NR_WRITEBACK, nr);
774+
wb_stat_mod(&inode_to_bdi(inode)->wb, WB_WRITEBACK, nr);
774775
__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
775776
}
776777
}

fs/nfs/pnfs.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct pnfs_commit_ops {
193193
void (*recover_commit_reqs) (struct list_head *list,
194194
struct nfs_commit_info *cinfo);
195195
struct nfs_page * (*search_commit_reqs)(struct nfs_commit_info *cinfo,
196-
struct page *page);
196+
struct folio *folio);
197197
};
198198

199199
struct pnfs_layout_hdr {
@@ -395,7 +395,7 @@ void pnfs_generic_rw_release(void *data);
395395
void pnfs_generic_recover_commit_reqs(struct list_head *dst,
396396
struct nfs_commit_info *cinfo);
397397
struct nfs_page *pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo,
398-
struct page *page);
398+
struct folio *folio);
399399
int pnfs_generic_commit_pagelist(struct inode *inode,
400400
struct list_head *mds_pages,
401401
int how,
@@ -557,13 +557,13 @@ pnfs_recover_commit_reqs(struct list_head *head, struct nfs_commit_info *cinfo)
557557

558558
static inline struct nfs_page *
559559
pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo,
560-
struct page *page)
560+
struct folio *folio)
561561
{
562562
struct pnfs_ds_commit_info *fl_cinfo = cinfo->ds;
563563

564564
if (!fl_cinfo->ops || !fl_cinfo->ops->search_commit_reqs)
565565
return NULL;
566-
return fl_cinfo->ops->search_commit_reqs(cinfo, page);
566+
return fl_cinfo->ops->search_commit_reqs(cinfo, folio);
567567
}
568568

569569
/* Should the pNFS client commit and return the layout upon a setattr */
@@ -864,7 +864,7 @@ pnfs_recover_commit_reqs(struct list_head *head, struct nfs_commit_info *cinfo)
864864

865865
static inline struct nfs_page *
866866
pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo,
867-
struct page *page)
867+
struct folio *folio)
868868
{
869869
return NULL;
870870
}

fs/nfs/pnfs_nfs.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ EXPORT_SYMBOL_GPL(pnfs_generic_recover_commit_reqs);
353353

354354
static struct nfs_page *
355355
pnfs_bucket_search_commit_reqs(struct pnfs_commit_bucket *buckets,
356-
unsigned int nbuckets, struct page *page)
356+
unsigned int nbuckets, struct folio *folio)
357357
{
358358
struct nfs_page *req;
359359
struct pnfs_commit_bucket *b;
@@ -363,34 +363,34 @@ pnfs_bucket_search_commit_reqs(struct pnfs_commit_bucket *buckets,
363363
* request is found */
364364
for (i = 0, b = buckets; i < nbuckets; i++, b++) {
365365
list_for_each_entry(req, &b->written, wb_list) {
366-
if (req->wb_page == page)
366+
if (nfs_page_to_folio(req) == folio)
367367
return req->wb_head;
368368
}
369369
list_for_each_entry(req, &b->committing, wb_list) {
370-
if (req->wb_page == page)
370+
if (nfs_page_to_folio(req) == folio)
371371
return req->wb_head;
372372
}
373373
}
374374
return NULL;
375375
}
376376

377377
/* pnfs_generic_search_commit_reqs - Search lists in @cinfo for the head request
378-
* for @page
378+
* for @folio
379379
* @cinfo - commit info for current inode
380-
* @page - page to search for matching head request
380+
* @folio - page to search for matching head request
381381
*
382382
* Return: the head request if one is found, otherwise %NULL.
383383
*/
384-
struct nfs_page *
385-
pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page)
384+
struct nfs_page *pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo,
385+
struct folio *folio)
386386
{
387387
struct pnfs_ds_commit_info *fl_cinfo = cinfo->ds;
388388
struct pnfs_commit_array *array;
389389
struct nfs_page *req;
390390

391391
list_for_each_entry(array, &fl_cinfo->commits, cinfo_list) {
392392
req = pnfs_bucket_search_commit_reqs(array->buckets,
393-
array->nbuckets, page);
393+
array->nbuckets, folio);
394394
if (req)
395395
return req;
396396
}
@@ -1180,7 +1180,7 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
11801180

11811181
nfs_request_add_commit_list_locked(req, list, cinfo);
11821182
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
1183-
nfs_mark_page_unstable(req->wb_page, cinfo);
1183+
nfs_folio_mark_unstable(nfs_page_to_folio(req), cinfo);
11841184
return;
11851185
out_resched:
11861186
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);

0 commit comments

Comments
 (0)