diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-01-30 18:38:24 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-04-18 11:56:04 -0400 |
commit | 19fdb624dc8ccb663f6e48b3a3a3fa4e4e567fc1 (patch) | |
tree | b50e358686ca63789af4af07526e0d21f2806bfb /fs/ocfs2 | |
parent | 4670c46ded9a18268d1265417ff4ac72145a7917 (diff) |
ocfs2: Abstract out node number queries.
ocfs2 asks the cluster stack for the local node's node number for two
reasons; to fill the slot map and to print it. While the slot map isn't
necessary for userspace cluster stacks, the printing is very nice for
debugging. Thus we add ocfs2_cluster_this_node() as a generic API to get
this value. It is anticipated that the slot map will not be used under a
userspace cluster stack, so validity checks of the node num only need to
exist in the slot map code. Otherwise, it just gets used and printed as an
opaque value.
[ Fixed up some "int" versus "unsigned int" issues and made osb->node_num
truly opaque. --Mark ]
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/ocfs2.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/slot_map.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.c | 17 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.h | 1 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 22 |
5 files changed, 30 insertions, 14 deletions
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 664e4fe3eab5..7006abaffd47 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -218,7 +218,7 @@ struct ocfs2_super | |||
218 | unsigned int s_atime_quantum; | 218 | unsigned int s_atime_quantum; |
219 | 219 | ||
220 | unsigned int max_slots; | 220 | unsigned int max_slots; |
221 | s16 node_num; | 221 | unsigned int node_num; |
222 | int slot_num; | 222 | int slot_num; |
223 | int preferred_slot; | 223 | int preferred_slot; |
224 | int s_sectsize_bits; | 224 | int s_sectsize_bits; |
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index 63fb1b26d964..bb5ff8939bf1 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c | |||
@@ -73,8 +73,6 @@ static void ocfs2_set_slot(struct ocfs2_slot_info *si, | |||
73 | int slot_num, unsigned int node_num) | 73 | int slot_num, unsigned int node_num) |
74 | { | 74 | { |
75 | BUG_ON((slot_num < 0) || (slot_num >= si->si_num_slots)); | 75 | BUG_ON((slot_num < 0) || (slot_num >= si->si_num_slots)); |
76 | BUG_ON((node_num == O2NM_INVALID_NODE_NUM) || | ||
77 | (node_num >= O2NM_MAX_NODES)); | ||
78 | 76 | ||
79 | si->si_slots[slot_num].sl_valid = 1; | 77 | si->si_slots[slot_num].sl_valid = 1; |
80 | si->si_slots[slot_num].sl_node_num = node_num; | 78 | si->si_slots[slot_num].sl_node_num = node_num; |
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index f6f309a08344..814686356cc6 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/fs.h> | 25 | #include <linux/fs.h> |
26 | 26 | ||
27 | #include "cluster/masklog.h" | 27 | #include "cluster/masklog.h" |
28 | #include "cluster/nodemanager.h" | ||
29 | |||
28 | #include "stackglue.h" | 30 | #include "stackglue.h" |
29 | 31 | ||
30 | static struct ocfs2_locking_protocol *lproto; | 32 | static struct ocfs2_locking_protocol *lproto; |
@@ -371,6 +373,21 @@ int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn) | |||
371 | return 0; | 373 | return 0; |
372 | } | 374 | } |
373 | 375 | ||
376 | int ocfs2_cluster_this_node(unsigned int *node) | ||
377 | { | ||
378 | int node_num; | ||
379 | |||
380 | node_num = o2nm_this_node(); | ||
381 | if (node_num == O2NM_INVALID_NODE_NUM) | ||
382 | return -ENOENT; | ||
383 | |||
384 | if (node_num >= O2NM_MAX_NODES) | ||
385 | return -EOVERFLOW; | ||
386 | |||
387 | *node = node_num; | ||
388 | return 0; | ||
389 | } | ||
390 | |||
374 | void o2cb_get_stack(struct ocfs2_locking_protocol *proto) | 391 | void o2cb_get_stack(struct ocfs2_locking_protocol *proto) |
375 | { | 392 | { |
376 | BUG_ON(proto == NULL); | 393 | BUG_ON(proto == NULL); |
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h index 3900b5c3933c..ccb03991b514 100644 --- a/fs/ocfs2/stackglue.h +++ b/fs/ocfs2/stackglue.h | |||
@@ -74,6 +74,7 @@ int ocfs2_cluster_connect(const char *group, | |||
74 | void *recovery_data, | 74 | void *recovery_data, |
75 | struct ocfs2_cluster_connection **conn); | 75 | struct ocfs2_cluster_connection **conn); |
76 | int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn); | 76 | int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn); |
77 | int ocfs2_cluster_this_node(unsigned int *node); | ||
77 | 78 | ||
78 | int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn, | 79 | int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn, |
79 | int mode, | 80 | int mode, |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 0ee49757467d..d3c4d323fab5 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -694,7 +694,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
694 | if (ocfs2_mount_local(osb)) | 694 | if (ocfs2_mount_local(osb)) |
695 | snprintf(nodestr, sizeof(nodestr), "local"); | 695 | snprintf(nodestr, sizeof(nodestr), "local"); |
696 | else | 696 | else |
697 | snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); | 697 | snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num); |
698 | 698 | ||
699 | printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) " | 699 | printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) " |
700 | "with %s data mode.\n", | 700 | "with %s data mode.\n", |
@@ -1145,16 +1145,17 @@ static int ocfs2_fill_local_node_info(struct ocfs2_super *osb) | |||
1145 | * desirable. */ | 1145 | * desirable. */ |
1146 | if (ocfs2_mount_local(osb)) | 1146 | if (ocfs2_mount_local(osb)) |
1147 | osb->node_num = 0; | 1147 | osb->node_num = 0; |
1148 | else | 1148 | else { |
1149 | osb->node_num = o2nm_this_node(); | 1149 | status = ocfs2_cluster_this_node(&osb->node_num); |
1150 | 1150 | if (status < 0) { | |
1151 | if (osb->node_num == O2NM_MAX_NODES) { | 1151 | mlog_errno(status); |
1152 | mlog(ML_ERROR, "could not find this host's node number\n"); | 1152 | mlog(ML_ERROR, |
1153 | status = -ENOENT; | 1153 | "could not find this host's node number\n"); |
1154 | goto bail; | 1154 | goto bail; |
1155 | } | ||
1155 | } | 1156 | } |
1156 | 1157 | ||
1157 | mlog(0, "I am node %d\n", osb->node_num); | 1158 | mlog(0, "I am node %u\n", osb->node_num); |
1158 | 1159 | ||
1159 | status = 0; | 1160 | status = 0; |
1160 | bail: | 1161 | bail: |
@@ -1282,7 +1283,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) | |||
1282 | if (ocfs2_mount_local(osb)) | 1283 | if (ocfs2_mount_local(osb)) |
1283 | snprintf(nodestr, sizeof(nodestr), "local"); | 1284 | snprintf(nodestr, sizeof(nodestr), "local"); |
1284 | else | 1285 | else |
1285 | snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); | 1286 | snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num); |
1286 | 1287 | ||
1287 | printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n", | 1288 | printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n", |
1288 | osb->dev_str, nodestr); | 1289 | osb->dev_str, nodestr); |
@@ -1384,7 +1385,6 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
1384 | 1385 | ||
1385 | osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | 1386 | osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; |
1386 | 1387 | ||
1387 | osb->node_num = O2NM_INVALID_NODE_NUM; | ||
1388 | osb->slot_num = OCFS2_INVALID_SLOT; | 1388 | osb->slot_num = OCFS2_INVALID_SLOT; |
1389 | 1389 | ||
1390 | osb->local_alloc_state = OCFS2_LA_UNUSED; | 1390 | osb->local_alloc_state = OCFS2_LA_UNUSED; |