summaryrefslogtreecommitdiff
path: root/rnd.c
blob: 8c123abb802997808a0fef90f5e46d75776a4e4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#include "rnd.h"
#include "die.h"
#include "ioexact.h"
#include "ioops.h"

static int fdw = -1;

static void randombytes_weak(unsigned char *x, size_t xlen)
{
	int ret;

	if (fdw == -1) {
		for (;;) {
			fdw = open(LOW_ENTROPY_SOURCE, O_RDONLY);
			if (fdw != -1)
				break;
			sleep(1);
		}
	}

	while (xlen > 0) {
		if (xlen < 1048576)
			ret = xlen;
		else
			ret = 1048576;

		ret = read(fdw, x, ret);
		if (ret < 1) {
			sleep(1);
			continue;
		}

		x += ret;
		xlen -= ret;
	}
}

static void randombytes_strong(unsigned char *x, size_t xlen)
{
	int fds, ret;

	fds = open_or_die(HIG_ENTROPY_SOURCE, O_RDONLY);

	ret = read_exact(fds, x, xlen, 0);
	if (ret != (int) xlen)
		panic("Error reading from entropy source!\n");

	close(fds);
}

int secrand(void)
{
	int ret;

	randombytes_weak((void *) &ret, sizeof(ret));

	return ret;
}

void gen_key_bytes(unsigned char *area, size_t len)
{
	randombytes_strong(area, len);
}
cetree/bindings/net/marvell-neta-bm.txt?id=930c532869774ebf8af9efe9484c597f896a7d46&id2=92d21ac74a9e3c09b0b01c764e530657e4c85c49'>diff)
libceph: apply new_state before new_up_client on incrementals
Currently, osd_weight and osd_state fields are updated in the encoding order. This is wrong, because an incremental map may look like e.g. new_up_client: { osd=6, addr=... } # set osd_state and addr new_state: { osd=6, xorstate=EXISTS } # clear osd_state Suppose osd6's current osd_state is EXISTS (i.e. osd6 is down). After applying new_up_client, osd_state is changed to EXISTS | UP. Carrying on with the new_state update, we flip EXISTS and leave osd6 in a weird "!EXISTS but UP" state. A non-existent OSD is considered down by the mapping code 2087 for (i = 0; i < pg->pg_temp.len; i++) { 2088 if (ceph_osd_is_down(osdmap, pg->pg_temp.osds[i])) { 2089 if (ceph_can_shift_osds(pi)) 2090 continue; 2091 2092 temp->osds[temp->size++] = CRUSH_ITEM_NONE; and so requests get directed to the second OSD in the set instead of the first, resulting in OSD-side errors like: [WRN] : client.4239 192.168.122.21:0/2444980242 misdirected client.4239.1:2827 pg 2.5df899f2 to osd.4 not [1,4,6] in e680/680 and hung rbds on the client: [ 493.566367] rbd: rbd0: write 400000 at 11cc00000 (0) [ 493.566805] rbd: rbd0: result -6 xferred 400000 [ 493.567011] blk_update_request: I/O error, dev rbd0, sector 9330688 The fix is to decouple application from the decoding and: - apply new_weight first - apply new_state before new_up_client - twiddle osd_state flags if marking in - clear out some of the state if osd is destroyed Fixes: http://tracker.ceph.com/issues/14901 Cc: stable@vger.kernel.org # 3.15+: 6dd74e44dc1d: libceph: set 'exists' flag for newly up osd Cc: stable@vger.kernel.org # 3.15+ Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Josh Durgin <jdurgin@redhat.com>
Diffstat (limited to 'Documentation/devicetree/bindings/net/marvell-neta-bm.txt')