Skip to content

Commit 59953fb

Browse files
committed
Merge tag 'nfs-for-4.1-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client updates from Trond Myklebust: "Another set of mainly bugfixes and a couple of cleanups. No new functionality in this round. Highlights include: Stable patches: - Fix a regression in /proc/self/mountstats - Fix the pNFS flexfiles O_DIRECT support - Fix high load average due to callback thread sleeping Bugfixes: - Various patches to fix the pNFS layoutcommit support - Do not cache pNFS deviceids unless server notifications are enabled - Fix a SUNRPC transport reconnection regression - make debugfs file creation failure non-fatal in SUNRPC - Another fix for circular directory warnings on NFSv4 "junctioned" mountpoints - Fix locking around NFSv4.2 fallocate() support - Truncating NFSv4 file opens should also sync O_DIRECT writes - Prevent infinite loop in rpcrdma_ep_create() Features: - Various improvements to the RDMA transport code's handling of memory registration - Various code cleanups" * tag 'nfs-for-4.1-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (55 commits) fs/nfs: fix new compiler warning about boolean in switch nfs: Remove unneeded casts in nfs NFS: Don't attempt to decode missing directory entries Revert "nfs: replace nfs_add_stats with nfs_inc_stats when add one" NFS: Rename idmap.c to nfs4idmap.c NFS: Move nfs_idmap.h into fs/nfs/ NFS: Remove CONFIG_NFS_V4 checks from nfs_idmap.h NFS: Add a stub for GETDEVICELIST nfs: remove WARN_ON_ONCE from nfs_direct_good_bytes nfs: fix DIO good bytes calculation nfs: Fetch MOUNTED_ON_FILEID when updating an inode sunrpc: make debugfs file creation failure non-fatal nfs: fix high load average due to callback thread sleeping NFS: Reduce time spent holding the i_mutex during fallocate() NFS: Don't zap caches on fallocate() xprtrdma: Make rpcrdma_{un}map_one() into inline functions xprtrdma: Handle non-SEND completions via a callout xprtrdma: Add "open" memreg op xprtrdma: Add "destroy MRs" memreg op xprtrdma: Add "reset MRs" memreg op ...
2 parents 9ec3a64 + f139b6c commit 59953fb

Some content is hidden

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

49 files changed

+1150
-914
lines changed

fs/nfs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ nfsv3-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
2222
obj-$(CONFIG_NFS_V4) += nfsv4.o
2323
CFLAGS_nfs4trace.o += -I$(src)
2424
nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \
25-
delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \
25+
delegation.o nfs4idmap.o callback.o callback_xdr.o callback_proc.o \
2626
nfs4namespace.o nfs4getroot.o nfs4client.o nfs4session.o \
2727
dns_resolve.o nfs4trace.o
2828
nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o

fs/nfs/blocklayout/blocklayout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ static struct pnfs_layoutdriver_type blocklayout_type = {
890890
.free_deviceid_node = bl_free_deviceid_node,
891891
.pg_read_ops = &bl_pg_read_ops,
892892
.pg_write_ops = &bl_pg_write_ops,
893+
.sync = pnfs_generic_sync,
893894
};
894895

895896
static int __init nfs4blocklayout_init(void)

fs/nfs/blocklayout/dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bl_free_deviceid_node(struct nfs4_deviceid_node *d)
3333
container_of(d, struct pnfs_block_dev, node);
3434

3535
bl_free_device(dev);
36-
kfree(dev);
36+
kfree_rcu(dev, node.rcu);
3737
}
3838

3939
static int

fs/nfs/callback.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ nfs41_callback_svc(void *vrqstp)
128128
if (try_to_freeze())
129129
continue;
130130

131-
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_UNINTERRUPTIBLE);
131+
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
132132
spin_lock_bh(&serv->sv_cb_lock);
133133
if (!list_empty(&serv->sv_cb_list)) {
134134
req = list_first_entry(&serv->sv_cb_list,
@@ -142,10 +142,10 @@ nfs41_callback_svc(void *vrqstp)
142142
error);
143143
} else {
144144
spin_unlock_bh(&serv->sv_cb_lock);
145-
/* schedule_timeout to game the hung task watchdog */
146-
schedule_timeout(60 * HZ);
145+
schedule();
147146
finish_wait(&serv->sv_cb_waitq, &wq);
148147
}
148+
flush_signals(current);
149149
}
150150
return 0;
151151
}

fs/nfs/client.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <linux/lockd/bind.h>
3232
#include <linux/seq_file.h>
3333
#include <linux/mount.h>
34-
#include <linux/nfs_idmap.h>
3534
#include <linux/vfs.h>
3635
#include <linux/inet.h>
3736
#include <linux/in6.h>

fs/nfs/delegation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
378378
if (freeme == NULL)
379379
goto out;
380380
}
381-
list_add_rcu(&delegation->super_list, &server->delegations);
381+
list_add_tail_rcu(&delegation->super_list, &server->delegations);
382382
rcu_assign_pointer(nfsi->delegation, delegation);
383383
delegation = NULL;
384384

@@ -514,7 +514,7 @@ void nfs_inode_return_delegation_noreclaim(struct inode *inode)
514514

515515
delegation = nfs_inode_detach_delegation(inode);
516516
if (delegation != NULL)
517-
nfs_do_return_delegation(inode, delegation, 0);
517+
nfs_do_return_delegation(inode, delegation, 1);
518518
}
519519

520520
/**

fs/nfs/dir.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en
543543
if (scratch == NULL)
544544
return -ENOMEM;
545545

546+
if (buflen == 0)
547+
goto out_nopages;
548+
546549
xdr_init_decode_pages(&stream, &buf, xdr_pages, buflen);
547550
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
548551

@@ -564,6 +567,7 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en
564567
break;
565568
} while (!entry->eof);
566569

570+
out_nopages:
567571
if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) {
568572
array = nfs_readdir_get_array(page);
569573
if (!IS_ERR(array)) {

fs/nfs/direct.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,25 @@ nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr)
129129
int i;
130130
ssize_t count;
131131

132-
WARN_ON_ONCE(hdr->pgio_mirror_idx >= dreq->mirror_count);
133-
134-
count = dreq->mirrors[hdr->pgio_mirror_idx].count;
135-
if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) {
136-
count = hdr->io_start + hdr->good_bytes - dreq->io_start;
137-
dreq->mirrors[hdr->pgio_mirror_idx].count = count;
138-
}
139-
140-
/* update the dreq->count by finding the minimum agreed count from all
141-
* mirrors */
142-
count = dreq->mirrors[0].count;
132+
if (dreq->mirror_count == 1) {
133+
dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes;
134+
dreq->count += hdr->good_bytes;
135+
} else {
136+
/* mirrored writes */
137+
count = dreq->mirrors[hdr->pgio_mirror_idx].count;
138+
if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) {
139+
count = hdr->io_start + hdr->good_bytes - dreq->io_start;
140+
dreq->mirrors[hdr->pgio_mirror_idx].count = count;
141+
}
142+
/* update the dreq->count by finding the minimum agreed count from all
143+
* mirrors */
144+
count = dreq->mirrors[0].count;
143145

144-
for (i = 1; i < dreq->mirror_count; i++)
145-
count = min(count, dreq->mirrors[i].count);
146+
for (i = 1; i < dreq->mirror_count; i++)
147+
count = min(count, dreq->mirrors[i].count);
146148

147-
dreq->count = count;
149+
dreq->count = count;
150+
}
148151
}
149152

150153
/*
@@ -258,18 +261,11 @@ ssize_t nfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
258261
if (!IS_SWAPFILE(inode))
259262
return 0;
260263

261-
#ifndef CONFIG_NFS_SWAP
262-
dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n",
263-
iocb->ki_filp, (long long) pos, iter->nr_segs);
264-
265-
return -EINVAL;
266-
#else
267264
VM_BUG_ON(iov_iter_count(iter) != PAGE_SIZE);
268265

269266
if (iov_iter_rw(iter) == READ)
270267
return nfs_file_direct_read(iocb, iter, pos);
271268
return nfs_file_direct_write(iocb, iter);
272-
#endif /* CONFIG_NFS_SWAP */
273269
}
274270

275271
static void nfs_direct_release_pages(struct page **pages, unsigned int npages)
@@ -1030,6 +1026,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
10301026
if (i_size_read(inode) < iocb->ki_pos)
10311027
i_size_write(inode, iocb->ki_pos);
10321028
spin_unlock(&inode->i_lock);
1029+
generic_write_sync(file, pos, result);
10331030
}
10341031
}
10351032
nfs_direct_req_release(dreq);

fs/nfs/file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
280280

281281
trace_nfs_fsync_enter(inode);
282282

