Skip to content

Commit 070a542

Browse files
committed
Merge tag 'nfs-for-6.18-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client updates from Anna Schumaker: "New Features: - Add a Kconfig option to redirect dfprintk() to the trace buffer - Enable use of the RWF_DONTCACHE flag on the NFS client - Add striped layout handling to pNFS flexfiles - Add proper localio handling for READ and WRITE O_DIRECT Bugfixes: - Handle NFS4ERR_GRACE errors during delegation recall - Fix NFSv4.1 backchannel max_resp_sz verification check - Fix mount hang after CREATE_SESSION failure - Fix d_parent->d_inode locking in nfs4_setup_readdir() Other Cleanups and Improvements: - Improvements to write handling tracepoints - Fix a few trivial spelling mistakes - Cleanups to the rpcbind cleanup call sites - Convert the SUNRPC xdr_buf to use a scratch folio instead of scratch page - Remove unused NFS_WBACK_BUSY() macro - Remove __GFP_NOWARN flags - Unexport rpc_malloc() and rpc_free()" * tag 'nfs-for-6.18-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (46 commits) NFS: add basic STATX_DIOALIGN and STATX_DIO_READ_ALIGN support nfs/localio: add tracepoints for misaligned DIO READ and WRITE support nfs/localio: add proper O_DIRECT support for READ and WRITE nfs/localio: refactor iocb initialization nfs/localio: refactor iocb and iov_iter_bvec initialization nfs/localio: avoid issuing misaligned IO using O_DIRECT nfs/localio: make trace_nfs_local_open_fh more useful NFSD: filecache: add STATX_DIOALIGN and STATX_DIO_READ_ALIGN support sunrpc: unexport rpc_malloc() and rpc_free() NFSv4/flexfiles: Add support for striped layouts NFSv4/flexfiles: Update layout stats & error paths for striped layouts NFSv4/flexfiles: Write path updates for striped layouts NFSv4/flexfiles: Commit path updates for striped layouts NFSv4/flexfiles: Read path updates for striped layouts NFSv4/flexfiles: Update low level helper functions to be DS stripe aware. NFSv4/flexfiles: Add data structure support for striped layouts NFSv4/flexfiles: Use ds_commit_idx when marking a write commit NFSv4/flexfiles: Remove cred local variable dependency nfs4_setup_readdir(): insufficient locking for ->d_parent->d_inode dereferencing NFS: Enable use of the RWF_DONTCACHE flag on the NFS client ...
2 parents 63e62ba + 1f0d4ab commit 070a542

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1460
-547
lines changed

fs/lockd/svc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ static int make_socks(struct svc_serv *serv, struct net *net,
216216
if (warned++ == 0)
217217
printk(KERN_WARNING
218218
"lockd_up: makesock failed, error=%d\n", err);
219-
svc_xprt_destroy_all(serv, net);
220-
svc_rpcb_cleanup(serv, net);
219+
svc_xprt_destroy_all(serv, net, true);
221220
return err;
222221
}
223222

