blob: a55b5f4d0dbebd264d8f04cdff379d822e658636 [file] [log] [blame]
Goldwyn Rodrigues8e854e92014-03-07 11:21:15 -06001/*
2 * Copyright (C) 2015, SUSE
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 */
10
11
12#include <linux/module.h>
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -060013#include <linux/dlm.h>
14#include <linux/sched.h>
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -050015#include <linux/raid/md_p.h>
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -060016#include "md.h"
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -050017#include "bitmap.h"
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -050018#include "md-cluster.h"
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -060019
20#define LVB_SIZE 64
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -050021#define NEW_DEV_TIMEOUT 5000
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -060022
23struct dlm_lock_resource {
24 dlm_lockspace_t *ls;
25 struct dlm_lksb lksb;
26 char *name; /* lock name. */
27 uint32_t flags; /* flags to pass to dlm_lock() */
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -060028 struct completion completion; /* completion for synchronized locking */
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -050029 void (*bast)(void *arg, int mode); /* blocking AST function pointer*/
30 struct mddev *mddev; /* pointing back to mddev. */
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -050031 int mode;
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -050032};
33
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -050034struct suspend_info {
35 int slot;
36 sector_t lo;
37 sector_t hi;
38 struct list_head list;
39};
40
41struct resync_info {
42 __le64 lo;
43 __le64 hi;
44};
45
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -060046/* md_cluster_info flags */
47#define MD_CLUSTER_WAITING_FOR_NEWDISK 1
Goldwyn Rodrigues90382ed2015-06-24 09:30:32 -050048#define MD_CLUSTER_SUSPEND_READ_BALANCING 2
Guoqing Jiangeece0752015-07-10 17:01:21 +080049#define MD_CLUSTER_BEGIN_JOIN_CLUSTER 3
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -060050
Guoqing Jiang8b9277c2015-12-21 10:51:00 +110051/* Lock the send communication. This is done through
52 * bit manipulation as opposed to a mutex in order to
53 * accomodate lock and hold. See next comment.
54 */
55#define MD_CLUSTER_SEND_LOCK 4
Guoqing Jiange19508f2015-12-21 10:51:01 +110056/* If cluster operations (such as adding a disk) must lock the
57 * communication channel, so as to perform extra operations
58 * (update metadata) and no other operation is allowed on the
59 * MD. Token needs to be locked and held until the operation
60 * completes witha md_update_sb(), which would eventually release
61 * the lock.
Guoqing Jiang8b9277c2015-12-21 10:51:00 +110062 */
63#define MD_CLUSTER_SEND_LOCKED_ALREADY 5
64
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -060065
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -050066struct md_cluster_info {
67 /* dlm lock space and resources for clustered raid. */
68 dlm_lockspace_t *lockspace;
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -050069 int slot_number;
70 struct completion completion;
Guoqing Jiang8b9277c2015-12-21 10:51:00 +110071 struct mutex recv_mutex;
Goldwyn Rodrigues54519c52014-06-06 12:12:32 -050072 struct dlm_lock_resource *bitmap_lockres;
Guoqing Jiangf6a2dc62015-12-21 10:51:00 +110073 struct dlm_lock_resource **other_bitmap_lockres;
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -050074 struct dlm_lock_resource *resync_lockres;
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -050075 struct list_head suspend_list;
76 spinlock_t suspend_lock;
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -050077 struct md_thread *recovery_thread;
78 unsigned long recovery_map;
Goldwyn Rodrigues46646802014-06-07 01:08:29 -050079 /* communication loc resources */
80 struct dlm_lock_resource *ack_lockres;
81 struct dlm_lock_resource *message_lockres;
82 struct dlm_lock_resource *token_lockres;
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -050083 struct dlm_lock_resource *no_new_dev_lockres;
Goldwyn Rodrigues46646802014-06-07 01:08:29 -050084 struct md_thread *recv_thread;
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -050085 struct completion newdisk_completion;
Guoqing Jiang8b9277c2015-12-21 10:51:00 +110086 wait_queue_head_t wait;
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -060087 unsigned long state;
Guoqing Jiang18c9ff72016-05-02 11:50:12 -040088 /* record the region in RESYNCING message */
89 sector_t sync_low;
90 sector_t sync_hi;
Goldwyn Rodrigues46646802014-06-07 01:08:29 -050091};
92
93enum msg_type {
94 METADATA_UPDATED = 0,
95 RESYNCING,
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -050096 NEWDISK,
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -050097 REMOVE,
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -050098 RE_ADD,
Guoqing Jiangdc737d72015-07-10 16:54:04 +080099 BITMAP_NEEDS_SYNC,
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500100};
101
102struct cluster_msg {
Guoqing Jiangcf97a342015-10-16 15:40:22 +0800103 __le32 type;
104 __le32 slot;
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500105 /* TODO: Unionize this for smaller footprint */
Guoqing Jiangcf97a342015-10-16 15:40:22 +0800106 __le64 low;
107 __le64 high;
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500108 char uuid[16];
Guoqing Jiangcf97a342015-10-16 15:40:22 +0800109 __le32 raid_slot;
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600110};
111
112static void sync_ast(void *arg)
113{
114 struct dlm_lock_resource *res;
115
NeilBrown2e2a7cd2015-10-19 15:42:18 +1100116 res = arg;
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600117 complete(&res->completion);
118}
119
120static int dlm_lock_sync(struct dlm_lock_resource *res, int mode)
121{
122 int ret = 0;
123
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600124 ret = dlm_lock(res->ls, mode, &res->lksb,
125 res->flags, res->name, strlen(res->name),
126 0, sync_ast, res, res->bast);
127 if (ret)
128 return ret;
129 wait_for_completion(&res->completion);
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -0500130 if (res->lksb.sb_status == 0)
131 res->mode = mode;
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600132 return res->lksb.sb_status;
133}
134
135static int dlm_unlock_sync(struct dlm_lock_resource *res)
136{
137 return dlm_lock_sync(res, DLM_LOCK_NL);
138}
139
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500140static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600141 char *name, void (*bastfn)(void *arg, int mode), int with_lvb)
142{
143 struct dlm_lock_resource *res = NULL;
144 int ret, namelen;
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500145 struct md_cluster_info *cinfo = mddev->cluster_info;
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600146
147 res = kzalloc(sizeof(struct dlm_lock_resource), GFP_KERNEL);
148 if (!res)
149 return NULL;
Guoqing Jiangb83d51c2015-07-10 17:01:16 +0800150 init_completion(&res->completion);
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500151 res->ls = cinfo->lockspace;
152 res->mddev = mddev;
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -0500153 res->mode = DLM_LOCK_IV;
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600154 namelen = strlen(name);
155 res->name = kzalloc(namelen + 1, GFP_KERNEL);
156 if (!res->name) {
157 pr_err("md-cluster: Unable to allocate resource name for resource %s\n", name);
158 goto out_err;
159 }
160 strlcpy(res->name, name, namelen + 1);
161 if (with_lvb) {
162 res->lksb.sb_lvbptr = kzalloc(LVB_SIZE, GFP_KERNEL);
163 if (!res->lksb.sb_lvbptr) {
164 pr_err("md-cluster: Unable to allocate LVB for resource %s\n", name);
165 goto out_err;
166 }
167 res->flags = DLM_LKF_VALBLK;
168 }
169
170 if (bastfn)
171 res->bast = bastfn;
172
173 res->flags |= DLM_LKF_EXPEDITE;
174
175 ret = dlm_lock_sync(res, DLM_LOCK_NL);
176 if (ret) {
177 pr_err("md-cluster: Unable to lock NL on new lock resource %s\n", name);
178 goto out_err;
179 }
180 res->flags &= ~DLM_LKF_EXPEDITE;
181 res->flags |= DLM_LKF_CONVERT;
182
183 return res;
184out_err:
185 kfree(res->lksb.sb_lvbptr);
186 kfree(res->name);
187 kfree(res);
188 return NULL;
189}
190
191static void lockres_free(struct dlm_lock_resource *res)
192{
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800193 int ret;
194
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600195 if (!res)
196 return;
197
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800198 /* cancel a lock request or a conversion request that is blocked */
199 res->flags |= DLM_LKF_CANCEL;
200retry:
201 ret = dlm_unlock(res->ls, res->lksb.sb_lkid, 0, &res->lksb, res);
202 if (unlikely(ret != 0)) {
203 pr_info("%s: failed to unlock %s return %d\n", __func__, res->name, ret);
204
205 /* if a lock conversion is cancelled, then the lock is put
206 * back to grant queue, need to ensure it is unlocked */
207 if (ret == -DLM_ECANCEL)
208 goto retry;
209 }
210 res->flags &= ~DLM_LKF_CANCEL;
Goldwyn Rodrigues47741b72014-03-07 13:49:26 -0600211 wait_for_completion(&res->completion);
212
213 kfree(res->name);
214 kfree(res->lksb.sb_lvbptr);
215 kfree(res);
216}
Goldwyn Rodrigues8e854e92014-03-07 11:21:15 -0600217
NeilBrown30661b42015-10-19 15:44:00 +1100218static void add_resync_info(struct dlm_lock_resource *lockres,
219 sector_t lo, sector_t hi)
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500220{
221 struct resync_info *ri;
222
223 ri = (struct resync_info *)lockres->lksb.sb_lvbptr;
224 ri->lo = cpu_to_le64(lo);
225 ri->hi = cpu_to_le64(hi);
226}
227
228static struct suspend_info *read_resync_info(struct mddev *mddev, struct dlm_lock_resource *lockres)
229{
230 struct resync_info ri;
231 struct suspend_info *s = NULL;
232 sector_t hi = 0;
233
234 dlm_lock_sync(lockres, DLM_LOCK_CR);
235 memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(struct resync_info));
236 hi = le64_to_cpu(ri.hi);
Guoqing Jiangcf97a342015-10-16 15:40:22 +0800237 if (hi > 0) {
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500238 s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL);
239 if (!s)
240 goto out;
241 s->hi = hi;
242 s->lo = le64_to_cpu(ri.lo);
243 }
244 dlm_unlock_sync(lockres);
245out:
246 return s;
247}
248
kbuild test robot6dc69c9c2015-02-28 07:04:37 +0800249static void recover_bitmaps(struct md_thread *thread)
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -0500250{
251 struct mddev *mddev = thread->mddev;
252 struct md_cluster_info *cinfo = mddev->cluster_info;
253 struct dlm_lock_resource *bm_lockres;
254 char str[64];
255 int slot, ret;
256 struct suspend_info *s, *tmp;
257 sector_t lo, hi;
258
259 while (cinfo->recovery_map) {
260 slot = fls64((u64)cinfo->recovery_map) - 1;
261
262 /* Clear suspend_area associated with the bitmap */
263 spin_lock_irq(&cinfo->suspend_lock);
264 list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
265 if (slot == s->slot) {
266 list_del(&s->list);
267 kfree(s);
268 }
269 spin_unlock_irq(&cinfo->suspend_lock);
270
271 snprintf(str, 64, "bitmap%04d", slot);
272 bm_lockres = lockres_init(mddev, str, NULL, 1);
273 if (!bm_lockres) {
274 pr_err("md-cluster: Cannot initialize bitmaps\n");
275 goto clear_bit;
276 }
277
278 ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW);
279 if (ret) {
280 pr_err("md-cluster: Could not DLM lock %s: %d\n",
281 str, ret);
282 goto clear_bit;
283 }
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -0500284 ret = bitmap_copy_from_slot(mddev, slot, &lo, &hi, true);
Goldwyn Rodrigues4b26a082014-06-07 00:52:29 -0500285 if (ret) {
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -0500286 pr_err("md-cluster: Could not copy data from bitmap %d\n", slot);
Goldwyn Rodrigues4b26a082014-06-07 00:52:29 -0500287 goto dlm_unlock;
288 }
289 if (hi > 0) {
Goldwyn Rodrigues4b26a082014-06-07 00:52:29 -0500290 if (lo < mddev->recovery_cp)
291 mddev->recovery_cp = lo;
Guoqing Jiangeb315cd2016-05-02 11:33:10 -0400292 /* wake up thread to continue resync in case resync
293 * is not finished */
294 if (mddev->recovery_cp != MaxSector) {
295 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
296 md_wakeup_thread(mddev->thread);
297 }
Goldwyn Rodrigues4b26a082014-06-07 00:52:29 -0500298 }
299dlm_unlock:
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -0500300 dlm_unlock_sync(bm_lockres);
301clear_bit:
Shaohua Li4ac7a652016-01-22 15:54:42 -0800302 lockres_free(bm_lockres);
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -0500303 clear_bit(slot, &cinfo->recovery_map);
304 }
305}
306
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500307static void recover_prep(void *arg)
308{
Goldwyn Rodrigues90382ed2015-06-24 09:30:32 -0500309 struct mddev *mddev = arg;
310 struct md_cluster_info *cinfo = mddev->cluster_info;
311 set_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state);
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500312}
313
Guoqing Jiang05cd0e52015-07-10 16:54:03 +0800314static void __recover_slot(struct mddev *mddev, int slot)
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500315{
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500316 struct md_cluster_info *cinfo = mddev->cluster_info;
317
Guoqing Jiang05cd0e52015-07-10 16:54:03 +0800318 set_bit(slot, &cinfo->recovery_map);
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -0500319 if (!cinfo->recovery_thread) {
320 cinfo->recovery_thread = md_register_thread(recover_bitmaps,
321 mddev, "recover");
322 if (!cinfo->recovery_thread) {
323 pr_warn("md-cluster: Could not create recovery thread\n");
324 return;
325 }
326 }
327 md_wakeup_thread(cinfo->recovery_thread);
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500328}
329
Guoqing Jiang05cd0e52015-07-10 16:54:03 +0800330static void recover_slot(void *arg, struct dlm_slot *slot)
331{
332 struct mddev *mddev = arg;
333 struct md_cluster_info *cinfo = mddev->cluster_info;
334
335 pr_info("md-cluster: %s Node %d/%d down. My slot: %d. Initiating recovery.\n",
336 mddev->bitmap_info.cluster_name,
337 slot->nodeid, slot->slot,
338 cinfo->slot_number);
339 /* deduct one since dlm slot starts from one while the num of
340 * cluster-md begins with 0 */
341 __recover_slot(mddev, slot->slot - 1);
342}
343
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500344static void recover_done(void *arg, struct dlm_slot *slots,
345 int num_slots, int our_slot,
346 uint32_t generation)
347{
348 struct mddev *mddev = arg;
349 struct md_cluster_info *cinfo = mddev->cluster_info;
350
351 cinfo->slot_number = our_slot;
Guoqing Jiangeece0752015-07-10 17:01:21 +0800352 /* completion is only need to be complete when node join cluster,
353 * it doesn't need to run during another node's failure */
354 if (test_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state)) {
355 complete(&cinfo->completion);
356 clear_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state);
357 }
Goldwyn Rodrigues90382ed2015-06-24 09:30:32 -0500358 clear_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state);
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500359}
360
Guoqing Jiangeece0752015-07-10 17:01:21 +0800361/* the ops is called when node join the cluster, and do lock recovery
362 * if node failure occurs */
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500363static const struct dlm_lockspace_ops md_ls_ops = {
364 .recover_prep = recover_prep,
365 .recover_slot = recover_slot,
366 .recover_done = recover_done,
367};
368
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500369/*
370 * The BAST function for the ack lock resource
371 * This function wakes up the receive thread in
372 * order to receive and process the message.
373 */
374static void ack_bast(void *arg, int mode)
375{
NeilBrown2e2a7cd2015-10-19 15:42:18 +1100376 struct dlm_lock_resource *res = arg;
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500377 struct md_cluster_info *cinfo = res->mddev->cluster_info;
378
379 if (mode == DLM_LOCK_EX)
380 md_wakeup_thread(cinfo->recv_thread);
381}
382
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500383static void __remove_suspend_info(struct md_cluster_info *cinfo, int slot)
384{
385 struct suspend_info *s, *tmp;
386
387 list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
388 if (slot == s->slot) {
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500389 list_del(&s->list);
390 kfree(s);
391 break;
392 }
393}
394
Goldwyn Rodriguesb8ca8462015-10-09 11:27:01 -0500395static void remove_suspend_info(struct mddev *mddev, int slot)
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500396{
Goldwyn Rodriguesb8ca8462015-10-09 11:27:01 -0500397 struct md_cluster_info *cinfo = mddev->cluster_info;
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500398 spin_lock_irq(&cinfo->suspend_lock);
399 __remove_suspend_info(cinfo, slot);
400 spin_unlock_irq(&cinfo->suspend_lock);
Goldwyn Rodriguesb8ca8462015-10-09 11:27:01 -0500401 mddev->pers->quiesce(mddev, 2);
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500402}
403
404
Goldwyn Rodrigues9ed38ff52015-08-14 12:19:40 -0500405static void process_suspend_info(struct mddev *mddev,
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500406 int slot, sector_t lo, sector_t hi)
407{
Goldwyn Rodrigues9ed38ff52015-08-14 12:19:40 -0500408 struct md_cluster_info *cinfo = mddev->cluster_info;
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500409 struct suspend_info *s;
410
411 if (!hi) {
Goldwyn Rodriguesb8ca8462015-10-09 11:27:01 -0500412 remove_suspend_info(mddev, slot);
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -0500413 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
414 md_wakeup_thread(mddev->thread);
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500415 return;
416 }
Guoqing Jiang18c9ff72016-05-02 11:50:12 -0400417
418 /*
419 * The bitmaps are not same for different nodes
420 * if RESYNCING is happening in one node, then
421 * the node which received the RESYNCING message
422 * probably will perform resync with the region
423 * [lo, hi] again, so we could reduce resync time
424 * a lot if we can ensure that the bitmaps among
425 * different nodes are match up well.
426 *
427 * sync_low/hi is used to record the region which
428 * arrived in the previous RESYNCING message,
429 *
430 * Call bitmap_sync_with_cluster to clear
431 * NEEDED_MASK and set RESYNC_MASK since
432 * resync thread is running in another node,
433 * so we don't need to do the resync again
434 * with the same section */
435 bitmap_sync_with_cluster(mddev, cinfo->sync_low,
436 cinfo->sync_hi,
437 lo, hi);
438 cinfo->sync_low = lo;
439 cinfo->sync_hi = hi;
440
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500441 s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL);
442 if (!s)
443 return;
444 s->slot = slot;
445 s->lo = lo;
446 s->hi = hi;
Goldwyn Rodrigues9ed38ff52015-08-14 12:19:40 -0500447 mddev->pers->quiesce(mddev, 1);
448 mddev->pers->quiesce(mddev, 0);
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500449 spin_lock_irq(&cinfo->suspend_lock);
450 /* Remove existing entry (if exists) before adding */
451 __remove_suspend_info(cinfo, slot);
452 list_add(&s->list, &cinfo->suspend_list);
453 spin_unlock_irq(&cinfo->suspend_lock);
Goldwyn Rodriguesb8ca8462015-10-09 11:27:01 -0500454 mddev->pers->quiesce(mddev, 2);
Goldwyn Rodriguese59721c2014-06-07 02:30:30 -0500455}
456
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500457static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
458{
459 char disk_uuid[64];
460 struct md_cluster_info *cinfo = mddev->cluster_info;
461 char event_name[] = "EVENT=ADD_DEVICE";
462 char raid_slot[16];
463 char *envp[] = {event_name, disk_uuid, raid_slot, NULL};
464 int len;
465
466 len = snprintf(disk_uuid, 64, "DEVICE_UUID=");
Guoqing Jiangb89f7042015-07-10 16:54:02 +0800467 sprintf(disk_uuid + len, "%pU", cmsg->uuid);
Guoqing Jiangfaeff832015-10-12 17:21:21 +0800468 snprintf(raid_slot, 16, "RAID_DISK=%d", le32_to_cpu(cmsg->raid_slot));
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500469 pr_info("%s:%d Sending kobject change with %s and %s\n", __func__, __LINE__, disk_uuid, raid_slot);
470 init_completion(&cinfo->newdisk_completion);
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -0600471 set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500472 kobject_uevent_env(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE, envp);
473 wait_for_completion_timeout(&cinfo->newdisk_completion,
474 NEW_DEV_TIMEOUT);
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -0600475 clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500476}
477
478
479static void process_metadata_update(struct mddev *mddev, struct cluster_msg *msg)
480{
481 struct md_cluster_info *cinfo = mddev->cluster_info;
Guoqing Jiang15858fa2015-12-21 10:51:00 +1100482 mddev->good_device_nr = le32_to_cpu(msg->raid_slot);
483 set_bit(MD_RELOAD_SB, &mddev->flags);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500484 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR);
Guoqing Jiang15858fa2015-12-21 10:51:00 +1100485 md_wakeup_thread(mddev->thread);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500486}
487
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -0500488static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg)
489{
Guoqing Jiangfaeff832015-10-12 17:21:21 +0800490 struct md_rdev *rdev = md_find_rdev_nr_rcu(mddev,
491 le32_to_cpu(msg->raid_slot));
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -0500492
Guoqing Jiang659b2542015-12-21 10:50:59 +1100493 if (rdev) {
494 set_bit(ClusterRemove, &rdev->flags);
495 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
496 md_wakeup_thread(mddev->thread);
497 }
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -0500498 else
Guoqing Jiangfaeff832015-10-12 17:21:21 +0800499 pr_warn("%s: %d Could not find disk(%d) to REMOVE\n",
500 __func__, __LINE__, le32_to_cpu(msg->raid_slot));
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -0500501}
502
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -0500503static void process_readd_disk(struct mddev *mddev, struct cluster_msg *msg)
504{
Guoqing Jiangfaeff832015-10-12 17:21:21 +0800505 struct md_rdev *rdev = md_find_rdev_nr_rcu(mddev,
506 le32_to_cpu(msg->raid_slot));
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -0500507
508 if (rdev && test_bit(Faulty, &rdev->flags))
509 clear_bit(Faulty, &rdev->flags);
510 else
Guoqing Jiangfaeff832015-10-12 17:21:21 +0800511 pr_warn("%s: %d Could not find disk(%d) which is faulty",
512 __func__, __LINE__, le32_to_cpu(msg->raid_slot));
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -0500513}
514
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500515static void process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
516{
Guoqing Jiang256f5b22015-10-12 17:21:23 +0800517 if (WARN(mddev->cluster_info->slot_number - 1 == le32_to_cpu(msg->slot),
518 "node %d received it's own msg\n", le32_to_cpu(msg->slot)))
519 return;
Guoqing Jiangcf97a342015-10-16 15:40:22 +0800520 switch (le32_to_cpu(msg->type)) {
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500521 case METADATA_UPDATED:
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500522 process_metadata_update(mddev, msg);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500523 break;
524 case RESYNCING:
Guoqing Jiangcf97a342015-10-16 15:40:22 +0800525 process_suspend_info(mddev, le32_to_cpu(msg->slot),
526 le64_to_cpu(msg->low),
527 le64_to_cpu(msg->high));
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500528 break;
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500529 case NEWDISK:
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500530 process_add_new_disk(mddev, msg);
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -0500531 break;
532 case REMOVE:
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -0500533 process_remove_disk(mddev, msg);
534 break;
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -0500535 case RE_ADD:
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -0500536 process_readd_disk(mddev, msg);
537 break;
Guoqing Jiangdc737d72015-07-10 16:54:04 +0800538 case BITMAP_NEEDS_SYNC:
Guoqing Jiangcf97a342015-10-16 15:40:22 +0800539 __recover_slot(mddev, le32_to_cpu(msg->slot));
Guoqing Jiangdc737d72015-07-10 16:54:04 +0800540 break;
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -0500541 default:
542 pr_warn("%s:%d Received unknown message from %d\n",
543 __func__, __LINE__, msg->slot);
kbuild test robot09dd1af2015-02-28 09:16:08 +0800544 }
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500545}
546
547/*
548 * thread for receiving message
549 */
550static void recv_daemon(struct md_thread *thread)
551{
552 struct md_cluster_info *cinfo = thread->mddev->cluster_info;
553 struct dlm_lock_resource *ack_lockres = cinfo->ack_lockres;
554 struct dlm_lock_resource *message_lockres = cinfo->message_lockres;
555 struct cluster_msg msg;
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800556 int ret;
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500557
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100558 mutex_lock(&cinfo->recv_mutex);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500559 /*get CR on Message*/
560 if (dlm_lock_sync(message_lockres, DLM_LOCK_CR)) {
561 pr_err("md/raid1:failed to get CR on MESSAGE\n");
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100562 mutex_unlock(&cinfo->recv_mutex);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500563 return;
564 }
565
566 /* read lvb and wake up thread to process this message_lockres */
567 memcpy(&msg, message_lockres->lksb.sb_lvbptr, sizeof(struct cluster_msg));
568 process_recvd_msg(thread->mddev, &msg);
569
570 /*release CR on ack_lockres*/
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800571 ret = dlm_unlock_sync(ack_lockres);
572 if (unlikely(ret != 0))
573 pr_info("unlock ack failed return %d\n", ret);
Guoqing Jiang66099bb2015-07-10 17:01:15 +0800574 /*up-convert to PR on message_lockres*/
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800575 ret = dlm_lock_sync(message_lockres, DLM_LOCK_PR);
576 if (unlikely(ret != 0))
577 pr_info("lock PR on msg failed return %d\n", ret);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500578 /*get CR on ack_lockres again*/
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800579 ret = dlm_lock_sync(ack_lockres, DLM_LOCK_CR);
580 if (unlikely(ret != 0))
581 pr_info("lock CR on ack failed return %d\n", ret);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500582 /*release CR on message_lockres*/
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800583 ret = dlm_unlock_sync(message_lockres);
584 if (unlikely(ret != 0))
585 pr_info("unlock msg failed return %d\n", ret);
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100586 mutex_unlock(&cinfo->recv_mutex);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500587}
588
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100589/* lock_token()
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500590 * Takes the lock on the TOKEN lock resource so no other
591 * node can communicate while the operation is underway.
592 */
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100593static int lock_token(struct md_cluster_info *cinfo)
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500594{
595 int error;
596
597 error = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX);
598 if (error)
599 pr_err("md-cluster(%s:%d): failed to get EX on TOKEN (%d)\n",
600 __func__, __LINE__, error);
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100601
602 /* Lock the receive sequence */
603 mutex_lock(&cinfo->recv_mutex);
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500604 return error;
605}
606
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100607/* lock_comm()
608 * Sets the MD_CLUSTER_SEND_LOCK bit to lock the send channel.
609 */
610static int lock_comm(struct md_cluster_info *cinfo)
611{
612 wait_event(cinfo->wait,
613 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state));
614
615 return lock_token(cinfo);
616}
617
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500618static void unlock_comm(struct md_cluster_info *cinfo)
619{
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -0500620 WARN_ON(cinfo->token_lockres->mode != DLM_LOCK_EX);
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100621 mutex_unlock(&cinfo->recv_mutex);
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500622 dlm_unlock_sync(cinfo->token_lockres);
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100623 clear_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state);
624 wake_up(&cinfo->wait);
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500625}
626
627/* __sendmsg()
628 * This function performs the actual sending of the message. This function is
629 * usually called after performing the encompassing operation
630 * The function:
631 * 1. Grabs the message lockresource in EX mode
632 * 2. Copies the message to the message LVB
Guoqing Jiang66099bb2015-07-10 17:01:15 +0800633 * 3. Downconverts message lockresource to CW
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500634 * 4. Upconverts ack lock resource from CR to EX. This forces the BAST on other nodes
635 * and the other nodes read the message. The thread will wait here until all other
636 * nodes have released ack lock resource.
637 * 5. Downconvert ack lockresource to CR
638 */
639static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
640{
641 int error;
642 int slot = cinfo->slot_number - 1;
643
644 cmsg->slot = cpu_to_le32(slot);
645 /*get EX on Message*/
646 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_EX);
647 if (error) {
648 pr_err("md-cluster: failed to get EX on MESSAGE (%d)\n", error);
649 goto failed_message;
650 }
651
652 memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg,
653 sizeof(struct cluster_msg));
Guoqing Jiang66099bb2015-07-10 17:01:15 +0800654 /*down-convert EX to CW on Message*/
655 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_CW);
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500656 if (error) {
Guoqing Jiang66099bb2015-07-10 17:01:15 +0800657 pr_err("md-cluster: failed to convert EX to CW on MESSAGE(%d)\n",
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500658 error);
Guoqing Jiang66099bb2015-07-10 17:01:15 +0800659 goto failed_ack;
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500660 }
661
662 /*up-convert CR to EX on Ack*/
663 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_EX);
664 if (error) {
665 pr_err("md-cluster: failed to convert CR to EX on ACK(%d)\n",
666 error);
667 goto failed_ack;
668 }
669
670 /*down-convert EX to CR on Ack*/
671 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR);
672 if (error) {
673 pr_err("md-cluster: failed to convert EX to CR on ACK(%d)\n",
674 error);
675 goto failed_ack;
676 }
677
678failed_ack:
Guoqing Jiangb5ef5672015-07-10 17:01:17 +0800679 error = dlm_unlock_sync(cinfo->message_lockres);
680 if (unlikely(error != 0)) {
681 pr_err("md-cluster: failed convert to NL on MESSAGE(%d)\n",
682 error);
683 /* in case the message can't be released due to some reason */
684 goto failed_ack;
685 }
Goldwyn Rodrigues601b5152014-06-07 01:28:53 -0500686failed_message:
687 return error;
688}
689
690static int sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
691{
692 int ret;
693
694 lock_comm(cinfo);
695 ret = __sendmsg(cinfo, cmsg);
696 unlock_comm(cinfo);
697 return ret;
698}
699
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500700static int gather_all_resync_info(struct mddev *mddev, int total_slots)
701{
702 struct md_cluster_info *cinfo = mddev->cluster_info;
703 int i, ret = 0;
704 struct dlm_lock_resource *bm_lockres;
705 struct suspend_info *s;
706 char str[64];
Guoqing Jiangabb9b222015-07-10 17:01:22 +0800707 sector_t lo, hi;
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500708
709
710 for (i = 0; i < total_slots; i++) {
711 memset(str, '\0', 64);
712 snprintf(str, 64, "bitmap%04d", i);
713 bm_lockres = lockres_init(mddev, str, NULL, 1);
714 if (!bm_lockres)
715 return -ENOMEM;
Shaohua Li4ac7a652016-01-22 15:54:42 -0800716 if (i == (cinfo->slot_number - 1)) {
717 lockres_free(bm_lockres);
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500718 continue;
Shaohua Li4ac7a652016-01-22 15:54:42 -0800719 }
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500720
721 bm_lockres->flags |= DLM_LKF_NOQUEUE;
722 ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW);
723 if (ret == -EAGAIN) {
724 memset(bm_lockres->lksb.sb_lvbptr, '\0', LVB_SIZE);
725 s = read_resync_info(mddev, bm_lockres);
726 if (s) {
727 pr_info("%s:%d Resync[%llu..%llu] in progress on %d\n",
728 __func__, __LINE__,
729 (unsigned long long) s->lo,
730 (unsigned long long) s->hi, i);
731 spin_lock_irq(&cinfo->suspend_lock);
732 s->slot = i;
733 list_add(&s->list, &cinfo->suspend_list);
734 spin_unlock_irq(&cinfo->suspend_lock);
735 }
736 ret = 0;
737 lockres_free(bm_lockres);
738 continue;
739 }
Guoqing Jiang6e6d9f22015-07-10 17:01:20 +0800740 if (ret) {
741 lockres_free(bm_lockres);
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500742 goto out;
Guoqing Jiang6e6d9f22015-07-10 17:01:20 +0800743 }
Guoqing Jiangabb9b222015-07-10 17:01:22 +0800744
745 /* Read the disk bitmap sb and check if it needs recovery */
746 ret = bitmap_copy_from_slot(mddev, i, &lo, &hi, false);
747 if (ret) {
748 pr_warn("md-cluster: Could not gather bitmaps from slot %d", i);
749 lockres_free(bm_lockres);
750 continue;
751 }
752 if ((hi > 0) && (lo < mddev->recovery_cp)) {
753 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
754 mddev->recovery_cp = lo;
755 md_check_recovery(mddev);
756 }
757
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500758 dlm_unlock_sync(bm_lockres);
759 lockres_free(bm_lockres);
760 }
761out:
762 return ret;
763}
764
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -0500765static int join(struct mddev *mddev, int nodes)
766{
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500767 struct md_cluster_info *cinfo;
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500768 int ret, ops_rv;
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500769 char str[64];
770
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500771 cinfo = kzalloc(sizeof(struct md_cluster_info), GFP_KERNEL);
772 if (!cinfo)
773 return -ENOMEM;
774
Guoqing Jiang9e3072e2015-07-10 17:01:18 +0800775 INIT_LIST_HEAD(&cinfo->suspend_list);
776 spin_lock_init(&cinfo->suspend_lock);
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500777 init_completion(&cinfo->completion);
Guoqing Jiangeece0752015-07-10 17:01:21 +0800778 set_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state);
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100779 init_waitqueue_head(&cinfo->wait);
780 mutex_init(&cinfo->recv_mutex);
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500781
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500782 mddev->cluster_info = cinfo;
783
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500784 memset(str, 0, 64);
Guoqing Jiangb89f7042015-07-10 16:54:02 +0800785 sprintf(str, "%pU", mddev->uuid);
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500786 ret = dlm_new_lockspace(str, mddev->bitmap_info.cluster_name,
787 DLM_LSFL_FS, LVB_SIZE,
788 &md_ls_ops, mddev, &ops_rv, &cinfo->lockspace);
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500789 if (ret)
790 goto err;
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500791 wait_for_completion(&cinfo->completion);
Guoqing Jiang8c58f022015-04-21 11:25:52 -0500792 if (nodes < cinfo->slot_number) {
793 pr_err("md-cluster: Slot allotted(%d) is greater than available slots(%d).",
794 cinfo->slot_number, nodes);
Goldwyn Rodriguesb97e92572014-06-06 11:50:56 -0500795 ret = -ERANGE;
796 goto err;
797 }
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500798 /* Initiate the communication resources */
799 ret = -ENOMEM;
800 cinfo->recv_thread = md_register_thread(recv_daemon, mddev, "cluster_recv");
801 if (!cinfo->recv_thread) {
802 pr_err("md-cluster: cannot allocate memory for recv_thread!\n");
803 goto err;
804 }
805 cinfo->message_lockres = lockres_init(mddev, "message", NULL, 1);
806 if (!cinfo->message_lockres)
807 goto err;
808 cinfo->token_lockres = lockres_init(mddev, "token", NULL, 0);
809 if (!cinfo->token_lockres)
810 goto err;
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500811 cinfo->no_new_dev_lockres = lockres_init(mddev, "no-new-dev", NULL, 0);
812 if (!cinfo->no_new_dev_lockres)
813 goto err;
814
Guoqing Jiang15352122016-05-02 11:33:12 -0400815 ret = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX);
816 if (ret) {
817 ret = -EAGAIN;
818 pr_err("md-cluster: can't join cluster to avoid lock issue\n");
819 goto err;
820 }
821 cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0);
822 if (!cinfo->ack_lockres)
823 goto err;
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500824 /* get sync CR lock on ACK. */
825 if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR))
826 pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n",
827 ret);
Guoqing Jiang15352122016-05-02 11:33:12 -0400828 dlm_unlock_sync(cinfo->token_lockres);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500829 /* get sync CR lock on no-new-dev. */
830 if (dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR))
831 pr_err("md-cluster: failed to get a sync CR lock on no-new-dev!(%d)\n", ret);
832
Goldwyn Rodrigues54519c52014-06-06 12:12:32 -0500833
834 pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number);
835 snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1);
836 cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1);
837 if (!cinfo->bitmap_lockres)
838 goto err;
839 if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) {
840 pr_err("Failed to get bitmap lock\n");
841 ret = -EINVAL;
842 goto err;
843 }
844
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -0500845 cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0);
846 if (!cinfo->resync_lockres)
847 goto err;
848
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500849 ret = gather_all_resync_info(mddev, nodes);
850 if (ret)
851 goto err;
852
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -0500853 return 0;
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500854err:
Guoqing Jiang5b0fb332016-05-02 11:33:11 -0400855 md_unregister_thread(&cinfo->recovery_thread);
856 md_unregister_thread(&cinfo->recv_thread);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500857 lockres_free(cinfo->message_lockres);
858 lockres_free(cinfo->token_lockres);
859 lockres_free(cinfo->ack_lockres);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500860 lockres_free(cinfo->no_new_dev_lockres);
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -0500861 lockres_free(cinfo->resync_lockres);
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -0500862 lockres_free(cinfo->bitmap_lockres);
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500863 if (cinfo->lockspace)
864 dlm_release_lockspace(cinfo->lockspace, 2);
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500865 mddev->cluster_info = NULL;
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500866 kfree(cinfo);
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500867 return ret;
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -0500868}
869
Guoqing Jiang09995412015-10-01 00:09:18 +0800870static void resync_bitmap(struct mddev *mddev)
871{
872 struct md_cluster_info *cinfo = mddev->cluster_info;
873 struct cluster_msg cmsg = {0};
874 int err;
875
876 cmsg.type = cpu_to_le32(BITMAP_NEEDS_SYNC);
877 err = sendmsg(cinfo, &cmsg);
878 if (err)
879 pr_err("%s:%d: failed to send BITMAP_NEEDS_SYNC message (%d)\n",
880 __func__, __LINE__, err);
881}
882
Guoqing Jiangf6a2dc62015-12-21 10:51:00 +1100883static void unlock_all_bitmaps(struct mddev *mddev);
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -0500884static int leave(struct mddev *mddev)
885{
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500886 struct md_cluster_info *cinfo = mddev->cluster_info;
887
888 if (!cinfo)
889 return 0;
Guoqing Jiang09995412015-10-01 00:09:18 +0800890
891 /* BITMAP_NEEDS_SYNC message should be sent when node
892 * is leaving the cluster with dirty bitmap, also we
893 * can only deliver it when dlm connection is available */
894 if (cinfo->slot_number > 0 && mddev->recovery_cp != MaxSector)
895 resync_bitmap(mddev);
896
Goldwyn Rodriguese94987d2014-06-07 00:45:22 -0500897 md_unregister_thread(&cinfo->recovery_thread);
Goldwyn Rodrigues46646802014-06-07 01:08:29 -0500898 md_unregister_thread(&cinfo->recv_thread);
899 lockres_free(cinfo->message_lockres);
900 lockres_free(cinfo->token_lockres);
901 lockres_free(cinfo->ack_lockres);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -0500902 lockres_free(cinfo->no_new_dev_lockres);
Shaohua Li4ac7a652016-01-22 15:54:42 -0800903 lockres_free(cinfo->resync_lockres);
Goldwyn Rodrigues54519c52014-06-06 12:12:32 -0500904 lockres_free(cinfo->bitmap_lockres);
Guoqing Jiangf6a2dc62015-12-21 10:51:00 +1100905 unlock_all_bitmaps(mddev);
Goldwyn Rodriguesc4ce8672014-03-29 10:20:02 -0500906 dlm_release_lockspace(cinfo->lockspace, 2);
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -0500907 return 0;
908}
909
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -0500910/* slot_number(): Returns the MD slot number to use
911 * DLM starts the slot numbers from 1, wheras cluster-md
912 * wants the number to be from zero, so we deduct one
913 */
914static int slot_number(struct mddev *mddev)
915{
916 struct md_cluster_info *cinfo = mddev->cluster_info;
917
918 return cinfo->slot_number - 1;
919}
920
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100921/*
922 * Check if the communication is already locked, else lock the communication
923 * channel.
924 * If it is already locked, token is in EX mode, and hence lock_token()
925 * should not be called.
926 */
Goldwyn Rodrigues293467a2014-06-07 01:44:51 -0500927static int metadata_update_start(struct mddev *mddev)
928{
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100929 struct md_cluster_info *cinfo = mddev->cluster_info;
930
931 wait_event(cinfo->wait,
932 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state) ||
933 test_and_clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state));
934
935 /* If token is already locked, return 0 */
936 if (cinfo->token_lockres->mode == DLM_LOCK_EX)
937 return 0;
938
939 return lock_token(cinfo);
Goldwyn Rodrigues293467a2014-06-07 01:44:51 -0500940}
941
942static int metadata_update_finish(struct mddev *mddev)
943{
944 struct md_cluster_info *cinfo = mddev->cluster_info;
945 struct cluster_msg cmsg;
Goldwyn Rodrigues70bcecd2015-08-21 10:33:39 -0500946 struct md_rdev *rdev;
947 int ret = 0;
NeilBrownba2746b2015-10-16 13:48:35 +1100948 int raid_slot = -1;
Goldwyn Rodrigues293467a2014-06-07 01:44:51 -0500949
950 memset(&cmsg, 0, sizeof(cmsg));
951 cmsg.type = cpu_to_le32(METADATA_UPDATED);
Goldwyn Rodrigues70bcecd2015-08-21 10:33:39 -0500952 /* Pick up a good active device number to send.
953 */
954 rdev_for_each(rdev, mddev)
955 if (rdev->raid_disk > -1 && !test_bit(Faulty, &rdev->flags)) {
NeilBrownba2746b2015-10-16 13:48:35 +1100956 raid_slot = rdev->desc_nr;
Goldwyn Rodrigues70bcecd2015-08-21 10:33:39 -0500957 break;
958 }
NeilBrownba2746b2015-10-16 13:48:35 +1100959 if (raid_slot >= 0) {
960 cmsg.raid_slot = cpu_to_le32(raid_slot);
Goldwyn Rodrigues70bcecd2015-08-21 10:33:39 -0500961 ret = __sendmsg(cinfo, &cmsg);
NeilBrownba2746b2015-10-16 13:48:35 +1100962 } else
Goldwyn Rodrigues70bcecd2015-08-21 10:33:39 -0500963 pr_warn("md-cluster: No good device id found to send\n");
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100964 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state);
Goldwyn Rodrigues293467a2014-06-07 01:44:51 -0500965 unlock_comm(cinfo);
966 return ret;
967}
968
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -0500969static void metadata_update_cancel(struct mddev *mddev)
Goldwyn Rodrigues293467a2014-06-07 01:44:51 -0500970{
971 struct md_cluster_info *cinfo = mddev->cluster_info;
Guoqing Jiang8b9277c2015-12-21 10:51:00 +1100972 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state);
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -0500973 unlock_comm(cinfo);
Goldwyn Rodrigues293467a2014-06-07 01:44:51 -0500974}
975
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -0500976static int resync_start(struct mddev *mddev)
977{
978 struct md_cluster_info *cinfo = mddev->cluster_info;
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -0500979 return dlm_lock_sync(cinfo->resync_lockres, DLM_LOCK_EX);
980}
981
Goldwyn Rodriguesc40f3412015-08-19 08:14:42 +1000982static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi)
Goldwyn Rodrigues965400e2014-06-07 02:16:58 -0500983{
984 struct md_cluster_info *cinfo = mddev->cluster_info;
Goldwyn Rodriguesac277c62015-12-21 10:50:59 +1100985 struct resync_info ri;
Guoqing Jiangaee177a2015-10-12 17:21:24 +0800986 struct cluster_msg cmsg = {0};
Goldwyn Rodrigues965400e2014-06-07 02:16:58 -0500987
Goldwyn Rodriguesac277c62015-12-21 10:50:59 +1100988 /* do not send zero again, if we have sent before */
989 if (hi == 0) {
990 memcpy(&ri, cinfo->bitmap_lockres->lksb.sb_lvbptr, sizeof(struct resync_info));
991 if (le64_to_cpu(ri.hi) == 0)
992 return 0;
993 }
994
NeilBrown30661b42015-10-19 15:44:00 +1100995 add_resync_info(cinfo->bitmap_lockres, lo, hi);
Goldwyn Rodriguesc40f3412015-08-19 08:14:42 +1000996 /* Re-acquire the lock to refresh LVB */
997 dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW);
Goldwyn Rodriguesc40f3412015-08-19 08:14:42 +1000998 cmsg.type = cpu_to_le32(RESYNCING);
Goldwyn Rodrigues965400e2014-06-07 02:16:58 -0500999 cmsg.low = cpu_to_le64(lo);
1000 cmsg.high = cpu_to_le64(hi);
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -05001001
Goldwyn Rodrigues965400e2014-06-07 02:16:58 -05001002 return sendmsg(cinfo, &cmsg);
1003}
1004
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -05001005static int resync_finish(struct mddev *mddev)
1006{
1007 struct md_cluster_info *cinfo = mddev->cluster_info;
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -05001008 dlm_unlock_sync(cinfo->resync_lockres);
1009 return resync_info_update(mddev, 0, 0);
1010}
1011
Goldwyn Rodrigues90382ed2015-06-24 09:30:32 -05001012static int area_resyncing(struct mddev *mddev, int direction,
1013 sector_t lo, sector_t hi)
Goldwyn Rodrigues589a1c42014-06-07 02:39:37 -05001014{
1015 struct md_cluster_info *cinfo = mddev->cluster_info;
1016 int ret = 0;
1017 struct suspend_info *s;
1018
Goldwyn Rodrigues90382ed2015-06-24 09:30:32 -05001019 if ((direction == READ) &&
1020 test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state))
1021 return 1;
1022
Goldwyn Rodrigues589a1c42014-06-07 02:39:37 -05001023 spin_lock_irq(&cinfo->suspend_lock);
1024 if (list_empty(&cinfo->suspend_list))
1025 goto out;
1026 list_for_each_entry(s, &cinfo->suspend_list, list)
1027 if (hi > s->lo && lo < s->hi) {
1028 ret = 1;
1029 break;
1030 }
1031out:
1032 spin_unlock_irq(&cinfo->suspend_lock);
1033 return ret;
1034}
1035
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -05001036/* add_new_disk() - initiates a disk add
1037 * However, if this fails before writing md_update_sb(),
1038 * add_new_disk_cancel() must be called to release token lock
1039 */
1040static int add_new_disk(struct mddev *mddev, struct md_rdev *rdev)
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001041{
1042 struct md_cluster_info *cinfo = mddev->cluster_info;
1043 struct cluster_msg cmsg;
1044 int ret = 0;
1045 struct mdp_superblock_1 *sb = page_address(rdev->sb_page);
1046 char *uuid = sb->device_uuid;
1047
1048 memset(&cmsg, 0, sizeof(cmsg));
1049 cmsg.type = cpu_to_le32(NEWDISK);
1050 memcpy(cmsg.uuid, uuid, 16);
Guoqing Jiangfaeff832015-10-12 17:21:21 +08001051 cmsg.raid_slot = cpu_to_le32(rdev->desc_nr);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001052 lock_comm(cinfo);
1053 ret = __sendmsg(cinfo, &cmsg);
1054 if (ret)
1055 return ret;
1056 cinfo->no_new_dev_lockres->flags |= DLM_LKF_NOQUEUE;
1057 ret = dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_EX);
1058 cinfo->no_new_dev_lockres->flags &= ~DLM_LKF_NOQUEUE;
1059 /* Some node does not "see" the device */
1060 if (ret == -EAGAIN)
1061 ret = -ENOENT;
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -05001062 if (ret)
1063 unlock_comm(cinfo);
Guoqing Jiang8b9277c2015-12-21 10:51:00 +11001064 else {
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001065 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR);
Guoqing Jiange19508f2015-12-21 10:51:01 +11001066 /* Since MD_CHANGE_DEVS will be set in add_bound_rdev which
1067 * will run soon after add_new_disk, the below path will be
1068 * invoked:
1069 * md_wakeup_thread(mddev->thread)
1070 * -> conf->thread (raid1d)
1071 * -> md_check_recovery -> md_update_sb
1072 * -> metadata_update_start/finish
1073 * MD_CLUSTER_SEND_LOCKED_ALREADY will be cleared eventually.
1074 *
1075 * For other failure cases, metadata_update_cancel and
1076 * add_new_disk_cancel also clear below bit as well.
1077 * */
Guoqing Jiang8b9277c2015-12-21 10:51:00 +11001078 set_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state);
1079 wake_up(&cinfo->wait);
1080 }
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001081 return ret;
1082}
1083
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -05001084static void add_new_disk_cancel(struct mddev *mddev)
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001085{
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -05001086 struct md_cluster_info *cinfo = mddev->cluster_info;
Guoqing Jiang8b9277c2015-12-21 10:51:00 +11001087 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state);
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -05001088 unlock_comm(cinfo);
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001089}
1090
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -06001091static int new_disk_ack(struct mddev *mddev, bool ack)
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001092{
1093 struct md_cluster_info *cinfo = mddev->cluster_info;
1094
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -06001095 if (!test_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state)) {
1096 pr_warn("md-cluster(%s): Spurious cluster confirmation\n", mdname(mddev));
1097 return -EINVAL;
1098 }
1099
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001100 if (ack)
1101 dlm_unlock_sync(cinfo->no_new_dev_lockres);
1102 complete(&cinfo->newdisk_completion);
Goldwyn Rodriguesfa8259d2015-03-02 10:55:49 -06001103 return 0;
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001104}
1105
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -05001106static int remove_disk(struct mddev *mddev, struct md_rdev *rdev)
1107{
Guoqing Jiangaee177a2015-10-12 17:21:24 +08001108 struct cluster_msg cmsg = {0};
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -05001109 struct md_cluster_info *cinfo = mddev->cluster_info;
Guoqing Jiangfaeff832015-10-12 17:21:21 +08001110 cmsg.type = cpu_to_le32(REMOVE);
1111 cmsg.raid_slot = cpu_to_le32(rdev->desc_nr);
Goldwyn Rodrigues54a88392015-12-21 10:51:00 +11001112 return sendmsg(cinfo, &cmsg);
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -05001113}
1114
Guoqing Jiangf6a2dc62015-12-21 10:51:00 +11001115static int lock_all_bitmaps(struct mddev *mddev)
1116{
1117 int slot, my_slot, ret, held = 1, i = 0;
1118 char str[64];
1119 struct md_cluster_info *cinfo = mddev->cluster_info;
1120
1121 cinfo->other_bitmap_lockres = kzalloc((mddev->bitmap_info.nodes - 1) *
1122 sizeof(struct dlm_lock_resource *),
1123 GFP_KERNEL);
1124 if (!cinfo->other_bitmap_lockres) {
1125 pr_err("md: can't alloc mem for other bitmap locks\n");
1126 return 0;
1127 }
1128
1129 my_slot = slot_number(mddev);
1130 for (slot = 0; slot < mddev->bitmap_info.nodes; slot++) {
1131 if (slot == my_slot)
1132 continue;
1133
1134 memset(str, '\0', 64);
1135 snprintf(str, 64, "bitmap%04d", slot);
1136 cinfo->other_bitmap_lockres[i] = lockres_init(mddev, str, NULL, 1);
1137 if (!cinfo->other_bitmap_lockres[i])
1138 return -ENOMEM;
1139
1140 cinfo->other_bitmap_lockres[i]->flags |= DLM_LKF_NOQUEUE;
1141 ret = dlm_lock_sync(cinfo->other_bitmap_lockres[i], DLM_LOCK_PW);
1142 if (ret)
1143 held = -1;
1144 i++;
1145 }
1146
1147 return held;
1148}
1149
1150static void unlock_all_bitmaps(struct mddev *mddev)
1151{
1152 struct md_cluster_info *cinfo = mddev->cluster_info;
1153 int i;
1154
1155 /* release other node's bitmap lock if they are existed */
1156 if (cinfo->other_bitmap_lockres) {
1157 for (i = 0; i < mddev->bitmap_info.nodes - 1; i++) {
1158 if (cinfo->other_bitmap_lockres[i]) {
1159 dlm_unlock_sync(cinfo->other_bitmap_lockres[i]);
1160 lockres_free(cinfo->other_bitmap_lockres[i]);
1161 }
1162 }
1163 kfree(cinfo->other_bitmap_lockres);
1164 }
1165}
1166
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -05001167static int gather_bitmaps(struct md_rdev *rdev)
1168{
1169 int sn, err;
1170 sector_t lo, hi;
Guoqing Jiangaee177a2015-10-12 17:21:24 +08001171 struct cluster_msg cmsg = {0};
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -05001172 struct mddev *mddev = rdev->mddev;
1173 struct md_cluster_info *cinfo = mddev->cluster_info;
1174
Guoqing Jiangfaeff832015-10-12 17:21:21 +08001175 cmsg.type = cpu_to_le32(RE_ADD);
1176 cmsg.raid_slot = cpu_to_le32(rdev->desc_nr);
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -05001177 err = sendmsg(cinfo, &cmsg);
1178 if (err)
1179 goto out;
1180
1181 for (sn = 0; sn < mddev->bitmap_info.nodes; sn++) {
1182 if (sn == (cinfo->slot_number - 1))
1183 continue;
1184 err = bitmap_copy_from_slot(mddev, sn, &lo, &hi, false);
1185 if (err) {
1186 pr_warn("md-cluster: Could not gather bitmaps from slot %d", sn);
1187 goto out;
1188 }
1189 if ((hi > 0) && (lo < mddev->recovery_cp))
1190 mddev->recovery_cp = lo;
1191 }
1192out:
1193 return err;
1194}
1195
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -05001196static struct md_cluster_operations cluster_ops = {
1197 .join = join,
1198 .leave = leave,
Goldwyn Rodriguescf921cc2014-03-30 00:42:49 -05001199 .slot_number = slot_number,
Goldwyn Rodriguesc186b122015-09-30 13:20:35 -05001200 .resync_start = resync_start,
1201 .resync_finish = resync_finish,
Goldwyn Rodrigues96ae9232014-06-06 12:35:34 -05001202 .resync_info_update = resync_info_update,
Goldwyn Rodrigues293467a2014-06-07 01:44:51 -05001203 .metadata_update_start = metadata_update_start,
1204 .metadata_update_finish = metadata_update_finish,
1205 .metadata_update_cancel = metadata_update_cancel,
Goldwyn Rodrigues589a1c42014-06-07 02:39:37 -05001206 .area_resyncing = area_resyncing,
Goldwyn Rodriguesdbb64f82015-10-01 13:20:27 -05001207 .add_new_disk = add_new_disk,
1208 .add_new_disk_cancel = add_new_disk_cancel,
Goldwyn Rodrigues1aee41f2014-10-29 18:51:31 -05001209 .new_disk_ack = new_disk_ack,
Goldwyn Rodrigues88bcfef2015-04-14 10:44:44 -05001210 .remove_disk = remove_disk,
Goldwyn Rodrigues97f6cd32015-04-14 10:45:42 -05001211 .gather_bitmaps = gather_bitmaps,
Guoqing Jiangf6a2dc62015-12-21 10:51:00 +11001212 .lock_all_bitmaps = lock_all_bitmaps,
1213 .unlock_all_bitmaps = unlock_all_bitmaps,
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -05001214};
1215
Goldwyn Rodrigues8e854e92014-03-07 11:21:15 -06001216static int __init cluster_init(void)
1217{
1218 pr_warn("md-cluster: EXPERIMENTAL. Use with caution\n");
1219 pr_info("Registering Cluster MD functions\n");
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -05001220 register_md_cluster_operations(&cluster_ops, THIS_MODULE);
Goldwyn Rodrigues8e854e92014-03-07 11:21:15 -06001221 return 0;
1222}
1223
1224static void cluster_exit(void)
1225{
Goldwyn Rodriguesedb39c92014-03-29 10:01:53 -05001226 unregister_md_cluster_operations();
Goldwyn Rodrigues8e854e92014-03-07 11:21:15 -06001227}
1228
1229module_init(cluster_init);
1230module_exit(cluster_exit);
Guoqing Jiang86b57272015-10-12 17:21:25 +08001231MODULE_AUTHOR("SUSE");
Goldwyn Rodrigues8e854e92014-03-07 11:21:15 -06001232MODULE_LICENSE("GPL");
1233MODULE_DESCRIPTION("Clustering support for MD");