diff options
Diffstat (limited to 'fs/ocfs2/dlm/dlmdomain.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmdomain.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 7e38a072d720..99805d578ab5 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
@@ -926,9 +926,10 @@ static int dlm_assert_joined_handler(struct o2net_msg *msg, u32 len, void *data, | |||
926 | } | 926 | } |
927 | 927 | ||
928 | static int dlm_match_regions(struct dlm_ctxt *dlm, | 928 | static int dlm_match_regions(struct dlm_ctxt *dlm, |
929 | struct dlm_query_region *qr) | 929 | struct dlm_query_region *qr, |
930 | char *local, int locallen) | ||
930 | { | 931 | { |
931 | char *local = NULL, *remote = qr->qr_regions; | 932 | char *remote = qr->qr_regions; |
932 | char *l, *r; | 933 | char *l, *r; |
933 | int localnr, i, j, foundit; | 934 | int localnr, i, j, foundit; |
934 | int status = 0; | 935 | int status = 0; |
@@ -957,13 +958,8 @@ static int dlm_match_regions(struct dlm_ctxt *dlm, | |||
957 | r += O2HB_MAX_REGION_NAME_LEN; | 958 | r += O2HB_MAX_REGION_NAME_LEN; |
958 | } | 959 | } |
959 | 960 | ||
960 | local = kmalloc(sizeof(qr->qr_regions), GFP_ATOMIC); | 961 | localnr = min(O2NM_MAX_REGIONS, locallen/O2HB_MAX_REGION_NAME_LEN); |
961 | if (!local) { | 962 | localnr = o2hb_get_all_regions(local, (u8)localnr); |
962 | status = -ENOMEM; | ||
963 | goto bail; | ||
964 | } | ||
965 | |||
966 | localnr = o2hb_get_all_regions(local, O2NM_MAX_REGIONS); | ||
967 | 963 | ||
968 | /* compare local regions with remote */ | 964 | /* compare local regions with remote */ |
969 | l = local; | 965 | l = local; |
@@ -1012,8 +1008,6 @@ static int dlm_match_regions(struct dlm_ctxt *dlm, | |||
1012 | } | 1008 | } |
1013 | 1009 | ||
1014 | bail: | 1010 | bail: |
1015 | kfree(local); | ||
1016 | |||
1017 | return status; | 1011 | return status; |
1018 | } | 1012 | } |
1019 | 1013 | ||
@@ -1075,6 +1069,7 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len, | |||
1075 | { | 1069 | { |
1076 | struct dlm_query_region *qr; | 1070 | struct dlm_query_region *qr; |
1077 | struct dlm_ctxt *dlm = NULL; | 1071 | struct dlm_ctxt *dlm = NULL; |
1072 | char *local = NULL; | ||
1078 | int status = 0; | 1073 | int status = 0; |
1079 | int locked = 0; | 1074 | int locked = 0; |
1080 | 1075 | ||
@@ -1083,6 +1078,13 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len, | |||
1083 | mlog(0, "Node %u queries hb regions on domain %s\n", qr->qr_node, | 1078 | mlog(0, "Node %u queries hb regions on domain %s\n", qr->qr_node, |
1084 | qr->qr_domain); | 1079 | qr->qr_domain); |
1085 | 1080 | ||
1081 | /* buffer used in dlm_mast_regions() */ | ||
1082 | local = kmalloc(sizeof(qr->qr_regions), GFP_KERNEL); | ||
1083 | if (!local) { | ||
1084 | status = -ENOMEM; | ||
1085 | goto bail; | ||
1086 | } | ||
1087 | |||
1086 | status = -EINVAL; | 1088 | status = -EINVAL; |
1087 | 1089 | ||
1088 | spin_lock(&dlm_domain_lock); | 1090 | spin_lock(&dlm_domain_lock); |
@@ -1112,13 +1114,15 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len, | |||
1112 | goto bail; | 1114 | goto bail; |
1113 | } | 1115 | } |
1114 | 1116 | ||
1115 | status = dlm_match_regions(dlm, qr); | 1117 | status = dlm_match_regions(dlm, qr, local, sizeof(qr->qr_regions)); |
1116 | 1118 | ||
1117 | bail: | 1119 | bail: |
1118 | if (locked) | 1120 | if (locked) |
1119 | spin_unlock(&dlm->spinlock); | 1121 | spin_unlock(&dlm->spinlock); |
1120 | spin_unlock(&dlm_domain_lock); | 1122 | spin_unlock(&dlm_domain_lock); |
1121 | 1123 | ||
1124 | kfree(local); | ||
1125 | |||
1122 | return status; | 1126 | return status; |
1123 | } | 1127 | } |
1124 | 1128 | ||