Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752752Ab3IKI0f (ORCPT ); Wed, 11 Sep 2013 04:26:35 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:45020 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129Ab3IKI0b (ORCPT ); Wed, 11 Sep 2013 04:26:31 -0400 Message-ID: <5230292E.8050408@oracle.com> Date: Wed, 11 Sep 2013 16:26:22 +0800 From: Joe Jin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: James Bottomley CC: "linux-kernel@vger.kernel.org" , linux-scsi@vger.kernel.org Subject: Re: [PATCH] [scsi] enclosure: remove all possible sysfs entries before add device References: <522D685D.5060201@oracle.com> <1378817174.6973.54.camel@dabdike.int.hansenpartnership.com> In-Reply-To: <1378817174.6973.54.camel@dabdike.int.hansenpartnership.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8794 Lines: 147 On 09/10/13 20:46, James Bottomley wrote: >> > During our test, multipath used, each LUN has 2 paths. when adding second >> > path enclousure did not check if will adding device's symlink existed or no. > The description doesn't look helpful. The problem, presumably in a > remove/re-add test that the add event gets processed before the remove > event, which is why the link is still there? Attach my debug info to here: sd 7:0:27:0: [ses_intf_add]:cdev:ffff8817e81fcba0,intf:ffffffffa00c9400,sdev:ffff8817e81fc800 sd 7:0:27:0: [ses_intf_add] call ses_match_to_enclosure(edev=ffff8817e812c000,sdev=ffff8817e81fc800), cdev=ffff8817e81fcba0 sd 7:0:27:0: *** inq[6]: 48 sd 7:0:27:0: [sdq] 1172123568 512-byte logical blocks: (600 GB/558 GiB) sd 7:0:27:0: [sdq] Write Protect is off ADD: [enclosure_add_links]: kobj: target: , device ADD: [enclosure_add_links]: kobj: target: , name: enclosure_device:HDD10 [ses_enclosure_find_by_addr] call enclosure_add_device(edev=ffff8817e812c000,i=4,efd->dev=ffff8817e81fc938),cdev=ffff8817e812ccd0 sd 7:0:27:0: [ses_intf_add] call ses_match_to_enclosure(edev=ffff8817ebd18000,sdev=ffff8817e81fc800), cdev=ffff8817e81fcba0 sd 7:0:27:0: *** inq[6]: 48 sd 7:0:27:0: [sdq] Write cache: disabled, read cache: enabled, supports DPO and FUA [ses_enclosure_find_by_addr] call enclosure_add_device(edev=ffff8817e812c000,i=4,efd->dev=ffff8817e81fc938),cdev=ffff8817e812ccd0 sd 7:0:27:0: Attached scsi generic sg17 type 0 sdq: sdq1 sdq2 scsi 6:0:27:0: SSP: handle(0x001c), sas_addr(0x5000c500006bd15e), phy(2), device_name(0x5000c500006bd15e) scsi 6:0:27:0: SSP: enclosure_logical_id(0x5080020000a3a510), slot(10) scsi 6:0:27:0: serial_number(000934E00P0S 3SL00P0S) scsi 6:0:27:0: qdepth(254), tagged(1), simple(0), ordered(0), scsi_level(6), cmd_que(1) sd 6:0:27:0: [ses_intf_add]:cdev:ffff8817e8304ba0,intf:ffffffffa00c9400,sdev:ffff8817e8304800 sd 6:0:27:0: [ses_intf_add] call ses_match_to_enclosure(edev=ffff8817e0c5c000,sdev=ffff8817e8304800), cdev=ffff8817e8304ba0 sd 6:0:27:0: *** inq[6]: 48 sd 6:0:27:0: [sdac] 1172123568 512-byte logical blocks: (600 GB/558 GiB) sd 7:0:27:0: [sdq] Attached SCSI disk RM: [enclosure_remove_links]: kobj: name: [enclosure_device:HDD10] RM: [enclosure_remove_links]: kobj: device sd 6:0:27:0: [sdac] Write Protect is off ADD: [enclosure_add_links]: kobj: target: , device ADD: [enclosure_add_links]: kobj: target: , name: enclosure_device:HDD10 [ses_enclosure_find_by_addr] call enclosure_add_device(edev=ffff8817e812c000,i=4,efd->dev=ffff8817e8304938),cdev=ffff8817e812ccd0 sd 6:0:27:0: [ses_intf_add] call ses_match_to_enclosure(edev=ffff8817e4094000,sdev=ffff8817e8304800), cdev=ffff8817e8304ba0 sd 6:0:27:0: *** inq[6]: 48 RM: [enclosure_remove_links]: kobj: name: [enclosure_device:HDD10] RM: [enclosure_remove_links]: kobj: device ADD: [enclosure_add_links]: kobj: target: , device ADD: [enclosure_add_links]: kobj: target: , name: enclosure_device:HDD10 ------------[ cut here ]------------ WARNING: at fs/sysfs/dir.c:455 sysfs_add_one+0xbc/0xe0() Hardware name: SUN FIRE X4370 M2 SERVER sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/0000:0d:00.0/host6/port-6:1/expander-6:1/port-6:1:14/end_device-6:1:14/target6:0:27/6:0:27:0/enclosure_device:HDD10' Modules linked in: oracleacfs(P)(U) oracleadvm(P)(U) oracleoks(P)(U) mptctl mptbase autofs4 hidp bluetooth rfkill lockd sunrpc bonding be2iscsi iscsi_boot_sysfs ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp bnx2i cnic uio ipv6 cxgb3i libcxgbi cxgb3 mdio libiscsi_tcp libiscsi scsi_transport_iscsi dm_round_robin dm_multipath video sbs sbshc acpi_pad acpi_memhotplug acpi_ipmi parport_pc lp parport ipmi_si ipmi_devintf ipmi_msghandler sg ses enclosure ixgbe e1000e hwmon igb snd_seq_dummy snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd soundcore snd_page_alloc iTCO_wdt pcspkr i2c_i801 ioatdma ghes iTCO_vendor_support hed dca i2c_core i7core_edac edac_core dm_snapshot dm_zero dm_mirror dm_region_hash dm_log dm_mod usb_storage shpchp mpt2sas scsi_transport_sas raid_class ahci libahci sd_mod crc_t10dif raid1 ext3 jbd mbcache Pid: 23302, comm: kworker/u:2 Tainted: P 2.6.39-400.124.1.el5uek.bug17342873V2 #1 Call Trace: [] ? sysfs_add_one+0xbc/0xe0 [] warn_slowpath_common+0x90/0xc0 [] warn_slowpath_fmt+0x6e/0x70 [] ? strlcat+0x54/0x70 [] sysfs_add_one+0xbc/0xe0 [] sysfs_do_create_link+0x148/0x1d0 [] sysfs_create_link+0x13/0x20 [] enclosure_add_links+0xe7/0x110 [enclosure] [] ? kobject_release+0xd/0x10 [] ? kref_put+0x37/0x70 [] enclosure_add_device+0x93/0xa0 [enclosure] [] ses_enclosure_find_by_addr+0x76/0xc0 [ses] [] ? ses_get_fault+0x40/0x40 [ses] [] enclosure_for_each_device+0x63/0x90 [enclosure] [] ses_match_to_enclosure+0x11a/0x1d0 [ses] [] ses_intf_add+0x2c8/0x5c0 [ses] [] ? kobject_get+0x1a/0x30 [] ? add_tail+0x36/0x50 [] device_add+0x2d4/0x380 [] scsi_sysfs_add_sdev+0xe6/0x2a0 [] scsi_add_lun+0x41c/0x560 [] scsi_probe_and_add_lun+0x1e0/0x3e0 [] ? default_spin_lock_flags+0x9/0x10 [] __scsi_scan_target+0xe7/0x120 [] scsi_scan_target+0xcd/0xf0 [] sas_rphy_add+0x11b/0x170 [scsi_transport_sas] [] mpt2sas_transport_port_add+0x2cf/0x430 [mpt2sas] [] _scsih_sas_device_add+0x87/0x110 [mpt2sas] [] _scsih_add_device+0x248/0x340 [mpt2sas] [] ? mpt2sas_transport_update_links+0xf1/0x190 [mpt2sas] [] _scsih_sas_topology_change_event+0x3c6/0x490 [mpt2sas] [] ? add_timer+0x18/0x20 [] ? queue_delayed_work_on+0xc5/0x170 [] _mpt2sas_fw_work+0x205/0x240 [mpt2sas] [] _firmware_event_work_delayed+0x19/0x20 [mpt2sas] [] process_one_work+0xf9/0x370 [] _firmware_event_work_delayed+0x19/0x20 [mpt2sas] [] process_one_work+0xf9/0x370 [] ? _mpt2sas_fw_work+0x240/0x240 [mpt2sas] [] worker_thread+0xca/0x240 [] ? manage_workers+0x90/0x90 [] kthread+0x97/0xa0 [] kernel_thread_helper+0x4/0x10 [] ? kthread_bind+0x80/0x80 [] ? gs_change+0x13/0x13 ---[ end trace 89a1351702ab360f ]--- [ses_enclosure_find_by_addr] call enclosure_add_device(edev=ffff8817e4094000,i=4,efd->dev=ffff8817e8304938),cdev=ffff8817e4094cd0 Per above message you can see the last tried for enclosure_device:HDD10, the index of component is not same then conflicted. BTW, 6:0:27:0 and 7:0:27:0 are same disk. > >> > Cc: James Bottomley >> > Signed-off-by: Joe Jin >> > --- >> > drivers/misc/enclosure.c | 7 +++++++ >> > 1 file changed, 7 insertions(+) >> > >> > diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c >> > index 0e8df41..efc0e86 100644 >> > --- a/drivers/misc/enclosure.c >> > +++ b/drivers/misc/enclosure.c >> > @@ -325,6 +325,13 @@ int enclosure_add_device(struct enclosure_device *edev, int component, >> > if (cdev->dev) >> > enclosure_remove_links(cdev); >> > >> > + if (dev) { > This test is pointless. Adding a NULL device is illegal. Yes this is right. Thanks, Joe > >> > + char name[ENCLOSURE_NAME_SIZE]; >> > + >> > + enclosure_link_name(cdev, name); >> > + sysfs_remove_link(&dev->kobj, name); > If we're really going to force eject the device, then this should be > enclosure_remove_device(edev, dev); > > How do you prevent the case for remove re-add in the same slot? Surely > in that case, with your code, the link will get removed again when the > remove gets processed, so the slot will then look empty (even though > it's not). -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/