Skip to content
Snippets Groups Projects
Commit f6581430 authored by Federico Vaga's avatar Federico Vaga Committed by Alessandro Rubini
Browse files

bugfix: assign bi and ti after their registration


The bug was evident in zio_change_current_buffer. When you change the
buffer, zio registers a new bi, but the old __bi_register() overwrites
the current bi in use by the channel; so, when zio tries to unregister
the old bi, there is not any reference to it.

Now you must assign a bi to a channel after its registration. For
simmetry and to prevent future bugs, also ti assignment must be done
after __ti_registration().

Signed-off-by: default avatarFederico Vaga <federico.vaga@gmail.com>
Acked-by: default avatarAlessandro Rubini <rubini@gnudd.com>
parent 8caedd21
Branches
Tags
No related merge requests found
...@@ -519,6 +519,7 @@ static int zio_change_current_trigger(struct zio_cset *cset, char *name) ...@@ -519,6 +519,7 @@ static int zio_change_current_trigger(struct zio_cset *cset, char *name)
/* Set new trigger*/ /* Set new trigger*/
mb(); mb();
cset->trig = trig; cset->trig = trig;
cset->ti = ti;
/* Rename trigger-tmp to trigger */ /* Rename trigger-tmp to trigger */
err = kobject_rename(&ti->head.kobj, "trigger"); err = kobject_rename(&ti->head.kobj, "trigger");
if (err) if (err)
...@@ -1086,10 +1087,8 @@ static int __bi_register(struct zio_buffer_type *zbuf, ...@@ -1086,10 +1087,8 @@ static int __bi_register(struct zio_buffer_type *zbuf,
list_add(&bi->list, &zbuf->list); list_add(&bi->list, &zbuf->list);
spin_unlock(&zbuf->lock); spin_unlock(&zbuf->lock);
bi->cset = chan->cset; bi->cset = chan->cset;
chan->bi = bi;
/* Done. This chan->bi marks everything is running (FIXME: audit) */
mb();
bi->chan = chan; bi->chan = chan;
/* Done. This bi->chan marks everything is running */
return 0; return 0;
...@@ -1181,10 +1180,8 @@ static int __ti_register(struct zio_trigger_type *trig, struct zio_cset *cset, ...@@ -1181,10 +1180,8 @@ static int __ti_register(struct zio_trigger_type *trig, struct zio_cset *cset,
spin_lock(&trig->lock); spin_lock(&trig->lock);
list_add(&ti->list, &trig->list); list_add(&ti->list, &trig->list);
spin_unlock(&trig->lock); spin_unlock(&trig->lock);
cset->ti = ti;
/* Done. This cset->ti marks everything is running (FIXME: audit) */
mb();
ti->cset = cset; ti->cset = cset;
/* Done. This ti->cset marks everything is running */
return 0; return 0;
...@@ -1251,7 +1248,8 @@ static int chan_register(struct zio_channel *chan) ...@@ -1251,7 +1248,8 @@ static int chan_register(struct zio_channel *chan)
err = __bi_register(chan->cset->zbuf, chan, bi, "buffer"); err = __bi_register(chan->cset->zbuf, chan, bi, "buffer");
if (err) if (err)
goto out_bi_destroy; goto out_bi_destroy;
/* Assign the buffer instance to this channel */
chan->bi = bi;
/* Create channel char devices*/ /* Create channel char devices*/
err = zio_create_chan_devices(chan); err = zio_create_chan_devices(chan);
if (err) if (err)
...@@ -1465,6 +1463,7 @@ static int cset_register(struct zio_cset *cset) ...@@ -1465,6 +1463,7 @@ static int cset_register(struct zio_cset *cset)
if (err) if (err)
goto out_tr; goto out_tr;
cset->trig = trig; cset->trig = trig;
cset->ti = ti;
} }
spin_lock(&zstat->lock); spin_lock(&zstat->lock);
list_add(&cset->list_cset, &zstat->list_cset); list_add(&cset->list_cset, &zstat->list_cset);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment