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
43 #include <linux/random.h>
45 #include <obd_support.h>
46 #include <obd_class.h>
47 #include "ptlrpc_internal.h"
52 * The delay policy schedules RPCs so that they are only processed after some
53 * configurable amount of time (in seconds) has passed.
55 * The defaults were chosen arbitrarily.
60 #define NRS_POL_NAME_DELAY "delay"
62 /* Default minimum delay in seconds. */
63 #define NRS_DELAY_MIN_DEFAULT 5
64 /* Default maximum delay, in seconds. */
65 #define NRS_DELAY_MAX_DEFAULT 300
66 /* Default percentage of delayed RPCs. */
67 #define NRS_DELAY_PCT_DEFAULT 100
70 * Binary heap predicate.
72 * Elements are sorted according to the start time assigned to the requests
73 * upon enqueue. An element with an earlier start time is "less than" an
74 * element with a later start time.
76 * \retval 0 start_time(e1) > start_time(e2)
77 * \retval 1 start_time(e1) <= start_time(e2)
79 static int delay_req_compare(struct binheap_node *e1,
80 struct binheap_node *e2)
82 struct ptlrpc_nrs_request *nrq1;
83 struct ptlrpc_nrs_request *nrq2;
85 nrq1 = container_of(e1, struct ptlrpc_nrs_request, nr_node);
86 nrq2 = container_of(e2, struct ptlrpc_nrs_request, nr_node);
88 return nrq1->nr_u.delay.req_start_time <=
89 nrq2->nr_u.delay.req_start_time;
92 static struct binheap_ops nrs_delay_heap_ops = {
95 .hop_compare = delay_req_compare,
99 * Is called before the policy transitions into
100 * ptlrpc_nrs_pol_state::NRS_POL_STATE_STARTED; allocates and initializes
101 * the delay-specific private data structure.
103 * \param[in] policy The policy to start
104 * \param[in] Generic char buffer; unused in this policy
106 * \retval -ENOMEM OOM error
109 * \see nrs_policy_register()
110 * \see nrs_policy_ctl()
112 static int nrs_delay_start(struct ptlrpc_nrs_policy *policy, char *arg)
114 struct nrs_delay_data *delay_data;
118 OBD_CPT_ALLOC_PTR(delay_data, nrs_pol2cptab(policy),
119 nrs_pol2cptid(policy));
120 if (delay_data == NULL)
123 delay_data->delay_binheap = binheap_create(&nrs_delay_heap_ops,
124 CBH_FLAG_ATOMIC_GROW,
126 nrs_pol2cptab(policy),
127 nrs_pol2cptid(policy));
129 if (delay_data->delay_binheap == NULL) {
130 OBD_FREE_PTR(delay_data);
134 delay_data->min_delay = NRS_DELAY_MIN_DEFAULT;
135 delay_data->max_delay = NRS_DELAY_MAX_DEFAULT;
136 delay_data->delay_pct = NRS_DELAY_PCT_DEFAULT;
138 policy->pol_private = delay_data;
144 * Is called before the policy transitions into
145 * ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED; deallocates the delay-specific
146 * private data structure.
148 * \param[in] policy The policy to stop
150 * \see nrs_policy_stop0()
152 static void nrs_delay_stop(struct ptlrpc_nrs_policy *policy)
154 struct nrs_delay_data *delay_data = policy->pol_private;
156 LASSERT(delay_data != NULL);
157 LASSERT(delay_data->delay_binheap != NULL);
158 LASSERT(binheap_is_empty(delay_data->delay_binheap));
160 binheap_destroy(delay_data->delay_binheap);
162 OBD_FREE_PTR(delay_data);
166 * Is called for obtaining a delay policy resource.
168 * \param[in] policy The policy on which the request is being asked for
169 * \param[in] nrq The request for which resources are being taken
170 * \param[in] parent Parent resource, unused in this policy
171 * \param[out] resp Resources references are placed in this array
172 * \param[in] moving_req Signifies limited caller context; unused in this
175 * \retval 1 The delay policy only has a one-level resource hierarchy
177 * \see nrs_resource_get_safe()
179 static int nrs_delay_res_get(struct ptlrpc_nrs_policy *policy,
180 struct ptlrpc_nrs_request *nrq,
181 const struct ptlrpc_nrs_resource *parent,
182 struct ptlrpc_nrs_resource **resp, bool moving_req)
185 * Just return the resource embedded inside nrs_delay_data, and end this
186 * resource hierarchy reference request.
188 *resp = &((struct nrs_delay_data *)policy->pol_private)->delay_res;
193 * Called when getting a request from the delay policy for handling, or just
194 * peeking; removes the request from the policy when it is to be handled.
195 * Requests are only removed from this policy when their start time has
198 * \param[in] policy The policy
199 * \param[in] peek When set, signifies that we just want to examine the
200 * request, and not handle it, so the request is not removed
202 * \param[in] force Force the policy to return a request
204 * \retval The request to be handled
205 * \retval NULL no request available
207 * \see ptlrpc_nrs_req_get_nolock()
208 * \see nrs_request_get()
211 struct ptlrpc_nrs_request *nrs_delay_req_get(struct ptlrpc_nrs_policy *policy,
212 bool peek, bool force)
214 struct nrs_delay_data *delay_data = policy->pol_private;
215 struct binheap_node *node;
216 struct ptlrpc_nrs_request *nrq;
218 node = binheap_root(delay_data->delay_binheap);
219 nrq = unlikely(node == NULL) ? NULL :
220 container_of(node, struct ptlrpc_nrs_request, nr_node);
222 if (likely(nrq != NULL)) {
224 ktime_get_real_seconds() < nrq->nr_u.delay.req_start_time)
226 else if (likely(!peek))
227 binheap_remove(delay_data->delay_binheap,
235 * Adds request \a nrq to a delay \a policy instance's set of queued requests
237 * A percentage (delay_pct) of incoming requests are delayed by this policy.
238 * If selected for delay a request start time is calculated. A start time
239 * is the current time plus a random offset in the range [min_delay, max_delay]
240 * The start time is recorded in the request, and is then used by
241 * delay_req_compare() to maintain a set of requests ordered by their start
244 * \param[in] policy The policy
245 * \param[in] nrq The request to add
247 * \retval 0 request added
248 * \retval 1 request not added
251 static int nrs_delay_req_add(struct ptlrpc_nrs_policy *policy,
252 struct ptlrpc_nrs_request *nrq)
254 struct nrs_delay_data *delay_data = policy->pol_private;
256 if (delay_data->delay_pct == 0 || /* Not delaying anything */
257 (delay_data->delay_pct != 100 &&
258 delay_data->delay_pct < prandom_u32_max(100)))
261 nrq->nr_u.delay.req_start_time = ktime_get_real_seconds() +
262 prandom_u32_max(delay_data->max_delay - delay_data->min_delay + 1) +
263 delay_data->min_delay;
265 return binheap_insert(delay_data->delay_binheap, &nrq->nr_node);
269 * Removes request \a nrq from \a policy's list of queued requests.
271 * \param[in] policy The policy
272 * \param[in] nrq The request to remove
274 static void nrs_delay_req_del(struct ptlrpc_nrs_policy *policy,
275 struct ptlrpc_nrs_request *nrq)
277 struct nrs_delay_data *delay_data = policy->pol_private;
279 binheap_remove(delay_data->delay_binheap, &nrq->nr_node);
283 * Prints a debug statement right before the request \a nrq stops being
286 * \param[in] policy The policy handling the request
287 * \param[in] nrq The request being handled
289 * \see ptlrpc_server_finish_request()
290 * \see ptlrpc_nrs_req_stop_nolock()
292 static void nrs_delay_req_stop(struct ptlrpc_nrs_policy *policy,
293 struct ptlrpc_nrs_request *nrq)
295 struct ptlrpc_request *req = container_of(nrq, struct ptlrpc_request,
298 DEBUG_REQ(D_RPCTRACE, req,
299 "NRS: finished delayed request from %s after %llds",
300 libcfs_idstr(&req->rq_peer),
301 (s64)(nrq->nr_u.delay.req_start_time -
302 req->rq_srv.sr_arrival_time.tv_sec));
306 * Performs ctl functions specific to delay policy instances; similar to ioctl
308 * \param[in] policy the policy instance
309 * \param[in] opc the opcode
310 * \param[in,out] arg used for passing parameters and information
312 * \pre assert_spin_locked(&policy->pol_nrs->->nrs_lock)
313 * \post assert_spin_locked(&policy->pol_nrs->->nrs_lock)
315 * \retval 0 operation carried out successfully
318 static int nrs_delay_ctl(struct ptlrpc_nrs_policy *policy,
319 enum ptlrpc_nrs_ctl opc, void *arg)
321 struct nrs_delay_data *delay_data = policy->pol_private;
322 __u32 *val = (__u32 *)arg;
324 assert_spin_locked(&policy->pol_nrs->nrs_lock);
330 case NRS_CTL_DELAY_RD_MIN:
331 *val = delay_data->min_delay;
334 case NRS_CTL_DELAY_WR_MIN:
335 if (*val > delay_data->max_delay)
338 delay_data->min_delay = *val;
341 case NRS_CTL_DELAY_RD_MAX:
342 *val = delay_data->max_delay;
345 case NRS_CTL_DELAY_WR_MAX:
346 if (*val < delay_data->min_delay)
349 delay_data->max_delay = *val;
352 case NRS_CTL_DELAY_RD_PCT:
353 *val = delay_data->delay_pct;
356 case NRS_CTL_DELAY_WR_PCT:
357 if (*val < 0 || *val > 100)
360 delay_data->delay_pct = *val;
370 /* nrs_delay_min and nrs_delay_max are bounded by these values */
371 #define LPROCFS_NRS_DELAY_LOWER_BOUND 0
372 #define LPROCFS_NRS_DELAY_UPPER_BOUND 65535
374 #define LPROCFS_NRS_DELAY_MIN_NAME "delay_min:"
375 #define LPROCFS_NRS_DELAY_MIN_NAME_REG "reg_delay_min:"
376 #define LPROCFS_NRS_DELAY_MIN_NAME_HP "hp_delay_min:"
379 * Max size of the nrs_delay_min seq_write buffer. Needs to be large enough
380 * to hold the string: "reg_min_delay:65535 hp_min_delay:65535"
382 #define LPROCFS_NRS_DELAY_MIN_SIZE \
383 sizeof(LPROCFS_NRS_DELAY_MIN_NAME_REG \
384 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND) \
385 " " LPROCFS_NRS_DELAY_MIN_NAME_HP \
386 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND))
388 #define LPROCFS_NRS_DELAY_MAX_NAME "delay_max:"
389 #define LPROCFS_NRS_DELAY_MAX_NAME_REG "reg_delay_max:"
390 #define LPROCFS_NRS_DELAY_MAX_NAME_HP "hp_delay_max:"
393 * Similar to LPROCFS_NRS_DELAY_MIN_SIZE above, but for the nrs_delay_max
396 #define LPROCFS_NRS_DELAY_MAX_SIZE \
397 sizeof(LPROCFS_NRS_DELAY_MAX_NAME_REG \
398 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND) \
399 " " LPROCFS_NRS_DELAY_MAX_NAME_HP \
400 __stringify(LPROCFS_NRS_DELAY_UPPER_BOUND))
402 #define LPROCFS_NRS_DELAY_PCT_MIN_VAL 0
403 #define LPROCFS_NRS_DELAY_PCT_MAX_VAL 100
404 #define LPROCFS_NRS_DELAY_PCT_NAME "delay_pct:"
405 #define LPROCFS_NRS_DELAY_PCT_NAME_REG "reg_delay_pct:"
406 #define LPROCFS_NRS_DELAY_PCT_NAME_HP "hp_delay_pct:"
409 * Similar to LPROCFS_NRS_DELAY_MIN_SIZE above, but for the nrs_delay_pct
412 #define LPROCFS_NRS_DELAY_PCT_SIZE \
413 sizeof(LPROCFS_NRS_DELAY_PCT_NAME_REG \
414 __stringify(LPROCFS_NRS_DELAY_PCT_MAX_VAL) \
415 " " LPROCFS_NRS_DELAY_PCT_NAME_HP \
416 __stringify(LPROCFS_NRS_DELAY_PCT_MAX_VAL))
419 * Helper for delay's seq_write functions.
422 lprocfs_nrs_delay_seq_write_common(const char __user *buffer,
423 unsigned int bufsize, size_t count,
424 const char *var_name, unsigned int min_val,
425 unsigned int max_val,
426 struct ptlrpc_service *svc, char *pol_name,
427 enum ptlrpc_nrs_ctl opc, bool single)
429 enum ptlrpc_nrs_queue_type queue = 0;
432 long unsigned int val_reg;
433 long unsigned int val_hp;
439 if (count > bufsize - 1)
442 OBD_ALLOC(kernbuf, bufsize);
446 if (copy_from_user(kernbuf, buffer, count))
447 GOTO(free_kernbuf, rc = -EFAULT);
449 tmpsize = strlen("reg_") + strlen(var_name) + 1;
450 OBD_ALLOC(tmp, tmpsize);
452 GOTO(free_tmp, rc = -ENOMEM);
454 /* look for "reg_<var_name>" in kernbuf */
455 snprintf(tmp, tmpsize, "reg_%s", var_name);
457 val_str = lprocfs_find_named_value(kernbuf, tmp, &count_copy);
458 if (val_str != kernbuf) {
459 rc = kstrtoul(val_str, 10, &val_reg);
461 GOTO(free_tmp, rc = -EINVAL);
462 queue |= PTLRPC_NRS_QUEUE_REG;
465 /* look for "hp_<var_name>" in kernbuf */
466 snprintf(tmp, tmpsize, "hp_%s", var_name);
468 val_str = lprocfs_find_named_value(kernbuf, tmp, &count_copy);
469 if (val_str != kernbuf) {
470 if (!nrs_svc_has_hp(svc))
471 GOTO(free_tmp, rc = -ENODEV);
473 rc = kstrtoul(val_str, 10, &val_hp);
475 GOTO(free_tmp, rc = -EINVAL);
476 queue |= PTLRPC_NRS_QUEUE_HP;
480 if (!isdigit(kernbuf[0]))
481 GOTO(free_tmp, rc = -EINVAL);
483 rc = kstrtoul(kernbuf, 10, &val_reg);
485 GOTO(free_tmp, rc = -EINVAL);
487 queue = PTLRPC_NRS_QUEUE_REG;
489 if (nrs_svc_has_hp(svc)) {
490 queue |= PTLRPC_NRS_QUEUE_HP;
495 if (queue & PTLRPC_NRS_QUEUE_REG) {
496 if (val_reg > max_val || val_reg < min_val)
497 GOTO(free_tmp, rc = -EINVAL);
499 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
500 pol_name, opc, single, &val_reg);
501 if ((rc < 0 && rc != -ENODEV) ||
502 (rc == -ENODEV && queue == PTLRPC_NRS_QUEUE_REG))
506 if (queue & PTLRPC_NRS_QUEUE_HP) {
508 if (val_hp > max_val || val_hp < min_val)
509 GOTO(free_tmp, rc = -EINVAL);
511 rc2 = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
512 pol_name, opc, single, &val_hp);
513 if ((rc2 < 0 && rc2 != -ENODEV) ||
514 (rc2 == -ENODEV && queue == PTLRPC_NRS_QUEUE_HP))
515 GOTO(free_tmp, rc = rc2);
518 /* If we've reached here then we want to return count */
522 OBD_FREE(tmp, tmpsize);
524 OBD_FREE(kernbuf, bufsize);
530 * Retrieves the value of the minimum delay for delay policy instances on both
531 * the regular and high-priority NRS head of a service, as long as a policy
532 * instance is not in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state;
535 ptlrpc_lprocfs_nrs_delay_min_seq_show(struct seq_file *m, void *data)
537 struct ptlrpc_service *svc = m->private;
538 unsigned int min_delay;
541 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
543 NRS_CTL_DELAY_RD_MIN,
547 seq_printf(m, LPROCFS_NRS_DELAY_MIN_NAME_REG"%-5d\n",
550 * Ignore -ENODEV as the regular NRS head's policy may be in
551 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
553 else if (rc != -ENODEV)
556 if (!nrs_svc_has_hp(svc))
559 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
561 NRS_CTL_DELAY_RD_MIN,
564 seq_printf(m, LPROCFS_NRS_DELAY_MIN_NAME_HP"%-5d\n",
567 * Ignore -ENODEV as the regular NRS head's policy may be in
568 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
570 else if (rc == -ENODEV)
577 * Sets the value of the minimum request delay for delay policy instances of a
578 * service. The user can set the minimum request delay for the regular or high
579 * priority NRS head individually by specifying each value, or both together in
580 * a single invocation.
584 * lctl set_param *.*.*.nrs_delay_min=reg_delay_min:5, to set the regular
585 * request minimum delay on all PtlRPC services to 5 seconds
587 * lctl set_param *.*.*.nrs_delay_min=hp_delay_min:2, to set the high-priority
588 * request minimum delay on all PtlRPC services to 2 seconds, and
590 * lctl set_param *.*.ost_io.nrs_delay_min=8, to set both the regular and
591 * high priority request minimum delay of the ost_io service to 8 seconds.
594 ptlrpc_lprocfs_nrs_delay_min_seq_write(struct file *file,
595 const char __user *buffer, size_t count,
598 struct seq_file *m = file->private_data;
599 struct ptlrpc_service *svc = m->private;
601 return lprocfs_nrs_delay_seq_write_common(buffer,
602 LPROCFS_NRS_DELAY_MIN_SIZE,
604 LPROCFS_NRS_DELAY_MIN_NAME,
605 LPROCFS_NRS_DELAY_LOWER_BOUND,
606 LPROCFS_NRS_DELAY_UPPER_BOUND,
607 svc, NRS_POL_NAME_DELAY,
608 NRS_CTL_DELAY_WR_MIN, false);
610 LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_delay_min);
613 * Retrieves the value of the maximum delay for delay policy instances on both
614 * the regular and high-priority NRS head of a service, as long as a policy
615 * instance is not in the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state;
618 ptlrpc_lprocfs_nrs_delay_max_seq_show(struct seq_file *m, void *data)
620 struct ptlrpc_service *svc = m->private;
621 unsigned int max_delay;
624 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
626 NRS_CTL_DELAY_RD_MAX,
630 seq_printf(m, LPROCFS_NRS_DELAY_MAX_NAME_REG"%-5d\n",
633 * Ignore -ENODEV as the regular NRS head's policy may be in
634 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
636 else if (rc != -ENODEV)
639 if (!nrs_svc_has_hp(svc))
642 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
644 NRS_CTL_DELAY_RD_MAX,
647 seq_printf(m, LPROCFS_NRS_DELAY_MAX_NAME_HP"%-5d\n",
650 * Ignore -ENODEV as the regular NRS head's policy may be in
651 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
653 else if (rc == -ENODEV)
660 * Sets the value of the maximum request delay for delay policy instances of a
661 * service. The user can set the maximum request delay for the regular or high
662 * priority NRS head individually by specifying each value, or both together in
663 * a single invocation.
667 * lctl set_param *.*.*.nrs_delay_max=reg_delay_max:20, to set the regular
668 * request maximum delay on all PtlRPC services to 20 seconds
670 * lctl set_param *.*.*.nrs_delay_max=hp_delay_max:10, to set the high-priority
671 * request maximum delay on all PtlRPC services to 10 seconds, and
673 * lctl set_param *.*.ost_io.nrs_delay_max=35, to set both the regular and
674 * high priority request maximum delay of the ost_io service to 35 seconds.
677 ptlrpc_lprocfs_nrs_delay_max_seq_write(struct file *file,
678 const char __user *buffer, size_t count,
681 struct seq_file *m = file->private_data;
682 struct ptlrpc_service *svc = m->private;
684 return lprocfs_nrs_delay_seq_write_common(buffer,
685 LPROCFS_NRS_DELAY_MAX_SIZE,
687 LPROCFS_NRS_DELAY_MAX_NAME,
688 LPROCFS_NRS_DELAY_LOWER_BOUND,
689 LPROCFS_NRS_DELAY_UPPER_BOUND,
690 svc, NRS_POL_NAME_DELAY,
691 NRS_CTL_DELAY_WR_MAX, false);
693 LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_delay_max);
696 * Retrieves the value of the percentage of requests which should be delayed
697 * for delay policy instances on both the regular and high-priority NRS head
698 * of a service, as long as a policy instance is not in the
699 * ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state;
702 ptlrpc_lprocfs_nrs_delay_pct_seq_show(struct seq_file *m, void *data)
704 struct ptlrpc_service *svc = m->private;
705 unsigned int delay_pct;
708 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_REG,
710 NRS_CTL_DELAY_RD_PCT,
714 seq_printf(m, LPROCFS_NRS_DELAY_PCT_NAME_REG"%-3d\n",
717 * Ignore -ENODEV as the regular NRS head's policy may be in
718 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
720 else if (rc != -ENODEV)
723 if (!nrs_svc_has_hp(svc))
726 rc = ptlrpc_nrs_policy_control(svc, PTLRPC_NRS_QUEUE_HP,
728 NRS_CTL_DELAY_RD_PCT,
731 seq_printf(m, LPROCFS_NRS_DELAY_PCT_NAME_HP"%-3d\n",
734 * Ignore -ENODEV as the regular NRS head's policy may be in
735 * the ptlrpc_nrs_pol_state::NRS_POL_STATE_STOPPED state.
737 else if (rc == -ENODEV)
744 * Sets the value of the percentage of requests to be delayed for delay policy
745 * instances of a service. The user can set the percentage for the regular or
746 * high-priority NRS head individually by specifying each value, or both
747 * together in a single invocation.
751 * lctl set_param *.*.*.nrs_delay_pct=reg_delay_pct:5, to delay 5 percent of
752 * regular requests on all PtlRPC services
754 * lctl set_param *.*.*.nrs_delay_pct=hp_delay_pct:2, to delay 2 percent of
755 * high-priority requests on all PtlRPC services, and
757 * lctl set_param *.*.ost_io.nrs_delay_pct=8, to delay 8 percent of both
758 * regular and high-priority requests of the ost_io service.
761 ptlrpc_lprocfs_nrs_delay_pct_seq_write(struct file *file,
762 const char __user *buffer, size_t count,
765 struct seq_file *m = file->private_data;
766 struct ptlrpc_service *svc = m->private;
768 return lprocfs_nrs_delay_seq_write_common(buffer,
769 LPROCFS_NRS_DELAY_PCT_SIZE,
771 LPROCFS_NRS_DELAY_PCT_NAME,
772 LPROCFS_NRS_DELAY_PCT_MIN_VAL,
773 LPROCFS_NRS_DELAY_PCT_MAX_VAL,
774 svc, NRS_POL_NAME_DELAY,
775 NRS_CTL_DELAY_WR_PCT, false);
778 LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_delay_pct);
780 static int nrs_delay_lprocfs_init(struct ptlrpc_service *svc)
782 struct ldebugfs_vars nrs_delay_lprocfs_vars[] = {
783 { .name = "nrs_delay_min",
784 .fops = &ptlrpc_lprocfs_nrs_delay_min_fops,
786 { .name = "nrs_delay_max",
787 .fops = &ptlrpc_lprocfs_nrs_delay_max_fops,
789 { .name = "nrs_delay_pct",
790 .fops = &ptlrpc_lprocfs_nrs_delay_pct_fops,
795 if (!svc->srv_debugfs_entry)
798 ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_delay_lprocfs_vars, NULL);
804 * Delay policy operations
806 static const struct ptlrpc_nrs_pol_ops nrs_delay_ops = {
807 .op_policy_start = nrs_delay_start,
808 .op_policy_stop = nrs_delay_stop,
809 .op_policy_ctl = nrs_delay_ctl,
810 .op_res_get = nrs_delay_res_get,
811 .op_req_get = nrs_delay_req_get,
812 .op_req_enqueue = nrs_delay_req_add,
813 .op_req_dequeue = nrs_delay_req_del,
814 .op_req_stop = nrs_delay_req_stop,
815 .op_lprocfs_init = nrs_delay_lprocfs_init,
819 * Delay policy configuration
821 struct ptlrpc_nrs_pol_conf nrs_conf_delay = {
822 .nc_name = NRS_POL_NAME_DELAY,
823 .nc_ops = &nrs_delay_ops,
824 .nc_compat = nrs_policy_compat_all,