From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759333AbbJ3QZg (ORCPT ); Fri, 30 Oct 2015 12:25:36 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:35266 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753517AbbJ3QZe (ORCPT ); Fri, 30 Oct 2015 12:25:34 -0400 Date: Fri, 30 Oct 2015 09:25:32 -0700 From: Shaohua Li To: Roman Gushchin Cc: Neil Brown , "linux-kernel@vger.kernel.org" , "linux-raid@vger.kernel.org" Subject: Re: [PATCH] md/raid5: fix locking in handle_stripe_clean_event() Message-ID: <20151030162443.GA31413@kernel.org> References: <1446022340-1453-1-git-send-email-klamm@yandex-team.ru> <87r3kebjgx.fsf@notabene.neil.brown.name> <30651446128148@webcorp02d.yandex-team.ru> <87ziz1w33r.fsf@notabene.neil.brown.name> <47541446213767@webcorp02e.yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <47541446213767@webcorp02e.yandex-team.ru> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 30, 2015 at 05:02:47PM +0300, Roman Gushchin wrote: > > Isn't the 4.1 fix just: > > > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > > index e5befa356dbe..6e4350a78257 100644 > > --- a/drivers/md/raid5.c > > +++ b/drivers/md/raid5.c > > @@ -3522,16 +3522,16 @@ returnbi: > >                   * no updated data, so remove it from hash list and the stripe > >                   * will be reinitialized > >                   */ > > - spin_lock_irq(&conf->device_lock); > >  unhash: > > + spin_lock_irq(conf->hash_locks + sh->hash_lock_index); > >                  remove_hash(sh); > > + spin_unlock_irq(conf->hash_locks + sh->hash_lock_index); > >                  if (head_sh->batch_head) { > >                          sh = list_first_entry(&sh->batch_list, > >                                                struct stripe_head, batch_list); > >                          if (sh != head_sh) > >                                          goto unhash; > >                  } > > - spin_unlock_irq(&conf->device_lock); > >                  sh = head_sh; > > > >                  if (test_bit(STRIPE_SYNC_REQUESTED, &sh->state)) > > > > ?? > > In my opion, this patch looks correct, although it seems to me, that there is an another issue here. > > >                  if (head_sh->batch_head) { > >                          sh = list_first_entry(&sh->batch_list, > >                                                struct stripe_head, batch_list); > >                          if (sh != head_sh) > >                                          goto unhash; > >                  } > > With a patch above this code will be executed without taking any locks. It it correct? > In my opinion, we need to take at least sh->stripe_lock, which protects sh->batch_head. > Or do I miss something? > > If you want, we can handle this issue separately. The batch_list list doesn't need the protection. Only the remove_hash() need it. Thanks, Shaohua