drbd: Store op in drbd_peer_request

Message ID 20221017090154.15696-1-christoph.boehmwalder@linbit.com
State New
Headers
Series drbd: Store op in drbd_peer_request |

Commit Message

Christoph Böhmwalder Oct. 17, 2022, 9:01 a.m. UTC
  (Sort of) cherry-picked from the out-of-tree drbd9 branch. Original
commit message by Joel Colledge:

    This simplifies drbd_submit_peer_request by removing most of the
    arguments. It also makes the treatment of the op better aligned with
    that in struct bio.

    Determine fault_type dynamically using information which is already
    available instead of passing it in as a parameter.

Note: The opf in receive_rs_deallocated was changed from
REQ_OP_WRITE_ZEROES to REQ_OP_DISCARD. This was required in the
out-of-tree module, and does not matter in-tree. The opf is ignored
anyway in drbd_submit_peer_request, since the discard/zero-out is
decided by the EE_TRIM flag.

Signed-off-by: Joel Colledge <joel.colledge@linbit.com>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
---
 drivers/block/drbd/drbd_int.h      |  8 ++-
 drivers/block/drbd/drbd_receiver.c | 81 +++++++++++++++++-------------
 drivers/block/drbd/drbd_worker.c   |  4 +-
 3 files changed, 53 insertions(+), 40 deletions(-)
  

Comments

