Skip to content

Commit 5eaee6e

Browse files
Christoph Hellwigaxboe
authored andcommitted
drbd: split out a drbd_discard_supported helper
Add a helper to check if discard is supported for a given connection / backing device combination. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Philipp Reisner <[email protected]> Reviewed-by: Lars Ellenberg <[email protected]> Tested-by: Christoph Böhmwalder <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent e3992e0 commit 5eaee6e

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

drivers/block/drbd/drbd_nl.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,24 +1231,33 @@ static unsigned int drbd_max_discard_sectors(struct drbd_connection *connection)
12311231
return AL_EXTENT_SIZE >> 9;
12321232
}
12331233

1234-
static void decide_on_discard_support(struct drbd_device *device,
1234+
static bool drbd_discard_supported(struct drbd_connection *connection,
12351235
struct drbd_backing_dev *bdev)
12361236
{
1237-
struct drbd_connection *connection =
1238-
first_peer_device(device)->connection;
1239-
struct request_queue *q = device->rq_queue;
1240-
unsigned int max_discard_sectors;
1241-
12421237
if (bdev && !bdev_max_discard_sectors(bdev->backing_bdev))
1243-
goto not_supported;
1238+
return false;
12441239

12451240
if (connection->cstate >= C_CONNECTED &&
12461241
!(connection->agreed_features & DRBD_FF_TRIM)) {
12471242
drbd_info(connection,
12481243
"peer DRBD too old, does not support TRIM: disabling discards\n");
1249-
goto not_supported;
1244+
return false;
12501245
}
12511246

1247+
return true;
1248+
}
1249+
1250+
static void decide_on_discard_support(struct drbd_device *device,
1251+
struct drbd_backing_dev *bdev)
1252+
{
1253+
struct drbd_connection *connection =
1254+
first_peer_device(device)->connection;
1255+
struct request_queue *q = device->rq_queue;
1256+
unsigned int max_discard_sectors;
1257+
1258+
if (!drbd_discard_supported(connection, bdev))
1259+
goto not_supported;
1260+
12521261
/*
12531262
* We don't care for the granularity, really.
12541263
*

0 commit comments

Comments
 (0)