dm: fix undue/missing spaces
[platform/kernel/linux-starfive.git] / drivers / md / dm-writecache.c
index 96a003e..738533b 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (C) 2018 Red Hat. All rights reserved.
  *
@@ -85,12 +85,12 @@ struct wc_entry {
        unsigned short wc_list_contiguous;
        bool write_in_progress
 #if BITS_PER_LONG == 64
-               :1
+               : 1
 #endif
        ;
        unsigned long index
 #if BITS_PER_LONG == 64
-               :47
+               : 47
 #endif
        ;
        unsigned long age;
@@ -128,9 +128,9 @@ struct dm_writecache {
        unsigned long max_age;
        unsigned long pause;
 
-       unsigned uncommitted_blocks;
-       unsigned autocommit_blocks;
-       unsigned max_writeback_jobs;
+       unsigned int uncommitted_blocks;
+       unsigned int autocommit_blocks;
+       unsigned int max_writeback_jobs;
 
        int error;
 
@@ -155,7 +155,7 @@ struct dm_writecache {
        sector_t data_device_sectors;
        void *block_start;
        struct wc_entry *entries;
-       unsigned block_size;
+       unsigned int block_size;
        unsigned char block_size_bits;
 
        bool pmem_mode:1;
@@ -178,13 +178,13 @@ struct dm_writecache {
        bool metadata_only:1;
        bool pause_set:1;
 
-       unsigned high_wm_percent_value;
-       unsigned low_wm_percent_value;
-       unsigned autocommit_time_value;
-       unsigned max_age_value;
-       unsigned pause_value;
+       unsigned int high_wm_percent_value;
+       unsigned int low_wm_percent_value;
+       unsigned int autocommit_time_value;
+       unsigned int max_age_value;
+       unsigned int pause_value;
 
-       unsigned writeback_all;
+       unsigned int writeback_all;
        struct workqueue_struct *writeback_wq;
        struct work_struct writeback_work;
        struct work_struct flush_work;
@@ -202,7 +202,7 @@ struct dm_writecache {
 
        struct dm_kcopyd_client *dm_kcopyd;
        unsigned long *dirty_bitmap;
-       unsigned dirty_bitmap_size;
+       unsigned int dirty_bitmap_size;
 
        struct bio_set bio_set;
        mempool_t copy_pool;
@@ -227,7 +227,7 @@ struct writeback_struct {
        struct list_head endio_entry;
        struct dm_writecache *wc;
        struct wc_entry **wc_list;
-       unsigned wc_list_n;
+       unsigned int wc_list_n;
        struct wc_entry *wc_list_inline[WB_LIST_INLINE];
        struct bio bio;
 };
@@ -236,7 +236,7 @@ struct copy_struct {
        struct list_head endio_entry;
        struct dm_writecache *wc;
        struct wc_entry *e;
-       unsigned n_entries;
+       unsigned int n_entries;
        int error;
 };
 
@@ -369,7 +369,7 @@ static struct page *persistent_memory_page(void *addr)
                return virt_to_page(addr);
 }
 
-static unsigned persistent_memory_page_offset(void *addr)
+static unsigned int persistent_memory_page_offset(void *addr)
 {
        return (unsigned long)addr & (PAGE_SIZE - 1);
 }
@@ -502,11 +502,11 @@ static void ssd_commit_flushed(struct dm_writecache *wc, bool wait_for_ios)
                COMPLETION_INITIALIZER_ONSTACK(endio.c),
                ATOMIC_INIT(1),
        };
-       unsigned bitmap_bits = wc->dirty_bitmap_size * 8;
-       unsigned i = 0;
+       unsigned int bitmap_bits = wc->dirty_bitmap_size * 8;
+       unsigned int i = 0;
 
        while (1) {
-               unsigned j;
+               unsigned int j;
                i = find_next_bit(wc->dirty_bitmap, bitmap_bits, i);
                if (unlikely(i == bitmap_bits))
                        break;
@@ -531,7 +531,7 @@ static void ssd_commit_flushed(struct dm_writecache *wc, bool wait_for_ios)
                req.notify.context = &endio;
 
                /* writing via async dm-io (implied by notify.fn above) won't return an error */
-               (void) dm_io(&req, 1, &region, NULL);
+               (void) dm_io(&req, 1, &region, NULL);
                i = j;
        }
 
@@ -1100,7 +1100,7 @@ erase_this:
        wc_unlock(wc);
 }
 
-static int process_flush_mesg(unsigned argc, char **argv, struct dm_writecache *wc)
+static int process_flush_mesg(unsigned int argc, char **argv, struct dm_writecache *wc)
 {
        if (argc != 1)
                return -EINVAL;
@@ -1133,7 +1133,7 @@ static int process_flush_mesg(unsigned argc, char **argv, struct dm_writecache *
        return 0;
 }
 
-static int process_flush_on_suspend_mesg(unsigned argc, char **argv, struct dm_writecache *wc)
+static int process_flush_on_suspend_mesg(unsigned int argc, char **argv, struct dm_writecache *wc)
 {
        if (argc != 1)
                return -EINVAL;
@@ -1153,7 +1153,7 @@ static void activate_cleaner(struct dm_writecache *wc)
        wc->freelist_low_watermark = wc->n_blocks;
 }
 
-static int process_cleaner_mesg(unsigned argc, char **argv, struct dm_writecache *wc)
+static int process_cleaner_mesg(unsigned int argc, char **argv, struct dm_writecache *wc)
 {
        if (argc != 1)
                return -EINVAL;
@@ -1167,7 +1167,7 @@ static int process_cleaner_mesg(unsigned argc, char **argv, struct dm_writecache
        return 0;
 }
 
-static int process_clear_stats_mesg(unsigned argc, char **argv, struct dm_writecache *wc)
+static int process_clear_stats_mesg(unsigned int argc, char **argv, struct dm_writecache *wc)
 {
        if (argc != 1)
                return -EINVAL;
@@ -1179,8 +1179,8 @@ static int process_clear_stats_mesg(unsigned argc, char **argv, struct dm_writec
        return 0;
 }
 
-static int writecache_message(struct dm_target *ti, unsigned argc, char **argv,
-                             char *result, unsigned maxlen)
+static int writecache_message(struct dm_target *ti, unsigned int argc, char **argv,
+                             char *result, unsigned int maxlen)
 {
        int r = -EINVAL;
        struct dm_writecache *wc = ti->private;
@@ -1238,9 +1238,9 @@ static void memcpy_flushcache_optimized(void *dest, void *source, size_t size)
 static void bio_copy_block(struct dm_writecache *wc, struct bio *bio, void *data)
 {
        void *buf;
-       unsigned size;
+       unsigned int size;
        int rw = bio_data_dir(bio);
-       unsigned remaining_size = wc->block_size;
+       unsigned int remaining_size = wc->block_size;
 
        do {
                struct bio_vec bv = bio_iter_iovec(bio, bio->bi_iter);
@@ -1371,7 +1371,7 @@ read_next_block:
 static void writecache_bio_copy_ssd(struct dm_writecache *wc, struct bio *bio,
                                    struct wc_entry *e, bool search_used)
 {
-       unsigned bio_size = wc->block_size;
+       unsigned int bio_size = wc->block_size;
        sector_t start_cache_sec = cache_sector(wc, e);
        sector_t current_cache_sec = start_cache_sec + (bio_size >> SECTOR_SHIFT);
 
@@ -1540,7 +1540,7 @@ static int writecache_map(struct dm_target *ti, struct bio *bio)
 
        bio->bi_iter.bi_sector = dm_target_offset(ti, bio->bi_iter.bi_sector);
 
-       if (unlikely((((unsigned)bio->bi_iter.bi_sector | bio_sectors(bio)) &
+       if (unlikely((((unsigned int)bio->bi_iter.bi_sector | bio_sectors(bio)) &
                                (wc->block_size / 512 - 1)) != 0)) {
                DMERR("I/O is not aligned, sector %llu, size %u, block size %u",
                      (unsigned long long)bio->bi_iter.bi_sector,
@@ -1666,7 +1666,7 @@ static void writecache_copy_endio(int read_err, unsigned long write_err, void *p
 
 static void __writecache_endio_pmem(struct dm_writecache *wc, struct list_head *list)
 {
-       unsigned i;
+       unsigned int i;
        struct writeback_struct *wb;
        struct wc_entry *e;
        unsigned long n_walked = 0;
@@ -1782,7 +1782,7 @@ pop_from_list:
 static bool wc_add_block(struct writeback_struct *wb, struct wc_entry *e)
 {
        struct dm_writecache *wc = wb->wc;
-       unsigned block_size = wc->block_size;
+       unsigned int block_size = wc->block_size;
        void *address = memory_data(wc, e);
 
        persistent_memory_flush_cache(address, block_size);
@@ -1817,7 +1817,7 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba
        struct wc_entry *e, *f;
        struct bio *bio;
        struct writeback_struct *wb;
-       unsigned max_pages;
+       unsigned int max_pages;
 
        while (wbl->size) {
                wbl->size--;
@@ -1832,10 +1832,13 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba
                wb->wc = wc;
                bio->bi_end_io = writecache_writeback_endio;
                bio->bi_iter.bi_sector = read_original_sector(wc, e);
-               if (max_pages <= WB_LIST_INLINE ||
-                   unlikely(!(wb->wc_list = kmalloc_array(max_pages, sizeof(struct wc_entry *),
-                                                          GFP_NOIO | __GFP_NORETRY |
-                                                          __GFP_NOMEMALLOC | __GFP_NOWARN)))) {
+
+               if (unlikely(max_pages > WB_LIST_INLINE))
+                       wb->wc_list = kmalloc_array(max_pages, sizeof(struct wc_entry *),
+                                                   GFP_NOIO | __GFP_NORETRY |
+                                                   __GFP_NOMEMALLOC | __GFP_NOWARN);
+
+               if (likely(max_pages <= WB_LIST_INLINE) || unlikely(!wb->wc_list)) {
                        wb->wc_list = wb->wc_list_inline;
                        max_pages = WB_LIST_INLINE;
                }
@@ -1880,7 +1883,7 @@ static void __writecache_writeback_ssd(struct dm_writecache *wc, struct writebac
        struct copy_struct *c;
 
        while (wbl->size) {
-               unsigned n_sectors;
+               unsigned int n_sectors;
 
                wbl->size--;
                e = container_of(wbl->list.prev, struct wc_entry, lru);
@@ -2092,7 +2095,7 @@ restart:
        }
 }
 
-static int calculate_memory_size(uint64_t device_size, unsigned block_size,
+static int calculate_memory_size(uint64_t device_size, unsigned int block_size,
                                 size_t *n_blocks_p, size_t *n_metadata_blocks_p)
 {
        uint64_t n_blocks, offset;
@@ -2207,12 +2210,12 @@ static void writecache_dtr(struct dm_target *ti)
        kfree(wc);
 }
 
-static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
+static int writecache_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 {
        struct dm_writecache *wc;
        struct dm_arg_set as;
        const char *string;
-       unsigned opt_params;
+       unsigned int opt_params;
        size_t offset, data_size;
        int i, r;
        char dummy;
@@ -2419,7 +2422,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
                                goto invalid_optional;
                        wc->autocommit_blocks_set = true;
                } else if (!strcasecmp(string, "autocommit_time") && opt_params >= 1) {
-                       unsigned autocommit_msecs;
+                       unsigned int autocommit_msecs;
                        string = dm_shift_arg(&as), opt_params--;
                        if (sscanf(string, "%u%c", &autocommit_msecs, &dummy) != 1)
                                goto invalid_optional;
@@ -2429,7 +2432,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
                        wc->autocommit_time_value = autocommit_msecs;
                        wc->autocommit_time_set = true;
                } else if (!strcasecmp(string, "max_age") && opt_params >= 1) {
-                       unsigned max_age_msecs;
+                       unsigned int max_age_msecs;
                        string = dm_shift_arg(&as), opt_params--;
                        if (sscanf(string, "%u%c", &max_age_msecs, &dummy) != 1)
                                goto invalid_optional;
@@ -2454,7 +2457,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
                } else if (!strcasecmp(string, "metadata_only")) {
                        wc->metadata_only = true;
                } else if (!strcasecmp(string, "pause_writeback") && opt_params >= 1) {
-                       unsigned pause_msecs;
+                       unsigned int pause_msecs;
                        if (WC_MODE_PMEM(wc))
                                goto invalid_optional;
                        string = dm_shift_arg(&as), opt_params--;
@@ -2653,11 +2656,11 @@ bad:
 }
 
 static void writecache_status(struct dm_target *ti, status_type_t type,
-                             unsigned status_flags, char *result, unsigned maxlen)
+                             unsigned int status_flags, char *result, unsigned int maxlen)
 {
        struct dm_writecache *wc = ti->private;
-       unsigned extra_args;
-       unsigned sz = 0;
+       unsigned int extra_args;
+       unsigned int sz = 0;
 
        switch (type) {
        case STATUSTYPE_INFO: