diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-16 03:25:56 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-24 06:32:56 -0400 |
commit | 85c6e6e28259e9b58b8984db536c45bc3161f40c (patch) | |
tree | f389adfe74753f318290b45b7ce190421d18c48e /drivers/mtd/ubi/wl.c | |
parent | bb84c1a199558962edf4b4aeb4480fb09aa09b91 (diff) |
UBI: amend commentaries
Hch asked not to use "unit" for sub-systems, let it be so.
Also some other commentaries modifications.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/wl.c')
-rw-r--r-- | drivers/mtd/ubi/wl.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index cc8fe2934d2b..761952ba125b 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
@@ -19,22 +19,22 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * UBI wear-leveling unit. | 22 | * UBI wear-leveling sub-system. |
23 | * | 23 | * |
24 | * This unit is responsible for wear-leveling. It works in terms of physical | 24 | * This sub-system is responsible for wear-leveling. It works in terms of |
25 | * eraseblocks and erase counters and knows nothing about logical eraseblocks, | 25 | * physical* eraseblocks and erase counters and knows nothing about logical |
26 | * volumes, etc. From this unit's perspective all physical eraseblocks are of | 26 | * eraseblocks, volumes, etc. From this sub-system's perspective all physical |
27 | * two types - used and free. Used physical eraseblocks are those that were | 27 | * eraseblocks are of two types - used and free. Used physical eraseblocks are |
28 | * "get" by the 'ubi_wl_get_peb()' function, and free physical eraseblocks are | 28 | * those that were "get" by the 'ubi_wl_get_peb()' function, and free physical |
29 | * those that were put by the 'ubi_wl_put_peb()' function. | 29 | * eraseblocks are those that were put by the 'ubi_wl_put_peb()' function. |
30 | * | 30 | * |
31 | * Physical eraseblocks returned by 'ubi_wl_get_peb()' have only erase counter | 31 | * Physical eraseblocks returned by 'ubi_wl_get_peb()' have only erase counter |
32 | * header. The rest of the physical eraseblock contains only 0xFF bytes. | 32 | * header. The rest of the physical eraseblock contains only %0xFF bytes. |
33 | * | 33 | * |
34 | * When physical eraseblocks are returned to the WL unit by means of the | 34 | * When physical eraseblocks are returned to the WL sub-system by means of the |
35 | * 'ubi_wl_put_peb()' function, they are scheduled for erasure. The erasure is | 35 | * 'ubi_wl_put_peb()' function, they are scheduled for erasure. The erasure is |
36 | * done asynchronously in context of the per-UBI device background thread, | 36 | * done asynchronously in context of the per-UBI device background thread, |
37 | * which is also managed by the WL unit. | 37 | * which is also managed by the WL sub-system. |
38 | * | 38 | * |
39 | * The wear-leveling is ensured by means of moving the contents of used | 39 | * The wear-leveling is ensured by means of moving the contents of used |
40 | * physical eraseblocks with low erase counter to free physical eraseblocks | 40 | * physical eraseblocks with low erase counter to free physical eraseblocks |
@@ -43,34 +43,36 @@ | |||
43 | * The 'ubi_wl_get_peb()' function accepts data type hints which help to pick | 43 | * The 'ubi_wl_get_peb()' function accepts data type hints which help to pick |
44 | * an "optimal" physical eraseblock. For example, when it is known that the | 44 | * an "optimal" physical eraseblock. For example, when it is known that the |
45 | * physical eraseblock will be "put" soon because it contains short-term data, | 45 | * physical eraseblock will be "put" soon because it contains short-term data, |
46 | * the WL unit may pick a free physical eraseblock with low erase counter, and | 46 | * the WL sub-system may pick a free physical eraseblock with low erase |
47 | * so forth. | 47 | * counter, and so forth. |
48 | * | 48 | * |
49 | * If the WL unit fails to erase a physical eraseblock, it marks it as bad. | 49 | * If the WL sub-system fails to erase a physical eraseblock, it marks it as |
50 | * bad. | ||
50 | * | 51 | * |
51 | * This unit is also responsible for scrubbing. If a bit-flip is detected in a | 52 | * This sub-system is also responsible for scrubbing. If a bit-flip is detected |
52 | * physical eraseblock, it has to be moved. Technically this is the same as | 53 | * in a physical eraseblock, it has to be moved. Technically this is the same |
53 | * moving it for wear-leveling reasons. | 54 | * as moving it for wear-leveling reasons. |
54 | * | 55 | * |
55 | * As it was said, for the UBI unit all physical eraseblocks are either "free" | 56 | * As it was said, for the UBI sub-system all physical eraseblocks are either |
56 | * or "used". Free eraseblock are kept in the @wl->free RB-tree, while used | 57 | * "free" or "used". Free eraseblock are kept in the @wl->free RB-tree, while |
57 | * eraseblocks are kept in a set of different RB-trees: @wl->used, | 58 | * used eraseblocks are kept in a set of different RB-trees: @wl->used, |
58 | * @wl->prot.pnum, @wl->prot.aec, and @wl->scrub. | 59 | * @wl->prot.pnum, @wl->prot.aec, and @wl->scrub. |
59 | * | 60 | * |
60 | * Note, in this implementation, we keep a small in-RAM object for each physical | 61 | * Note, in this implementation, we keep a small in-RAM object for each physical |
61 | * eraseblock. This is surely not a scalable solution. But it appears to be good | 62 | * eraseblock. This is surely not a scalable solution. But it appears to be good |
62 | * enough for moderately large flashes and it is simple. In future, one may | 63 | * enough for moderately large flashes and it is simple. In future, one may |
63 | * re-work this unit and make it more scalable. | 64 | * re-work this sub-system and make it more scalable. |
64 | * | 65 | * |
65 | * At the moment this unit does not utilize the sequence number, which was | 66 | * At the moment this sub-system does not utilize the sequence number, which |
66 | * introduced relatively recently. But it would be wise to do this because the | 67 | * was introduced relatively recently. But it would be wise to do this because |
67 | * sequence number of a logical eraseblock characterizes how old is it. For | 68 | * the sequence number of a logical eraseblock characterizes how old is it. For |
68 | * example, when we move a PEB with low erase counter, and we need to pick the | 69 | * example, when we move a PEB with low erase counter, and we need to pick the |
69 | * target PEB, we pick a PEB with the highest EC if our PEB is "old" and we | 70 | * target PEB, we pick a PEB with the highest EC if our PEB is "old" and we |
70 | * pick target PEB with an average EC if our PEB is not very "old". This is a | 71 | * pick target PEB with an average EC if our PEB is not very "old". This is a |
71 | * room for future re-works of the WL unit. | 72 | * room for future re-works of the WL sub-system. |
72 | * | 73 | * |
73 | * FIXME: looks too complex, should be simplified (later). | 74 | * Note: the stuff with protection trees looks too complex and is difficult to |
75 | * understand. Should be fixed. | ||
74 | */ | 76 | */ |
75 | 77 | ||
76 | #include <linux/slab.h> | 78 | #include <linux/slab.h> |
@@ -92,20 +94,21 @@ | |||
92 | 94 | ||
93 | /* | 95 | /* |
94 | * Maximum difference between two erase counters. If this threshold is | 96 | * Maximum difference between two erase counters. If this threshold is |
95 | * exceeded, the WL unit starts moving data from used physical eraseblocks with | 97 | * exceeded, the WL sub-system starts moving data from used physical |
96 | * low erase counter to free physical eraseblocks with high erase counter. | 98 | * eraseblocks with low erase counter to free physical eraseblocks with high |
99 | * erase counter. | ||
97 | */ | 100 | */ |
98 | #define UBI_WL_THRESHOLD CONFIG_MTD_UBI_WL_THRESHOLD | 101 | #define UBI_WL_THRESHOLD CONFIG_MTD_UBI_WL_THRESHOLD |
99 | 102 | ||
100 | /* | 103 | /* |
101 | * When a physical eraseblock is moved, the WL unit has to pick the target | 104 | * When a physical eraseblock is moved, the WL sub-system has to pick the target |
102 | * physical eraseblock to move to. The simplest way would be just to pick the | 105 | * physical eraseblock to move to. The simplest way would be just to pick the |
103 | * one with the highest erase counter. But in certain workloads this could lead | 106 | * one with the highest erase counter. But in certain workloads this could lead |
104 | * to an unlimited wear of one or few physical eraseblock. Indeed, imagine a | 107 | * to an unlimited wear of one or few physical eraseblock. Indeed, imagine a |
105 | * situation when the picked physical eraseblock is constantly erased after the | 108 | * situation when the picked physical eraseblock is constantly erased after the |
106 | * data is written to it. So, we have a constant which limits the highest erase | 109 | * data is written to it. So, we have a constant which limits the highest erase |
107 | * counter of the free physical eraseblock to pick. Namely, the WL unit does | 110 | * counter of the free physical eraseblock to pick. Namely, the WL sub-system |
108 | * not pick eraseblocks with erase counter greater then the lowest erase | 111 | * does not pick eraseblocks with erase counter greater then the lowest erase |
109 | * counter plus %WL_FREE_MAX_DIFF. | 112 | * counter plus %WL_FREE_MAX_DIFF. |
110 | */ | 113 | */ |
111 | #define WL_FREE_MAX_DIFF (2*UBI_WL_THRESHOLD) | 114 | #define WL_FREE_MAX_DIFF (2*UBI_WL_THRESHOLD) |
@@ -123,11 +126,11 @@ | |||
123 | * @abs_ec: the absolute erase counter value when the protection ends | 126 | * @abs_ec: the absolute erase counter value when the protection ends |
124 | * @e: the wear-leveling entry of the physical eraseblock under protection | 127 | * @e: the wear-leveling entry of the physical eraseblock under protection |
125 | * | 128 | * |
126 | * When the WL unit returns a physical eraseblock, the physical eraseblock is | 129 | * When the WL sub-system returns a physical eraseblock, the physical |
127 | * protected from being moved for some "time". For this reason, the physical | 130 | * eraseblock is protected from being moved for some "time". For this reason, |
128 | * eraseblock is not directly moved from the @wl->free tree to the @wl->used | 131 | * the physical eraseblock is not directly moved from the @wl->free tree to the |
129 | * tree. There is one more tree in between where this physical eraseblock is | 132 | * @wl->used tree. There is one more tree in between where this physical |
130 | * temporarily stored (@wl->prot). | 133 | * eraseblock is temporarily stored (@wl->prot). |
131 | * | 134 | * |
132 | * All this protection stuff is needed because: | 135 | * All this protection stuff is needed because: |
133 | * o we don't want to move physical eraseblocks just after we have given them | 136 | * o we don't want to move physical eraseblocks just after we have given them |
@@ -175,7 +178,6 @@ struct ubi_wl_prot_entry { | |||
175 | * @list: a link in the list of pending works | 178 | * @list: a link in the list of pending works |
176 | * @func: worker function | 179 | * @func: worker function |
177 | * @priv: private data of the worker function | 180 | * @priv: private data of the worker function |
178 | * | ||
179 | * @e: physical eraseblock to erase | 181 | * @e: physical eraseblock to erase |
180 | * @torture: if the physical eraseblock has to be tortured | 182 | * @torture: if the physical eraseblock has to be tortured |
181 | * | 183 | * |
@@ -1136,7 +1138,7 @@ out_ro: | |||
1136 | } | 1138 | } |
1137 | 1139 | ||
1138 | /** | 1140 | /** |
1139 | * ubi_wl_put_peb - return a physical eraseblock to the wear-leveling unit. | 1141 | * ubi_wl_put_peb - return a PEB to the wear-leveling sub-system. |
1140 | * @ubi: UBI device description object | 1142 | * @ubi: UBI device description object |
1141 | * @pnum: physical eraseblock to return | 1143 | * @pnum: physical eraseblock to return |
1142 | * @torture: if this physical eraseblock has to be tortured | 1144 | * @torture: if this physical eraseblock has to be tortured |
@@ -1175,11 +1177,11 @@ retry: | |||
1175 | /* | 1177 | /* |
1176 | * User is putting the physical eraseblock which was selected | 1178 | * User is putting the physical eraseblock which was selected |
1177 | * as the target the data is moved to. It may happen if the EBA | 1179 | * as the target the data is moved to. It may happen if the EBA |
1178 | * unit already re-mapped the LEB in 'ubi_eba_copy_leb()' but | 1180 | * sub-system already re-mapped the LEB in 'ubi_eba_copy_leb()' |
1179 | * the WL unit has not put the PEB to the "used" tree yet, but | 1181 | * but the WL sub-system has not put the PEB to the "used" tree |
1180 | * it is about to do this. So we just set a flag which will | 1182 | * yet, but it is about to do this. So we just set a flag which |
1181 | * tell the WL worker that the PEB is not needed anymore and | 1183 | * will tell the WL worker that the PEB is not needed anymore |
1182 | * should be scheduled for erasure. | 1184 | * and should be scheduled for erasure. |
1183 | */ | 1185 | */ |
1184 | dbg_wl("PEB %d is the target of data moving", pnum); | 1186 | dbg_wl("PEB %d is the target of data moving", pnum); |
1185 | ubi_assert(!ubi->move_to_put); | 1187 | ubi_assert(!ubi->move_to_put); |
@@ -1425,8 +1427,7 @@ static void cancel_pending(struct ubi_device *ubi) | |||
1425 | } | 1427 | } |
1426 | 1428 | ||
1427 | /** | 1429 | /** |
1428 | * ubi_wl_init_scan - initialize the wear-leveling unit using scanning | 1430 | * ubi_wl_init_scan - initialize the WL sub-system using scanning information. |
1429 | * information. | ||
1430 | * @ubi: UBI device description object | 1431 | * @ubi: UBI device description object |
1431 | * @si: scanning information | 1432 | * @si: scanning information |
1432 | * | 1433 | * |
@@ -1583,13 +1584,12 @@ static void protection_trees_destroy(struct ubi_device *ubi) | |||
1583 | } | 1584 | } |
1584 | 1585 | ||
1585 | /** | 1586 | /** |
1586 | * ubi_wl_close - close the wear-leveling unit. | 1587 | * ubi_wl_close - close the wear-leveling sub-system. |
1587 | * @ubi: UBI device description object | 1588 | * @ubi: UBI device description object |
1588 | */ | 1589 | */ |
1589 | void ubi_wl_close(struct ubi_device *ubi) | 1590 | void ubi_wl_close(struct ubi_device *ubi) |
1590 | { | 1591 | { |
1591 | dbg_wl("close the UBI wear-leveling unit"); | 1592 | dbg_wl("close the WL sub-system"); |
1592 | |||
1593 | cancel_pending(ubi); | 1593 | cancel_pending(ubi); |
1594 | protection_trees_destroy(ubi); | 1594 | protection_trees_destroy(ubi); |
1595 | tree_destroy(&ubi->used); | 1595 | tree_destroy(&ubi->used); |