imsm: clear bad block from bad block log

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
This commit is contained in:
Tomasz Majchrzak 2016-11-29 14:02:31 +01:00 committed by Jes Sorensen
parent 6f50473f25
commit c07a5a4f41
1 changed files with 53 additions and 0 deletions

View File

@ -904,6 +904,28 @@ static int record_new_badblock(struct bbm_log *log, const __u8 idx, unsigned
return new_bb;
}
/* clear given bad block */
static int clear_badblock(struct bbm_log *log, const __u8 idx, const unsigned
long long sector, const int length) {
__u32 i = 0;
while (i < log->entry_count) {
struct bbm_log_entry *entries = log->marked_block_entries;
if ((entries[i].disk_ordinal == idx) &&
(__le48_to_cpu(&entries[i].defective_block_start) ==
sector) && (entries[i].marked_count + 1 == length)) {
if (i < log->entry_count - 1)
entries[i] = entries[log->entry_count - 1];
log->entry_count--;
break;
}
i++;
}
return 1;
}
#endif /* MDASSEMBLE */
/* allocate and load BBM log from metadata */
@ -9797,6 +9819,36 @@ static int imsm_record_badblock(struct active_array *a, int slot,
return ret;
}
/*******************************************************************************
* Function: imsm_clear_badblock
* Description: This routine clears bad block record from BBM log
*
* Parameters:
* a : array containing a bad block
* slot : disk number containing a bad block
* sector : bad block sector
* length : bad block sectors range
* Returns:
* 1 : Success
* 0 : Error
******************************************************************************/
static int imsm_clear_badblock(struct active_array *a, int slot,
unsigned long long sector, int length)
{
struct intel_super *super = a->container->sb;
int ord;
int ret;
ord = imsm_disk_slot_to_ord(a, slot);
if (ord < 0)
return 0;
ret = clear_badblock(super->bbm_log, ord_to_idx(ord), sector, length);
if (ret)
super->updates_pending++;
return ret;
}
/*******************************************************************************
* Function: init_migr_record_imsm
* Description: Function inits imsm migration record
@ -11351,5 +11403,6 @@ struct superswitch super_imsm = {
.process_update = imsm_process_update,
.prepare_update = imsm_prepare_update,
.record_bad_block = imsm_record_badblock,
.clear_bad_block = imsm_clear_badblock,
#endif /* MDASSEMBLE */
};