Re: [PATCH V5 1/3] percpu_ref: add percpu_ref_is_initialized for MD

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

 



On Sun, Sep 27, 2020 at 02:26:52PM +0800, Ming Lei wrote:
> MD code uses perpcu-refcount internal to check if this percpu-refcount
> variable is initialized, this way is a hack.
> 
> Add percpu_ref_is_initialized for MD so that the hack can be avoided.
> 
> Acked-by: Song Liu <song@xxxxxxxxxx>
> Suggested-by: Jens Axboe <axboe@xxxxxxxxx>
> Tested-by: Veronika Kabatova <vkabatov@xxxxxxxxxx>
> Cc: Song Liu <song@xxxxxxxxxx>
> Cc: linux-raid@xxxxxxxxxxxxxxx
> Cc: Sagi Grimberg <sagi@xxxxxxxxxxx>
> Cc: Tejun Heo <tj@xxxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>
> Cc: Jens Axboe <axboe@xxxxxxxxx>
> Cc: Bart Van Assche <bvanassche@xxxxxxx>
> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
> ---
>  drivers/md/md.c                 | 2 +-
>  include/linux/percpu-refcount.h | 1 +
>  lib/percpu-refcount.c           | 6 ++++++
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index de8419b7ae98..241ff618d84e 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -5631,7 +5631,7 @@ static void no_op(struct percpu_ref *r) {}
>  
>  int mddev_init_writes_pending(struct mddev *mddev)
>  {
> -	if (mddev->writes_pending.percpu_count_ptr)
> +	if (percpu_ref_is_initialized(&mddev->writes_pending))
>  		return 0;

I'd much rather use a flag in the containing mddev structure then
exposing this new "API".  That mddev code is pretty gross to be honest,
we should just initialize the percpu_ref once instea of such a hack.



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux