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 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-03-24 06:11:31 +07:00
|
|
|
/*
|
|
|
|
* Some low level IO code, and hacks for various block layer limitations
|
|
|
|
*
|
|
|
|
* Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com>
|
|
|
|
* Copyright 2012 Google, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "bcache.h"
|
|
|
|
#include "bset.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
2013-04-27 05:39:55 +07:00
|
|
|
#include <linux/blkdev.h>
|
|
|
|
|
2013-03-24 06:11:31 +07:00
|
|
|
/* Bios with headers */
|
|
|
|
|
|
|
|
void bch_bbio_free(struct bio *bio, struct cache_set *c)
|
|
|
|
{
|
|
|
|
struct bbio *b = container_of(bio, struct bbio, bio);
|
2018-08-11 12:19:45 +07:00
|
|
|
|
2018-05-21 05:25:51 +07:00
|
|
|
mempool_free(b, &c->bio_meta);
|
2013-03-24 06:11:31 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
struct bio *bch_bbio_alloc(struct cache_set *c)
|
|
|
|
{
|
2018-05-21 05:25:51 +07:00
|
|
|
struct bbio *b = mempool_alloc(&c->bio_meta, GFP_NOIO);
|
2013-03-24 06:11:31 +07:00
|
|
|
struct bio *bio = &b->bio;
|
|
|
|
|
2016-11-22 22:57:21 +07:00
|
|
|
bio_init(bio, bio->bi_inline_vecs, bucket_pages(c));
|
2013-03-24 06:11:31 +07:00
|
|
|
|
|
|
|
return bio;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __bch_submit_bbio(struct bio *bio, struct cache_set *c)
|
|
|
|
{
|
|
|
|
struct bbio *b = container_of(bio, struct bbio, bio);
|
|
|
|
|
2013-10-12 05:44:27 +07:00
|
|
|
bio->bi_iter.bi_sector = PTR_OFFSET(&b->key, 0);
|
2017-08-24 00:10:32 +07:00
|
|
|
bio_set_dev(bio, PTR_CACHE(c, &b->key, 0)->bdev);
|
2013-03-24 06:11:31 +07:00
|
|
|
|
|
|
|
b->submit_time_us = local_clock_us();
|
bcache: add CACHE_SET_IO_DISABLE to struct cache_set flags
When too many I/Os failed on cache device, bch_cache_set_error() is called
in the error handling code path to retire whole problematic cache set. If
new I/O requests continue to come and take refcount dc->count, the cache
set won't be retired immediately, this is a problem.
Further more, there are several kernel thread and self-armed kernel work
may still running after bch_cache_set_error() is called. It needs to wait
quite a while for them to stop, or they won't stop at all. They also
prevent the cache set from being retired.
The solution in this patch is, to add per cache set flag to disable I/O
request on this cache and all attached backing devices. Then new coming I/O
requests can be rejected in *_make_request() before taking refcount, kernel
threads and self-armed kernel worker can stop very fast when flags bit
CACHE_SET_IO_DISABLE is set.
Because bcache also do internal I/Os for writeback, garbage collection,
bucket allocation, journaling, this kind of I/O should be disabled after
bch_cache_set_error() is called. So closure_bio_submit() is modified to
check whether CACHE_SET_IO_DISABLE is set on cache_set->flags. If set,
closure_bio_submit() will set bio->bi_status to BLK_STS_IOERR and
return, generic_make_request() won't be called.
A sysfs interface is also added to set or clear CACHE_SET_IO_DISABLE bit
from cache_set->flags, to disable or enable cache set I/O for debugging. It
is helpful to trigger more corner case issues for failed cache device.
Changelog
v4, add wait_for_kthread_stop(), and call it before exits writeback and gc
kernel threads.
v3, change CACHE_SET_IO_DISABLE from 4 to 3, since it is bit index.
remove "bcache: " prefix when printing out kernel message.
v2, more changes by previous review,
- Use CACHE_SET_IO_DISABLE of cache_set->flags, suggested by Junhui.
- Check CACHE_SET_IO_DISABLE in bch_btree_gc() to stop a while-loop, this
is reported and inspired from origal patch of Pavel Vazharov.
v1, initial version.
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Pavel Vazharov <freakpv@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-03-19 07:36:17 +07:00
|
|
|
closure_bio_submit(c, bio, bio->bi_private);
|
2013-03-24 06:11:31 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void bch_submit_bbio(struct bio *bio, struct cache_set *c,
|
2018-08-11 12:19:44 +07:00
|
|
|
struct bkey *k, unsigned int ptr)
|
2013-03-24 06:11:31 +07:00
|
|
|
{
|
|
|
|
struct bbio *b = container_of(bio, struct bbio, bio);
|
2018-08-11 12:19:45 +07:00
|
|
|
|
2013-03-24 06:11:31 +07:00
|
|
|
bch_bkey_copy_single_ptr(&b->key, k, ptr);
|
|
|
|
__bch_submit_bbio(bio, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IO errors */
|
bcache: add io_disable to struct cached_dev
If a bcache device is configured to writeback mode, current code does not
handle write I/O errors on backing devices properly.
In writeback mode, write request is written to cache device, and
latter being flushed to backing device. If I/O failed when writing from
cache device to the backing device, bcache code just ignores the error and
upper layer code is NOT noticed that the backing device is broken.
This patch tries to handle backing device failure like how the cache device
failure is handled,
- Add a error counter 'io_errors' and error limit 'error_limit' in struct
cached_dev. Add another io_disable to struct cached_dev to disable I/Os
on the problematic backing device.
- When I/O error happens on backing device, increase io_errors counter. And
if io_errors reaches error_limit, set cache_dev->io_disable to true, and
stop the bcache device.
The result is, if backing device is broken of disconnected, and I/O errors
reach its error limit, backing device will be disabled and the associated
bcache device will be removed from system.
Changelog:
v2: remove "bcache: " prefix in pr_error(), and use correct name string to
print out bcache device gendisk name.
v1: indeed this is new added in v2 patch set.
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-03-19 07:36:25 +07:00
|
|
|
void bch_count_backing_io_errors(struct cached_dev *dc, struct bio *bio)
|
|
|
|
{
|
2018-08-11 12:19:44 +07:00
|
|
|
unsigned int errors;
|
bcache: add io_disable to struct cached_dev
If a bcache device is configured to writeback mode, current code does not
handle write I/O errors on backing devices properly.
In writeback mode, write request is written to cache device, and
latter being flushed to backing device. If I/O failed when writing from
cache device to the backing device, bcache code just ignores the error and
upper layer code is NOT noticed that the backing device is broken.
This patch tries to handle backing device failure like how the cache device
failure is handled,
- Add a error counter 'io_errors' and error limit 'error_limit' in struct
cached_dev. Add another io_disable to struct cached_dev to disable I/Os
on the problematic backing device.
- When I/O error happens on backing device, increase io_errors counter. And
if io_errors reaches error_limit, set cache_dev->io_disable to true, and
stop the bcache device.
The result is, if backing device is broken of disconnected, and I/O errors
reach its error limit, backing device will be disabled and the associated
bcache device will be removed from system.
Changelog:
v2: remove "bcache: " prefix in pr_error(), and use correct name string to
print out bcache device gendisk name.
v1: indeed this is new added in v2 patch set.
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-03-19 07:36:25 +07:00
|
|
|
|
|
|
|
WARN_ONCE(!dc, "NULL pointer of struct cached_dev");
|
|
|
|
|
|
|
|
errors = atomic_add_return(1, &dc->io_errors);
|
|
|
|
if (errors < dc->error_limit)
|
|
|
|
pr_err("%s: IO error on backing device, unrecoverable",
|
2018-05-03 17:51:32 +07:00
|
|
|
dc->backing_dev_name);
|
bcache: add io_disable to struct cached_dev
If a bcache device is configured to writeback mode, current code does not
handle write I/O errors on backing devices properly.
In writeback mode, write request is written to cache device, and
latter being flushed to backing device. If I/O failed when writing from
cache device to the backing device, bcache code just ignores the error and
upper layer code is NOT noticed that the backing device is broken.
This patch tries to handle backing device failure like how the cache device
failure is handled,
- Add a error counter 'io_errors' and error limit 'error_limit' in struct
cached_dev. Add another io_disable to struct cached_dev to disable I/Os
on the problematic backing device.
- When I/O error happens on backing device, increase io_errors counter. And
if io_errors reaches error_limit, set cache_dev->io_disable to true, and
stop the bcache device.
The result is, if backing device is broken of disconnected, and I/O errors
reach its error limit, backing device will be disabled and the associated
bcache device will be removed from system.
Changelog:
v2: remove "bcache: " prefix in pr_error(), and use correct name string to
print out bcache device gendisk name.
v1: indeed this is new added in v2 patch set.
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-03-19 07:36:25 +07:00
|
|
|
else
|
|
|
|
bch_cached_dev_error(dc);
|
|
|
|
}
|
2013-03-24 06:11:31 +07:00
|
|
|
|
2018-01-09 03:21:29 +07:00
|
|
|
void bch_count_io_errors(struct cache *ca,
|
|
|
|
blk_status_t error,
|
|
|
|
int is_read,
|
|
|
|
const char *m)
|
2013-03-24 06:11:31 +07:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The halflife of an error is:
|
|
|
|
* log2(1/2)/log2(127/128) * refresh ~= 88 * refresh
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (ca->set->error_decay) {
|
2018-08-11 12:19:44 +07:00
|
|
|
unsigned int count = atomic_inc_return(&ca->io_count);
|
2013-03-24 06:11:31 +07:00
|
|
|
|
|
|
|
while (count > ca->set->error_decay) {
|
2018-08-11 12:19:44 +07:00
|
|
|
unsigned int errors;
|
|
|
|
unsigned int old = count;
|
|
|
|
unsigned int new = count - ca->set->error_decay;
|
2013-03-24 06:11:31 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First we subtract refresh from count; each time we
|
2018-08-11 12:19:52 +07:00
|
|
|
* successfully do so, we rescale the errors once:
|
2013-03-24 06:11:31 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
count = atomic_cmpxchg(&ca->io_count, old, new);
|
|
|
|
|
|
|
|
if (count == old) {
|
|
|
|
count = new;
|
|
|
|
|
|
|
|
errors = atomic_read(&ca->io_errors);
|
|
|
|
do {
|
|
|
|
old = errors;
|
|
|
|
new = ((uint64_t) errors * 127) / 128;
|
|
|
|
errors = atomic_cmpxchg(&ca->io_errors,
|
|
|
|
old, new);
|
|
|
|
} while (old != errors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
2018-08-11 12:19:44 +07:00
|
|
|
unsigned int errors = atomic_add_return(1 << IO_ERROR_SHIFT,
|
2013-03-24 06:11:31 +07:00
|
|
|
&ca->io_errors);
|
|
|
|
errors >>= IO_ERROR_SHIFT;
|
|
|
|
|
|
|
|
if (errors < ca->set->error_limit)
|
2018-01-09 03:21:29 +07:00
|
|
|
pr_err("%s: IO error on %s%s",
|
2018-05-03 17:51:32 +07:00
|
|
|
ca->cache_dev_name, m,
|
2018-01-09 03:21:29 +07:00
|
|
|
is_read ? ", recovering." : ".");
|
2013-03-24 06:11:31 +07:00
|
|
|
else
|
|
|
|
bch_cache_set_error(ca->set,
|
|
|
|
"%s: too many IO errors %s",
|
2018-05-03 17:51:32 +07:00
|
|
|
ca->cache_dev_name, m);
|
2013-03-24 06:11:31 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
|
2017-06-03 14:38:06 +07:00
|
|
|
blk_status_t error, const char *m)
|
2013-03-24 06:11:31 +07:00
|
|
|
{
|
|
|
|
struct bbio *b = container_of(bio, struct bbio, bio);
|
|
|
|
struct cache *ca = PTR_CACHE(c, &b->key, 0);
|
2018-01-09 03:21:29 +07:00
|
|
|
int is_read = (bio_data_dir(bio) == READ ? 1 : 0);
|
2013-03-24 06:11:31 +07:00
|
|
|
|
2018-08-11 12:19:44 +07:00
|
|
|
unsigned int threshold = op_is_write(bio_op(bio))
|
2013-03-24 06:11:31 +07:00
|
|
|
? c->congested_write_threshold_us
|
|
|
|
: c->congested_read_threshold_us;
|
|
|
|
|
|
|
|
if (threshold) {
|
2018-08-11 12:19:44 +07:00
|
|
|
unsigned int t = local_clock_us();
|
2013-03-24 06:11:31 +07:00
|
|
|
int us = t - b->submit_time_us;
|
|
|
|
int congested = atomic_read(&c->congested);
|
|
|
|
|
|
|
|
if (us > (int) threshold) {
|
|
|
|
int ms = us / 1024;
|
2018-08-11 12:19:45 +07:00
|
|
|
|
2013-03-24 06:11:31 +07:00
|
|
|
c->congested_last_us = t;
|
|
|
|
|
|
|
|
ms = min(ms, CONGESTED_MAX + congested);
|
|
|
|
atomic_sub(ms, &c->congested);
|
|
|
|
} else if (congested < 0)
|
|
|
|
atomic_inc(&c->congested);
|
|
|
|
}
|
|
|
|
|
2018-01-09 03:21:29 +07:00
|
|
|
bch_count_io_errors(ca, error, is_read, m);
|
2013-03-24 06:11:31 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void bch_bbio_endio(struct cache_set *c, struct bio *bio,
|
2017-06-03 14:38:06 +07:00
|
|
|
blk_status_t error, const char *m)
|
2013-03-24 06:11:31 +07:00
|
|
|
{
|
|
|
|
struct closure *cl = bio->bi_private;
|
|
|
|
|
|
|
|
bch_bbio_count_io_errors(c, bio, error, m);
|
|
|
|
bio_put(bio);
|
|
|
|
closure_put(cl);
|
|
|
|
}
|