[dm-devel] Fix for dm-thin pool resizing

Drew Hastings dhastings at crucialwebhost.com
Tue Mar 10 06:39:49 UTC 2020


Expanding the data device consumes metadata space. Right now the data
device is currently resized *before* the metadata device is. This creates a
situation where you can reload the pool with a much larger metadata device
and a larger data device, but it will fail the pool by running out of
metadata space trying to expand the data device.

I've been able to fix this by simply changing around the order that things
are checked. Rather than checking data device first, which might itself
require too much metadata to expand, just check the metadata device first
and expand that (allowing for the subsequent data device expansion).

static int pool_preresume(struct dm_target *ti)
{
    int r;
    bool need_commit;
    struct pool_c *pt = ti->private;
    struct pool *pool = pt->pool;

    /*
     * Take control of the pool object.
     */
    r = bind_control_target(pool, ti);
    if (r)
        return r;

    r = maybe_resize_metadata_dev(ti, &need_commit);
    if (r)
        return r;

    if(need_commit) (void) commit(pool);

    r = maybe_resize_data_dev(ti, &need_commit);
    if (r)
        return r;

    if(need_commit) (void) commit(pool);

    return 0;
}


Thanks for your hard work!
- Drew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20200309/864a2896/attachment.htm>


More information about the dm-devel mailing list