[Bugs] [Bug 1200670] New: Convert quota size from n-to-h order before using it
bugzilla at redhat.com
bugzilla at redhat.com
Wed Mar 11 06:39:34 UTC 2015
https://bugzilla.redhat.com/show_bug.cgi?id=1200670
Bug ID: 1200670
Summary: Convert quota size from n-to-h order before using it
Product: GlusterFS
Version: mainline
Component: replicate
Assignee: bugs at gluster.org
Reporter: kdhananj at redhat.com
CC: bugs at gluster.org, gluster-bugs at redhat.com
Description of problem:
Figured while reading code that AFR is NOT converting quota_size value from
network to host byte order before using it in comparisons towards getting the
max size. This can cause problems with max_size calculation when the client is
running on a little endian machine.
0 afr_handle_quota_size (call_frame_t *frame, xlator_t *this)
1 {
2 unsigned char *readable = NULL;
3 afr_local_t *local = NULL;
4 afr_private_t *priv = NULL;
5 struct afr_reply *replies = NULL;
6 int i = 0;
7 uint64_t size = 0;
8 uint64_t max_size = 0;
9 int readable_cnt = 0;
10 int read_subvol = -1;
11
12 local = frame->local;
13 priv = this->private;
14 replies = local->replies;
15
16 readable = alloca0 (priv->child_count);
17
18 afr_inode_read_subvol_get (local->inode, this, readable, 0, 0);
19
20 readable_cnt = AFR_COUNT (readable, priv->child_count);
21
22 for (i = 0; i < priv->child_count; i++) {
23 if (!replies[i].valid || replies[i].op_ret == -1)
24 continue;
25 if (readable_cnt && !readable[i])
26 continue;
27 if (!replies[i].xdata)
28 continue;
29 if (dict_get_uint64 (replies[i].xdata, QUOTA_SIZE_KEY,
&size)) <---------- here
30 continue;
32 if (read_subvol == -1)
33 read_subvol = i;
34 if (size > max_size) {
35 read_subvol = i;
36 max_size = size;
37 }
38 }
39
40 if (!max_size)
41 return read_subvol;
44
45 for (i = 0; i < priv->child_count; i++) {
46 if (!replies[i].valid || replies[i].op_ret == -1)
47 continue;
48 if (readable_cnt && !readable[i])
49 continue;
50 if (!replies[i].xdata)
51 continue;
52 if (dict_set_uint64 (replies[i].xdata, QUOTA_SIZE_KEY,
max_size)) <------ and here
53 continue;
54 }
55
56 return read_subvol;
57 }
Version-Release number of selected component (if applicable):
How reproducible:
Steps to Reproduce:
1.
2.
3.
Actual results:
Expected results:
Additional info:
--
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
More information about the Bugs
mailing list