dlmfs.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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. static 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_i_callback(struct rcu_head *head)
  290. {
  291. struct inode *inode = container_of(head, struct inode, i_rcu);
  292. INIT_LIST_HEAD(&inode->i_dentry);
  293. kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode));
  294. }
  295. static void dlmfs_destroy_inode(struct inode *inode)
  296. {
  297. call_rcu(&inode->i_rcu, dlmfs_i_callback);
  298. }
  299. static void dlmfs_evict_inode(struct inode *inode)
  300. {
  301. int status;
  302. struct dlmfs_inode_private *ip;
  303. end_writeback(inode);
  304. mlog(0, "inode %lu\n", inode->i_ino);
  305. ip = DLMFS_I(inode);
  306. if (S_ISREG(inode->i_mode)) {
  307. status = user_dlm_destroy_lock(&ip->ip_lockres);
  308. if (status < 0)
  309. mlog_errno(status);
  310. iput(ip->ip_parent);
  311. goto clear_fields;
  312. }
  313. mlog(0, "we're a directory, ip->ip_conn = 0x%p\n", ip->ip_conn);
  314. /* we must be a directory. If required, lets unregister the
  315. * dlm context now. */
  316. if (ip->ip_conn)
  317. user_dlm_unregister(ip->ip_conn);
  318. clear_fields:
  319. ip->ip_parent = NULL;
  320. ip->ip_conn = NULL;
  321. }
  322. static struct backing_dev_info dlmfs_backing_dev_info = {
  323. .name = "ocfs2-dlmfs",
  324. .ra_pages = 0, /* No readahead */
  325. .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
  326. };
  327. static struct inode *dlmfs_get_root_inode(struct super_block *sb)
  328. {
  329. struct inode *inode = new_inode(sb);
  330. int mode = S_IFDIR | 0755;
  331. struct dlmfs_inode_private *ip;
  332. if (inode) {
  333. ip = DLMFS_I(inode);
  334. inode->i_ino = get_next_ino();
  335. inode->i_mode = mode;
  336. inode->i_uid = current_fsuid();
  337. inode->i_gid = current_fsgid();
  338. inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
  339. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  340. inc_nlink(inode);
  341. inode->i_fop = &simple_dir_operations;
  342. inode->i_op = &dlmfs_root_inode_operations;
  343. }
  344. return inode;
  345. }
  346. static struct inode *dlmfs_get_inode(struct inode *parent,
  347. struct dentry *dentry,
  348. int mode)
  349. {
  350. struct super_block *sb = parent->i_sb;
  351. struct inode * inode = new_inode(sb);
  352. struct dlmfs_inode_private *ip;
  353. if (!inode)
  354. return NULL;
  355. inode->i_ino = get_next_ino();
  356. inode->i_mode = mode;
  357. inode->i_uid = current_fsuid();
  358. inode->i_gid = current_fsgid();
  359. inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
  360. inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  361. ip = DLMFS_I(inode);
  362. ip->ip_conn = DLMFS_I(parent)->ip_conn;
  363. switch (mode & S_IFMT) {
  364. default:
  365. /* for now we don't support anything other than
  366. * directories and regular files. */
  367. BUG();
  368. break;
  369. case S_IFREG:
  370. inode->i_op = &dlmfs_file_inode_operations;
  371. inode->i_fop = &dlmfs_file_operations;
  372. i_size_write(inode, DLM_LVB_LEN);
  373. user_dlm_lock_res_init(&ip->ip_lockres, dentry);
  374. /* released at clear_inode time, this insures that we
  375. * get to drop the dlm reference on each lock *before*
  376. * we call the unregister code for releasing parent
  377. * directories. */
  378. ip->ip_parent = igrab(parent);
  379. BUG_ON(!ip->ip_parent);
  380. break;
  381. case S_IFDIR:
  382. inode->i_op = &dlmfs_dir_inode_operations;
  383. inode->i_fop = &simple_dir_operations;
  384. /* directory inodes start off with i_nlink ==
  385. * 2 (for "." entry) */
  386. inc_nlink(inode);
  387. break;
  388. }
  389. if (parent->i_mode & S_ISGID) {
  390. inode->i_gid = parent->i_gid;
  391. if (S_ISDIR(mode))
  392. inode->i_mode |= S_ISGID;
  393. }
  394. return inode;
  395. }
  396. /*
  397. * File creation. Allocate an inode, and we're done..
  398. */
  399. /* SMP-safe */
  400. static int dlmfs_mkdir(struct inode * dir,
  401. struct dentry * dentry,
  402. int mode)
  403. {
  404. int status;
  405. struct inode *inode = NULL;
  406. struct qstr *domain = &dentry->d_name;
  407. struct dlmfs_inode_private *ip;
  408. struct ocfs2_cluster_connection *conn;
  409. mlog(0, "mkdir %.*s\n", domain->len, domain->name);
  410. /* verify that we have a proper domain */
  411. if (domain->len >= GROUP_NAME_MAX) {
  412. status = -EINVAL;
  413. mlog(ML_ERROR, "invalid domain name for directory.\n");
  414. goto bail;
  415. }
  416. inode = dlmfs_get_inode(dir, dentry, mode | S_IFDIR);
  417. if (!inode) {
  418. status = -ENOMEM;
  419. mlog_errno(status);
  420. goto bail;
  421. }
  422. ip = DLMFS_I(inode);
  423. conn = user_dlm_register(domain);
  424. if (IS_ERR(conn)) {
  425. status = PTR_ERR(conn);
  426. mlog(ML_ERROR, "Error %d could not register domain \"%.*s\"\n",
  427. status, domain->len, domain->name);
  428. goto bail;
  429. }
  430. ip->ip_conn = conn;
  431. inc_nlink(dir);
  432. d_instantiate(dentry, inode);
  433. dget(dentry); /* Extra count - pin the dentry in core */
  434. status = 0;
  435. bail:
  436. if (status < 0)
  437. iput(inode);
  438. return status;
  439. }
  440. static int dlmfs_create(struct inode *dir,
  441. struct dentry *dentry,
  442. int mode,
  443. struct nameidata *nd)
  444. {
  445. int status = 0;
  446. struct inode *inode;
  447. struct qstr *name = &dentry->d_name;
  448. mlog(0, "create %.*s\n", name->len, name->name);
  449. /* verify name is valid and doesn't contain any dlm reserved
  450. * characters */
  451. if (name->len >= USER_DLM_LOCK_ID_MAX_LEN ||
  452. name->name[0] == '$') {
  453. status = -EINVAL;
  454. mlog(ML_ERROR, "invalid lock name, %.*s\n", name->len,
  455. name->name);
  456. goto bail;
  457. }
  458. inode = dlmfs_get_inode(dir, dentry, mode | S_IFREG);
  459. if (!inode) {
  460. status = -ENOMEM;
  461. mlog_errno(status);
  462. goto bail;
  463. }
  464. d_instantiate(dentry, inode);
  465. dget(dentry); /* Extra count - pin the dentry in core */
  466. bail:
  467. return status;
  468. }
  469. static int dlmfs_unlink(struct inode *dir,
  470. struct dentry *dentry)
  471. {
  472. int status;
  473. struct inode *inode = dentry->d_inode;
  474. mlog(0, "unlink inode %lu\n", inode->i_ino);
  475. /* if there are no current holders, or none that are waiting
  476. * to acquire a lock, this basically destroys our lockres. */
  477. status = user_dlm_destroy_lock(&DLMFS_I(inode)->ip_lockres);
  478. if (status < 0) {
  479. mlog(ML_ERROR, "unlink %.*s, error %d from destroy\n",
  480. dentry->d_name.len, dentry->d_name.name, status);
  481. goto bail;
  482. }
  483. status = simple_unlink(dir, dentry);
  484. bail:
  485. return status;
  486. }
  487. static int dlmfs_fill_super(struct super_block * sb,
  488. void * data,
  489. int silent)
  490. {
  491. struct inode * inode;
  492. struct dentry * root;
  493. sb->s_maxbytes = MAX_LFS_FILESIZE;
  494. sb->s_blocksize = PAGE_CACHE_SIZE;
  495. sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
  496. sb->s_magic = DLMFS_MAGIC;
  497. sb->s_op = &dlmfs_ops;
  498. inode = dlmfs_get_root_inode(sb);
  499. if (!inode)
  500. return -ENOMEM;
  501. root = d_alloc_root(inode);
  502. if (!root) {
  503. iput(inode);
  504. return -ENOMEM;
  505. }
  506. sb->s_root = root;
  507. return 0;
  508. }
  509. static const struct file_operations dlmfs_file_operations = {
  510. .open = dlmfs_file_open,
  511. .release = dlmfs_file_release,
  512. .poll = dlmfs_file_poll,
  513. .read = dlmfs_file_read,
  514. .write = dlmfs_file_write,
  515. .llseek = default_llseek,
  516. };
  517. static const struct inode_operations dlmfs_dir_inode_operations = {
  518. .create = dlmfs_create,
  519. .lookup = simple_lookup,
  520. .unlink = dlmfs_unlink,
  521. };
  522. /* this way we can restrict mkdir to only the toplevel of the fs. */
  523. static const struct inode_operations dlmfs_root_inode_operations = {
  524. .lookup = simple_lookup,
  525. .mkdir = dlmfs_mkdir,
  526. .rmdir = simple_rmdir,
  527. };
  528. static const struct super_operations dlmfs_ops = {
  529. .statfs = simple_statfs,
  530. .alloc_inode = dlmfs_alloc_inode,
  531. .destroy_inode = dlmfs_destroy_inode,
  532. .evict_inode = dlmfs_evict_inode,
  533. .drop_inode = generic_delete_inode,
  534. };
  535. static const struct inode_operations dlmfs_file_inode_operations = {
  536. .getattr = simple_getattr,
  537. .setattr = dlmfs_file_setattr,
  538. };
  539. static struct dentry *dlmfs_mount(struct file_system_type *fs_type,
  540. int flags, const char *dev_name, void *data)
  541. {
  542. return mount_nodev(fs_type, flags, data, dlmfs_fill_super);
  543. }
  544. static struct file_system_type dlmfs_fs_type = {
  545. .owner = THIS_MODULE,
  546. .name = "ocfs2_dlmfs",
  547. .mount = dlmfs_mount,
  548. .kill_sb = kill_litter_super,
  549. };
  550. static int __init init_dlmfs_fs(void)
  551. {
  552. int status;
  553. int cleanup_inode = 0, cleanup_worker = 0;
  554. dlmfs_print_version();
  555. status = bdi_init(&dlmfs_backing_dev_info);
  556. if (status)
  557. return status;
  558. dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache",
  559. sizeof(struct dlmfs_inode_private),
  560. 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
  561. SLAB_MEM_SPREAD),
  562. dlmfs_init_once);
  563. if (!dlmfs_inode_cache) {
  564. status = -ENOMEM;
  565. goto bail;
  566. }
  567. cleanup_inode = 1;
  568. user_dlm_worker = create_singlethread_workqueue("user_dlm");
  569. if (!user_dlm_worker) {
  570. status = -ENOMEM;
  571. goto bail;
  572. }
  573. cleanup_worker = 1;
  574. user_dlm_set_locking_protocol();
  575. status = register_filesystem(&dlmfs_fs_type);
  576. bail:
  577. if (status) {
  578. if (cleanup_inode)
  579. kmem_cache_destroy(dlmfs_inode_cache);
  580. if (cleanup_worker)
  581. destroy_workqueue(user_dlm_worker);
  582. bdi_destroy(&dlmfs_backing_dev_info);
  583. } else
  584. printk("OCFS2 User DLM kernel interface loaded\n");
  585. return status;
  586. }
  587. static void __exit exit_dlmfs_fs(void)
  588. {
  589. unregister_filesystem(&dlmfs_fs_type);
  590. flush_workqueue(user_dlm_worker);
  591. destroy_workqueue(user_dlm_worker);
  592. kmem_cache_destroy(dlmfs_inode_cache);
  593. bdi_destroy(&dlmfs_backing_dev_info);
  594. }
  595. MODULE_AUTHOR("Oracle");
  596. MODULE_LICENSE("GPL");
  597. module_init(init_dlmfs_fs)
  598. module_exit(exit_dlmfs_fs)