@@ -1274,7 +1274,7 @@ static int _badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors,
sector_t *first_bad, int *bad_sectors)
{
- int unacked_badblocks, acked_badblocks;
+ int acked_badblocks;
int prev = -1, hint = -1, set = 0;
struct badblocks_context bad;
unsigned int seq;
@@ -1297,7 +1297,6 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors,
seq = read_seqbegin(&bb->lock);
p = bb->page;
- unacked_badblocks = 0;
acked_badblocks = 0;
re_check:
@@ -1318,21 +1317,24 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors,
}
if (overlap_front(bb, prev, &bad)) {
- if (BB_ACK(p[prev]))
+ if (set == 0) {
+ *first_bad = BB_OFFSET(p[prev]);
+ *bad_sectors = BB_LEN(p[prev]);
+ set = 1;
+ }
+
+ if (BB_ACK(p[prev])) {
acked_badblocks++;
- else
- unacked_badblocks++;
+ } else {
+ rv = -1;
+ goto out;
+ }
if (BB_END(p[prev]) >= (s + sectors))
len = sectors;
else
len = BB_END(p[prev]) - s;
- if (set == 0) {
- *first_bad = BB_OFFSET(p[prev]);
- *bad_sectors = BB_LEN(p[prev]);
- set = 1;
- }
goto update_sectors;
}
@@ -1355,13 +1357,12 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors,
WARN_ON(sectors < 0);
- if (unacked_badblocks > 0)
- rv = -1;
- else if (acked_badblocks > 0)
+ if (acked_badblocks > 0)
rv = 1;
else
rv = 0;
+out:
if (read_seqretry(&bb->lock, seq))
goto retry;