aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/badblocks.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/block/badblocks.c b/block/badblocks.c
index 6610e282a03e..6ebcef282314 100644
--- a/block/badblocks.c
+++ b/block/badblocks.c
@@ -133,6 +133,26 @@ retry:
133} 133}
134EXPORT_SYMBOL_GPL(badblocks_check); 134EXPORT_SYMBOL_GPL(badblocks_check);
135 135
136static void badblocks_update_acked(struct badblocks *bb)
137{
138 u64 *p = bb->page;
139 int i;
140 bool unacked = false;
141
142 if (!bb->unacked_exist)
143 return;
144
145 for (i = 0; i < bb->count ; i++) {
146 if (!BB_ACK(p[i])) {
147 unacked = true;
148 break;
149 }
150 }
151
152 if (!unacked)
153 bb->unacked_exist = 0;
154}
155
136/** 156/**
137 * badblocks_set() - Add a range of bad blocks to the table. 157 * badblocks_set() - Add a range of bad blocks to the table.
138 * @bb: the badblocks structure that holds all badblock information 158 * @bb: the badblocks structure that holds all badblock information
@@ -294,6 +314,8 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
294 bb->changed = 1; 314 bb->changed = 1;
295 if (!acknowledged) 315 if (!acknowledged)
296 bb->unacked_exist = 1; 316 bb->unacked_exist = 1;
317 else
318 badblocks_update_acked(bb);
297 write_sequnlock_irqrestore(&bb->lock, flags); 319 write_sequnlock_irqrestore(&bb->lock, flags);
298 320
299 return rv; 321 return rv;
@@ -401,6 +423,7 @@ int badblocks_clear(struct badblocks *bb, sector_t s, int sectors)
401 } 423 }
402 } 424 }
403 425
426 badblocks_update_acked(bb);
404 bb->changed = 1; 427 bb->changed = 1;
405out: 428out:
406 write_sequnlock_irq(&bb->lock); 429 write_sequnlock_irq(&bb->lock);