[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CE661700.7BC5%Tomoki.Sekiyama@hds.com>
Date: Mon, 23 Sep 2013 20:11:55 +0000
From: Tomoki Sekiyama <tomoki.sekiyama@....com>
To: Tejun Heo <tj@...nel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"axboe@...nel.dk" <axboe@...nel.dk>,
Seiji Aguchi <seiji.aguchi@....com>,
"vgoyal@...hat.com" <vgoyal@...hat.com>,
"majianpeng@...il.com" <majianpeng@...il.com>
Subject: Re: [PATCH v2 1/2] elevator: Fix a race in elevator switching and
md device initialization
Hi Tejun,
Thank you for the review.
On 9/22/13 13:04 , "Tejun Heo" <tj@...nel.org> wrote:
>On Fri, Aug 30, 2013 at 06:47:07PM -0400, Tomoki Sekiyama wrote:
>> @@ -739,9 +739,17 @@ blk_init_allocated_queue(struct request_queue *q,
>>request_fn_proc *rfn,
>>
>> q->sg_reserved_size = INT_MAX;
>>
>> + /* Protect q->elevator from elevator_change */
>> + mutex_lock(&q->sysfs_lock);
>> +
>> /* init elevator */
>> - if (elevator_init(q, NULL))
>> + if (elevator_init(q, NULL)) {
>> + mutex_unlock(&q->sysfs_lock);
>> return NULL;
>> + }
>> +
>> + mutex_unlock(&q->sysfs_lock);
>> +
>> return q;
>> }
>> EXPORT_SYMBOL(blk_init_allocated_queue);
>> diff --git a/block/elevator.c b/block/elevator.c
>> index 668394d..02d4390 100644
>> --- a/block/elevator.c
>> +++ b/block/elevator.c
>> @@ -186,6 +186,12 @@ int elevator_init(struct request_queue *q, char
>>*name)
>> struct elevator_type *e = NULL;
>> int err;
>>
>> + /*
>> + * q->sysfs_lock must be held to provide mutual exclusion between
>> + * elevator_switch() and here.
>> + */
>> + lockdep_assert_held(&q->sysfs_lock);
>> +
>> if (unlikely(q->elevator))
>> return 0;
>
>Hmm... why aren't we just changing elevator_init() to grab sysfs_lock
>where necessary?
The locking cannot be moved into elevator_init() because it is called
from elevator_switch() path, where the request_queue's sysfs_lock is
already taken.
> It'd be more consistent with elevator_exit() that way.
What elevator_exit() locks is elevator_queue's sysfs_lock, not
request_queue's sysfs_lock. What we need here is request_queue's
sysfs_lock.
>Thanks.
>
>--
>Tejun
Thanks,
Tomoki Sekiyama
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists