mirror of
https://github.com/versity/scoutfs.git
synced 2026-05-01 10:25:43 +00:00
prandom_bytes and family removed, switch to get_random_bytes variants
In v6.1-rc5-2-ge9a688bcb193, get_random_u32_below() becomes available and can start replacing prandom_bytes_max(). Switch to it where we can. get_random_bytes() has been available since el7, so also replace prandom_bytes() where we're using it. Signed-off-by: Auke Kok <auke.kok@versity.com>
This commit is contained in:
@@ -496,3 +496,11 @@ endif
|
||||
ifneq (,$(shell grep 'struct posix_acl.*get_inode_acl' include/linux/fs.h))
|
||||
ccflags-y += -DKC_GET_INODE_ACL
|
||||
endif
|
||||
|
||||
#
|
||||
# v6.1-rc5-2-ge9a688bcb193
|
||||
#
|
||||
# get_random_u32_below() implementation
|
||||
ifneq (,$(shell grep 'u32 get_random_u32_below' include/linux/random.h))
|
||||
ccflags-y += -DKC_HAVE_GET_RANDOM_U32_BELOW
|
||||
endif
|
||||
|
||||
@@ -884,7 +884,7 @@ int scoutfs_block_dirty_ref(struct super_block *sb, struct scoutfs_alloc *alloc,
|
||||
hdr->magic = cpu_to_le32(magic);
|
||||
hdr->fsid = cpu_to_le64(sbi->fsid);
|
||||
hdr->blkno = cpu_to_le64(bl->blkno);
|
||||
prandom_bytes(&hdr->seq, sizeof(hdr->seq));
|
||||
get_random_bytes(&hdr->seq, sizeof(hdr->seq));
|
||||
|
||||
trace_scoutfs_block_dirty_ref(sb, le64_to_cpu(ref->blkno), le64_to_cpu(ref->seq),
|
||||
le64_to_cpu(hdr->blkno), le64_to_cpu(hdr->seq));
|
||||
|
||||
@@ -2068,7 +2068,7 @@ void scoutfs_inode_schedule_orphan_dwork(struct super_block *sb)
|
||||
|
||||
low = (opts.orphan_scan_delay_ms * 80) / 100;
|
||||
high = (opts.orphan_scan_delay_ms * 120) / 100;
|
||||
delay = msecs_to_jiffies(low + prandom_u32_max(high - low)) ?: 1;
|
||||
delay = msecs_to_jiffies(low + get_random_u32_below(high - low)) ?: 1;
|
||||
|
||||
mod_delayed_work(system_wq, &inf->orphan_scan_dwork, delay);
|
||||
}
|
||||
|
||||
@@ -489,4 +489,8 @@ static inline void stack_trace_print(unsigned long *entries, unsigned int nr_ent
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef KC_HAVE_GET_RANDOM_U32_BELOW
|
||||
#define get_random_u32_below prandom_u32_max
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -162,7 +162,7 @@ static void quorum_slot_sin(struct scoutfs_quorum_config *qconf, int i, struct s
|
||||
static ktime_t election_timeout(void)
|
||||
{
|
||||
return ktime_add_ms(ktime_get(), SCOUTFS_QUORUM_ELECT_MIN_MS +
|
||||
prandom_u32_max(SCOUTFS_QUORUM_ELECT_VAR_MS));
|
||||
get_random_u32_below(SCOUTFS_QUORUM_ELECT_VAR_MS));
|
||||
}
|
||||
|
||||
static ktime_t heartbeat_interval(void)
|
||||
|
||||
@@ -205,7 +205,7 @@ static struct squota_check *lookup_random_check(struct rhashtable *rht)
|
||||
|
||||
tbl = rht_dereference_rcu(rht->tbl, rht);
|
||||
do {
|
||||
for (s = 0, i = prandom_u32_max(tbl->size);
|
||||
for (s = 0, i = get_random_u32_below(tbl->size);
|
||||
s < tbl->size;
|
||||
s++, i = (i + 1) % tbl->size) {
|
||||
rht_for_each_entry_rcu(chk, pos, tbl, i, head) {
|
||||
|
||||
Reference in New Issue
Block a user