diff options
author | Sunil Mushran <Sunil.Mushran@oracle.com> | 2006-12-05 20:56:35 -0500 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2006-12-07 20:37:53 -0500 |
commit | c271c5c22b0a7ca45fda15f1f4d258bca36a5b94 (patch) | |
tree | 9803af515ecf1c101c4a5921d7407c66184147e1 /fs/ocfs2/super.c | |
parent | c99767974ebd2a719d849fdeaaa1674456f5283f (diff) |
ocfs2: local mounts
This allows users to format an ocfs2 file system with a special flag,
OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT. When the file system sees this flag, it
will not use any cluster services, nor will it require a cluster
configuration, thus acting like a 'local' file system.
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/super.c')
-rw-r--r-- | fs/ocfs2/super.c | 90 |
1 files changed, 65 insertions, 25 deletions
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 4bf39540e65..a6d2f8cc165 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -508,6 +508,27 @@ bail: | |||
508 | return status; | 508 | return status; |
509 | } | 509 | } |
510 | 510 | ||
511 | static int ocfs2_verify_heartbeat(struct ocfs2_super *osb) | ||
512 | { | ||
513 | if (ocfs2_mount_local(osb)) { | ||
514 | if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { | ||
515 | mlog(ML_ERROR, "Cannot heartbeat on a locally " | ||
516 | "mounted device.\n"); | ||
517 | return -EINVAL; | ||
518 | } | ||
519 | } | ||
520 | |||
521 | if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { | ||
522 | if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb)) { | ||
523 | mlog(ML_ERROR, "Heartbeat has to be started to mount " | ||
524 | "a read-write clustered device.\n"); | ||
525 | return -EINVAL; | ||
526 | } | ||
527 | } | ||
528 | |||
529 | return 0; | ||
530 | } | ||
531 | |||
511 | static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | 532 | static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) |
512 | { | 533 | { |
513 | struct dentry *root; | 534 | struct dentry *root; |
@@ -516,16 +537,24 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
516 | struct inode *inode = NULL; | 537 | struct inode *inode = NULL; |
517 | struct ocfs2_super *osb = NULL; | 538 | struct ocfs2_super *osb = NULL; |
518 | struct buffer_head *bh = NULL; | 539 | struct buffer_head *bh = NULL; |
540 | char nodestr[8]; | ||
519 | 541 | ||
520 | mlog_entry("%p, %p, %i", sb, data, silent); | 542 | mlog_entry("%p, %p, %i", sb, data, silent); |
521 | 543 | ||
522 | /* for now we only have one cluster/node, make sure we see it | 544 | if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) { |
523 | * in the heartbeat universe */ | ||
524 | if (!o2hb_check_local_node_heartbeating()) { | ||
525 | status = -EINVAL; | 545 | status = -EINVAL; |
526 | goto read_super_error; | 546 | goto read_super_error; |
527 | } | 547 | } |
528 | 548 | ||
549 | /* for now we only have one cluster/node, make sure we see it | ||
550 | * in the heartbeat universe */ | ||
551 | if (parsed_opt & OCFS2_MOUNT_HB_LOCAL) { | ||
552 | if (!o2hb_check_local_node_heartbeating()) { | ||
553 | status = -EINVAL; | ||
554 | goto read_super_error; | ||
555 | } | ||
556 | } | ||
557 | |||
529 | /* probe for superblock */ | 558 | /* probe for superblock */ |
530 | status = ocfs2_sb_probe(sb, &bh, §or_size); | 559 | status = ocfs2_sb_probe(sb, &bh, §or_size); |
531 | if (status < 0) { | 560 | if (status < 0) { |
@@ -541,11 +570,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
541 | } | 570 | } |
542 | brelse(bh); | 571 | brelse(bh); |
543 | bh = NULL; | 572 | bh = NULL; |
544 | |||
545 | if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) { | ||
546 | status = -EINVAL; | ||
547 | goto read_super_error; | ||
548 | } | ||
549 | osb->s_mount_opt = parsed_opt; | 573 | osb->s_mount_opt = parsed_opt; |
550 | 574 | ||
551 | sb->s_magic = OCFS2_SUPER_MAGIC; | 575 | sb->s_magic = OCFS2_SUPER_MAGIC; |
@@ -588,21 +612,16 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
588 | } | 612 | } |
589 | 613 | ||
590 | if (!ocfs2_is_hard_readonly(osb)) { | 614 | if (!ocfs2_is_hard_readonly(osb)) { |
591 | /* If this isn't a hard readonly mount, then we need | ||
592 | * to make sure that heartbeat is in a valid state, | ||
593 | * and that we mark ourselves soft readonly is -oro | ||
594 | * was specified. */ | ||
595 | if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { | ||
596 | mlog(ML_ERROR, "No heartbeat for device (%s)\n", | ||
597 | sb->s_id); | ||
598 | status = -EINVAL; | ||
599 | goto read_super_error; | ||
600 | } | ||
601 | |||
602 | if (sb->s_flags & MS_RDONLY) | 615 | if (sb->s_flags & MS_RDONLY) |
603 | ocfs2_set_ro_flag(osb, 0); | 616 | ocfs2_set_ro_flag(osb, 0); |
604 | } | 617 | } |
605 | 618 | ||
619 | status = ocfs2_verify_heartbeat(osb); | ||
620 | if (status < 0) { | ||
621 | mlog_errno(status); | ||
622 | goto read_super_error; | ||
623 | } | ||
624 | |||
606 | osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, | 625 | osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, |
607 | ocfs2_debugfs_root); | 626 | ocfs2_debugfs_root); |
608 | if (!osb->osb_debug_root) { | 627 | if (!osb->osb_debug_root) { |
@@ -635,9 +654,14 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
635 | 654 | ||
636 | ocfs2_complete_mount_recovery(osb); | 655 | ocfs2_complete_mount_recovery(osb); |
637 | 656 | ||
638 | printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %d, slot %d) " | 657 | if (ocfs2_mount_local(osb)) |
658 | snprintf(nodestr, sizeof(nodestr), "local"); | ||
659 | else | ||
660 | snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); | ||
661 | |||
662 | printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) " | ||
639 | "with %s data mode.\n", | 663 | "with %s data mode.\n", |
640 | osb->dev_str, osb->node_num, osb->slot_num, | 664 | osb->dev_str, nodestr, osb->slot_num, |
641 | osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : | 665 | osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : |
642 | "ordered"); | 666 | "ordered"); |
643 | 667 | ||
@@ -999,7 +1023,11 @@ static int ocfs2_fill_local_node_info(struct ocfs2_super *osb) | |||
999 | 1023 | ||
1000 | /* XXX hold a ref on the node while mounte? easy enough, if | 1024 | /* XXX hold a ref on the node while mounte? easy enough, if |
1001 | * desirable. */ | 1025 | * desirable. */ |
1002 | osb->node_num = o2nm_this_node(); | 1026 | if (ocfs2_mount_local(osb)) |
1027 | osb->node_num = 0; | ||
1028 | else | ||
1029 | osb->node_num = o2nm_this_node(); | ||
1030 | |||
1003 | if (osb->node_num == O2NM_MAX_NODES) { | 1031 | if (osb->node_num == O2NM_MAX_NODES) { |
1004 | mlog(ML_ERROR, "could not find this host's node number\n"); | 1032 | mlog(ML_ERROR, "could not find this host's node number\n"); |
1005 | status = -ENOENT; | 1033 | status = -ENOENT; |
@@ -1084,6 +1112,9 @@ static int ocfs2_mount_volume(struct super_block *sb) | |||
1084 | goto leave; | 1112 | goto leave; |
1085 | } | 1113 | } |
1086 | 1114 | ||
1115 | if (ocfs2_mount_local(osb)) | ||
1116 | goto leave; | ||
1117 | |||
1087 | /* This should be sent *after* we recovered our journal as it | 1118 | /* This should be sent *after* we recovered our journal as it |
1088 | * will cause other nodes to unmark us as needing | 1119 | * will cause other nodes to unmark us as needing |
1089 | * recovery. However, we need to send it *before* dropping the | 1120 | * recovery. However, we need to send it *before* dropping the |
@@ -1114,6 +1145,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) | |||
1114 | { | 1145 | { |
1115 | int tmp; | 1146 | int tmp; |
1116 | struct ocfs2_super *osb = NULL; | 1147 | struct ocfs2_super *osb = NULL; |
1148 | char nodestr[8]; | ||
1117 | 1149 | ||
1118 | mlog_entry("(0x%p)\n", sb); | 1150 | mlog_entry("(0x%p)\n", sb); |
1119 | 1151 | ||
@@ -1177,8 +1209,13 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) | |||
1177 | 1209 | ||
1178 | atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); | 1210 | atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); |
1179 | 1211 | ||
1180 | printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %d)\n", | 1212 | if (ocfs2_mount_local(osb)) |
1181 | osb->dev_str, osb->node_num); | 1213 | snprintf(nodestr, sizeof(nodestr), "local"); |
1214 | else | ||
1215 | snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); | ||
1216 | |||
1217 | printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n", | ||
1218 | osb->dev_str, nodestr); | ||
1182 | 1219 | ||
1183 | ocfs2_delete_osb(osb); | 1220 | ocfs2_delete_osb(osb); |
1184 | kfree(osb); | 1221 | kfree(osb); |
@@ -1536,6 +1573,7 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
1536 | { | 1573 | { |
1537 | int status = 0; | 1574 | int status = 0; |
1538 | int dirty; | 1575 | int dirty; |
1576 | int local; | ||
1539 | struct ocfs2_dinode *local_alloc = NULL; /* only used if we | 1577 | struct ocfs2_dinode *local_alloc = NULL; /* only used if we |
1540 | * recover | 1578 | * recover |
1541 | * ourselves. */ | 1579 | * ourselves. */ |
@@ -1563,8 +1601,10 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
1563 | "recovering volume.\n"); | 1601 | "recovering volume.\n"); |
1564 | } | 1602 | } |
1565 | 1603 | ||
1604 | local = ocfs2_mount_local(osb); | ||
1605 | |||
1566 | /* will play back anything left in the journal. */ | 1606 | /* will play back anything left in the journal. */ |
1567 | ocfs2_journal_load(osb->journal); | 1607 | ocfs2_journal_load(osb->journal, local); |
1568 | 1608 | ||
1569 | if (dirty) { | 1609 | if (dirty) { |
1570 | /* recover my local alloc if we didn't unmount cleanly. */ | 1610 | /* recover my local alloc if we didn't unmount cleanly. */ |