Commit 6af8652849a15e407b458a271ef9154e472f6dd4
Committed by
Sage Weil
1 parent
c213b50b7d
Exists in
master
and in
20 other branches
ceph: tidy ceph_mdsmap_decode() a little
I introduced a new temporary variable "info" instead of "m->m_info[mds]". Also I reversed the if condition and pulled everything in one indent level. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Alex Elder <elder@inktank.com>
Showing 1 changed file with 22 additions and 20 deletions Side-by-side Diff
fs/ceph/mdsmap.c
... | ... | @@ -92,6 +92,7 @@ |
92 | 92 | u32 num_export_targets; |
93 | 93 | void *pexport_targets = NULL; |
94 | 94 | struct ceph_timespec laggy_since; |
95 | + struct ceph_mds_info *info; | |
95 | 96 | |
96 | 97 | ceph_decode_need(p, end, sizeof(u64)*2 + 1 + sizeof(u32), bad); |
97 | 98 | global_id = ceph_decode_64(p); |
... | ... | @@ -126,26 +127,27 @@ |
126 | 127 | i+1, n, global_id, mds, inc, |
127 | 128 | ceph_pr_addr(&addr.in_addr), |
128 | 129 | ceph_mds_state_name(state)); |
129 | - if (mds >= 0 && mds < m->m_max_mds && state > 0) { | |
130 | - m->m_info[mds].global_id = global_id; | |
131 | - m->m_info[mds].state = state; | |
132 | - m->m_info[mds].addr = addr; | |
133 | - m->m_info[mds].laggy = | |
134 | - (laggy_since.tv_sec != 0 || | |
135 | - laggy_since.tv_nsec != 0); | |
136 | - m->m_info[mds].num_export_targets = num_export_targets; | |
137 | - if (num_export_targets) { | |
138 | - m->m_info[mds].export_targets = | |
139 | - kcalloc(num_export_targets, sizeof(u32), | |
140 | - GFP_NOFS); | |
141 | - if (m->m_info[mds].export_targets == NULL) | |
142 | - goto badmem; | |
143 | - for (j = 0; j < num_export_targets; j++) | |
144 | - m->m_info[mds].export_targets[j] = | |
145 | - ceph_decode_32(&pexport_targets); | |
146 | - } else { | |
147 | - m->m_info[mds].export_targets = NULL; | |
148 | - } | |
130 | + | |
131 | + if (mds < 0 || mds >= m->m_max_mds || state <= 0) | |
132 | + continue; | |
133 | + | |
134 | + info = &m->m_info[mds]; | |
135 | + info->global_id = global_id; | |
136 | + info->state = state; | |
137 | + info->addr = addr; | |
138 | + info->laggy = (laggy_since.tv_sec != 0 || | |
139 | + laggy_since.tv_nsec != 0); | |
140 | + info->num_export_targets = num_export_targets; | |
141 | + if (num_export_targets) { | |
142 | + info->export_targets = kcalloc(num_export_targets, | |
143 | + sizeof(u32), GFP_NOFS); | |
144 | + if (info->export_targets == NULL) | |
145 | + goto badmem; | |
146 | + for (j = 0; j < num_export_targets; j++) | |
147 | + info->export_targets[j] = | |
148 | + ceph_decode_32(&pexport_targets); | |
149 | + } else { | |
150 | + info->export_targets = NULL; | |
149 | 151 | } |
150 | 152 | } |
151 | 153 |