Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'nfs-for-2.6.40' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6

* 'nfs-for-2.6.40' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6:
SUNRPC: Support for RPC over AF_LOCAL transports
SUNRPC: Remove obsolete comment
SUNRPC: Use AF_LOCAL for rpcbind upcalls
SUNRPC: Clean up use of curly braces in switch cases
NFS: Revert NFSROOT default mount options
SUNRPC: Rename xs_encode_tcp_fragment_header()
nfs,rcu: convert call_rcu(nfs_free_delegation_callback) to kfree_rcu()
nfs41: Correct offset for LAYOUTCOMMIT
NFS: nfs_update_inode: print current and new inode size in debug output
NFSv4.1: Fix the handling of NFS4ERR_SEQ_MISORDERED errors
NFSv4: Handle expired stateids when the lease is still valid
SUNRPC: Deal with the lack of a SYN_SENT sk->sk_state_change callback...

+542 -66
+1 -13
fs/nfs/delegation.c
··· 21 21 #include "delegation.h" 22 22 #include "internal.h" 23 23 24 - static void nfs_do_free_delegation(struct nfs_delegation *delegation) 25 - { 26 - kfree(delegation); 27 - } 28 - 29 - static void nfs_free_delegation_callback(struct rcu_head *head) 30 - { 31 - struct nfs_delegation *delegation = container_of(head, struct nfs_delegation, rcu); 32 - 33 - nfs_do_free_delegation(delegation); 34 - } 35 - 36 24 static void nfs_free_delegation(struct nfs_delegation *delegation) 37 25 { 38 26 if (delegation->cred) { 39 27 put_rpccred(delegation->cred); 40 28 delegation->cred = NULL; 41 29 } 42 - call_rcu(&delegation->rcu, nfs_free_delegation_callback); 30 + kfree_rcu(delegation, rcu); 43 31 } 44 32 45 33 /**
+6 -2
fs/nfs/inode.c
··· 1298 1298 i_size_write(inode, new_isize); 1299 1299 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; 1300 1300 } 1301 - dprintk("NFS: isize change on server for file %s/%ld\n", 1302 - inode->i_sb->s_id, inode->i_ino); 1301 + dprintk("NFS: isize change on server for file %s/%ld " 1302 + "(%Ld to %Ld)\n", 1303 + inode->i_sb->s_id, 1304 + inode->i_ino, 1305 + (long long)cur_isize, 1306 + (long long)new_isize); 1303 1307 } 1304 1308 } else 1305 1309 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
+7 -2
fs/nfs/nfs4proc.c
··· 267 267 break; 268 268 nfs4_schedule_stateid_recovery(server, state); 269 269 goto wait_on_recovery; 270 + case -NFS4ERR_EXPIRED: 271 + if (state != NULL) 272 + nfs4_schedule_stateid_recovery(server, state); 270 273 case -NFS4ERR_STALE_STATEID: 271 274 case -NFS4ERR_STALE_CLIENTID: 272 - case -NFS4ERR_EXPIRED: 273 275 nfs4_schedule_lease_recovery(clp); 274 276 goto wait_on_recovery; 275 277 #if defined(CONFIG_NFS_V4_1) ··· 3672 3670 break; 3673 3671 nfs4_schedule_stateid_recovery(server, state); 3674 3672 goto wait_on_recovery; 3673 + case -NFS4ERR_EXPIRED: 3674 + if (state != NULL) 3675 + nfs4_schedule_stateid_recovery(server, state); 3675 3676 case -NFS4ERR_STALE_STATEID: 3676 3677 case -NFS4ERR_STALE_CLIENTID: 3677 - case -NFS4ERR_EXPIRED: 3678 3678 nfs4_schedule_lease_recovery(clp); 3679 3679 goto wait_on_recovery; 3680 3680 #if defined(CONFIG_NFS_V4_1) ··· 4547 4543 case -ESTALE: 4548 4544 goto out; 4549 4545 case -NFS4ERR_EXPIRED: 4546 + nfs4_schedule_stateid_recovery(server, state); 4550 4547 case -NFS4ERR_STALE_CLIENTID: 4551 4548 case -NFS4ERR_STALE_STATEID: 4552 4549 nfs4_schedule_lease_recovery(server->nfs_client);
+5 -1
fs/nfs/nfs4state.c
··· 1466 1466 #ifdef CONFIG_NFS_V4_1 1467 1467 void nfs4_schedule_session_recovery(struct nfs4_session *session) 1468 1468 { 1469 - nfs4_schedule_lease_recovery(session->clp); 1469 + struct nfs_client *clp = session->clp; 1470 + 1471 + set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); 1472 + nfs4_schedule_lease_recovery(clp); 1470 1473 } 1471 1474 EXPORT_SYMBOL_GPL(nfs4_schedule_session_recovery); 1472 1475 ··· 1552 1549 status = nfs4_recovery_handle_error(clp, status); 1553 1550 goto out; 1554 1551 } 1552 + clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); 1555 1553 /* create_session negotiated new slot table */ 1556 1554 clear_bit(NFS4CLNT_RECALL_SLOT, &clp->cl_state); 1557 1555
+1 -1
fs/nfs/nfsroot.c
··· 87 87 #define NFS_ROOT "/tftpboot/%s" 88 88 89 89 /* Default NFSROOT mount options. */ 90 - #define NFS_DEF_OPTIONS "udp" 90 + #define NFS_DEF_OPTIONS "vers=2,udp,rsize=4096,wsize=4096" 91 91 92 92 /* Parameters passed from the kernel command line */ 93 93 static char nfs_root_parms[256] __initdata = "";
+1 -1
fs/nfs/pnfs.c
··· 1009 1009 pnfs_set_layoutcommit(struct nfs_write_data *wdata) 1010 1010 { 1011 1011 struct nfs_inode *nfsi = NFS_I(wdata->inode); 1012 - loff_t end_pos = wdata->args.offset + wdata->res.count; 1012 + loff_t end_pos = wdata->mds_offset + wdata->res.count; 1013 1013 bool mark_as_dirty = false; 1014 1014 1015 1015 spin_lock(&nfsi->vfs_inode.i_lock);
+1
include/linux/sunrpc/msg_prot.h
··· 145 145 #define RPCBIND_NETID_TCP "tcp" 146 146 #define RPCBIND_NETID_UDP6 "udp6" 147 147 #define RPCBIND_NETID_TCP6 "tcp6" 148 + #define RPCBIND_NETID_LOCAL "local" 148 149 149 150 /* 150 151 * Note that RFC 1833 does not put any size restrictions on the
+2 -1
include/linux/sunrpc/xprt.h
··· 141 141 XPRT_TRANSPORT_UDP = IPPROTO_UDP, 142 142 XPRT_TRANSPORT_TCP = IPPROTO_TCP, 143 143 XPRT_TRANSPORT_BC_TCP = IPPROTO_TCP | XPRT_TRANSPORT_BC, 144 - XPRT_TRANSPORT_RDMA = 256 144 + XPRT_TRANSPORT_RDMA = 256, 145 + XPRT_TRANSPORT_LOCAL = 257, 145 146 }; 146 147 147 148 struct rpc_xprt {
+16 -13
net/sunrpc/clnt.c
··· 13 13 * and need to be refreshed, or when a packet was damaged in transit. 14 14 * This may be have to be moved to the VFS layer. 15 15 * 16 - * NB: BSD uses a more intelligent approach to guessing when a request 17 - * or reply has been lost by keeping the RTO estimate for each procedure. 18 - * We currently make do with a constant timeout value. 19 - * 20 16 * Copyright (C) 1992,1993 Rick Sladkey <jrs@world.std.com> 21 17 * Copyright (C) 1995,1996 Olaf Kirch <okir@monad.swb.de> 22 18 */ ··· 28 32 #include <linux/slab.h> 29 33 #include <linux/utsname.h> 30 34 #include <linux/workqueue.h> 35 + #include <linux/in.h> 31 36 #include <linux/in6.h> 37 + #include <linux/un.h> 32 38 33 39 #include <linux/sunrpc/clnt.h> 34 40 #include <linux/sunrpc/rpc_pipe_fs.h> ··· 296 298 * up a string representation of the passed-in address. 297 299 */ 298 300 if (args->servername == NULL) { 301 + struct sockaddr_un *sun = 302 + (struct sockaddr_un *)args->address; 303 + struct sockaddr_in *sin = 304 + (struct sockaddr_in *)args->address; 305 + struct sockaddr_in6 *sin6 = 306 + (struct sockaddr_in6 *)args->address; 307 + 299 308 servername[0] = '\0'; 300 309 switch (args->address->sa_family) { 301 - case AF_INET: { 302 - struct sockaddr_in *sin = 303 - (struct sockaddr_in *)args->address; 310 + case AF_LOCAL: 311 + snprintf(servername, sizeof(servername), "%s", 312 + sun->sun_path); 313 + break; 314 + case AF_INET: 304 315 snprintf(servername, sizeof(servername), "%pI4", 305 316 &sin->sin_addr.s_addr); 306 317 break; 307 - } 308 - case AF_INET6: { 309 - struct sockaddr_in6 *sin = 310 - (struct sockaddr_in6 *)args->address; 318 + case AF_INET6: 311 319 snprintf(servername, sizeof(servername), "%pI6", 312 - &sin->sin6_addr); 320 + &sin6->sin6_addr); 313 321 break; 314 - } 315 322 default: 316 323 /* caller wants default server name, but 317 324 * address family isn't recognized. */
+83 -14
net/sunrpc/rpcb_clnt.c
··· 16 16 17 17 #include <linux/types.h> 18 18 #include <linux/socket.h> 19 + #include <linux/un.h> 19 20 #include <linux/in.h> 20 21 #include <linux/in6.h> 21 22 #include <linux/kernel.h> ··· 32 31 #ifdef RPC_DEBUG 33 32 # define RPCDBG_FACILITY RPCDBG_BIND 34 33 #endif 34 + 35 + #define RPCBIND_SOCK_PATHNAME "/var/run/rpcbind.sock" 35 36 36 37 #define RPCBIND_PROGRAM (100000u) 37 38 #define RPCBIND_PORT (111u) ··· 161 158 kfree(map); 162 159 } 163 160 164 - static const struct sockaddr_in rpcb_inaddr_loopback = { 165 - .sin_family = AF_INET, 166 - .sin_addr.s_addr = htonl(INADDR_LOOPBACK), 167 - .sin_port = htons(RPCBIND_PORT), 168 - }; 161 + /* 162 + * Returns zero on success, otherwise a negative errno value 163 + * is returned. 164 + */ 165 + static int rpcb_create_local_unix(void) 166 + { 167 + static const struct sockaddr_un rpcb_localaddr_rpcbind = { 168 + .sun_family = AF_LOCAL, 169 + .sun_path = RPCBIND_SOCK_PATHNAME, 170 + }; 171 + struct rpc_create_args args = { 172 + .net = &init_net, 173 + .protocol = XPRT_TRANSPORT_LOCAL, 174 + .address = (struct sockaddr *)&rpcb_localaddr_rpcbind, 175 + .addrsize = sizeof(rpcb_localaddr_rpcbind), 176 + .servername = "localhost", 177 + .program = &rpcb_program, 178 + .version = RPCBVERS_2, 179 + .authflavor = RPC_AUTH_NULL, 180 + }; 181 + struct rpc_clnt *clnt, *clnt4; 182 + int result = 0; 169 183 170 - static DEFINE_MUTEX(rpcb_create_local_mutex); 184 + /* 185 + * Because we requested an RPC PING at transport creation time, 186 + * this works only if the user space portmapper is rpcbind, and 187 + * it's listening on AF_LOCAL on the named socket. 188 + */ 189 + clnt = rpc_create(&args); 190 + if (IS_ERR(clnt)) { 191 + dprintk("RPC: failed to create AF_LOCAL rpcbind " 192 + "client (errno %ld).\n", PTR_ERR(clnt)); 193 + result = -PTR_ERR(clnt); 194 + goto out; 195 + } 196 + 197 + clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4); 198 + if (IS_ERR(clnt4)) { 199 + dprintk("RPC: failed to bind second program to " 200 + "rpcbind v4 client (errno %ld).\n", 201 + PTR_ERR(clnt4)); 202 + clnt4 = NULL; 203 + } 204 + 205 + /* Protected by rpcb_create_local_mutex */ 206 + rpcb_local_clnt = clnt; 207 + rpcb_local_clnt4 = clnt4; 208 + 209 + out: 210 + return result; 211 + } 171 212 172 213 /* 173 214 * Returns zero on success, otherwise a negative errno value 174 215 * is returned. 175 216 */ 176 - static int rpcb_create_local(void) 217 + static int rpcb_create_local_net(void) 177 218 { 219 + static const struct sockaddr_in rpcb_inaddr_loopback = { 220 + .sin_family = AF_INET, 221 + .sin_addr.s_addr = htonl(INADDR_LOOPBACK), 222 + .sin_port = htons(RPCBIND_PORT), 223 + }; 178 224 struct rpc_create_args args = { 179 225 .net = &init_net, 180 226 .protocol = XPRT_TRANSPORT_TCP, ··· 237 185 }; 238 186 struct rpc_clnt *clnt, *clnt4; 239 187 int result = 0; 240 - 241 - if (rpcb_local_clnt) 242 - return result; 243 - 244 - mutex_lock(&rpcb_create_local_mutex); 245 - if (rpcb_local_clnt) 246 - goto out; 247 188 248 189 clnt = rpc_create(&args); 249 190 if (IS_ERR(clnt)) { ··· 259 214 clnt4 = NULL; 260 215 } 261 216 217 + /* Protected by rpcb_create_local_mutex */ 262 218 rpcb_local_clnt = clnt; 263 219 rpcb_local_clnt4 = clnt4; 220 + 221 + out: 222 + return result; 223 + } 224 + 225 + /* 226 + * Returns zero on success, otherwise a negative errno value 227 + * is returned. 228 + */ 229 + static int rpcb_create_local(void) 230 + { 231 + static DEFINE_MUTEX(rpcb_create_local_mutex); 232 + int result = 0; 233 + 234 + if (rpcb_local_clnt) 235 + return result; 236 + 237 + mutex_lock(&rpcb_create_local_mutex); 238 + if (rpcb_local_clnt) 239 + goto out; 240 + 241 + if (rpcb_create_local_unix() != 0) 242 + result = rpcb_create_local_net(); 264 243 265 244 out: 266 245 mutex_unlock(&rpcb_create_local_mutex);
+2
net/sunrpc/svc.c
··· 942 942 if (progp->pg_vers[i]->vs_hidden) 943 943 continue; 944 944 945 + dprintk("svc: attempting to unregister %sv%u\n", 946 + progp->pg_name, i); 945 947 __svc_unregister(progp->pg_prog, i, progp->pg_name); 946 948 } 947 949 }
+417 -18
net/sunrpc/xprtsock.c
··· 19 19 */ 20 20 21 21 #include <linux/types.h> 22 + #include <linux/string.h> 22 23 #include <linux/slab.h> 23 24 #include <linux/module.h> 24 25 #include <linux/capability.h> ··· 29 28 #include <linux/in.h> 30 29 #include <linux/net.h> 31 30 #include <linux/mm.h> 31 + #include <linux/un.h> 32 32 #include <linux/udp.h> 33 33 #include <linux/tcp.h> 34 34 #include <linux/sunrpc/clnt.h> ··· 47 45 #include <net/tcp.h> 48 46 49 47 #include "sunrpc.h" 48 + 49 + static void xs_close(struct rpc_xprt *xprt); 50 + 50 51 /* 51 52 * xprtsock tunables 52 53 */ ··· 266 261 return (struct sockaddr *) &xprt->addr; 267 262 } 268 263 264 + static inline struct sockaddr_un *xs_addr_un(struct rpc_xprt *xprt) 265 + { 266 + return (struct sockaddr_un *) &xprt->addr; 267 + } 268 + 269 269 static inline struct sockaddr_in *xs_addr_in(struct rpc_xprt *xprt) 270 270 { 271 271 return (struct sockaddr_in *) &xprt->addr; ··· 286 276 struct sockaddr *sap = xs_addr(xprt); 287 277 struct sockaddr_in6 *sin6; 288 278 struct sockaddr_in *sin; 279 + struct sockaddr_un *sun; 289 280 char buf[128]; 290 281 291 - (void)rpc_ntop(sap, buf, sizeof(buf)); 292 - xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL); 293 - 294 282 switch (sap->sa_family) { 283 + case AF_LOCAL: 284 + sun = xs_addr_un(xprt); 285 + strlcpy(buf, sun->sun_path, sizeof(buf)); 286 + xprt->address_strings[RPC_DISPLAY_ADDR] = 287 + kstrdup(buf, GFP_KERNEL); 288 + break; 295 289 case AF_INET: 290 + (void)rpc_ntop(sap, buf, sizeof(buf)); 291 + xprt->address_strings[RPC_DISPLAY_ADDR] = 292 + kstrdup(buf, GFP_KERNEL); 296 293 sin = xs_addr_in(xprt); 297 294 snprintf(buf, sizeof(buf), "%08x", ntohl(sin->sin_addr.s_addr)); 298 295 break; 299 296 case AF_INET6: 297 + (void)rpc_ntop(sap, buf, sizeof(buf)); 298 + xprt->address_strings[RPC_DISPLAY_ADDR] = 299 + kstrdup(buf, GFP_KERNEL); 300 300 sin6 = xs_addr_in6(xprt); 301 301 snprintf(buf, sizeof(buf), "%pi6", &sin6->sin6_addr); 302 302 break; 303 303 default: 304 304 BUG(); 305 305 } 306 + 306 307 xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL); 307 308 } 308 309 ··· 516 495 return ret; 517 496 } 518 497 498 + /* 499 + * Construct a stream transport record marker in @buf. 500 + */ 501 + static inline void xs_encode_stream_record_marker(struct xdr_buf *buf) 502 + { 503 + u32 reclen = buf->len - sizeof(rpc_fraghdr); 504 + rpc_fraghdr *base = buf->head[0].iov_base; 505 + *base = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | reclen); 506 + } 507 + 508 + /** 509 + * xs_local_send_request - write an RPC request to an AF_LOCAL socket 510 + * @task: RPC task that manages the state of an RPC request 511 + * 512 + * Return values: 513 + * 0: The request has been sent 514 + * EAGAIN: The socket was blocked, please call again later to 515 + * complete the request 516 + * ENOTCONN: Caller needs to invoke connect logic then call again 517 + * other: Some other error occured, the request was not sent 518 + */ 519 + static int xs_local_send_request(struct rpc_task *task) 520 + { 521 + struct rpc_rqst *req = task->tk_rqstp; 522 + struct rpc_xprt *xprt = req->rq_xprt; 523 + struct sock_xprt *transport = 524 + container_of(xprt, struct sock_xprt, xprt); 525 + struct xdr_buf *xdr = &req->rq_snd_buf; 526 + int status; 527 + 528 + xs_encode_stream_record_marker(&req->rq_snd_buf); 529 + 530 + xs_pktdump("packet data:", 531 + req->rq_svec->iov_base, req->rq_svec->iov_len); 532 + 533 + status = xs_sendpages(transport->sock, NULL, 0, 534 + xdr, req->rq_bytes_sent); 535 + dprintk("RPC: %s(%u) = %d\n", 536 + __func__, xdr->len - req->rq_bytes_sent, status); 537 + if (likely(status >= 0)) { 538 + req->rq_bytes_sent += status; 539 + req->rq_xmit_bytes_sent += status; 540 + if (likely(req->rq_bytes_sent >= req->rq_slen)) { 541 + req->rq_bytes_sent = 0; 542 + return 0; 543 + } 544 + status = -EAGAIN; 545 + } 546 + 547 + switch (status) { 548 + case -EAGAIN: 549 + status = xs_nospace(task); 550 + break; 551 + default: 552 + dprintk("RPC: sendmsg returned unrecognized error %d\n", 553 + -status); 554 + case -EPIPE: 555 + xs_close(xprt); 556 + status = -ENOTCONN; 557 + } 558 + 559 + return status; 560 + } 561 + 519 562 /** 520 563 * xs_udp_send_request - write an RPC request to a UDP socket 521 564 * @task: address of RPC task that manages the state of an RPC request ··· 659 574 kernel_sock_shutdown(sock, SHUT_WR); 660 575 } 661 576 662 - static inline void xs_encode_tcp_record_marker(struct xdr_buf *buf) 663 - { 664 - u32 reclen = buf->len - sizeof(rpc_fraghdr); 665 - rpc_fraghdr *base = buf->head[0].iov_base; 666 - *base = htonl(RPC_LAST_STREAM_FRAGMENT | reclen); 667 - } 668 - 669 577 /** 670 578 * xs_tcp_send_request - write an RPC request to a TCP socket 671 579 * @task: address of RPC task that manages the state of an RPC request ··· 681 603 struct xdr_buf *xdr = &req->rq_snd_buf; 682 604 int status; 683 605 684 - xs_encode_tcp_record_marker(&req->rq_snd_buf); 606 + xs_encode_stream_record_marker(&req->rq_snd_buf); 685 607 686 608 xs_pktdump("packet data:", 687 609 req->rq_svec->iov_base, ··· 861 783 static inline struct rpc_xprt *xprt_from_sock(struct sock *sk) 862 784 { 863 785 return (struct rpc_xprt *) sk->sk_user_data; 786 + } 787 + 788 + static int xs_local_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb) 789 + { 790 + struct xdr_skb_reader desc = { 791 + .skb = skb, 792 + .offset = sizeof(rpc_fraghdr), 793 + .count = skb->len - sizeof(rpc_fraghdr), 794 + }; 795 + 796 + if (xdr_partial_copy_from_skb(xdr, 0, &desc, xdr_skb_read_bits) < 0) 797 + return -1; 798 + if (desc.count) 799 + return -1; 800 + return 0; 801 + } 802 + 803 + /** 804 + * xs_local_data_ready - "data ready" callback for AF_LOCAL sockets 805 + * @sk: socket with data to read 806 + * @len: how much data to read 807 + * 808 + * Currently this assumes we can read the whole reply in a single gulp. 809 + */ 810 + static void xs_local_data_ready(struct sock *sk, int len) 811 + { 812 + struct rpc_task *task; 813 + struct rpc_xprt *xprt; 814 + struct rpc_rqst *rovr; 815 + struct sk_buff *skb; 816 + int err, repsize, copied; 817 + u32 _xid; 818 + __be32 *xp; 819 + 820 + read_lock_bh(&sk->sk_callback_lock); 821 + dprintk("RPC: %s...\n", __func__); 822 + xprt = xprt_from_sock(sk); 823 + if (xprt == NULL) 824 + goto out; 825 + 826 + skb = skb_recv_datagram(sk, 0, 1, &err); 827 + if (skb == NULL) 828 + goto out; 829 + 830 + if (xprt->shutdown) 831 + goto dropit; 832 + 833 + repsize = skb->len - sizeof(rpc_fraghdr); 834 + if (repsize < 4) { 835 + dprintk("RPC: impossible RPC reply size %d\n", repsize); 836 + goto dropit; 837 + } 838 + 839 + /* Copy the XID from the skb... */ 840 + xp = skb_header_pointer(skb, sizeof(rpc_fraghdr), sizeof(_xid), &_xid); 841 + if (xp == NULL) 842 + goto dropit; 843 + 844 + /* Look up and lock the request corresponding to the given XID */ 845 + spin_lock(&xprt->transport_lock); 846 + rovr = xprt_lookup_rqst(xprt, *xp); 847 + if (!rovr) 848 + goto out_unlock; 849 + task = rovr->rq_task; 850 + 851 + copied = rovr->rq_private_buf.buflen; 852 + if (copied > repsize) 853 + copied = repsize; 854 + 855 + if (xs_local_copy_to_xdr(&rovr->rq_private_buf, skb)) { 856 + dprintk("RPC: sk_buff copy failed\n"); 857 + goto out_unlock; 858 + } 859 + 860 + xprt_complete_rqst(task, copied); 861 + 862 + out_unlock: 863 + spin_unlock(&xprt->transport_lock); 864 + dropit: 865 + skb_free_datagram(sk, skb); 866 + out: 867 + read_unlock_bh(&sk->sk_callback_lock); 864 868 } 865 869 866 870 /** ··· 1504 1344 case TCP_CLOSE_WAIT: 1505 1345 /* The server initiated a shutdown of the socket */ 1506 1346 xprt_force_disconnect(xprt); 1507 - case TCP_SYN_SENT: 1508 1347 xprt->connect_cookie++; 1509 1348 case TCP_CLOSING: 1510 1349 /* ··· 1730 1571 return err; 1731 1572 } 1732 1573 1574 + /* 1575 + * We don't support autobind on AF_LOCAL sockets 1576 + */ 1577 + static void xs_local_rpcbind(struct rpc_task *task) 1578 + { 1579 + xprt_set_bound(task->tk_xprt); 1580 + } 1581 + 1582 + static void xs_local_set_port(struct rpc_xprt *xprt, unsigned short port) 1583 + { 1584 + } 1733 1585 1734 1586 #ifdef CONFIG_DEBUG_LOCK_ALLOC 1735 1587 static struct lock_class_key xs_key[2]; 1736 1588 static struct lock_class_key xs_slock_key[2]; 1589 + 1590 + static inline void xs_reclassify_socketu(struct socket *sock) 1591 + { 1592 + struct sock *sk = sock->sk; 1593 + 1594 + BUG_ON(sock_owned_by_user(sk)); 1595 + sock_lock_init_class_and_name(sk, "slock-AF_LOCAL-RPC", 1596 + &xs_slock_key[1], "sk_lock-AF_LOCAL-RPC", &xs_key[1]); 1597 + } 1737 1598 1738 1599 static inline void xs_reclassify_socket4(struct socket *sock) 1739 1600 { ··· 1776 1597 static inline void xs_reclassify_socket(int family, struct socket *sock) 1777 1598 { 1778 1599 switch (family) { 1600 + case AF_LOCAL: 1601 + xs_reclassify_socketu(sock); 1602 + break; 1779 1603 case AF_INET: 1780 1604 xs_reclassify_socket4(sock); 1781 1605 break; ··· 1788 1606 } 1789 1607 } 1790 1608 #else 1609 + static inline void xs_reclassify_socketu(struct socket *sock) 1610 + { 1611 + } 1612 + 1791 1613 static inline void xs_reclassify_socket4(struct socket *sock) 1792 1614 { 1793 1615 } ··· 1828 1642 return sock; 1829 1643 out: 1830 1644 return ERR_PTR(err); 1645 + } 1646 + 1647 + static int xs_local_finish_connecting(struct rpc_xprt *xprt, 1648 + struct socket *sock) 1649 + { 1650 + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, 1651 + xprt); 1652 + 1653 + if (!transport->inet) { 1654 + struct sock *sk = sock->sk; 1655 + 1656 + write_lock_bh(&sk->sk_callback_lock); 1657 + 1658 + xs_save_old_callbacks(transport, sk); 1659 + 1660 + sk->sk_user_data = xprt; 1661 + sk->sk_data_ready = xs_local_data_ready; 1662 + sk->sk_write_space = xs_udp_write_space; 1663 + sk->sk_error_report = xs_error_report; 1664 + sk->sk_allocation = GFP_ATOMIC; 1665 + 1666 + xprt_clear_connected(xprt); 1667 + 1668 + /* Reset to new socket */ 1669 + transport->sock = sock; 1670 + transport->inet = sk; 1671 + 1672 + write_unlock_bh(&sk->sk_callback_lock); 1673 + } 1674 + 1675 + /* Tell the socket layer to start connecting... */ 1676 + xprt->stat.connect_count++; 1677 + xprt->stat.connect_start = jiffies; 1678 + return kernel_connect(sock, xs_addr(xprt), xprt->addrlen, 0); 1679 + } 1680 + 1681 + /** 1682 + * xs_local_setup_socket - create AF_LOCAL socket, connect to a local endpoint 1683 + * @xprt: RPC transport to connect 1684 + * @transport: socket transport to connect 1685 + * @create_sock: function to create a socket of the correct type 1686 + * 1687 + * Invoked by a work queue tasklet. 1688 + */ 1689 + static void xs_local_setup_socket(struct work_struct *work) 1690 + { 1691 + struct sock_xprt *transport = 1692 + container_of(work, struct sock_xprt, connect_worker.work); 1693 + struct rpc_xprt *xprt = &transport->xprt; 1694 + struct socket *sock; 1695 + int status = -EIO; 1696 + 1697 + if (xprt->shutdown) 1698 + goto out; 1699 + 1700 + clear_bit(XPRT_CONNECTION_ABORT, &xprt->state); 1701 + status = __sock_create(xprt->xprt_net, AF_LOCAL, 1702 + SOCK_STREAM, 0, &sock, 1); 1703 + if (status < 0) { 1704 + dprintk("RPC: can't create AF_LOCAL " 1705 + "transport socket (%d).\n", -status); 1706 + goto out; 1707 + } 1708 + xs_reclassify_socketu(sock); 1709 + 1710 + dprintk("RPC: worker connecting xprt %p via AF_LOCAL to %s\n", 1711 + xprt, xprt->address_strings[RPC_DISPLAY_ADDR]); 1712 + 1713 + status = xs_local_finish_connecting(xprt, sock); 1714 + switch (status) { 1715 + case 0: 1716 + dprintk("RPC: xprt %p connected to %s\n", 1717 + xprt, xprt->address_strings[RPC_DISPLAY_ADDR]); 1718 + xprt_set_connected(xprt); 1719 + break; 1720 + case -ENOENT: 1721 + dprintk("RPC: xprt %p: socket %s does not exist\n", 1722 + xprt, xprt->address_strings[RPC_DISPLAY_ADDR]); 1723 + break; 1724 + default: 1725 + printk(KERN_ERR "%s: unhandled error (%d) connecting to %s\n", 1726 + __func__, -status, 1727 + xprt->address_strings[RPC_DISPLAY_ADDR]); 1728 + } 1729 + 1730 + out: 1731 + xprt_clear_connecting(xprt); 1732 + xprt_wake_pending_tasks(xprt, status); 1831 1733 } 1832 1734 1833 1735 static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) ··· 2032 1758 static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) 2033 1759 { 2034 1760 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); 1761 + int ret = -ENOTCONN; 2035 1762 2036 1763 if (!transport->inet) { 2037 1764 struct sock *sk = sock->sk; ··· 2064 1789 } 2065 1790 2066 1791 if (!xprt_bound(xprt)) 2067 - return -ENOTCONN; 1792 + goto out; 2068 1793 2069 1794 /* Tell the socket layer to start connecting... */ 2070 1795 xprt->stat.connect_count++; 2071 1796 xprt->stat.connect_start = jiffies; 2072 - return kernel_connect(sock, xs_addr(xprt), xprt->addrlen, O_NONBLOCK); 1797 + ret = kernel_connect(sock, xs_addr(xprt), xprt->addrlen, O_NONBLOCK); 1798 + switch (ret) { 1799 + case 0: 1800 + case -EINPROGRESS: 1801 + /* SYN_SENT! */ 1802 + xprt->connect_cookie++; 1803 + if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO) 1804 + xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; 1805 + } 1806 + out: 1807 + return ret; 2073 1808 } 2074 1809 2075 1810 /** ··· 2202 1917 } 2203 1918 2204 1919 /** 1920 + * xs_local_print_stats - display AF_LOCAL socket-specifc stats 1921 + * @xprt: rpc_xprt struct containing statistics 1922 + * @seq: output file 1923 + * 1924 + */ 1925 + static void xs_local_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) 1926 + { 1927 + long idle_time = 0; 1928 + 1929 + if (xprt_connected(xprt)) 1930 + idle_time = (long)(jiffies - xprt->last_used) / HZ; 1931 + 1932 + seq_printf(seq, "\txprt:\tlocal %lu %lu %lu %ld %lu %lu %lu " 1933 + "%llu %llu\n", 1934 + xprt->stat.bind_count, 1935 + xprt->stat.connect_count, 1936 + xprt->stat.connect_time, 1937 + idle_time, 1938 + xprt->stat.sends, 1939 + xprt->stat.recvs, 1940 + xprt->stat.bad_xids, 1941 + xprt->stat.req_u, 1942 + xprt->stat.bklog_u); 1943 + } 1944 + 1945 + /** 2205 1946 * xs_udp_print_stats - display UDP socket-specifc stats 2206 1947 * @xprt: rpc_xprt struct containing statistics 2207 1948 * @seq: output file ··· 2325 2014 unsigned long headoff; 2326 2015 unsigned long tailoff; 2327 2016 2328 - /* 2329 - * Set up the rpc header and record marker stuff 2330 - */ 2331 - xs_encode_tcp_record_marker(xbufp); 2017 + xs_encode_stream_record_marker(xbufp); 2332 2018 2333 2019 tailoff = (unsigned long)xbufp->tail[0].iov_base & ~PAGE_MASK; 2334 2020 headoff = (unsigned long)xbufp->head[0].iov_base & ~PAGE_MASK; ··· 2397 2089 { 2398 2090 } 2399 2091 2092 + static struct rpc_xprt_ops xs_local_ops = { 2093 + .reserve_xprt = xprt_reserve_xprt, 2094 + .release_xprt = xs_tcp_release_xprt, 2095 + .rpcbind = xs_local_rpcbind, 2096 + .set_port = xs_local_set_port, 2097 + .connect = xs_connect, 2098 + .buf_alloc = rpc_malloc, 2099 + .buf_free = rpc_free, 2100 + .send_request = xs_local_send_request, 2101 + .set_retrans_timeout = xprt_set_retrans_timeout_def, 2102 + .close = xs_close, 2103 + .destroy = xs_destroy, 2104 + .print_stats = xs_local_print_stats, 2105 + }; 2106 + 2400 2107 static struct rpc_xprt_ops xs_udp_ops = { 2401 2108 .set_buffer_size = xs_udp_set_buffer_size, 2402 2109 .reserve_xprt = xprt_reserve_xprt_cong, ··· 2473 2150 }; 2474 2151 2475 2152 switch (family) { 2153 + case AF_LOCAL: 2154 + break; 2476 2155 case AF_INET: 2477 2156 memcpy(sap, &sin, sizeof(sin)); 2478 2157 break; ··· 2520 2195 } 2521 2196 2522 2197 return xprt; 2198 + } 2199 + 2200 + static const struct rpc_timeout xs_local_default_timeout = { 2201 + .to_initval = 10 * HZ, 2202 + .to_maxval = 10 * HZ, 2203 + .to_retries = 2, 2204 + }; 2205 + 2206 + /** 2207 + * xs_setup_local - Set up transport to use an AF_LOCAL socket 2208 + * @args: rpc transport creation arguments 2209 + * 2210 + * AF_LOCAL is a "tpi_cots_ord" transport, just like TCP 2211 + */ 2212 + static struct rpc_xprt *xs_setup_local(struct xprt_create *args) 2213 + { 2214 + struct sockaddr_un *sun = (struct sockaddr_un *)args->dstaddr; 2215 + struct sock_xprt *transport; 2216 + struct rpc_xprt *xprt; 2217 + struct rpc_xprt *ret; 2218 + 2219 + xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries); 2220 + if (IS_ERR(xprt)) 2221 + return xprt; 2222 + transport = container_of(xprt, struct sock_xprt, xprt); 2223 + 2224 + xprt->prot = 0; 2225 + xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); 2226 + xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; 2227 + 2228 + xprt->bind_timeout = XS_BIND_TO; 2229 + xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; 2230 + xprt->idle_timeout = XS_IDLE_DISC_TO; 2231 + 2232 + xprt->ops = &xs_local_ops; 2233 + xprt->timeout = &xs_local_default_timeout; 2234 + 2235 + switch (sun->sun_family) { 2236 + case AF_LOCAL: 2237 + if (sun->sun_path[0] != '/') { 2238 + dprintk("RPC: bad AF_LOCAL address: %s\n", 2239 + sun->sun_path); 2240 + ret = ERR_PTR(-EINVAL); 2241 + goto out_err; 2242 + } 2243 + xprt_set_bound(xprt); 2244 + INIT_DELAYED_WORK(&transport->connect_worker, 2245 + xs_local_setup_socket); 2246 + xs_format_peer_addresses(xprt, "local", RPCBIND_NETID_LOCAL); 2247 + break; 2248 + default: 2249 + ret = ERR_PTR(-EAFNOSUPPORT); 2250 + goto out_err; 2251 + } 2252 + 2253 + dprintk("RPC: set up xprt to %s via AF_LOCAL\n", 2254 + xprt->address_strings[RPC_DISPLAY_ADDR]); 2255 + 2256 + if (try_module_get(THIS_MODULE)) 2257 + return xprt; 2258 + ret = ERR_PTR(-EINVAL); 2259 + out_err: 2260 + xprt_free(xprt); 2261 + return ret; 2523 2262 } 2524 2263 2525 2264 static const struct rpc_timeout xs_udp_default_timeout = { ··· 2827 2438 return ret; 2828 2439 } 2829 2440 2441 + static struct xprt_class xs_local_transport = { 2442 + .list = LIST_HEAD_INIT(xs_local_transport.list), 2443 + .name = "named UNIX socket", 2444 + .owner = THIS_MODULE, 2445 + .ident = XPRT_TRANSPORT_LOCAL, 2446 + .setup = xs_setup_local, 2447 + }; 2448 + 2830 2449 static struct xprt_class xs_udp_transport = { 2831 2450 .list = LIST_HEAD_INIT(xs_udp_transport.list), 2832 2451 .name = "udp", ··· 2870 2473 sunrpc_table_header = register_sysctl_table(sunrpc_table); 2871 2474 #endif 2872 2475 2476 + xprt_register_transport(&xs_local_transport); 2873 2477 xprt_register_transport(&xs_udp_transport); 2874 2478 xprt_register_transport(&xs_tcp_transport); 2875 2479 xprt_register_transport(&xs_bc_tcp_transport); ··· 2891 2493 } 2892 2494 #endif 2893 2495 2496 + xprt_unregister_transport(&xs_local_transport); 2894 2497 xprt_unregister_transport(&xs_udp_transport); 2895 2498 xprt_unregister_transport(&xs_tcp_transport); 2896 2499 xprt_unregister_transport(&xs_bc_tcp_transport);