Merge tag 'for-6.3-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[linux-2.6-microblaze.git] / drivers / md / dm-log.c
index cf10fa6..afd94d2 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (C) 2003 Sistina Software
  * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
@@ -182,10 +183,12 @@ void dm_dirty_log_destroy(struct dm_dirty_log *log)
 }
 EXPORT_SYMBOL(dm_dirty_log_destroy);
 
-/*-----------------------------------------------------------------
+/*
+ *---------------------------------------------------------------
  * Persistent and core logs share a lot of their implementation.
  * FIXME: need a reload method to be called from a resume
- *---------------------------------------------------------------*/
+ *---------------------------------------------------------------
+ */
 /*
  * Magic for persistent mirrors: "MiRr"
  */
@@ -223,7 +226,7 @@ struct log_c {
        unsigned int region_count;
        region_t sync_count;
 
-       unsigned bitset_uint32_count;
+       unsigned int bitset_uint32_count;
        uint32_t *clean_bits;
        uint32_t *sync_bits;
        uint32_t *recovering_bits;      /* FIXME: this seems excessive */
@@ -255,28 +258,30 @@ struct log_c {
  * The touched member needs to be updated every time we access
  * one of the bitsets.
  */
-static inline int log_test_bit(uint32_t *bs, unsigned bit)
+static inline int log_test_bit(uint32_t *bs, unsigned int bit)
 {
        return test_bit_le(bit, bs) ? 1 : 0;
 }
 
 static inline void log_set_bit(struct log_c *l,
-                              uint32_t *bs, unsigned bit)
+                              uint32_t *bs, unsigned int bit)
 {
        __set_bit_le(bit, bs);
        l->touched_cleaned = 1;
 }
 
 static inline void log_clear_bit(struct log_c *l,
-                                uint32_t *bs, unsigned bit)
+                                uint32_t *bs, unsigned int bit)
 {
        __clear_bit_le(bit, bs);
        l->touched_dirtied = 1;
 }
 
-/*----------------------------------------------------------------
+/*
+ *---------------------------------------------------------------
  * Header IO
- *--------------------------------------------------------------*/
+ *--------------------------------------------------------------
+ */
 static void header_to_disk(struct log_header_core *core, struct log_header_disk *disk)
 {
        disk->magic = cpu_to_le32(core->magic);
@@ -352,11 +357,13 @@ static int _check_region_size(struct dm_target *ti, uint32_t region_size)
        return 1;
 }
 
-/*----------------------------------------------------------------
+/*
+ *--------------------------------------------------------------
  * core log constructor/destructor
  *
  * argv contains region_size followed optionally by [no]sync
- *--------------------------------------------------------------*/
+ *--------------------------------------------------------------
+ */
 #define BYTE_SHIFT 3
 static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
                              unsigned int argc, char **argv,
@@ -382,8 +389,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
                else if (!strcmp(argv[1], "nosync"))
                        sync = NOSYNC;
                else {
-                       DMWARN("unrecognised sync argument to "
-                              "dirty region log: %s", argv[1]);
+                       DMWARN("unrecognised sync argument to dirty region log: %s", argv[1]);
                        return -EINVAL;
                }
        }
@@ -441,8 +447,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
                 */
                buf_size =
                    dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + bitset_size,
