From 711e142d055fda62be482f74f2f73acac5e7e453 Mon Sep 17 00:00:00 2001 From: Maxim Patlasov Date: Fri, 6 Aug 2010 17:21:46 +0400 Subject: [PATCH] b=18751 Move prng.c to libcfs i=adilger i=maxim Note that some function names were changed: cfs_get_random_bytes --> cfs_get_random_bytes_prim ll_get_random_bytes --> cfs_get_random_bytes ll_rand --> cfs_rand ll_srand --> cfs_srand --- libcfs/include/libcfs/darwin/darwin-utils.h | 2 +- libcfs/include/libcfs/libcfs.h | 10 ++++ libcfs/include/libcfs/linux/linux-prim.h | 5 +- libcfs/include/libcfs/user-prim.h | 2 + libcfs/include/libcfs/winnt/portals_utils.h | 2 +- libcfs/libcfs/Makefile.in | 2 +- libcfs/libcfs/autoMakefile.am | 4 +- {lustre/lvfs => libcfs/libcfs}/prng.c | 84 +++++++++++++++-------------- lnet/klnds/o2iblnd/o2iblnd.h | 1 - lustre/include/linux/lustre_handles.h | 1 - lustre/include/lustre_lib.h | 5 -- lustre/include/obd_class.h | 2 +- lustre/liblustre/lutil.c | 4 +- lustre/llite/llite_lib.c | 1 - lustre/llite/remote_perm.c | 1 - lustre/llite/super25.c | 5 +- lustre/lov/lov_qos.c | 12 ++--- lustre/lvfs/Makefile.in | 2 +- lustre/lvfs/autoMakefile.am | 2 +- lustre/lvfs/lvfs_lib.c | 5 +- lustre/lvfs/quotafmt_test.c | 3 +- lustre/mds/handler.c | 1 - lustre/mds/mds_fs.c | 2 +- lustre/mdt/mdt_capa.c | 2 +- lustre/mgc/mgc_request.c | 2 +- lustre/obdclass/llog_test.c | 2 +- lustre/obdclass/lustre_handles.c | 6 +-- lustre/obdclass/mea.c | 1 - lustre/obdecho/echo_client.c | 2 +- lustre/osd-ldiskfs/osd_handler.c | 4 +- lustre/ptlrpc/client.c | 2 +- lustre/ptlrpc/gss/gss_bulk.c | 1 - lustre/ptlrpc/gss/gss_cli_upcall.c | 1 - lustre/ptlrpc/gss/gss_keyring.c | 1 - lustre/ptlrpc/gss/gss_krb5_mech.c | 5 +- lustre/ptlrpc/gss/gss_pipefs.c | 1 - lustre/ptlrpc/gss/gss_svc_upcall.c | 2 +- lustre/ptlrpc/gss/lproc_gss.c | 1 - lustre/ptlrpc/gss/sec_gss.c | 1 - 39 files changed, 95 insertions(+), 97 deletions(-) rename {lustre/lvfs => libcfs/libcfs}/prng.c (66%) diff --git a/libcfs/include/libcfs/darwin/darwin-utils.h b/libcfs/include/libcfs/darwin/darwin-utils.h index 508db7f..f91b298 100644 --- a/libcfs/include/libcfs/darwin/darwin-utils.h +++ b/libcfs/include/libcfs/darwin/darwin-utils.h @@ -61,7 +61,7 @@ char * ul2dstr(unsigned long address, char *buf, int len); #define set_bit(i, a) setbit(a, i) #define clear_bit(i, a) clrbit(a, i) -#define get_random_bytes(buf, len) read_random(buf, len) +#define cfs_get_random_bytes_prim(buf, len) read_random(buf, len) #endif /* __KERNEL__ */ diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index 549dab6..5ec895a 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -284,6 +284,16 @@ int cfs_oflags2univ(int flags); /* convert universal open flags to local open flags */ int cfs_univ2oflags(int flags); +/* + * Random number handling + */ + +/* returns a random 32-bit integer */ +unsigned int cfs_rand(void); +/* seed the generator */ +void cfs_srand(unsigned int, unsigned int); +void cfs_get_random_bytes(void *buf, int size); + #include #include #include diff --git a/libcfs/include/libcfs/linux/linux-prim.h b/libcfs/include/libcfs/linux/linux-prim.h index de374e5..b4612ad 100644 --- a/libcfs/include/libcfs/linux/linux-prim.h +++ b/libcfs/include/libcfs/linux/linux-prim.h @@ -62,6 +62,9 @@ #include #include #include +#ifdef HAVE_LINUX_RANDOM_H +#include +#endif #include #include @@ -378,5 +381,5 @@ typedef struct group_info cfs_group_info_t; /* * Random bytes */ -#define cfs_get_random_bytes(buf, nbytes) get_random_bytes(buf, nbytes) +#define cfs_get_random_bytes_prim(buf, nbytes) get_random_bytes(buf, nbytes) #endif diff --git a/libcfs/include/libcfs/user-prim.h b/libcfs/include/libcfs/user-prim.h index 9b2755c..8605d37 100644 --- a/libcfs/include/libcfs/user-prim.h +++ b/libcfs/include/libcfs/user-prim.h @@ -200,6 +200,8 @@ typedef struct cfs_group_info { # define max(x,y) ((x)>(y) ? (x) : (y)) #endif +#define cfs_get_random_bytes_prim(val, size) (*val) = 0 + /* utility libcfs init/fini entries */ #ifdef __WINNT__ extern int libcfs_arch_init(void); diff --git a/libcfs/include/libcfs/winnt/portals_utils.h b/libcfs/include/libcfs/winnt/portals_utils.h index e0572b9..27a554c 100644 --- a/libcfs/include/libcfs/winnt/portals_utils.h +++ b/libcfs/include/libcfs/winnt/portals_utils.h @@ -240,7 +240,7 @@ static inline void read_random(char *buf, int len) } } -#define cfs_get_random_bytes(buf, len) read_random(buf, len) +#define cfs_get_random_bytes_prim(buf, len) read_random(buf, len) /* do NOT use function or expression as parameters ... */ diff --git a/libcfs/libcfs/Makefile.in b/libcfs/libcfs/Makefile.in index 0f7913b..fbeefdd 100644 --- a/libcfs/libcfs/Makefile.in +++ b/libcfs/libcfs/Makefile.in @@ -25,7 +25,7 @@ sources: endif libcfs-all-objs := debug.o nidstrings.o lwt.o module.o tracefile.o watchdog.o \ - libcfs_string.o hash.o kernel_user_comm.o + libcfs_string.o hash.o kernel_user_comm.o prng.o libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs) diff --git a/libcfs/libcfs/autoMakefile.am b/libcfs/libcfs/autoMakefile.am index 644cd57..e15394a 100644 --- a/libcfs/libcfs/autoMakefile.am +++ b/libcfs/libcfs/autoMakefile.am @@ -43,7 +43,7 @@ DIST_SUBDIRS := linux util posix darwin if LIBLUSTRE noinst_LIBRARIES= libcfs.a libcfs_a_SOURCES= posix/posix-debug.c user-prim.c user-lock.c user-tcpip.c \ - user-bitops.c user-mem.c hash.c kernel_user_comm.c + prng.c user-bitops.c user-mem.c hash.c kernel_user_comm.c libcfs_a_CPPFLAGS = $(LLCPPFLAGS) libcfs_a_CFLAGS = $(LLCFLAGS) endif @@ -88,6 +88,6 @@ install-data-hook: $(install_data_hook) EXTRA_DIST := Info.plist MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux-*.c linux/*.o darwin/*.o libcfs -DIST_SOURCES := $(libcfs-all-objs:%.o=%.c) tracefile.h user-prim.c \ +DIST_SOURCES := $(libcfs-all-objs:%.o=%.c) tracefile.h user-prim.c prng.c \ user-lock.c user-tcpip.c user-bitops.c\ user-mem.c kernel_user_comm.c linux/linux-tracefile.h diff --git a/lustre/lvfs/prng.c b/libcfs/libcfs/prng.c similarity index 66% rename from lustre/lvfs/prng.c rename to libcfs/libcfs/prng.c index c07730e..f1568f4 100644 --- a/lustre/lvfs/prng.c +++ b/libcfs/libcfs/prng.c @@ -33,7 +33,7 @@ * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. * - * lustre/lvfs/prng.c + * libcfs/libcfs/prng.c * * concatenation of following two 16-bit multiply with carry generators * x(n)=a*x(n-1)+carry mod 2^16 and y(n)=b*y(n-1)+carry mod 2^16, @@ -45,14 +45,7 @@ # define EXPORT_SYMTAB #endif -#ifndef __KERNEL__ -#include -#define cfs_get_random_bytes(val, size) (*val) = 0 -#endif -#include -#if defined(HAVE_LINUX_RANDOM_H) -#include -#endif +#include /* From: George Marsaglia @@ -78,32 +71,49 @@ Date: Tue, 30 Sep 1997 05:29:35 -0700 static unsigned int seed_x = 521288629; static unsigned int seed_y = 362436069; -unsigned int ll_rand(void) -{ - seed_x = RANDOM_CONST_A * (seed_x & 65535) + (seed_x >> 16); - seed_y = RANDOM_CONST_B * (seed_y & 65535) + (seed_y >> 16); +/** + * cfs_rand - creates new seeds + * + * First it creates new seeds from the previous seeds. Then it generates a + * new psuedo random number for use. + * + * Returns a pseudo-random 32-bit integer + */ +unsigned int cfs_rand(void) +{ + seed_x = RANDOM_CONST_A * (seed_x & 65535) + (seed_x >> 16); + seed_y = RANDOM_CONST_B * (seed_y & 65535) + (seed_y >> 16); - return ((seed_x << 16) + (seed_y & 65535)); + return ((seed_x << 16) + (seed_y & 65535)); } -EXPORT_SYMBOL(ll_rand); +CFS_EXPORT_SYMBOL(cfs_rand); -/* Note that if the input seeds are not completely random, then there is - * a preferred location for the entropy in the two seeds, in order to avoid - * the initial values from the PRNG to be the same each time. +/** + * cfs_srand - sets the inital seed + * @seed1 : (seed_x) should have the most entropy in the low bits of the word + * @seed2 : (seed_y) should have the most entropy in the high bits of the word * - * seed1 (seed_x) should have the most entropy in the low bits of the word - * seed2 (seed_y) should have the most entropy in the high bits of the word */ -void ll_srand(unsigned int seed1, unsigned int seed2) + * Replaces the original seeds with new values. Used to generate a new pseudo + * random numbers. + */ +void cfs_srand(unsigned int seed1, unsigned int seed2) { - if (seed1) - seed_x = seed1; /* use default seeds if parameter is 0 */ - if (seed2) - seed_y = seed2; + if (seed1) + seed_x = seed1; /* use default seeds if parameter is 0 */ + if (seed2) + seed_y = seed2; } -EXPORT_SYMBOL(ll_srand); +CFS_EXPORT_SYMBOL(cfs_srand); -void ll_get_random_bytes(void *buf, int size) +/** + * cfs_get_random_bytes - generate a bunch of random numbers + * @buf : buffer to fill with random numbers + * @size: size of passed in buffer + * + * Fills a buffer with random bytes + */ +void cfs_get_random_bytes(void *buf, int size) { int *p = buf; int rem, tmp; @@ -112,30 +122,24 @@ void ll_get_random_bytes(void *buf, int size) rem = min((int)((unsigned long)buf & (sizeof(int) - 1)), size); if (rem) { - cfs_get_random_bytes(&tmp, sizeof(tmp)); - tmp ^= ll_rand(); + cfs_get_random_bytes_prim(&tmp, sizeof(tmp)); + tmp ^= cfs_rand(); memcpy(buf, &tmp, rem); p = buf + rem; size -= rem; } while (size >= sizeof(int)) { - cfs_get_random_bytes(&tmp, sizeof(tmp)); - *p = ll_rand() ^ tmp; + cfs_get_random_bytes_prim(&tmp, sizeof(tmp)); + *p = cfs_rand() ^ tmp; size -= sizeof(int); p++; } buf = p; if (size) { - cfs_get_random_bytes(&tmp, sizeof(tmp)); - tmp ^= ll_rand(); + cfs_get_random_bytes_prim(&tmp, sizeof(tmp)); + tmp ^= cfs_rand(); memcpy(buf, &tmp, size); } } -EXPORT_SYMBOL(ll_get_random_bytes); - -void ll_generate_random_uuid(class_uuid_t uuid_out) -{ - ll_get_random_bytes(uuid_out, sizeof(class_uuid_t)); -} -EXPORT_SYMBOL(ll_generate_random_uuid); +CFS_EXPORT_SYMBOL(cfs_get_random_bytes); diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index a78fa53..9122f2a 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -65,7 +65,6 @@ #include #include #include -#include #include #include diff --git a/lustre/include/linux/lustre_handles.h b/lustre/include/linux/lustre_handles.h index 29eec05..7393383 100644 --- a/lustre/include/linux/lustre_handles.h +++ b/lustre/include/linux/lustre_handles.h @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index f4ebfb6..02cc979 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -60,11 +60,6 @@ #error Unsupported operating system. #endif -/* prng.c */ -unsigned int ll_rand(void); /* returns a random 32-bit integer */ -void ll_srand(unsigned int, unsigned int); /* seed the generator */ -void ll_get_random_bytes(void *buf, int size); - /* target.c */ struct ptlrpc_request; struct obd_export; diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index dbf25cc..22fda83 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -2229,6 +2229,6 @@ int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen); int raw_name2idx(int hashtype, int count, const char *name, int namelen); /* prng.c */ -void ll_generate_random_uuid(class_uuid_t uuid_out); +#define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t)) #endif /* __LINUX_OBD_CLASS_H */ diff --git a/lustre/liblustre/lutil.c b/lustre/liblustre/lutil.c index 8ff4248..dead71b 100644 --- a/lustre/liblustre/lutil.c +++ b/lustre/liblustre/lutil.c @@ -128,7 +128,7 @@ void liblustre_init_random() if (_rand_dev_fd >= 0) { if (syscall(SYS_read, _rand_dev_fd, &seed, sizeof(seed)) == sizeof(seed)) { - ll_srand(seed[0], seed[1]); + cfs_srand(seed[0], seed[1]); syscall(SYS_close, _rand_dev_fd); return; } @@ -142,7 +142,7 @@ void liblustre_init_random() seed[0] = _my_pnid; #endif gettimeofday(&tv, NULL); - ll_srand(tv.tv_sec ^ __swab32(seed[0]), tv.tv_usec ^__swab32(getpid())); + cfs_srand(tv.tv_sec ^ __swab32(seed[0]), tv.tv_usec ^__swab32(getpid())); } static void init_capability(__u32 *res) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 512d1e2..b395e2b 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -42,7 +42,6 @@ #include #include -#include #include #include diff --git a/lustre/llite/remote_perm.c b/lustre/llite/remote_perm.c index ab34659..f90de1f 100644 --- a/lustre/llite/remote_perm.c +++ b/lustre/llite/remote_perm.c @@ -45,7 +45,6 @@ #include #include -#include #include #include diff --git a/lustre/llite/super25.c b/lustre/llite/super25.c index 1d11708..358b769 100644 --- a/lustre/llite/super25.c +++ b/lustre/llite/super25.c @@ -38,7 +38,6 @@ #include #include -#include #include #include #include @@ -162,7 +161,7 @@ static int __init init_lustre_lite(void) lustre_register_client_process_config(ll_process_config); - ll_get_random_bytes(seed, sizeof(seed)); + cfs_get_random_bytes(seed, sizeof(seed)); /* Nodes with small feet have little entropy * the NID for this node gives the most entropy in the low bits */ @@ -176,7 +175,7 @@ static int __init init_lustre_lite(void) } cfs_gettimeofday(&tv); - ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); + cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); init_timer(&ll_capa_timer); ll_capa_timer.function = ll_capa_timer_callback; diff --git a/lustre/lov/lov_qos.c b/lustre/lov/lov_qos.c index 2262c50..8c40022 100644 --- a/lustre/lov/lov_qos.c +++ b/lustre/lov/lov_qos.c @@ -609,7 +609,7 @@ static int alloc_rr(struct lov_obd *lov, int *idx_arr, int *stripe_cnt, GOTO(out, rc); if (--lqr->lqr_start_count <= 0) { - lqr->lqr_start_idx = ll_rand() % osts->op_count; + lqr->lqr_start_idx = cfs_rand() % osts->op_count; lqr->lqr_start_count = (LOV_CREATE_RESEED_MIN / max(osts->op_count, 1U) + LOV_CREATE_RESEED_MULT) * max(osts->op_count, 1U); @@ -880,23 +880,23 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt, if (total_weight) { #if BITS_PER_LONG == 32 - rand = ll_rand() % (unsigned)total_weight; + rand = cfs_rand() % (unsigned)total_weight; /* If total_weight > 32-bit, first generate the high * 32 bits of the random number, then add in the low * 32 bits (truncated to the upper limit, if needed) */ if (total_weight > 0xffffffffULL) - rand = (__u64)(ll_rand() % + rand = (__u64)(cfs_rand() % (unsigned)(total_weight >> 32)) << 32; else rand = 0; if (rand == (total_weight & 0xffffffff00000000ULL)) - rand |= ll_rand() % (unsigned)total_weight; + rand |= cfs_rand() % (unsigned)total_weight; else - rand |= ll_rand(); + rand |= cfs_rand(); #else - rand = ((__u64)ll_rand() << 32 | ll_rand()) % + rand = ((__u64)cfs_rand() << 32 | cfs_rand()) % total_weight; #endif } else { diff --git a/lustre/lvfs/Makefile.in b/lustre/lvfs/Makefile.in index 5c5ea61..4321250f 100644 --- a/lustre/lvfs/Makefile.in +++ b/lustre/lvfs/Makefile.in @@ -2,7 +2,7 @@ MODULES := lvfs @SERVER_TRUE@MODULES += fsfilt_@BACKINGFS@ @QUOTA_TRUE@MODULES += quotafmt_test -lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o upcall_cache.o prng.o lvfs_lib.o +lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o upcall_cache.o lvfs_lib.o @QUOTA_TRUE@quotafmt-objs := quotafmt_test.o diff --git a/lustre/lvfs/autoMakefile.am b/lustre/lvfs/autoMakefile.am index 001fc7e..861a71b 100644 --- a/lustre/lvfs/autoMakefile.am +++ b/lustre/lvfs/autoMakefile.am @@ -36,7 +36,7 @@ if LIBLUSTRE noinst_LIBRARIES = liblvfs.a -liblvfs_a_SOURCES = lvfs_userfs.c prng.c lvfs_lib.c +liblvfs_a_SOURCES = lvfs_userfs.c lvfs_lib.c liblvfs_a_CFLAGS = $(LLCFLAGS) liblvfs_a_CPPFLAGS = $(LLCPPFLAGS) diff --git a/lustre/lvfs/lvfs_lib.c b/lustre/lvfs/lvfs_lib.c index 9b0f367..9ec5e6f 100644 --- a/lustre/lvfs/lvfs_lib.c +++ b/lustre/lvfs/lvfs_lib.c @@ -41,7 +41,6 @@ */ #ifdef __KERNEL__ #include -#include #else #include #endif @@ -56,7 +55,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, size_t size, const char *file, int line) { if (ptr == NULL || - (ll_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) { + (cfs_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) { CERROR("%s%salloc of %s ("LPU64" bytes) failed at %s:%d\n", ptr ? "force " :"", type, name, (__u64)size, file, line); @@ -87,7 +86,7 @@ int __obd_fail_check_set(__u32 id, __u32 value, int set) /* Fail 1/obd_fail_val times */ if (obd_fail_loc & OBD_FAIL_RAND) { - if (obd_fail_val < 2 || ll_rand() % obd_fail_val > 0) + if (obd_fail_val < 2 || cfs_rand() % obd_fail_val > 0) return 0; } diff --git a/lustre/lvfs/quotafmt_test.c b/lustre/lvfs/quotafmt_test.c index 2fa315d..f9e3c95 100644 --- a/lustre/lvfs/quotafmt_test.c +++ b/lustre/lvfs/quotafmt_test.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -230,7 +229,7 @@ static struct lustre_dquot *get_rand_dquot(struct lustre_quota_info *lqi) if (dquot == NULL) return NULL; - ll_get_random_bytes(&rand, sizeof(rand)); + cfs_get_random_bytes(&rand, sizeof(rand)); if (!rand) rand = 1000; diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 7430bb6..d4c4dc4 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index eba7427..af66fc1 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -66,7 +66,7 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, { struct mds_obd *mds = &exp->exp_obd->u.mds; struct inode *parent_inode = mds->mds_objects_dir->d_inode; - unsigned int tmpname = ll_rand(); + unsigned int tmpname = cfs_rand(); struct file *filp; struct dentry *new_child; struct lvfs_run_ctxt saved; diff --git a/lustre/mdt/mdt_capa.c b/lustre/mdt/mdt_capa.c index 9ab150c..71e8434 100644 --- a/lustre/mdt/mdt_capa.c +++ b/lustre/mdt/mdt_capa.c @@ -57,7 +57,7 @@ static void make_capa_key(struct lustre_capa_key *key, { key->lk_seq = mdsnum; key->lk_keyid = keyid + 1; - ll_get_random_bytes(key->lk_key, sizeof(key->lk_key)); + cfs_get_random_bytes(key->lk_key, sizeof(key->lk_key)); } static inline void lck_cpu_to_le(struct lustre_capa_key *tgt, diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 47eb2bf..18c2106 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -419,7 +419,7 @@ static int mgc_requeue_thread(void *data) /* Always wait a few seconds to allow the server who caused the lock revocation to finish its setup, plus some random so everyone doesn't try to reconnect at once. */ - lwi_now = LWI_TIMEOUT(3 * CFS_HZ + (ll_rand() & 0xff) * \ + lwi_now = LWI_TIMEOUT(3 * CFS_HZ + (cfs_rand() & 0xff) * \ (CFS_HZ / 100), NULL, NULL); l_wait_event(rq_waitq, rq_state & RQ_STOP, &lwi_now); diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index 4dcda3b..d03f0bd 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -726,7 +726,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (rc) RETURN(rc); - llog_test_rand = ll_rand(); + llog_test_rand = cfs_rand(); rc = llog_run_tests(obd); if (rc) diff --git a/lustre/obdclass/lustre_handles.c b/lustre/obdclass/lustre_handles.c index ec8e51d..9c91df3 100644 --- a/lustre/obdclass/lustre_handles.c +++ b/lustre/obdclass/lustre_handles.c @@ -238,11 +238,11 @@ int class_handle_init(void) } /** bug 21430: add randomness to the initial base */ - ll_get_random_bytes(seed, sizeof(seed)); + cfs_get_random_bytes(seed, sizeof(seed)); cfs_gettimeofday(&tv); - ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); + cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); - ll_get_random_bytes(&handle_base, sizeof(handle_base)); + cfs_get_random_bytes(&handle_base, sizeof(handle_base)); LASSERT(handle_base != 0ULL); return 0; diff --git a/lustre/obdclass/mea.c b/lustre/obdclass/mea.c index e5eda8e..d3f06ee 100644 --- a/lustre/obdclass/mea.c +++ b/lustre/obdclass/mea.c @@ -39,7 +39,6 @@ #ifdef __KERNEL__ #include /* for request_module() */ #include -#include #include #include #else diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 883b311..9d548e0 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1308,7 +1308,7 @@ static int echo_create_object(struct echo_device *ed, int on_target, if (lsm->lsm_stripe_size == 0) lsm->lsm_stripe_size = CFS_PAGE_SIZE; - idx = ll_rand(); + idx = cfs_rand(); /* setup stripes: indices + default ids if required */ for (i = 0; i < lsm->lsm_stripe_count; i++) { diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 2a6b90a..2999143 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -2055,9 +2055,9 @@ static struct obd_capa *osd_capa_get(const struct lu_env *env, __u32 d[4], s[4]; s[0] = obj->oo_inode->i_uid; - ll_get_random_bytes(&(s[1]), sizeof(__u32)); + cfs_get_random_bytes(&(s[1]), sizeof(__u32)); s[2] = obj->oo_inode->i_gid; - ll_get_random_bytes(&(s[3]), sizeof(__u32)); + cfs_get_random_bytes(&(s[3]), sizeof(__u32)); rc = capa_encrypt_id(d, s, key->lk_key, CAPA_HMAC_KEY_MAX_LEN); if (unlikely(rc)) RETURN(ERR_PTR(rc)); diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 3c94ed2..60d6206 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -2727,7 +2727,7 @@ void ptlrpc_init_xid(void) cfs_spin_lock_init(&ptlrpc_last_xid_lock); if (now < YEAR_2004) { - ll_get_random_bytes(&ptlrpc_last_xid, sizeof(ptlrpc_last_xid)); + cfs_get_random_bytes(&ptlrpc_last_xid, sizeof(ptlrpc_last_xid)); ptlrpc_last_xid >>= 2; ptlrpc_last_xid |= (1ULL << 61); } else { diff --git a/lustre/ptlrpc/gss/gss_bulk.c b/lustre/ptlrpc/gss/gss_bulk.c index 2f10dca..5e90010 100644 --- a/lustre/ptlrpc/gss/gss_bulk.c +++ b/lustre/ptlrpc/gss/gss_bulk.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #else diff --git a/lustre/ptlrpc/gss/gss_cli_upcall.c b/lustre/ptlrpc/gss/gss_cli_upcall.c index b7f4560..ed2f672 100644 --- a/lustre/ptlrpc/gss/gss_cli_upcall.c +++ b/lustre/ptlrpc/gss/gss_cli_upcall.c @@ -49,7 +49,6 @@ #include #include #include -#include #else #include #endif diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c index 181c739..1aa2f6f 100644 --- a/lustre/ptlrpc/gss/gss_keyring.c +++ b/lustre/ptlrpc/gss/gss_keyring.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/ptlrpc/gss/gss_krb5_mech.c b/lustre/ptlrpc/gss/gss_krb5_mech.c index 9148f71..4b7900f 100644 --- a/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -57,7 +57,6 @@ #include #include #include -#include #include #else #include @@ -1248,7 +1247,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, fill_krb5_header(kctx, khdr, 1); /* generate confounder */ - ll_get_random_bytes(conf, ke->ke_conf_size); + cfs_get_random_bytes(conf, ke->ke_conf_size); /* get encryption blocksize. note kc_keye might not associated with * a tfm, currently only for arcfour-hmac */ @@ -1418,7 +1417,7 @@ __u32 gss_wrap_bulk_kerberos(struct gss_ctx *gctx, fill_krb5_header(kctx, khdr, 1); /* generate confounder */ - ll_get_random_bytes(conf, ke->ke_conf_size); + cfs_get_random_bytes(conf, ke->ke_conf_size); /* get encryption blocksize. note kc_keye might not associated with * a tfm, currently only for arcfour-hmac */ diff --git a/lustre/ptlrpc/gss/gss_pipefs.c b/lustre/ptlrpc/gss/gss_pipefs.c index 8611608..904435e 100644 --- a/lustre/ptlrpc/gss/gss_pipefs.c +++ b/lustre/ptlrpc/gss/gss_pipefs.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/ptlrpc/gss/gss_svc_upcall.c b/lustre/ptlrpc/gss/gss_svc_upcall.c index 3c51715..aaa4c85 100644 --- a/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -1424,7 +1424,7 @@ int __init gss_init_svc_upcall(void) * sequence number checking, thus no chance to sent error notification * back to clients. */ - ll_get_random_bytes(&__ctx_index, sizeof(__ctx_index)); + cfs_get_random_bytes(&__ctx_index, sizeof(__ctx_index)); cache_register(&rsi_cache); diff --git a/lustre/ptlrpc/gss/lproc_gss.c b/lustre/ptlrpc/gss/lproc_gss.c index ff340f0..1ac37b2 100644 --- a/lustre/ptlrpc/gss/lproc_gss.c +++ b/lustre/ptlrpc/gss/lproc_gss.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #else #include diff --git a/lustre/ptlrpc/gss/sec_gss.c b/lustre/ptlrpc/gss/sec_gss.c index 2cd6dea..be2322c 100644 --- a/lustre/ptlrpc/gss/sec_gss.c +++ b/lustre/ptlrpc/gss/sec_gss.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #else -- 1.8.3.1