]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block/drbd: Use the enum req_op and blk_opf_t types
authorBart Van Assche <bvanassche@acm.org>
Thu, 14 Jul 2022 18:06:39 +0000 (11:06 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 14 Jul 2022 18:14:31 +0000 (12:14 -0600)
Improve static type checking by using the enum req_op type for variables
that represent a request operation and the new blk_opf_t type for
variables that represent request flags.

Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20220714180729.1065367-14-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_actlog.c
drivers/block/drbd/drbd_bitmap.c
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_receiver.c

index f5bcded3640da368da0ea1259bd306f38d53ed7c..e27478ae579cc32f34d4ce4b44172f2397d45f79 100644 (file)
@@ -124,12 +124,13 @@ void wait_until_done_or_force_detached(struct drbd_device *device, struct drbd_b
 
 static int _drbd_md_sync_page_io(struct drbd_device *device,
                                 struct drbd_backing_dev *bdev,
-                                sector_t sector, int op)
+                                sector_t sector, enum req_op op)
 {
        struct bio *bio;
        /* we do all our meta data IO in aligned 4k blocks. */
        const int size = 4096;
-       int err, op_flags = 0;
+       int err;
+       blk_opf_t op_flags = 0;
 
        device->md_io.done = 0;
        device->md_io.error = -ENODEV;
@@ -174,7 +175,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
 }
 
 int drbd_md_sync_page_io(struct drbd_device *device, struct drbd_backing_dev *bdev,
-                        sector_t sector, int op)
+                        sector_t sector, enum req_op op)
 {
        int err;
        D_ASSERT(device, atomic_read(&device->md_io.in_use) == 1);
@@ -385,7 +386,7 @@ static int __al_write_transaction(struct drbd_device *device, struct al_transact
                write_al_updates = rcu_dereference(device->ldev->disk_conf)->al_updates;
                rcu_read_unlock();
                if (write_al_updates) {
-                       if (drbd_md_sync_page_io(device, device->ldev, sector, WRITE)) {
+                       if (drbd_md_sync_page_io(device, device->ldev, sector, REQ_OP_WRITE)) {
                                err = -EIO;
                                drbd_chk_io_error(device, 1, DRBD_META_IO_ERROR);
                        } else {
index 9e060e49b3f8c7233b70b5c32e432c6de272e343..603f6828dd7963fa90e009aa47ce8a7cb9b15738 100644 (file)
@@ -977,7 +977,7 @@ static void drbd_bm_endio(struct bio *bio)
 static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_hold(local)
 {
        struct drbd_device *device = ctx->device;
-       unsigned int op = (ctx->flags & BM_AIO_READ) ? REQ_OP_READ : REQ_OP_WRITE;
+       enum req_op op = ctx->flags & BM_AIO_READ ? REQ_OP_READ : REQ_OP_WRITE;
        struct bio *bio = bio_alloc_bioset(device->ldev->md_bdev, 1, op,
                                           GFP_NOIO, &drbd_md_io_bio_set);
        struct drbd_bitmap *b = device->bitmap;
index 4d3efaa20b7bffca3c9cae661a417d14bf2458f3..ecb2ecd8d67d73a3dbaec4a8e6a5276e9ad26718 100644 (file)
@@ -1495,7 +1495,7 @@ extern int drbd_resync_finished(struct drbd_device *device);
 extern void *drbd_md_get_buffer(struct drbd_device *device, const char *intent);
 extern void drbd_md_put_buffer(struct drbd_device *device);
 extern int drbd_md_sync_page_io(struct drbd_device *device,
-               struct drbd_backing_dev *bdev, sector_t sector, int op);
+               struct drbd_backing_dev *bdev, sector_t sector, enum req_op op);
 extern void drbd_ov_out_of_sync_found(struct drbd_device *, sector_t, int);
 extern void wait_until_done_or_force_detached(struct drbd_device *device,
                struct drbd_backing_dev *bdev, unsigned int *done);
@@ -1547,8 +1547,8 @@ extern bool drbd_rs_c_min_rate_throttle(struct drbd_device *device);
 extern bool drbd_rs_should_slow_down(struct drbd_device *device, sector_t sector,
                bool throttle_if_app_is_waiting);
 extern int drbd_submit_peer_request(struct drbd_device *,
-                                   struct drbd_peer_request *, const unsigned,
-                                   const unsigned, const int);
+                                   struct drbd_peer_request *, enum req_op,
+                                   blk_opf_t, int);
 extern int drbd_free_peer_reqs(struct drbd_device *, struct list_head *);
 extern struct drbd_peer_request *drbd_alloc_peer_req(struct drbd_peer_device *, u64,
                                                     sector_t, unsigned int,
index 6762be53f40937b60e95f86dca9c904a47c0a7ba..caf646dd91ba9a9e6caa0d9b58669fc643b7d228 100644 (file)
@@ -1621,7 +1621,7 @@ static void drbd_issue_peer_discard_or_zero_out(struct drbd_device *device, stru
 /* TODO allocate from our own bio_set. */
 int drbd_submit_peer_request(struct drbd_device *device,
                             struct drbd_peer_request *peer_req,
-                            const unsigned op, const unsigned op_flags,
+                            const enum req_op op, const blk_opf_t op_flags,
                             const int fault_type)
 {
        struct bio *bios = NULL;
@@ -2383,14 +2383,14 @@ static int wait_for_and_update_peer_seq(struct drbd_peer_device *peer_device, co
 /* see also bio_flags_to_wire()
  * DRBD_REQ_*, because we need to semantically map the flags to data packet
  * flags and back. We may replicate to other kernel versions. */
-static unsigned long wire_flags_to_bio_flags(u32 dpf)
+static blk_opf_t wire_flags_to_bio_flags(u32 dpf)
 {
        return  (dpf & DP_RW_SYNC ? REQ_SYNC : 0) |
                (dpf & DP_FUA ? REQ_FUA : 0) |
                (dpf & DP_FLUSH ? REQ_PREFLUSH : 0);
 }
 
-static unsigned long wire_flags_to_bio_op(u32 dpf)
+static enum req_op wire_flags_to_bio_op(u32 dpf)
 {
        if (dpf & DP_ZEROES)
                return REQ_OP_WRITE_ZEROES;
@@ -2543,7 +2543,8 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info *
        struct drbd_peer_request *peer_req;
        struct p_data *p = pi->data;
        u32 peer_seq = be32_to_cpu(p->seq_num);
-       int op, op_flags;
+       enum req_op op;
+       blk_opf_t op_flags;
        u32 dp_flags;
        int err, tp;
 
@@ -4951,7 +4952,7 @@ static int receive_rs_deallocated(struct drbd_connection *connection, struct pac
 
        if (get_ldev(device)) {
                struct drbd_peer_request *peer_req;
-               const int op = REQ_OP_WRITE_ZEROES;
+               const enum req_op op = REQ_OP_WRITE_ZEROES;
 
                peer_req = drbd_alloc_peer_req(peer_device, ID_SYNCER, sector,
                                               size, 0, GFP_NOIO);