Re: [PATCH] md:raid1/10: avoid unnecessary locking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 10 2017, shli@xxxxxxxxxx wrote:

> From: Shaohua Li <shli@xxxxxx>
>
> If we add bios to block plugging list, locking is unnecessry, since the block
> unplug is guaranteed not to run at that time.

Yes, that make sense.  Thanks

Reviewed-by: NeilBrown <neilb@xxxxxxxx>


>
> Cc: NeilBrown <neilb@xxxxxxxx>
> Signed-off-by: Shaohua Li <shli@xxxxxx>
> ---
>  drivers/md/raid1.c  | 7 +++----
>  drivers/md/raid10.c | 7 +++----
>  2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 7c1f73398800..a17ed6218d51 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -1529,17 +1529,16 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
>  			plug = container_of(cb, struct raid1_plug_cb, cb);
>  		else
>  			plug = NULL;
> -		spin_lock_irqsave(&conf->device_lock, flags);
>  		if (plug) {
>  			bio_list_add(&plug->pending, mbio);
>  			plug->pending_cnt++;
>  		} else {
> +			spin_lock_irqsave(&conf->device_lock, flags);
>  			bio_list_add(&conf->pending_bio_list, mbio);
>  			conf->pending_count++;
> -		}
> -		spin_unlock_irqrestore(&conf->device_lock, flags);
> -		if (!plug)
> +			spin_unlock_irqrestore(&conf->device_lock, flags);
>  			md_wakeup_thread(mddev->thread);
> +		}
>  	}
>  
>  	r1_bio_write_done(r1_bio);
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 6b86a0032cf8..4343d7ff9916 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1282,17 +1282,16 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio,
>  		plug = container_of(cb, struct raid10_plug_cb, cb);
>  	else
>  		plug = NULL;
> -	spin_lock_irqsave(&conf->device_lock, flags);
>  	if (plug) {
>  		bio_list_add(&plug->pending, mbio);
>  		plug->pending_cnt++;
>  	} else {
> +		spin_lock_irqsave(&conf->device_lock, flags);
>  		bio_list_add(&conf->pending_bio_list, mbio);
>  		conf->pending_count++;
> -	}
> -	spin_unlock_irqrestore(&conf->device_lock, flags);
> -	if (!plug)
> +		spin_unlock_irqrestore(&conf->device_lock, flags);
>  		md_wakeup_thread(mddev->thread);
> +	}
>  }
>  
>  static void raid10_write_request(struct mddev *mddev, struct bio *bio,
> -- 
> 2.11.0

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux