]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: clear bad block from bad block log
authorTomasz Majchrzak <tomasz.majchrzak@intel.com>
Tue, 29 Nov 2016 13:02:31 +0000 (14:02 +0100)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 2 Dec 2016 16:02:25 +0000 (11:02 -0500)
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
super-intel.c

index 54dafac04099ff7ab8c4c5db3bfc2b6cf3d16577..5c7f4d0732388e38626cd8d39dbb17858e53324d 100644 (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 */
 };