Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
* Re: linux-next: Tree for May 19 (block/rnbd/)
       [not found] <20200520040354.3e619918@canb.auug.org.au>
@ 2020-05-19 18:59 ` Randy Dunlap
  2020-05-20 10:12   ` Danil Kipnis
  2020-05-21 17:50   ` [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled Danil Kipnis
  0 siblings, 2 replies; 6+ messages in thread
From: Randy Dunlap @ 2020-05-19 18:59 UTC (permalink / raw)
  To: Stephen Rothwell, Linux Next Mailing List
  Cc: Linux Kernel Mailing List, linux-block, Danil Kipnis, Jack Wang

On 5/19/20 11:03 AM, Stephen Rothwell wrote:
> Hi all,
> 
> News: there will be no linux-next release tomorrow.
> 
> Changes since 20200518:
> 

seen on i386:

when CONFIG_MODULES is not set/enabled:

../drivers/block/rnbd/rnbd-clt-sysfs.c: In function 'rnbd_clt_remove_dev_symlink':
../drivers/block/rnbd/rnbd-clt-sysfs.c:435:39: error: implicit declaration of function 'module_is_live'; did you mean 'module_driver'? [-Werror=implicit-function-declaration]
  if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
                                       ^~~~~~~~~~~~~~
                                       module_driver


-- 
~Randy
Reported-by: Randy Dunlap <rdunlap@infradead.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: linux-next: Tree for May 19 (block/rnbd/)
  2020-05-19 18:59 ` linux-next: Tree for May 19 (block/rnbd/) Randy Dunlap
@ 2020-05-20 10:12   ` Danil Kipnis
  2020-05-21 17:50   ` [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled Danil Kipnis
  1 sibling, 0 replies; 6+ messages in thread
From: Danil Kipnis @ 2020-05-20 10:12 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Stephen Rothwell, Linux Next Mailing List,
	Linux Kernel Mailing List, linux-block, Jack Wang

Hi Randy,

On Tue, May 19, 2020 at 8:59 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> On 5/19/20 11:03 AM, Stephen Rothwell wrote:
> > Hi all,
> >
> > News: there will be no linux-next release tomorrow.
> >
> > Changes since 20200518:
> >
>
> seen on i386:
>
> when CONFIG_MODULES is not set/enabled:
>
> ../drivers/block/rnbd/rnbd-clt-sysfs.c: In function 'rnbd_clt_remove_dev_symlink':
> ../drivers/block/rnbd/rnbd-clt-sysfs.c:435:39: error: implicit declaration of function 'module_is_live'; did you mean 'module_driver'? [-Werror=implicit-function-declaration]
>   if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
>                                        ^~~~~~~~~~~~~~
>                                        module_driver
>
>
> --
> ~Randy
> Reported-by: Randy Dunlap <rdunlap@infradead.org>

Looking into this, thank you

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled
  2020-05-19 18:59 ` linux-next: Tree for May 19 (block/rnbd/) Randy Dunlap
  2020-05-20 10:12   ` Danil Kipnis
@ 2020-05-21 17:50   ` Danil Kipnis
  2020-05-21 18:39     ` Randy Dunlap
  1 sibling, 1 reply; 6+ messages in thread
From: Danil Kipnis @ 2020-05-21 17:50 UTC (permalink / raw)
  To: linux-block, linux-rdma, dledford, jgg
  Cc: axboe, bvanassche, leon, danil.kipnis, jinpu.wang, guoqing.jiang,
	Randy Dunlap

module_is_live function is only defined when CONFIG_MODULES is enabled.
Use try_module_get instead to check whether the module is being removed.

When module unload and manuall unmapping is happening in parallel, we can
try removing the symlink twice: rnbd_client_exit vs. rnbd_clt_unmap_dev_store.

This is probably not the best way to deal with this race in general, but for
now this fixes the compilation issue when CONFIG_MODULES is disabled and has
no functional impact. Regression tests passed.

Fixes: 1eb54f8f5dd8 block/rnbd: client: sysfs interface functions
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Suggested-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
---
 drivers/block/rnbd/rnbd-clt-sysfs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
index a4508fcc7ffe..73d7cb40abb3 100644
--- a/drivers/block/rnbd/rnbd-clt-sysfs.c
+++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
@@ -428,12 +428,14 @@ static struct attribute *rnbd_dev_attrs[] = {
 void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
 {
 	/*
-	 * The module_is_live() check is crucial and helps to avoid annoying
-	 * sysfs warning raised in sysfs_remove_link(), when the whole sysfs
-	 * path was just removed, see rnbd_close_sessions().
+	 * The module unload rnbd_client_exit path is racing with unmapping of the
+	 * last single device from the sysfs manually i.e. rnbd_clt_unmap_dev_store()
+	 * leading to a sysfs warning because of sysfs link already was removed already.
 	 */
-	if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
+	if (strlen(dev->blk_symlink_name) && try_module_get(THIS_MODULE)) {
 		sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name);
+		module_put(THIS_MODULE);
+	}
 }
 
 static struct kobj_type rnbd_dev_ktype = {

base-commit: f11e0ec55f0c80ff47693af2150bad5db0e20387
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled
  2020-05-21 17:50   ` [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled Danil Kipnis
@ 2020-05-21 18:39     ` Randy Dunlap
  2020-05-21 18:59       ` Danil Kipnis
  0 siblings, 1 reply; 6+ messages in thread
From: Randy Dunlap @ 2020-05-21 18:39 UTC (permalink / raw)
  To: Danil Kipnis, linux-block, linux-rdma, dledford, jgg
  Cc: axboe, bvanassche, leon, jinpu.wang, guoqing.jiang

On 5/21/20 10:50 AM, Danil Kipnis wrote:
> module_is_live function is only defined when CONFIG_MODULES is enabled.
> Use try_module_get instead to check whether the module is being removed.
> 
> When module unload and manuall unmapping is happening in parallel, we can
> try removing the symlink twice: rnbd_client_exit vs. rnbd_clt_unmap_dev_store.
> 
> This is probably not the best way to deal with this race in general, but for
> now this fixes the compilation issue when CONFIG_MODULES is disabled and has
> no functional impact. Regression tests passed.
> 
> Fixes: 1eb54f8f5dd8 block/rnbd: client: sysfs interface functions

The Fixes: line has a specific expected format. It should be like this:

Fixes: 1eb54f8f5dd8 ("block/rnbd: client: sysfs interface functions")

> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Suggested-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
> Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested


Thanks.

> ---
>  drivers/block/rnbd/rnbd-clt-sysfs.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
> index a4508fcc7ffe..73d7cb40abb3 100644
> --- a/drivers/block/rnbd/rnbd-clt-sysfs.c
> +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
> @@ -428,12 +428,14 @@ static struct attribute *rnbd_dev_attrs[] = {
>  void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
>  {
>  	/*
> -	 * The module_is_live() check is crucial and helps to avoid annoying
> -	 * sysfs warning raised in sysfs_remove_link(), when the whole sysfs
> -	 * path was just removed, see rnbd_close_sessions().
> +	 * The module unload rnbd_client_exit path is racing with unmapping of the
> +	 * last single device from the sysfs manually i.e. rnbd_clt_unmap_dev_store()
> +	 * leading to a sysfs warning because of sysfs link already was removed already.
>  	 */
> -	if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
> +	if (strlen(dev->blk_symlink_name) && try_module_get(THIS_MODULE)) {
>  		sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name);
> +		module_put(THIS_MODULE);
> +	}
>  }
>  
>  static struct kobj_type rnbd_dev_ktype = {
> 
> base-commit: f11e0ec55f0c80ff47693af2150bad5db0e20387
> 


-- 
~Randy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled
  2020-05-21 18:39     ` Randy Dunlap
@ 2020-05-21 18:59       ` Danil Kipnis
  2020-05-23  0:24         ` Jason Gunthorpe
  0 siblings, 1 reply; 6+ messages in thread
From: Danil Kipnis @ 2020-05-21 18:59 UTC (permalink / raw)
  To: linux-block, linux-rdma, dledford, jgg, rdunlap
  Cc: axboe, bvanassche, leon, danil.kipnis, jinpu.wang, guoqing.jiang

module_is_live function is only defined when CONFIG_MODULES is enabled.
Use try_module_get instead to check whether the module is being removed.

When module unload and manuall unmapping is happening in parallel, we can
try removing the symlink twice: rnbd_client_exit vs. rnbd_clt_unmap_dev_store.

This is probably not the best way to deal with this race in general, but for
now this fixes the compilation issue when CONFIG_MODULES is disabled and has
no functional impact. Regression tests passed.

Fixes: 1eb54f8f5dd8 ("block/rnbd: client: sysfs interface functions")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Suggested-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
---
v1->v2 Fix format of the "Fixes:" line
       Add Acked-by Randy Runlap <rdunlap@infradead.org>
 drivers/block/rnbd/rnbd-clt-sysfs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
index a4508fcc7ffe..73d7cb40abb3 100644
--- a/drivers/block/rnbd/rnbd-clt-sysfs.c
+++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
@@ -428,12 +428,14 @@ static struct attribute *rnbd_dev_attrs[] = {
 void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
 {
 	/*
-	 * The module_is_live() check is crucial and helps to avoid annoying
-	 * sysfs warning raised in sysfs_remove_link(), when the whole sysfs
-	 * path was just removed, see rnbd_close_sessions().
+	 * The module unload rnbd_client_exit path is racing with unmapping of the
+	 * last single device from the sysfs manually i.e. rnbd_clt_unmap_dev_store()
+	 * leading to a sysfs warning because of sysfs link already was removed already.
 	 */
-	if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
+	if (strlen(dev->blk_symlink_name) && try_module_get(THIS_MODULE)) {
 		sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name);
+		module_put(THIS_MODULE);
+	}
 }
 
 static struct kobj_type rnbd_dev_ktype = {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled
  2020-05-21 18:59       ` Danil Kipnis
@ 2020-05-23  0:24         ` Jason Gunthorpe
  0 siblings, 0 replies; 6+ messages in thread
From: Jason Gunthorpe @ 2020-05-23  0:24 UTC (permalink / raw)
  To: Danil Kipnis
  Cc: linux-block, linux-rdma, dledford, rdunlap, axboe, bvanassche,
	leon, jinpu.wang, guoqing.jiang

On Thu, May 21, 2020 at 08:59:09PM +0200, Danil Kipnis wrote:
> module_is_live function is only defined when CONFIG_MODULES is enabled.
> Use try_module_get instead to check whether the module is being removed.
> 
> When module unload and manuall unmapping is happening in parallel, we can
> try removing the symlink twice: rnbd_client_exit vs. rnbd_clt_unmap_dev_store.
> 
> This is probably not the best way to deal with this race in general, but for
> now this fixes the compilation issue when CONFIG_MODULES is disabled and has
> no functional impact. Regression tests passed.
> 
> Fixes: 1eb54f8f5dd8 ("block/rnbd: client: sysfs interface functions")
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Suggested-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
> Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
> Acked-by: Randy Dunlap <rdunlap@infradead.org>
> v1->v2 Fix format of the "Fixes:" line
>        Add Acked-by Randy Runlap <rdunlap@infradead.org>
>  drivers/block/rnbd/rnbd-clt-sysfs.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
> index a4508fcc7ffe..73d7cb40abb3 100644
> +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
> @@ -428,12 +428,14 @@ static struct attribute *rnbd_dev_attrs[] = {
>  void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
>  {
>  	/*
> -	 * The module_is_live() check is crucial and helps to avoid annoying
> -	 * sysfs warning raised in sysfs_remove_link(), when the whole sysfs
> -	 * path was just removed, see rnbd_close_sessions().
> +	 * The module unload rnbd_client_exit path is racing with unmapping of the
> +	 * last single device from the sysfs manually i.e. rnbd_clt_unmap_dev_store()
> +	 * leading to a sysfs warning because of sysfs link already was removed already.
>  	 */
> -	if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
> +	if (strlen(dev->blk_symlink_name) && try_module_get(THIS_MODULE)) {
>  		sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name);
> +		module_put(THIS_MODULE);
> +	}
>  }

This is a really gross thing to do, please fix it properly in future

Applied to for-next

Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200520040354.3e619918@canb.auug.org.au>
2020-05-19 18:59 ` linux-next: Tree for May 19 (block/rnbd/) Randy Dunlap
2020-05-20 10:12   ` Danil Kipnis
2020-05-21 17:50   ` [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled Danil Kipnis
2020-05-21 18:39     ` Randy Dunlap
2020-05-21 18:59       ` Danil Kipnis
2020-05-23  0:24         ` Jason Gunthorpe

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git