From patchwork Wed Aug 17 07:15:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 9285291 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 46C3660459 for ; Wed, 17 Aug 2016 07:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3818028886 for ; Wed, 17 Aug 2016 07:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29D4428884; Wed, 17 Aug 2016 07:27:17 +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 AAED628884 for ; Wed, 17 Aug 2016 07:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753688AbcHQH1Q (ORCPT ); Wed, 17 Aug 2016 03:27:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753614AbcHQH1P (ORCPT ); Wed, 17 Aug 2016 03:27:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA5DF85376; Wed, 17 Aug 2016 07:16:00 +0000 (UTC) Received: from lemon.nay.redhat.com (dhcp-15-153.nay.redhat.com [10.66.15.153]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7H7FGWC008426; Wed, 17 Aug 2016 03:15:56 -0400 From: Fam Zheng To: linux-kernel@vger.kernel.org Cc: linux-nvme@lists.infradead.org, Keith Busch , Michael Ellerman , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, "Michael S. Tsirkin" , linux-block@vger.kernel.org, Brian Norris , Paul Mackerras , linux-mtd@lists.infradead.org, "Ed L. Cashin" , Jens Axboe , Minchan Kim , virtualization@lists.linux-foundation.org, Sergey Senozhatsky , Nitin Gupta , David Woodhouse Subject: [PATCH 08/15] nvme: Pass attribute group to device_add_disk Date: Wed, 17 Aug 2016 15:15:08 +0800 Message-Id: <1471418115-3654-9-git-send-email-famz@redhat.com> In-Reply-To: <1471418115-3654-1-git-send-email-famz@redhat.com> References: <1471418115-3654-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Aug 2016 07:16:01 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng --- drivers/nvme/host/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 23a795f..1921cb2 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1686,11 +1686,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) if (ns->type == NVME_NS_LIGHTNVM) return; - device_add_disk(ctrl->device, ns->disk, NULL); - if (sysfs_create_group(&disk_to_dev(ns->disk)->kobj, - &nvme_ns_attr_group)) - pr_warn("%s: failed to create sysfs group for identification\n", - ns->disk->disk_name); + device_add_disk(ctrl->device, ns->disk, &nvme_ns_attr_group); return; out_free_disk: kfree(disk);