Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp242702pxf; Wed, 10 Mar 2021 05:29:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTtio1FZgY7QTUjLdDBckp8YTNOptQtOZVaxgDYJ6478JKGlxQHNdC/jntPJMrKCwXn3eg X-Received: by 2002:aa7:c1d0:: with SMTP id d16mr3202397edp.153.1615382996080; Wed, 10 Mar 2021 05:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615382996; cv=none; d=google.com; s=arc-20160816; b=rToJi7vWiKY7JJO54vtF56scPSBikaI2GsZSUX2SQ0W64o+IUtLLp44GQf7o05m/cY Kh1f975t8jRct1sTVAgzdf0r31ikVf3GzRNizW3DblLeQAjBhKpA3RxOhrxEO6k0rzuG LYuDXR9TAf6lnVTMHx23ler06SxxBLI2YECka/Tkg3rnUQG2YMjBIuNoq/PdDFsn8gsg 7G7boeOnzEF+Ge92xqBIcMoOIUMj7OLxhtUxD8D38E2PBJlwmuYN4R0or3Lpc26YdvvZ z5q0LrPSh7RfQiUybZ8NgkcKQkrzFWh9h14NGTVqDo5FuQ1NAW35FCMHbWMzk06Afp3m LIlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V6NYm3/P2rmxj8d7r+5WxuBPV8ygKXYsZwkH1gmWf7Q=; b=bqDz/qqaXPggqj2Ad79Y2NMD/Yz/4pSWayEBgEALkU8wLm3Xrk94ibym/P+EDrQKcJ SPmaZgZH4MG0J9PFqiejoIJdDDe3UWScFzPG9JDBGwUql0WnQSgt+tL+6R1ZCHJHNms0 v6+wEbwGz79wonFDCKyFEEIg+5Yyp7rSRuisnbVfx6RmFK9XHcKp0Ujx5QlaziK/8C/k cyceXvxRnldQdQi8YbHlFuqMHj1jmQlD8rEhTAXE0/3FF3cOlQTjpzXD0N2m5x9OgKzm Mj7je9W+N5C65ZA2B3Uwu/V2D15IDFiXz00X9ZuFI1J55k/Nvx7M70eAqnLMpkxopNvU diSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HtLnmdt6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si11780441ejv.562.2021.03.10.05.29.33; Wed, 10 Mar 2021 05:29:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HtLnmdt6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234020AbhCJN2g (ORCPT + 99 others); Wed, 10 Mar 2021 08:28:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:47532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233270AbhCJNZQ (ORCPT ); Wed, 10 Mar 2021 08:25:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F55C6503E; Wed, 10 Mar 2021 13:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382715; bh=dtOjaz4fqdVqMM9rDzoAnXqUd3J2Q+VpWaU4hqsOOyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HtLnmdt6mlmecQ4fmK4b69riTD6Ss0igBJgh8/YjF60oBw/gCiAYlbkNvORskfX41 yTT6S+Bbhnu9j6aTJc0b2sHawnOmC71cvqSW8Fs9P1My53LS3z+SJWxnaIbXyvAK1e X9epBxz5E5bWBE1RDhJbpQwcwd5Xqz7jWdtgeR3I= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Christoph Hellwig , "Ed L. Cachin" , Bart Van Assche , Jens Axboe , Jeffle Xu Subject: [PATCH 4.19 13/39] aoe: register default groups with device_add_disk() Date: Wed, 10 Mar 2021 14:24:21 +0100 Message-Id: <20210310132320.147185819@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.708237392@linuxfoundation.org> References: <20210310132319.708237392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Hannes Reinecke commit 95cf7809bf9169fec4e4b7bb24b8069d8f354f96 upstream. Register default sysfs groups during device_add_disk() to avoid a race condition with udev during startup. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Acked-by: Ed L. Cachin Reviewed-by: Bart Van Assche Signed-off-by: Jens Axboe Signed-off-by: Jeffle Xu Signed-off-by: Greg Kroah-Hartman --- 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(-) --- 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); --- 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); --- 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);