Lines Matching refs:vol

47 	struct ubi_volume *vol = desc->vol;  in get_exclusive()  local
49 spin_lock(&vol->ubi->volumes_lock); in get_exclusive()
50 users = vol->readers + vol->writers + vol->exclusive + vol->metaonly; in get_exclusive()
53 ubi_err(vol->ubi, "%d users for volume %d", users, vol->vol_id); in get_exclusive()
56 vol->readers = vol->writers = vol->metaonly = 0; in get_exclusive()
57 vol->exclusive = 1; in get_exclusive()
61 spin_unlock(&vol->ubi->volumes_lock); in get_exclusive()
73 struct ubi_volume *vol = desc->vol; in revoke_exclusive() local
75 spin_lock(&vol->ubi->volumes_lock); in revoke_exclusive()
76 ubi_assert(vol->readers == 0 && vol->writers == 0 && vol->metaonly == 0); in revoke_exclusive()
77 ubi_assert(vol->exclusive == 1 && desc->mode == UBI_EXCLUSIVE); in revoke_exclusive()
78 vol->exclusive = 0; in revoke_exclusive()
80 vol->readers = 1; in revoke_exclusive()
82 vol->writers = 1; in revoke_exclusive()
84 vol->metaonly = 1; in revoke_exclusive()
86 vol->exclusive = 1; in revoke_exclusive()
87 spin_unlock(&vol->ubi->volumes_lock); in revoke_exclusive()
120 struct ubi_volume *vol = desc->vol; in vol_cdev_release() local
123 vol->ubi->ubi_num, vol->vol_id, desc->mode); in vol_cdev_release()
125 if (vol->updating) { in vol_cdev_release()
126 ubi_warn(vol->ubi, "update of volume %d not finished, volume is damaged", in vol_cdev_release()
127 vol->vol_id); in vol_cdev_release()
128 ubi_assert(!vol->changing_leb); in vol_cdev_release()
129 vol->updating = 0; in vol_cdev_release()
130 vfree(vol->upd_buf); in vol_cdev_release()
131 } else if (vol->changing_leb) { in vol_cdev_release()
133 vol->upd_received, vol->upd_bytes, vol->ubi->ubi_num, in vol_cdev_release()
134 vol->vol_id); in vol_cdev_release()
135 vol->changing_leb = 0; in vol_cdev_release()
136 vfree(vol->upd_buf); in vol_cdev_release()
146 struct ubi_volume *vol = desc->vol; in vol_cdev_llseek() local
148 if (vol->updating) { in vol_cdev_llseek()
150 ubi_err(vol->ubi, "updating"); in vol_cdev_llseek()
154 return fixed_size_llseek(file, offset, origin, vol->used_bytes); in vol_cdev_llseek()
161 struct ubi_device *ubi = desc->vol->ubi; in vol_cdev_fsync()
175 struct ubi_volume *vol = desc->vol; in vol_cdev_read() local
176 struct ubi_device *ubi = vol->ubi; in vol_cdev_read()
182 count, *offp, vol->vol_id); in vol_cdev_read()
184 if (vol->updating) { in vol_cdev_read()
185 ubi_err(vol->ubi, "updating"); in vol_cdev_read()
188 if (vol->upd_marker) { in vol_cdev_read()
189 ubi_err(vol->ubi, "damaged volume, update marker is set"); in vol_cdev_read()
192 if (*offp == vol->used_bytes || count == 0) in vol_cdev_read()
195 if (vol->corrupted) in vol_cdev_read()
196 dbg_gen("read from corrupted volume %d", vol->vol_id); in vol_cdev_read()
198 if (*offp + count > vol->used_bytes) in vol_cdev_read()
199 count_save = count = vol->used_bytes - *offp; in vol_cdev_read()
201 tbuf_size = vol->usable_leb_size; in vol_cdev_read()
209 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); in vol_cdev_read()
214 if (off + len >= vol->usable_leb_size) in vol_cdev_read()
215 len = vol->usable_leb_size - off; in vol_cdev_read()
217 err = ubi_eba_read_leb(ubi, vol, lnum, tbuf, off, len, 0); in vol_cdev_read()
222 if (off == vol->usable_leb_size) { in vol_cdev_read()
224 off -= vol->usable_leb_size; in vol_cdev_read()
252 struct ubi_volume *vol = desc->vol; in vol_cdev_direct_write() local
253 struct ubi_device *ubi = vol->ubi; in vol_cdev_direct_write()
258 if (!vol->direct_writes) in vol_cdev_direct_write()
262 count, *offp, vol->vol_id); in vol_cdev_direct_write()
264 if (vol->vol_type == UBI_STATIC_VOLUME) in vol_cdev_direct_write()
267 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); in vol_cdev_direct_write()
273 if (*offp + count > vol->used_bytes) in vol_cdev_direct_write()
274 count_save = count = vol->used_bytes - *offp; in vol_cdev_direct_write()
282 tbuf_size = vol->usable_leb_size; in vol_cdev_direct_write()
294 if (off + len >= vol->usable_leb_size) in vol_cdev_direct_write()
295 len = vol->usable_leb_size - off; in vol_cdev_direct_write()
303 err = ubi_eba_write_leb(ubi, vol, lnum, tbuf, off, len); in vol_cdev_direct_write()
308 if (off == vol->usable_leb_size) { in vol_cdev_direct_write()
310 off -= vol->usable_leb_size; in vol_cdev_direct_write()
328 struct ubi_volume *vol = desc->vol; in vol_cdev_write() local
329 struct ubi_device *ubi = vol->ubi; in vol_cdev_write()
331 if (!vol->updating && !vol->changing_leb) in vol_cdev_write()
334 if (vol->updating) in vol_cdev_write()
335 err = ubi_more_update_data(ubi, vol, buf, count); in vol_cdev_write()
337 err = ubi_more_leb_change_data(ubi, vol, buf, count); in vol_cdev_write()
352 if (vol->changing_leb) { in vol_cdev_write()
361 err = ubi_check_volume(ubi, vol->vol_id); in vol_cdev_write()
367 vol->vol_id, ubi->ubi_num); in vol_cdev_write()
368 vol->corrupted = 1; in vol_cdev_write()
370 vol->checked = 1; in vol_cdev_write()
371 ubi_volume_notify(ubi, vol, UBI_VOLUME_UPDATED); in vol_cdev_write()
383 struct ubi_volume *vol = desc->vol; in vol_cdev_ioctl() local
384 struct ubi_device *ubi = vol->ubi; in vol_cdev_ioctl()
409 rsvd_bytes = (long long)vol->reserved_pebs * in vol_cdev_ioctl()
410 vol->usable_leb_size; in vol_cdev_ioctl()
420 err = ubi_start_update(ubi, vol, bytes); in vol_cdev_ioctl()
422 ubi_volume_notify(ubi, vol, UBI_VOLUME_UPDATED); in vol_cdev_ioctl()
441 vol->vol_type == UBI_STATIC_VOLUME) { in vol_cdev_ioctl()
448 if (!ubi_leb_valid(vol, req.lnum) || in vol_cdev_ioctl()
449 req.bytes < 0 || req.bytes > vol->usable_leb_size) in vol_cdev_ioctl()
456 err = ubi_start_leb_change(ubi, vol, &req); in vol_cdev_ioctl()
474 vol->vol_type == UBI_STATIC_VOLUME) { in vol_cdev_ioctl()
479 if (!ubi_leb_valid(vol, lnum)) { in vol_cdev_ioctl()
484 dbg_gen("erase LEB %d:%d", vol->vol_id, lnum); in vol_cdev_ioctl()
485 err = ubi_eba_unmap_leb(ubi, vol, lnum); in vol_cdev_ioctl()
549 desc->vol->direct_writes = !!req.value; in vol_cdev_ioctl()
746 if (re->desc->vol->name_len == name_len && in rename_volumes()
747 !memcmp(re->desc->vol->name, name, name_len)) { in rename_volumes()
757 vol_id, re->desc->vol->name, name); in rename_volumes()
775 if (re->new_name_len == re1->desc->vol->name_len && in rename_volumes()
776 !memcmp(re->new_name, re1->desc->vol->name, in rename_volumes()
777 re1->desc->vol->name_len)) { in rename_volumes()
815 re1->desc->vol->vol_id, re1->desc->vol->name); in rename_volumes()
930 pebs = div_u64(req.bytes + desc->vol->usable_leb_size - 1, in ubi_cdev_ioctl()
931 desc->vol->usable_leb_size); in ubi_cdev_ioctl()