37 #include <linux/module.h>
40 #include <linux/types.h>
41 #include <linux/slab.h>
44 #include <linux/string.h>
46 #include <linux/poll.h>
48 #include <asm/uaccess.h>
54 #define MLOG_MASK_PREFIX ML_DLMFS
90 #define DLMFS_CAPABILITIES "bast stackglue"
91 static int param_set_dlmfs_capabilities(
const char *
val,
97 static int param_get_dlmfs_capabilities(
char *
buffer,
104 param_get_dlmfs_capabilities,
NULL, 0444);
117 static int dlmfs_decode_open_flags(
int open_flags,
133 static int dlmfs_file_open(
struct inode *
inode,
143 mlog(0,
"open called on inode %lu, flags 0x%x\n", inode->
i_ino,
146 status = dlmfs_decode_open_flags(file->
f_flags, &level, &flags);
180 static int dlmfs_file_release(
struct inode *inode,
190 mlog(0,
"close called on inode %lu\n", inode->
i_ino);
212 struct inode *inode = dentry->
d_inode;
220 mark_inode_dirty(inode);
224 static unsigned int dlmfs_file_poll(
struct file *file,
poll_table *
wait)
227 struct inode *inode = file->
f_path.dentry->d_inode;
230 poll_wait(file, &ip->
ip_lockres.l_event, wait);
240 static ssize_t dlmfs_file_read(
struct file *filp,
248 struct inode *inode = filp->
f_path.dentry->d_inode;
250 mlog(0,
"inode %lu, count = %zu, *ppos = %llu\n",
251 inode->
i_ino, count, *ppos);
253 if (*ppos >= i_size_read(inode))
263 if ((count + *ppos) > i_size_read(inode))
264 readlen = i_size_read(inode) - *ppos;
276 readlen -= bytes_left;
282 *ppos = *ppos + readlen;
284 mlog(0,
"read %zd bytes\n", readlen);
288 static ssize_t dlmfs_file_write(
struct file *filp,
289 const char __user *buf,
296 struct inode *inode = filp->
f_path.dentry->d_inode;
298 mlog(0,
"inode %lu, count = %zu, *ppos = %llu\n",
299 inode->
i_ino, count, *ppos);
301 if (*ppos >= i_size_read(inode))
311 if ((count + *ppos) > i_size_read(inode))
312 writelen = i_size_read(inode) - *ppos;
314 writelen = count - *ppos;
321 writelen -= bytes_left;
327 *ppos = *ppos + writelen;
328 mlog(0,
"wrote %zd bytes\n", writelen);
332 static void dlmfs_init_once(
void *
foo)
343 static struct inode *dlmfs_alloc_inode(
struct super_block *
sb)
360 static void dlmfs_destroy_inode(
struct inode *inode)
365 static void dlmfs_evict_inode(
struct inode *inode)
384 mlog(0,
"we're a directory, ip->ip_conn = 0x%p\n", ip->
ip_conn);
395 .name =
"ocfs2-dlmfs",
400 static struct inode *dlmfs_get_root_inode(
struct super_block *sb)
411 inode->
i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
416 inode->
i_op = &dlmfs_root_inode_operations;
422 static struct inode *dlmfs_get_inode(
struct inode *parent,
423 struct dentry *dentry,
435 inode->
i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
439 ip->
ip_conn = DLMFS_I(parent)->ip_conn;
448 inode->
i_op = &dlmfs_file_inode_operations;
449 inode->
i_fop = &dlmfs_file_operations;
463 inode->
i_op = &dlmfs_dir_inode_operations;
478 static int dlmfs_mkdir(
struct inode * dir,
479 struct dentry * dentry,
483 struct inode *inode =
NULL;
488 mlog(0,
"mkdir %.*s\n", domain->len, domain->
name);
497 inode = dlmfs_get_inode(dir, dentry, mode |
S_IFDIR);
508 status = PTR_ERR(conn);
509 mlog(
ML_ERROR,
"Error %d could not register domain \"%.*s\"\n",
510 status, domain->len, domain->
name);
526 static int dlmfs_create(
struct inode *dir,
527 struct dentry *dentry,
535 mlog(0,
"create %.*s\n", name->len, name->
name);
540 name->
name[0] ==
'$') {
547 inode = dlmfs_get_inode(dir, dentry, mode |
S_IFREG);
560 static int dlmfs_unlink(
struct inode *dir,
561 struct dentry *dentry)
564 struct inode *inode = dentry->
d_inode;
566 mlog(0,
"unlink inode %lu\n", inode->
i_ino);
581 static int dlmfs_fill_super(
struct super_block * sb,
589 sb->
s_op = &dlmfs_ops;
597 .open = dlmfs_file_open,
598 .release = dlmfs_file_release,
599 .poll = dlmfs_file_poll,
600 .read = dlmfs_file_read,
601 .write = dlmfs_file_write,
606 .create = dlmfs_create,
608 .unlink = dlmfs_unlink,
614 .mkdir = dlmfs_mkdir,
620 .alloc_inode = dlmfs_alloc_inode,
621 .destroy_inode = dlmfs_destroy_inode,
622 .evict_inode = dlmfs_evict_inode,
628 .setattr = dlmfs_file_setattr,
632 int flags,
const char *dev_name,
void *data)
634 return mount_nodev(fs_type, flags, data, dlmfs_fill_super);
639 .name =
"ocfs2_dlmfs",
640 .mount = dlmfs_mount,
644 static int __init init_dlmfs_fs(
void)
647 int cleanup_inode = 0, cleanup_worker = 0;
651 status =
bdi_init(&dlmfs_backing_dev_info);
660 if (!dlmfs_inode_cache) {
667 if (!user_dlm_worker) {
683 printk(
"OCFS2 User DLM kernel interface loaded\n");
687 static void __exit exit_dlmfs_fs(
void)