From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751613AbdBOPlR (ORCPT ); Wed, 15 Feb 2017 10:41:17 -0500 Received: from mail-it0-f42.google.com ([209.85.214.42]:35449 "EHLO mail-it0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751328AbdBOPlP (ORCPT ); Wed, 15 Feb 2017 10:41:15 -0500 Subject: Re: [PATCH] block: do not allow updates through sysfs until registration completes To: Tahsin Erdogan , linux-block@vger.kernel.org References: <20170215032738.22689-1-tahsin@google.com> Cc: linux-kernel@vger.kernel.org From: Jens Axboe Message-ID: <95afa7b1-86c2-34ff-3870-8a32412a3a45@kernel.dk> Date: Wed, 15 Feb 2017 08:41:13 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170215032738.22689-1-tahsin@google.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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