userdlm.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /* -*- mode: c; c-basic-offset: 8; -*-
  2. * vim: noexpandtab sw=8 ts=8 sts=0:
  3. *
  4. * userdlm.c
  5. *
  6. * Code which implements the kernel side of a minimal userspace
  7. * interface to our DLM.
  8. *
  9. * Many of the functions here are pared down versions of dlmglue.c
  10. * functions.
  11. *
  12. * Copyright (C) 2003, 2004 Oracle. All rights reserved.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public
  16. * License as published by the Free Software Foundation; either
  17. * version 2 of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public
  25. * License along with this program; if not, write to the
  26. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  27. * Boston, MA 021110-1307, USA.
  28. */
  29. #include <linux/signal.h>
  30. #include <linux/module.h>
  31. #include <linux/fs.h>
  32. #include <linux/types.h>
  33. #include <linux/crc32.h>
  34. #include "cluster/nodemanager.h"
  35. #include "cluster/heartbeat.h"
  36. #include "cluster/tcp.h"
  37. #include "dlmapi.h"
  38. #include "userdlm.h"
  39. #define MLOG_MASK_PREFIX ML_DLMFS
  40. #include "cluster/masklog.h"
  41. static inline int user_check_wait_flag(struct user_lock_res *lockres,
  42. int flag)
  43. {
  44. int ret;
  45. spin_lock(&lockres->l_lock);
  46. ret = lockres->l_flags & flag;
  47. spin_unlock(&lockres->l_lock);
  48. return ret;
  49. }
  50. static inline void user_wait_on_busy_lock(struct user_lock_res *lockres)
  51. {
  52. wait_event(lockres->l_event,
  53. !user_check_wait_flag(lockres, USER_LOCK_BUSY));
  54. }
  55. static inline void user_wait_on_blocked_lock(struct user_lock_res *lockres)
  56. {
  57. wait_event(lockres->l_event,
  58. !user_check_wait_flag(lockres, USER_LOCK_BLOCKED));
  59. }
  60. /* I heart container_of... */
  61. static inline struct dlm_ctxt *
  62. dlm_ctxt_from_user_lockres(struct user_lock_res *lockres)
  63. {
  64. struct dlmfs_inode_private *ip;
  65. ip = container_of(lockres,
  66. struct dlmfs_inode_private,
  67. ip_lockres);
  68. return ip->ip_dlm;
  69. }
  70. static struct inode *
  71. user_dlm_inode_from_user_lockres(struct user_lock_res *lockres)
  72. {
  73. struct dlmfs_inode_private *ip;
  74. ip = container_of(lockres,
  75. struct dlmfs_inode_private,
  76. ip_lockres);
  77. return &ip->ip_vfs_inode;
  78. }
  79. static inline void user_recover_from_dlm_error(struct user_lock_res *lockres)
  80. {
  81. spin_lock(&lockres->l_lock);
  82. lockres->l_flags &= ~USER_LOCK_BUSY;
  83. spin_unlock(&lockres->l_lock);
  84. }
  85. #define user_log_dlm_error(_func, _stat, _lockres) do { \
  86. mlog(ML_ERROR, "Dlm error \"%s\" while calling %s on " \
  87. "resource %s: %s\n", dlm_errname(_stat), _func, \
  88. _lockres->l_name, dlm_errmsg(_stat)); \
  89. } while (0)
  90. /* WARNING: This function lives in a world where the only three lock
  91. * levels are EX, PR, and NL. It *will* have to be adjusted when more
  92. * lock types are added. */
  93. static inline int user_highest_compat_lock_level(int level)
  94. {
  95. int new_level = LKM_EXMODE;
  96. if (level == LKM_EXMODE)
  97. new_level = LKM_NLMODE;
  98. else if (level == LKM_PRMODE)
  99. new_level = LKM_PRMODE;
  100. return new_level;
  101. }
  102. static void user_ast(void *opaque)
  103. {
  104. struct user_lock_res *lockres = opaque;
  105. struct dlm_lockstatus *lksb;
  106. mlog(0, "AST fired for lockres %s\n", lockres->l_name);
  107. spin_lock(&lockres->l_lock);
  108. lksb = &(lockres->l_lksb);
  109. if (lksb->status != DLM_NORMAL) {
  110. mlog(ML_ERROR, "lksb status value of %u on lockres %s\n",
  111. lksb->status, lockres->l_name);
  112. spin_unlock(&lockres->l_lock);
  113. return;
  114. }
  115. mlog_bug_on_msg(lockres->l_requested == LKM_IVMODE,
  116. "Lockres %s, requested ivmode. flags 0x%x\n",
  117. lockres->l_name, lockres->l_flags);
  118. /* we're downconverting. */
  119. if (lockres->l_requested < lockres->l_level) {
  120. if (lockres->l_requested <=
  121. user_highest_compat_lock_level(lockres->l_blocking)) {
  122. lockres->l_blocking = LKM_NLMODE;
  123. lockres->l_flags &= ~USER_LOCK_BLOCKED;
  124. }
  125. }
  126. lockres->l_level = lockres->l_requested;
  127. lockres->l_requested = LKM_IVMODE;
  128. lockres->l_flags |= USER_LOCK_ATTACHED;
  129. lockres->l_flags &= ~USER_LOCK_BUSY;
  130. spin_unlock(&lockres->l_lock);
  131. wake_up(&lockres->l_event);
  132. }
  133. static inline void user_dlm_grab_inode_ref(struct user_lock_res *lockres)
  134. {
  135. struct inode *inode;
  136. inode = user_dlm_inode_from_user_lockres(lockres);
  137. if (!igrab(inode))
  138. BUG();
  139. }
  140. static void user_dlm_unblock_lock(void *opaque);
  141. static void __user_dlm_queue_lockres(struct user_lock_res *lockres)
  142. {
  143. if (!(lockres->l_flags & USER_LOCK_QUEUED)) {
  144. user_dlm_grab_inode_ref(lockres);
  145. INIT_WORK(&lockres->l_work, user_dlm_unblock_lock,
  146. lockres);
  147. queue_work(user_dlm_worker, &lockres->l_work);
  148. lockres->l_flags |= USER_LOCK_QUEUED;
  149. }
  150. }
  151. static void __user_dlm_cond_queue_lockres(struct user_lock_res *lockres)
  152. {
  153. int queue = 0;
  154. if (!(lockres->l_flags & USER_LOCK_BLOCKED))
  155. return;
  156. switch (lockres->l_blocking) {
  157. case LKM_EXMODE:
  158. if (!lockres->l_ex_holders && !lockres->l_ro_holders)
  159. queue = 1;
  160. break;
  161. case LKM_PRMODE:
  162. if (!lockres->l_ex_holders)
  163. queue = 1;
  164. break;
  165. default:
  166. BUG();
  167. }
  168. if (queue)
  169. __user_dlm_queue_lockres(lockres);
  170. }
  171. static void user_bast(void *opaque, int level)
  172. {
  173. struct user_lock_res *lockres = opaque;
  174. mlog(0, "Blocking AST fired for lockres %s. Blocking level %d\n",
  175. lockres->l_name, level);
  176. spin_lock(&lockres->l_lock);
  177. lockres->l_flags |= USER_LOCK_BLOCKED;
  178. if (level > lockres->l_blocking)
  179. lockres->l_blocking = level;
  180. __user_dlm_queue_lockres(lockres);
  181. spin_unlock(&lockres->l_lock);
  182. wake_up(&lockres->l_event);
  183. }
  184. static void user_unlock_ast(void *opaque, enum dlm_status status)
  185. {
  186. struct user_lock_res *lockres = opaque;
  187. mlog(0, "UNLOCK AST called on lock %s\n", lockres->l_name);
  188. if (status != DLM_NORMAL)
  189. mlog(ML_ERROR, "Dlm returns status %d\n", status);
  190. spin_lock(&lockres->l_lock);
  191. if (lockres->l_flags & USER_LOCK_IN_TEARDOWN)
  192. lockres->l_level = LKM_IVMODE;
  193. else {
  194. lockres->l_requested = LKM_IVMODE; /* cancel an
  195. * upconvert
  196. * request. */
  197. lockres->l_flags &= ~USER_LOCK_IN_CANCEL;
  198. /* we want the unblock thread to look at it again
  199. * now. */
  200. __user_dlm_queue_lockres(lockres);
  201. }
  202. lockres->l_flags &= ~USER_LOCK_BUSY;
  203. spin_unlock(&lockres->l_lock);
  204. wake_up(&lockres->l_event);
  205. }
  206. static inline void user_dlm_drop_inode_ref(struct user_lock_res *lockres)
  207. {
  208. struct inode *inode;
  209. inode = user_dlm_inode_from_user_lockres(lockres);
  210. iput(inode);
  211. }
  212. static void user_dlm_unblock_lock(void *opaque)
  213. {
  214. int new_level, status;
  215. struct user_lock_res *lockres = (struct user_lock_res *) opaque;
  216. struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres);
  217. mlog(0, "processing lockres %s\n", lockres->l_name);
  218. spin_lock(&lockres->l_lock);
  219. mlog_bug_on_msg(!(lockres->l_flags & USER_LOCK_QUEUED),
  220. "Lockres %s, flags 0x%x\n",
  221. lockres->l_name, lockres->l_flags);
  222. /* notice that we don't clear USER_LOCK_BLOCKED here. If it's
  223. * set, we want user_ast clear it. */
  224. lockres->l_flags &= ~USER_LOCK_QUEUED;
  225. /* It's valid to get here and no longer be blocked - if we get
  226. * several basts in a row, we might be queued by the first
  227. * one, the unblock thread might run and clear the queued
  228. * flag, and finally we might get another bast which re-queues
  229. * us before our ast for the downconvert is called. */
  230. if (!(lockres->l_flags & USER_LOCK_BLOCKED)) {
  231. mlog(0, "Lockres %s, flags 0x%x: queued but not blocking\n",
  232. lockres->l_name, lockres->l_flags);
  233. spin_unlock(&lockres->l_lock);
  234. goto drop_ref;
  235. }
  236. if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
  237. mlog(0, "lock is in teardown so we do nothing\n");
  238. spin_unlock(&lockres->l_lock);
  239. goto drop_ref;
  240. }
  241. if (lockres->l_flags & USER_LOCK_BUSY) {
  242. mlog(0, "BUSY flag detected...\n");
  243. if (lockres->l_flags & USER_LOCK_IN_CANCEL) {
  244. spin_unlock(&lockres->l_lock);
  245. goto drop_ref;
  246. }
  247. lockres->l_flags |= USER_LOCK_IN_CANCEL;
  248. spin_unlock(&lockres->l_lock);
  249. status = dlmunlock(dlm,
  250. &lockres->l_lksb,
  251. LKM_CANCEL,
  252. user_unlock_ast,
  253. lockres);
  254. if (status == DLM_CANCELGRANT) {
  255. /* If we got this, then the ast was fired
  256. * before we could cancel. We cleanup our
  257. * state, and restart the function. */
  258. spin_lock(&lockres->l_lock);
  259. lockres->l_flags &= ~USER_LOCK_IN_CANCEL;
  260. spin_unlock(&lockres->l_lock);
  261. } else if (status != DLM_NORMAL)
  262. user_log_dlm_error("dlmunlock", status, lockres);
  263. goto drop_ref;
  264. }
  265. /* If there are still incompat holders, we can exit safely
  266. * without worrying about re-queueing this lock as that will
  267. * happen on the last call to user_cluster_unlock. */
  268. if ((lockres->l_blocking == LKM_EXMODE)
  269. && (lockres->l_ex_holders || lockres->l_ro_holders)) {
  270. spin_unlock(&lockres->l_lock);
  271. mlog(0, "can't downconvert for ex: ro = %u, ex = %u\n",
  272. lockres->l_ro_holders, lockres->l_ex_holders);
  273. goto drop_ref;
  274. }
  275. if ((lockres->l_blocking == LKM_PRMODE)
  276. && lockres->l_ex_holders) {
  277. spin_unlock(&lockres->l_lock);
  278. mlog(0, "can't downconvert for pr: ex = %u\n",
  279. lockres->l_ex_holders);
  280. goto drop_ref;
  281. }
  282. /* yay, we can downconvert now. */
  283. new_level = user_highest_compat_lock_level(lockres->l_blocking);
  284. lockres->l_requested = new_level;
  285. lockres->l_flags |= USER_LOCK_BUSY;
  286. mlog(0, "Downconvert lock from %d to %d\n",
  287. lockres->l_level, new_level);
  288. spin_unlock(&lockres->l_lock);
  289. /* need lock downconvert request now... */
  290. status = dlmlock(dlm,
  291. new_level,
  292. &lockres->l_lksb,
  293. LKM_CONVERT|LKM_VALBLK,
  294. lockres->l_name,
  295. user_ast,
  296. lockres,
  297. user_bast);
  298. if (status != DLM_NORMAL) {
  299. user_log_dlm_error("dlmlock", status, lockres);
  300. user_recover_from_dlm_error(lockres);
  301. }
  302. drop_ref:
  303. user_dlm_drop_inode_ref(lockres);
  304. }
  305. static inline void user_dlm_inc_holders(struct user_lock_res *lockres,
  306. int level)
  307. {
  308. switch(level) {
  309. case LKM_EXMODE:
  310. lockres->l_ex_holders++;
  311. break;
  312. case LKM_PRMODE:
  313. lockres->l_ro_holders++;
  314. break;
  315. default:
  316. BUG();
  317. }
  318. }
  319. /* predict what lock level we'll be dropping down to on behalf
  320. * of another node, and return true if the currently wanted
  321. * level will be compatible with it. */
  322. static inline int
  323. user_may_continue_on_blocked_lock(struct user_lock_res *lockres,
  324. int wanted)
  325. {
  326. BUG_ON(!(lockres->l_flags & USER_LOCK_BLOCKED));
  327. return wanted <= user_highest_compat_lock_level(lockres->l_blocking);
  328. }
  329. int user_dlm_cluster_lock(struct user_lock_res *lockres,
  330. int level,
  331. int lkm_flags)
  332. {
  333. int status, local_flags;
  334. struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres);
  335. if (level != LKM_EXMODE &&
  336. level != LKM_PRMODE) {
  337. mlog(ML_ERROR, "lockres %s: invalid request!\n",
  338. lockres->l_name);
  339. status = -EINVAL;
  340. goto bail;
  341. }
  342. mlog(0, "lockres %s: asking for %s lock, passed flags = 0x%x\n",
  343. lockres->l_name,
  344. (level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE",
  345. lkm_flags);
  346. again:
  347. if (signal_pending(current)) {
  348. status = -ERESTARTSYS;
  349. goto bail;
  350. }
  351. spin_lock(&lockres->l_lock);
  352. /* We only compare against the currently granted level
  353. * here. If the lock is blocked waiting on a downconvert,
  354. * we'll get caught below. */
  355. if ((lockres->l_flags & USER_LOCK_BUSY) &&
  356. (level > lockres->l_level)) {
  357. /* is someone sitting in dlm_lock? If so, wait on
  358. * them. */
  359. spin_unlock(&lockres->l_lock);
  360. user_wait_on_busy_lock(lockres);
  361. goto again;
  362. }
  363. if ((lockres->l_flags & USER_LOCK_BLOCKED) &&
  364. (!user_may_continue_on_blocked_lock(lockres, level))) {
  365. /* is the lock is currently blocked on behalf of
  366. * another node */
  367. spin_unlock(&lockres->l_lock);
  368. user_wait_on_blocked_lock(lockres);
  369. goto again;
  370. }
  371. if (level > lockres->l_level) {
  372. local_flags = lkm_flags | LKM_VALBLK;
  373. if (lockres->l_level != LKM_IVMODE)
  374. local_flags |= LKM_CONVERT;
  375. lockres->l_requested = level;
  376. lockres->l_flags |= USER_LOCK_BUSY;
  377. spin_unlock(&lockres->l_lock);
  378. BUG_ON(level == LKM_IVMODE);
  379. BUG_ON(level == LKM_NLMODE);
  380. mlog(0, "lock %s, get lock from %d to level = %d\n",
  381. lockres->l_name, lockres->l_level, level);
  382. /* call dlm_lock to upgrade lock now */
  383. status = dlmlock(dlm,
  384. level,
  385. &lockres->l_lksb,
  386. local_flags,
  387. lockres->l_name,
  388. user_ast,
  389. lockres,
  390. user_bast);
  391. if (status != DLM_NORMAL) {
  392. if ((lkm_flags & LKM_NOQUEUE) &&
  393. (status == DLM_NOTQUEUED))
  394. status = -EAGAIN;
  395. else {
  396. user_log_dlm_error("dlmlock", status, lockres);
  397. status = -EINVAL;
  398. }
  399. user_recover_from_dlm_error(lockres);
  400. goto bail;
  401. }
  402. mlog(0, "lock %s, successfull return from dlmlock\n",
  403. lockres->l_name);
  404. user_wait_on_busy_lock(lockres);
  405. goto again;
  406. }
  407. user_dlm_inc_holders(lockres, level);
  408. spin_unlock(&lockres->l_lock);
  409. mlog(0, "lockres %s: Got %s lock!\n", lockres->l_name,
  410. (level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE");
  411. status = 0;
  412. bail:
  413. return status;
  414. }
  415. static inline void user_dlm_dec_holders(struct user_lock_res *lockres,
  416. int level)
  417. {
  418. switch(level) {
  419. case LKM_EXMODE:
  420. BUG_ON(!lockres->l_ex_holders);
  421. lockres->l_ex_holders--;
  422. break;
  423. case LKM_PRMODE:
  424. BUG_ON(!lockres->l_ro_holders);
  425. lockres->l_ro_holders--;
  426. break;
  427. default:
  428. BUG();
  429. }
  430. }
  431. void user_dlm_cluster_unlock(struct user_lock_res *lockres,
  432. int level)
  433. {
  434. if (level != LKM_EXMODE &&
  435. level != LKM_PRMODE) {
  436. mlog(ML_ERROR, "lockres %s: invalid request!\n", lockres->l_name);
  437. return;
  438. }
  439. mlog(0, "lockres %s: dropping %s lock\n", lockres->l_name,
  440. (level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE");
  441. spin_lock(&lockres->l_lock);
  442. user_dlm_dec_holders(lockres, level);
  443. __user_dlm_cond_queue_lockres(lockres);
  444. spin_unlock(&lockres->l_lock);
  445. }
  446. void user_dlm_write_lvb(struct inode *inode,
  447. const char *val,
  448. unsigned int len)
  449. {
  450. struct user_lock_res *lockres = &DLMFS_I(inode)->ip_lockres;
  451. char *lvb = lockres->l_lksb.lvb;
  452. BUG_ON(len > DLM_LVB_LEN);
  453. spin_lock(&lockres->l_lock);
  454. BUG_ON(lockres->l_level < LKM_EXMODE);
  455. memcpy(lvb, val, len);
  456. spin_unlock(&lockres->l_lock);
  457. }
  458. void user_dlm_read_lvb(struct inode *inode,
  459. char *val,
  460. unsigned int len)
  461. {
  462. struct user_lock_res *lockres = &DLMFS_I(inode)->ip_lockres;
  463. char *lvb = lockres->l_lksb.lvb;
  464. BUG_ON(len > DLM_LVB_LEN);
  465. spin_lock(&lockres->l_lock);
  466. BUG_ON(lockres->l_level < LKM_PRMODE);
  467. memcpy(val, lvb, len);
  468. spin_unlock(&lockres->l_lock);
  469. }
  470. void user_dlm_lock_res_init(struct user_lock_res *lockres,
  471. struct dentry *dentry)
  472. {
  473. memset(lockres, 0, sizeof(*lockres));
  474. spin_lock_init(&lockres->l_lock);
  475. init_waitqueue_head(&lockres->l_event);
  476. lockres->l_level = LKM_IVMODE;
  477. lockres->l_requested = LKM_IVMODE;
  478. lockres->l_blocking = LKM_IVMODE;
  479. /* should have been checked before getting here. */
  480. BUG_ON(dentry->d_name.len >= USER_DLM_LOCK_ID_MAX_LEN);
  481. memcpy(lockres->l_name,
  482. dentry->d_name.name,
  483. dentry->d_name.len);
  484. }
  485. int user_dlm_destroy_lock(struct user_lock_res *lockres)
  486. {
  487. int status = -EBUSY;
  488. struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres);
  489. mlog(0, "asked to destroy %s\n", lockres->l_name);
  490. spin_lock(&lockres->l_lock);
  491. while (lockres->l_flags & USER_LOCK_BUSY) {
  492. spin_unlock(&lockres->l_lock);
  493. mlog(0, "lock %s is busy\n", lockres->l_name);
  494. user_wait_on_busy_lock(lockres);
  495. spin_lock(&lockres->l_lock);
  496. }
  497. if (lockres->l_ro_holders || lockres->l_ex_holders) {
  498. spin_unlock(&lockres->l_lock);
  499. mlog(0, "lock %s has holders\n", lockres->l_name);
  500. goto bail;
  501. }
  502. status = 0;
  503. if (!(lockres->l_flags & USER_LOCK_ATTACHED)) {
  504. spin_unlock(&lockres->l_lock);
  505. mlog(0, "lock %s is not attached\n", lockres->l_name);
  506. goto bail;
  507. }
  508. lockres->l_flags &= ~USER_LOCK_ATTACHED;
  509. lockres->l_flags |= USER_LOCK_BUSY;
  510. lockres->l_flags |= USER_LOCK_IN_TEARDOWN;
  511. spin_unlock(&lockres->l_lock);
  512. mlog(0, "unlocking lockres %s\n", lockres->l_name);
  513. status = dlmunlock(dlm,
  514. &lockres->l_lksb,
  515. LKM_VALBLK,
  516. user_unlock_ast,
  517. lockres);
  518. if (status != DLM_NORMAL) {
  519. user_log_dlm_error("dlmunlock", status, lockres);
  520. status = -EINVAL;
  521. goto bail;
  522. }
  523. user_wait_on_busy_lock(lockres);
  524. status = 0;
  525. bail:
  526. return status;
  527. }
  528. struct dlm_ctxt *user_dlm_register_context(struct qstr *name)
  529. {
  530. struct dlm_ctxt *dlm;
  531. u32 dlm_key;
  532. char *domain;
  533. domain = kmalloc(name->len + 1, GFP_KERNEL);
  534. if (!domain) {
  535. mlog_errno(-ENOMEM);
  536. return ERR_PTR(-ENOMEM);
  537. }
  538. dlm_key = crc32_le(0, name->name, name->len);
  539. snprintf(domain, name->len + 1, "%.*s", name->len, name->name);
  540. dlm = dlm_register_domain(domain, dlm_key);
  541. if (IS_ERR(dlm))
  542. mlog_errno(PTR_ERR(dlm));
  543. kfree(domain);
  544. return dlm;
  545. }
  546. void user_dlm_unregister_context(struct dlm_ctxt *dlm)
  547. {
  548. dlm_unregister_domain(dlm);
  549. }