Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1201087

Re: [PATCH 1/3] zpool: add zpool_has_pool()

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH 1/3] zpool: add zpool_has_pool()
Date 2015-08-05 22:10 +0200
Message-ID <pUdaG-3fe-23@gated-at.bofh.it> (permalink)
References <pU7eX-2WR-29@gated-at.bofh.it> <pU7eY-2WR-47@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed,  5 Aug 2015 09:46:41 -0400 Dan Streetman <ddstreet@ieee.org> wrote:

> Add zpool_has_pool() function, indicating if the specified type of zpool
> is available (i.e. zsmalloc or zbud).  This allows checking if a pool is
> available, without actually trying to allocate it, similar to
> crypto_has_alg().
> 
> This is used by a following patch to zswap that enables the dynamic
> runtime creation of zswap zpools.
> 
> ...
>
>  /**
> + * zpool_has_pool() - Check if the pool driver is available
> + * @type	The type of the zpool to check (e.g. zbud, zsmalloc)
> + *
> + * This checks if the @type pool driver is available.
> + *
> + * Returns: true if @type pool is available, false if not
> + */
> +bool zpool_has_pool(char *type)
> +{
> +	struct zpool_driver *driver = zpool_get_driver(type);
> +
> +	if (!driver) {
> +		request_module("zpool-%s", type);
> +		driver = zpool_get_driver(type);
> +	}
> +
> +	if (!driver)
> +		return false;
> +
> +	zpool_put_driver(driver);
> +	return true;
> +}

This looks racy: after that zpool_put_driver() has completed, an rmmod
will invalidate zpool_has_pool()'s return value.

If there's some reason why this can't happen, can we please have a code
comment which reveals that reason?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] zpool: add zpool_has_pool() Dan Streetman <ddstreet@ieee.org> - 2015-08-05 15:50 +0200
  Re: [PATCH 1/3] zpool: add zpool_has_pool() Andrew Morton <akpm@linux-foundation.org> - 2015-08-05 22:10 +0200
    Re: [PATCH 1/3] zpool: add zpool_has_pool() Andrew Morton <akpm@linux-foundation.org> - 2015-08-06 00:10 +0200
      Re: [PATCH 1/3] zpool: add zpool_has_pool() Seth Jennings <sjennings@variantweb.net> - 2015-08-07 00:00 +0200
        Re: [PATCH 1/3] zpool: add zpool_has_pool() Seth Jennings <sjennings@variantweb.net> - 2015-08-07 05:40 +0200
      Re: [PATCH 1/3] zpool: add zpool_has_pool() Dan Streetman <ddstreet@ieee.org> - 2015-08-14 22:10 +0200
    Re: [PATCH 1/3] zpool: add zpool_has_pool() Dan Streetman <ddstreet@ieee.org> - 2015-08-06 00:10 +0200
      [PATCH] zpool: clarification comment for zpool_has_pool Dan Streetman <ddstreet@ieee.org> - 2015-08-06 20:00 +0200

csiph-web