Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\blk-throttle.c Create Date:2022-07-28 17:43:49
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:tg_set_limit

Proto:static ssize_t tg_set_limit(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off)

Type:ssize_t

Parameter:

TypeParameterName
struct kernfs_open_file *of
char *buf
size_tnbytes
loff_toff
1632  blkcg = css_to_blkcg(of_css(of))
1639  index = private
1641  ret = lkg_conf_prep - parse and prepare for per-blkg config update*@blkcg: target block cgroup*@pol: target policy*@input: input string*@ctx: blkg_conf_ctx to be filled* Parse per-blkg config update from @input and initialize @ctx with the* result
1642  If ret Then Return ret
1645  tg = blkg_to_tg(blkg)
1647  v[0] = user configured bps limits [generic data direction definitions ][index]
1648  v[1] = user configured bps limits [WRITE][index]
1649  v[2] = user configured IOPS limits [generic data direction definitions ][index]
1650  v[3] = user configured IOPS limits [WRITE][index]
1652  idle_time = us
1653  latency_time = us
1654  When (true) cycle
1657  val = U64_MAX
1660  If sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments != 1 Then Break
1662  If tok[0] == '\0' Then Break
1664  body += len
1666  ret = -EINVAL
1667  p = tok
1668  strsep - Split a string into tokens*@s: The string to be searched*@ct: The characters to search for* strsep() updates @s to point after the token, ready for the next call.* It returns empty tokens, too, behaving exactly like the libc function
1669  If Not p || sscanf - Unformat a buffer into a list of arguments*@buf: input buffer*@fmt: formatting of buffer*@...: resulting arguments != 1 && strcmp(p, "max") Then Go to out_finish
1672  ret = -ERANGE
1673  If Not val Then Go to out_finish
1676  ret = -EINVAL
1677  If Not strcmp(tok, "rbps") Then v[0] = val
1679  Else if Not strcmp(tok, "wbps") Then v[1] = val
1681  Else if Not strcmp(tok, "riops") Then v[2] = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u64, val, UINT_MAX)
1683  Else if Not strcmp(tok, "wiops") Then v[3] = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u64, val, UINT_MAX)
1685  Else if off == LIMIT_LOW && Not strcmp(tok, "idle") Then idle_time = val
1687  Else if off == LIMIT_LOW && Not strcmp(tok, "latency") Then latency_time = val
1689  Else Go to out_finish
1693  user configured bps limits [generic data direction definitions ][index] = v[0]
1694  user configured bps limits [WRITE][index] = v[1]
1695  user configured IOPS limits [generic data direction definitions ][index] = v[2]
1696  user configured IOPS limits [WRITE][index] = v[3]
1698  If index == LIMIT_MAX Then
1699  internally used bytes per second rate limits [generic data direction definitions ][index] = v[0]
1700  internally used bytes per second rate limits [WRITE][index] = v[1]
1701  internally used IOPS limits [generic data direction definitions ][index] = v[2]
1702  internally used IOPS limits [WRITE][index] = v[3]
1704  internally used bytes per second rate limits [generic data direction definitions ][LIMIT_LOW] = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value( user configured bps limits [generic data direction definitions ][LIMIT_LOW], user configured bps limits [generic data direction definitions ][LIMIT_MAX])
1706  internally used bytes per second rate limits [WRITE][LIMIT_LOW] = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value( user configured bps limits [WRITE][LIMIT_LOW], user configured bps limits [WRITE][LIMIT_MAX])
1708  internally used IOPS limits [generic data direction definitions ][LIMIT_LOW] = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value( user configured IOPS limits [generic data direction definitions ][LIMIT_LOW], user configured IOPS limits [generic data direction definitions ][LIMIT_MAX])
1710  internally used IOPS limits [WRITE][LIMIT_LOW] = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value( user configured IOPS limits [WRITE][LIMIT_LOW], user configured IOPS limits [WRITE][LIMIT_MAX])
1712  us = idle_time
1713  us = latency_time
1716  If Not ( internally used bytes per second rate limits [generic data direction definitions ][LIMIT_LOW] || internally used IOPS limits [generic data direction definitions ][LIMIT_LOW] || internally used bytes per second rate limits [WRITE][LIMIT_LOW] || internally used IOPS limits [WRITE][LIMIT_LOW]) || us == DFL_IDLE_THRESHOLD || us == DFL_LATENCY_TARGET Then
1720  internally used bytes per second rate limits [generic data direction definitions ][LIMIT_LOW] = 0
1721  internally used bytes per second rate limits [WRITE][LIMIT_LOW] = 0
1722  internally used IOPS limits [generic data direction definitions ][LIMIT_LOW] = 0
1723  internally used IOPS limits [WRITE][LIMIT_LOW] = 0
1724  us = DFL_IDLE_THRESHOLD
1725  us = DFL_LATENCY_TARGET
1726  Else if index == LIMIT_LOW Then
1727  us = us
1728  us = us
1731  blk_throtl_update_limit_valid( throtl_data this group belongs to )
1732  If limit_valid[LIMIT_LOW] Then
1733  If index == LIMIT_LOW Then limit_index = LIMIT_LOW
1735  Else limit_index = LIMIT_MAX
1737  tg_conf_updated(tg, index == LIMIT_LOW && limit_valid[LIMIT_LOW])
1739  ret = 0
1740  out_finish :
1741  lkg_conf_finish - finish up per-blkg config update*@ctx: blkg_conf_ctx intiailized by blkg_conf_prep()* Finish up after per-blkg config update. This function must be paired* with blkg_conf_prep().
1742  Return If ret Else nbytes