Lines Matching refs:vol
60 struct ubi_volume *vol = desc->vol; in get_exclusive() local
62 spin_lock(&vol->ubi->volumes_lock); in get_exclusive()
63 users = vol->readers + vol->writers + vol->exclusive + vol->metaonly; in get_exclusive()
66 ubi_err(vol->ubi, "%d users for volume %d", users, vol->vol_id); in get_exclusive()
69 vol->readers = vol->writers = vol->metaonly = 0; in get_exclusive()
70 vol->exclusive = 1; in get_exclusive()
74 spin_unlock(&vol->ubi->volumes_lock); in get_exclusive()
86 struct ubi_volume *vol = desc->vol; in revoke_exclusive() local
88 spin_lock(&vol->ubi->volumes_lock); in revoke_exclusive()
89 ubi_assert(vol->readers == 0 && vol->writers == 0 && vol->metaonly == 0); in revoke_exclusive()
90 ubi_assert(vol->exclusive == 1 && desc->mode == UBI_EXCLUSIVE); in revoke_exclusive()
91 vol->exclusive = 0; in revoke_exclusive()
93 vol->readers = 1; in revoke_exclusive()
95 vol->writers = 1; in revoke_exclusive()
97 vol->metaonly = 1; in revoke_exclusive()
99 vol->exclusive = 1; in revoke_exclusive()
100 spin_unlock(&vol->ubi->volumes_lock); in revoke_exclusive()
133 struct ubi_volume *vol = desc->vol; in vol_cdev_release() local
136 vol->ubi->ubi_num, vol->vol_id, desc->mode); in vol_cdev_release()
138 if (vol->updating) { in vol_cdev_release()
139 ubi_warn(vol->ubi, "update of volume %d not finished, volume is damaged", in vol_cdev_release()
140 vol->vol_id); in vol_cdev_release()
141 ubi_assert(!vol->changing_leb); in vol_cdev_release()
142 vol->updating = 0; in vol_cdev_release()
143 vfree(vol->upd_buf); in vol_cdev_release()
144 } else if (vol->changing_leb) { in vol_cdev_release()
146 vol->upd_received, vol->upd_bytes, vol->ubi->ubi_num, in vol_cdev_release()
147 vol->vol_id); in vol_cdev_release()
148 vol->changing_leb = 0; in vol_cdev_release()
149 vfree(vol->upd_buf); in vol_cdev_release()
159 struct ubi_volume *vol = desc->vol; in vol_cdev_llseek() local
161 if (vol->updating) { in vol_cdev_llseek()
163 ubi_err(vol->ubi, "updating"); in vol_cdev_llseek()
167 return fixed_size_llseek(file, offset, origin, vol->used_bytes); in vol_cdev_llseek()
174 struct ubi_device *ubi = desc->vol->ubi; in vol_cdev_fsync()
188 struct ubi_volume *vol = desc->vol; in vol_cdev_read() local
189 struct ubi_device *ubi = vol->ubi; in vol_cdev_read()
195 count, *offp, vol->vol_id); in vol_cdev_read()
197 if (vol->updating) { in vol_cdev_read()
198 ubi_err(vol->ubi, "updating"); in vol_cdev_read()
201 if (vol->upd_marker) { in vol_cdev_read()
202 ubi_err(vol->ubi, "damaged volume, update marker is set"); in vol_cdev_read()
205 if (*offp == vol->used_bytes || count == 0) in vol_cdev_read()
208 if (vol->corrupted) in vol_cdev_read()
209 dbg_gen("read from corrupted volume %d", vol->vol_id); in vol_cdev_read()
211 if (*offp + count > vol->used_bytes) in vol_cdev_read()
212 count_save = count = vol->used_bytes - *offp; in vol_cdev_read()
214 tbuf_size = vol->usable_leb_size; in vol_cdev_read()
222 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); in vol_cdev_read()
227 if (off + len >= vol->usable_leb_size) in vol_cdev_read()
228 len = vol->usable_leb_size - off; in vol_cdev_read()
230 err = ubi_eba_read_leb(ubi, vol, lnum, tbuf, off, len, 0); in vol_cdev_read()
235 if (off == vol->usable_leb_size) { in vol_cdev_read()
237 off -= vol->usable_leb_size; in vol_cdev_read()
265 struct ubi_volume *vol = desc->vol; in vol_cdev_direct_write() local
266 struct ubi_device *ubi = vol->ubi; in vol_cdev_direct_write()
271 if (!vol->direct_writes) in vol_cdev_direct_write()
275 count, *offp, vol->vol_id); in vol_cdev_direct_write()
277 if (vol->vol_type == UBI_STATIC_VOLUME) in vol_cdev_direct_write()
280 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); in vol_cdev_direct_write()
286 if (*offp + count > vol->used_bytes) in vol_cdev_direct_write()
287 count_save = count = vol->used_bytes - *offp; in vol_cdev_direct_write()
295 tbuf_size = vol->usable_leb_size; in vol_cdev_direct_write()
307 if (off + len >= vol->usable_leb_size) in vol_cdev_direct_write()
308 len = vol->usable_leb_size - off; in vol_cdev_direct_write()
316 err = ubi_eba_write_leb(ubi, vol, lnum, tbuf, off, len); in vol_cdev_direct_write()
321 if (off == vol->usable_leb_size) { in vol_cdev_direct_write()
323 off -= vol->usable_leb_size; in vol_cdev_direct_write()
341 struct ubi_volume *vol = desc->vol; in vol_cdev_write() local
342 struct ubi_device *ubi = vol->ubi; in vol_cdev_write()
344 if (!vol->updating && !vol->changing_leb) in vol_cdev_write()
347 if (vol->updating) in vol_cdev_write()
348 err = ubi_more_update_data(ubi, vol, buf, count); in vol_cdev_write()
350 err = ubi_more_leb_change_data(ubi, vol, buf, count); in vol_cdev_write()
365 if (vol->changing_leb) { in vol_cdev_write()
370 err = ubi_check_volume(ubi, vol->vol_id); in vol_cdev_write()
376 vol->vol_id, ubi->ubi_num); in vol_cdev_write()
377 vol->corrupted = 1; in vol_cdev_write()
379 vol->checked = 1; in vol_cdev_write()
380 ubi_volume_notify(ubi, vol, UBI_VOLUME_UPDATED); in vol_cdev_write()
392 struct ubi_volume *vol = desc->vol; in vol_cdev_ioctl() local
393 struct ubi_device *ubi = vol->ubi; in vol_cdev_ioctl()
418 rsvd_bytes = (long long)vol->reserved_pebs * in vol_cdev_ioctl()
419 ubi->leb_size-vol->data_pad; in vol_cdev_ioctl()
429 err = ubi_start_update(ubi, vol, bytes); in vol_cdev_ioctl()
431 ubi_volume_notify(ubi, vol, UBI_VOLUME_UPDATED); in vol_cdev_ioctl()
450 vol->vol_type == UBI_STATIC_VOLUME) { in vol_cdev_ioctl()
457 if (req.lnum < 0 || req.lnum >= vol->reserved_pebs || in vol_cdev_ioctl()
458 req.bytes < 0 || req.bytes > vol->usable_leb_size) in vol_cdev_ioctl()
465 err = ubi_start_leb_change(ubi, vol, &req); in vol_cdev_ioctl()
483 vol->vol_type == UBI_STATIC_VOLUME) { in vol_cdev_ioctl()
488 if (lnum < 0 || lnum >= vol->reserved_pebs) { in vol_cdev_ioctl()
493 dbg_gen("erase LEB %d:%d", vol->vol_id, lnum); in vol_cdev_ioctl()
494 err = ubi_eba_unmap_leb(ubi, vol, lnum); in vol_cdev_ioctl()
558 desc->vol->direct_writes = !!req.value; in vol_cdev_ioctl()
748 if (re->desc->vol->name_len == name_len && in rename_volumes()
749 !memcmp(re->desc->vol->name, name, name_len)) { in rename_volumes()
759 vol_id, re->desc->vol->name, name); in rename_volumes()
777 if (re->new_name_len == re1->desc->vol->name_len && in rename_volumes()
778 !memcmp(re->new_name, re1->desc->vol->name, in rename_volumes()
779 re1->desc->vol->name_len)) { in rename_volumes()
817 re1->desc->vol->vol_id, re1->desc->vol->name); in rename_volumes()
932 pebs = div_u64(req.bytes + desc->vol->usable_leb_size - 1, in ubi_cdev_ioctl()
933 desc->vol->usable_leb_size); in ubi_cdev_ioctl()