UBI: introduce volume refcounting

Add ref_count field to UBI volumes and remove weired "vol->removed"
field. This way things are better understandable and we do not have
to do whold show_attr operation under spinlock.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
Artem Bityutskiy
2007-12-17 15:42:57 +02:00
parent db6e5770ef
commit d05c77a816
5 changed files with 84 additions and 42 deletions

View File

@@ -152,6 +152,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
break;
}
get_device(&vol->dev);
vol->ref_count += 1;
spin_unlock(&ubi->volumes_lock);
desc->vol = vol;
@@ -261,10 +262,11 @@ void ubi_close_volume(struct ubi_volume_desc *desc)
case UBI_EXCLUSIVE:
vol->exclusive = 0;
}
vol->ref_count -= 1;
spin_unlock(&vol->ubi->volumes_lock);
kfree(desc);
put_device(&vol->dev);
kfree(desc);
module_put(THIS_MODULE);
}
EXPORT_SYMBOL_GPL(ubi_close_volume);