We need to refuse to assemble an arrays with bad blocks.
Initially there was condition in container_content function
that returns error value in the case when metadata store information
about bad blocks.
When the container_content function is called from functions NOT connected
with assemble (Kill_subarray, Detail) we get faulty error return value.
Patch introduces new flag in array.status - MD_SB_BBM_ERRORS. It is set
in container_content when bad blocks are detected and can be checked by
container_content caller.
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
content;
content = content->next) {
+ /* do not assemble arrays that might have bad blocks */
+ if (content->array.state & (1<<MD_SB_BBM_ERRORS)) {
+ fprintf(stderr, Name ": BBM log found in metadata. "
+ "Cannot activate array(s).\n");
+ tmpdev->used = 2;
+ goto loop;
+ }
if (!ident_matches(ident, content, tst,
homehost, update,
report_missmatch ? devname : NULL))
if (map_lock(&map))
fprintf(stderr, Name ": failed to get exclusive lock on "
"mapfile\n");
+ /* do not assemble arrays that might have bad blocks */
+ if (list->array.state & (1<<MD_SB_BBM_ERRORS)) {
+ fprintf(stderr, Name ": BBM log found in metadata. "
+ "Cannot activate array(s).\n");
+ list = NULL;
+ }
for (ra = list ; ra ; ra = ra->next) {
int mdfd;
*/
#define MD_SB_CLEAN 0
#define MD_SB_ERRORS 1
+#define MD_SB_BBM_ERRORS 2
#define MD_SB_BITMAP_PRESENT 8 /* bitmap may be present nearby */
struct imsm_super *mpb = super->anchor;
struct mdinfo *rest = NULL;
unsigned int i;
+ int bbm_errors = 0;
- /* do not assemble arrays that might have bad blocks */
- if (imsm_bbm_log_size(super->anchor)) {
- fprintf(stderr, Name ": BBM log found in metadata. "
- "Cannot activate array(s).\n");
- return NULL;
- }
+ /* check for bad blocks */
+ if (imsm_bbm_log_size(super->anchor))
+ bbm_errors = 1;
for (i = 0; i < mpb->num_raid_devs; i++) {
struct imsm_dev *dev;
rest = this;
}
+ /* if array has bad blocks, set suitable bit in array status */
+ if (bbm_errors)
+ rest->array.state |= (1<<MD_SB_BBM_ERRORS);
+
return rest;
}