From patchwork Wed Mar 18 22:56:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 6044531 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 485A5BF90F for ; Wed, 18 Mar 2015 22:56:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7281C20272 for ; Wed, 18 Mar 2015 22:56:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 749F720173 for ; Wed, 18 Mar 2015 22:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755261AbbCRW4T (ORCPT ); Wed, 18 Mar 2015 18:56:19 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:36974 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753360AbbCRW4T (ORCPT ); Wed, 18 Mar 2015 18:56:19 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 0DA368EE253; Wed, 18 Mar 2015 15:56:18 -0700 (PDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rqf2OQriTpFa; Wed, 18 Mar 2015 15:56:17 -0700 (PDT) Received: from [153.66.254.242] (unknown [50.46.149.214]) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 958FA8EE072; Wed, 18 Mar 2015 15:56:17 -0700 (PDT) Message-ID: <1426719376.2307.36.camel@HansenPartnership.com> Subject: Re: [PATCH RESUBMIT] Enclosure: fix WARN ON when doing dlpar removing an adapter in dual patch devices From: James Bottomley To: wenxiong@linux.vnet.ibm.com Cc: linux-scsi@vger.kernel.org, brking@linux.vnet.ibm.com, wenxiong@us.ibm.com Date: Wed, 18 Mar 2015 15:56:16 -0700 In-Reply-To: <1426717101-26910-1-git-send-email-wenxiong@linux.vnet.ibm.com> References: <1426717101-26910-1-git-send-email-wenxiong@linux.vnet.ibm.com> X-Mailer: Evolution 3.12.9 Mime-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 2015-03-18 at 17:18 -0500, wenxiong@linux.vnet.ibm.com wrote: > From: Wen Xiong > > Hi James, > > Our test teams still see lots of these errors in error log when dlpar removing > the adapter in dual configuration. So I re-submit the patch. OK so in this case you have two struct devices for one bay (one for each path). The links are screwed up because a bay only points at one device (although each device points to an enclosure). We have a check, so the enclosure backlink points to the first device it encountered. The scope for cockups in this situation is huge (like if the device the enclosure points to gets removed > diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c > index 38552a3..0d20e19 100644 > --- a/drivers/misc/enclosure.c > +++ b/drivers/misc/enclosure.c > @@ -209,6 +209,9 @@ static void enclosure_remove_links(struct enclosure_component *cdev) > if (!cdev->dev->kobj.sd) > return; > > + if (!cdev->cdev.kobj.sd) > + return; > + > enclosure_link_name(cdev, name); > sysfs_remove_link(&cdev->dev->kobj, name); > sysfs_remove_link(&cdev->cdev.kobj, "device"); This doesn't look right: for this to work it means you have to have a dev with a kernfs link but a cdev without one. We probably still need to remove the dangling dev link. Does this work? It should remove either link if they exist. James --- -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 38552a3..65fed71 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -202,16 +202,17 @@ static void enclosure_remove_links(struct enclosure_component *cdev) { char name[ENCLOSURE_NAME_SIZE]; + enclosure_link_name(cdev, name); + /* * In odd circumstances, like multipath devices, something else may * already have removed the links, so check for this condition first. */ - if (!cdev->dev->kobj.sd) - return; + if (cdev->dev->kobj.sd) + sysfs_remove_link(&cdev->dev->kobj, name); - enclosure_link_name(cdev, name); - sysfs_remove_link(&cdev->dev->kobj, name); - sysfs_remove_link(&cdev->cdev.kobj, "device"); + if (cdev->cdev.kobj.sd) + sysfs_remove_link(&cdev->cdev.kobj, "device"); } static int enclosure_add_links(struct enclosure_component *cdev)