diff options
Diffstat (limited to 'fs/ocfs2/dlmfs/dlmfs.c')
-rw-r--r-- | fs/ocfs2/dlmfs/dlmfs.c | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 13ac2bffb05d..8697366b63ad 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c | |||
@@ -47,21 +47,13 @@ | |||
47 | 47 | ||
48 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
49 | 49 | ||
50 | 50 | #include "stackglue.h" | |
51 | #include "cluster/nodemanager.h" | ||
52 | #include "cluster/heartbeat.h" | ||
53 | #include "cluster/tcp.h" | ||
54 | |||
55 | #include "dlm/dlmapi.h" | ||
56 | |||
57 | #include "userdlm.h" | 51 | #include "userdlm.h" |
58 | |||
59 | #include "dlmfsver.h" | 52 | #include "dlmfsver.h" |
60 | 53 | ||
61 | #define MLOG_MASK_PREFIX ML_DLMFS | 54 | #define MLOG_MASK_PREFIX ML_DLMFS |
62 | #include "cluster/masklog.h" | 55 | #include "cluster/masklog.h" |
63 | 56 | ||
64 | #include "ocfs2_lockingver.h" | ||
65 | 57 | ||
66 | static const struct super_operations dlmfs_ops; | 58 | static const struct super_operations dlmfs_ops; |
67 | static const struct file_operations dlmfs_file_operations; | 59 | static const struct file_operations dlmfs_file_operations; |
@@ -72,15 +64,6 @@ static struct kmem_cache *dlmfs_inode_cache; | |||
72 | 64 | ||
73 | struct workqueue_struct *user_dlm_worker; | 65 | struct workqueue_struct *user_dlm_worker; |
74 | 66 | ||
75 | /* | ||
76 | * This is the userdlmfs locking protocol version. | ||
77 | * | ||
78 | * See fs/ocfs2/dlmglue.c for more details on locking versions. | ||
79 | */ | ||
80 | static const struct dlm_protocol_version user_locking_protocol = { | ||
81 | .pv_major = OCFS2_LOCKING_PROTOCOL_MAJOR, | ||
82 | .pv_minor = OCFS2_LOCKING_PROTOCOL_MINOR, | ||
83 | }; | ||
84 | 67 | ||
85 | 68 | ||
86 | /* | 69 | /* |
@@ -259,7 +242,7 @@ static ssize_t dlmfs_file_read(struct file *filp, | |||
259 | loff_t *ppos) | 242 | loff_t *ppos) |
260 | { | 243 | { |
261 | int bytes_left; | 244 | int bytes_left; |
262 | ssize_t readlen; | 245 | ssize_t readlen, got; |
263 | char *lvb_buf; | 246 | char *lvb_buf; |
264 | struct inode *inode = filp->f_path.dentry->d_inode; | 247 | struct inode *inode = filp->f_path.dentry->d_inode; |
265 | 248 | ||
@@ -285,9 +268,13 @@ static ssize_t dlmfs_file_read(struct file *filp, | |||
285 | if (!lvb_buf) | 268 | if (!lvb_buf) |
286 | return -ENOMEM; | 269 | return -ENOMEM; |
287 | 270 | ||
288 | user_dlm_read_lvb(inode, lvb_buf, readlen); | 271 | got = user_dlm_read_lvb(inode, lvb_buf, readlen); |
289 | bytes_left = __copy_to_user(buf, lvb_buf, readlen); | 272 | if (got) { |
290 | readlen -= bytes_left; | 273 | BUG_ON(got != readlen); |
274 | bytes_left = __copy_to_user(buf, lvb_buf, readlen); | ||
275 | readlen -= bytes_left; | ||
276 | } else | ||
277 | readlen = 0; | ||
291 | 278 | ||
292 | kfree(lvb_buf); | 279 | kfree(lvb_buf); |
293 | 280 | ||
@@ -346,7 +333,7 @@ static void dlmfs_init_once(void *foo) | |||
346 | struct dlmfs_inode_private *ip = | 333 | struct dlmfs_inode_private *ip = |
347 | (struct dlmfs_inode_private *) foo; | 334 | (struct dlmfs_inode_private *) foo; |
348 | 335 | ||
349 | ip->ip_dlm = NULL; | 336 | ip->ip_conn = NULL; |
350 | ip->ip_parent = NULL; | 337 | ip->ip_parent = NULL; |
351 | 338 | ||
352 | inode_init_once(&ip->ip_vfs_inode); | 339 | inode_init_once(&ip->ip_vfs_inode); |
@@ -388,14 +375,14 @@ static void dlmfs_clear_inode(struct inode *inode) | |||
388 | goto clear_fields; | 375 | goto clear_fields; |
389 | } | 376 | } |
390 | 377 | ||
391 | mlog(0, "we're a directory, ip->ip_dlm = 0x%p\n", ip->ip_dlm); | 378 | mlog(0, "we're a directory, ip->ip_conn = 0x%p\n", ip->ip_conn); |
392 | /* we must be a directory. If required, lets unregister the | 379 | /* we must be a directory. If required, lets unregister the |
393 | * dlm context now. */ | 380 | * dlm context now. */ |
394 | if (ip->ip_dlm) | 381 | if (ip->ip_conn) |
395 | user_dlm_unregister_context(ip->ip_dlm); | 382 | user_dlm_unregister(ip->ip_conn); |
396 | clear_fields: | 383 | clear_fields: |
397 | ip->ip_parent = NULL; | 384 | ip->ip_parent = NULL; |
398 | ip->ip_dlm = NULL; | 385 | ip->ip_conn = NULL; |
399 | } | 386 | } |
400 | 387 | ||
401 | static struct backing_dev_info dlmfs_backing_dev_info = { | 388 | static struct backing_dev_info dlmfs_backing_dev_info = { |
@@ -445,7 +432,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent, | |||
445 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 432 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
446 | 433 | ||
447 | ip = DLMFS_I(inode); | 434 | ip = DLMFS_I(inode); |
448 | ip->ip_dlm = DLMFS_I(parent)->ip_dlm; | 435 | ip->ip_conn = DLMFS_I(parent)->ip_conn; |
449 | 436 | ||
450 | switch (mode & S_IFMT) { | 437 | switch (mode & S_IFMT) { |
451 | default: | 438 | default: |
@@ -499,13 +486,12 @@ static int dlmfs_mkdir(struct inode * dir, | |||
499 | struct inode *inode = NULL; | 486 | struct inode *inode = NULL; |
500 | struct qstr *domain = &dentry->d_name; | 487 | struct qstr *domain = &dentry->d_name; |
501 | struct dlmfs_inode_private *ip; | 488 | struct dlmfs_inode_private *ip; |
502 | struct dlm_ctxt *dlm; | 489 | struct ocfs2_cluster_connection *conn; |
503 | struct dlm_protocol_version proto = user_locking_protocol; | ||
504 | 490 | ||
505 | mlog(0, "mkdir %.*s\n", domain->len, domain->name); | 491 | mlog(0, "mkdir %.*s\n", domain->len, domain->name); |
506 | 492 | ||
507 | /* verify that we have a proper domain */ | 493 | /* verify that we have a proper domain */ |
508 | if (domain->len >= O2NM_MAX_NAME_LEN) { | 494 | if (domain->len >= GROUP_NAME_MAX) { |
509 | status = -EINVAL; | 495 | status = -EINVAL; |
510 | mlog(ML_ERROR, "invalid domain name for directory.\n"); | 496 | mlog(ML_ERROR, "invalid domain name for directory.\n"); |
511 | goto bail; | 497 | goto bail; |
@@ -520,14 +506,14 @@ static int dlmfs_mkdir(struct inode * dir, | |||
520 | 506 | ||
521 | ip = DLMFS_I(inode); | 507 | ip = DLMFS_I(inode); |
522 | 508 | ||
523 | dlm = user_dlm_register_context(domain, &proto); | 509 | conn = user_dlm_register(domain); |
524 | if (IS_ERR(dlm)) { | 510 | if (IS_ERR(conn)) { |
525 | status = PTR_ERR(dlm); | 511 | status = PTR_ERR(conn); |
526 | mlog(ML_ERROR, "Error %d could not register domain \"%.*s\"\n", | 512 | mlog(ML_ERROR, "Error %d could not register domain \"%.*s\"\n", |
527 | status, domain->len, domain->name); | 513 | status, domain->len, domain->name); |
528 | goto bail; | 514 | goto bail; |
529 | } | 515 | } |
530 | ip->ip_dlm = dlm; | 516 | ip->ip_conn = conn; |
531 | 517 | ||
532 | inc_nlink(dir); | 518 | inc_nlink(dir); |
533 | d_instantiate(dentry, inode); | 519 | d_instantiate(dentry, inode); |
@@ -696,6 +682,7 @@ static int __init init_dlmfs_fs(void) | |||
696 | } | 682 | } |
697 | cleanup_worker = 1; | 683 | cleanup_worker = 1; |
698 | 684 | ||
685 | user_dlm_set_locking_protocol(); | ||
699 | status = register_filesystem(&dlmfs_fs_type); | 686 | status = register_filesystem(&dlmfs_fs_type); |
700 | bail: | 687 | bail: |
701 | if (status) { | 688 | if (status) { |