Lines Matching refs:vol

49 static int set_update_marker(struct ubi_device *ubi, struct ubi_volume *vol)  in set_update_marker()  argument
54 dbg_gen("set update marker for volume %d", vol->vol_id); in set_update_marker()
56 if (vol->upd_marker) { in set_update_marker()
57 ubi_assert(ubi->vtbl[vol->vol_id].upd_marker); in set_update_marker()
62 vtbl_rec = ubi->vtbl[vol->vol_id]; in set_update_marker()
66 err = ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec); in set_update_marker()
67 vol->upd_marker = 1; in set_update_marker()
82 static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol, in clear_update_marker() argument
88 dbg_gen("clear update marker for volume %d", vol->vol_id); in clear_update_marker()
90 vtbl_rec = ubi->vtbl[vol->vol_id]; in clear_update_marker()
91 ubi_assert(vol->upd_marker && vtbl_rec.upd_marker); in clear_update_marker()
94 if (vol->vol_type == UBI_STATIC_VOLUME) { in clear_update_marker()
95 vol->corrupted = 0; in clear_update_marker()
96 vol->used_bytes = bytes; in clear_update_marker()
97 vol->used_ebs = div_u64_rem(bytes, vol->usable_leb_size, in clear_update_marker()
98 &vol->last_eb_bytes); in clear_update_marker()
99 if (vol->last_eb_bytes) in clear_update_marker()
100 vol->used_ebs += 1; in clear_update_marker()
102 vol->last_eb_bytes = vol->usable_leb_size; in clear_update_marker()
106 err = ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec); in clear_update_marker()
107 vol->upd_marker = 0; in clear_update_marker()
122 int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol, in ubi_start_update() argument
127 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes); in ubi_start_update()
128 ubi_assert(!vol->updating && !vol->changing_leb); in ubi_start_update()
129 vol->updating = 1; in ubi_start_update()
131 vol->upd_buf = vmalloc(ubi->leb_size); in ubi_start_update()
132 if (!vol->upd_buf) in ubi_start_update()
135 err = set_update_marker(ubi, vol); in ubi_start_update()
140 for (i = 0; i < vol->reserved_pebs; i++) { in ubi_start_update()
141 err = ubi_eba_unmap_leb(ubi, vol, i); in ubi_start_update()
151 err = clear_update_marker(ubi, vol, 0); in ubi_start_update()
155 vfree(vol->upd_buf); in ubi_start_update()
156 vol->updating = 0; in ubi_start_update()
160 vol->upd_ebs = div_u64(bytes + vol->usable_leb_size - 1, in ubi_start_update()
161 vol->usable_leb_size); in ubi_start_update()
162 vol->upd_bytes = bytes; in ubi_start_update()
163 vol->upd_received = 0; in ubi_start_update()
176 int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, in ubi_start_leb_change() argument
179 ubi_assert(!vol->updating && !vol->changing_leb); in ubi_start_leb_change()
182 vol->vol_id, req->lnum, req->bytes); in ubi_start_leb_change()
184 return ubi_eba_atomic_leb_change(ubi, vol, req->lnum, NULL, 0); in ubi_start_leb_change()
186 vol->upd_bytes = req->bytes; in ubi_start_leb_change()
187 vol->upd_received = 0; in ubi_start_leb_change()
188 vol->changing_leb = 1; in ubi_start_leb_change()
189 vol->ch_lnum = req->lnum; in ubi_start_leb_change()
191 vol->upd_buf = vmalloc(req->bytes); in ubi_start_leb_change()
192 if (!vol->upd_buf) in ubi_start_leb_change()
227 static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, in write_leb() argument
232 if (vol->vol_type == UBI_DYNAMIC_VOLUME) { in write_leb()
242 err = ubi_eba_write_leb(ubi, vol, lnum, buf, 0, len); in write_leb()
253 memset(buf + len, 0, vol->usable_leb_size - len); in write_leb()
254 err = ubi_eba_write_leb_st(ubi, vol, lnum, buf, len, used_ebs); in write_leb()
273 int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol, in ubi_more_update_data() argument
284 count, vol->upd_bytes, vol->upd_received); in ubi_more_update_data()
289 lnum = div_u64_rem(vol->upd_received, vol->usable_leb_size, &offs); in ubi_more_update_data()
290 if (vol->upd_received + count > vol->upd_bytes) in ubi_more_update_data()
291 to_write = count = vol->upd_bytes - vol->upd_received; in ubi_more_update_data()
305 len = vol->usable_leb_size - offs; in ubi_more_update_data()
309 err = copy_from_user(vol->upd_buf + offs, buf, len); in ubi_more_update_data()
313 if (offs + len == vol->usable_leb_size || in ubi_more_update_data()
314 vol->upd_received + len == vol->upd_bytes) { in ubi_more_update_data()
321 ubi_assert(flush_len <= vol->usable_leb_size); in ubi_more_update_data()
322 err = write_leb(ubi, vol, lnum, vol->upd_buf, flush_len, in ubi_more_update_data()
323 vol->upd_ebs); in ubi_more_update_data()
328 vol->upd_received += len; in ubi_more_update_data()
339 if (count > vol->usable_leb_size) in ubi_more_update_data()
340 len = vol->usable_leb_size; in ubi_more_update_data()
344 err = copy_from_user(vol->upd_buf, buf, len); in ubi_more_update_data()
348 if (len == vol->usable_leb_size || in ubi_more_update_data()
349 vol->upd_received + len == vol->upd_bytes) { in ubi_more_update_data()
350 err = write_leb(ubi, vol, lnum, vol->upd_buf, in ubi_more_update_data()
351 len, vol->upd_ebs); in ubi_more_update_data()
356 vol->upd_received += len; in ubi_more_update_data()
362 ubi_assert(vol->upd_received <= vol->upd_bytes); in ubi_more_update_data()
363 if (vol->upd_received == vol->upd_bytes) { in ubi_more_update_data()
368 err = clear_update_marker(ubi, vol, vol->upd_bytes); in ubi_more_update_data()
371 vol->updating = 0; in ubi_more_update_data()
373 vfree(vol->upd_buf); in ubi_more_update_data()
393 int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol, in ubi_more_leb_change_data() argument
399 count, vol->upd_bytes, vol->upd_received); in ubi_more_leb_change_data()
404 if (vol->upd_received + count > vol->upd_bytes) in ubi_more_leb_change_data()
405 count = vol->upd_bytes - vol->upd_received; in ubi_more_leb_change_data()
407 err = copy_from_user(vol->upd_buf + vol->upd_received, buf, count); in ubi_more_leb_change_data()
411 vol->upd_received += count; in ubi_more_leb_change_data()
413 if (vol->upd_received == vol->upd_bytes) { in ubi_more_leb_change_data()
414 int len = ALIGN((int)vol->upd_bytes, ubi->min_io_size); in ubi_more_leb_change_data()
416 memset(vol->upd_buf + vol->upd_bytes, 0xFF, in ubi_more_leb_change_data()
417 len - vol->upd_bytes); in ubi_more_leb_change_data()
418 len = ubi_calc_data_len(ubi, vol->upd_buf, len); in ubi_more_leb_change_data()
419 err = ubi_eba_atomic_leb_change(ubi, vol, vol->ch_lnum, in ubi_more_leb_change_data()
420 vol->upd_buf, len); in ubi_more_leb_change_data()
425 ubi_assert(vol->upd_received <= vol->upd_bytes); in ubi_more_leb_change_data()
426 if (vol->upd_received == vol->upd_bytes) { in ubi_more_leb_change_data()
427 vol->changing_leb = 0; in ubi_more_leb_change_data()
429 vfree(vol->upd_buf); in ubi_more_leb_change_data()