From: Dan Streetman <ddstreet@ieee.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Seth Jennings <sjennings@variantweb.net>,
Linux-MM <linux-mm@kvack.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] zpool: add zpool_has_pool()
Date: Wed, 5 Aug 2015 18:00:26 -0400 [thread overview]
Message-ID: <CALZtONDNYyKEdk2fc40ePH4Y+vOcUE-D7OG1DRekgSxLgVYKeA@mail.gmail.com> (raw)
In-Reply-To: <20150805130836.16c42cd0a9fe6f4050cf0620@linux-foundation.org>
On Wed, Aug 5, 2015 at 4:08 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> 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.
the true/false return value is only a snapshot of that moment in time;
zswap's use of this is only to validate that the user-provided zpool
name is valid; if this fails, zswap will just return failure to the
user (or if this happens at init-time, falls back to LZO). If this
succeeds, zswap still must use zpool_create_pool() which will fail if
the requested module can't be loaded.
essentially zswap does:
if (!zpool_has_pool(zpool_type) || !crypto_has_comp(compressor_type))
return -EINVAL;
that allows it to check that the requested zpool and compressor types
are valid, before actually creating anything. The creation of the
zpool and compressor do have error handling if either of them fail.
>
> If there's some reason why this can't happen, can we please have a code
> comment which reveals that reason?
zpool_create_pool() should work if this returns true, unless as you
say the module is rmmod'ed *and* removed from the system - since
zpool_create_pool() will call request_module() just as this function
does. I can add a comment explaining that.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-08-05 22:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-05 13:46 [PATCH 0/3] make zswap params changeable at runtime Dan Streetman
2015-08-05 13:46 ` [PATCH 1/3] zpool: add zpool_has_pool() Dan Streetman
2015-08-05 20:08 ` Andrew Morton
2015-08-05 22:00 ` Dan Streetman [this message]
2015-08-05 22:06 ` Andrew Morton
2015-08-06 21:50 ` Seth Jennings
2015-08-07 3:30 ` Seth Jennings
2015-08-14 20:01 ` Dan Streetman
2015-08-06 17:54 ` [PATCH] zpool: clarification comment for zpool_has_pool Dan Streetman
2015-08-05 13:46 ` [PATCH 2/3] zswap: dynamic pool creation Dan Streetman
2015-08-07 6:30 ` Sergey Senozhatsky
2015-08-07 14:24 ` Dan Streetman
2015-08-07 18:57 ` Dan Streetman
2015-08-10 0:49 ` Sergey Senozhatsky
2015-08-14 20:02 ` Dan Streetman
2015-08-05 13:46 ` [PATCH 3/3] zswap: change zpool/compressor at runtime Dan Streetman
2015-08-05 20:14 ` Andrew Morton
2015-08-06 10:06 ` Dan Streetman
2015-08-06 17:54 ` [PATCH] zswap: comment clarifying maxlen Dan Streetman
2015-08-06 0:08 ` [PATCH 3/3] zswap: change zpool/compressor at runtime Sergey Senozhatsky
2015-08-06 10:20 ` Dan Streetman
2015-08-06 10:59 ` Sergey Senozhatsky
2015-08-06 11:07 ` Dan Streetman
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=CALZtONDNYyKEdk2fc40ePH4Y+vOcUE-D7OG1DRekgSxLgVYKeA@mail.gmail.com \
--to=ddstreet@ieee.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sjennings@variantweb.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox