dlmfs.c 17 KB

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