4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details.
15 * You should have received a copy of the GNU General Public License
16 * version 2 along with this program; If not, see
17 * http://www.gnu.org/licenses/gpl-2.0.html
22 * Copyright (c) 2017, Cray Inc. All Rights Reserved.
24 * Copyright (c) 2017, Intel Corporation.
27 * lustre/ptlrpc/nrs_delay.c
29 * Network Request Scheduler (NRS) Delay policy
31 * This policy will delay request handling for some configurable amount of
34 * Author: Chris Horn <hornc@cray.com>
41 #define DEBUG_SUBSYSTEM S_RPC
42 #include <obd_support.h>
43 #include <obd_class.h>
44 #include "ptlrpc_internal.h"
49 * The delay policy schedules RPCs so that they are only processed after some
50 * configurable amount of time (in seconds) has passed.
52 * The defaults were chosen arbitrarily.
57 #define NRS_POL_NAME_DELAY "delay"
59 /* Default minimum delay in seconds. */
60 #define NRS_DELAY_MIN_DEFAULT 5
61 /* Default maximum delay, in seconds. */
62 #define NRS_DELAY_MAX_DEFAULT 300
63 /* Default percentage of delayed RPCs. */
64 #define NRS_DELAY_PCT_DEFAULT 100
67 * Binary heap predicate.
69 * Elements are sorted according to the start time assigned to the requests
70 * upon enqueue. An element with an earlier start time is "less than" an
71 * element with a later start time.
73 * \retval 0 start_time(e1) > start_time(e2)
74 * \retval 1 start_time(e1) <= start_time(e2)
76 static int delay_req_compare(struct cfs_binheap_node *e1,
77 struct cfs_binheap_node *e2)
79 struct ptlrpc_nrs_request *nrq1;
80 struct ptlrpc_nrs_request *nrq2;
82 nrq1 = container_of(e1, struct ptlrpc_nrs_request, nr_node);
83 nrq2 = container_of(e2, struct ptlrpc_nrs_request, nr_node);
85 return nrq1->nr_u.delay.req_start_time <=
86 nrq2->nr_u.delay.req_start_time;
89 static struct cfs_binheap_ops nrs_delay_heap_ops = {
92 .hop_compare = delay_req_compare,
96 * Is called before the policy transitions into
97 * ptlrpc_nrs_pol_state::NRS_POL_STATE_STARTED; allocates and initializes
98 * the delay-specific private data structure.
100 * \param[in] policy The policy to start
101 * \param[in] Generic char buffer; unused in this policy
103 * \retval -ENOMEM OOM error
106 * \see nrs_policy_register()
107 * \see nrs_policy_ctl()
109 static int nrs_delay_start(struct ptlrpc_nrs_policy *policy, char *arg)
111 struct nrs_delay_data *delay_data;
115 OBD_CPT_ALLOC_PTR(delay_data, nrs_pol2cptab(policy),
116 nrs_pol2cptid(policy));
117 if (delay_data == NULL)
120 delay_data->delay_binheap = cfs_binheap_create(&nrs_delay_heap_ops,
121 CBH_FLAG_ATOMIC_GROW,
123 nrs_pol2cptab(policy),
124 nrs_pol2cptid(policy));
126 if (delay_data->delay_binheap == NULL) {
127 OBD_FREE_PTR(delay_data);
131 delay_data->min_delay = NRS_DELAY_MIN_DEFAULT;
132 delay_data->max_delay = NRS_DELAY_MAX_DEFAULT;
133 delay_data->delay_pct = NRS_DELAY_PCT_DEFAULT;
135 policy->pol_private = delay_data;
141 * Is called before the policy transitions into
142 * ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED; deallocates the delay-specific
143 * private data structure.
145 * \param[in] policy The policy to stop
147 * \see nrs_policy_stop0()
149 static void nrs_delay_stop(struct ptlrpc_nrs_policy *policy)
151 struct nrs_delay_data *delay_data = policy->pol_private;
153 LASSERT(delay_data != NULL);
154 LASSERT(delay_data->delay_binheap != NULL);
155 LASSERT(cfs_binheap_is_empty(delay_data->delay_binheap));
157 cfs_binheap_destroy(delay_data->delay_binheap);
159 OBD_FREE_PTR(delay_data);
163 * Is called for obtaining a delay policy resource.
165 * \param[in] policy The policy on which the request is being asked for
166 * \param[in] nrq The request for which resources are being taken
167 * \param[in] parent Parent resource, unused in this policy
168 * \param[out] resp Resources references are placed in this array
169 * \param[in] moving_req Signifies limited caller context; unused in this
172 * \retval 1 The delay policy only has a one-level resource hierarchy
174 * \see nrs_resource_get_safe()
176 static int nrs_delay_res_get(struct ptlrpc_nrs_policy *policy,
177 struct ptlrpc_nrs_request *nrq,
178 const struct ptlrpc_nrs_resource *parent,
179 struct ptlrpc_nrs_resource **resp, bool moving_req)
182 * Just return the resource embedded inside nrs_delay_data, and end this
183 * resource hierarchy reference request.
185 *resp = &((struct nrs_delay_data *)policy->pol_private)->delay_res;
190 * Called when getting a request from the delay policy for handling, or just
191 * peeking; removes the request from the policy when it is to be handled.
192 * Requests are only removed from this policy when their start time has
195 * \param[in] policy The policy
196 * \param[in] peek When set, signifies that we just want to examine the
197 * request, and not handle it, so the request is not removed
199 * \param[in] force Force the policy to return a request
201 * \retval The request to be handled
202 * \retval NULL no request available
204 * \see ptlrpc_nrs_req_get_nolock()
205 * \see nrs_request_get()
208 struct ptlrpc_nrs_request *nrs_delay_req_get(struct ptlrpc_nrs_policy *policy,
209 bool peek, bool force)
211 struct nrs_delay_data *delay_data = policy->pol_private;
212 struct cfs_binheap_node *node;
213 struct ptlrpc_nrs_request *nrq;
215 node = cfs_binheap_root(delay_data->delay_binheap);
216 nrq = unlikely(node == NULL) ? NULL :
217 container_of(node, struct ptlrpc_nrs_request, nr_node);
219 if (likely(nrq != NULL)) {
221 ktime_get_real_seconds() < nrq->nr_u.delay.req_start_time)
223 else if (likely(!peek))
224 cfs_binheap_remove(delay_data->delay_binheap,
232 * Adds request \a nrq to a delay \a policy instance's set of queued requests
234 * A percentage (delay_pct) of incoming requests are delayed by this policy.
235 * If selected for delay a request start time is calculated. A start time
236 * is the current time plus a random offset in the range [min_delay, max_delay]
237 * The start time is recorded in the request, and is then used by
238 * delay_req_compare() to maintain a set of requests ordered by their start
241 * \param[in] policy The policy
242 * \param[in] nrq The request to add
244 * \retval 0 request added
245 * \retval 1 request not added
248 static int nrs_delay_req_add(struct ptlrpc_nrs_policy *policy,
249 struct ptlrpc_nrs_request *nrq)
251 struct nrs_delay_data *delay_data = policy->pol_private;
253 if (delay_data->delay_pct == 0 || /* Not delaying anything */
254 (delay_data->delay_pct != 100 &&
255 delay_data->delay_pct < cfs_rand() % 100))
258 nrq->nr_u.delay.req_start_time = ktime_get_real_seconds() + cfs_rand() %
259 (delay_data->max_delay -
260 delay_data->min_delay + 1) +
261 delay_data->min_delay;
263 return cfs_binheap_insert(delay_data->delay_binheap, &nrq->nr_node);
267 * Removes request \a nrq from \a policy's list of queued requests.
269 * \param[in] policy The policy
270 * \param[in] nrq The request to remove
272 static void nrs_delay_req_del(struct ptlrpc_nrs_policy *policy,
273 struct ptlrpc_nrs_request *nrq)
275 struct nrs_delay_data *delay_data = policy->pol_private;
277 cfs_binheap_remove(delay_data->delay_binheap, &nrq->nr_node);
281 * Prints a debug statement right before the request \a nrq stops being
284 * \param[in] policy The policy handling the request
285 * \param[in] nrq The request being handled
287 * \see ptlrpc_server_finish_request()
288 * \see ptlrpc_nrs_req_stop_nolock()
290 static void nrs_delay_req_stop(struct ptlrpc_nrs_policy *policy,
291 struct ptlrpc_nrs_request *nrq)
293 struct ptlrpc_request *req = container_of(nrq, struct ptlrpc_request,
296 DEBUG_REQ(D_RPCTRACE, req,
297 "NRS: finished delayed request from %s after %llds",
298 libcfs_id2str(req->rq_peer),
299 (s64)(nrq->nr_u.delay.req_start_time -
300 req->rq_srv.sr_arrival_time.tv_sec));
304 * Performs ctl functions specific to delay policy instances; similar to ioctl
306 * \param[in] policy the policy instance
307 * \param[in] opc the opcode
308 * \param[in,out] arg used for passing parameters and information
310 * \pre assert_spin_locked(&policy->pol_nrs->->nrs_lock)
311 * \post assert_spin_locked(&policy->pol_nrs->->nrs_lock)
313 * \retval 0 operation carried out successfully
316 static int nrs_delay_ctl(struct ptlrpc_nrs_policy *policy,
317 enum ptlrpc_nrs_ctl opc, void *arg)
319 struct nrs_delay_data *delay_data = policy->pol_private;
320 __u32 *val = (__u32 *)arg;
322 assert_spin_locked(&policy->pol_nrs->nrs_lock);
324 switch ((enum nrs_ctl_delay)opc) {
328 case NRS_CTL_DELAY_RD_MIN:
329 *val = delay_data->min_delay;
332 case NRS_CTL_DELAY_WR_MIN:
333 if (*val > delay_data->max_delay)
336 delay_data->min_delay = *val;
339 case NRS_CTL_DELAY_RD_MAX:
340 *val = delay_data->max_delay;
343 case NRS_CTL_DELAY_WR_MAX:
344 if (*val < delay_data->min_delay)
347 delay_data->max_delay = *val;
350 case NRS_CTL_DELAY_RD_PCT:
351 *val = delay_data->delay_pct;
354 case NRS_CTL_DELAY_WR_PCT:
355 if (*val < 0 || *val > 100)
358 delay_data->delay_pct = *val;
368 /* nrs_delay_min and nrs_delay_max are bounded by these values */
369 #define LPROCFS_NRS_DELAY_LOWER_BOUND 0
370 #define LPROCFS_NRS_DELAY_UPPER_BOUND 65535
372 #define LPROCFS_NRS_DELAY_MIN_NAME "delay_min:"
373 #define LPROCFS_NRS_DELAY_MIN_NAME_REG "reg_delay_min:"
374 #define LPROCFS_NRS_DELAY_MIN_NAME_HP "hp_delay_min:"
377 * Max size of the nrs_delay_min seq_write buffer. Needs to be large enough
378 * to hold the string: "reg_min_delay:65535 hp_min_delay:65535"
380 #define LPROCFS_NRS_DELAY_MIN_SIZE \
381 sizeof(LPROCFS_NRS_DELAY_MIN_NAME_REG \
382 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND) \
383 " " LPROCFS_NRS_DELAY_MIN_NAME_HP \
384 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND))
386 #define LPROCFS_NRS_DELAY_MAX_NAME "delay_max:"
387 #define LPROCFS_NRS_DELAY_MAX_NAME_REG "reg_delay_max:"
388 #define LPROCFS_NRS_DELAY_MAX_NAME_HP "hp_delay_max:"
391 * Similar to LPROCFS_NRS_DELAY_MIN_SIZE above, but for the nrs_delay_max
394 #define LPROCFS_NRS_DELAY_MAX_SIZE \
395 sizeof(LPROCFS_NRS_DELAY_MAX_NAME_REG \
396 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND) \
397 " " LPROCFS_NRS_DELAY_MAX_NAME_HP \
398 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND))
400 #define LPROCFS_NRS_DELAY_PCT_MIN_VAL 0
401 #define LPROCFS_NRS_DELAY_PCT_MAX_VAL 100
402 #define LPROCFS_NRS_DELAY_PCT_NAME "delay_pct:"
403 #define LPROCFS_NRS_DELAY_PCT_NAME_REG "reg_delay_pct:"
404 #define LPROCFS_NRS_DELAY_PCT_NAME_HP "hp_delay_pct:"
407 * Similar to LPROCFS_NRS_DELAY_MIN_SIZE above, but for the nrs_delay_pct
410 #define LPROCFS_NRS_DELAY_PCT_SIZE \
411 sizeof(LPROCFS_NRS_DELAY_PCT_NAME_REG \
412 __stringify(LPROCFS_NRS_DELAY_PCT_MAX_VAL) \
413 " " LPROCFS_NRS_DELAY_PCT_NAME_HP \
414 __stringify(LPROCFS_NRS_DELAY_PCT_MAX_VAL))
417 * Helper for delay's seq_write functions.
420 lprocfs_nrs_delay_seq_write_common(const char __user *buffer,
421 unsigned int bufsize, size_t count,
422 const char *var_name, unsigned int min_val,
423 unsigned int max_val,
424 struct ptlrpc_service *svc, char *pol_name,
425 enum ptlrpc_nrs_ctl opc, bool single)
427 enum ptlrpc_nrs_queue_type queue = 0;
430 long unsigned int val_reg;
431 long unsigned int val_hp;
437 if (count > bufsize - 1)
440 OBD_ALLOC(kernbuf, bufsize);
444 if (copy_from_user(kernbuf, buffer, count))
445 GOTO(free_kernbuf, rc = -EFAULT);
447 tmpsize = strlen("reg_") + strlen(var_name) + 1;
448 OBD_ALLOC(tmp, tmpsize);
450 GOTO(free_tmp, rc = -ENOMEM);
452 /* look for "reg_<var_name>" in kernbuf */
453 snprintf(tmp, tmpsize, "reg_%s", var_name);
455 val_str = lprocfs_find_named_value(kernbuf, tmp, &count_copy);
456 if (val_str != kernbuf) {
457 rc = kstrtoul(val_str, 10, &val_reg);
459 GOTO(free_tmp, rc = -EINVAL);
460 queue |= PTLRPC_NRS_QUEUE_REG;
463 /* look for "hp_<var_name>" in kernbuf */
464 snprintf(tmp, tmpsize, "hp_%s", var_name);
466 val_str = lprocfs_find_named_value(kernbuf, tmp, &count_copy);
467 if (val_str != kernbuf) {
468 if (!nrs_svc_has_hp(svc))
469 GOTO(free_tmp, rc = -ENODEV);
471 rc = kstrtoul(val_str, 10, &val_hp);
473 GOTO(free_tmp, rc = -EINVAL);
474 queue |= PTLRPC_NRS_QUEUE_HP;
478 if (!isdigit(kernbuf[0]))
479 GOTO(free_tmp, rc = -EINVAL);
481 rc = kstrtoul(kernbuf, 10, &val_reg);
483 GOTO(free_tmp, rc = -EINVAL);
485 queue = PTLRPC_NRS_QUEUE_REG;
487 if (nrs_svc_has_hp(svc)) {
488 queue |= PTLRPC_NRS_QUEUE_HP;
493 if (queue & PTLRPC_NRS_QUEUE_REG) {
494 if (val_reg > max_val || val_reg < min_val)
495 GOTO(free_tmp, rc = -EINVAL);
497 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
498 pol_name, opc, single, &val_reg);
499 if ((rc < 0 && rc != -ENODEV) ||
500 (rc == -ENODEV && queue == PTLRPC_NRS_QUEUE_REG))
504 if (queue & PTLRPC_NRS_QUEUE_HP) {
506 if (val_hp > max_val || val_hp < min_val)
507 GOTO(free_tmp, rc = -EINVAL);
509 rc2 = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
510 pol_name, opc, single, &val_hp);
511 if ((rc2 < 0 && rc2 != -ENODEV) ||
512 (rc2 == -ENODEV && queue == PTLRPC_NRS_QUEUE_HP))
513 GOTO(free_tmp, rc = rc2);
516 /* If we've reached here then we want to return count */
520 OBD_FREE(tmp, tmpsize);
522 OBD_FREE(kernbuf, bufsize);
528 * Retrieves the value of the minimum delay for delay policy instances on both
529 * the regular and high-priority NRS head of a service, as long as a policy
530 * instance is not in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state;
533 ptlrpc_lprocfs_nrs_delay_min_seq_show(struct seq_file *m, void *data)
535 struct ptlrpc_service *svc = m->private;
536 unsigned int min_delay;
539 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
541 NRS_CTL_DELAY_RD_MIN,
545 seq_printf(m, LPROCFS_NRS_DELAY_MIN_NAME_REG"%-5d\n",
548 * Ignore -ENODEV as the regular NRS head's policy may be in
549 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
551 else if (rc != -ENODEV)
554 if (!nrs_svc_has_hp(svc))
557 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
559 NRS_CTL_DELAY_RD_MIN,
562 seq_printf(m, LPROCFS_NRS_DELAY_MIN_NAME_HP"%-5d\n",
565 * Ignore -ENODEV as the regular NRS head's policy may be in
566 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
568 else if (rc == -ENODEV)
575 * Sets the value of the minimum request delay for delay policy instances of a
576 * service. The user can set the minimum request delay for the regular or high
577 * priority NRS head individually by specifying each value, or both together in
578 * a single invocation.
582 * lctl set_param *.*.*.nrs_delay_min=reg_delay_min:5, to set the regular
583 * request minimum delay on all PtlRPC services to 5 seconds
585 * lctl set_param *.*.*.nrs_delay_min=hp_delay_min:2, to set the high-priority
586 * request minimum delay on all PtlRPC services to 2 seconds, and
588 * lctl set_param *.*.ost_io.nrs_delay_min=8, to set both the regular and
589 * high priority request minimum delay of the ost_io service to 8 seconds.
592 ptlrpc_lprocfs_nrs_delay_min_seq_write(struct file *file,
593 const char __user *buffer, size_t count,
596 struct seq_file *m = file->private_data;
597 struct ptlrpc_service *svc = m->private;
599 return lprocfs_nrs_delay_seq_write_common(buffer,
600 LPROCFS_NRS_DELAY_MIN_SIZE,
602 LPROCFS_NRS_DELAY_MIN_NAME,
603 LPROCFS_NRS_DELAY_LOWER_BOUND,
604 LPROCFS_NRS_DELAY_UPPER_BOUND,
605 svc, NRS_POL_NAME_DELAY,
606 NRS_CTL_DELAY_WR_MIN, false);
608 LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_delay_min);
611 * Retrieves the value of the maximum delay for delay policy instances on both
612 * the regular and high-priority NRS head of a service, as long as a policy
613 * instance is not in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state;
616 ptlrpc_lprocfs_nrs_delay_max_seq_show(struct seq_file *m, void *data)
618 struct ptlrpc_service *svc = m->private;
619 unsigned int max_delay;
622 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
624 NRS_CTL_DELAY_RD_MAX,
628 seq_printf(m, LPROCFS_NRS_DELAY_MAX_NAME_REG"%-5d\n",
631 * Ignore -ENODEV as the regular NRS head's policy may be in
632 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
634 else if (rc != -ENODEV)
637 if (!nrs_svc_has_hp(svc))
640 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
642 NRS_CTL_DELAY_RD_MAX,
645 seq_printf(m, LPROCFS_NRS_DELAY_MAX_NAME_HP"%-5d\n",
648 * Ignore -ENODEV as the regular NRS head's policy may be in
649 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
651 else if (rc == -ENODEV)
658 * Sets the value of the maximum request delay for delay policy instances of a
659 * service. The user can set the maximum request delay for the regular or high
660 * priority NRS head individually by specifying each value, or both together in
661 * a single invocation.
665 * lctl set_param *.*.*.nrs_delay_max=reg_delay_max:20, to set the regular
666 * request maximum delay on all PtlRPC services to 20 seconds
668 * lctl set_param *.*.*.nrs_delay_max=hp_delay_max:10, to set the high-priority
669 * request maximum delay on all PtlRPC services to 10 seconds, and
671 * lctl set_param *.*.ost_io.nrs_delay_max=35, to set both the regular and
672 * high priority request maximum delay of the ost_io service to 35 seconds.
675 ptlrpc_lprocfs_nrs_delay_max_seq_write(struct file *file,
676 const char __user *buffer, size_t count,
679 struct seq_file *m = file->private_data;
680 struct ptlrpc_service *svc = m->private;
682 return lprocfs_nrs_delay_seq_write_common(buffer,
683 LPROCFS_NRS_DELAY_MAX_SIZE,
685 LPROCFS_NRS_DELAY_MAX_NAME,
686 LPROCFS_NRS_DELAY_LOWER_BOUND,
687 LPROCFS_NRS_DELAY_UPPER_BOUND,
688 svc, NRS_POL_NAME_DELAY,
689 NRS_CTL_DELAY_WR_MAX, false);
691 LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_delay_max);
694 * Retrieves the value of the percentage of requests which should be delayed
695 * for delay policy instances on both the regular and high-priority NRS head
696 * of a service, as long as a policy instance is not in the
697 * ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state;
700 ptlrpc_lprocfs_nrs_delay_pct_seq_show(struct seq_file *m, void *data)
702 struct ptlrpc_service *svc = m->private;
703 unsigned int delay_pct;
706 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
708 NRS_CTL_DELAY_RD_PCT,
712 seq_printf(m, LPROCFS_NRS_DELAY_PCT_NAME_REG"%-3d\n",
715 * Ignore -ENODEV as the regular NRS head's policy may be in
716 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
718 else if (rc != -ENODEV)
721 if (!nrs_svc_has_hp(svc))
724 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
726 NRS_CTL_DELAY_RD_PCT,
729 seq_printf(m, LPROCFS_NRS_DELAY_PCT_NAME_HP"%-3d\n",
732 * Ignore -ENODEV as the regular NRS head's policy may be in
733 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
735 else if (rc == -ENODEV)
742 * Sets the value of the percentage of requests to be delayed for delay policy
743 * instances of a service. The user can set the percentage for the regular or
744 * high-priority NRS head individually by specifying each value, or both
745 * together in a single invocation.
749 * lctl set_param *.*.*.nrs_delay_pct=reg_delay_pct:5, to delay 5 percent of
750 * regular requests on all PtlRPC services
752 * lctl set_param *.*.*.nrs_delay_pct=hp_delay_pct:2, to delay 2 percent of
753 * high-priority requests on all PtlRPC services, and
755 * lctl set_param *.*.ost_io.nrs_delay_pct=8, to delay 8 percent of both
756 * regular and high-priority requests of the ost_io service.
759 ptlrpc_lprocfs_nrs_delay_pct_seq_write(struct file *file,
760 const char __user *buffer, size_t count,
763 struct seq_file *m = file->private_data;
764 struct ptlrpc_service *svc = m->private;
766 return lprocfs_nrs_delay_seq_write_common(buffer,
767 LPROCFS_NRS_DELAY_PCT_SIZE,
769 LPROCFS_NRS_DELAY_PCT_NAME,
770 LPROCFS_NRS_DELAY_PCT_MIN_VAL,
771 LPROCFS_NRS_DELAY_PCT_MAX_VAL,
772 svc, NRS_POL_NAME_DELAY,
773 NRS_CTL_DELAY_WR_PCT, false);
776 LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_delay_pct);
778 static int nrs_delay_lprocfs_init(struct ptlrpc_service *svc)
780 struct lprocfs_vars nrs_delay_lprocfs_vars[] = {
781 { .name = "nrs_delay_min",
782 .fops = &ptlrpc_lprocfs_nrs_delay_min_fops,
784 { .name = "nrs_delay_max",
785 .fops = &ptlrpc_lprocfs_nrs_delay_max_fops,
787 { .name = "nrs_delay_pct",
788 .fops = &ptlrpc_lprocfs_nrs_delay_pct_fops,
793 if (IS_ERR_OR_NULL(svc->srv_debugfs_entry))
796 return ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_delay_lprocfs_vars,
801 * Delay policy operations
803 static const struct ptlrpc_nrs_pol_ops nrs_delay_ops = {
804 .op_policy_start = nrs_delay_start,
805 .op_policy_stop = nrs_delay_stop,
806 .op_policy_ctl = nrs_delay_ctl,
807 .op_res_get = nrs_delay_res_get,
808 .op_req_get = nrs_delay_req_get,
809 .op_req_enqueue = nrs_delay_req_add,
810 .op_req_dequeue = nrs_delay_req_del,
811 .op_req_stop = nrs_delay_req_stop,
812 .op_lprocfs_init = nrs_delay_lprocfs_init,
816 * Delay policy configuration
818 struct ptlrpc_nrs_pol_conf nrs_conf_delay = {
819 .nc_name = NRS_POL_NAME_DELAY,
820 .nc_ops = &nrs_delay_ops,
821 .nc_compat = nrs_policy_compat_all,