public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Eykholt <jeykholt@cisco.com>
To: Greg KH <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org, stable@kernel.org,
	stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Robert Love <robert.w.love@intel.com>,
	James Bottomley <James.Bottomley@suse.de>
Subject: Re: [50/98] [SCSI] libfc: fix free of fc_rport_priv with timer pending
Date: Tue, 26 Jan 2010 16:03:13 -0800	[thread overview]
Message-ID: <4B5F82C1.6050108@cisco.com> (raw)
In-Reply-To: <20100126233927.458130052@mini.kroah.org>

Greg KH wrote:
> 2.6.32-stable review patch.  If anyone has any objections, please let us know.
> 
> ------------------
> 
> From: Joe Eykholt <jeykholt@cisco.com>
> 
> commit b4a9c7ede96e90f7b1ec009ce7256059295e76df upstream.
> 
> Timer crashes were caused by freeing a struct fc_rport_priv
> with a timer pending, causing the timer facility list to be
> corrupted.  This was during FC uplink flap tests with a lot
> of targets.
> 
> After discovery, we were doing an PLOGI on an rdata that was
> in DELETE state but not yet removed from the lookup list.
> This moved the rdata from DELETE state to PLOGI state.
> If the PLOGI exchange allocation failed and needed to be
> retried, the timer scheduling could race with the free
> being done by fc_rport_work().
> 
> When fc_rport_login() is called on a rport in DELETE state,
> move it to a new state RESTART.  In fc_rport_work, when
> handling a LOGO, STOPPED or FAILED event, look for restart
> state.  In the RESTART case, don't take the rdata off the
> list and after the transport remote port is deleted and
> exchanges are reset, re-login to the remote port.
> 
> Note that the new RESTART state also corrects a problem we
> had when re-discovering a port that had moved to DELETE state.
> In that case, a new rdata was created, but the old rdata
> would do an exchange manager reset affecting the FC_ID
> for both the new rdata and old rdata.  With the new state,
> the new port isn't logged into until after any old exchanges
> are reset.
> 
> Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
> Signed-off-by: Robert Love <robert.w.love@intel.com>
> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
> 
> ---
>  drivers/scsi/libfc/fc_rport.c |   69 ++++++++++++++++++++++++++++++------------
>  include/scsi/libfc.h          |    1 
>  2 files changed, 51 insertions(+), 19 deletions(-)
> 
> --- a/drivers/scsi/libfc/fc_rport.c
> +++ b/drivers/scsi/libfc/fc_rport.c
> @@ -86,6 +86,7 @@ static const char *fc_rport_state_names[
>  	[RPORT_ST_LOGO] = "LOGO",
>  	[RPORT_ST_ADISC] = "ADISC",
>  	[RPORT_ST_DELETE] = "Delete",
> +	[RPORT_ST_RESTART] = "Restart",
>  };
>  
>  /**
> @@ -99,8 +100,7 @@ static struct fc_rport_priv *fc_rport_lo
>  	struct fc_rport_priv *rdata;
>  
>  	list_for_each_entry(rdata, &lport->disc.rports, peers)
> -		if (rdata->ids.port_id == port_id &&
> -		    rdata->rp_state != RPORT_ST_DELETE)
> +		if (rdata->ids.port_id == port_id)
>  			return rdata;
>  	return NULL;
>  }
> @@ -235,6 +235,7 @@ static void fc_rport_work(struct work_st
>  	struct fc_rport_operations *rport_ops;
>  	struct fc_rport_identifiers ids;
>  	struct fc_rport *rport;
> +	int restart = 0;
>  
>  	mutex_lock(&rdata->rp_mutex);
>  	event = rdata->event;
> @@ -287,8 +288,19 @@ static void fc_rport_work(struct work_st
>  		mutex_unlock(&rdata->rp_mutex);
>  
>  		if (port_id != FC_FID_DIR_SERV) {
> +			/*
> +			 * We must drop rp_mutex before taking disc_mutex.
> +			 * Re-evaluate state to allow for restart.
> +			 * A transition to RESTART state must only happen
> +			 * while disc_mutex is held and rdata is on the list.
> +			 */
>  			mutex_lock(&lport->disc.disc_mutex);
> -			list_del(&rdata->peers);
> +			mutex_lock(&rdata->rp_mutex);
> +			if (rdata->rp_state == RPORT_ST_RESTART)
> +				restart = 1;
> +			else
> +				list_del(&rdata->peers);