Jens Axboe Oct. 17, 2022, 2:22 p.m. UTC | #1
On 10/17/22 3:01 AM, Christoph B?hmwalder wrote:
> diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
> index 4d661282ff41..0f8e3b94a635 100644
> --- a/drivers/block/drbd/drbd_int.h
> +++ b/drivers/block/drbd/drbd_int.h
> @@ -395,6 +395,7 @@ struct drbd_peer_request {
>  	struct drbd_peer_device *peer_device;
>  	struct drbd_epoch *epoch; /* for writes */
>  	struct page *pages;
> +	unsigned int opf; /* to be used as bi_opf */

Why isn't this blk_opf_t?
  
kernel test robot Oct. 17, 2022, 9:13 p.m. UTC | #2
Hi Christoph,

I love your patch! Perhaps something to improve:

[auto build test WARNING on axboe-block/for-next]
[also build test WARNING on linus/master v6.1-rc1 next-20221017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christoph-B-hmwalder/drbd-Store-op-in-drbd_peer_request/20221017-170252
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link:    https://lore.kernel.org/r/20221017090154.15696-1-christoph.boehmwalder%40linbit.com
patch subject: [PATCH] drbd: Store op in drbd_peer_request
config: x86_64-allyesconfig
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/56bd9760957a27a5899aba7d1f75d650c1ac7a15
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Christoph-B-hmwalder/drbd-Store-op-in-drbd_peer_request/20221017-170252
        git checkout 56bd9760957a27a5899aba7d1f75d650c1ac7a15
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/block/drbd/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/block/drbd/drbd_receiver.c: In function 'wire_flags_to_bio':
>> drivers/block/drbd/drbd_receiver.c:2411:23: warning: unused variable 'opf' [-Wunused-variable]
    2411 |         unsigned long opf = wire_flags_to_bio_op(dpf) |
         |                       ^~~
   drivers/block/drbd/drbd_receiver.c:2415:1: error: no return statement in function returning non-void [-Werror=return-type]
    2415 | }
         | ^
   cc1: some warnings being treated as errors


vim +/opf +2411 drivers/block/drbd/drbd_receiver.c

  2407	
  2408	/* see also bio_flags_to_wire() */
  2409	static unsigned long wire_flags_to_bio(struct drbd_connection *connection, u32 dpf)
  2410	{
> 2411		unsigned long opf = wire_flags_to_bio_op(dpf) |
  2412			(dpf & DP_RW_SYNC ? REQ_SYNC : 0) |
  2413			(dpf & DP_FUA ? REQ_FUA : 0) |
  2414			(dpf & DP_FLUSH ? REQ_PREFLUSH : 0);
  2415	}
  2416
  
kernel test robot Oct. 18, 2022, 2:57 a.m. UTC | #3
Hi Christoph,

I love your patch! Perhaps something to improve:

[auto build test WARNING on axboe-block/for-next]
[also build test WARNING on linus/master v6.1-rc1 next-20221017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christoph-B-hmwalder/drbd-Store-op-in-drbd_peer_request/20221017-170252
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link:    https://lore.kernel.org/r/20221017090154.15696-1-christoph.boehmwalder%40linbit.com
patch subject: [PATCH] drbd: Store op in drbd_peer_request
config: x86_64-randconfig-s023-20221017
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/56bd9760957a27a5899aba7d1f75d650c1ac7a15
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Christoph-B-hmwalder/drbd-Store-op-in-drbd_peer_request/20221017-170252
        git checkout 56bd9760957a27a5899aba7d1f75d650c1ac7a15
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/block/drbd/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
   drivers/block/drbd/drbd_worker.c:616:39: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:616:39: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:616:39: sparse:    struct disk_conf *
>> drivers/block/drbd/drbd_worker.c:403:23: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int opf @@     got restricted blk_opf_t @@
   drivers/block/drbd/drbd_worker.c:403:23: sparse:     expected unsigned int opf
   drivers/block/drbd/drbd_worker.c:403:23: sparse:     got restricted blk_opf_t
   drivers/block/drbd/drbd_worker.c:508:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:508:14: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:508:14: sparse:    struct disk_conf *
   drivers/block/drbd/drbd_worker.c:509:16: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:509:16: sparse:    struct fifo_buffer [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:509:16: sparse:    struct fifo_buffer *
   drivers/block/drbd/drbd_worker.c:558:13: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:558:13: sparse:    struct fifo_buffer [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:558:13: sparse:    struct fifo_buffer *
   drivers/block/drbd/drbd_worker.c:562:39: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:562:39: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:562:39: sparse:    struct disk_conf *
   drivers/block/drbd/drbd_worker.c:995:22: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:995:22: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:995:22: sparse:    struct disk_conf *
   drivers/block/drbd/drbd_worker.c:1540:32: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:1540:32: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:1540:32: sparse:    struct disk_conf *
   drivers/block/drbd/drbd_worker.c:1649:32: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:1649:32: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:1649:32: sparse:    struct disk_conf *
   drivers/block/drbd/drbd_worker.c:1687:16: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:1687:16: sparse:    struct fifo_buffer [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:1687:16: sparse:    struct fifo_buffer *
   drivers/block/drbd/drbd_worker.c:1716:34: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:1716:34: sparse:    struct net_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:1716:34: sparse:    struct net_conf *
   drivers/block/drbd/drbd_worker.c:1889:38: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:1889:38: sparse:    struct net_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:1889:38: sparse:    struct net_conf *
   drivers/block/drbd/drbd_worker.c:2094:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:2094:14: sparse:    struct net_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:2094:14: sparse:    struct net_conf *
   drivers/block/drbd/drbd_worker.c:2149:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_worker.c:2149:14: sparse:    struct net_conf [noderef] __rcu *
   drivers/block/drbd/drbd_worker.c:2149:14: sparse:    struct net_conf *
   drivers/block/drbd/drbd_worker.c:59:25: sparse: sparse: context imbalance in 'drbd_md_endio' - unexpected unlock
   drivers/block/drbd/drbd_worker.c: note: in included file:
   drivers/block/drbd/drbd_int.h:1720:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_int.h:1720:14: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_int.h:1720:14: sparse:    struct disk_conf *
   drivers/block/drbd/drbd_int.h:1720:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_int.h:1720:14: sparse:    struct disk_conf [noderef] __rcu *
   drivers/block/drbd/drbd_int.h:1720:14: sparse:    struct disk_conf *
   drivers/block/drbd/drbd_int.h:2138:14: sparse: sparse: incompatible types in comparison expression (different address spaces):
   drivers/block/drbd/drbd_int.h:2138:14: sparse:    struct net_conf [noderef] __rcu *
   drivers/block/drbd/drbd_int.h:2138:14: sparse:    struct net_conf *

vim +403 drivers/block/drbd/drbd_worker.c

   386	
   387	static int read_for_csum(struct drbd_peer_device *peer_device, sector_t sector, int size)
   388	{
   389		struct drbd_device *device = peer_device->device;
   390		struct drbd_peer_request *peer_req;
   391	
   392		if (!get_ldev(device))
   393			return -EIO;
   394	
   395		/* GFP_TRY, because if there is no memory available right now, this may
   396		 * be rescheduled for later. It is "only" background resync, after all. */
   397		peer_req = drbd_alloc_peer_req(peer_device, ID_SYNCER /* unused */, sector,
   398					       size, size, GFP_TRY);
   399		if (!peer_req)
   400			goto defer;
   401	
   402		peer_req->w.cb = w_e_send_csum;
 > 403		peer_req->opf = REQ_OP_READ;
   404		spin_lock_irq(&device->resource->req_lock);
   405		list_add_tail(&peer_req->w.list, &device->read_ee);
   406		spin_unlock_irq(&device->resource->req_lock);
   407	
   408		atomic_add(size >> 9, &device->rs_sect_ev);
   409		if (drbd_submit_peer_request(peer_req) == 0)
   410			return 0;
   411	
   412		/* If it failed because of ENOMEM, retry should help.  If it failed
   413		 * because bio_add_page failed (probably broken lower level driver),
   414		 * retry may or may not help.
   415		 * If it does not, you may need to force disconnect. */
   416		spin_lock_irq(&device->resource->req_lock);
   417		list_del(&peer_req->w.list);
   418		spin_unlock_irq(&device->resource->req_lock);
   419	
   420		drbd_free_peer_req(device, peer_req);
   421	defer:
   422		put_ldev(device);
   423		return -EAGAIN;
   424	}
   425
  

Patch

diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 4d661282ff41..0f8e3b94a635 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -395,6 +395,7 @@  struct drbd_peer_request {
 	struct drbd_peer_device *peer_device;
 	struct drbd_epoch *epoch; /* for writes */
 	struct page *pages;
+	unsigned int opf; /* to be used as bi_opf */
 	atomic_t pending_bios;
 	struct drbd_interval i;
 	/* see comments on ee flag bits below */
@@ -406,6 +407,10 @@  struct drbd_peer_request {
 	};
 };
 
+/* Equivalent to bio_op and req_op. */
+#define peer_req_op(peer_req) \
+       ((peer_req)->opf & REQ_OP_MASK)
+
 /* ee flag bits.
  * While corresponding bios are in flight, the only modification will be
  * set_bit WAS_ERROR, which has to be atomic.
@@ -1545,8 +1550,7 @@  extern void drbd_send_acks_wf(struct work_struct *ws);
 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 *, blk_opf_t, int);
+extern int drbd_submit_peer_request(struct drbd_peer_request *);
 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,
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index c897c4572036..41cf706a5e7a 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1603,9 +1603,19 @@  static void drbd_issue_peer_discard_or_zero_out(struct drbd_device *device, stru
 	drbd_endio_write_sec_final(peer_req);
 }
 
+static int peer_request_fault_type(struct drbd_peer_request *peer_req)
+{
+	if (peer_req_op(peer_req) == REQ_OP_READ) {
+		return peer_req->flags & EE_APPLICATION ?
+			DRBD_FAULT_DT_RD : DRBD_FAULT_RS_RD;
+	} else {
+		return peer_req->flags & EE_APPLICATION ?
+			DRBD_FAULT_DT_WR : DRBD_FAULT_RS_WR;
+	}
+}
+
 /**
  * drbd_submit_peer_request()
- * @device:	DRBD device.
  * @peer_req:	peer request
  *
  * May spread the pages to multiple bios,
@@ -1619,10 +1629,9 @@  static void drbd_issue_peer_discard_or_zero_out(struct drbd_device *device, stru
  *  on certain Xen deployments.
  */
 /* TODO allocate from our own bio_set. */
-int drbd_submit_peer_request(struct drbd_device *device,
-			     struct drbd_peer_request *peer_req,
-			     const blk_opf_t opf, const int fault_type)
+int drbd_submit_peer_request(struct drbd_peer_request *peer_req)
 {
+	struct drbd_device *device = peer_req->peer_device->device;
 	struct bio *bios = NULL;
 	struct bio *bio;
 	struct page *page = peer_req->pages;
@@ -1667,7 +1676,18 @@  int drbd_submit_peer_request(struct drbd_device *device,
 	 * generated bio, but a bio allocated on behalf of the peer.
 	 */
 next_bio:
-	bio = bio_alloc(device->ldev->backing_bdev, nr_pages, opf, GFP_NOIO);
+	/* _DISCARD, _WRITE_ZEROES handled above.
+	 * REQ_OP_FLUSH (empty flush) not expected,
+	 * should have been mapped to a "drbd protocol barrier".
+	 * REQ_OP_SECURE_ERASE: I don't see how we could ever support that.
+	 */
+	if (!(peer_req_op(peer_req) == REQ_OP_WRITE ||
+				peer_req_op(peer_req) == REQ_OP_READ)) {
+		drbd_err(device, "Invalid bio op received: 0x%x\n", peer_req->opf);
+		return -EINVAL;
+	}
+
+	bio = bio_alloc(device->ldev->backing_bdev, nr_pages, peer_req->opf, GFP_NOIO);
 	/* > peer_req->i.sector, unless this is the first bio */
 	bio->bi_iter.bi_sector = sector;
 	bio->bi_private = peer_req;
@@ -1697,7 +1717,7 @@  int drbd_submit_peer_request(struct drbd_device *device,
 		bios = bios->bi_next;
 		bio->bi_next = NULL;
 
-		drbd_submit_bio_noacct(device, fault_type, bio);
+		drbd_submit_bio_noacct(device, peer_request_fault_type(peer_req), bio);
 	} while (bios);
 	return 0;
 }
@@ -2051,6 +2071,7 @@  static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t secto
 	 * respective _drbd_clear_done_ee */
 
 	peer_req->w.cb = e_end_resync_block;
+	peer_req->opf = REQ_OP_WRITE;
 	peer_req->submit_jif = jiffies;
 
 	spin_lock_irq(&device->resource->req_lock);
@@ -2058,8 +2079,7 @@  static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t secto
 	spin_unlock_irq(&device->resource->req_lock);
 
 	atomic_add(pi->size >> 9, &device->rs_sect_ev);
-	if (drbd_submit_peer_request(device, peer_req, REQ_OP_WRITE,
-				     DRBD_FAULT_RS_WR) == 0)
+	if (drbd_submit_peer_request(peer_req) == 0)
 		return 0;
 
 	/* don't care for the reason here */
@@ -2375,16 +2395,6 @@  static int wait_for_and_update_peer_seq(struct drbd_peer_device *peer_device, co
 	return ret;
 }
 
-/* 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 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 enum req_op wire_flags_to_bio_op(u32 dpf)
 {
 	if (dpf & DP_ZEROES)
@@ -2395,6 +2405,15 @@  static enum req_op wire_flags_to_bio_op(u32 dpf)
 		return REQ_OP_WRITE;
 }
 
+/* see also bio_flags_to_wire() */
+static unsigned long wire_flags_to_bio(struct drbd_connection *connection, u32 dpf)
+{
+	unsigned long opf = wire_flags_to_bio_op(dpf) |
+		(dpf & DP_RW_SYNC ? REQ_SYNC : 0) |
+		(dpf & DP_FUA ? REQ_FUA : 0) |
+		(dpf & DP_FLUSH ? REQ_PREFLUSH : 0);
+}
+
 static void fail_postponed_requests(struct drbd_device *device, sector_t sector,
 				    unsigned int size)
 {
@@ -2538,8 +2557,6 @@  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);
-	enum req_op op;
-	blk_opf_t op_flags;
 	u32 dp_flags;
 	int err, tp;
 
@@ -2578,11 +2595,10 @@  static int receive_Data(struct drbd_connection *connection, struct packet_info *
 	peer_req->flags |= EE_APPLICATION;
 
 	dp_flags = be32_to_cpu(p->dp_flags);
-	op = wire_flags_to_bio_op(dp_flags);
-	op_flags = wire_flags_to_bio_flags(dp_flags);
+	peer_req->opf = wire_flags_to_bio(connection, dp_flags);
 	if (pi->cmd == P_TRIM) {
 		D_ASSERT(peer_device, peer_req->i.size > 0);
-		D_ASSERT(peer_device, op == REQ_OP_DISCARD);
+		D_ASSERT(peer_device, peer_req_op(peer_req) == REQ_OP_DISCARD);
 		D_ASSERT(peer_device, peer_req->pages == NULL);
 		/* need to play safe: an older DRBD sender
 		 * may mean zero-out while sending P_TRIM. */
@@ -2590,7 +2606,7 @@  static int receive_Data(struct drbd_connection *connection, struct packet_info *
 			peer_req->flags |= EE_ZEROOUT;
 	} else if (pi->cmd == P_ZEROES) {
 		D_ASSERT(peer_device, peer_req->i.size > 0);
-		D_ASSERT(peer_device, op == REQ_OP_WRITE_ZEROES);
+		D_ASSERT(peer_device, peer_req_op(peer_req) == REQ_OP_WRITE_ZEROES);
 		D_ASSERT(peer_device, peer_req->pages == NULL);
 		/* Do (not) pass down BLKDEV_ZERO_NOUNMAP? */
 		if (dp_flags & DP_DISCARD)
@@ -2677,8 +2693,7 @@  static int receive_Data(struct drbd_connection *connection, struct packet_info *
 		peer_req->flags |= EE_CALL_AL_COMPLETE_IO;
 	}
 
-	err = drbd_submit_peer_request(device, peer_req, op | op_flags,
-				       DRBD_FAULT_DT_WR);
+	err = drbd_submit_peer_request(peer_req);
 	if (!err)
 		return 0;
 
@@ -2789,7 +2804,6 @@  static int receive_DataRequest(struct drbd_connection *connection, struct packet
 	struct drbd_peer_request *peer_req;
 	struct digest_info *di = NULL;
 	int size, verb;
-	unsigned int fault_type;
 	struct p_block_req *p =	pi->data;
 
 	peer_device = conn_peer_device(connection, pi->vnr);
@@ -2849,11 +2863,11 @@  static int receive_DataRequest(struct drbd_connection *connection, struct packet
 		put_ldev(device);
 		return -ENOMEM;
 	}
+	peer_req->opf = REQ_OP_READ;
 
 	switch (pi->cmd) {
 	case P_DATA_REQUEST:
 		peer_req->w.cb = w_e_end_data_req;
-		fault_type = DRBD_FAULT_DT_RD;
 		/* application IO, don't drbd_rs_begin_io */
 		peer_req->flags |= EE_APPLICATION;
 		goto submit;
@@ -2867,14 +2881,12 @@  static int receive_DataRequest(struct drbd_connection *connection, struct packet
 		fallthrough;
 	case P_RS_DATA_REQUEST:
 		peer_req->w.cb = w_e_end_rsdata_req;
-		fault_type = DRBD_FAULT_RS_RD;
 		/* used in the sector offset progress display */
 		device->bm_resync_fo = BM_SECT_TO_BIT(sector);
 		break;
 
 	case P_OV_REPLY:
 	case P_CSUM_RS_REQUEST:
-		fault_type = DRBD_FAULT_RS_RD;
 		di = kmalloc(sizeof(*di) + pi->size, GFP_NOIO);
 		if (!di)
 			goto out_free_e;
@@ -2923,7 +2935,6 @@  static int receive_DataRequest(struct drbd_connection *connection, struct packet
 					(unsigned long long)sector);
 		}
 		peer_req->w.cb = w_e_end_ov_req;
-		fault_type = DRBD_FAULT_RS_RD;
 		break;
 
 	default:
@@ -2975,8 +2986,7 @@  static int receive_DataRequest(struct drbd_connection *connection, struct packet
 submit:
 	update_receiver_timing_details(connection, drbd_submit_peer_request);
 	inc_unacked(device);
-	if (drbd_submit_peer_request(device, peer_req, REQ_OP_READ,
-				     fault_type) == 0)
+	if (drbd_submit_peer_request(peer_req) == 0)
 		return 0;
 
 	/* don't care for the reason here */
@@ -4947,7 +4957,6 @@  static int receive_rs_deallocated(struct drbd_connection *connection, struct pac
 
 	if (get_ldev(device)) {
 		struct drbd_peer_request *peer_req;
-		const enum req_op op = REQ_OP_WRITE_ZEROES;
 
 		peer_req = drbd_alloc_peer_req(peer_device, ID_SYNCER, sector,
 					       size, 0, GFP_NOIO);
@@ -4957,6 +4966,7 @@  static int receive_rs_deallocated(struct drbd_connection *connection, struct pac
 		}
 
 		peer_req->w.cb = e_end_resync_block;
+		peer_req->opf = REQ_OP_DISCARD;
 		peer_req->submit_jif = jiffies;
 		peer_req->flags |= EE_TRIM;
 
@@ -4965,8 +4975,7 @@  static int receive_rs_deallocated(struct drbd_connection *connection, struct pac
 		spin_unlock_irq(&device->resource->req_lock);
 
 		atomic_add(pi->size >> 9, &device->rs_sect_ev);
-		err = drbd_submit_peer_request(device, peer_req, op,
-					       DRBD_FAULT_RS_WR);
+		err = drbd_submit_peer_request(peer_req);
 
 		if (err) {
 			spin_lock_irq(&device->resource->req_lock);
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index 0bb1a900c2d5..c69beefc9d5c 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -400,13 +400,13 @@  static int read_for_csum(struct drbd_peer_device *peer_device, sector_t sector,
 		goto defer;
 
 	peer_req->w.cb = w_e_send_csum;
+	peer_req->opf = REQ_OP_READ;
 	spin_lock_irq(&device->resource->req_lock);
 	list_add_tail(&peer_req->w.list, &device->read_ee);
 	spin_unlock_irq(&device->resource->req_lock);
 
 	atomic_add(size >> 9, &device->rs_sect_ev);
-	if (drbd_submit_peer_request(device, peer_req, REQ_OP_READ,
-				     DRBD_FAULT_RS_RD) == 0)
+	if (drbd_submit_peer_request(peer_req) == 0)
 		return 0;
 
 	/* If it failed because of ENOMEM, retry should help.  If it failed