@@ -255,8 +254,7 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net)
255254
nlm_shutdown_hosts_net(net);
256255
cancel_delayed_work_sync(&ln->grace_period_end);
257256
locks_end_grace(&ln->lockd_manager);
258-
svc_xprt_destroy_all(serv, net);
259-
svc_rpcb_cleanup(serv, net);
257+
svc_xprt_destroy_all(serv, net, true);
260258
}
261259
} else {
262260
pr_err("%s: no users! net=%x\n",

fs/nfs/blocklayout/blocklayout.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
676676
struct pnfs_layout_segment *lseg;
677677
struct xdr_buf buf;
678678
struct xdr_stream xdr;
679-
struct page *scratch;
679+
struct folio *scratch;
680680
int status, i;
681681
uint32_t count;
682682
__be32 *p;
@@ -689,13 +689,13 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
689689
return ERR_PTR(-ENOMEM);
690690

691691
status = -ENOMEM;
692-
scratch = alloc_page(gfp_mask);
692+
scratch = folio_alloc(gfp_mask, 0);
693693
if (!scratch)
694694
goto out;
695695

696696
xdr_init_decode_pages(&xdr, &buf,
697697
lgr->layoutp->pages, lgr->layoutp->len);
698-
xdr_set_scratch_page(&xdr, scratch);
698+
xdr_set_scratch_folio(&xdr, scratch);
699699

700700
status = -EIO;
701701
p = xdr_inline_decode(&xdr, 4);
@@ -744,7 +744,7 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr,
744744
}
745745

746746
out_free_scratch:
747-
__free_page(scratch);
747+
folio_put(scratch);
748748
out:
749749
dprintk("%s returns %d\n", __func__, status);
750750
switch (status) {

fs/nfs/blocklayout/dev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,16 +541,16 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
541541
struct pnfs_block_dev *top;
542542
struct xdr_stream xdr;
543543
struct xdr_buf buf;
544-
struct page *scratch;
544+
struct folio *scratch;
545545
int nr_volumes, ret, i;
546546
__be32 *p;
547547

548-
scratch = alloc_page(gfp_mask);
548+
scratch = folio_alloc(gfp_mask, 0);
549549
if (!scratch)
550550
goto out;
551551

552552
xdr_init_decode_pages(&xdr, &buf, pdev->pages, pdev->pglen);
553-
xdr_set_scratch_page(&xdr, scratch);
553+
xdr_set_scratch_folio(&xdr, scratch);
554554

555555
p = xdr_inline_decode(&xdr, sizeof(__be32));
556556
if (!p)
@@ -582,7 +582,7 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
582582
out_free_volumes:
583583
kfree(volumes);
584584
out_free_scratch:
585-
__free_page(scratch);
585+
folio_put(scratch);
586586
out:
587587
return node;
588588
}

fs/nfs/callback.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static void nfs_callback_down_net(u32 minorversion, struct svc_serv *serv, struc
136136
return;
137137

138138
dprintk("NFS: destroy per-net callback data; net=%x\n", net->ns.inum);
139-
svc_xprt_destroy_all(serv, net);
139+
svc_xprt_destroy_all(serv, net, false);
140140
}
141141

142142
static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
@@ -153,7 +153,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
153153
ret = svc_bind(serv, net);
154154
if (ret < 0) {
155155
printk(KERN_WARNING "NFS: bind callback service failed\n");
156-
goto err_bind;
156+
goto err;
157157
}
158158

159159
ret = 0;
@@ -166,13 +166,11 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
166166

167167
if (ret < 0) {
168168
printk(KERN_ERR "NFS: callback service start failed\n");
169-
goto err_socks;
169+
goto err;
170170
}
171171
return 0;
172172

173-
err_socks:
174-
svc_rpcb_cleanup(serv, net);
175-
err_bind:
173+
err:
176174
nn->cb_users[minorversion]--;
177175
dprintk("NFS: Couldn't create callback socket: err = %d; "
178176
"net = %x\n", ret, net->ns.inum);

fs/nfs/dir.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,17 +829,17 @@ static int nfs_readdir_folio_filler(struct nfs_readdir_descriptor *desc,
829829
struct address_space *mapping = desc->file->f_mapping;
830830
struct folio *new, *folio = *arrays;
831831
struct xdr_stream stream;
832-
struct page *scratch;
832+
struct folio *scratch;
833833
struct xdr_buf buf;
834834
u64 cookie;
835835
int status;
836836

837-
scratch = alloc_page(GFP_KERNEL);
837+
scratch = folio_alloc(GFP_KERNEL, 0);
838838
if (scratch == NULL)
839839
return -ENOMEM;
840840

841841
xdr_init_decode_pages(&stream, &buf, xdr_pages, buflen);
842-
xdr_set_scratch_page(&stream, scratch);
842+
xdr_set_scratch_folio(&stream, scratch);
843843

844844
do {
845845
status = nfs_readdir_entry_decode(desc, entry, &stream);
@@ -891,7 +891,7 @@ static int nfs_readdir_folio_filler(struct nfs_readdir_descriptor *desc,
891891
if (folio != *arrays)
892892
nfs_readdir_folio_unlock_and_put(folio);
893893

894-
put_page(scratch);
894+
folio_put(scratch);
895895
return status;
896896
}
897897

fs/nfs/file.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to)
161161
struct inode *inode = file_inode(iocb->ki_filp);
162162
ssize_t result;
163163

164+
trace_nfs_file_read(iocb, to);
165+
164166
if (iocb->ki_flags & IOCB_DIRECT)
165167
return nfs_file_direct_read(iocb, to, false);
166168

@@ -361,6 +363,8 @@ static bool nfs_want_read_modify_write(struct file *file, struct folio *folio,
361363

362364
if (pnfs_ld_read_whole_page(file_inode(file)))
363365
return true;
366+
if (folio_test_dropbehind(folio))
367+
return false;
364368
/* Open for reading too? */
365369
if (file->f_mode & FMODE_READ)
366370
return true;
@@ -380,22 +384,23 @@ static int nfs_write_begin(const struct kiocb *iocb,
380384
loff_t pos, unsigned len, struct folio **foliop,
381385
void **fsdata)
382386
{
383-
fgf_t fgp = FGP_WRITEBEGIN;
384387
struct folio *folio;
385388
struct file *file = iocb->ki_filp;
386389
int once_thru = 0;
387390
int ret;
388391

392+
trace_nfs_write_begin(file_inode(file), pos, len);
393+
389394
dfprintk(PAGECACHE, "NFS: write_begin(%pD2(%lu), %u@%lld)\n",
390395
file, mapping->host->i_ino, len, (long long) pos);
391396
nfs_truncate_last_folio(mapping, i_size_read(mapping->host), pos);
392397

393-
fgp |= fgf_set_order(len);
394398
start:
395-
folio = __filemap_get_folio(mapping, pos >> PAGE_SHIFT, fgp,
396-
mapping_gfp_mask(mapping));
397-
if (IS_ERR(folio))
398-
return PTR_ERR(folio);
399+
folio = write_begin_get_folio(iocb, mapping, pos >> PAGE_SHIFT, len);
400+
if (IS_ERR(folio)) {
401+
ret = PTR_ERR(folio);
402+
goto out;
403+
}
399404
*foliop = folio;
400405

401406
ret = nfs_flush_incompatible(file, folio);
@@ -405,11 +410,14 @@ static int nfs_write_begin(const struct kiocb *iocb,
405410
} else if (!once_thru &&
406411
nfs_want_read_modify_write(file, folio, pos, len)) {
407412
once_thru = 1;
413+
folio_clear_dropbehind(folio);
408414
ret = nfs_read_folio(file, folio);
409415
folio_put(folio);
410416
if (!ret)
411417
goto start;
412418
}
419+
out:
420+
trace_nfs_write_begin_done(file_inode(file), pos, len, ret);
413421
return ret;
414422
}
415423

@@ -423,6 +431,7 @@ static int nfs_write_end(const struct kiocb *iocb,
423431
unsigned offset = offset_in_folio(folio, pos);
424432
int status;
425433

434+
trace_nfs_write_end(file_inode(file), pos, len);
426435
dfprintk(PAGECACHE, "NFS: write_end(%pD2(%lu), %u@%lld)\n",
427436
file, mapping->host->i_ino, len, (long long) pos);
428437

@@ -451,13 +460,16 @@ static int nfs_write_end(const struct kiocb *iocb,
451460
folio_unlock(folio);
452461
folio_put(folio);
453462

454-
if (status < 0)
463+
if (status < 0) {
464+
trace_nfs_write_end_done(file_inode(file), pos, len, status);
455465
return status;
466+
}
456467
NFS_I(mapping->host)->write_io += copied;
457468

458469
if (nfs_ctx_key_to_expire(ctx, mapping->host))
459470
nfs_wb_all(mapping->host);
460471

472+
trace_nfs_write_end_done(file_inode(file), pos, len, copied);
461473
return copied;
462474
}
463475

@@ -690,6 +702,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
690702
errseq_t since;
691703
int error;
692704

705+
trace_nfs_file_write(iocb, from);
706+
693707
result = nfs_key_timeout_notify(file, inode);
694708
if (result)
695709
return result;
@@ -949,5 +963,6 @@ const struct file_operations nfs_file_operations = {
949963
.splice_write = iter_file_splice_write,
950964
.check_flags = nfs_check_flags,
951965
.setlease = simple_nosetlease,
966+
.fop_flags = FOP_DONTCACHE,
952967
};
953968
EXPORT_SYMBOL_GPL(nfs_file_operations);

fs/nfs/filelayout/filelayout.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,19 +646,19 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
646646
{
647647
struct xdr_stream stream;
648648
struct xdr_buf buf;
649-
struct page *scratch;
649+
struct folio *scratch;
650650
__be32 *p;
651651
uint32_t nfl_util;
652652
int i;
653653

654654
dprintk("%s: set_layout_map Begin\n", __func__);
655655

656-
scratch = alloc_page(gfp_flags);
656+
scratch = folio_alloc(gfp_flags, 0);
657657
if (!scratch)
658658
return -ENOMEM;
659659

660660
xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages, lgr->layoutp->len);
661-
xdr_set_scratch_page(&stream, scratch);
661+
xdr_set_scratch_folio(&stream, scratch);
662662

663663
/* 20 = ufl_util (4), first_stripe_index (4), pattern_offset (8),
664664
* num_fh (4) */
@@ -724,11 +724,11 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
724724
fl->fh_array[i]->size);
725725
}
726726

727-
__free_page(scratch);
727+
folio_put(scratch);
728728
return 0;
729729

730730
out_err:
731-
__free_page(scratch);
731+
folio_put(scratch);
732732
return -EIO;
733733
}
734734

fs/nfs/filelayout/filelayoutdev.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,18 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
7373
struct nfs4_file_layout_dsaddr *dsaddr = NULL;
7474
struct xdr_stream stream;
7575
struct xdr_buf buf;
76-
struct page *scratch;
76+
struct folio *scratch;
7777
struct list_head dsaddrs;
7878
struct nfs4_pnfs_ds_addr *da;
7979
struct net *net = server->nfs_client->cl_net;
8080

8181
/* set up xdr stream */
82-
scratch = alloc_page(gfp_flags);
82+
scratch = folio_alloc(gfp_flags, 0);
8383
if (!scratch)
8484
goto out_err;
8585

8686
xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen);
87-
xdr_set_scratch_page(&stream, scratch);
87+
xdr_set_scratch_folio(&stream, scratch);
8888

8989
/* Get the stripe count (number of stripe index) */
9090
p = xdr_inline_decode(&stream, 4);
@@ -186,7 +186,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
186186
}
187187
}
188188

189-
__free_page(scratch);
189+
folio_put(scratch);
190190
return dsaddr;
191191

192192
out_err_drain_dsaddrs:
@@ -204,7 +204,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
204204
out_err_free_stripe_indices:
205205
kfree(stripe_indices);
206206
out_err_free_scratch:
207-
__free_page(scratch);
207+
folio_put(scratch);
208208
out_err:
209209
dprintk("%s ERROR: returning NULL\n", __func__);
210210
return NULL;

0 commit comments

Comments
 (0)