diff options
| author | Mike Snitzer <snitzer@redhat.com> | 2017-11-25 00:27:26 -0500 |
|---|---|---|
| committer | Mike Snitzer <snitzer@redhat.com> | 2017-11-25 00:27:26 -0500 |
| commit | c2318d07ead871f058dda62e942ed7b6b1c1cfcf (patch) | |
| tree | 21b703634f29a5372880d58cad0f2dc3814811d1 | |
| parent | 06ede5f6086757f746b7be860ae76137f4e95032 (diff) | |
| download | linux-dm-c2318d07ead871f058dda62e942ed7b6b1c1cfcf.tar.gz | |
dm table: fix regression from improper dm_dev_internal.count refcount_t conversion
Notice: this object is not reachable from any branch.
Multiple refcounts are needed if the device was already added. The
micro-optimization of setting the refcount to 1 on first added (rather
than fall thru to a common refcount_inc) lost sight of the fact that the
refcount_inc is also needed for the case when the device already exists
and the mode need not be upgraded.
Fixes: 2a0b4682e0 ("dm: convert dm_dev_internal.count from atomic_t to refcount_t")
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Notice: this object is not reachable from any branch.
| -rw-r--r-- | drivers/md/dm-table.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 88130b5d95f90..f6d32eed38071 100644 --- 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; } - refcount_set(&dd->count, 1); + refcount_set(&dd->count, 0); 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); } + refcount_inc(&dd->count); *result = dd->dm_dev; return 0; |