283+
nfs_inode_dio_wait(inode);
283284
do {
284285
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
285286
if (ret != 0)
@@ -782,7 +783,7 @@ do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
782783
* Flush all pending writes before doing anything
783784
* with locks..
784785
*/
785-
nfs_sync_mapping(filp->f_mapping);
786+
vfs_fsync(filp, 0);
786787

787788
l_ctx = nfs_get_lock_context(nfs_file_open_context(filp));
788789
if (!IS_ERR(l_ctx)) {

fs/nfs/filelayout/filelayout.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ filelayout_set_layoutcommit(struct nfs_pgio_header *hdr)
258258
hdr->res.verf->committed != NFS_DATA_SYNC)
259259
return;
260260

261-
pnfs_set_layoutcommit(hdr);
261+
pnfs_set_layoutcommit(hdr->inode, hdr->lseg,
262+
hdr->mds_offset + hdr->res.count);
262263
dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino,
263264
(unsigned long) NFS_I(hdr->inode)->layout->plh_lwb);
264265
}
@@ -373,7 +374,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task,
373374
}
374375

375376
if (data->verf.committed == NFS_UNSTABLE)
376-
pnfs_commit_set_layoutcommit(data);
377+
pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb);
377378

378379
return 0;
379380
}
@@ -1086,7 +1087,7 @@ filelayout_alloc_deviceid_node(struct nfs_server *server,
10861087
}
10871088

10881089
static void
1089-
filelayout_free_deveiceid_node(struct nfs4_deviceid_node *d)
1090+
filelayout_free_deviceid_node(struct nfs4_deviceid_node *d)
10901091
{
10911092
nfs4_fl_free_deviceid(container_of(d, struct nfs4_file_layout_dsaddr, id_node));
10921093
}
@@ -1137,7 +1138,8 @@ static struct pnfs_layoutdriver_type filelayout_type = {
11371138
.read_pagelist = filelayout_read_pagelist,
11381139
.write_pagelist = filelayout_write_pagelist,
11391140
.alloc_deviceid_node = filelayout_alloc_deviceid_node,
1140-
.free_deviceid_node = filelayout_free_deveiceid_node,
1141+
.free_deviceid_node = filelayout_free_deviceid_node,
1142+
.sync = pnfs_nfs_generic_sync,
11411143
};
11421144

11431145
static int __init nfs4filelayout_init(void)

fs/nfs/filelayout/filelayoutdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr)
5555
nfs4_pnfs_ds_put(ds);
5656
}
5757
kfree(dsaddr->stripe_indices);
58-
kfree(dsaddr);
58+
kfree_rcu(dsaddr, id_node.rcu);
5959
}
6060

6161
/* Decode opaque device data and return the result */

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#include <linux/module.h>
1212

1313
#include <linux/sunrpc/metrics.h>
14-
#include <linux/nfs_idmap.h>
1514

1615
#include "flexfilelayout.h"
1716
#include "../nfs4session.h"
17+
#include "../nfs4idmap.h"
1818
#include "../internal.h"
1919
#include "../delegation.h"
2020
#include "../nfs4trace.h"
@@ -891,7 +891,8 @@ static int ff_layout_read_done_cb(struct rpc_task *task,
891891
static void
892892
ff_layout_set_layoutcommit(struct nfs_pgio_header *hdr)
893893
{
894-
pnfs_set_layoutcommit(hdr);
894+
pnfs_set_layoutcommit(hdr->inode, hdr->lseg,
895+
hdr->mds_offset + hdr->res.count);
895896
dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino,
896897
(unsigned long) NFS_I(hdr->inode)->layout->plh_lwb);
897898
}
@@ -1074,7 +1075,7 @@ static int ff_layout_commit_done_cb(struct rpc_task *task,
10741075
}
10751076

10761077
if (data->verf.committed == NFS_UNSTABLE)
1077-
pnfs_commit_set_layoutcommit(data);
1078+
pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb);
10781079

10791080
return 0;
10801081
}
@@ -1414,7 +1415,7 @@ ff_layout_get_ds_info(struct inode *inode)
14141415
}
14151416

