Skip to content

Commit 19fdb62

Browse files
Joel BeckerMark Fasheh
authored andcommitted
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>
1 parent 4670c46 commit 19fdb62

5 files changed

Lines changed: 30 additions & 14 deletions

File tree

‎fs/ocfs2/ocfs2.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ struct ocfs2_super
218218
unsigned int s_atime_quantum;
219219

220220
unsigned int max_slots;
221-
s16 node_num;
221+
unsigned int node_num;
222222
int slot_num;
223223
int preferred_slot;
224224
int s_sectsize_bits;

‎fs/ocfs2/slot_map.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ static void ocfs2_set_slot(struct ocfs2_slot_info *si,
7373
int slot_num, unsigned int node_num)
7474
{
7575
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));
7876

7977
si->si_slots[slot_num].sl_valid = 1;
8078
si->si_slots[slot_num].sl_node_num = node_num;

‎fs/ocfs2/stackglue.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <linux/fs.h>
2626

2727
#include "cluster/masklog.h"
28+
#include "cluster/nodemanager.h"
29+
2830
#include "stackglue.h"
2931

3032
static struct ocfs2_locking_protocol *lproto;
@@ -371,6 +373,21 @@ int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn)
371373
return 0;
372374
}
373375

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+
374391
void o2cb_get_stack(struct ocfs2_locking_protocol *proto)
375392
{
376393
BUG_ON(proto == NULL);

‎fs/ocfs2/stackglue.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int ocfs2_cluster_connect(const char *group,
7474
void *recovery_data,
7575
struct ocfs2_cluster_connection **conn);
7676
int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn);
77+
int ocfs2_cluster_this_node(unsigned int *node);
7778

7879
int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
7980
int mode,

‎fs/ocfs2/super.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
694694
if (ocfs2_mount_local(osb))
695695
snprintf(nodestr, sizeof(nodestr), "local");
696696
else
697-
snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num);
697+
snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num);
698698

699699
printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) "
700700
"with %s data mode.\n",
@@ -1145,16 +1145,17 @@ static int ocfs2_fill_local_node_info(struct ocfs2_super *osb)
11451145
* desirable. */
11461146
if (ocfs2_mount_local(osb))
11471147
osb->node_num = 0;
1148-
else
1149-
osb->node_num = o2nm_this_node();
1150-
1151-
if (osb->node_num == O2NM_MAX_NODES) {
1152-
mlog(ML_ERROR, "could not find this host's node number\n");
1153-
status = -ENOENT;
1154-
goto bail;
1148+
else {
1149+
status = ocfs2_cluster_this_node(&osb->node_num);
1150+
if (status < 0) {
1151+
mlog_errno(status);
1152+
mlog(ML_ERROR,
1153+
"could not find this host's node number\n");
1154+
goto bail;
1155+
}
11551156
}
11561157

1157-
mlog(0, "I am node %d\n", osb->node_num);
1158+
mlog(0, "I am node %u\n", osb->node_num);
11581159

11591160
status = 0;
11601161
bail:
@@ -1282,7 +1283,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
12821283
if (ocfs2_mount_local(osb))
12831284
snprintf(nodestr, sizeof(nodestr), "local");
12841285
else
1285-
snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num);
1286+
snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num);
12861287

12871288
printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n",
12881289
osb->dev_str, nodestr);
@@ -1384,7 +1385,6 @@ static int ocfs2_initialize_super(struct super_block *sb,
13841385

13851386
osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
13861387

1387-
osb->node_num = O2NM_INVALID_NODE_NUM;
13881388
osb->slot_num = OCFS2_INVALID_SLOT;
13891389

13901390
osb->local_alloc_state = OCFS2_LA_UNUSED;

0 commit comments

Comments
 (0)