dlmfs.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. /* -*- mode: c; c-basic-offset: 8; -*-
  2. * vim: noexpandtab sw=8 ts=8 sts=0:
  3. *
  4. * dlmfs.c
  5. *
  6. * Code which implements the kernel side of a minimal userspace
  7. * interface to our DLM. This file handles the virtual file system
  8. * used for communication with userspace. Credit should go to ramfs,
  9. * which was a template for the fs side of this module.
  10. *
  11. * Copyright (C) 2003, 2004 Oracle. All rights reserved.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public
  15. * License as published by the Free Software Foundation; either
  16. * version 2 of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. * General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public
  24. * License along with this program; if not, write to the
  25. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  26. * Boston, MA 021110-1307, USA.
  27. */
  28. /* Simple VFS hooks based on: */
  29. /*
  30. * Resizable simple ram filesystem for Linux.
  31. *
  32. * Copyright (C) 2000 Linus Torvalds.
  33. * 2000 Transmeta Corp.
  34. */
  35. #include <linux/module.h>
  36. #include <linux/fs.h>
  37. #include <linux/pagemap.h>
  38. #include <linux/types.h>
  39. #include <linux/slab.h>
  40. #include <linux/highmem.h>
  41. #include <linux/init.h>
  42. #include <linux/string.h>
  43. #include <linux/backing-dev.h>
  44. #include <linux/poll.h>
  45. #include <asm/uaccess.h>
  46. #include "stackglue.h"
  47. #include "userdlm.h"
  48. #include "dlmfsver.h"
  49. #define MLOG_MASK_PREFIX ML_DLMFS
  50. #include "cluster/masklog.h"
  51. static const struct super_operations dlmfs_ops;
  52. static const struct file_operations dlmfs_file_operations;
  53. static const struct inode_operations dlmfs_dir_inode_operations;
  54. static const struct inode_operations dlmfs_root_inode_operations;
  55. static const struct inode_operations dlmfs_file_inode_operations;
  56. static struct kmem_cache *dlmfs_inode_cache;
  57. struct workqueue_struct *user_dlm_worker;
  58. /*
  59. * These are the ABI capabilities of dlmfs.
  60. *
  61. * Over time, dlmfs has added some features that were not part of the
  62. * initial ABI. Unfortunately, some of these features are not detectable
  63. * via standard usage. For example, Linux's default poll always returns
  64. * POLLIN, so there is no way for a caller of poll(2) to know when dlmfs
  65. * added poll support. Instead, we provide this list of new capabilities.
  66. *
  67. * Capabilities is a read-only attribute. We do it as a module parameter
  68. * so we can discover it whether dlmfs is built in, loaded, or even not
  69. * loaded.
  70. *
  71. * The ABI features are local to this machine's dlmfs mount. This is
  72. * distinct from the locking protocol, which is concerned with inter-node
  73. * interaction.
  74. *
  75. * Capabilities:
  76. * - bast : POLLIN against the file descriptor of a held lock
  77. * signifies a bast fired on the lock.
  78. */
  79. #define DLMFS_CAPABILITIES "bast stackglue"
  80. extern int param_set_dlmfs_capabilities(const char *val,
  81. struct kernel_param *kp)
  82. {
  83. printk(KERN_ERR "%s: readonly parameter\n", kp->name);
  84. return -EINVAL;
  85. }
  86. static int param_get_dlmfs_capabilities(char *buffer,
  87. struct kernel_param *kp)
  88. {
  89. return strlcpy(buffer, DLMFS_CAPABILITIES,
  90. strlen(DLMFS_CAPABILITIES) + 1);
  91. }
  92. module_param_call(capabilities, param_set_dlmfs_capabilities,
  93. param_get_dlmfs_capabilities, NULL, 0444);
  94. MODULE_PARM_DESC(capabilities, DLMFS_CAPABILITIES);
  95. /*
  96. * decodes a set of open flags into a valid lock level and a set of flags.
  97. * returns < 0 if we have invalid flags
  98. * flags which mean something to us:
  99. * O_RDONLY -> PRMODE level
  100. * O_WRONLY -> EXMODE level
  101. *
  102. * O_NONBLOCK -> NOQUEUE
  103. */
  104. static int dlmfs_decode_open_flags(int open_flags,
  105. int *level,
  106. int *flags)
  107. {
  108. if (open_flags & (O_WRONLY|O_RDWR))
  109. *level = DLM_LOCK_EX;
  110. else
  111. *level = DLM_LOCK_PR;
  112. *flags = 0;
  113. if (open_flags & O_NONBLOCK)
  114. *flags |= DLM_LKF_NOQUEUE;
  115. return 0;
  116. }
  117. static int dlmfs_file_open(struct inode *inode,
  118. struct file *file)
  119. {
  120. int status, level, flags;
  121. struct dlmfs_filp_private *fp = NULL;
  122. struct dlmfs_inode_private *ip;
  123. if (S_ISDIR(inode->i_mode))
  124. BUG();
  125. mlog(0, "open called on inode %lu, flags 0x%x\n", inode->i_ino,
  126. file->f_flags);
  127. status = dlmfs_decode_open_flags(file->f_flags, &level, &flags);
  128. if (status < 0)
  129. goto bail;
  130. /* We don't want to honor O_APPEND at read/write time as it
  131. * doesn't make sense for LVB writes. */
  132. file->f_flags &= ~O_APPEND;
  133. fp = kmalloc(sizeof(*fp), GFP_NOFS);
  134. if (!fp) {
  135. status = -ENOMEM;
  136. goto bail;
  137. }
  138. fp->fp_lock_level = level;
  139. ip = DLMFS_I(inode);
  140. status = user_dlm_cluster_lock(&ip->ip_lockres, level, flags);
  141. if (status < 0) {
  142. /* this is a strange error to return here but I want
  143. * to be able userspace to be able to distinguish a
  144. * valid lock request from one that simply couldn't be
  145. * granted. */
  146. if (flags & DLM_LKF_NOQUEUE && status == -EAGAIN)
  147. status = -ETXTBSY;
  148. kfree(fp);
  149. goto bail;
  150. }
  151. file->private_data = fp;
  152. bail:
  153. return status;
  154. }
  155. static int dlmfs_file_release(struct inode *inode,
  156. struct file *file)
  157. {
  158. int level, status;
  159. struct dlmfs_inode_private *ip = DLMFS_I(inode);
  160. struct dlmfs_filp_private *fp = file->private_data;
  161. if (S_ISDIR(inode->i_mode))
  162. BUG();
  163. mlog(0, "close called on inode %lu\n", inode->i_ino);
  164. status = 0;
  165. if (fp) {
  166. level = fp->fp_lock_level;
  167. if (level != DLM_LOCK_IV)
  168. user_dlm_cluster_unlock(&ip->ip_lockres, level);
  169. kfree(fp);
  170. file->private_data = NULL;
  171. }
  172. return 0;
  173. }
  174. /*
  175. * We do ->setattr() just to override size changes. Our size is the size
  176. * of the LVB and nothing else.
  177. */
  178. static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr)
  179. {
  180. int error;
  181. struct inode *inode = dentry->d_inode;
  182. attr->ia_valid &= ~ATTR_SIZE;
  183. error = inode_change_ok(inode, attr);
  184. if (error)
  185. return error;
  186. setattr_copy(inode, attr);
  187. mark_inode_dirty(inode);
  188. return 0;
  189. }
  190. static unsigned int dlmfs_file_poll(struct file *file, poll_table *wait)
  191. {
  192. int event = 0;
  193. struct inode *inode = file->f_path.dentry->d_inode;
  194. struct dlmfs_inode_private *ip = DLMFS_I(inode);
  195. poll_wait(file, &ip->ip_lockres.l_event, wait);
  196. spin_lock(&ip->ip_lockres.l_lock);
  197. if (ip->ip_lockres.l_flags & USER_LOCK_BLOCKED)
  198. event = POLLIN | POLLRDNORM;
  199. spin_unlock(&ip->ip_lockres.l_lock);
  200. return event;
  201. }
  202. static ssize_t dlmfs_file_read(struct file *filp,
  203. char __user *buf,
  204. size_t count,
  205. loff_t *ppos)
  206. {
  207. int bytes_left;
  208. ssize_t readlen, got;
  209. char *lvb_buf;
  210. struct inode *inode = filp->f_path.dentry->d_inode;
  211. mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
  212. inode->i_ino, count, *ppos);
  213. if (*ppos >= i_size_read(inode))
  214. return 0;
  215. if (!count)
  216. return 0;
  217. if (!access_ok(VERIFY_WRITE, buf, count))
  218. return -EFAULT;
  219. /* don't read past the lvb */
  220. if ((count + *ppos) > i_size_read(inode))
  221. readlen = i_size_read(inode) - *ppos;
  222. else
  223. readlen = count;
  224. lvb_buf = kmalloc(readlen, GFP_NOFS);
  225. if (!lvb_buf)
  226. return -ENOMEM;
  227. got = user_dlm_read_lvb(inode, lvb_buf, readlen);
  228. if (got) {
  229. BUG_ON(got != readlen);
  230. bytes_left = __copy_to_user(buf, lvb_buf, readlen);
  231. readlen -= bytes_left;
  232. } else
  233. readlen = 0;
  234. kfree(lvb_buf);
  235. *ppos = *ppos + readlen;
  236. mlog(0, "read %zd bytes\n", readlen);
  237. return readlen;
  238. }
  239. static ssize_t dlmfs_file_write(struct file *filp,
  240. const char __user *buf,
  241. size_t count,
  242. loff_t *ppos)
  243. {
  244. int bytes_left;
  245. ssize_t writelen;
  246. char *lvb_buf;
  247. struct inode *inode = filp->f_path.dentry->d_inode;
  248. mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
  249. inode->i_ino, count, *ppos);
  250. if (*ppos >= i_size_read(inode))
  251. return -ENOSPC;
  252. if (!count)
  253. return 0;
  254. if (!access_ok(VERIFY_READ, buf, count))
  255. return -EFAULT;
  256. /* don't write past the lvb */
  257. if ((count + *ppos) > i_size_read(inode))
  258. writelen = i_size_read(inode) - *ppos;
  259. else
  260. writelen = count - *ppos;
  261. lvb_buf = kmalloc(writelen, GFP_NOFS);
  262. if (!lvb_buf)
  263. return -ENOMEM;
  264. bytes_left = copy_from_user(lvb_buf, buf, writelen);
  265. writelen -= bytes_left;
  266. if (writelen)
  267. user_dlm_write_lvb(inode, lvb_buf, writelen);
  268. kfree(lvb_buf);
  269. *ppos = *ppos + writelen;
  270. mlog(0, "wrote %zd bytes\n", writelen);
  271. return writelen;
  272. }
  273. static void dlmfs_init_once(void *foo)
  274. {
  275. struct dlmfs_inode_private *ip =
  276. (struct dlmfs_inode_private *) foo;
  277. ip->ip_conn = NULL;
  278. ip->ip_parent = NULL;
  279. inode_init_once(&ip->ip_vfs_inode);
  280. }
  281. static struct inode *dlmfs_alloc_inode(struct super_block *sb)
  282. {
  283. struct dlmfs_inode_private *ip;
  284. ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_NOFS);
  285. if (!ip)
  286. return NULL;
  287. return &ip->ip_vfs_inode;
  288. }
  289. static void dlmfs_destroy_inode(struct inode *inode)
  290. {
  291. kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode));
  292. }
  293. static void dlmfs_evict_inode(struct inode *inode)
  294. {
  295. int status;
  296. struct dlmfs_inode_private *ip;
  297. end_writeback(inode);
  298. mlog(0, "inode %lu\n", inode->i_ino);
  299. ip = DLMFS_I(inode);
  300. if (S_ISREG(inode->i_mode)) {
  301. status = user_dlm_destroy_lock(&ip->ip_lockres);
  302. if (status < 0)
  303. mlog_errno(status);
  304. iput(ip->ip_parent);
  305. goto clear_fields;
  306. }
  307. mlog(0, "we're a directory, ip->ip_conn = 0x%p\n", ip->ip_conn);
  308. /* we must be a directory. If required, lets unregister the
  309. * dlm context now. */
  310. if (ip->ip_conn)
  311. user_dlm_unregister(ip->ip_conn);
  312. clear_fields:
  313. ip->ip_parent = NULL;
  314. ip->ip_conn = NULL;
  315. }
  316. static struct backing_dev_info dlmfs_backing_dev_info = {
  317. .name = "ocfs2-dlmfs",
  318. .ra_pages = 0, /* No readahead */
  319. .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
  320. };
  321. static struct inode *dlmfs_get_root_inode(struct super_block *sb)
  322. {
  323. struct inode *inode = new_inode(sb);
  324. int mode = S_IFDIR | 0755;
  325. struct dlmfs_inode_private *ip;
  326. if (inode) {
  327. ip = DLMFS_I(inode);
  328. inode->i_mode = mode;
  329. inode->i_uid = current_fsuid();
  330. inode->i_gid = current_fsgid();
  331. inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
  332. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  333. inc_nlink(inode);
  334. inode->i_fop = &simple_dir_operations;
  335. inode->i_op = &dlmfs_root_inode_operations;
  336. }
  337. return inode;
  338. }
  339. static struct inode *dlmfs_get_inode(struct inode *parent,
  340. struct dentry *dentry,
  341. int mode)
  342. {
  343. struct super_block *sb = parent->i_sb;
  344. struct inode * inode = new_inode(sb);
  345. struct dlmfs_inode_private *ip;
  346. if (!inode)
  347. return NULL;
  348. inode->i_mode = mode;
  349. inode->i_uid = current_fsuid();
  350. inode->i_gid = current_fsgid();
  351. inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
  352. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  353. ip = DLMFS_I(inode);
  354. ip->ip_conn = DLMFS_I(parent)->ip_conn;
  355. switch (mode & S_IFMT) {
  356. default:
  357. /* for now we don't support anything other than
  358. * directories and regular files. */
  359. BUG();
  360. break;
  361. case S_IFREG:
  362. inode->i_op = &dlmfs_file_inode_operations;
  363. inode->i_fop = &dlmfs_file_operations;
  364. i_size_write(inode, DLM_LVB_LEN);
  365. user_dlm_lock_res_init(&ip->ip_lockres, dentry);
  366. /* released at clear_inode time, this insures that we
  367. * get to drop the dlm reference on each lock *before*
  368. * we call the unregister code for releasing parent
  369. * directories. */
  370. ip->ip_parent = igrab(parent);
  371. BUG_ON(!ip->ip_parent);
  372. break;
  373. case S_IFDIR:
  374. inode->i_op = &dlmfs_dir_inode_operations;
  375. inode->i_fop = &simple_dir_operations;
  376. /* directory inodes start off with i_nlink ==
  377. * 2 (for "." entry) */
  378. inc_nlink(inode);
  379. break;
  380. }
  381. if (parent->i_mode & S_ISGID) {
  382. inode->i_gid = parent->i_gid;
  383. if (S_ISDIR(mode))
  384. inode->i_mode |= S_ISGID;
  385. }
  386. return inode;
  387. }
  388. /*
  389. * File creation. Allocate an inode, and we're done..
  390. */
  391. /* SMP-safe */
  392. static int dlmfs_mkdir(struct inode * dir,
  393. struct dentry * dentry,
  394. int mode)
  395. {
  396. int status;
  397. struct inode *inode = NULL;
  398. struct qstr *domain = &dentry->d_name;
  399. struct dlmfs_inode_private *ip;
  400. struct ocfs2_cluster_connection *conn;
  401. mlog(0, "mkdir %.*s\n", domain->len, domain->name);
  402. /* verify that we have a proper domain */
  403. if (domain->len >= GROUP_NAME_MAX) {
  404. status = -EINVAL;
  405. mlog(ML_ERROR, "invalid domain name for directory.\n");
  406. goto bail;
  407. }
  408. inode = dlmfs_get_inode(dir, dentry, mode | S_IFDIR);
  409. if (!inode) {
  410. status = -ENOMEM;
  411. mlog_errno(status);
  412. goto bail;
  413. }
  414. ip = DLMFS_I(inode);
  415. conn = user_dlm_register(domain);
  416. if (IS_ERR(conn)) {
  417. status = PTR_ERR(conn);
  418. mlog(ML_ERROR, "Error %d could not register domain \"%.*s\"\n",
  419. status, domain->len, domain->name);
  420. goto bail;
  421. }
  422. ip->ip_conn = conn;
  423. inc_nlink(dir);
  424. d_instantiate(dentry, inode);
  425. dget(dentry); /* Extra count - pin the dentry in core */
  426. status = 0;
  427. bail:
  428. if (status < 0)
  429. iput(inode);
  430. return status;
  431. }
  432. static int dlmfs_create(struct inode *dir,
  433. struct dentry *dentry,
  434. int mode,
  435. struct nameidata *nd)
  436. {
  437. int status = 0;
  438. struct inode *inode;
  439. struct qstr *name = &dentry->d_name;
  440. mlog(0, "create %.*s\n", name->len, name->name);
  441. /* verify name is valid and doesn't contain any dlm reserved
  442. * characters */
  443. if (name->len >= USER_DLM_LOCK_ID_MAX_LEN ||
  444. name->name[0] == '$') {
  445. status = -EINVAL;
  446. mlog(ML_ERROR, "invalid lock name, %.*s\n", name->len,
  447. name->name);
  448. goto bail;
  449. }
  450. inode = dlmfs_get_inode(dir, dentry, mode | S_IFREG);
  451. if (!inode) {
  452. status = -ENOMEM;
  453. mlog_errno(status);
  454. goto bail;
  455. }
  456. d_instantiate(dentry, inode);
  457. dget(dentry); /* Extra count - pin the dentry in core */
  458. bail:
  459. return status;
  460. }
  461. static int dlmfs_unlink(struct inode *dir,
  462. struct dentry *dentry)
  463. {
  464. int status;
  465. struct inode *inode = dentry->d_inode;
  466. mlog(0, "unlink inode %lu\n", inode->i_ino);
  467. /* if there are no current holders, or none that are waiting
  468. * to acquire a lock, this basically destroys our lockres. */
  469. status = user_dlm_destroy_lock(&DLMFS_I(inode)->ip_lockres);
  470. if (status < 0) {
  471. mlog(ML_ERROR, "unlink %.*s, error %d from destroy\n",
  472. dentry->d_name.len, dentry->d_name.name, status);
  473. goto bail;
  474. }
  475. status = simple_unlink(dir, dentry);
  476. bail:
  477. return status;
  478. }
  479. static int dlmfs_fill_super(struct super_block * sb,
  480. void * data,
  481. int silent)
  482. {
  483. struct inode * inode;
  484. struct dentry * root;
  485. sb->s_maxbytes = MAX_LFS_FILESIZE;
  486. sb->s_blocksize = PAGE_CACHE_SIZE;
  487. sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
  488. sb->s_magic = DLMFS_MAGIC;
  489. sb->s_op = &dlmfs_ops;
  490. inode = dlmfs_get_root_inode(sb);
  491. if (!inode)
  492. return -ENOMEM;
  493. root = d_alloc_root(inode);
  494. if (!root) {
  495. iput(inode);
  496. return -ENOMEM;
  497. }
  498. sb->s_root = root;
  499. return 0;
  500. }
  501. static const struct file_operations dlmfs_file_operations = {
  502. .open = dlmfs_file_open,
  503. .release = dlmfs_file_release,
  504. .poll = dlmfs_file_poll,
  505. .read = dlmfs_file_read,
  506. .write = dlmfs_file_write,
  507. };
  508. static const struct inode_operations dlmfs_dir_inode_operations = {
  509. .create = dlmfs_create,
  510. .lookup = simple_lookup,
  511. .unlink = dlmfs_unlink,
  512. };
  513. /* this way we can restrict mkdir to only the toplevel of the fs. */
  514. static const struct inode_operations dlmfs_root_inode_operations = {
  515. .lookup = simple_lookup,
  516. .mkdir = dlmfs_mkdir,
  517. .rmdir = simple_rmdir,
  518. };
  519. static const struct super_operations dlmfs_ops = {
  520. .statfs = simple_statfs,
  521. .alloc_inode = dlmfs_alloc_inode,
  522. .destroy_inode = dlmfs_destroy_inode,
  523. .evict_inode = dlmfs_evict_inode,
  524. .drop_inode = generic_delete_inode,
  525. };
  526. static const struct inode_operations dlmfs_file_inode_operations = {
  527. .getattr = simple_getattr,
  528. .setattr = dlmfs_file_setattr,
  529. };
  530. static int dlmfs_get_sb(struct file_system_type *fs_type,
  531. int flags, const char *dev_name, void *data, struct vfsmount *mnt)
  532. {
  533. return get_sb_nodev(fs_type, flags, data, dlmfs_fill_super, mnt);
  534. }
  535. static struct file_system_type dlmfs_fs_type = {
  536. .owner = THIS_MODULE,
  537. .name = "ocfs2_dlmfs",
  538. .get_sb = dlmfs_get_sb,
  539. .kill_sb = kill_litter_super,
  540. };
  541. static int __init init_dlmfs_fs(void)
  542. {
  543. int status;
  544. int cleanup_inode = 0, cleanup_worker = 0;
  545. dlmfs_print_version();
  546. status = bdi_init(&dlmfs_backing_dev_info);
  547. if (status)
  548. return status;
  549. dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache",
  550. sizeof(struct dlmfs_inode_private),
  551. 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
  552. SLAB_MEM_SPREAD),
  553. dlmfs_init_once);
  554. if (!dlmfs_inode_cache) {
  555. status = -ENOMEM;
  556. goto bail;
  557. }
  558. cleanup_inode = 1;
  559. user_dlm_worker = create_singlethread_workqueue("user_dlm");
  560. if (!user_dlm_worker) {
  561. status = -ENOMEM;
  562. goto bail;
  563. }
  564. cleanup_worker = 1;
  565. user_dlm_set_locking_protocol();
  566. status = register_filesystem(&dlmfs_fs_type);
  567. bail:
  568. if (status) {
  569. if (cleanup_inode)
  570. kmem_cache_destroy(dlmfs_inode_cache);
  571. if (cleanup_worker)
  572. destroy_workqueue(user_dlm_worker);
  573. bdi_destroy(&dlmfs_backing_dev_info);
  574. } else
  575. printk("OCFS2 User DLM kernel interface loaded\n");
  576. return status;
  577. }
  578. static void __exit exit_dlmfs_fs(void)
  579. {
  580. unregister_filesystem(&dlmfs_fs_type);
  581. flush_workqueue(user_dlm_worker);
  582. destroy_workqueue(user_dlm_worker);
  583. kmem_cache_destroy(dlmfs_inode_cache);
  584. bdi_destroy(&dlmfs_backing_dev_info);
  585. }
  586. MODULE_AUTHOR("Oracle");
  587. MODULE_LICENSE("GPL");
  588. module_init(init_dlmfs_fs)
  589. module_exit(exit_dlmfs_fs)