14161417
static void
1417-
ff_layout_free_deveiceid_node(struct nfs4_deviceid_node *d)
1418+
ff_layout_free_deviceid_node(struct nfs4_deviceid_node *d)
14181419
{
14191420
nfs4_ff_layout_free_deviceid(container_of(d, struct nfs4_ff_layout_ds,
14201421
id_node));
@@ -1498,7 +1499,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = {
14981499
.pg_read_ops = &ff_layout_pg_read_ops,
14991500
.pg_write_ops = &ff_layout_pg_write_ops,
15001501
.get_ds_info = ff_layout_get_ds_info,
1501-
.free_deviceid_node = ff_layout_free_deveiceid_node,
1502+
.free_deviceid_node = ff_layout_free_deviceid_node,
15021503
.mark_request_commit = pnfs_layout_mark_request_commit,
15031504
.clear_request_commit = pnfs_generic_clear_request_commit,
15041505
.scan_commit_lists = pnfs_generic_scan_commit_lists,
@@ -1508,6 +1509,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = {
15081509
.write_pagelist = ff_layout_write_pagelist,
15091510
.alloc_deviceid_node = ff_layout_alloc_deviceid_node,
15101511
.encode_layoutreturn = ff_layout_encode_layoutreturn,
1512+
.sync = pnfs_nfs_generic_sync,
15111513
};
15121514

15131515
static int __init nfs4flexfilelayout_init(void)

fs/nfs/flexfilelayout/flexfilelayoutdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void nfs4_ff_layout_free_deviceid(struct nfs4_ff_layout_ds *mirror_ds)
3030
{
3131
nfs4_print_deviceid(&mirror_ds->id_node.deviceid);
3232
nfs4_pnfs_ds_put(mirror_ds->ds);
33-
kfree(mirror_ds);
33+
kfree_rcu(mirror_ds, id_node.rcu);
3434
}
3535

3636
/* Decode opaque device data and construct new_ds using it */

fs/nfs/inode.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ void nfs_evict_inode(struct inode *inode)
133133
nfs_clear_inode(inode);
134134
}
135135

136+
int nfs_sync_inode(struct inode *inode)
137+
{
138+
nfs_inode_dio_wait(inode);
139+
return nfs_wb_all(inode);
140+
}
141+
EXPORT_SYMBOL_GPL(nfs_sync_inode);
142+
136143
/**
137144
* nfs_sync_mapping - helper to flush all mmapped dirty data to disk
138145
*/
@@ -192,7 +199,6 @@ void nfs_zap_caches(struct inode *inode)
192199
nfs_zap_caches_locked(inode);
193200
spin_unlock(&inode->i_lock);
194201
}
195-
EXPORT_SYMBOL_GPL(nfs_zap_caches);
196202

197203
void nfs_zap_mapping(struct inode *inode, struct address_space *mapping)
198204
{
@@ -525,10 +531,8 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
525531
trace_nfs_setattr_enter(inode);
526532

527533
/* Write all dirty data */
528-
if (S_ISREG(inode->i_mode)) {
529-
nfs_inode_dio_wait(inode);
530-
nfs_wb_all(inode);
531-
}
534+
if (S_ISREG(inode->i_mode))
535+
nfs_sync_inode(inode);
532536

533537
fattr = nfs_alloc_fattr();
534538
if (fattr == NULL)
@@ -644,8 +648,9 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
644648
trace_nfs_getattr_enter(inode);
645649
/* Flush out writes to the server in order to update c/mtime. */
646650
if (S_ISREG(inode->i_mode)) {
647-
nfs_inode_dio_wait(inode);
648-
err = filemap_write_and_wait(inode->i_mapping);
651+
mutex_lock(&inode->i_mutex);
652+
err = nfs_sync_inode(inode);
653+
mutex_unlock(&inode->i_mutex);
649654
if (err)
650655
goto out;
651656
}
@@ -1588,6 +1593,19 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa
15881593
}
15891594
EXPORT_SYMBOL_GPL(nfs_post_op_update_inode_force_wcc);
15901595

1596+
1597+
static inline bool nfs_fileid_valid(struct nfs_inode *nfsi,
1598+
struct nfs_fattr *fattr)
1599+
{
1600+
bool ret1 = true, ret2 = true;
1601+
1602+
if (fattr->valid & NFS_ATTR_FATTR_FILEID)
1603+
ret1 = (nfsi->fileid == fattr->fileid);
1604+
if (fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
1605+
ret2 = (nfsi->fileid == fattr->mounted_on_fileid);
1606+
return ret1 || ret2;
1607+
}
1608+
15911609
/*
15921610
* Many nfs protocol calls return the new file attributes after
15931611
* an operation. Here we update the inode to reflect the state
@@ -1614,7 +1632,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
16141632
nfs_display_fhandle_hash(NFS_FH(inode)),
16151633
atomic_read(&inode->i_count), fattr->valid);
16161634

1617-
if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid) {
1635+
if (!nfs_fileid_valid(nfsi, fattr)) {
16181636
printk(KERN_ERR "NFS: server %s error: fileid changed\n"
16191637
"fsid %s: expected fileid 0x%Lx, got 0x%Lx\n",
16201638
NFS_SERVER(inode)->nfs_client->cl_hostname,
@@ -1819,7 +1837,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
18191837
struct inode *nfs_alloc_inode(struct super_block *sb)
18201838
{
18211839
struct nfs_inode *nfsi;
1822-
nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, GFP_KERNEL);
1840+
nfsi = kmem_cache_alloc(nfs_inode_cachep, GFP_KERNEL);
18231841
if (!nfsi)
18241842
return NULL;
18251843
nfsi->flags = 0UL;

0 commit comments

Comments
 (0)