There is a follow-up patch that adds this line at this point:

                         rdata->event = RPORT_EV_NONE;

If this patch is integrated, that one should be integrated
as well.  That patch is:

commit 5543c72e2bbb30e5ba5938b18ec26617b8b3fb04
Author: Abhijeet Joglekar <abjoglek@cisco.com>
Date:   Thu Dec 10 09:59:20 2009 -0800

[SCSI] libfc: remote port gets stuck in restart state without really restarting

	Joe


> +			mutex_unlock(&rdata->rp_mutex);
>  			mutex_unlock(&lport->disc.disc_mutex);
>  		}
>  
> @@ -312,7 +324,13 @@ static void fc_rport_work(struct work_st
>  			mutex_unlock(&rdata->rp_mutex);
>  			fc_remote_port_delete(rport);
>  		}
> -		kref_put(&rdata->kref, lport->tt.rport_destroy);
> +		if (restart) {
> +			mutex_lock(&rdata->rp_mutex);
> +			FC_RPORT_DBG(rdata, "work restart\n");
> +			fc_rport_enter_plogi(rdata);
> +			mutex_unlock(&rdata->rp_mutex);
> +		} else
> +			kref_put(&rdata->kref, lport->tt.rport_destroy);
>  		break;
>  
>  	default:
> @@ -342,6 +360,12 @@ int fc_rport_login(struct fc_rport_priv 
>  		FC_RPORT_DBG(rdata, "ADISC port\n");
>  		fc_rport_enter_adisc(rdata);
>  		break;
> +	case RPORT_ST_RESTART:
> +		break;
> +	case RPORT_ST_DELETE:
> +		FC_RPORT_DBG(rdata, "Restart deleted port\n");
> +		fc_rport_state_enter(rdata, RPORT_ST_RESTART);
> +		break;
>  	default:
>  		FC_RPORT_DBG(rdata, "Login to port\n");
>  		fc_rport_enter_plogi(rdata);
> @@ -397,20 +421,21 @@ int fc_rport_logoff(struct fc_rport_priv
>  
>  	if (rdata->rp_state == RPORT_ST_DELETE) {
>  		FC_RPORT_DBG(rdata, "Port in Delete state, not removing\n");
> -		mutex_unlock(&rdata->rp_mutex);
>  		goto out;
>  	}
>  
> -	fc_rport_enter_logo(rdata);
> +	if (rdata->rp_state == RPORT_ST_RESTART)
> +		FC_RPORT_DBG(rdata, "Port in Restart state, deleting\n");
> +	else
> +		fc_rport_enter_logo(rdata);
>  
>  	/*
>  	 * Change the state to Delete so that we discard
>  	 * the response.
>  	 */
>  	fc_rport_enter_delete(rdata, RPORT_EV_STOP);
> -	mutex_unlock(&rdata->rp_mutex);
> -
>  out:
> +	mutex_unlock(&rdata->rp_mutex);
>  	return 0;
>  }
>  
> @@ -466,6 +491,7 @@ static void fc_rport_timeout(struct work
>  	case RPORT_ST_READY:
>  	case RPORT_ST_INIT:
>  	case RPORT_ST_DELETE:
> +	case RPORT_ST_RESTART:
>  		break;
>  	}
>  
> @@ -499,6 +525,7 @@ static void fc_rport_error(struct fc_rpo
>  		fc_rport_enter_logo(rdata);
>  		break;
>  	case RPORT_ST_DELETE:
> +	case RPORT_ST_RESTART:
>  	case RPORT_ST_READY:
>  	case RPORT_ST_INIT:
>  		break;
> @@ -1248,6 +1275,7 @@ static void fc_rport_recv_plogi_req(stru
>  		}
>  		break;
>  	case RPORT_ST_PRLI:
> +	case RPORT_ST_RTV:
>  	case RPORT_ST_READY:
>  	case RPORT_ST_ADISC:
>  		FC_RPORT_DBG(rdata, "Received PLOGI in logged-in state %d "
> @@ -1255,11 +1283,14 @@ static void fc_rport_recv_plogi_req(stru
>  		/* XXX TBD - should reset */
>  		break;
>  	case RPORT_ST_DELETE:
> -	default:
> -		FC_RPORT_DBG(rdata, "Received PLOGI in unexpected state %d\n",
> -			     rdata->rp_state);
> -		fc_frame_free(rx_fp);
> -		goto out;
> +	case RPORT_ST_LOGO:
> +	case RPORT_ST_RESTART:
> +		FC_RPORT_DBG(rdata, "Received PLOGI in state %s - send busy\n",
> +			     fc_rport_state(rdata));
> +		mutex_unlock(&rdata->rp_mutex);
> +		rjt_data.reason = ELS_RJT_BUSY;
> +		rjt_data.explan = ELS_EXPL_NONE;
> +		goto reject;
>  	}
>  
>  	/*
> @@ -1510,14 +1541,14 @@ static void fc_rport_recv_logo_req(struc
>  		FC_RPORT_DBG(rdata, "Received LOGO request while in state %s\n",
>  			     fc_rport_state(rdata));
>  
> +		fc_rport_enter_delete(rdata, RPORT_EV_LOGO);
> +
>  		/*
> -		 * If the remote port was created due to discovery,
> -		 * log back in.  It may have seen a stale RSCN about us.
> +		 * If the remote port was created due to discovery, set state
> +		 * to log back in.  It may have seen a stale RSCN about us.
>  		 */
> -		if (rdata->rp_state != RPORT_ST_DELETE && rdata->disc_id)
> -			fc_rport_enter_plogi(rdata);
> -		else
> -			fc_rport_enter_delete(rdata, RPORT_EV_LOGO);
> +		if (rdata->disc_id)
> +			fc_rport_state_enter(rdata, RPORT_ST_RESTART);
>  		mutex_unlock(&rdata->rp_mutex);
>  	} else
>  		FC_RPORT_ID_DBG(lport, sid,
> --- a/include/scsi/libfc.h
> +++ b/include/scsi/libfc.h
> @@ -145,6 +145,7 @@ enum fc_rport_state {
>  	RPORT_ST_LOGO,		/* port logout sent */
>  	RPORT_ST_ADISC,		/* Discover Address sent */
>  	RPORT_ST_DELETE,	/* port being deleted */
> +	RPORT_ST_RESTART,       /* remote port being deleted and will restart */
>  };
>  
>  /**
> 
> 


  reply	other threads:[~2010-01-27  0:03 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-26 23:39 [00/98] 2.6.32.7-stable review Greg KH
2010-01-26 23:33 ` [01/98] clockevent: Dont remove broadcast device when cpu is dead Greg KH
2010-01-26 23:33 ` [02/98] clockevents: Add missing include to pacify sparse Greg KH
2010-01-26 23:33 ` [03/98] ACPI: dont cond_resched if irq is disabled Greg KH
2010-01-26 23:33 ` [04/98] sfc: Fix DMA mapping cleanup in case of an error in TSO Greg KH
2010-01-26 23:33 ` [05/98] be2net: Add support for next generation of BladeEngine device Greg KH
2010-01-26 23:33 ` [06/98] be2net: Add the new PCI IDs to PCI_DEVICE_TABLE Greg KH
2010-01-26 23:33 ` [07/98] [SCSI] mpt2sas: New device SAS2208 support is added Greg KH
2010-01-26 23:33 ` [08/98] ar9170: Add support for D-Link DWA 160 A2 Greg KH
2010-01-26 23:33 ` [09/98] [stable] [PATCH] powerpc/fsl: Add PCI device ids for new QoirQ chips Greg KH
2010-01-26 23:33 ` [10/98] davinci: dm646x: Add support for 3.x silicon revision Greg KH
2010-01-26 23:33 ` [11/98] Input: ALPS - add interleaved protocol support (Dell E6x00 series) Greg KH
2010-01-26 23:33 ` [12/98] Driver-Core: devtmpfs - set root directory mode to 0755 Greg KH
2010-01-27  4:09   ` Kay Sievers
2010-01-27 16:35     ` Greg KH
2010-01-26 23:33 ` [13/98] driver-core: fix devtmpfs crash on s390 Greg KH
2010-01-26 23:33 ` [14/98] ALSA: hda - Add PCI IDs for Nvidia G2xx-series Greg KH
2010-01-26 23:33 ` [15/98] V4L/DVB (13569): smsusb: add autodetection support for five additional Hauppauge USB IDs Greg KH
2010-01-26 23:33 ` [16/98] USB: mos7840: add device IDs for B&B electronics devices Greg KH
2010-01-26 23:33 ` [17/98] USB: ftdi_sio: add USB device IDs for B&B Electronics line Greg KH
2010-01-26 23:33 ` [18/98] V4L/DVB (13168): Add support for Asus Europa Hybrid DVB-T card (SAA7134 SubVendor ID: 0x1043 Device ID: 0x4847) Greg KH
2010-01-26 23:33 ` [19/98] [WATCHDOG] iTCO_wdt: Add support for Intel Ibex Peak Greg KH
2010-01-26 23:33 ` [20/98] atl1c:use common_task instead of reset_task and link_chg_task Greg KH
2010-01-27  5:25   ` [Stable-review] " Willy Tarreau
2010-01-27 14:45     ` Stefan Bader
2010-01-30 18:09     ` Willy Tarreau
2010-01-26 23:33 ` [21/98] atl1e:disable NETIF_F_TSO6 for hardware limit Greg KH
2010-01-26 23:33 ` [22/98] V4L/DVB (13680a): DocBook/media: copy images after building HTML Greg KH
2010-01-26 23:33 ` [23/98] V4L/DVB (13680b): DocBook/media: create links for included sources Greg KH
2010-01-26 23:33 ` [24/98] netfilter: xtables: fix conntrack match v1 ipt-save output Greg KH
2010-01-26 23:33 ` [25/98] partitions: read whole sector with EFI GPT header Greg KH
2010-01-26 23:33 ` [26/98] partitions: use sector size for EFI GPT Greg KH
2010-01-26 23:33 ` [27/98] ALSA: ice1724 - Patch for suspend/resume for ESI Juli@ Greg KH
2010-01-26 23:33 ` [28/98] sched: Fix isolcpus boot option Greg KH
2010-01-26 23:33 ` [29/98] sched: Fix missing sched tunable recalculation on cpu add/remove Greg KH
2010-01-26 23:33 ` [30/98] nohz: Prevent clocksource wrapping during idle Greg KH
2010-01-26 23:33 ` [31/98] nfsd: Fix sort_pacl in fs/nfsd/nf4acl.c to actually sort groups Greg KH
2010-01-26 23:33 ` [32/98] timers, init: Limit the number of per cpu calibration bootup messages Greg KH
2010-01-26 23:33 ` [33/98] PCI: Always set prefetchable base/limit upper32 registers Greg KH
2010-01-26 23:34 ` [34/98] [SCSI] iscsi class: modify handling of replacement timeout Greg KH
2010-01-26 23:34 ` [35/98] NFS: Revert default r/wsize behavior Greg KH
2010-01-26 23:34 ` [36/98] HID: fixup quirk for NCR devices Greg KH
2010-01-26 23:34 ` [37/98] [SCSI] scsi_devinfo: update Hitachi entries (v2) Greg KH
2010-01-26 23:34 ` [38/98] [SCSI] scsi_dh: create sysfs file, dh_state for all SCSI disk devices Greg KH
2010-01-26 23:34 ` [39/98] [SCSI] scsi_transport_fc: remove invalid BUG_ON Greg KH
2010-01-26 23:34 ` [40/98] [SCSI] lpfc: fix hang on SGI ia64 platform Greg KH
2010-01-26 23:34 ` [41/98] [SCSI] libfc: fix typo in retry check on received PRLI Greg KH
2010-01-26 23:34 ` [42/98] [SCSI] libfc: fix ddp in fc_fcp for 0 xid Greg KH
2010-01-26 23:34 ` [43/98] [SCSI] fcoe: remove redundant checking of netdev->netdev_ops Greg KH
2010-01-26 23:34 ` [44/98] [SCSI] libfc: Fix wrong scsi return status under FC_DATA_UNDRUN Greg KH
2010-01-26 23:34 ` [45/98] [SCSI] libfc: lport: fix minor documentation errors Greg KH
2010-01-26 23:34 ` [46/98] [SCSI] libfc: dont WARN_ON in lport_timeout for RESET state Greg KH
2010-01-26 23:34 ` [47/98] [SCSI] fcoe: initialize return value in fcoe_destroy Greg KH
2010-01-26 23:34 ` [48/98] [SCSI] libfc: Fix frags in frame exceeding SKB_MAX_FRAGS in fc_fcp_send_data Greg KH
2010-01-26 23:34 ` [49/98] [SCSI] libfc: fix memory corruption caused by double frees and bad error handling Greg KH
2010-01-26 23:34 ` [50/98] [SCSI] libfc: fix free of fc_rport_priv with timer pending Greg KH
2010-01-27  0:03   ` Joe Eykholt [this message]
2010-01-27  2:03     ` Greg KH
2010-01-26 23:34 ` [51/98] [SCSI] fcoe, libfc: fix an libfc issue with queue ramp down in libfc Greg KH
2010-01-26 23:34 ` [52/98] [SCSI] fcoe: Fix checking san mac address Greg KH
2010-01-26 23:34 ` [53/98] [SCSI] fcoe: Fix getting san mac for VLAN interface Greg KH
2010-01-26 23:34 ` [54/98] qlge: Remove explicit setting of PCI Dev CTL reg Greg KH
2010-01-26 23:34 ` [55/98] qlge: Set PCIE max read request size Greg KH
2010-01-26 23:34 ` [56/98] qlge: Dont fail open when port is not initialized Greg KH
2010-01-26 23:34 ` [57/98] qlge: Add handler for DCBX firmware event Greg KH
2010-01-26 23:34 ` [58/98] qlge: Bonding fix for mode 6 Greg KH
2010-01-26 23:34 ` [59/98] PCI: AER: fix aer inject result in kernel oops Greg KH
2010-01-26 23:34 ` [60/98] DMI: allow omitting ident strings in DMI tables Greg KH
2010-01-26 23:34 ` [61/98] Input: i8042 - remove identification strings from " Greg KH
2010-01-27  0:00   ` Linus Torvalds
2010-01-27  0:11     ` Greg KH
2010-01-26 23:34 ` [62/98] Input: i8042 - add Gigabyte M1022M to the noloop list Greg KH
2010-01-26 23:34 ` [63/98] Input: i8042 - add Dritek quirk for Acer Aspire 5610 Greg KH
2010-01-26 23:34 ` [64/98] ALSA: hda - select IbexPeak handler for Calpella Greg KH
2010-01-26 23:34 ` [65/98] ALSA: hda - Fix quirk for Maxdata obook4-1 Greg KH
2010-01-26 23:34 ` [66/98] ALSA: hda - Add missing Line-Out and PCM switches as slave Greg KH
2010-01-26 23:34 ` [67/98] [WATCHDOG] iTCO_wdt.c - cleanup chipset documentation Greg KH
2010-01-26 23:34 ` [68/98] [WATCHDOG] iTCO_wdt: add PCI ID for the Intel EP80579 (Tolapai) SoC Greg KH
2010-01-26 23:34 ` [69/98] [WATCHDOG] iTCO_wdt: Add Intel Cougar Point and PCH DeviceIDs Greg KH
2010-01-26 23:34 ` [70/98] ahci: disable SNotification capability for ich8 Greg KH
2010-01-26 23:34 ` [71/98] ata_piix: fix MWDMA handling on PIIX3 Greg KH
2010-01-26 23:34 ` [72/98] ata_piix: enable 32bit PIO on SATA piix Greg KH
2010-01-26 23:56   ` Tejun Heo
2010-01-27  0:03     ` Greg KH
2010-01-26 23:34 ` [73/98] md: fix small irregularity with start_ro module parameter Greg KH
2010-01-26 23:34 ` [74/98] V4L/DVB (13826): uvcvideo: Fix controls blacklisting Greg KH
2010-01-26 23:34 ` [75/98] [S390] cio: fix double free in case of probe failure Greg KH
2010-01-26 23:34 ` [76/98] [S390] cio: dont panic in non-fatal conditions Greg KH
2010-01-26 23:34 ` [77/98] netiucv: displayed TX bytes value much too high Greg KH
2010-01-26 23:34 ` [78/98] ipc ns: fix memory leak (idr) Greg KH
2010-01-26 23:34 ` [79/98] ALSA: hda - Fix HP T5735 automute Greg KH
2010-01-26 23:34 ` [80/98] hwmon: (fschmd) Fix a memleak on multiple opens of /dev/watchdog Greg KH
2010-01-26 23:34 ` [81/98] UBI: fix memory leak in update path Greg KH
2010-01-26 23:34 ` [82/98] UBI: initialise update marker Greg KH
2010-01-26 23:34 ` [83/98] ASoC: fix a memory-leak in wm8903 Greg KH
2010-01-26 23:34 ` [84/98] mac80211: check that ieee80211_set_power_mgmt only handles STA interfaces Greg KH
2010-01-26 23:34 ` [85/98] cfg80211: fix channel setting for wext Greg KH
2010-01-26 23:34 ` [86/98] KVM: S390: fix potential array overrun in intercept handling Greg KH
2010-01-26 23:34 ` [87/98] KVM: only allow one gsi per fd Greg KH
2010-01-26 23:34 ` [88/98] KVM: Fix race between APIC TMR and IRR Greg KH
2010-01-26 23:34 ` [89/98] KVM: MMU: bail out pagewalk on kvm_read_guest error Greg KH
2010-01-26 23:34 ` [90/98] KVM: x86: Fix host_mapping_level() Greg KH
2010-01-26 23:34 ` [91/98] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Greg KH
2010-01-26 23:34 ` [92/98] KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init() Greg KH
2010-01-26 23:34 ` [93/98] KVM: fix lock imbalance in kvm_*_irq_source_id() Greg KH
2010-01-26 23:35 ` [94/98] KVM: only clear irq_source_id if irqchip is present Greg KH
2010-01-26 23:35 ` [95/98] IPoIB: Clear ipoib_neigh.dgid in ipoib_neigh_alloc() Greg KH
2010-01-26 23:35 ` [96/98] x86: Reenable TSC sync check at boot, even with NONSTOP_TSC Greg KH
2010-01-26 23:35 ` [97/98] ACPI: enable C2 and Turbo-mode on Nehalem notebooks on A/C Greg KH
2010-01-26 23:35 ` [98/98] iwlwifi: Fix throughput stall issue in HT mode for 5000 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=4B5F82C1.6050108@cisco.com \
    --to=jeykholt@cisco.com \
    --cc=James.Bottomley@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robert.w.love@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox