From 79bbc79bf780c79e24e28dc0b511791bc344ac75 Mon Sep 17 00:00:00 2001 From: wangdi Date: Wed, 6 Dec 2006 07:54:43 +0000 Subject: [PATCH] Branch:b_new_cmd choose mds by nid instead by name to avoid mds-mds recovery temporarily for debuging 11/17. currently, the parent is locked before mds-mds rpc, which may caused some problem when do mds-mds recovery. --- lustre/lmv/lmv_obd.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index fc54c13..e1e4e3c 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -723,6 +723,11 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(rc); } +enum MDS_POLICY { + CHAR_TYPE, + NID_TYPE +}; + static int lmv_all_chars_policy(int count, const char *name, int len) { @@ -734,6 +739,36 @@ static int lmv_all_chars_policy(int count, const char *name, return c; } +static int lmv_nid_policy(struct lmv_obd *lmv) +{ + struct obd_import *imp = class_exp2cliimp(lmv->tgts[0].ltd_exp); + __u32 id; + /* + * XXX Hack: to get nid we assume that underlying obd device is mdc. + */ + id = imp->imp_connection->c_self ^ (imp->imp_connection->c_self >> 32); + return id % lmv->desc.ld_tgt_count; +} + +static int lmv_choose_mds(struct lmv_obd *lmv, struct md_op_data *op_data, + int type) +{ + switch (type) { + case CHAR_TYPE: + return lmv_all_chars_policy(lmv->desc.ld_tgt_count, + op_data->op_name, + op_data->op_namelen); + case NID_TYPE: + return lmv_nid_policy(lmv); + + default: + break; + } + + CERROR("unsupport type %d \n", type); + return -EINVAL; +} + /* This is _inode_ placement policy function (not name). */ static int lmv_placement_policy(struct obd_device *obd, struct md_op_data *op_data, @@ -784,9 +819,7 @@ static int lmv_placement_policy(struct obd_device *obd, * directory in it. Let's calculate where to place it according * to name. */ - *mds = lmv_all_chars_policy(lmv->desc.ld_tgt_count, - op_data->op_name, - op_data->op_namelen); + *mds = lmv_choose_mds(lmv, op_data, NID_TYPE); rc = 0; } EXIT; -- 1.8.3.1