};
#define NRS_POL_NAME_MAX 16
+#define NRS_POL_ARG_MAX 16
struct ptlrpc_nrs_pol_desc;
*/
char pi_name[NRS_POL_NAME_MAX];
/**
+ * Policy argument
+ */
+ char pi_arg[NRS_POL_ARG_MAX];
+ /**
* Current policy state
*/
enum ptlrpc_nrs_pol_state pi_state;
*/
long pol_ref;
/**
+ * Human-readable policy argument
+ */
+ char pol_arg[NRS_POL_ARG_MAX];
+ /**
* The NRS head this policy has been created at
*/
struct ptlrpc_nrs *pol_nrs;
LASSERT(info != NULL);
assert_spin_locked(&policy->pol_nrs->nrs_lock);
+ LASSERT(sizeof(info->pi_arg) == sizeof(policy->pol_arg));
memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX);
+ memcpy(info->pi_arg, policy->pol_arg, sizeof(policy->pol_arg));
info->pi_fallback = !!(policy->pol_flags & PTLRPC_NRS_FL_FALLBACK);
info->pi_state = policy->pol_state;
if (i == 0) {
memcpy(infos[pol_idx].pi_name, tmp.pi_name,
NRS_POL_NAME_MAX);
+ memcpy(infos[pol_idx].pi_arg, tmp.pi_arg,
+ sizeof(tmp.pi_arg));
memcpy(&infos[pol_idx].pi_state, &tmp.pi_state,
sizeof(tmp.pi_state));
infos[pol_idx].pi_fallback = tmp.pi_fallback;
LASSERT(strncmp(infos[pol_idx].pi_name,
tmp.pi_name,
NRS_POL_NAME_MAX) == 0);
+ LASSERT(strncmp(infos[pol_idx].pi_arg,
+ tmp.pi_arg,
+ sizeof(tmp.pi_arg)) == 0);
/**
* Not asserting ptlrpc_nrs_pol_info::pi_state,
* because it may be different between
"high_priority_requests:");
for (pol_idx = 0; pol_idx < num_pols; pol_idx++) {
- seq_printf(m, " - name: %s\n"
- " state: %s\n"
+ if (strlen(infos[pol_idx].pi_arg) > 0)
+ seq_printf(m, " - name: %s %s\n",
+ infos[pol_idx].pi_name,
+ infos[pol_idx].pi_arg);
+ else
+ seq_printf(m, " - name: %s\n",
+ infos[pol_idx].pi_name);
+
+
+ seq_printf(m, " state: %s\n"
" fallback: %s\n"
" queued: %-20d\n"
" active: %-20d\n\n",
- infos[pol_idx].pi_name,
nrs_state2str(infos[pol_idx].pi_state),
infos[pol_idx].pi_fallback ? "yes" : "no",
(int)infos[pol_idx].pi_req_queued,
if (nrs->nrs_policy_fallback == NULL)
RETURN(-EPERM);
- if (policy->pol_state == NRS_POL_STATE_STARTED)
- RETURN(0);
+ if (policy->pol_state == NRS_POL_STATE_STARTED) {
+ /**
+ * If the policy argument now is different from the last time,
+ * stop the policy first and start it again with the new
+ * argument.
+ */
+ if ((arg != NULL) && (strlen(arg) >= NRS_POL_ARG_MAX))
+ return -EINVAL;
+
+ if ((arg == NULL && strlen(policy->pol_arg) == 0) ||
+ (arg != NULL && strcmp(policy->pol_arg, arg) == 0))
+ RETURN(0);
+
+ rc = nrs_policy_stop_locked(policy);
+ if (rc)
+ RETURN(-EAGAIN);
+ }
}
/**
RETURN(-ENODEV);
}
+ if (arg != NULL) {
+ if (strlen(arg) + 1 > sizeof(policy->pol_arg)) {
+ CERROR("NRS: arg '%s' is too long\n", arg);
+ GOTO(out, rc = -E2BIG);
+ }
+ strncpy(policy->pol_arg, arg, sizeof(policy->pol_arg));
+ }
+
/**
* Serialize policy starting across the NRS head
*/