License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-01-29 21:51:59 +08:00
|
|
|
/*
|
|
|
|
* Functions related to sysfs handling
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-01-29 21:51:59 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/bio.h>
|
|
|
|
#include <linux/blkdev.h>
|
2015-05-23 05:13:32 +08:00
|
|
|
#include <linux/backing-dev.h>
|
2008-01-29 21:51:59 +08:00
|
|
|
#include <linux/blktrace_api.h>
|
blk-mq: new multi-queue block IO queueing mechanism
Linux currently has two models for block devices:
- The classic request_fn based approach, where drivers use struct
request units for IO. The block layer provides various helper
functionalities to let drivers share code, things like tag
management, timeout handling, queueing, etc.
- The "stacked" approach, where a driver squeezes in between the
block layer and IO submitter. Since this bypasses the IO stack,
driver generally have to manage everything themselves.
With drivers being written for new high IOPS devices, the classic
request_fn based driver doesn't work well enough. The design dates
back to when both SMP and high IOPS was rare. It has problems with
scaling to bigger machines, and runs into scaling issues even on
smaller machines when you have IOPS in the hundreds of thousands
per device.
The stacked approach is then most often selected as the model
for the driver. But this means that everybody has to re-invent
everything, and along with that we get all the problems again
that the shared approach solved.
This commit introduces blk-mq, block multi queue support. The
design is centered around per-cpu queues for queueing IO, which
then funnel down into x number of hardware submission queues.
We might have a 1:1 mapping between the two, or it might be
an N:M mapping. That all depends on what the hardware supports.
blk-mq provides various helper functions, which include:
- Scalable support for request tagging. Most devices need to
be able to uniquely identify a request both in the driver and
to the hardware. The tagging uses per-cpu caches for freed
tags, to enable cache hot reuse.
- Timeout handling without tracking request on a per-device
basis. Basically the driver should be able to get a notification,
if a request happens to fail.
- Optional support for non 1:1 mappings between issue and
submission queues. blk-mq can redirect IO completions to the
desired location.
- Support for per-request payloads. Drivers almost always need
to associate a request structure with some driver private
command structure. Drivers can tell blk-mq this at init time,
and then any request handed to the driver will have the
required size of memory associated with it.
- Support for merging of IO, and plugging. The stacked model
gets neither of these. Even for high IOPS devices, merging
sequential IO reduces per-command overhead and thus
increases bandwidth.
For now, this is provided as a potential 3rd queueing model, with
the hope being that, as it matures, it can replace both the classic
and stacked model. That would get us back to having just 1 real
model for block devices, leaving the stacked approach to dm/md
devices (as it was originally intended).
Contributions in this patch from the following people:
Shaohua Li <shli@fusionio.com>
Alexander Gordeev <agordeev@redhat.com>
Christoph Hellwig <hch@infradead.org>
Mike Christie <michaelc@cs.wisc.edu>
Matias Bjorling <m@bjorling.me>
Jeff Moyer <jmoyer@redhat.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2013-10-24 16:20:05 +08:00
|
|
|
#include <linux/blk-mq.h>
|
2015-05-23 05:13:17 +08:00
|
|
|
#include <linux/blk-cgroup.h>
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
#include "blk.h"
|
2013-12-26 21:31:38 +08:00
|
|
|
#include "blk-mq.h"
|
2017-05-04 15:31:30 +08:00
|
|
|
#include "blk-mq-debugfs.h"
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
#include "blk-wbt.h"
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
struct queue_sysfs_entry {
|
|
|
|
struct attribute attr;
|
|
|
|
ssize_t (*show)(struct request_queue *, char *);
|
|
|
|
ssize_t (*store)(struct request_queue *, const char *, size_t);
|
|
|
|
};
|
|
|
|
|
|
|
|
static ssize_t
|
2009-07-17 15:26:26 +08:00
|
|
|
queue_var_show(unsigned long var, char *page)
|
2008-01-29 21:51:59 +08:00
|
|
|
{
|
2009-07-17 15:26:26 +08:00
|
|
|
return sprintf(page, "%lu\n", var);
|
2008-01-29 21:51:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
queue_var_store(unsigned long *var, const char *page, size_t count)
|
|
|
|
{
|
2012-09-08 23:55:45 +08:00
|
|
|
int err;
|
|
|
|
unsigned long v;
|
|
|
|
|
2013-09-12 05:20:08 +08:00
|
|
|
err = kstrtoul(page, 10, &v);
|
2012-09-08 23:55:45 +08:00
|
|
|
if (err || v > UINT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
*var = v;
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2016-11-29 00:22:47 +08:00
|
|
|
static ssize_t queue_var_store64(s64 *var, const char *page)
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
{
|
|
|
|
int err;
|
2016-11-29 00:22:47 +08:00
|
|
|
s64 v;
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
|
2016-11-29 00:22:47 +08:00
|
|
|
err = kstrtos64(page, 10, &v);
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
*var = v;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
static ssize_t queue_requests_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(q->nr_requests, (page));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
queue_requests_store(struct request_queue *q, const char *page, size_t count)
|
|
|
|
{
|
|
|
|
unsigned long nr;
|
2014-05-21 01:49:02 +08:00
|
|
|
int ret, err;
|
2009-09-12 04:44:29 +08:00
|
|
|
|
2014-05-21 01:49:02 +08:00
|
|
|
if (!q->request_fn && !q->mq_ops)
|
2009-09-12 04:44:29 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ret = queue_var_store(&nr, page, count);
|
2012-09-08 23:55:45 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
if (nr < BLKDEV_MIN_RQ)
|
|
|
|
nr = BLKDEV_MIN_RQ;
|
|
|
|
|
2014-05-21 01:49:02 +08:00
|
|
|
if (q->request_fn)
|
|
|
|
err = blk_update_nr_requests(q, nr);
|
|
|
|
else
|
|
|
|
err = blk_mq_update_nr_requests(q, nr);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_ra_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2017-02-02 22:56:50 +08:00
|
|
|
unsigned long ra_kb = q->backing_dev_info->ra_pages <<
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 20:29:47 +08:00
|
|
|
(PAGE_SHIFT - 10);
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
return queue_var_show(ra_kb, (page));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
queue_ra_store(struct request_queue *q, const char *page, size_t count)
|
|
|
|
{
|
|
|
|
unsigned long ra_kb;
|
|
|
|
ssize_t ret = queue_var_store(&ra_kb, page, count);
|
|
|
|
|
2012-09-08 23:55:45 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2017-02-02 22:56:50 +08:00
|
|
|
q->backing_dev_info->ra_pages = ra_kb >> (PAGE_SHIFT - 10);
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_max_sectors_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2009-05-23 05:17:50 +08:00
|
|
|
int max_sectors_kb = queue_max_sectors(q) >> 1;
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
return queue_var_show(max_sectors_kb, (page));
|
|
|
|
}
|
|
|
|
|
2010-03-10 13:48:33 +08:00
|
|
|
static ssize_t queue_max_segments_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(queue_max_segments(q), (page));
|
|
|
|
}
|
|
|
|
|
2017-02-08 21:46:49 +08:00
|
|
|
static ssize_t queue_max_discard_segments_show(struct request_queue *q,
|
|
|
|
char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(queue_max_discard_segments(q), (page));
|
|
|
|
}
|
|
|
|
|
2010-09-11 02:50:10 +08:00
|
|
|
static ssize_t queue_max_integrity_segments_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(q->limits.max_integrity_segments, (page));
|
|
|
|
}
|
|
|
|
|
2010-03-10 13:48:33 +08:00
|
|
|
static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2010-12-02 02:41:49 +08:00
|
|
|
if (blk_queue_cluster(q))
|
2010-03-10 13:48:33 +08:00
|
|
|
return queue_var_show(queue_max_segment_size(q), (page));
|
|
|
|
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 20:29:47 +08:00
|
|
|
return queue_var_show(PAGE_SIZE, (page));
|
2010-03-10 13:48:33 +08:00
|
|
|
}
|
|
|
|
|
2009-05-23 05:17:49 +08:00
|
|
|
static ssize_t queue_logical_block_size_show(struct request_queue *q, char *page)
|
2008-01-30 02:14:08 +08:00
|
|
|
{
|
2009-05-23 05:17:49 +08:00
|
|
|
return queue_var_show(queue_logical_block_size(q), page);
|
2008-01-30 02:14:08 +08:00
|
|
|
}
|
|
|
|
|
2009-05-23 05:17:53 +08:00
|
|
|
static ssize_t queue_physical_block_size_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(queue_physical_block_size(q), page);
|
|
|
|
}
|
|
|
|
|
2016-10-18 14:40:30 +08:00
|
|
|
static ssize_t queue_chunk_sectors_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(q->limits.chunk_sectors, page);
|
|
|
|
}
|
|
|
|
|
2009-05-23 05:17:53 +08:00
|
|
|
static ssize_t queue_io_min_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(queue_io_min(q), page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_io_opt_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(queue_io_opt(q), page);
|
2008-01-30 02:14:08 +08:00
|
|
|
}
|
|
|
|
|
2009-11-10 18:50:21 +08:00
|
|
|
static ssize_t queue_discard_granularity_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(q->limits.discard_granularity, page);
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:14:26 +08:00
|
|
|
static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
|
2016-02-17 22:15:30 +08:00
|
|
|
return sprintf(page, "%llu\n",
|
|
|
|
(unsigned long long)q->limits.max_hw_discard_sectors << 9);
|
2015-07-16 23:14:26 +08:00
|
|
|
}
|
|
|
|
|
2009-11-10 18:50:21 +08:00
|
|
|
static ssize_t queue_discard_max_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2011-05-18 16:37:35 +08:00
|
|
|
return sprintf(page, "%llu\n",
|
|
|
|
(unsigned long long)q->limits.max_discard_sectors << 9);
|
2009-11-10 18:50:21 +08:00
|
|
|
}
|
|
|
|
|
2015-07-16 23:14:26 +08:00
|
|
|
static ssize_t queue_discard_max_store(struct request_queue *q,
|
|
|
|
const char *page, size_t count)
|
|
|
|
{
|
|
|
|
unsigned long max_discard;
|
|
|
|
ssize_t ret = queue_var_store(&max_discard, page, count);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (max_discard & (q->limits.discard_granularity - 1))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
max_discard >>= 9;
|
|
|
|
if (max_discard > UINT_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (max_discard > q->limits.max_hw_discard_sectors)
|
|
|
|
max_discard = q->limits.max_hw_discard_sectors;
|
|
|
|
|
|
|
|
q->limits.max_discard_sectors = max_discard;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-12-03 16:24:48 +08:00
|
|
|
static ssize_t queue_discard_zeroes_data_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2017-04-06 01:21:23 +08:00
|
|
|
return queue_var_show(0, page);
|
2009-12-03 16:24:48 +08:00
|
|
|
}
|
|
|
|
|
2012-09-19 00:19:27 +08:00
|
|
|
static ssize_t queue_write_same_max_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%llu\n",
|
|
|
|
(unsigned long long)q->limits.max_write_same_sectors << 9);
|
|
|
|
}
|
|
|
|
|
2016-12-01 04:28:59 +08:00
|
|
|
static ssize_t queue_write_zeroes_max_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%llu\n",
|
|
|
|
(unsigned long long)q->limits.max_write_zeroes_sectors << 9);
|
|
|
|
}
|
2012-09-19 00:19:27 +08:00
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
static ssize_t
|
|
|
|
queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
|
|
|
|
{
|
|
|
|
unsigned long max_sectors_kb,
|
2009-05-23 05:17:50 +08:00
|
|
|
max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1,
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 20:29:47 +08:00
|
|
|
page_kb = 1 << (PAGE_SHIFT - 10);
|
2008-01-29 21:51:59 +08:00
|
|
|
ssize_t ret = queue_var_store(&max_sectors_kb, page, count);
|
|
|
|
|
2012-09-08 23:55:45 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2015-11-14 05:46:48 +08:00
|
|
|
max_hw_sectors_kb = min_not_zero(max_hw_sectors_kb, (unsigned long)
|
|
|
|
q->limits.max_dev_sectors >> 1);
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
|
|
|
|
return -EINVAL;
|
2008-11-25 16:08:39 +08:00
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
spin_lock_irq(q->queue_lock);
|
2009-09-02 04:40:15 +08:00
|
|
|
q->limits.max_sectors = max_sectors_kb << 1;
|
2017-02-02 22:56:50 +08:00
|
|
|
q->backing_dev_info->io_pages = max_sectors_kb >> (PAGE_SHIFT - 10);
|
2008-01-29 21:51:59 +08:00
|
|
|
spin_unlock_irq(q->queue_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2009-05-23 05:17:50 +08:00
|
|
|
int max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1;
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
return queue_var_show(max_hw_sectors_kb, (page));
|
|
|
|
}
|
|
|
|
|
2010-08-08 00:13:50 +08:00
|
|
|
#define QUEUE_SYSFS_BIT_FNS(name, flag, neg) \
|
|
|
|
static ssize_t \
|
|
|
|
queue_show_##name(struct request_queue *q, char *page) \
|
|
|
|
{ \
|
|
|
|
int bit; \
|
|
|
|
bit = test_bit(QUEUE_FLAG_##flag, &q->queue_flags); \
|
|
|
|
return queue_var_show(neg ? !bit : bit, page); \
|
|
|
|
} \
|
|
|
|
static ssize_t \
|
|
|
|
queue_store_##name(struct request_queue *q, const char *page, size_t count) \
|
|
|
|
{ \
|
|
|
|
unsigned long val; \
|
|
|
|
ssize_t ret; \
|
|
|
|
ret = queue_var_store(&val, page, count); \
|
2013-04-04 03:53:57 +08:00
|
|
|
if (ret < 0) \
|
|
|
|
return ret; \
|
2010-08-08 00:13:50 +08:00
|
|
|
if (neg) \
|
|
|
|
val = !val; \
|
|
|
|
\
|
|
|
|
if (val) \
|
2018-03-08 09:10:04 +08:00
|
|
|
blk_queue_flag_set(QUEUE_FLAG_##flag, q); \
|
2010-08-08 00:13:50 +08:00
|
|
|
else \
|
2018-03-08 09:10:04 +08:00
|
|
|
blk_queue_flag_clear(QUEUE_FLAG_##flag, q); \
|
2010-08-08 00:13:50 +08:00
|
|
|
return ret; \
|
2009-01-07 19:22:39 +08:00
|
|
|
}
|
|
|
|
|
2010-08-08 00:13:50 +08:00
|
|
|
QUEUE_SYSFS_BIT_FNS(nonrot, NONROT, 1);
|
|
|
|
QUEUE_SYSFS_BIT_FNS(random, ADD_RANDOM, 0);
|
|
|
|
QUEUE_SYSFS_BIT_FNS(iostats, IO_STAT, 0);
|
|
|
|
#undef QUEUE_SYSFS_BIT_FNS
|
2009-01-07 19:22:39 +08:00
|
|
|
|
2016-10-18 14:40:29 +08:00
|
|
|
static ssize_t queue_zoned_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
switch (blk_queue_zoned_model(q)) {
|
|
|
|
case BLK_ZONED_HA:
|
|
|
|
return sprintf(page, "host-aware\n");
|
|
|
|
case BLK_ZONED_HM:
|
|
|
|
return sprintf(page, "host-managed\n");
|
|
|
|
default:
|
|
|
|
return sprintf(page, "none\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-29 20:44:19 +08:00
|
|
|
static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2010-01-29 16:04:08 +08:00
|
|
|
return queue_var_show((blk_queue_nomerges(q) << 1) |
|
|
|
|
blk_queue_noxmerges(q), page);
|
2008-04-29 20:44:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_nomerges_store(struct request_queue *q, const char *page,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
unsigned long nm;
|
|
|
|
ssize_t ret = queue_var_store(&nm, page, count);
|
|
|
|
|
2012-09-08 23:55:45 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2008-05-07 15:09:39 +08:00
|
|
|
spin_lock_irq(q->queue_lock);
|
2010-01-29 16:04:08 +08:00
|
|
|
queue_flag_clear(QUEUE_FLAG_NOMERGES, q);
|
|
|
|
queue_flag_clear(QUEUE_FLAG_NOXMERGES, q);
|
|
|
|
if (nm == 2)
|
2008-05-07 15:09:39 +08:00
|
|
|
queue_flag_set(QUEUE_FLAG_NOMERGES, q);
|
2010-01-29 16:04:08 +08:00
|
|
|
else if (nm)
|
|
|
|
queue_flag_set(QUEUE_FLAG_NOXMERGES, q);
|
2008-05-07 15:09:39 +08:00
|
|
|
spin_unlock_irq(q->queue_lock);
|
2009-01-07 19:22:39 +08:00
|
|
|
|
2008-04-29 20:44:19 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-09-14 02:26:01 +08:00
|
|
|
static ssize_t queue_rq_affinity_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2009-07-17 15:26:26 +08:00
|
|
|
bool set = test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags);
|
2011-07-24 02:44:25 +08:00
|
|
|
bool force = test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags);
|
2008-09-14 02:26:01 +08:00
|
|
|
|
2011-07-24 02:44:25 +08:00
|
|
|
return queue_var_show(set << force, page);
|
2008-09-14 02:26:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
|
|
|
|
{
|
|
|
|
ssize_t ret = -EINVAL;
|
2013-11-15 06:32:07 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2008-09-14 02:26:01 +08:00
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
ret = queue_var_store(&val, page, count);
|
2012-09-08 23:55:45 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2008-09-14 02:26:01 +08:00
|
|
|
spin_lock_irq(q->queue_lock);
|
2011-08-24 03:25:12 +08:00
|
|
|
if (val == 2) {
|
2008-09-14 02:26:01 +08:00
|
|
|
queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
|
2011-08-24 03:25:12 +08:00
|
|
|
queue_flag_set(QUEUE_FLAG_SAME_FORCE, q);
|
|
|
|
} else if (val == 1) {
|
|
|
|
queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
|
|
|
|
queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
|
|
|
|
} else if (val == 0) {
|
2011-07-24 02:44:25 +08:00
|
|
|
queue_flag_clear(QUEUE_FLAG_SAME_COMP, q);
|
|
|
|
queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
|
|
|
|
}
|
2008-09-14 02:26:01 +08:00
|
|
|
spin_unlock_irq(q->queue_lock);
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
2008-01-29 21:51:59 +08:00
|
|
|
|
2016-11-15 04:01:59 +08:00
|
|
|
static ssize_t queue_poll_delay_show(struct request_queue *q, char *page)
|
|
|
|
{
|
2016-11-15 04:03:03 +08:00
|
|
|
int val;
|
|
|
|
|
|
|
|
if (q->poll_nsec == -1)
|
|
|
|
val = -1;
|
|
|
|
else
|
|
|
|
val = q->poll_nsec / 1000;
|
|
|
|
|
|
|
|
return sprintf(page, "%d\n", val);
|
2016-11-15 04:01:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page,
|
|
|
|
size_t count)
|
|
|
|
{
|
2016-11-15 04:03:03 +08:00
|
|
|
int err, val;
|
2016-11-15 04:01:59 +08:00
|
|
|
|
|
|
|
if (!q->mq_ops || !q->mq_ops->poll)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2016-11-15 04:03:03 +08:00
|
|
|
err = kstrtoint(page, 10, &val);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2016-11-15 04:01:59 +08:00
|
|
|
|
2016-11-15 04:03:03 +08:00
|
|
|
if (val == -1)
|
|
|
|
q->poll_nsec = -1;
|
|
|
|
else
|
|
|
|
q->poll_nsec = val * 1000;
|
|
|
|
|
|
|
|
return count;
|
2016-11-15 04:01:59 +08:00
|
|
|
}
|
|
|
|
|
2015-11-06 01:44:55 +08:00
|
|
|
static ssize_t queue_poll_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(test_bit(QUEUE_FLAG_POLL, &q->queue_flags), page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_poll_store(struct request_queue *q, const char *page,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
unsigned long poll_on;
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
if (!q->mq_ops || !q->mq_ops->poll)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ret = queue_var_store(&poll_on, page, count);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (poll_on)
|
2018-03-08 09:10:04 +08:00
|
|
|
blk_queue_flag_set(QUEUE_FLAG_POLL, q);
|
2015-11-06 01:44:55 +08:00
|
|
|
else
|
2018-03-08 09:10:04 +08:00
|
|
|
blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
|
2015-11-06 01:44:55 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
if (!q->rq_wb)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return sprintf(page, "%llu\n", div_u64(q->rq_wb->min_lat_nsec, 1000));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,
|
|
|
|
size_t count)
|
|
|
|
{
|
2016-11-29 00:22:47 +08:00
|
|
|
struct rq_wb *rwb;
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
ssize_t ret;
|
2016-11-29 00:22:47 +08:00
|
|
|
s64 val;
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
|
|
|
|
ret = queue_var_store64(&val, page);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2016-11-29 00:40:34 +08:00
|
|
|
if (val < -1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
rwb = q->rq_wb;
|
|
|
|
if (!rwb) {
|
|
|
|
ret = wbt_init(q);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
|
2017-11-23 21:39:40 +08:00
|
|
|
rwb = q->rq_wb;
|
2016-11-29 00:22:47 +08:00
|
|
|
if (val == -1)
|
|
|
|
rwb->min_lat_nsec = wbt_default_latency_nsec(q);
|
|
|
|
else if (val >= 0)
|
|
|
|
rwb->min_lat_nsec = val * 1000ULL;
|
2016-11-29 00:40:34 +08:00
|
|
|
|
|
|
|
if (rwb->enable_state == WBT_STATE_ON_DEFAULT)
|
|
|
|
rwb->enable_state = WBT_STATE_ON_MANUAL;
|
2016-11-29 00:22:47 +08:00
|
|
|
|
|
|
|
wbt_update_limits(rwb);
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2016-04-13 02:32:46 +08:00
|
|
|
static ssize_t queue_wc_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
if (test_bit(QUEUE_FLAG_WC, &q->queue_flags))
|
|
|
|
return sprintf(page, "write back\n");
|
|
|
|
|
|
|
|
return sprintf(page, "write through\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t queue_wc_store(struct request_queue *q, const char *page,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
int set = -1;
|
|
|
|
|
|
|
|
if (!strncmp(page, "write back", 10))
|
|
|
|
set = 1;
|
|
|
|
else if (!strncmp(page, "write through", 13) ||
|
|
|
|
!strncmp(page, "none", 4))
|
|
|
|
set = 0;
|
|
|
|
|
|
|
|
if (set == -1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (set)
|
2018-03-08 09:10:04 +08:00
|
|
|
blk_queue_flag_set(QUEUE_FLAG_WC, q);
|
2016-04-13 02:32:46 +08:00
|
|
|
else
|
2018-03-08 09:10:04 +08:00
|
|
|
blk_queue_flag_clear(QUEUE_FLAG_WC, q);
|
2016-04-13 02:32:46 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-05-09 09:33:58 +08:00
|
|
|
static ssize_t queue_fua_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return sprintf(page, "%u\n", test_bit(QUEUE_FLAG_FUA, &q->queue_flags));
|
|
|
|
}
|
|
|
|
|
2016-06-24 05:05:51 +08:00
|
|
|
static ssize_t queue_dax_show(struct request_queue *q, char *page)
|
|
|
|
{
|
|
|
|
return queue_var_show(blk_queue_dax(q), page);
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
static struct queue_sysfs_entry queue_requests_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "nr_requests", .mode = 0644 },
|
2008-01-29 21:51:59 +08:00
|
|
|
.show = queue_requests_show,
|
|
|
|
.store = queue_requests_store,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct queue_sysfs_entry queue_ra_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "read_ahead_kb", .mode = 0644 },
|
2008-01-29 21:51:59 +08:00
|
|
|
.show = queue_ra_show,
|
|
|
|
.store = queue_ra_store,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct queue_sysfs_entry queue_max_sectors_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "max_sectors_kb", .mode = 0644 },
|
2008-01-29 21:51:59 +08:00
|
|
|
.show = queue_max_sectors_show,
|
|
|
|
.store = queue_max_sectors_store,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct queue_sysfs_entry queue_max_hw_sectors_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "max_hw_sectors_kb", .mode = 0444 },
|
2008-01-29 21:51:59 +08:00
|
|
|
.show = queue_max_hw_sectors_show,
|
|
|
|
};
|
|
|
|
|
2010-03-10 13:48:33 +08:00
|
|
|
static struct queue_sysfs_entry queue_max_segments_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "max_segments", .mode = 0444 },
|
2010-03-10 13:48:33 +08:00
|
|
|
.show = queue_max_segments_show,
|
|
|
|
};
|
|
|
|
|
2017-02-08 21:46:49 +08:00
|
|
|
static struct queue_sysfs_entry queue_max_discard_segments_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "max_discard_segments", .mode = 0444 },
|
2017-02-08 21:46:49 +08:00
|
|
|
.show = queue_max_discard_segments_show,
|
|
|
|
};
|
|
|
|
|
2010-09-11 02:50:10 +08:00
|
|
|
static struct queue_sysfs_entry queue_max_integrity_segments_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "max_integrity_segments", .mode = 0444 },
|
2010-09-11 02:50:10 +08:00
|
|
|
.show = queue_max_integrity_segments_show,
|
|
|
|
};
|
|
|
|
|
2010-03-10 13:48:33 +08:00
|
|
|
static struct queue_sysfs_entry queue_max_segment_size_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "max_segment_size", .mode = 0444 },
|
2010-03-10 13:48:33 +08:00
|
|
|
.show = queue_max_segment_size_show,
|
|
|
|
};
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
static struct queue_sysfs_entry queue_iosched_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "scheduler", .mode = 0644 },
|
2008-01-29 21:51:59 +08:00
|
|
|
.show = elv_iosched_show,
|
|
|
|
.store = elv_iosched_store,
|
|
|
|
};
|
|
|
|
|
2008-01-30 02:14:08 +08:00
|
|
|
static struct queue_sysfs_entry queue_hw_sector_size_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "hw_sector_size", .mode = 0444 },
|
2009-05-23 05:17:49 +08:00
|
|
|
.show = queue_logical_block_size_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct queue_sysfs_entry queue_logical_block_size_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "logical_block_size", .mode = 0444 },
|
2009-05-23 05:17:49 +08:00
|
|
|
.show = queue_logical_block_size_show,
|
2008-01-30 02:14:08 +08:00
|
|
|
};
|
|
|
|
|
2009-05-23 05:17:53 +08:00
|
|
|
static struct queue_sysfs_entry queue_physical_block_size_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "physical_block_size", .mode = 0444 },
|
2009-05-23 05:17:53 +08:00
|
|
|
.show = queue_physical_block_size_show,
|
|
|
|
};
|
|
|
|
|
2016-10-18 14:40:30 +08:00
|
|
|
static struct queue_sysfs_entry queue_chunk_sectors_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "chunk_sectors", .mode = 0444 },
|
2016-10-18 14:40:30 +08:00
|
|
|
.show = queue_chunk_sectors_show,
|
|
|
|
};
|
|
|
|
|
2009-05-23 05:17:53 +08:00
|
|
|
static struct queue_sysfs_entry queue_io_min_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "minimum_io_size", .mode = 0444 },
|
2009-05-23 05:17:53 +08:00
|
|
|
.show = queue_io_min_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct queue_sysfs_entry queue_io_opt_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "optimal_io_size", .mode = 0444 },
|
2009-05-23 05:17:53 +08:00
|
|
|
.show = queue_io_opt_show,
|
2008-01-30 02:14:08 +08:00
|
|
|
};
|
|
|
|
|
2009-11-10 18:50:21 +08:00
|
|
|
static struct queue_sysfs_entry queue_discard_granularity_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "discard_granularity", .mode = 0444 },
|
2009-11-10 18:50:21 +08:00
|
|
|
.show = queue_discard_granularity_show,
|
|
|
|
};
|
|
|
|
|
2015-07-16 23:14:26 +08:00
|
|
|
static struct queue_sysfs_entry queue_discard_max_hw_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "discard_max_hw_bytes", .mode = 0444 },
|
2015-07-16 23:14:26 +08:00
|
|
|
.show = queue_discard_max_hw_show,
|
|
|
|
};
|
|
|
|
|
2009-11-10 18:50:21 +08:00
|
|
|
static struct queue_sysfs_entry queue_discard_max_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "discard_max_bytes", .mode = 0644 },
|
2009-11-10 18:50:21 +08:00
|
|
|
.show = queue_discard_max_show,
|
2015-07-16 23:14:26 +08:00
|
|
|
.store = queue_discard_max_store,
|
2009-11-10 18:50:21 +08:00
|
|
|
};
|
|
|
|
|
2009-12-03 16:24:48 +08:00
|
|
|
static struct queue_sysfs_entry queue_discard_zeroes_data_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "discard_zeroes_data", .mode = 0444 },
|
2009-12-03 16:24:48 +08:00
|
|
|
.show = queue_discard_zeroes_data_show,
|
|
|
|
};
|
|
|
|
|
2012-09-19 00:19:27 +08:00
|
|
|
static struct queue_sysfs_entry queue_write_same_max_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "write_same_max_bytes", .mode = 0444 },
|
2012-09-19 00:19:27 +08:00
|
|
|
.show = queue_write_same_max_show,
|
|
|
|
};
|
|
|
|
|
2016-12-01 04:28:59 +08:00
|
|
|
static struct queue_sysfs_entry queue_write_zeroes_max_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "write_zeroes_max_bytes", .mode = 0444 },
|
2016-12-01 04:28:59 +08:00
|
|
|
.show = queue_write_zeroes_max_show,
|
|
|
|
};
|
|
|
|
|
2009-01-07 19:22:39 +08:00
|
|
|
static struct queue_sysfs_entry queue_nonrot_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "rotational", .mode = 0644 },
|
2010-08-08 00:13:50 +08:00
|
|
|
.show = queue_show_nonrot,
|
|
|
|
.store = queue_store_nonrot,
|
2009-01-07 19:22:39 +08:00
|
|
|
};
|
|
|
|
|
2016-10-18 14:40:29 +08:00
|
|
|
static struct queue_sysfs_entry queue_zoned_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "zoned", .mode = 0444 },
|
2016-10-18 14:40:29 +08:00
|
|
|
.show = queue_zoned_show,
|
|
|
|
};
|
|
|
|
|
2008-04-29 20:44:19 +08:00
|
|
|
static struct queue_sysfs_entry queue_nomerges_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "nomerges", .mode = 0644 },
|
2008-04-29 20:44:19 +08:00
|
|
|
.show = queue_nomerges_show,
|
|
|
|
.store = queue_nomerges_store,
|
|
|
|
};
|
|
|
|
|
2008-09-14 02:26:01 +08:00
|
|
|
static struct queue_sysfs_entry queue_rq_affinity_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "rq_affinity", .mode = 0644 },
|
2008-09-14 02:26:01 +08:00
|
|
|
.show = queue_rq_affinity_show,
|
|
|
|
.store = queue_rq_affinity_store,
|
|
|
|
};
|
|
|
|
|
2009-01-23 17:54:44 +08:00
|
|
|
static struct queue_sysfs_entry queue_iostats_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "iostats", .mode = 0644 },
|
2010-08-08 00:13:50 +08:00
|
|
|
.show = queue_show_iostats,
|
|
|
|
.store = queue_store_iostats,
|
2009-01-23 17:54:44 +08:00
|
|
|
};
|
|
|
|
|
2010-06-09 16:42:09 +08:00
|
|
|
static struct queue_sysfs_entry queue_random_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "add_random", .mode = 0644 },
|
2010-08-08 00:13:50 +08:00
|
|
|
.show = queue_show_random,
|
|
|
|
.store = queue_store_random,
|
2010-06-09 16:42:09 +08:00
|
|
|
};
|
|
|
|
|
2015-11-06 01:44:55 +08:00
|
|
|
static struct queue_sysfs_entry queue_poll_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "io_poll", .mode = 0644 },
|
2015-11-06 01:44:55 +08:00
|
|
|
.show = queue_poll_show,
|
|
|
|
.store = queue_poll_store,
|
|
|
|
};
|
|
|
|
|
2016-11-15 04:01:59 +08:00
|
|
|
static struct queue_sysfs_entry queue_poll_delay_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "io_poll_delay", .mode = 0644 },
|
2016-11-15 04:01:59 +08:00
|
|
|
.show = queue_poll_delay_show,
|
|
|
|
.store = queue_poll_delay_store,
|
|
|
|
};
|
|
|
|
|
2016-04-13 02:32:46 +08:00
|
|
|
static struct queue_sysfs_entry queue_wc_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "write_cache", .mode = 0644 },
|
2016-04-13 02:32:46 +08:00
|
|
|
.show = queue_wc_show,
|
|
|
|
.store = queue_wc_store,
|
|
|
|
};
|
|
|
|
|
2018-05-09 09:33:58 +08:00
|
|
|
static struct queue_sysfs_entry queue_fua_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "fua", .mode = 0444 },
|
2018-05-09 09:33:58 +08:00
|
|
|
.show = queue_fua_show,
|
|
|
|
};
|
|
|
|
|
2016-06-24 05:05:51 +08:00
|
|
|
static struct queue_sysfs_entry queue_dax_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "dax", .mode = 0444 },
|
2016-06-24 05:05:51 +08:00
|
|
|
.show = queue_dax_show,
|
|
|
|
};
|
|
|
|
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
static struct queue_sysfs_entry queue_wb_lat_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "wbt_lat_usec", .mode = 0644 },
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
.show = queue_wb_lat_show,
|
|
|
|
.store = queue_wb_lat_store,
|
|
|
|
};
|
|
|
|
|
2017-03-28 01:51:37 +08:00
|
|
|
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
|
|
|
|
static struct queue_sysfs_entry throtl_sample_time_entry = {
|
2018-05-25 03:38:59 +08:00
|
|
|
.attr = {.name = "throttle_sample_time", .mode = 0644 },
|
2017-03-28 01:51:37 +08:00
|
|
|
.show = blk_throtl_sample_time_show,
|
|
|
|
.store = blk_throtl_sample_time_store,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
static struct attribute *default_attrs[] = {
|
|
|
|
&queue_requests_entry.attr,
|
|
|
|
&queue_ra_entry.attr,
|
|
|
|
&queue_max_hw_sectors_entry.attr,
|
|
|
|
&queue_max_sectors_entry.attr,
|
2010-03-10 13:48:33 +08:00
|
|
|
&queue_max_segments_entry.attr,
|
2017-02-08 21:46:49 +08:00
|
|
|
&queue_max_discard_segments_entry.attr,
|
2010-09-11 02:50:10 +08:00
|
|
|
&queue_max_integrity_segments_entry.attr,
|
2010-03-10 13:48:33 +08:00
|
|
|
&queue_max_segment_size_entry.attr,
|
2008-01-29 21:51:59 +08:00
|
|
|
&queue_iosched_entry.attr,
|
2008-01-30 02:14:08 +08:00
|
|
|
&queue_hw_sector_size_entry.attr,
|
2009-05-23 05:17:49 +08:00
|
|
|
&queue_logical_block_size_entry.attr,
|
2009-05-23 05:17:53 +08:00
|
|
|
&queue_physical_block_size_entry.attr,
|
2016-10-18 14:40:30 +08:00
|
|
|
&queue_chunk_sectors_entry.attr,
|
2009-05-23 05:17:53 +08:00
|
|
|
&queue_io_min_entry.attr,
|
|
|
|
&queue_io_opt_entry.attr,
|
2009-11-10 18:50:21 +08:00
|
|
|
&queue_discard_granularity_entry.attr,
|
|
|
|
&queue_discard_max_entry.attr,
|
2015-07-16 23:14:26 +08:00
|
|
|
&queue_discard_max_hw_entry.attr,
|
2009-12-03 16:24:48 +08:00
|
|
|
&queue_discard_zeroes_data_entry.attr,
|
2012-09-19 00:19:27 +08:00
|
|
|
&queue_write_same_max_entry.attr,
|
2016-12-01 04:28:59 +08:00
|
|
|
&queue_write_zeroes_max_entry.attr,
|
2009-01-07 19:22:39 +08:00
|
|
|
&queue_nonrot_entry.attr,
|
2016-10-18 14:40:29 +08:00
|
|
|
&queue_zoned_entry.attr,
|
2008-04-29 20:44:19 +08:00
|
|
|
&queue_nomerges_entry.attr,
|
2008-09-14 02:26:01 +08:00
|
|
|
&queue_rq_affinity_entry.attr,
|
2009-01-23 17:54:44 +08:00
|
|
|
&queue_iostats_entry.attr,
|
2010-06-09 16:42:09 +08:00
|
|
|
&queue_random_entry.attr,
|
2015-11-06 01:44:55 +08:00
|
|
|
&queue_poll_entry.attr,
|
2016-04-13 02:32:46 +08:00
|
|
|
&queue_wc_entry.attr,
|
2018-05-09 09:33:58 +08:00
|
|
|
&queue_fua_entry.attr,
|
2016-06-24 05:05:51 +08:00
|
|
|
&queue_dax_entry.attr,
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
&queue_wb_lat_entry.attr,
|
2016-11-15 04:01:59 +08:00
|
|
|
&queue_poll_delay_entry.attr,
|
2017-03-28 01:51:37 +08:00
|
|
|
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
|
|
|
|
&throtl_sample_time_entry.attr,
|
|
|
|
#endif
|
2008-01-29 21:51:59 +08:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr)
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
|
|
|
|
{
|
|
|
|
struct queue_sysfs_entry *entry = to_queue(attr);
|
|
|
|
struct request_queue *q =
|
|
|
|
container_of(kobj, struct request_queue, kobj);
|
|
|
|
ssize_t res;
|
|
|
|
|
|
|
|
if (!entry->show)
|
|
|
|
return -EIO;
|
|
|
|
mutex_lock(&q->sysfs_lock);
|
2012-11-28 20:42:38 +08:00
|
|
|
if (blk_queue_dying(q)) {
|
2008-01-29 21:51:59 +08:00
|
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
res = entry->show(q, page);
|
|
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
queue_attr_store(struct kobject *kobj, struct attribute *attr,
|
|
|
|
const char *page, size_t length)
|
|
|
|
{
|
|
|
|
struct queue_sysfs_entry *entry = to_queue(attr);
|
2008-01-31 20:03:55 +08:00
|
|
|
struct request_queue *q;
|
2008-01-29 21:51:59 +08:00
|
|
|
ssize_t res;
|
|
|
|
|
|
|
|
if (!entry->store)
|
|
|
|
return -EIO;
|
2008-01-31 20:03:55 +08:00
|
|
|
|
|
|
|
q = container_of(kobj, struct request_queue, kobj);
|
2008-01-29 21:51:59 +08:00
|
|
|
mutex_lock(&q->sysfs_lock);
|
2012-11-28 20:42:38 +08:00
|
|
|
if (blk_queue_dying(q)) {
|
2008-01-29 21:51:59 +08:00
|
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
res = entry->store(q, page, length);
|
|
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-01-10 00:05:13 +08:00
|
|
|
static void blk_free_queue_rcu(struct rcu_head *rcu_head)
|
|
|
|
{
|
|
|
|
struct request_queue *q = container_of(rcu_head, struct request_queue,
|
|
|
|
rcu_head);
|
|
|
|
kmem_cache_free(blk_requestq_cachep, q);
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
/**
|
2017-06-15 03:27:50 +08:00
|
|
|
* __blk_release_queue - release a request queue when it is no longer needed
|
|
|
|
* @work: pointer to the release_work member of the request queue to be released
|
2008-01-29 21:51:59 +08:00
|
|
|
*
|
|
|
|
* Description:
|
2017-06-15 03:27:50 +08:00
|
|
|
* blk_release_queue is the counterpart of blk_init_queue(). It should be
|
|
|
|
* called when a request queue is being released; typically when a block
|
|
|
|
* device is being de-registered. Its primary task it to free the queue
|
|
|
|
* itself.
|
2008-01-29 21:51:59 +08:00
|
|
|
*
|
2017-06-15 03:27:50 +08:00
|
|
|
* Notes:
|
2014-12-09 23:57:48 +08:00
|
|
|
* The low level driver must have finished any outstanding requests first
|
|
|
|
* via blk_cleanup_queue().
|
2017-06-15 03:27:50 +08:00
|
|
|
*
|
|
|
|
* Although blk_release_queue() may be called with preemption disabled,
|
|
|
|
* __blk_release_queue() may sleep.
|
|
|
|
*/
|
|
|
|
static void __blk_release_queue(struct work_struct *work)
|
2008-01-29 21:51:59 +08:00
|
|
|
{
|
2017-06-15 03:27:50 +08:00
|
|
|
struct request_queue *q = container_of(work, typeof(*q), release_work);
|
2008-01-29 21:51:59 +08:00
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 23:56:08 +08:00
|
|
|
if (test_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags))
|
|
|
|
blk_stat_remove_callback(q, q->poll_cb);
|
|
|
|
blk_stat_free_callback(q->poll_cb);
|
2011-09-28 22:07:01 +08:00
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 23:56:08 +08:00
|
|
|
blk_free_queue_stats(q->stats);
|
|
|
|
|
2017-06-01 05:43:45 +08:00
|
|
|
blk_exit_rl(q, &q->root_rl);
|
2008-01-29 21:51:59 +08:00
|
|
|
|
|
|
|
if (q->queue_tags)
|
|
|
|
__blk_queue_free_tags(q);
|
|
|
|
|
2017-01-28 00:51:45 +08:00
|
|
|
if (!q->mq_ops) {
|
|
|
|
if (q->exit_rq_fn)
|
|
|
|
q->exit_rq_fn(q, q->fq->flush_rq);
|
2014-09-25 23:23:47 +08:00
|
|
|
blk_free_flush_queue(q->fq);
|
2017-01-28 00:51:45 +08:00
|
|
|
} else {
|
2015-01-29 20:17:27 +08:00
|
|
|
blk_mq_release(q);
|
2017-01-28 00:51:45 +08:00
|
|
|
}
|
2014-02-11 00:29:00 +08:00
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
blk_trace_shutdown(q);
|
|
|
|
|
2017-02-01 06:53:21 +08:00
|
|
|
if (q->mq_ops)
|
|
|
|
blk_mq_debugfs_unregister(q);
|
|
|
|
|
2018-05-21 06:25:47 +08:00
|
|
|
bioset_exit(&q->bio_split);
|
2015-04-24 13:37:18 +08:00
|
|
|
|
2011-12-14 07:33:37 +08:00
|
|
|
ida_simple_remove(&blk_queue_ida, q->id);
|
2013-01-10 00:05:13 +08:00
|
|
|
call_rcu(&q->rcu_head, blk_free_queue_rcu);
|
2008-01-29 21:51:59 +08:00
|
|
|
}
|
|
|
|
|
2017-06-15 03:27:50 +08:00
|
|
|
static void blk_release_queue(struct kobject *kobj)
|
|
|
|
{
|
|
|
|
struct request_queue *q =
|
|
|
|
container_of(kobj, struct request_queue, kobj);
|
|
|
|
|
|
|
|
INIT_WORK(&q->release_work, __blk_release_queue);
|
|
|
|
schedule_work(&q->release_work);
|
|
|
|
}
|
|
|
|
|
2010-01-19 09:58:23 +08:00
|
|
|
static const struct sysfs_ops queue_sysfs_ops = {
|
2008-01-29 21:51:59 +08:00
|
|
|
.show = queue_attr_show,
|
|
|
|
.store = queue_attr_store,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct kobj_type blk_queue_ktype = {
|
|
|
|
.sysfs_ops = &queue_sysfs_ops,
|
|
|
|
.default_attrs = default_attrs,
|
|
|
|
.release = blk_release_queue,
|
|
|
|
};
|
|
|
|
|
2018-01-18 03:48:10 +08:00
|
|
|
/**
|
|
|
|
* blk_register_queue - register a block layer queue with sysfs
|
|
|
|
* @disk: Disk of which the request queue should be registered with sysfs.
|
|
|
|
*/
|
2008-01-29 21:51:59 +08:00
|
|
|
int blk_register_queue(struct gendisk *disk)
|
|
|
|
{
|
|
|
|
int ret;
|
2009-04-14 14:00:05 +08:00
|
|
|
struct device *dev = disk_to_dev(disk);
|
2008-01-29 21:51:59 +08:00
|
|
|
struct request_queue *q = disk->queue;
|
|
|
|
|
2008-04-21 15:51:06 +08:00
|
|
|
if (WARN_ON(!q))
|
2008-01-29 21:51:59 +08:00
|
|
|
return -ENXIO;
|
|
|
|
|
2017-03-29 07:12:15 +08:00
|
|
|
WARN_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags),
|
|
|
|
"%s is registering an already registered queue\n",
|
|
|
|
kobject_name(&dev->kobj));
|
|
|
|
queue_flag_set_unlocked(QUEUE_FLAG_REGISTERED, q);
|
|
|
|
|
2012-09-21 05:08:52 +08:00
|
|
|
/*
|
2014-09-25 01:31:50 +08:00
|
|
|
* SCSI probing may synchronously create and destroy a lot of
|
|
|
|
* request_queues for non-existent devices. Shutting down a fully
|
|
|
|
* functional queue takes measureable wallclock time as RCU grace
|
|
|
|
* periods are involved. To avoid excessive latency in these
|
|
|
|
* cases, a request_queue starts out in a degraded mode which is
|
|
|
|
* faster to shut down and is made fully functional here as
|
|
|
|
* request_queues for non-existent devices never get registered.
|
2012-09-21 05:08:52 +08:00
|
|
|
*/
|
2014-09-09 23:50:58 +08:00
|
|
|
if (!blk_queue_init_done(q)) {
|
|
|
|
queue_flag_set_unlocked(QUEUE_FLAG_INIT_DONE, q);
|
2015-10-22 01:20:12 +08:00
|
|
|
percpu_ref_switch_to_percpu(&q->q_usage_counter);
|
2014-09-09 23:50:58 +08:00
|
|
|
blk_queue_bypass_end(q);
|
|
|
|
}
|
2012-09-21 05:08:52 +08:00
|
|
|
|
2009-04-14 14:00:05 +08:00
|
|
|
ret = blk_trace_init_sysfs(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2017-02-15 11:27:38 +08:00
|
|
|
/* Prevent changes through sysfs until registration is completed. */
|
|
|
|
mutex_lock(&q->sysfs_lock);
|
|
|
|
|
2009-06-12 01:52:27 +08:00
|
|
|
ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
|
2011-04-19 19:47:58 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
blk_trace_remove_sysfs(dev);
|
2017-02-15 11:27:38 +08:00
|
|
|
goto unlock;
|
2011-04-19 19:47:58 +08:00
|
|
|
}
|
2008-01-29 21:51:59 +08:00
|
|
|
|
2017-05-26 07:38:06 +08:00
|
|
|
if (q->mq_ops) {
|
2017-04-27 04:47:48 +08:00
|
|
|
__blk_mq_register_dev(dev, q);
|
2017-05-26 07:38:06 +08:00
|
|
|
blk_mq_debugfs_register(q);
|
|
|
|
}
|
2017-05-04 22:17:21 +08:00
|
|
|
|
2008-01-29 21:51:59 +08:00
|
|
|
kobject_uevent(&q->kobj, KOBJ_ADD);
|
|
|
|
|
2017-04-19 17:33:27 +08:00
|
|
|
wbt_enable_default(q);
|
block: hook up writeback throttling
Enable throttling of buffered writeback to make it a lot
more smooth, and has way less impact on other system activity.
Background writeback should be, by definition, background
activity. The fact that we flush huge bundles of it at the time
means that it potentially has heavy impacts on foreground workloads,
which isn't ideal. We can't easily limit the sizes of writes that
we do, since that would impact file system layout in the presence
of delayed allocation. So just throttle back buffered writeback,
unless someone is waiting for it.
The algorithm for when to throttle takes its inspiration in the
CoDel networking scheduling algorithm. Like CoDel, blk-wb monitors
the minimum latencies of requests over a window of time. In that
window of time, if the minimum latency of any request exceeds a
given target, then a scale count is incremented and the queue depth
is shrunk. The next monitoring window is shrunk accordingly. Unlike
CoDel, if we hit a window that exhibits good behavior, then we
simply increment the scale count and re-calculate the limits for that
scale value. This prevents us from oscillating between a
close-to-ideal value and max all the time, instead remaining in the
windows where we get good behavior.
Unlike CoDel, blk-wb allows the scale count to to negative. This
happens if we primarily have writes going on. Unlike positive
scale counts, this doesn't change the size of the monitoring window.
When the heavy writers finish, blk-bw quickly snaps back to it's
stable state of a zero scale count.
The patch registers a sysfs entry, 'wb_lat_usec'. This sets the latency
target to me met. It defaults to 2 msec for non-rotational storage, and
75 msec for rotational storage. Setting this value to '0' disables
blk-wb. Generally, a user would not have to touch this setting.
We don't enable WBT on devices that are managed with CFQ, and have
a non-root block cgroup attached. If we have a proportional share setup
on this particular disk, then the wbt throttling will interfere with
that. We don't have a strong need for wbt for that case, since we will
rely on CFQ doing that for us.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-10 03:38:14 +08:00
|
|
|
|
2017-03-28 01:51:38 +08:00
|
|
|
blk_throtl_register_queue(q);
|
|
|
|
|
2017-02-07 04:52:24 +08:00
|
|
|
if (q->request_fn || (q->mq_ops && q->elevator)) {
|
|
|
|
ret = elv_register_queue(q);
|
|
|
|
if (ret) {
|
2018-01-18 03:48:10 +08:00
|
|
|
mutex_unlock(&q->sysfs_lock);
|
2017-02-07 04:52:24 +08:00
|
|
|
kobject_uevent(&q->kobj, KOBJ_REMOVE);
|
|
|
|
kobject_del(&q->kobj);
|
|
|
|
blk_trace_remove_sysfs(dev);
|
|
|
|
kobject_put(&dev->kobj);
|
2018-01-18 03:48:10 +08:00
|
|
|
return ret;
|
2017-02-07 04:52:24 +08:00
|
|
|
}
|
2008-01-29 21:51:59 +08:00
|
|
|
}
|
2017-02-15 11:27:38 +08:00
|
|
|
ret = 0;
|
|
|
|
unlock:
|
|
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
return ret;
|
2008-01-29 21:51:59 +08:00
|
|
|
}
|
2018-01-09 11:01:13 +08:00
|
|
|
EXPORT_SYMBOL_GPL(blk_register_queue);
|
2008-01-29 21:51:59 +08:00
|
|
|
|
2018-01-18 03:48:10 +08:00
|
|
|
/**
|
|
|
|
* blk_unregister_queue - counterpart of blk_register_queue()
|
|
|
|
* @disk: Disk of which the request queue should be unregistered from sysfs.
|
|
|
|
*
|
|
|
|
* Note: the caller is responsible for guaranteeing that this function is called
|
|
|
|
* after blk_register_queue() has finished.
|
|
|
|
*/
|
2008-01-29 21:51:59 +08:00
|
|
|
void blk_unregister_queue(struct gendisk *disk)
|
|
|
|
{
|
|
|
|
struct request_queue *q = disk->queue;
|
|
|
|
|
2008-04-21 15:51:06 +08:00
|
|
|
if (WARN_ON(!q))
|
|
|
|
return;
|
|
|
|
|
2018-01-09 11:01:13 +08:00
|
|
|
/* Return early if disk->queue was never registered. */
|
|
|
|
if (!test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags))
|
|
|
|
return;
|
|
|
|
|
2018-01-12 03:11:01 +08:00
|
|
|
/*
|
2018-01-18 03:48:10 +08:00
|
|
|
* Since sysfs_remove_dir() prevents adding new directory entries
|
|
|
|
* before removal of existing entries starts, protect against
|
|
|
|
* concurrent elv_iosched_store() calls.
|
2018-01-12 03:11:01 +08:00
|
|
|
*/
|
2017-08-29 00:52:44 +08:00
|
|
|
mutex_lock(&q->sysfs_lock);
|
2017-03-29 07:12:15 +08:00
|
|
|
|
2018-03-08 09:10:04 +08:00
|
|
|
blk_queue_flag_clear(QUEUE_FLAG_REGISTERED, q);
|
2017-03-29 07:12:17 +08:00
|
|
|
|
2018-01-18 03:48:10 +08:00
|
|
|
/*
|
|
|
|
* Remove the sysfs attributes before unregistering the queue data
|
|
|
|
* structures that can be modified through sysfs.
|
|
|
|
*/
|
blk-mq: new multi-queue block IO queueing mechanism
Linux currently has two models for block devices:
- The classic request_fn based approach, where drivers use struct
request units for IO. The block layer provides various helper
functionalities to let drivers share code, things like tag
management, timeout handling, queueing, etc.
- The "stacked" approach, where a driver squeezes in between the
block layer and IO submitter. Since this bypasses the IO stack,
driver generally have to manage everything themselves.
With drivers being written for new high IOPS devices, the classic
request_fn based driver doesn't work well enough. The design dates
back to when both SMP and high IOPS was rare. It has problems with
scaling to bigger machines, and runs into scaling issues even on
smaller machines when you have IOPS in the hundreds of thousands
per device.
The stacked approach is then most often selected as the model
for the driver. But this means that everybody has to re-invent
everything, and along with that we get all the problems again
that the shared approach solved.
This commit introduces blk-mq, block multi queue support. The
design is centered around per-cpu queues for queueing IO, which
then funnel down into x number of hardware submission queues.
We might have a 1:1 mapping between the two, or it might be
an N:M mapping. That all depends on what the hardware supports.
blk-mq provides various helper functions, which include:
- Scalable support for request tagging. Most devices need to
be able to uniquely identify a request both in the driver and
to the hardware. The tagging uses per-cpu caches for freed
tags, to enable cache hot reuse.
- Timeout handling without tracking request on a per-device
basis. Basically the driver should be able to get a notification,
if a request happens to fail.
- Optional support for non 1:1 mappings between issue and
submission queues. blk-mq can redirect IO completions to the
desired location.
- Support for per-request payloads. Drivers almost always need
to associate a request structure with some driver private
command structure. Drivers can tell blk-mq this at init time,
and then any request handed to the driver will have the
required size of memory associated with it.
- Support for merging of IO, and plugging. The stacked model
gets neither of these. Even for high IOPS devices, merging
sequential IO reduces per-command overhead and thus
increases bandwidth.
For now, this is provided as a potential 3rd queueing model, with
the hope being that, as it matures, it can replace both the classic
and stacked model. That would get us back to having just 1 real
model for block devices, leaving the stacked approach to dm/md
devices (as it was originally intended).
Contributions in this patch from the following people:
Shaohua Li <shli@fusionio.com>
Alexander Gordeev <agordeev@redhat.com>
Christoph Hellwig <hch@infradead.org>
Mike Christie <michaelc@cs.wisc.edu>
Matias Bjorling <m@bjorling.me>
Jeff Moyer <jmoyer@redhat.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2013-10-24 16:20:05 +08:00
|
|
|
if (q->mq_ops)
|
2016-09-16 20:25:06 +08:00
|
|
|
blk_mq_unregister_dev(disk_to_dev(disk), q);
|
2018-01-18 03:48:10 +08:00
|
|
|
mutex_unlock(&q->sysfs_lock);
|
2008-01-29 21:51:59 +08:00
|
|
|
|
2009-09-25 12:19:26 +08:00
|
|
|
kobject_uevent(&q->kobj, KOBJ_REMOVE);
|
|
|
|
kobject_del(&q->kobj);
|
|
|
|
blk_trace_remove_sysfs(disk_to_dev(disk));
|
2018-01-12 03:11:01 +08:00
|
|
|
|
2018-01-18 03:48:10 +08:00
|
|
|
wbt_exit(q);
|
|
|
|
|
|
|
|
mutex_lock(&q->sysfs_lock);
|
|
|
|
if (q->request_fn || (q->mq_ops && q->elevator))
|
|
|
|
elv_unregister_queue(q);
|
2018-01-12 03:11:01 +08:00
|
|
|
mutex_unlock(&q->sysfs_lock);
|
2018-01-18 03:48:10 +08:00
|
|
|
|
|
|
|
kobject_put(&disk_to_dev(disk)->kobj);
|
2008-01-29 21:51:59 +08:00
|
|
|
}
|