CONFIG_READ_NRPAGES = 4
};
-static int mgc_apply_recover_logs(struct obd_device *obd,
+static int mgc_apply_recover_logs(struct obd_device *mgc,
struct config_llog_data *cld,
__u64 max_version,
void *data, int datalen)
u64 prev_version = 0;
char *inst;
char *buf;
- int bufsz = CFS_PAGE_SIZE;
+ int bufsz;
int pos;
int rc = 0;
int off = 0;
-
- OBD_ALLOC(buf, CFS_PAGE_SIZE);
- if (buf == NULL)
- return -ENOMEM;
+ ENTRY;
LASSERT(cfg->cfg_instance != NULL);
LASSERT(cfg->cfg_sb == cfg->cfg_instance);
- inst = buf;
+
+ OBD_ALLOC(inst, CFS_PAGE_SIZE);
+ if (inst == NULL)
+ RETURN(-ENOMEM);
+
if (!(lsi->lsi_flags & LSI_SERVER)) {
pos = sprintf(inst, "%p", cfg->cfg_instance);
} else {
LASSERT(IS_MDT(lsi->lsi_ldd));
pos = sprintf(inst, "MDT%04x", lsi->lsi_ldd->ldd_svindex);
}
- buf += pos + 1;
- bufsz -= pos + 1;
+
+ ++pos;
+ buf = inst + pos;
+ bufsz = CFS_PAGE_SIZE - pos;
while (datalen > 0) {
int entry_len = sizeof(*entry);
strcpy(obdname, cld->cld_logname);
cname = strrchr(obdname, '-');
if (cname == NULL) {
- CERROR("mgc: invalid logname %s\n", obdname);
+ CERROR("mgc %s: invalid logname %s\n",
+ mgc->obd_name, obdname);
break;
}
/* find the obd by obdname */
obd = class_name2obd(obdname);
if (obd == NULL) {
- CDEBUG(D_INFO, "mgc: cannot find obdname %s\n",
- obdname);
+ CDEBUG(D_INFO, "mgc %s: cannot find obdname %s\n",
+ mgc->obd_name, obdname);
/* this is a safe race, when the ost is starting up...*/
continue;
}
OBD_FREE(inst, CFS_PAGE_SIZE);
- return rc;
+ RETURN(rc);
}
/**
RETURN(0);
}
+/*
+ * For old clients there is no direct way of knowing which filesystems
+ * a client is operating at the MGS side. But we need to pick up those
+ * clients so that the MGS can mark the corresponding filesystem as
+ * non-IR capable because old clients are not ready to be notified.
+ *
+ * This is why we have this _hack_ function. We detect the filesystem's
+ * name by hacking llog operation which is currently used by the clients
+ * to fetch configuration logs. At present this is fine because this is
+ * the ONLY llog operation between mgc and the MGS.
+ *
+ * If extra llog operation is going to be added, this function needs fixing.
+ *
+ * If releases prior than 2.0 are not supported, we can remove this function.
+ */
static int mgs_handle_fslog_hack(struct ptlrpc_request *req)
{
char *logname;
check_cli_ir_state()
{
- local NODE=${1:-`hostname`}
+ local NODE=${1:-$HOSTNAME}
local st
st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
- awk '/imperative_recovery:/ { print \\\$2}' ")
+ awk '/imperative_recovery:/ { print \\\$2}'")
[ $st != ON -o $st != OFF ] ||
error "Error state $st, must be ON or OFF"
echo -n $st
nidtbl_version_client()
{
local cli=$1
- local node=${2:-`hostname`}
+ local node=${2:-$HOSTNAME}
if [ X$cli = Xclient ]; then
cli=$FSNAME-client
local obdtype=${cli/%[0-9]*/}
[ $obdtype != mds ] && error "wrong parameters $cli"
- node=`facet_active_host $cli`
+ node=$(facet_active_host $cli)
local t=${cli}_svc
cli=${!t}
fi
nidtbl_versions_match()
{
- [ `nidtbl_version_mgs` -eq `nidtbl_version_client ${1:-client}` ]
+ [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
}
target_instance_match()
esac
local target=${srv}_svc
- local si=`do_facet $srv lctl get_param -n $obdname.${!target}.instance`
- local ci=`lctl get_param -n $cliname.${!target}-${cliname}-*.import | \
- awk '/instance/{ print $2 }' |head -1`
+ local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
+ local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import | \
+ awk '/instance/{ print $2 }' |head -1)
- return `[ $si -eq $ci ]`
+ return $([ $si -eq $ci ])
}
test_100()
set_ir_status disabled
local saved_FAILURE_MODE=$FAILURE_MODE
- [ `facet_host mgs` = `facet_host ost1` ] && FAILURE_MODE="SOFT"
+ [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
fail ost1
# valid check
test_102()
{
- local clients=${CLIENTS:-`hostname`}
+ local clients=${CLIENTS:-$HOSTNAME}
local old_version
local new_version
local mgsdev=mgs
nidtbl_versions_match || error "nidtbl mismatch"
# get the version #
- old_version=`nidtbl_version_client client`
+ old_version=$(nidtbl_version_client client)
zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
# check new version
- new_version=`nidtbl_version_client client`
+ new_version=$(nidtbl_version_client client)
[ $new_version -lt $old_version ] &&
error "nidtbl version wrong after mgs restarts"
return 0
# sleep 30 seconds so the MDS has a chance to detect MGS restarting
local count=30
while [ $count -gt 0 ]; do
- [ `nidtbl_version_client mds1` -ne 0 ] && break
+ [ $(nidtbl_version_client mds1) -ne 0 ] && break
sleep 1
count=$((count-1))
done
set_ir_status full
stop ost1
- start ost1 `ostdevname 1` "$OST_MOUNT_OPTS -onoir" ||
+ start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
error "OST1 cannot start"
clients_up
local ir_state=$(check_target_ir_state ost1)
[ $ir_state = "OFF" ] || error "ir status on ost1 should be OFF"
- ost1_opt=
}
run_test 104 "IR: ost can disable IR voluntarily"
set_ir_status full
# get one of the clients from client list
- rcli=`echo $RCLIENTS |cut -d' ' -f 1`
+ local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
local old_MOUNTOPT=$MOUNTOPT
MOUNTOPT=${MOUNTOPT},noir
[ $ir_state = OFF ] || error "IR state must be OFF at $rcli"
# make sure MGS's state is Partial
- [ `get_ir_status` = "partial" ] || error "MGS IR state must be partial"
+ [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
fail ost1
# make sure IR on ost1 is OFF
zconf_mount $rcli $MOUNT || error "mount failed"
# make sure MGS's state is full
- [ `get_ir_status` = "full" ] || error "MGS IR status must be full"
+ [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
fail ost1
# make sure IR on ost1 is ON