Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: Jens Axboe Newsgroups: linux.kernel Subject: Re: [PATCH] block: do not allow updates through sysfs until registration completes Date: Wed, 15 Feb 2017 16:50:01 +0100 Message-ID: References: X-Original-To: Tahsin Erdogan , linux-block@vger.kernel.org Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=JohjVLpjYWsjZ3M4vZFsmj9k4ePlrj3AWBk5RDzC9Es=; b=bkVjjGXX5wzd4mQrHgZLJiJg3PDrkoG2G2vHvVkxLC90i7azJ2C0LysAyA9jjC4GaH T3rOrdv5EDs14omDGjv/VPRzdlcgW/4qm9uV2EvHFQB3/1S4fQh0X095gwru8eKcu3dj wnueMTXKg/v9tRv+hmcjZ2XsjMsKanRk6kl+HP67hDxvJjMDDcfysPP6S8vTSqoqYDEV aGzrDIngGOWhU7RgJ5p4MbXpWX0NQtHTgE7aQqs3jvNX1w3u+U6ldtCodgEDVDrPNJYY wlfk7OG2AggnunlS5qK5UMmy/tlxlHbfEw+tmaHCoIRI5uBcJMHkYGqpT/5LD4ZW2koK +MnQ== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=JohjVLpjYWsjZ3M4vZFsmj9k4ePlrj3AWBk5RDzC9Es=; b=JhdMiwG66mCA8K617pRLtanV19ntjAoCqVCSFhKZQROr6xI3JwT4v3M+m0zcb6Bp1g XFNCxKb2VNTxcbEgTbyoDO+gwh13/g5jsY/K9aagNGOP12YQT6yccBXjoEEeW8qkfvRG 2L8ZhtGL1xuLrAo1d+y5oTnyE60yHzCUnINROgeb+z3p8yy6mH5KNosDKF4bR21nhk+x ZYRJ91ri+yWEVCHGgqvmEGFlufMgJM2HvgoXXtDAv6eH1kh3OCucwA7OML7hwV7F/nd+ b1Xxme1Xjt7anMR23YbdJCL2R4DipB+7FuwjXqKIatarCH1loXHVRivzZrPDINRPlcy8 c6Gg== X-Gm-Message-State: AMke39k2UWc6fdGswv7S/cLVjCmX4EWtJq0KwRD9rf96D4JaZbtuzFSEEhxj2fcIfTaM0Q== X-Received: by 10.36.81.65 with SMTP id s62mr9544336ita.33.1487173274937; Wed, 15 Feb 2017 07:41:14 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 19 Organization: linux.* mail to news gateway X-Original-Cc: linux-kernel@vger.kernel.org X-Original-Date: Wed, 15 Feb 2017 08:41:13 -0700 X-Original-Message-ID: <95afa7b1-86c2-34ff-3870-8a32412a3a45@kernel.dk> X-Original-References: <20170215032738.22689-1-tahsin@google.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1581409 On 02/14/2017 08:27 PM, Tahsin Erdogan wrote: > When a new disk shows up, sysfs queue directory is created before elevator > is registered. This allows a user to attempt a scheduler switch even though > the initial registration hasn't completed yet. > > In one scenario, blk_register_queue() calls elv_register_queue() and > right before cfq_registered_queue() is called, another process executes > elevator_switch() and replaces q->elevator with deadline scheduler. When > cfq_registered_queue() executes it interprets e->elevator_data as struct > cfq_data even though it is actually struct deadline_data. > > Grab q->sysfs_lock in blk_register_queue() to synchronize with sysfs > callers. Thanks, this looks good to me - both the grabbing of the lock, and the ordering wrt UDEV_ADD. Queued up. -- Jens Axboe