aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/ubi.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/ubi.h')
-rw-r--r--drivers/mtd/ubi/ubi.h75
1 files changed, 51 insertions, 24 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 67dcbd11c15c..1c3fa18c26a7 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -74,15 +74,15 @@
74#define UBI_IO_RETRIES 3 74#define UBI_IO_RETRIES 3
75 75
76/* 76/*
77 * Error codes returned by the I/O unit. 77 * Error codes returned by the I/O sub-system.
78 * 78 *
79 * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only 79 * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only
80 * 0xFF bytes 80 * %0xFF bytes
81 * UBI_IO_PEB_FREE: the physical eraseblock is free, i.e. it contains only a 81 * UBI_IO_PEB_FREE: the physical eraseblock is free, i.e. it contains only a
82 * valid erase counter header, and the rest are %0xFF bytes 82 * valid erase counter header, and the rest are %0xFF bytes
83 * UBI_IO_BAD_EC_HDR: the erase counter header is corrupted (bad magic or CRC) 83 * UBI_IO_BAD_EC_HDR: the erase counter header is corrupted (bad magic or CRC)
84 * UBI_IO_BAD_VID_HDR: the volume identifier header is corrupted (bad magic or 84 * UBI_IO_BAD_VID_HDR: the volume identifier header is corrupted (bad magic or
85 * CRC) 85 * CRC)
86 * UBI_IO_BITFLIPS: bit-flips were detected and corrected 86 * UBI_IO_BITFLIPS: bit-flips were detected and corrected
87 */ 87 */
88enum { 88enum {
@@ -99,9 +99,9 @@ enum {
99 * @ec: erase counter 99 * @ec: erase counter
100 * @pnum: physical eraseblock number 100 * @pnum: physical eraseblock number
101 * 101 *
102 * This data structure is used in the WL unit. Each physical eraseblock has a 102 * This data structure is used in the WL sub-system. Each physical eraseblock
103 * corresponding &struct wl_entry object which may be kept in different 103 * has a corresponding &struct wl_entry object which may be kept in different
104 * RB-trees. See WL unit for details. 104 * RB-trees. See WL sub-system for details.
105 */ 105 */
106struct ubi_wl_entry { 106struct ubi_wl_entry {
107 struct rb_node rb; 107 struct rb_node rb;
@@ -118,10 +118,10 @@ struct ubi_wl_entry {
118 * @mutex: read/write mutex to implement read/write access serialization to 118 * @mutex: read/write mutex to implement read/write access serialization to
119 * the (@vol_id, @lnum) logical eraseblock 119 * the (@vol_id, @lnum) logical eraseblock
120 * 120 *
121 * This data structure is used in the EBA unit to implement per-LEB locking. 121 * This data structure is used in the EBA sub-system to implement per-LEB
122 * When a logical eraseblock is being locked - corresponding 122 * locking. When a logical eraseblock is being locked - corresponding
123 * &struct ubi_ltree_entry object is inserted to the lock tree (@ubi->ltree). 123 * &struct ubi_ltree_entry object is inserted to the lock tree (@ubi->ltree).
124 * See EBA unit for details. 124 * See EBA sub-system for details.
125 */ 125 */
126struct ubi_ltree_entry { 126struct ubi_ltree_entry {
127 struct rb_node rb; 127 struct rb_node rb;
@@ -131,6 +131,27 @@ struct ubi_ltree_entry {
131 struct rw_semaphore mutex; 131 struct rw_semaphore mutex;
132}; 132};
133 133
134/**
135 * struct ubi_rename_entry - volume re-name description data structure.
136 * @new_name_len: new volume name length
137 * @new_name: new volume name
138 * @remove: if not zero, this volume should be removed, not re-named
139 * @desc: descriptor of the volume
140 * @list: links re-name entries into a list
141 *
142 * This data structure is utilized in the multiple volume re-name code. Namely,
143 * UBI first creates a list of &struct ubi_rename_entry objects from the
144 * &struct ubi_rnvol_req request object, and then utilizes this list to do all
145 * the job.
146 */
147struct ubi_rename_entry {
148 int new_name_len;
149 char new_name[UBI_VOL_NAME_MAX + 1];
150 int remove;
151 struct ubi_volume_desc *desc;
152 struct list_head list;
153};
154
134struct ubi_volume_desc; 155struct ubi_volume_desc;
135 156
136/** 157/**
@@ -206,7 +227,7 @@ struct ubi_volume {
206 int alignment; 227 int alignment;
207 int data_pad; 228 int data_pad;
208 int name_len; 229 int name_len;
209 char name[UBI_VOL_NAME_MAX+1]; 230 char name[UBI_VOL_NAME_MAX + 1];
210 231
211 int upd_ebs; 232 int upd_ebs;
212 int ch_lnum; 233 int ch_lnum;
@@ -225,7 +246,7 @@ struct ubi_volume {
225#ifdef CONFIG_MTD_UBI_GLUEBI 246#ifdef CONFIG_MTD_UBI_GLUEBI
226 /* 247 /*
227 * Gluebi-related stuff may be compiled out. 248 * Gluebi-related stuff may be compiled out.
228 * TODO: this should not be built into UBI but should be a separate 249 * Note: this should not be built into UBI but should be a separate
229 * ubimtd driver which works on top of UBI and emulates MTD devices. 250 * ubimtd driver which works on top of UBI and emulates MTD devices.
230 */ 251 */
231 struct ubi_volume_desc *gluebi_desc; 252 struct ubi_volume_desc *gluebi_desc;
@@ -235,8 +256,7 @@ struct ubi_volume {
235}; 256};
236 257
237/** 258/**
238 * struct ubi_volume_desc - descriptor of the UBI volume returned when it is 259 * struct ubi_volume_desc - UBI volume descriptor returned when it is opened.
239 * opened.
240 * @vol: reference to the corresponding volume description object 260 * @vol: reference to the corresponding volume description object
241 * @mode: open mode (%UBI_READONLY, %UBI_READWRITE, or %UBI_EXCLUSIVE) 261 * @mode: open mode (%UBI_READONLY, %UBI_READWRITE, or %UBI_EXCLUSIVE)
242 */ 262 */
@@ -273,7 +293,7 @@ struct ubi_wl_entry;
273 * @vtbl_size: size of the volume table in bytes 293 * @vtbl_size: size of the volume table in bytes
274 * @vtbl: in-RAM volume table copy 294 * @vtbl: in-RAM volume table copy
275 * @volumes_mutex: protects on-flash volume table and serializes volume 295 * @volumes_mutex: protects on-flash volume table and serializes volume
276 * changes, like creation, deletion, update, resize 296 * changes, like creation, deletion, update, re-size and re-name
277 * 297 *
278 * @max_ec: current highest erase counter value 298 * @max_ec: current highest erase counter value
279 * @mean_ec: current mean erase counter value 299 * @mean_ec: current mean erase counter value
@@ -293,6 +313,7 @@ struct ubi_wl_entry;
293 * @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works 313 * @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works
294 * fields 314 * fields
295 * @move_mutex: serializes eraseblock moves 315 * @move_mutex: serializes eraseblock moves
316 * @work_sem: sycnhronizes the WL worker with use tasks
296 * @wl_scheduled: non-zero if the wear-leveling was scheduled 317 * @wl_scheduled: non-zero if the wear-leveling was scheduled
297 * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any 318 * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any
298 * physical eraseblock 319 * physical eraseblock
@@ -316,11 +337,11 @@ struct ubi_wl_entry;
316 * @ro_mode: if the UBI device is in read-only mode 337 * @ro_mode: if the UBI device is in read-only mode
317 * @leb_size: logical eraseblock size 338 * @leb_size: logical eraseblock size
318 * @leb_start: starting offset of logical eraseblocks within physical 339 * @leb_start: starting offset of logical eraseblocks within physical
319 * eraseblocks 340 * eraseblocks
320 * @ec_hdr_alsize: size of the EC header aligned to @hdrs_min_io_size 341 * @ec_hdr_alsize: size of the EC header aligned to @hdrs_min_io_size
321 * @vid_hdr_alsize: size of the VID header aligned to @hdrs_min_io_size 342 * @vid_hdr_alsize: size of the VID header aligned to @hdrs_min_io_size
322 * @vid_hdr_offset: starting offset of the volume identifier header (might be 343 * @vid_hdr_offset: starting offset of the volume identifier header (might be
323 * unaligned) 344 * unaligned)
324 * @vid_hdr_aloffset: starting offset of the VID header aligned to 345 * @vid_hdr_aloffset: starting offset of the VID header aligned to
325 * @hdrs_min_io_size 346 * @hdrs_min_io_size
326 * @vid_hdr_shift: contains @vid_hdr_offset - @vid_hdr_aloffset 347 * @vid_hdr_shift: contains @vid_hdr_offset - @vid_hdr_aloffset
@@ -331,6 +352,8 @@ struct ubi_wl_entry;
331 * @peb_buf1: a buffer of PEB size used for different purposes 352 * @peb_buf1: a buffer of PEB size used for different purposes
332 * @peb_buf2: another buffer of PEB size used for different purposes 353 * @peb_buf2: another buffer of PEB size used for different purposes
333 * @buf_mutex: proptects @peb_buf1 and @peb_buf2 354 * @buf_mutex: proptects @peb_buf1 and @peb_buf2
355 * @ckvol_mutex: serializes static volume checking when opening
356 * @mult_mutex: serializes operations on multiple volumes, like re-nameing
334 * @dbg_peb_buf: buffer of PEB size used for debugging 357 * @dbg_peb_buf: buffer of PEB size used for debugging
335 * @dbg_buf_mutex: proptects @dbg_peb_buf 358 * @dbg_buf_mutex: proptects @dbg_peb_buf
336 */ 359 */
@@ -356,16 +379,16 @@ struct ubi_device {
356 struct mutex volumes_mutex; 379 struct mutex volumes_mutex;
357 380
358 int max_ec; 381 int max_ec;
359 /* TODO: mean_ec is not updated run-time, fix */ 382 /* Note, mean_ec is not updated run-time - should be fixed */
360 int mean_ec; 383 int mean_ec;
361 384
362 /* EBA unit's stuff */ 385 /* EBA sub-system's stuff */
363 unsigned long long global_sqnum; 386 unsigned long long global_sqnum;
364 spinlock_t ltree_lock; 387 spinlock_t ltree_lock;
365 struct rb_root ltree; 388 struct rb_root ltree;
366 struct mutex alc_mutex; 389 struct mutex alc_mutex;
367 390
368 /* Wear-leveling unit's stuff */ 391 /* Wear-leveling sub-system's stuff */
369 struct rb_root used; 392 struct rb_root used;
370 struct rb_root free; 393 struct rb_root free;
371 struct rb_root scrub; 394 struct rb_root scrub;
@@ -388,7 +411,7 @@ struct ubi_device {
388 int thread_enabled; 411 int thread_enabled;
389 char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2]; 412 char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2];
390 413
391 /* I/O unit's stuff */ 414 /* I/O sub-system's stuff */
392 long long flash_size; 415 long long flash_size;
393 int peb_count; 416 int peb_count;
394 int peb_size; 417 int peb_size;
@@ -411,6 +434,7 @@ struct ubi_device {
411 void *peb_buf2; 434 void *peb_buf2;
412 struct mutex buf_mutex; 435 struct mutex buf_mutex;
413 struct mutex ckvol_mutex; 436 struct mutex ckvol_mutex;
437 struct mutex mult_mutex;
414#ifdef CONFIG_MTD_UBI_DEBUG 438#ifdef CONFIG_MTD_UBI_DEBUG
415 void *dbg_peb_buf; 439 void *dbg_peb_buf;
416 struct mutex dbg_buf_mutex; 440 struct mutex dbg_buf_mutex;
@@ -427,12 +451,15 @@ extern struct mutex ubi_devices_mutex;
427/* vtbl.c */ 451/* vtbl.c */
428int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, 452int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
429 struct ubi_vtbl_record *vtbl_rec); 453 struct ubi_vtbl_record *vtbl_rec);
454int ubi_vtbl_rename_volumes(struct ubi_device *ubi,
455 struct list_head *rename_list);
430int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si); 456int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si);
431 457
432/* vmt.c */ 458/* vmt.c */
433int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req); 459int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req);
434int ubi_remove_volume(struct ubi_volume_desc *desc); 460int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl);
435int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs); 461int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs);
462int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list);
436int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol); 463int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol);
437void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol); 464void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol);
438 465
@@ -447,7 +474,8 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
447 const void __user *buf, int count); 474 const void __user *buf, int count);
448 475
449/* misc.c */ 476/* misc.c */
450int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, int length); 477int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
478 int length);
451int ubi_check_volume(struct ubi_device *ubi, int vol_id); 479int ubi_check_volume(struct ubi_device *ubi, int vol_id);
452void ubi_calculate_reserved(struct ubi_device *ubi); 480void ubi_calculate_reserved(struct ubi_device *ubi);
453 481
@@ -477,7 +505,6 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
477int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, 505int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
478 struct ubi_vid_hdr *vid_hdr); 506 struct ubi_vid_hdr *vid_hdr);
479int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si); 507int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si);
480void ubi_eba_close(const struct ubi_device *ubi);
481 508
482/* wl.c */ 509/* wl.c */
483int ubi_wl_get_peb(struct ubi_device *ubi, int dtype); 510int ubi_wl_get_peb(struct ubi_device *ubi, int dtype);