All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Steve Dickson <SteveD@redhat.com>,
	Trond Myklebust <Trond.Myklebust@netapp.com>
Subject: [patch 48/48] SUNRPC: Fix tcp reconnection
Date: Fri, 04 Sep 2009 13:08:00 -0700	[thread overview]
Message-ID: <20090904200857.466721861@mini.kroah.org> (raw)
In-Reply-To: <20090904201112.GA8274@kroah.com>

[-- Attachment #1: sunrpc-fix-tcp-reconnection.patch --]
[-- Type: text/plain, Size: 3985 bytes --]


2.6.27-stable review patch.  If anyone has any objections, please let us know.

------------------
From: Trond Myklebust <Trond.Myklebust@netapp.com>

This fixes a problem that was reported as Red Hat Bugzilla entry number
485339, in which rpciod starts looping on the TCP connection code,
rendering the NFS client unusable for 1/2 minute or so.

It is basically a backport of commit
f75e6745aa3084124ae1434fd7629853bdaf6798 (SUNRPC: Fix the problem of
EADDRNOTAVAIL syslog floods on reconnect)

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


---
 include/linux/sunrpc/xprt.h |    1 +
 net/sunrpc/xprt.c           |    6 ++----
 net/sunrpc/xprtsock.c       |   37 ++++++++++++++++++++++++++++++++++---
 3 files changed, 37 insertions(+), 7 deletions(-)

--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -260,6 +260,7 @@ void			xprt_conditional_disconnect(struc
 #define XPRT_BOUND		(4)
 #define XPRT_BINDING		(5)
 #define XPRT_CLOSING		(6)
+#define XPRT_CONNECTION_CLOSE	(8)
 
 static inline void xprt_set_connected(struct rpc_xprt *xprt)
 {
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -645,10 +645,8 @@ xprt_init_autodisconnect(unsigned long d
 	if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
 		goto out_abort;
 	spin_unlock(&xprt->transport_lock);
-	if (xprt_connecting(xprt))
-		xprt_release_write(xprt, NULL);
-	else
-		queue_work(rpciod_workqueue, &xprt->task_cleanup);
+	set_bit(XPRT_CONNECTION_CLOSE, &xprt->state);
+	queue_work(rpciod_workqueue, &xprt->task_cleanup);
 	return;
 out_abort:
 	spin_unlock(&xprt->transport_lock);
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -748,6 +748,9 @@ out_release:
  *
  * This is used when all requests are complete; ie, no DRC state remains
  * on the server we want to save.
+ *
+ * The caller _must_ be holding XPRT_LOCKED in order to avoid issues with
+ * xs_reset_transport() zeroing the socket from underneath a writer.
  */
 static void xs_close(struct rpc_xprt *xprt)
 {
@@ -781,6 +784,14 @@ clear_close_wait:
 	xprt_disconnect_done(xprt);
 }
 
+static void xs_tcp_close(struct rpc_xprt *xprt)
+{
+	if (test_and_clear_bit(XPRT_CONNECTION_CLOSE, &xprt->state))
+		xs_close(xprt);
+	else
+		xs_tcp_shutdown(xprt);
+}
+
 /**
  * xs_destroy - prepare to shutdown a transport
  * @xprt: doomed transport
@@ -1676,11 +1687,21 @@ static void xs_tcp_connect_worker4(struc
 				goto out_clear;
 			case -ECONNREFUSED:
 			case -ECONNRESET:
+			case -ENETUNREACH:
 				/* retry with existing socket, after a delay */
-				break;
+				goto out_clear;
 			default:
 				/* get rid of existing socket, and retry */
 				xs_tcp_shutdown(xprt);
+				printk("%s: connect returned unhandled error %d\n",
+						__func__, status);
+			case -EADDRNOTAVAIL:
+				/* We're probably in TIME_WAIT. Get rid of existing socket,
+				 * and retry
+				 */
+				set_bit(XPRT_CONNECTION_CLOSE, &xprt->state);
+				xprt_force_disconnect(xprt);
+				status = -EAGAIN;
 		}
 	}
 out:
@@ -1735,11 +1756,21 @@ static void xs_tcp_connect_worker6(struc
 				goto out_clear;
 			case -ECONNREFUSED:
 			case -ECONNRESET:
+			case -ENETUNREACH:
 				/* retry with existing socket, after a delay */
-				break;
+				goto out_clear;
 			default:
 				/* get rid of existing socket, and retry */
 				xs_tcp_shutdown(xprt);
+				printk("%s: connect returned unhandled error %d\n",
+						__func__, status);
+			case -EADDRNOTAVAIL:
+				/* We're probably in TIME_WAIT. Get rid of existing socket,
+				 * and retry
+				 */
+				set_bit(XPRT_CONNECTION_CLOSE, &xprt->state);
+				xprt_force_disconnect(xprt);
+				status = -EAGAIN;
 		}
 	}
 out:
@@ -1871,7 +1902,7 @@ static struct rpc_xprt_ops xs_tcp_ops = 
 	.buf_free		= rpc_free,
 	.send_request		= xs_tcp_send_request,
 	.set_retrans_timeout	= xprt_set_retrans_timeout_def,
-	.close			= xs_tcp_shutdown,
+	.close			= xs_tcp_close,
 	.destroy		= xs_destroy,
 	.print_stats		= xs_tcp_print_stats,
 };



  parent reply	other threads:[~2009-09-04 20:15 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090904200712.724048145@mini.kroah.org>
2009-09-04 20:11 ` [patch 00/48] 2.6.27.32-stable review Greg KH
2009-09-04 20:07   ` [patch 01/48] ALSA: hda - Fix MacBookPro 3,1/4,1 quirk with ALC889A Greg KH
2009-09-04 20:07   ` [patch 02/48] clone(): fix race between copy_process() and de_thread() Greg KH
2009-09-04 20:07   ` [patch 03/48] ehea: Fix napi list corruption on ifconfig down Greg KH
2009-09-04 20:07   ` [patch 04/48] sound: pcm_lib: fix unsorted list constraint handling Greg KH
2009-09-04 20:07   ` [patch 05/48] SUNRPC: Fix rpc_task_force_reencode Greg KH
2009-09-04 20:07   ` [patch 06/48] KVM: VMX: Change cs reset state to be a data segment Greg KH
2009-09-04 20:07   ` [patch 07/48] KVM: VMX: Change segment dpl at reset to 3 Greg KH
2009-09-04 20:07   ` [patch 08/48] KVM: Load real mode segments correctly Greg KH
2009-09-04 20:07   ` [patch 09/48] KVM: Allocate guest memory as MAP_PRIVATE, not MAP_SHARED Greg KH
2009-09-04 20:07   ` [patch 10/48] KVM: Dont call get_user_pages(.force = 1) Greg KH
2009-09-04 20:07   ` [patch 11/48] KVM: MMU: Add locking around kvm_mmu_slot_remove_write_access() Greg KH
2009-09-04 20:07   ` [patch 12/48] KVM: MMU: Flush tlbs after clearing write permission when accessing dirty log Greg KH
2009-09-04 20:07   ` [patch 13/48] KVM: MMU: Fix setting the accessed bit on non-speculative sptes Greg KH
2009-09-04 20:07   ` [patch 14/48] KVM: Reduce kvm stack usage in kvm_arch_vm_ioctl() Greg KH
2009-09-06  5:47     ` Pavel Machek
2009-09-06 13:43       ` Dave Hansen
2009-09-04 20:07   ` [patch 15/48] KVM: Reduce stack usage in kvm_vcpu_ioctl() Greg KH
2009-09-04 20:07   ` [patch 16/48] KVM: Reduce stack usage in kvm_arch_vcpu_ioctl() Greg KH
2009-09-04 20:07   ` [patch 17/48] KVM: Reduce stack usage in kvm_pv_mmu_op() Greg KH
2009-09-04 20:07   ` [patch 18/48] KVM: add MC5_MISC msr read support Greg KH
2009-09-04 20:07   ` [patch 19/48] KVM: set debug registers after "schedulable" section Greg KH
2009-09-04 20:07   ` [patch 20/48] KVM: MMU: increase per-vcpu rmap cache alloc size Greg KH
2009-09-04 20:07   ` [patch 21/48] KVM: VMX: Set IGMT bit in EPT entry Greg KH
2009-09-04 20:07   ` [patch 22/48] KVM: Dont destroy vcpu in case vcpu_setup fails Greg KH
2009-09-04 20:07   ` [patch 23/48] KVM: VMX: Dont allow uninhibited access to EFER on i386 Greg KH
2009-09-04 20:07   ` [patch 24/48] KVM: SVM: Remove port 80 passthrough Greg KH
2009-09-04 20:07   ` [patch 25/48] KVM: Make EFER reads safe when EFER does not exist Greg KH
2009-09-04 20:07   ` [patch 26/48] KVM: VMX: Handle vmx instruction vmexits Greg KH
2009-09-04 20:07   ` [patch 27/48] KVM: Make paravirt tlb flush also reload the PAE PDPTRs Greg KH
2009-09-04 20:07   ` [patch 28/48] KVM: Fix PDPTR reloading on CR4 writes Greg KH
2009-09-04 20:07   ` [patch 29/48] KVM: MMU: do not free active mmu pages in free_mmu_pages() Greg KH
2009-09-04 20:07   ` [patch 30/48] KVM: Fix dirty bit tracking for slots with large pages Greg KH
2009-09-04 20:07   ` [patch 31/48] KVM: x86: check for cr3 validity in mmu_alloc_roots Greg KH
2009-09-04 20:07   ` [patch 32/48] KVM: MMU: protect kvm_mmu_change_mmu_pages with mmu_lock Greg KH
2009-09-04 20:07   ` [patch 33/48] appletalk: fix atalk_getname() leak Greg KH
2009-09-04 20:07   ` [patch 34/48] can: Fix raw_getname() leak Greg KH
2009-09-04 20:07   ` [patch 35/48] do_sigaltstack: avoid copying stack_t as a structure to user space Greg KH
2009-09-04 20:07   ` [patch 36/48] econet: Fix econet_getname() leak Greg KH
2009-09-04 20:07   ` [patch 37/48] irda: Fix irda_getname() leak Greg KH
2009-09-04 20:07   ` [patch 38/48] kthreads: fix kthread_create() vs kthread_stop() race Greg KH
2009-09-04 20:07   ` [patch 39/48] NET: llc, zero sockaddr_llc struct Greg KH
2009-09-04 20:07   ` [patch 40/48] netrom: Fix nr_getname() leak Greg KH
2009-09-04 20:07   ` [patch 41/48] ocfs2: Initialize the cluster were writing to in a non-sparse extend Greg KH
2009-09-04 21:00     ` Joel Becker
2009-09-06  8:32       ` Joel Becker
2009-09-06 18:17         ` Greg KH
2009-09-04 20:07   ` [patch 42/48] rose: Fix rose_getname() leak Greg KH
2009-09-04 20:07   ` [patch 43/48] ALSA: hda - Add missing vmaster initialization for ALC269 Greg KH
2009-09-04 20:07   ` [patch 44/48] parport: quickfix the proc registration bug Greg KH
2009-09-04 20:07   ` [patch 45/48] USB: removal of tty->low_latency hack dating back to the old serial code Greg KH
2009-09-04 20:07   ` [patch 46/48] Remove low_latency flag setting from nozomi and mxser drivers Greg KH
2009-09-04 20:07   ` [patch 47/48] SCSI: sr: report more accurate drive status after closing the tray Greg KH
2009-09-04 20:08   ` Greg KH [this message]
2009-09-06 22:58   ` [patch 00/48] 2.6.27.32-stable review Tilman Schmidt
2009-09-10 22:33     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090904200857.466721861@mini.kroah.org \
    --to=gregkh@suse.de \
    --cc=SteveD@redhat.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.