Re: [PATCH v3] block: genhd: don't call probe function with major_names_lock held

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

 



On Sun, Aug 15, 2021 at 04:49:55PM +0900, Tetsuo Handa wrote:
> On 2021/08/15 16:06, Greg KH wrote:
> > On Sun, Aug 15, 2021 at 03:52:45PM +0900, Tetsuo Handa wrote:
> >> --- a/include/linux/genhd.h
> >> +++ b/include/linux/genhd.h
> >> @@ -303,9 +303,9 @@ struct gendisk *__blk_alloc_disk(int node);
> >>  void blk_cleanup_disk(struct gendisk *disk);
> >>  
> >>  int __register_blkdev(unsigned int major, const char *name,
> >> -		void (*probe)(dev_t devt));
> >> +		      void (*probe)(dev_t devt), struct module *owner);
> >>  #define register_blkdev(major, name) \
> >> -	__register_blkdev(major, name, NULL)
> >> +	__register_blkdev(major, name, NULL, NULL)
> >>  void unregister_blkdev(unsigned int major, const char *name);
> > 
> > Do not force modules to put their own THIS_MODULE macro as a parameter,
> > put it in the .h file so that it happens automagically, much like the
> > usb_register() define in include/linux/usb.h is created.
> 
> Sure. We can do like below.
> 
> diff --git a/include/linux/genhd.h b/include/linux/genhd.h
> index 13b34177cc85..70f00641fa11 100644
> --- a/include/linux/genhd.h
> +++ b/include/linux/genhd.h
> @@ -302,10 +302,12 @@ extern void put_disk(struct gendisk *disk);
>  struct gendisk *__blk_alloc_disk(int node);
>  void blk_cleanup_disk(struct gendisk *disk);
>  
> -int __register_blkdev(unsigned int major, const char *name,
> -		void (*probe)(dev_t devt));
> +int ____register_blkdev(unsigned int major, const char *name,
> +			void (*probe)(dev_t devt), struct module *owner);
> +#define __register_blkdev(major, name, probe) \
> +	____register_blkdev(major, name, probe, THIS_MODULE)
>  #define register_blkdev(major, name) \
> -	__register_blkdev(major, name, NULL)
> +	____register_blkdev(major, name, NULL, NULL)

Why stop at 4 _ characters?

{sigh}

I think you need a new naming scheme here...

> > 
> > If you do that, you can probably get rid of the __register_blkdev()
> > direct calls as well...
> 
> I assume "automagically" implies "do not patch individual unregister_blkdev() /
> __register_blkdev() callers". But "removing __register_blkdev() direct calls"
> requires "patching individual __register_blkdev() callers". I didn't catch
> what you suggested here.

Yes, that is a different thing, sorry for the confusion.

> Anyway, since this patch should be backported to 5.11+ kernels, lines changed
> should be kept minimal. We can do whatever remapping after this patch.

Don't worry about backports, fix it properly first.

thanks,

greg k-h



[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