All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Danil Kipnis <danil.kipnis@cloud.ionos.com>
Cc: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org,
	dledford@redhat.com, rdunlap@infradead.org, axboe@kernel.dk,
	bvanassche@acm.org, leon@kernel.org, jinpu.wang@cloud.ionos.com,
	guoqing.jiang@cloud.ionos.com
Subject: Re: [PATCH] rnbd: fix compilation error when CONFIG_MODULES is disabled
Date: Fri, 22 May 2020 21:24:41 -0300	[thread overview]
Message-ID: <20200523002441.GA9180@ziepe.ca> (raw)
In-Reply-To: <20200521185909.457245-1-danil.kipnis@cloud.ionos.com>

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

  reply	other threads:[~2020-05-23  0:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19 18:03 linux-next: Tree for May 19 Stephen Rothwell
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 [this message]
2020-05-20  0:24 ` linux-next: Tree for May 19 (i2c/busses/i2c-mt65xx.o) Randy Dunlap
2020-05-20  8:46   ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200523002441.GA9180@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=danil.kipnis@cloud.ionos.com \
    --cc=dledford@redhat.com \
    --cc=guoqing.jiang@cloud.ionos.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=leon@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.