diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-06-17 21:16:55 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-06-17 21:16:55 -0400 |
commit | 4b337c5f245b6587ba844ac7bb13c313a2912f7b (patch) | |
tree | 999c6a6580b76a083c8efb9dabff709d1c49fcd0 /drivers/mtd/ubi/ubi.h | |
parent | 492b057c426e4aa747484958e18e9da29003985d (diff) | |
parent | 3fe0344faf7fdcb158bd5c1a9aec960a8d70c8e8 (diff) |
Merge commit 'origin/master' into next
Diffstat (limited to 'drivers/mtd/ubi/ubi.h')
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 84 |
1 files changed, 49 insertions, 35 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index c055511bb1b2..28acd133c997 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/device.h> | 36 | #include <linux/device.h> |
37 | #include <linux/string.h> | 37 | #include <linux/string.h> |
38 | #include <linux/vmalloc.h> | 38 | #include <linux/vmalloc.h> |
39 | #include <linux/notifier.h> | ||
39 | #include <linux/mtd/mtd.h> | 40 | #include <linux/mtd/mtd.h> |
40 | #include <linux/mtd/ubi.h> | 41 | #include <linux/mtd/ubi.h> |
41 | 42 | ||
@@ -100,6 +101,28 @@ enum { | |||
100 | UBI_IO_BITFLIPS | 101 | UBI_IO_BITFLIPS |
101 | }; | 102 | }; |
102 | 103 | ||
104 | /* | ||
105 | * Return codes of the 'ubi_eba_copy_leb()' function. | ||
106 | * | ||
107 | * MOVE_CANCEL_RACE: canceled because the volume is being deleted, the source | ||
108 | * PEB was put meanwhile, or there is I/O on the source PEB | ||
109 | * MOVE_SOURCE_RD_ERR: canceled because there was a read error from the source | ||
110 | * PEB | ||
111 | * MOVE_TARGET_RD_ERR: canceled because there was a read error from the target | ||
112 | * PEB | ||
113 | * MOVE_TARGET_WR_ERR: canceled because there was a write error to the target | ||
114 | * PEB | ||
115 | * MOVE_CANCEL_BITFLIPS: canceled because a bit-flip was detected in the | ||
116 | * target PEB | ||
117 | */ | ||
118 | enum { | ||
119 | MOVE_CANCEL_RACE = 1, | ||
120 | MOVE_SOURCE_RD_ERR, | ||
121 | MOVE_TARGET_RD_ERR, | ||
122 | MOVE_TARGET_WR_ERR, | ||
123 | MOVE_CANCEL_BITFLIPS, | ||
124 | }; | ||
125 | |||
103 | /** | 126 | /** |
104 | * struct ubi_wl_entry - wear-leveling entry. | 127 | * struct ubi_wl_entry - wear-leveling entry. |
105 | * @u.rb: link in the corresponding (free/used) RB-tree | 128 | * @u.rb: link in the corresponding (free/used) RB-tree |
@@ -208,10 +231,6 @@ struct ubi_volume_desc; | |||
208 | * @changing_leb: %1 if the atomic LEB change ioctl command is in progress | 231 | * @changing_leb: %1 if the atomic LEB change ioctl command is in progress |
209 | * @direct_writes: %1 if direct writes are enabled for this volume | 232 | * @direct_writes: %1 if direct writes are enabled for this volume |
210 | * | 233 | * |
211 | * @gluebi_desc: gluebi UBI volume descriptor | ||
212 | * @gluebi_refcount: reference count of the gluebi MTD device | ||
213 | * @gluebi_mtd: MTD device description object of the gluebi MTD device | ||
214 | * | ||
215 | * The @corrupted field indicates that the volume's contents is corrupted. | 234 | * The @corrupted field indicates that the volume's contents is corrupted. |
216 | * Since UBI protects only static volumes, this field is not relevant to | 235 | * Since UBI protects only static volumes, this field is not relevant to |
217 | * dynamic volumes - it is user's responsibility to assure their data | 236 | * dynamic volumes - it is user's responsibility to assure their data |
@@ -255,17 +274,6 @@ struct ubi_volume { | |||
255 | unsigned int updating:1; | 274 | unsigned int updating:1; |
256 | unsigned int changing_leb:1; | 275 | unsigned int changing_leb:1; |
257 | unsigned int direct_writes:1; | 276 | unsigned int direct_writes:1; |
258 | |||
259 | #ifdef CONFIG_MTD_UBI_GLUEBI | ||
260 | /* | ||
261 | * Gluebi-related stuff may be compiled out. | ||
262 | * Note: this should not be built into UBI but should be a separate | ||
263 | * ubimtd driver which works on top of UBI and emulates MTD devices. | ||
264 | */ | ||
265 | struct ubi_volume_desc *gluebi_desc; | ||
266 | int gluebi_refcount; | ||
267 | struct mtd_info gluebi_mtd; | ||
268 | #endif | ||
269 | }; | 277 | }; |
270 | 278 | ||
271 | /** | 279 | /** |
@@ -305,9 +313,9 @@ struct ubi_wl_entry; | |||
305 | * @vtbl_slots: how many slots are available in the volume table | 313 | * @vtbl_slots: how many slots are available in the volume table |
306 | * @vtbl_size: size of the volume table in bytes | 314 | * @vtbl_size: size of the volume table in bytes |
307 | * @vtbl: in-RAM volume table copy | 315 | * @vtbl: in-RAM volume table copy |
308 | * @volumes_mutex: protects on-flash volume table and serializes volume | 316 | * @device_mutex: protects on-flash volume table and serializes volume |
309 | * changes, like creation, deletion, update, re-size, | 317 | * creation, deletion, update, re-size, re-name and set |
310 | * re-name and set property | 318 | * property |
311 | * | 319 | * |
312 | * @max_ec: current highest erase counter value | 320 | * @max_ec: current highest erase counter value |
313 | * @mean_ec: current mean erase counter value | 321 | * @mean_ec: current mean erase counter value |
@@ -318,14 +326,15 @@ struct ubi_wl_entry; | |||
318 | * @alc_mutex: serializes "atomic LEB change" operations | 326 | * @alc_mutex: serializes "atomic LEB change" operations |
319 | * | 327 | * |
320 | * @used: RB-tree of used physical eraseblocks | 328 | * @used: RB-tree of used physical eraseblocks |
329 | * @erroneous: RB-tree of erroneous used physical eraseblocks | ||
321 | * @free: RB-tree of free physical eraseblocks | 330 | * @free: RB-tree of free physical eraseblocks |
322 | * @scrub: RB-tree of physical eraseblocks which need scrubbing | 331 | * @scrub: RB-tree of physical eraseblocks which need scrubbing |
323 | * @pq: protection queue (contain physical eraseblocks which are temporarily | 332 | * @pq: protection queue (contain physical eraseblocks which are temporarily |
324 | * protected from the wear-leveling worker) | 333 | * protected from the wear-leveling worker) |
325 | * @pq_head: protection queue head | 334 | * @pq_head: protection queue head |
326 | * @wl_lock: protects the @used, @free, @pq, @pq_head, @lookuptbl, @move_from, | 335 | * @wl_lock: protects the @used, @free, @pq, @pq_head, @lookuptbl, @move_from, |
327 | * @move_to, @move_to_put @erase_pending, @wl_scheduled and @works | 336 | * @move_to, @move_to_put @erase_pending, @wl_scheduled, @works, |
328 | * fields | 337 | * @erroneous, and @erroneous_peb_count fields |
329 | * @move_mutex: serializes eraseblock moves | 338 | * @move_mutex: serializes eraseblock moves |
330 | * @work_sem: synchronizes the WL worker with use tasks | 339 | * @work_sem: synchronizes the WL worker with use tasks |
331 | * @wl_scheduled: non-zero if the wear-leveling was scheduled | 340 | * @wl_scheduled: non-zero if the wear-leveling was scheduled |
@@ -339,12 +348,15 @@ struct ubi_wl_entry; | |||
339 | * @bgt_thread: background thread description object | 348 | * @bgt_thread: background thread description object |
340 | * @thread_enabled: if the background thread is enabled | 349 | * @thread_enabled: if the background thread is enabled |
341 | * @bgt_name: background thread name | 350 | * @bgt_name: background thread name |
351 | * @reboot_notifier: notifier to terminate background thread before rebooting | ||
342 | * | 352 | * |
343 | * @flash_size: underlying MTD device size (in bytes) | 353 | * @flash_size: underlying MTD device size (in bytes) |
344 | * @peb_count: count of physical eraseblocks on the MTD device | 354 | * @peb_count: count of physical eraseblocks on the MTD device |
345 | * @peb_size: physical eraseblock size | 355 | * @peb_size: physical eraseblock size |
346 | * @bad_peb_count: count of bad physical eraseblocks | 356 | * @bad_peb_count: count of bad physical eraseblocks |
347 | * @good_peb_count: count of good physical eraseblocks | 357 | * @good_peb_count: count of good physical eraseblocks |
358 | * @erroneous_peb_count: count of erroneous physical eraseblocks in @erroneous | ||
359 | * @max_erroneous: maximum allowed amount of erroneous physical eraseblocks | ||
348 | * @min_io_size: minimal input/output unit size of the underlying MTD device | 360 | * @min_io_size: minimal input/output unit size of the underlying MTD device |
349 | * @hdrs_min_io_size: minimal I/O unit size used for VID and EC headers | 361 | * @hdrs_min_io_size: minimal I/O unit size used for VID and EC headers |
350 | * @ro_mode: if the UBI device is in read-only mode | 362 | * @ro_mode: if the UBI device is in read-only mode |
@@ -366,7 +378,6 @@ struct ubi_wl_entry; | |||
366 | * @peb_buf2: another buffer of PEB size used for different purposes | 378 | * @peb_buf2: another buffer of PEB size used for different purposes |
367 | * @buf_mutex: protects @peb_buf1 and @peb_buf2 | 379 | * @buf_mutex: protects @peb_buf1 and @peb_buf2 |
368 | * @ckvol_mutex: serializes static volume checking when opening | 380 | * @ckvol_mutex: serializes static volume checking when opening |
369 | * @mult_mutex: serializes operations on multiple volumes, like re-naming | ||
370 | * @dbg_peb_buf: buffer of PEB size used for debugging | 381 | * @dbg_peb_buf: buffer of PEB size used for debugging |
371 | * @dbg_buf_mutex: protects @dbg_peb_buf | 382 | * @dbg_buf_mutex: protects @dbg_peb_buf |
372 | */ | 383 | */ |
@@ -389,7 +400,7 @@ struct ubi_device { | |||
389 | int vtbl_slots; | 400 | int vtbl_slots; |
390 | int vtbl_size; | 401 | int vtbl_size; |
391 | struct ubi_vtbl_record *vtbl; | 402 | struct ubi_vtbl_record *vtbl; |
392 | struct mutex volumes_mutex; | 403 | struct mutex device_mutex; |
393 | 404 | ||
394 | int max_ec; | 405 | int max_ec; |
395 | /* Note, mean_ec is not updated run-time - should be fixed */ | 406 | /* Note, mean_ec is not updated run-time - should be fixed */ |
@@ -403,6 +414,7 @@ struct ubi_device { | |||
403 | 414 | ||
404 | /* Wear-leveling sub-system's stuff */ | 415 | /* Wear-leveling sub-system's stuff */ |
405 | struct rb_root used; | 416 | struct rb_root used; |
417 | struct rb_root erroneous; | ||
406 | struct rb_root free; | 418 | struct rb_root free; |
407 | struct rb_root scrub; | 419 | struct rb_root scrub; |
408 | struct list_head pq[UBI_PROT_QUEUE_LEN]; | 420 | struct list_head pq[UBI_PROT_QUEUE_LEN]; |
@@ -420,6 +432,7 @@ struct ubi_device { | |||
420 | struct task_struct *bgt_thread; | 432 | struct task_struct *bgt_thread; |
421 | int thread_enabled; | 433 | int thread_enabled; |
422 | char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2]; | 434 | char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2]; |
435 | struct notifier_block reboot_notifier; | ||
423 | 436 | ||
424 | /* I/O sub-system's stuff */ | 437 | /* I/O sub-system's stuff */ |
425 | long long flash_size; | 438 | long long flash_size; |
@@ -427,6 +440,8 @@ struct ubi_device { | |||
427 | int peb_size; | 440 | int peb_size; |
428 | int bad_peb_count; | 441 | int bad_peb_count; |
429 | int good_peb_count; | 442 | int good_peb_count; |
443 | int erroneous_peb_count; | ||
444 | int max_erroneous; | ||
430 | int min_io_size; | 445 | int min_io_size; |
431 | int hdrs_min_io_size; | 446 | int hdrs_min_io_size; |
432 | int ro_mode; | 447 | int ro_mode; |
@@ -444,8 +459,7 @@ struct ubi_device { | |||
444 | void *peb_buf2; | 459 | void *peb_buf2; |
445 | struct mutex buf_mutex; | 460 | struct mutex buf_mutex; |
446 | struct mutex ckvol_mutex; | 461 | struct mutex ckvol_mutex; |
447 | struct mutex mult_mutex; | 462 | #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID |
448 | #ifdef CONFIG_MTD_UBI_DEBUG | ||
449 | void *dbg_peb_buf; | 463 | void *dbg_peb_buf; |
450 | struct mutex dbg_buf_mutex; | 464 | struct mutex dbg_buf_mutex; |
451 | #endif | 465 | #endif |
@@ -457,6 +471,7 @@ extern const struct file_operations ubi_cdev_operations; | |||
457 | extern const struct file_operations ubi_vol_cdev_operations; | 471 | extern const struct file_operations ubi_vol_cdev_operations; |
458 | extern struct class *ubi_class; | 472 | extern struct class *ubi_class; |
459 | extern struct mutex ubi_devices_mutex; | 473 | extern struct mutex ubi_devices_mutex; |
474 | extern struct blocking_notifier_head ubi_notifiers; | ||
460 | 475 | ||
461 | /* vtbl.c */ | 476 | /* vtbl.c */ |
462 | int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, | 477 | int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, |
@@ -489,17 +504,6 @@ int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, | |||
489 | int ubi_check_volume(struct ubi_device *ubi, int vol_id); | 504 | int ubi_check_volume(struct ubi_device *ubi, int vol_id); |
490 | void ubi_calculate_reserved(struct ubi_device *ubi); | 505 | void ubi_calculate_reserved(struct ubi_device *ubi); |
491 | 506 | ||
492 | /* gluebi.c */ | ||
493 | #ifdef CONFIG_MTD_UBI_GLUEBI | ||
494 | int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol); | ||
495 | int ubi_destroy_gluebi(struct ubi_volume *vol); | ||
496 | void ubi_gluebi_updated(struct ubi_volume *vol); | ||
497 | #else | ||
498 | #define ubi_create_gluebi(ubi, vol) 0 | ||
499 | #define ubi_destroy_gluebi(vol) 0 | ||
500 | #define ubi_gluebi_updated(vol) | ||
501 | #endif | ||
502 | |||
503 | /* eba.c */ | 507 | /* eba.c */ |
504 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, | 508 | int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, |
505 | int lnum); | 509 | int lnum); |
@@ -549,6 +553,16 @@ struct ubi_device *ubi_get_device(int ubi_num); | |||
549 | void ubi_put_device(struct ubi_device *ubi); | 553 | void ubi_put_device(struct ubi_device *ubi); |
550 | struct ubi_device *ubi_get_by_major(int major); | 554 | struct ubi_device *ubi_get_by_major(int major); |
551 | int ubi_major2num(int major); | 555 | int ubi_major2num(int major); |
556 | int ubi_volume_notify(struct ubi_device *ubi, struct ubi_volume *vol, | ||
557 | int ntype); | ||
558 | int ubi_notify_all(struct ubi_device *ubi, int ntype, | ||
559 | struct notifier_block *nb); | ||
560 | int ubi_enumerate_volumes(struct notifier_block *nb); | ||
561 | |||
562 | /* kapi.c */ | ||
563 | void ubi_do_get_device_info(struct ubi_device *ubi, struct ubi_device_info *di); | ||
564 | void ubi_do_get_volume_info(struct ubi_device *ubi, struct ubi_volume *vol, | ||
565 | struct ubi_volume_info *vi); | ||
552 | 566 | ||
553 | /* | 567 | /* |
554 | * ubi_rb_for_each_entry - walk an RB-tree. | 568 | * ubi_rb_for_each_entry - walk an RB-tree. |