From patchwork Thu Mar 16 18:49:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 9629211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F979604CC for ; Thu, 16 Mar 2017 18:49:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44B3E28665 for ; Thu, 16 Mar 2017 18:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 392FF28682; Thu, 16 Mar 2017 18:49:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C036728665 for ; Thu, 16 Mar 2017 18:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753613AbdCPSti (ORCPT ); Thu, 16 Mar 2017 14:49:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52609 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753096AbdCPSt2 (ORCPT ); Thu, 16 Mar 2017 14:49:28 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2GIheF9006925 for ; Thu, 16 Mar 2017 14:49:26 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 297ym4hvtb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 16 Mar 2017 14:49:26 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Mar 2017 14:49:25 -0400 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 16 Mar 2017 14:49:22 -0400 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2GInLlL17367472; Thu, 16 Mar 2017 11:49:21 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4379978037; Thu, 16 Mar 2017 12:49:21 -0600 (MDT) Received: from jarvis.ext.hansenpartnership.com (unknown [9.85.149.140]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS id 7BBEB78043; Thu, 16 Mar 2017 12:49:20 -0600 (MDT) Subject: Re: [PATCH] enclosure: fix sysfs symlinks creation when using multipath From: James Bottomley To: "Martin K. Petersen" , Maurizio Lombardi Cc: linux-scsi@vger.kernel.org Date: Thu, 16 Mar 2017 11:49:15 -0700 In-Reply-To: References: <1488454204-21251-1-git-send-email-mlombard@redhat.com> X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17031618-0052-0000-0000-000001AAB026 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006794; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00834760; UDB=6.00409979; IPR=6.00612416; BA=6.00005215; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014676; XFM=3.00000013; UTC=2017-03-16 18:49:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031618-0053-0000-0000-00004F32716E Message-Id: <1489690155.11068.10.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-16_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703160144 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 2017-03-15 at 19:39 -0400, Martin K. Petersen wrote: > Maurizio Lombardi writes: > > > With multipath, it may happen that the same device is passed to > > enclosure_add_device() multiple times and that the > > enclosure_add_links() function fails to create the symlinks because > > the device's sysfs directory entry is still NULL. In this case, > > the > > links will never be created because all the subsequent calls to > > enclosure_add_device() will immediately fail with EEXIST. > > James? Well I don't think the patch is the correct way to do this. The problem is that if we encounter an error creating the links, we shouldn't add the device to the enclosure. There's no need of a links_created variable (see below). However, more interesting is why the link creation failed in the first place. The device clearly seems to exist because it was added to sysfs at time index 19.2 and the enclosure didn't try to use it until 60.0. Can you debug this a bit more, please? I can't see anything specific to multipath in the trace, so whatever this is looks like it could happen in the single path case as well. James diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 65fed71..ae89082 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int component, struct device *dev) { struct enclosure_component *cdev; + int err; if (!edev || component >= edev->components) return -EINVAL; @@ -384,12 +385,15 @@ int enclosure_add_device(struct enclosure_device *edev, int component, if (cdev->dev == dev) return -EEXIST; - if (cdev->dev) + if (cdev->dev) { enclosure_remove_links(cdev); - - put_device(cdev->dev); - cdev->dev = get_device(dev); - return enclosure_add_links(cdev); + put_device(cdev->dev); + cdev->dev = NULL; + } + err = enclosure_add_links(cdev); + if (!err) + cdev->dev = get_device(dev); + return err; } EXPORT_SYMBOL_GPL(enclosure_add_device);