* [PATCH v3] drbd: use get_random_u64() where appropriate
@ 2026-04-05 15:47 David Carlier
2026-04-07 11:03 ` Christoph Böhmwalder
2026-04-07 12:27 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: David Carlier @ 2026-04-05 15:47 UTC (permalink / raw)
To: Philipp Reisner, Lars Ellenberg, Christoph Böhmwalder
Cc: Jens Axboe, drbd-dev, linux-block, linux-kernel, David Carlier
Use the typed random integer helpers instead of
get_random_bytes() when filling a single integer variable.
The helpers return the value directly, require no pointer
or size argument, and better express intent.
Signed-off-by: David Carlier <devnexen@gmail.com>
---
drivers/block/drbd/drbd_main.c | 4 ++--
drivers/block/drbd/drbd_nl.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 200d464e984b..b1a721dd0496 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -874,7 +874,7 @@ void drbd_gen_and_send_sync_uuid(struct drbd_peer_device *peer_device)
if (uuid && uuid != UUID_JUST_CREATED)
uuid = uuid + UUID_NEW_BM_OFFSET;
else
- get_random_bytes(&uuid, sizeof(u64));
+ uuid = get_random_u64();
drbd_uuid_set(device, UI_BITMAP, uuid);
drbd_print_uuids(device, "updated sync UUID");
drbd_md_sync(device);
@@ -3337,7 +3337,7 @@ void drbd_uuid_new_current(struct drbd_device *device) __must_hold(local)
u64 val;
unsigned long long bm_uuid;
- get_random_bytes(&val, sizeof(u64));
+ val = get_random_u64();
spin_lock_irq(&device->ldev->md.uuid_lock);
bm_uuid = device->ldev->md.uuid[UI_BITMAP];
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index e201f0087a0f..377f60b40f28 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -3173,7 +3173,7 @@ int drbd_adm_resume_io(struct sk_buff *skb, struct genl_info *info)
* matching real data uuid exists).
*/
u64 val;
- get_random_bytes(&val, sizeof(u64));
+ val = get_random_u64();
drbd_set_ed_uuid(device, val);
drbd_warn(device, "Resumed without access to data; please tear down before attempting to re-configure.\n");
}
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] drbd: use get_random_u64() where appropriate
2026-04-05 15:47 [PATCH v3] drbd: use get_random_u64() where appropriate David Carlier
@ 2026-04-07 11:03 ` Christoph Böhmwalder
2026-04-07 12:27 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Böhmwalder @ 2026-04-07 11:03 UTC (permalink / raw)
To: David Carlier
Cc: Philipp Reisner, Lars Ellenberg, Jens Axboe, drbd-dev,
linux-block, linux-kernel
On Sun, Apr 05, 2026 at 04:47:04PM +0100, David Carlier wrote:
>Use the typed random integer helpers instead of
>get_random_bytes() when filling a single integer variable.
>The helpers return the value directly, require no pointer
>or size argument, and better express intent.
>
>Signed-off-by: David Carlier <devnexen@gmail.com>
>---
> drivers/block/drbd/drbd_main.c | 4 ++--
> drivers/block/drbd/drbd_nl.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
Maybe I just missed it, but v1 and v2 of this don't seem to exist?
Anyway, the patch itself looks good, thanks.
Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] drbd: use get_random_u64() where appropriate
2026-04-05 15:47 [PATCH v3] drbd: use get_random_u64() where appropriate David Carlier
2026-04-07 11:03 ` Christoph Böhmwalder
@ 2026-04-07 12:27 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-04-07 12:27 UTC (permalink / raw)
To: Philipp Reisner, Lars Ellenberg, Christoph Böhmwalder,
David Carlier
Cc: drbd-dev, linux-block, linux-kernel
On Sun, 05 Apr 2026 16:47:04 +0100, David Carlier wrote:
> Use the typed random integer helpers instead of
> get_random_bytes() when filling a single integer variable.
> The helpers return the value directly, require no pointer
> or size argument, and better express intent.
Applied, thanks!
[1/1] drbd: use get_random_u64() where appropriate
commit: fa0cac9a515877fad856c860ad51107b86ed6c4f
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-07 12:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-05 15:47 [PATCH v3] drbd: use get_random_u64() where appropriate David Carlier
2026-04-07 11:03 ` Christoph Böhmwalder
2026-04-07 12:27 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox