From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Subject: [Drbd-dev] [PATCH 09/19] drbd: fix queue limit setup for discard
Date: Tue, 4 Aug 2015 14:56:33 +0200 [thread overview]
Message-ID: <1438693003-17554-10-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1438693003-17554-1-git-send-email-philipp.reisner@linbit.com>
From: Lars Ellenberg <lars.ellenberg@linbit.com>
We cannot possibly support SECDISCARD, even if all backend devices would
support it: if our peer is currently unreachable, some instance of the
data may obviously still be recoverable.
We did not set discard_granularity at all. We don't really care (yet),
we only pass them on, so for now, set our granularity to one sector.
blkdev_stack_limits() takes care of the rest.
If we decide we cannot support discards,
not only clear the (not user visible) QUEUE_FLAG_DISCARD,
but set both (user visible) discard_granularity and max_discard_sectors
to zero, to avoid confusion with e.g. lsblk -D.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
drivers/block/drbd/drbd_nl.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 66e8acd..9f60a68 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1168,21 +1168,19 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi
if (b) {
struct drbd_connection *connection = first_peer_device(device)->connection;
+ q->limits.max_discard_sectors = DRBD_MAX_DISCARD_SECTORS;
+
if (blk_queue_discard(b) &&
(connection->cstate < C_CONNECTED || connection->agreed_features & FF_TRIM)) {
- /* For now, don't allow more than one activity log extent worth of data
- * to be discarded in one go. We may need to rework drbd_al_begin_io()
- * to allow for even larger discard ranges */
- q->limits.max_discard_sectors = DRBD_MAX_DISCARD_SECTORS;
-
+ /* We don't care, stacking below should fix it for the local device.
+ * Whether or not it is a suitable granularity on the remote device
+ * is not our problem, really. If you care, you need to
+ * use devices with similar topology on all peers. */
+ q->limits.discard_granularity = 512;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
- /* REALLY? Is stacking secdiscard "legal"? */
- if (blk_queue_secdiscard(b))
- queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q);
} else {
- q->limits.max_discard_sectors = 0;
queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
- queue_flag_clear_unlocked(QUEUE_FLAG_SECDISCARD, q);
+ q->limits.discard_granularity = 0;
}
blk_queue_stack_limits(q, b);
@@ -1194,6 +1192,12 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi
q->backing_dev_info.ra_pages = b->backing_dev_info.ra_pages;
}
}
+ /* To avoid confusion, if this queue does not support discard, clear
+ * max_discard_sectors, which is what lsblk -D reports to the user. */
+ if (!blk_queue_discard(q)) {
+ q->limits.max_discard_sectors = 0;
+ q->limits.discard_granularity = 0;
+ }
}
void drbd_reconsider_max_bio_size(struct drbd_device *device, struct drbd_backing_dev *bdev)
--
1.9.1
next prev parent reply other threads:[~2015-08-04 12:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 12:56 [Drbd-dev] [PATCH 00/19] RFC DRBD updates for the 4.3 merge window (part II) Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 01/19] drbd: Rename asender to ack_receiver Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 02/19] drbd: Create a dedicated workqueue for sending acks on the control connection Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 03/19] drbd: prevent NULL pointer deref when resuming diskless primary Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 04/19] drbd: debugfs: expose ed_data_gen_id Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 05/19] drbd: use resource name in workqueue Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 06/19] drbd: avoid redefinition of BITS_PER_PAGE Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 07/19] drbd: use bitmap_weight() helper, don't open code Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 08/19] drbd: fix spurious alert level printk Philipp Reisner
2015-08-04 12:56 ` Philipp Reisner [this message]
2015-08-04 12:56 ` [Drbd-dev] [PATCH 10/19] drbd: make drbd known to lsblk: use bd_link_disk_holder Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 11/19] lru_cache: Converted lc_seq_printf_status to return void Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 12/19] drbd: don't block forever in disconnect during resync if fencing=r-a-stonith Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 13/19] drbd: fix memory leak in drbd_adm_resize Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 14/19] drbd: fix "endless" transfer log walk in protocol A Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 15/19] drbd: make suspend_io() / resume_io() must be thread and recursion safe Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 16/19] drbd: separate out __al_write_transaction helper function Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 17/19] drbd: avoid potential deadlock during handshake Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 18/19] drbd: fix error path during resize Philipp Reisner
2015-08-04 12:56 ` [Drbd-dev] [PATCH 19/19] MAINTAINERS: Updated information for DRBD DRIVER Philipp Reisner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438693003-17554-10-git-send-email-philipp.reisner@linbit.com \
--to=philipp.reisner@linbit.com \
--cc=axboe@kernel.dk \
--cc=drbd-dev@lists.linbit.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox