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.h45
1 files changed, 26 insertions, 19 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 1c3fa18c26a7..4a8ec485c91d 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -74,6 +74,13 @@
74#define UBI_IO_RETRIES 3 74#define UBI_IO_RETRIES 3
75 75
76/* 76/*
77 * Length of the protection queue. The length is effectively equivalent to the
78 * number of (global) erase cycles PEBs are protected from the wear-leveling
79 * worker.
80 */
81#define UBI_PROT_QUEUE_LEN 10
82
83/*
77 * Error codes returned by the I/O sub-system. 84 * Error codes returned by the I/O sub-system.
78 * 85 *
79 * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only 86 * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only
@@ -95,7 +102,8 @@ enum {
95 102
96/** 103/**
97 * struct ubi_wl_entry - wear-leveling entry. 104 * struct ubi_wl_entry - wear-leveling entry.
98 * @rb: link in the corresponding RB-tree 105 * @u.rb: link in the corresponding (free/used) RB-tree
106 * @u.list: link in the protection queue
99 * @ec: erase counter 107 * @ec: erase counter
100 * @pnum: physical eraseblock number 108 * @pnum: physical eraseblock number
101 * 109 *
@@ -104,7 +112,10 @@ enum {
104 * RB-trees. See WL sub-system for details. 112 * RB-trees. See WL sub-system for details.
105 */ 113 */
106struct ubi_wl_entry { 114struct ubi_wl_entry {
107 struct rb_node rb; 115 union {
116 struct rb_node rb;
117 struct list_head list;
118 } u;
108 int ec; 119 int ec;
109 int pnum; 120 int pnum;
110}; 121};
@@ -288,7 +299,7 @@ struct ubi_wl_entry;
288 * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling 299 * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling
289 * 300 *
290 * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end 301 * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end
291 * of UBI ititializetion 302 * of UBI initialization
292 * @vtbl_slots: how many slots are available in the volume table 303 * @vtbl_slots: how many slots are available in the volume table
293 * @vtbl_size: size of the volume table in bytes 304 * @vtbl_size: size of the volume table in bytes
294 * @vtbl: in-RAM volume table copy 305 * @vtbl: in-RAM volume table copy
@@ -306,18 +317,17 @@ struct ubi_wl_entry;
306 * @used: RB-tree of used physical eraseblocks 317 * @used: RB-tree of used physical eraseblocks
307 * @free: RB-tree of free physical eraseblocks 318 * @free: RB-tree of free physical eraseblocks
308 * @scrub: RB-tree of physical eraseblocks which need scrubbing 319 * @scrub: RB-tree of physical eraseblocks which need scrubbing
309 * @prot: protection trees 320 * @pq: protection queue (contain physical eraseblocks which are temporarily
310 * @prot.pnum: protection tree indexed by physical eraseblock numbers 321 * protected from the wear-leveling worker)
311 * @prot.aec: protection tree indexed by absolute erase counter value 322 * @pq_head: protection queue head
312 * @wl_lock: protects the @used, @free, @prot, @lookuptbl, @abs_ec, @move_from, 323 * @wl_lock: protects the @used, @free, @pq, @pq_head, @lookuptbl, @move_from,
313 * @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works 324 * @move_to, @move_to_put @erase_pending, @wl_scheduled and @works
314 * fields 325 * fields
315 * @move_mutex: serializes eraseblock moves 326 * @move_mutex: serializes eraseblock moves
316 * @work_sem: sycnhronizes the WL worker with use tasks 327 * @work_sem: synchronizes the WL worker with use tasks
317 * @wl_scheduled: non-zero if the wear-leveling was scheduled 328 * @wl_scheduled: non-zero if the wear-leveling was scheduled
318 * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any 329 * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any
319 * physical eraseblock 330 * physical eraseblock
320 * @abs_ec: absolute erase counter
321 * @move_from: physical eraseblock from where the data is being moved 331 * @move_from: physical eraseblock from where the data is being moved
322 * @move_to: physical eraseblock where the data is being moved to 332 * @move_to: physical eraseblock where the data is being moved to
323 * @move_to_put: if the "to" PEB was put 333 * @move_to_put: if the "to" PEB was put
@@ -351,11 +361,11 @@ struct ubi_wl_entry;
351 * 361 *
352 * @peb_buf1: a buffer of PEB size used for different purposes 362 * @peb_buf1: a buffer of PEB size used for different purposes
353 * @peb_buf2: another buffer of PEB size used for different purposes 363 * @peb_buf2: another buffer of PEB size used for different purposes
354 * @buf_mutex: proptects @peb_buf1 and @peb_buf2 364 * @buf_mutex: protects @peb_buf1 and @peb_buf2
355 * @ckvol_mutex: serializes static volume checking when opening 365 * @ckvol_mutex: serializes static volume checking when opening
356 * @mult_mutex: serializes operations on multiple volumes, like re-nameing 366 * @mult_mutex: serializes operations on multiple volumes, like re-naming
357 * @dbg_peb_buf: buffer of PEB size used for debugging 367 * @dbg_peb_buf: buffer of PEB size used for debugging
358 * @dbg_buf_mutex: proptects @dbg_peb_buf 368 * @dbg_buf_mutex: protects @dbg_peb_buf
359 */ 369 */
360struct ubi_device { 370struct ubi_device {
361 struct cdev cdev; 371 struct cdev cdev;
@@ -392,16 +402,13 @@ struct ubi_device {
392 struct rb_root used; 402 struct rb_root used;
393 struct rb_root free; 403 struct rb_root free;
394 struct rb_root scrub; 404 struct rb_root scrub;
395 struct { 405 struct list_head pq[UBI_PROT_QUEUE_LEN];
396 struct rb_root pnum; 406 int pq_head;
397 struct rb_root aec;
398 } prot;
399 spinlock_t wl_lock; 407 spinlock_t wl_lock;
400 struct mutex move_mutex; 408 struct mutex move_mutex;
401 struct rw_semaphore work_sem; 409 struct rw_semaphore work_sem;
402 int wl_scheduled; 410 int wl_scheduled;
403 struct ubi_wl_entry **lookuptbl; 411 struct ubi_wl_entry **lookuptbl;
404 unsigned long long abs_ec;
405 struct ubi_wl_entry *move_from; 412 struct ubi_wl_entry *move_from;
406 struct ubi_wl_entry *move_to; 413 struct ubi_wl_entry *move_to;
407 int move_to_put; 414 int move_to_put;