Miscellaneous DRBD updates for 6.2
Subsystems (2)
Christoph Böhmwalder
maintainercover Miscellaneous DRBD updates for 6.2
Here are some various updates for DRBD.
The first two are related to the handling of discards in DRBD, and the third is a resend of [0].
[0] https://lore.kernel.org/all/[email protected]/
Christoph Böhmwalder (2):
drbd: use blk_queue_max_discard_sectors helper
drbd: Store op in drbd_peer_request
Philipp Reisner (1):
drbd: disable discard support if granularity > max
drivers/block/drbd/drbd_int.h | 8 ++- drivers/block/drbd/drbd_nl.c | 23 +++++++-- drivers/block/drbd/drbd_receiver.c | 81 +++++++++++++++++------------- drivers/block/drbd/drbd_worker.c | 4 +- 4 files changed, 71 insertions(+), 45 deletions(-)
Signature · 1 line
2.38.1
Christoph Böhmwalder
maintainerPATCH 1/3 drbd: use blk_queue_max_discard_sectors helper
We currently only set q->limits.max_discard_sectors, but that is not enough. Another field, max_hw_discard_sectors, was introduced in commit 0034af036554 ("block: make /sys/block/<dev>/queue/discard_max_bytes writeable").
The difference is that max_discard_sectors can be changed from user space via sysfs, while max_hw_discard_sectors is the "hardware" upper limit.
So use this helper, which sets both.
This is also a fixup for commit 998e9cbcd615 ("drbd: cleanup decide_on_discard_support"): if discards are not supported, that does not necessarily mean we also want to disable write_zeroes.
--- drivers/block/drbd/drbd_nl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/block/drbd/drbd_nl.c +5 -5
@@ -1210,6 +1210,7 @@ static void decide_on_discard_support(struct drbd_device *device,struct drbd_connection *connection =first_peer_device (device)->connection;struct request_queue *q = device->rq_queue; +unsigned int max_discard_sectors;if (bdev && !bdev_max_discard_sectors (bdev->backing_bdev)) goto not_supported;
@@ -1230,15 +1231,14 @@ static void decide_on_discard_support(struct drbd_device *device,* topology on all peers. */ blk_queue_discard_granularity (q,512 ); - q->limits.max_discard_sectors =drbd_max_discard_sectors (connection); - q->limits.max_write_zeroes_sectors = -drbd_max_discard_sectors (connection); + max_discard_sectors =drbd_max_discard_sectors (connection); +blk_queue_max_discard_sectors (q, max_discard_sectors); +blk_queue_max_write_zeroes_sectors (q, max_discard_sectors);return ; not_supported:blk_queue_discard_granularity (q,0 ); - q->limits.max_discard_sectors =0 ; - q->limits.max_write_zeroes_sectors =0 ; +blk_queue_max_discard_sectors (q,0 ); }static void fixup_write_zeroes (struct drbd_device *device,struct request_queue *q)
Signature · 1 line
2.38.1
Re: [PATCH 1/3] drbd: use blk_queue_max_discard_sectors helper
Quoted 11 lines · Christoph Böhmwalder
We currently only set
q->limits.max_discard_sectors, but that is not enough. Another field,max_hw_discard_sectors, was introduced in commit0034af036554("block: make /sys/block/<dev>/queue/discard_max_bytes writeable").The difference is that
max_discard_sectorscan be changed from user space via sysfs, whilemax_hw_discard_sectorsis the "hardware" upper limit.So use this helper, which sets both.
Quoted 8 lines
This is also a fixup for commit
998e9cbcd615("drbd: cleanupdecide_on_discard_support"): if discards are not supported, that does not necessarily mean we also want to disablewrite_zeroes.Fixes 998e9cbcd615 ("drbd: cleanup decide_on_discard_support")Reviewed-by Joel Colledge <[email protected]>Signed-off-by Christoph Böhmwalder <[email protected]>---
Using helper is absolutely right way of setting up discard values...
-ck
Christoph Böhmwalder
maintainerPATCH 2/3 drbd: disable discard support if granularity > max
In reply to Christoph BöhmwalderFrom: Philipp Reisner <[email protected]>
The discard_granularity describes the minimum unit of a discard. If that is larger than the maximal discard size, we need to disable discards completely.
--- drivers/block/drbd/drbd_nl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/block/drbd/drbd_nl.c +13 -0
@@ -1256,6 +1256,18 @@ static void fixup_write_zeroes(struct drbd_device *device, struct request_queue q->limits.max_write_zeroes_sectors =0 ; } +static void fixup_discard_support (struct drbd_device *device,struct request_queue *q) +{ +unsigned int max_discard = device->rq_queue->limits.max_discard_sectors; +unsigned int discard_granularity = + device->rq_queue->limits.discard_granularity >>SECTOR_SHIFT ; + +if (discard_granularity > max_discard) { +blk_queue_discard_granularity (q,0 ); +blk_queue_max_discard_sectors (q,0 ); + } +} +static void drbd_setup_queue_param (struct drbd_device *device,struct drbd_backing_dev *bdev,unsigned int max_bio_size,struct o_qlim *o) {
@@ -1288,6 +1300,7 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backidisk_update_readahead (device->vdisk); }fixup_write_zeroes (device, q); +fixup_discard_support (device, q); }void drbd_reconsider_queue_parameters (struct drbd_device *device,struct drbd_backing_dev *bdev,struct o_qlim *o)
Signature · 1 line
2.38.1
Christoph Böhmwalder
maintainerPATCH RESEND 3/3 drbd: Store op in drbd_peer_request
In reply to Christoph Böhmwalder(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.
--- 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(-)
drivers/block/drbd/drbd_int.h +6 -2
@@ -395,6 +395,7 @@ struct drbd_peer_request {struct drbd_peer_device *peer_device;struct drbd_epoch *epoch;/* for writes */ struct page *pages; +blk_opf_t 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 *peer_req);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,
drivers/block/drbd/drbd_receiver.c +45 -36
216 lines not on this page · raw message
drivers/block/drbd/drbd_worker.c +2 -2
@@ -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
Signature · 1 line
2.38.1
Quoted 11 lines · Christoph Böhmwalder
Here are some various updates for DRBD.
The first two are related to the handling of discards in DRBD, and the third is a resend of [0].[0] https://lore.kernel.org/all/[email protected]/
Christoph Böhmwalder (2):
drbd: useblk_queue_max_discard_sectorshelper
drbd: Store op indrbd_peer_request[...]
Applied, thanks!
[1/3] drbd: use blk_queue_max_discard_sectors helper
commit: 258bea6388ac93f34561fd91064232d14e174bff
[2/3] drbd: disable discard support if granularity > max
commit: 21b87a7d7564751590e3a38dfb243f9a0bbedbd2
[3/3] drbd: Store op in drbd_peer_request
commit: ce668b6d68f9ddf76022b1c403b444f5a21cbc0fBest regards,
Signature · 1 line
Jens Axboe