Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4092234ooa; Tue, 14 Aug 2018 00:35:35 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzZoe4wheaggaXcuffUnOePsQMCcGV2shO5mBipFDd3hH1T+A+WtnB2r36KESiivLydARvv X-Received: by 2002:a63:342:: with SMTP id 63-v6mr19528042pgd.290.1534232135567; Tue, 14 Aug 2018 00:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534232135; cv=none; d=google.com; s=arc-20160816; b=S6Mk+VNouM4UdYOCtMv06Ht6DxEums7cXv3lXors7yeghoOP5Za4kN8Xv1EdsMHKH8 EymsSbU9XxTTRbKXPUE4WC1prlcfNqTsjQ/MqHbbyoXdqiQ90fd1iwiIyy7pPbob7DRu TLhQ0/frlizXcDxLToH7uXDBBjhr6I5p/HU1VWmx9d68LPJH+Ko3X8qmnUG2TkUgEJO1 g3dzO1gl5BbOhRUd/cU0AoZN+Ecy9Mzt8CtmdtPoQYJWEOOost5GKPe7QRpoFyazUElG dA7No7k3DMX9q3TFCOy3W/PZ+ClEEcQiOH/uo5L2WdhiopWsvOwkkf+TeLRlQ03GVg4j Vphg== 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=eeeyIwufgcarPfIZQEbst4iB2wqUVEVhb+75GvuQaDI=; b=nA8FFSW9ildCKt59QJKK+nO5Dg9XhUAyTM1RyA735XwPaSS8ephqV3mqYkP5voMNo6 lG6HlWEFZVP/YW/3uxtJfX7Qf5HCv9ZqULdzr3ZXBg5AasPmJ8r6HzphGpavhKPQbdmc xsFowjv3dFZuE4OQJVZpQhIAvy/25mxSvMMrqt0q8L6ZYC8YlpCOUJpEf9FnmTbFmcbn OReVRFnOi9q76yM1KEL3/v550bjUnhu4RJqK5AqEkH+EDC9VAVonx4Opo97KZFQVU4IE tBlFMATTEvJmYkzsinRR7LX0eyoLQ81NcvSFmSEW0XmbLA3aLs1jEk5kMtXk2B6PzHQF eIFg== 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 3-v6si20485887pgr.554.2018.08.14.00.35.20; Tue, 14 Aug 2018 00:35:35 -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 S1732162AbeHNKTl (ORCPT + 99 others); Tue, 14 Aug 2018 06:19:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:54256 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731228AbeHNKTI (ORCPT ); Tue, 14 Aug 2018 06:19:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1B4DDAF5B; 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 , Minchan Kim , Nitin Gupta Subject: [PATCH 4/5] zram: register default groups with device_add_disk() Date: Tue, 14 Aug 2018 09:33:04 +0200 Message-Id: <20180814073305.87255-5-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 Register default sysfs groups during device_add-disk() to avoid a race condition with udev during startup. Signed-off-by: Hannes Reinecke Cc: Minchan Kim Cc: Nitin Gupta Reviewed-by: Christoph Hellwig --- drivers/block/zram/zram_drv.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 2907a8156aaf..fc3626cb7fe5 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1618,6 +1618,11 @@ static const struct attribute_group zram_disk_attr_group = { .attrs = zram_disk_attrs, }; +static const struct attribute_group *zram_disk_attr_groups[] = { + &zram_disk_attr_group, + NULL, +}; + /* * Allocate and initialize new zram device. the function returns * '>= 0' device_id upon success, and negative value otherwise. @@ -1698,24 +1703,14 @@ static int zram_add(void) zram->disk->queue->backing_dev_info->capabilities |= (BDI_CAP_STABLE_WRITES | BDI_CAP_SYNCHRONOUS_IO); - add_disk(zram->disk); - - ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj, - &zram_disk_attr_group); - if (ret < 0) { - pr_err("Error creating sysfs group for device %d\n", - device_id); - goto out_free_disk; - } + device_add_disk(NULL, zram->disk, zram_disk_attr_groups); + strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); zram_debugfs_register(zram); pr_info("Added device: %s\n", zram->disk->disk_name); return device_id; -out_free_disk: - del_gendisk(zram->disk); - put_disk(zram->disk); out_free_queue: blk_cleanup_queue(queue); out_free_idr: @@ -1744,15 +1739,6 @@ static int zram_remove(struct zram *zram) mutex_unlock(&bdev->bd_mutex); zram_debugfs_unregister(zram); - /* - * Remove sysfs first, so no one will perform a disksize - * store while we destroy the devices. This also helps during - * hot_remove -- zram_reset_device() is the last holder of - * ->init_lock, no later/concurrent disksize_store() or any - * other sysfs handlers are possible. - */ - sysfs_remove_group(&disk_to_dev(zram->disk)->kobj, - &zram_disk_attr_group); /* Make sure all the pending I/O are finished */ fsync_bdev(bdev); -- 2.12.3