Skip to contentSkip to conversation

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

PATCH Hannes Reinecke 1 participant 1 message Feb 1, 2018 Device mapper

lore
Share & tools
lore
#0 lore raw

Hi Mike,

yet another refcount_t regression:

drivers/md/dm-table.c +0 -0
@@ -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

Signature · 10 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +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)

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel