Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4092632ooa; Tue, 14 Aug 2018 00:36:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyA5DUzDvz72asDhtNxMIAkB6FMyuHztyIbtwPaRRhxJFd6RbJ6lr1OV22XzMnXU/WzR6WR X-Received: by 2002:a63:5204:: with SMTP id g4-v6mr20240906pgb.274.1534232165995; Tue, 14 Aug 2018 00:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534232165; cv=none; d=google.com; s=arc-20160816; b=L6GZUN/X392MXOpkUoDAxLTDDmH8iZn07oDVRuPdTN2ZHFEAV3Aa3fD4GJt6BvTnKM Kx4OfkjuQbO5AYEx7/+Vp1Cv44K/yWoZbryL2JFHpQ7moX1b47kpyqVZ84Vxu1+2hcIc 23gqpa91l+wfhoULOyfYqXSJErrM/sxlexAh8c7hix8YZzomKnCJe1PtFqFQ242tHDyo A5rN04vKdnlS1iWUlu+E02j6moRvbkR0RaH2QqK4l9MvpiARqZJrDcX1Os2GMQKk8+0J 3namr1u/YK4dJhkVHHX0S3IiuBsoZf5Sd5jDb46828Xz+PQNk+Rc5CTT49zCnlfet/Ng b9pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tkp/i4QCwG4D7jxk+3rWx5jtpRvQHr2ZtmXXCzuH92s=; b=TXuY6p3odQ0k3/SWxgDkxo01zcvVtu/wA9tdvD4ylOt0WlU1s2jmKDXa8JOA44h0Vf NXIugjlvr6d4q9gNhhEESN1O3/qpKr07O4VnUPH4breZ3Njql4A3w645EzFwT2awghFG CNHVIt0N23pBxEEE/hXpcmIa7kcrbHj9O4nZ41yN0njwEUrXg54faXb66NvqFgtUH/6E EOQOGpwGOQgqJECDBukWfrMXkS6DISoJD8FRH/pfiLoB+iExSW03C0PrQYHzEDFqNjU+ UXery645DoJLMR/2fJi1weCQRP4J3MJffVqv7KlxphWOG/vWEbGKSImhDNy0+fVBd4Dl 7YBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17-v6si16766952pgp.549.2018.08.14.00.35.50; Tue, 14 Aug 2018 00:36:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731969AbeHNKTI (ORCPT + 99 others); Tue, 14 Aug 2018 06:19:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:54236 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727689AbeHNKTI (ORCPT ); Tue, 14 Aug 2018 06:19:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 18DF3AF52; Tue, 14 Aug 2018 07:33:10 +0000 (UTC) From: Hannes Reinecke To: Jens Axboe Cc: Christoph Hellwig , Sagi Grimberg , Keith Busch , Bart van Assche , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Linux Kernel Mailinglist , Hannes Reinecke , Hannes Reinecke , "Ed L . Cachin" Subject: [PATCH 3/5] aoe: use device_add_disk_with_groups() Date: Tue, 14 Aug 2018 09:33:03 +0200 Message-Id: <20180814073305.87255-4-hare@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180814073305.87255-1-hare@suse.de> References: <20180814073305.87255-1-hare@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use device_add_disk_with_groups() to avoid a race condition with udev during startup. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Cc: Ed L. Cachin --- drivers/block/aoe/aoe.h | 1 - drivers/block/aoe/aoeblk.c | 21 +++++++-------------- drivers/block/aoe/aoedev.c | 1 - 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h index c0ebda1283cc..015c68017a1c 100644 --- a/drivers/block/aoe/aoe.h +++ b/drivers/block/aoe/aoe.h @@ -201,7 +201,6 @@ int aoeblk_init(void); void aoeblk_exit(void); void aoeblk_gdalloc(void *); void aoedisk_rm_debugfs(struct aoedev *d); -void aoedisk_rm_sysfs(struct aoedev *d); int aoechr_init(void); void aoechr_exit(void); diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 429ebb84b592..ff770e7d9e52 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -177,10 +177,15 @@ static struct attribute *aoe_attrs[] = { NULL, }; -static const struct attribute_group attr_group = { +static const struct attribute_group aoe_attr_group = { .attrs = aoe_attrs, }; +static const struct attribute_group *aoe_attr_groups[] = { + &aoe_attr_group, + NULL, +}; + static const struct file_operations aoe_debugfs_fops = { .open = aoe_debugfs_open, .read = seq_read, @@ -220,17 +225,6 @@ aoedisk_rm_debugfs(struct aoedev *d) } static int -aoedisk_add_sysfs(struct aoedev *d) -{ - return sysfs_create_group(&disk_to_dev(d->gd)->kobj, &attr_group); -} -void -aoedisk_rm_sysfs(struct aoedev *d) -{ - sysfs_remove_group(&disk_to_dev(d->gd)->kobj, &attr_group); -} - -static int aoeblk_open(struct block_device *bdev, fmode_t mode) { struct aoedev *d = bdev->bd_disk->private_data; @@ -417,8 +411,7 @@ aoeblk_gdalloc(void *vp) spin_unlock_irqrestore(&d->lock, flags); - add_disk(gd); - aoedisk_add_sysfs(d); + device_add_disk(NULL, gd, aoe_attr_groups); aoedisk_add_debugfs(d); spin_lock_irqsave(&d->lock, flags); diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 697f735b07a4..d92fa1fe3580 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -275,7 +275,6 @@ freedev(struct aoedev *d) del_timer_sync(&d->timer); if (d->gd) { aoedisk_rm_debugfs(d); - aoedisk_rm_sysfs(d); del_gendisk(d->gd); put_disk(d->gd); blk_cleanup_queue(d->blkq); -- 2.12.3