ceph: tidy ceph_mdsmap_decode() a little
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 29 May 2013 11:46:56 +0000 (06:46 -0500)
committerSage Weil <sage@inktank.com>
Mon, 1 Jul 2013 16:52:02 +0000 (09:52 -0700)
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>
fs/ceph/mdsmap.c

index d4d38977dcbb0bf8e4cdaf2c0534f8a71c27c2c8..132b64eeecd494b01d224d1d58394db498ed70a9 100644 (file)
@@ -92,6 +92,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
                u32 num_export_targets;
                void *pexport_targets = NULL;
                struct ceph_timespec laggy_since;
+               struct ceph_mds_info *info;
 
                ceph_decode_need(p, end, sizeof(u64)*2 + 1 + sizeof(u32), bad);
                global_id = ceph_decode_64(p);
@@ -126,26 +127,27 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
                     i+1, n, global_id, mds, inc,
                     ceph_pr_addr(&addr.in_addr),
                     ceph_mds_state_name(state));
-               if (mds >= 0 && mds < m->m_max_mds && state > 0) {
-                       m->m_info[mds].global_id = global_id;
-                       m->m_info[mds].state = state;
-                       m->m_info[mds].addr = addr;
-                       m->m_info[mds].laggy =
-                               (laggy_since.tv_sec != 0 ||
-                                laggy_since.tv_nsec != 0);
-                       m->m_info[mds].num_export_targets = num_export_targets;
-                       if (num_export_targets) {
-                               m->m_info[mds].export_targets =
-                                       kcalloc(num_export_targets, sizeof(u32),
-                                               GFP_NOFS);
-                               if (m->m_info[mds].export_targets == NULL)
-                                       goto badmem;
-                               for (j = 0; j < num_export_targets; j++)
-                                       m->m_info[mds].export_targets[j] =
-                                              ceph_decode_32(&pexport_targets);
-                       } else {
-                               m->m_info[mds].export_targets = NULL;
-                       }
+
+               if (mds < 0 || mds >= m->m_max_mds || state <= 0)
+                       continue;
+
+               info = &m->m_info[mds];
+               info->global_id = global_id;
+               info->state = state;
+               info->addr = addr;
+               info->laggy = (laggy_since.tv_sec != 0 ||
+                              laggy_since.tv_nsec != 0);
+               info->num_export_targets = num_export_targets;
+               if (num_export_targets) {
+                       info->export_targets = kcalloc(num_export_targets,
+                                                      sizeof(u32), GFP_NOFS);
+                       if (info->export_targets == NULL)
+                               goto badmem;
+                       for (j = 0; j < num_export_targets; j++)
+                               info->export_targets[j] =
+                                      ceph_decode_32(&pexport_targets);
+               } else {
+                       info->export_targets = NULL;
                }
        }