Lines Matching full:range

23  * When the caller of badblocks_set() wants to set a range of bad blocks, the
24 * setting range can be acked or unacked. And the setting range may merge,
25 * overwrite, skip the overlapped already set range, depends on who they are
27 * more complicated when the setting range covers multiple already set bad block
28 * ranges, with restrictions of maximum length of each bad range and the bad
32 * for setting a large range of bad blocks, we can handle it by dividing the
33 * large range into smaller ones when encounter overlap, max range length or
34 * bad table full conditions. Every time only a smaller piece of the bad range
39 * When setting a range of bad blocks to the bad table, the simplified situations
41 * prefix E, and the setting bad blocks range is naming with prefix S)
43 * 1) A setting range is not overlapped or adjacent to any other already set bad
44 * block range.
52 * free slot from the bad blocks table to mark the setting range S. The
57 * 2) A setting range starts exactly at a start LBA of an already set bad blocks
58 * range.
59 * 2.1) The setting range size < already set range size
66 * 2.1.1) If S and E are both acked or unacked range, the setting range S can
67 * be merged into existing bad range E. The result is,
76 * 2.1.3) If S is acked setting and E is unacked, range S can overwrite on E.
78 * of E will move to end of the inserted range S. The result is,
82 * 2.2) The setting range size == already set range size
83 * 2.2.1) If S and E are both acked or unacked range, the setting range S can
84 * be merged into existing bad range E. The result is,
93 * 2.2.3) If S is acked setting and E is unacked, range S can overwrite all of
94 bad blocks range E. The result is,
98 * 2.3) The setting range size > already set range size
105 * For such situation, the setting range S can be treated as two parts, the
106 * first part (S1) is as same size as the already set range E, the second
107 * part (S2) is the rest of setting range.
114 * Now we only focus on how to handle the setting range S1 and already set
115 * range E, which are already explained in 2.2), for the rest S2 it will be
117 * 3) A setting range starts before the start LBA of an already set bad blocks
118 * range.
125 * For this situation, the setting range S can be divided into two parts, the
126 * first (S1) ends at the start LBA of already set range E, the second part
127 * (S2) starts exactly at a start LBA of the already set range E.
136 * of the already set range E, they will be handled in next loop in one of
138 * 4) A setting range starts after the start LBA of an already set bad blocks
139 * range.
140 * 4.1) If the setting range S exactly matches the tail part of already set bad
141 * blocks range E, like the following chart shows,
148 * 4.1.1) If range S and E have same acknowledge value (both acked or unacked),
153 * 4.1.2) If range E is acked and the setting range S is unacked, the setting
158 * 4.1.3) If range E is unacked, and the setting range S is acked, then S may
159 * overwrite the overlapped range of E, the result is,
163 * 4.2) If the setting range S stays in middle of an already set range E, like
171 * 4.2.1) If range S and E have same acknowledge value (both acked or unacked),
176 * 4.2.2) If range E is acked and the setting range S is unacked, the setting
181 * 4.2.3) If range E is unacked, and the setting range S is acked, then S will
182 * inserted into middle of E and split previous range E into two parts (E1
187 * 4.3) If the setting bad blocks range S is overlapped with an already set bad
188 * blocks range E. The range S starts after the start LBA of range E, and
189 * ends after the end LBA of range E, as the following chart shows,
196 * For this situation the range S can be divided into two parts, the first
197 * part (S1) ends at end range E, and the second part (S2) has rest range of
205 * Now in this loop the setting range S1 and already set range E can be
206 * handled as the situations 4.1), the rest range S2 will be handled in next
208 * 5) A setting bad blocks range S is adjacent to one or more already set bad
209 * blocks range(s), and they are all acked or unacked range.
210 * 5.1) Front merge: If the already set bad blocks range E is before setting
211 * range S and they are adjacent,
218 * 5.1.1) When total size of range S and E <= BB_MAX_LEN, and their acknowledge
219 * values are same, the setting range S can front merges into range E. The
225 * range S right after already set range E into the bad blocks table. The
240 * first part of setting range S will fail because no more available slot
242 * setting method should be go though all the setting bad blocks range and
255 * can be merged with rest part of S into less range S1 and S2. Now there is
261 * origin setting range S. Now the setting range S3 can be inserted into the
265 * range and E2 is an unacked bad blocks range, therefore they are not able
266 * to merge into a larger range. The setting bad blocks range S is acked,
281 * The above result is correct but not perfect. Range E1 and S in the bad
282 * blocks table are all acked, merging them into a larger one range may
284 * Therefore in such situation, after overwriting range S, the previous range
290 * 6.3) Behind merge: If the already set bad blocks range E is behind the setting
291 * range S and they are adjacent. Normally we don't need to care about this
292 * because front merge handles this while going though range S from head to
293 * tail, except for the tail part of range S. When the setting range S are
295 * tail LBA of range S is adjacent to the next already set range and not
303 * For the above special situation, when the setting range S are all handled
305 * set range E is right after S and mergeable.
306 * 6.3.1) When total size of range E and S <= BB_MAX_LEN, and their acknowledge
307 * values are same, the setting range S can behind merges into range E. The
312 * 6.3.2) Otherwise these two ranges cannot merge, just insert the setting range
313 * S in front of the already set range E in the bad blocks table. The result
320 * the bad block range setting conditions. Maybe there is some rare corner case
325 * time for the new loop prev_badblocks() is called to find an already set range
326 * which starts before or at current setting range. Since the setting bad blocks
327 * range is handled from head to tail, most of the cases it is unnecessary to do
335 * Clearing a bad blocks range from the bad block table has similar idea as
337 * when the clearing range hits middle of a bad block range, the existing bad
338 * block range will split into two, and one more item should be added into the
341 * clearing bad blocks range is naming with prefix C)
343 * 1) A clearing range is not overlapped to any already set ranges in bad block
353 * 2) The clearing range hits middle of an already setting bad blocks range in
361 * In this situation if the bad block table is not full, the range E will be
366 * 3) The clearing range starts exactly at same LBA as an already set bad block range
375 * For this situation, the overlapped already set range will update the
376 * start LBA to end of C and shrink the range to BB_LEN(E) - BB_LEN(C). No
388 * For this situation the whole bad blocks range E will be cleared and its
390 * 4) The clearing range exactly ends at same LBA as an already set bad block
391 * range.
398 * For the above situation, the already set range E is updated to shrink its
404 * 5) The clearing range is partially overlapped with an already set bad block
405 * range from the bad block table.
406 * 5.1) The already set bad block range is front overlapped with the clearing
407 * range.
414 * For such situation, the clearing range C can be treated as two parts. The
415 * first part ends at the start LBA of range E, and the second part starts at
416 * same LBA of range E.
425 * 5.2) The already set bad block range is behind overlaopped with the clearing
426 * range.
433 * For such situation, the clearing range C can be treated as two parts. The
434 * first part C1 ends at same end LBA of range E, and the second part starts
435 * at end LBA of range E.
442 * Now the first part clearing range C1 can be handled as condition 4), and
443 * the second part clearing range C2 can be handled as condition 1) in next
446 * All bad blocks range clearing can be simplified into the above 5 situations
447 * by only handling the head part of the clearing range in each run of the
448 * while-loop. The idea is similar to bad blocks range setting but much
453 * Find the range starts at-or-before 's' from bad table. The search
476 * Find the range starts at-or-before bad->start. If 'hint' is provided
478 * very probably the wanted bad range can be found from the hint index,
531 * Return 'true' if the range indicated by 'bad' can be backward merged
532 * with the bad range (from the bad table) index by 'behind'.
550 * Do backward merge for range indicated by 'bad' and the bad range
576 * Return 'true' if the range indicated by 'bad' can be forward
577 * merged with the bad range (from the bad table) indexed by 'prev'.
593 * Do forward merge for range indicated by 'bad' and the bad range
624 * handle: If a bad range (indexed by 'prev' from bad table) exactly
625 * starts as bad->start, and the bad range ahead of 'prev' (indexed by
628 * these two bad range (from bad table) can be combined.
649 * table) into one larger bad range, and the new range is indexed by
666 * Return 'true' if the range indicated by 'bad' is exactly forward
667 * overlapped with the bad range (from bad table) indexed by 'front'.
668 * Exactly forward overlap means the bad range (from bad table) indexed
669 * by 'prev' does not cover the whole range indicated by 'bad'.
683 * Return 'true' if the range indicated by 'bad' is exactly backward
684 * overlapped with the bad range (from bad table) indexed by 'behind'.
698 * Return 'true' if the range indicated by 'bad' can overwrite the bad
699 * range (from bad table) indexed by 'prev'.
701 * The range indicated by 'bad' can overwrite the bad range indexed by
703 * 1) The whole range indicated by 'bad' can cover partial or whole bad
704 * range (from bad table) indexed by 'prev'.
706 * range 'prev'.
708 * If the overwriting doesn't cover the whole bad range (from bad table)
709 * indexed by 'prev', new range might be split from existing bad range,
710 * 1) The overwrite covers head or tail part of existing bad range, 1
711 * extra bad range will be split and added into the bad table.
712 * 2) The overwrite covers middle of existing bad range, 2 extra bad
713 * ranges will be split (ahead and after the overwritten range) and
742 * prev range will be split into two, beside the overwritten in can_front_overwrite()
755 * Do the overwrite from the range indicated by 'bad' to the bad range
758 * extra bad range(s) might be split and added into the bad table. All
820 * Explicitly insert a range indicated by 'bad' to the bad table, where
858 /* Do exact work to set bad block range into the bad block table */
982 /* if no space in table, still try to merge in the covered range */ in _badblocks_set()
984 /* skip the cannot-merge range */ in _badblocks_set()
1021 * Check whether the following already set range can be in _badblocks_set()
1067 * Clear the bad block range from bad block table which is front overlapped
1068 * with the clearing range. The return value is how many sectors from an
1069 * already set bad block range are cleared. If the whole bad block range is
1070 * covered by the clearing range and fully cleared, 'delete' is set as 1 for
1112 * Handle the condition that the clearing range hits middle of an already set
1113 * bad block range from bad block table. In this condition the existing bad
1114 * block range is split into two after the middle part is cleared.
1133 /* Do the exact work to clear bad block range from the bad block table */
1192 * Both situations are to clear non-bad range, in _badblocks_clear()
1241 /* Clear non-bad range should be treated as successful */ in _badblocks_clear()
1246 /* Not cover any badblocks range in the table */ in _badblocks_clear()
1248 /* Clear non-bad range should be treated as successful */ in _badblocks_clear()
1273 /* Do the exact work to check bad blocks range from the bad block table */
1348 /* not cover any badblocks range in the table */ in _badblocks_check()
1374 * badblocks_check() - check a given range for bad sectors
1384 * Length of bad-range, in sectors: 0-511 for lengths 1-512
1385 * Start of bad-range, sector offset, 54 bits (allows 8 exbibytes)
1395 * When looking for a bad block we specify a range and want to
1396 * know if any block in the range is bad. So we binary-search
1397 * to the last range that starts at-or-before the given endpoint,
1398 * (or "before the sector after the target range")
1402 * 0: there are no known bad blocks in the range
1415 * badblocks_set() - Add a range of bad blocks to the table.
1437 * badblocks_clear() - Remove a range of bad blocks to the table.