Skip to content

Commit 763008c

Browse files
committed
Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
* 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6: NFS: Fix an Oops in the NFSv4 atomic open code NFS: Fix the selection of security flavours in Kconfig NFS: fix the return value of nfs_file_fsync() rpcrdma: Fix SQ size calculation when memreg is FRMR xprtrdma: Do not truncate iova_start values in frmr registrations. nfs: Remove redundant NULL check upon kfree() nfs: Add "lookupcache" to displayed mount options NFS: allow close-to-open cache semantics to apply to root of NFS filesystem SUNRPC: fix NFS client over TCP hangs due to packet loss (Bug 16494)
2 parents d1126ad + 0a377cf commit 763008c

10 files changed

Lines changed: 68 additions & 24 deletions

File tree

‎fs/nfs/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ config NFS_V3_ACL
6363
config NFS_V4
6464
bool "NFS client support for NFS version 4"
6565
depends on NFS_FS
66-
select RPCSEC_GSS_KRB5
6766
help
6867
This option enables support for version 4 of the NFS protocol
6968
(RFC 3530) in the kernel's NFS client.

‎fs/nfs/dir.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ nfs_opendir(struct inode *inode, struct file *filp)
140140

141141
/* Call generic open code in order to cache credentials */
142142
res = nfs_open(inode, filp);
143+
if (filp->f_path.dentry == filp->f_path.mnt->mnt_root) {
144+
/* This is a mountpoint, so d_revalidate will never
145+
* have been called, so we need to refresh the
146+
* inode (for close-open consistency) ourselves.
147+
*/
148+
__nfs_revalidate_inode(NFS_SERVER(inode), inode);
149+
}
143150
return res;
144151
}
145152

@@ -1103,7 +1110,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
11031110
if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
11041111
goto no_open_dput;
11051112
/* We can't create new files, or truncate existing ones here */
1106-
openflags &= ~(O_CREAT|O_TRUNC);
1113+
openflags &= ~(O_CREAT|O_EXCL|O_TRUNC);
11071114

11081115
/*
11091116
* Note: we're not holding inode->i_mutex and so may be racing with

‎fs/nfs/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ nfs_file_fsync(struct file *file, int datasync)
323323
have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
324324
if (have_error)
325325
ret = xchg(&ctx->error, 0);
326-
if (!ret)
326+
if (!ret && status < 0)
327327
ret = status;
328328
return ret;
329329
}

‎fs/nfs/nfs4proc.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,16 +2036,18 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
20362036
struct rpc_cred *cred;
20372037
struct nfs4_state *state;
20382038
struct dentry *res;
2039-
fmode_t fmode = nd->intent.open.flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC);
2039+
int open_flags = nd->intent.open.flags;
2040+
fmode_t fmode = open_flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC);
20402041

20412042
if (nd->flags & LOOKUP_CREATE) {
20422043
attr.ia_mode = nd->intent.open.create_mode;
20432044
attr.ia_valid = ATTR_MODE;
20442045
if (!IS_POSIXACL(dir))
20452046
attr.ia_mode &= ~current_umask();
20462047
} else {
2048+
open_flags &= ~O_EXCL;
20472049
attr.ia_valid = 0;
2048-
BUG_ON(nd->intent.open.flags & O_CREAT);
2050+
BUG_ON(open_flags & O_CREAT);
20492051
}
20502052

20512053
cred = rpc_lookup_cred();
@@ -2054,7 +2056,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
20542056
parent = dentry->d_parent;
20552057
/* Protect against concurrent sillydeletes */
20562058
nfs_block_sillyrename(parent);
2057-
state = nfs4_do_open(dir, &path, fmode, nd->intent.open.flags, &attr, cred);
2059+
state = nfs4_do_open(dir, &path, fmode, open_flags, &attr, cred);
20582060
put_rpccred(cred);
20592061
if (IS_ERR(state)) {
20602062
if (PTR_ERR(state) == -ENOENT) {
@@ -2273,8 +2275,7 @@ static int nfs4_get_referral(struct inode *dir, const struct qstr *name, struct
22732275
out:
22742276
if (page)
22752277
__free_page(page);
2276-
if (locations)
2277-
kfree(locations);
2278+
kfree(locations);
22782279
return status;
22792280
}
22802281

‎fs/nfs/super.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,13 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
655655

656656
if (nfss->options & NFS_OPTION_FSCACHE)
657657
seq_printf(m, ",fsc");
658+
659+
if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) {
660+
if (nfss->flags & NFS_MOUNT_LOOKUP_CACHE_NONE)
661+
seq_printf(m, ",lookupcache=none");
662+
else
663+
seq_printf(m, ",lookupcache=pos");
664+
}
658665
}
659666

