Lines Matching defs:vol

36  * @vol: volume description object
38 * This function sets the update marker flag for volume @vol. Returns zero
41 static int set_update_marker(struct ubi_device *ubi, struct ubi_volume *vol)
46 dbg_gen("set update marker for volume %d", vol->vol_id);
48 if (vol->upd_marker) {
49 ubi_assert(ubi->vtbl[vol->vol_id].upd_marker);
54 vtbl_rec = ubi->vtbl[vol->vol_id];
58 err = ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec);
59 vol->upd_marker = 1;
67 * @vol: volume description object
70 * This function clears the update marker for volume @vol, sets new volume
74 static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
80 dbg_gen("clear update marker for volume %d", vol->vol_id);
82 vtbl_rec = ubi->vtbl[vol->vol_id];
83 ubi_assert(vol->upd_marker && vtbl_rec.upd_marker);
86 if (vol->vol_type == UBI_STATIC_VOLUME) {
87 vol->corrupted = 0;
88 vol->used_bytes = bytes;
89 vol->used_ebs = div_u64_rem(bytes, vol->usable_leb_size,
90 &vol->last_eb_bytes);
91 if (vol->last_eb_bytes)
92 vol->used_ebs += 1;
94 vol->last_eb_bytes = vol->usable_leb_size;
98 err = ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec);
99 vol->upd_marker = 0;
107 * @vol: volume description object
114 int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
119 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes);
120 ubi_assert(!vol->updating && !vol->changing_leb);
121 vol->updating = 1;
123 vol->upd_buf = vmalloc(ubi->leb_size);
124 if (!vol->upd_buf)
127 err = set_update_marker(ubi, vol);
132 for (i = 0; i < vol->reserved_pebs; i++) {
133 err = ubi_eba_unmap_leb(ubi, vol, i);
143 err = clear_update_marker(ubi, vol, 0);
147 vfree(vol->upd_buf);
148 vol->updating = 0;
152 vol->upd_ebs = div_u64(bytes + vol->usable_leb_size - 1,
153 vol->usable_leb_size);
154 vol->upd_bytes = bytes;
155 vol->upd_received = 0;
162 * @vol: volume description object
168 int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
171 ubi_assert(!vol->updating && !vol->changing_leb);
174 vol->vol_id, req->lnum, req->bytes);
176 return ubi_eba_atomic_leb_change(ubi, vol, req->lnum, NULL, 0);
178 vol->upd_bytes = req->bytes;
179 vol->upd_received = 0;
180 vol->changing_leb = 1;
181 vol->ch_lnum = req->lnum;
183 vol->upd_buf = vmalloc(ALIGN((int)req->bytes, ubi->min_io_size));
184 if (!vol->upd_buf)
193 * @vol: volume description object
219 static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
224 if (vol->vol_type == UBI_DYNAMIC_VOLUME) {
234 err = ubi_eba_write_leb(ubi, vol, lnum, buf, 0, len);
245 memset(buf + len, 0, vol->usable_leb_size - len);
246 err = ubi_eba_write_leb_st(ubi, vol, lnum, buf, len, used_ebs);
255 * @vol: volume description object
265 int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
271 count, vol->upd_bytes, vol->upd_received);
276 lnum = div_u64_rem(vol->upd_received, vol->usable_leb_size, &offs);
277 if (vol->upd_received + count > vol->upd_bytes)
278 to_write = count = vol->upd_bytes - vol->upd_received;
292 len = vol->usable_leb_size - offs;
296 err = copy_from_user(vol->upd_buf + offs, buf, len);
300 if (offs + len == vol->usable_leb_size ||
301 vol->upd_received + len == vol->upd_bytes) {
308 ubi_assert(flush_len <= vol->usable_leb_size);
309 err = write_leb(ubi, vol, lnum, vol->upd_buf, flush_len,
310 vol->upd_ebs);
315 vol->upd_received += len;
326 if (count > vol->usable_leb_size)
327 len = vol->usable_leb_size;
331 err = copy_from_user(vol->upd_buf, buf, len);
335 if (len == vol->usable_leb_size ||
336 vol->upd_received + len == vol->upd_bytes) {
337 err = write_leb(ubi, vol, lnum, vol->upd_buf,
338 len, vol->upd_ebs);
343 vol->upd_received += len;
349 ubi_assert(vol->upd_received <= vol->upd_bytes);
350 if (vol->upd_received == vol->upd_bytes) {
355 err = clear_update_marker(ubi, vol, vol->upd_bytes);
358 vol->updating = 0;
360 vfree(vol->upd_buf);
369 * @vol: volume description object
380 int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
386 count, vol->upd_bytes, vol->upd_received);
391 if (vol->upd_received + count > vol->upd_bytes)
392 count = vol->upd_bytes - vol->upd_received;
394 err = copy_from_user(vol->upd_buf + vol->upd_received, buf, count);
398 vol->upd_received += count;
400 if (vol->upd_received == vol->upd_bytes) {
401 int len = ALIGN((int)vol->upd_bytes, ubi->min_io_size);
403 memset(vol->upd_buf + vol->upd_bytes, 0xFF,
404 len - vol->upd_bytes);
405 len = ubi_calc_data_len(ubi, vol->upd_buf, len);
406 err = ubi_eba_atomic_leb_change(ubi, vol, vol->ch_lnum,
407 vol->upd_buf, len);
412 ubi_assert(vol->upd_received <= vol->upd_bytes);
413 if (vol->upd_received == vol->upd_bytes) {
414 vol->changing_leb = 0;
416 vfree(vol->upd_buf);