[dm-devel] Regression introduced with commit 2a0b4682e09d76 ("dm: convert dm_dev_internal.count from atomic_t to refcount_t)

Hannes Reinecke hare at suse.de
Thu Feb 1 14:54:23 UTC 2018


Hi Mike,

yet another refcount_t regression:

--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -451,15 +451,15 @@ int dm_get_device(struct dm_target *ti, const char
*path, fmode_t mode,
                        return r;
                }

-               atomic_set(&dd->count, 0);
+               refcount_set(&dd->count, 1);
                list_add(&dd->list, &t->devices);

        } else if (dd->dm_dev->mode != (mode | dd->dm_dev->mode)) {
                r = upgrade_mode(dd, mode, t->md);
                if (r)
                        return r;
+               refcount_inc(&dd->count);
        }
-       atomic_inc(&dd->count);

        *result = dd->dm_dev;
        return 0;

is _NOT_ an equivalent modification.
If the second 'if' claus is not taken, the reference count is never
increased and the system goes 'boom'.

Will be sending a patch shortly.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)




More information about the dm-devel mailing list