-                               bdev_logical_block_size(lc->header_location.
-                                                           bdev));
+                               bdev_logical_block_size(lc->header_location.bdev));
 
                if (buf_size > bdev_nr_bytes(dev->bdev)) {
                        DMWARN("log device %s too small: need %llu bytes",
@@ -531,11 +536,13 @@ static void core_dtr(struct dm_dirty_log *log)
        destroy_log_context(lc);
 }
 
-/*----------------------------------------------------------------
+/*
+ *---------------------------------------------------------------------
  * disk log constructor/destructor
  *
  * argv contains log_device region_size followed optionally by [no]sync
- *--------------------------------------------------------------*/
+ *---------------------------------------------------------------------
+ */
 static int disk_ctr(struct dm_dirty_log *log, struct dm_target *ti,
                    unsigned int argc, char **argv)
 {
@@ -582,7 +589,7 @@ static void fail_log_device(struct log_c *lc)
 static int disk_resume(struct dm_dirty_log *log)
 {
        int r;
-       unsigned i;
+       unsigned int i;
        struct log_c *lc = (struct log_c *) log->context;
        size_t size = lc->bitset_uint32_count * sizeof(uint32_t);
 
@@ -646,12 +653,14 @@ static int disk_resume(struct dm_dirty_log *log)
 static uint32_t core_get_region_size(struct dm_dirty_log *log)
 {
        struct log_c *lc = (struct log_c *) log->context;
+
        return lc->region_size;
 }
 
 static int core_resume(struct dm_dirty_log *log)
 {
        struct log_c *lc = (struct log_c *) log->context;
+
        lc->sync_search = 0;
        return 0;
 }
@@ -659,12 +668,14 @@ static int core_resume(struct dm_dirty_log *log)
 static int core_is_clean(struct dm_dirty_log *log, region_t region)
 {
        struct log_c *lc = (struct log_c *) log->context;
+
        return log_test_bit(lc->clean_bits, region);
 }
 
 static int core_in_sync(struct dm_dirty_log *log, region_t region, int block)
 {
        struct log_c *lc = (struct log_c *) log->context;
+
        return log_test_bit(lc->sync_bits, region);
 }
 
@@ -717,12 +728,14 @@ static int disk_flush(struct dm_dirty_log *log)
 static void core_mark_region(struct dm_dirty_log *log, region_t region)
 {
        struct log_c *lc = (struct log_c *) log->context;
+
        log_clear_bit(lc, lc->clean_bits, region);
 }
 
 static void core_clear_region(struct dm_dirty_log *log, region_t region)
 {
        struct log_c *lc = (struct log_c *) log->context;
+
        if (likely(!lc->flush_failed))
                log_set_bit(lc, lc->clean_bits, region);
 }
@@ -757,8 +770,8 @@ static void core_set_region_sync(struct dm_dirty_log *log, region_t region,
        log_clear_bit(lc, lc->recovering_bits, region);
        if (in_sync) {
                log_set_bit(lc, lc->sync_bits, region);
-                lc->sync_count++;
-        } else if (log_test_bit(lc->sync_bits, region)) {
+               lc->sync_count++;
+       } else if (log_test_bit(lc->sync_bits, region)) {
                lc->sync_count--;
                log_clear_bit(lc, lc->sync_bits, region);
        }
@@ -766,14 +779,16 @@ static void core_set_region_sync(struct dm_dirty_log *log, region_t region,
 
 static region_t core_get_sync_count(struct dm_dirty_log *log)
 {
-        struct log_c *lc = (struct log_c *) log->context;
+       struct log_c *lc = (struct log_c *) log->context;
 
-        return lc->sync_count;
+       return lc->sync_count;
 }
 
 #define        DMEMIT_SYNC \
-       if (lc->sync != DEFAULTSYNC) \
-               DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : "")
+       do { \
+               if (lc->sync != DEFAULTSYNC) \
+                       DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : ""); \
+       } while (0)
 
 static int core_status(struct dm_dirty_log *log, status_type_t status,
                       char *result, unsigned int maxlen)
@@ -781,7 +796,7 @@ static int core_status(struct dm_dirty_log *log, status_type_t status,
        int sz = 0;
        struct log_c *lc = log->context;
 
-       switch(status) {
+       switch (status) {
        case STATUSTYPE_INFO:
                DMEMIT("1 %s", log->type->name);
                break;
@@ -806,7 +821,7 @@ static int disk_status(struct dm_dirty_log *log, status_type_t status,
        int sz = 0;
        struct log_c *lc = log->context;
 
-       switch(status) {
+       switch (status) {
        case STATUSTYPE_INFO:
                DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name,
                       lc->log_dev_flush_failed ? 'F' :