660667
/*

‎fs/nfsd/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ config NFSD_V4
6969
depends on NFSD && PROC_FS && EXPERIMENTAL
7070
select NFSD_V3
7171
select FS_POSIX_ACL
72-
select RPCSEC_GSS_KRB5
7372
help
7473
This option enables support in your system's NFS server for
7574
version 4 of the NFS protocol (RFC 3530).

‎net/sunrpc/Kconfig‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ config SUNRPC_XPRT_RDMA
1818
If unsure, say N.
1919

2020
config RPCSEC_GSS_KRB5
21-
tristate "Secure RPC: Kerberos V mechanism (EXPERIMENTAL)"
22-
depends on SUNRPC && EXPERIMENTAL
21+
tristate
22+
depends on SUNRPC && CRYPTO
23+
prompt "Secure RPC: Kerberos V mechanism" if !(NFS_V4 || NFSD_V4)
24+
default y
2325
select SUNRPC_GSS
24-
select CRYPTO
2526
select CRYPTO_MD5
2627
select CRYPTO_DES
2728
select CRYPTO_CBC
@@ -34,7 +35,7 @@ config RPCSEC_GSS_KRB5
3435
available from http://linux-nfs.org/. In addition, user-space
3536
Kerberos support should be installed.
3637

37-
If unsure, say N.
38+
If unsure, say Y.
3839

3940
config RPCSEC_GSS_SPKM3
4041
tristate "Secure RPC: SPKM3 mechanism (EXPERIMENTAL)"

‎net/sunrpc/xprtrdma/rpc_rdma.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target,
249249
req->rl_nchunks = nchunks;
250250

251251
BUG_ON(nchunks == 0);
252+
BUG_ON((r_xprt->rx_ia.ri_memreg_strategy == RPCRDMA_FRMR)
253+
&& (nchunks > 3));
252254

253255
/*
254256
* finish off header. If write, marshal discrim and nchunks.

‎net/sunrpc/xprtrdma/verbs.c‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,22 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
650650
ep->rep_attr.cap.max_send_wr = cdata->max_requests;
651651
switch (ia->ri_memreg_strategy) {
652652
case RPCRDMA_FRMR:
653-
/* Add room for frmr register and invalidate WRs */
654-
ep->rep_attr.cap.max_send_wr *= 3;
655-
if (ep->rep_attr.cap.max_send_wr > devattr.max_qp_wr)
656-
return -EINVAL;
653+
/* Add room for frmr register and invalidate WRs.
654+
* 1. FRMR reg WR for head
655+
* 2. FRMR invalidate WR for head
656+
* 3. FRMR reg WR for pagelist
657+
* 4. FRMR invalidate WR for pagelist
658+
* 5. FRMR reg WR for tail
659+
* 6. FRMR invalidate WR for tail
660+
* 7. The RDMA_SEND WR
661+
*/
662+
ep->rep_attr.cap.max_send_wr *= 7;
663+
if (ep->rep_attr.cap.max_send_wr > devattr.max_qp_wr) {
664+
cdata->max_requests = devattr.max_qp_wr / 7;
665+
if (!cdata->max_requests)
666+
return -EINVAL;
667+
ep->rep_attr.cap.max_send_wr = cdata->max_requests * 7;
668+
}
657669
break;
658670
case RPCRDMA_MEMWINDOWS_ASYNC:
659671
case RPCRDMA_MEMWINDOWS:
@@ -1490,7 +1502,7 @@ rpcrdma_register_frmr_external(struct rpcrdma_mr_seg *seg,
14901502
memset(&frmr_wr, 0, sizeof frmr_wr);
14911503
frmr_wr.opcode = IB_WR_FAST_REG_MR;
14921504
frmr_wr.send_flags = 0; /* unsignaled */
1493-
frmr_wr.wr.fast_reg.iova_start = (unsigned long)seg1->mr_dma;
1505+
frmr_wr.wr.fast_reg.iova_start = seg1->mr_dma;
14941506
frmr_wr.wr.fast_reg.page_list = seg1->mr_chunk.rl_mw->r.frmr.fr_pgl;
14951507
frmr_wr.wr.fast_reg.page_list_len = i;
14961508
frmr_wr.wr.fast_reg.page_shift = PAGE_SHIFT;

‎net/sunrpc/xprtsock.c‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,11 @@ static void xs_tcp_state_change(struct sock *sk)
13051305
if (!(xprt = xprt_from_sock(sk)))
13061306
goto out;
13071307
dprintk("RPC: xs_tcp_state_change client %p...\n", xprt);
1308-
dprintk("RPC: state %x conn %d dead %d zapped %d\n",
1308+
dprintk("RPC: state %x conn %d dead %d zapped %d sk_shutdown %d\n",
13091309
sk->sk_state, xprt_connected(xprt),
13101310
sock_flag(sk, SOCK_DEAD),
1311-
sock_flag(sk, SOCK_ZAPPED));
1311+
sock_flag(sk, SOCK_ZAPPED),
1312+
sk->sk_shutdown);
13121313

13131314
switch (sk->sk_state) {
13141315
case TCP_ESTABLISHED:
@@ -1779,10 +1780,25 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt, struct sock_xprt *tra
17791780
{
17801781
unsigned int state = transport->inet->sk_state;
17811782

1782-
if (state == TCP_CLOSE && transport->sock->state == SS_UNCONNECTED)
1783-
return;
1784-
if ((1 << state) & (TCPF_ESTABLISHED|TCPF_SYN_SENT))
1785-
return;
1783+
if (state == TCP_CLOSE && transport->sock->state == SS_UNCONNECTED) {
1784+
/* we don't need to abort the connection if the socket
1785+
* hasn't undergone a shutdown
1786+
*/
1787+
if (transport->inet->sk_shutdown == 0)
1788+
return;
1789+
dprintk("RPC: %s: TCP_CLOSEd and sk_shutdown set to %d\n",
1790+
__func__, transport->inet->sk_shutdown);
1791+
}
1792+
if ((1 << state) & (TCPF_ESTABLISHED|TCPF_SYN_SENT)) {
1793+
/* we don't need to abort the connection if the socket
1794+
* hasn't undergone a shutdown
1795+
*/
1796+
if (transport->inet->sk_shutdown == 0)
1797+
return;
1798+
dprintk("RPC: %s: ESTABLISHED/SYN_SENT "
1799+
"sk_shutdown set to %d\n",
1800+
__func__, transport->inet->sk_shutdown);
1801+
}
17861802
xs_abort_connection(xprt, transport);
17871803
}
17881804

0 commit comments

Comments
 (0)