Adjustements for 4.14 kernel
authorReto Buerki <reet@codelabs.ch>
Wed, 5 Dec 2018 08:02:27 +0000 (09:02 +0100)
committerReto Buerki <reet@codelabs.ch>
Mon, 28 Jan 2019 14:58:48 +0000 (15:58 +0100)
client.c
common.h
log.h
server.c

index 07726eb..69e95a4 100644 (file)
--- a/client.c
+++ b/client.c
@@ -352,7 +352,7 @@ static int muenblk_client_transfer_req(struct muenblk_device *dev,
        }
 
 transfer_finish_inform_bio:
-       bio->bi_error = error;
+       bio->bi_status = error;
        bio_endio(bio);
 
 transfer_finish:
@@ -427,7 +427,7 @@ static int muenblk_client_transfer_resp(struct muenblk_device *dev,
        if (unlikely(muenblk_is_dummy_bio(dev, bio)))
                goto transfer_finish;
 
-       bio->bi_error = error;
+       bio->bi_status = error;
        bio_endio(bio);
 
 transfer_finish:
@@ -599,7 +599,7 @@ static int muenblk_retrieve_size(struct muenblk_device *dev)
 
        mutex_lock(&dev->mutex);
 
-       dev->dummy.size_bio->bi_bdev = dev->bdev;
+       dev->dummy.size_bio->bi_disk = dev->disk;
        dev->dummy.size_bio->bi_flags = MUENBLK_COMMAND_SIZE;
        dev->dummy.size_bio->bi_opf = 0;
        dev->dummy.size_bio->bi_vcnt = 0;
@@ -614,15 +614,12 @@ static int muenblk_retrieve_size(struct muenblk_device *dev)
 
        if (!error) {
                dev->disk_sector_count = dev->dummy.size_bio->bi_iter.bi_sector;
-               dev->disk_kernel_sector_count = dev->disk_sector_count;
-               dev->disk_kernel_start_sector = 0;
-               dev->disk_size = dev->disk_kernel_sector_count *
+               dev->disk_size = dev->disk_sector_count *
                        KERNEL_SECTOR_SIZE;
 
-               TRACE("Received disk size (%llu, %llu, %llu)\n",
+               TRACE("Received disk size (%llu, %llu)\n",
                        dev->disk_size,
-                       dev->disk_sector_count,
-                       dev->disk_kernel_sector_count);
+                       dev->disk_sector_count);
        }
 
        mutex_unlock(&dev->mutex);
@@ -728,7 +725,7 @@ static int muenblk_client_init_blkdev(struct muenblk_device *dev)
        dev->disk->fops = &muenblk_fops;
 
        memcpy(dev->disk->disk_name, dev->disk_name, DISK_NAME_LEN);
-       set_capacity(dev->disk, dev->disk_kernel_sector_count);
+       set_capacity(dev->disk, dev->disk_sector_count);
 
        add_disk(dev->disk);
 
index 6dbe564..35bf5b8 100644 (file)
--- a/common.h
+++ b/common.h
@@ -86,8 +86,6 @@ struct muenblk_device {
 
        uint64_t                        disk_size;
        uint64_t                        disk_sector_count;
-       uint64_t                        disk_kernel_sector_count;
-       uint64_t                        disk_kernel_start_sector;
        uint32_t                        disk_major;
        uint8_t                         disk_minor;
        uint8_t                         disk_index;
diff --git a/log.h b/log.h
index 1738316..5436765 100644 (file)
--- a/log.h
+++ b/log.h
@@ -19,7 +19,7 @@
        #define BIO_TRACE(bio) " - (bio: %u, %u, %lu, %u, %u," \
            " %u, %u, %p, %p)\n", bio_op(bio), bio->bi_vcnt, \
            bio->bi_iter.bi_sector, bio->bi_iter.bi_size, bio->bi_iter.bi_idx, \
-           bio->bi_iter.bi_bvec_done, bio->bi_flags, bio->bi_bdev, bio
+           bio->bi_iter.bi_bvec_done, bio->bi_flags, bio->bi_disk, bio
 
        #define EVENT_TRACE(event) " - (event: %d, %llu, %d, %llx, %p)\n", \
            event->type, event->id, event->error, event->priv, event
index cb6f42c..bbb6e95 100644 (file)
--- a/server.c
+++ b/server.c
@@ -82,7 +82,7 @@ static int muenblk_server_command_req(struct muenblk_device *dev,
                bio->bi_iter.bi_idx = 0;
                bio->bi_iter.bi_size = 0;
                bio->bi_iter.bi_bvec_done = 0;
-               bio->bi_bdev = NULL;
+               bio->bi_disk = NULL;
 
                break;
 
@@ -211,7 +211,7 @@ static int muenblk_server_init_bio(struct muenblk_device *dev,
        metadata->error = 0;
        metadata->priv = event->priv;
 
-       bio->bi_bdev = dev->bdev;
+       bio_set_dev(bio, dev->bdev);
        bio->bi_end_io = muenblk_server_cb_endio;
        bio->bi_iter.bi_sector = event->id << 3;
        bio->bi_iter.bi_size = 0;
@@ -310,7 +310,7 @@ static int muenblk_server_read_resp(struct muenblk_device *dev,
 
        event->type = MUENBLK_EVENT_READ;
        event->id = ((bio->bi_iter.bi_sector -
-                               dev->disk_kernel_start_sector) >> 3) - 1;
+                               dev->bdev->bd_part->start_sect) >> 3) - 1;
 
        bio_for_each_segment_all(bvec, bio, i) {
                void *mapped_page = kmap_atomic(bvec->bv_page);
@@ -348,7 +348,7 @@ static int muenblk_server_write_resp(struct muenblk_device *dev,
 
        event->type = MUENBLK_EVENT_WRITE;
        event->id = ((bio->bi_iter.bi_sector -
-                               dev->disk_kernel_start_sector) >> 3) - 1;
+                               dev->bdev->bd_part->start_sect) >> 3) - 1;
 
        bio_for_each_segment_all(bvec, bio, i) {
                mempool_free(bvec->bv_page, dev->page_pool);
@@ -453,10 +453,10 @@ static void muenblk_server_cb_endio(struct bio *bio)
        BUG_ON(!bio);
 
        metadata = bio->bi_private;
-       metadata->error = bio->bi_error;
+       metadata->error = bio->bi_status;
 
-       if (unlikely(bio->bi_error))
-               ERROR("BIO EndIO invoked with error: %d", bio->bi_error);
+       if (unlikely(bio->bi_status))
+               ERROR("BIO EndIO invoked with error: %d", bio->bi_status);
 
        TRACE("BIO EndIO invoked" BIO_TRACE(bio));
 
@@ -538,19 +538,16 @@ static int muenblk_server_init_block_device(struct muenblk_device *dev)
 
        get_disk(bdev->bd_disk);
 
-       dev->disk_kernel_sector_count = bdev->bd_part->nr_sects;
-       dev->disk_kernel_start_sector = bdev->bd_part->start_sect;
-       dev->disk_sector_count = dev->disk_kernel_sector_count;
-       dev->disk_size = dev->disk_kernel_sector_count * KERNEL_SECTOR_SIZE;
+       dev->disk_sector_count = bdev->bd_part->nr_sects;
+       dev->disk_size = dev->disk_sector_count * KERNEL_SECTOR_SIZE;
 
        dev->queue = NULL;
 
-       INFO("Successfully initialized block device %s (%llu, %llu, %llu, %llu)\n",
+       INFO("Successfully initialized block device %s (%llu, %llu, %lu)\n",
                dev->disk_name,
                dev->disk_size,
                dev->disk_sector_count,
-               dev->disk_kernel_sector_count,
-               dev->disk_kernel_start_sector);
+               bdev->bd_part->start_sect);
 
 exit:
        return error;
@@ -564,7 +561,7 @@ static int muenblk_server_init_mem(struct muenblk_device *dev)
        //XXX: Why +2?
        num = dev->req.channel_queue_size + dev->resp.channel_queue_size + 2;
 
-       dev->bio_set = bioset_create(num, 0);
+       dev->bio_set = bioset_create(num, 0, BIOSET_NEED_BVECS);
        if (!dev->bio_set) {
                ERROR("Failed to create bioset\n");