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
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
|
|
|
|
* Horst Hummel <Horst.Hummel@de.ibm.com>
|
|
|
|
* Carsten Otte <Cotte@de.ibm.com>
|
|
|
|
* Martin Schwidefsky <schwidefsky@de.ibm.com>
|
|
|
|
* Bugreports.to..: <Linux390@de.ibm.com>
|
2012-07-20 17:15:04 +08:00
|
|
|
* Copyright IBM Corp. 1999, 2001
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* gendisk related functions for the dasd driver.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-03-26 22:23:49 +08:00
|
|
|
#define KMSG_COMPONENT "dasd"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/interrupt.h>
|
2021-09-20 20:33:25 +08:00
|
|
|
#include <linux/major.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/blkpg.h>
|
|
|
|
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* This is ugly... */
|
|
|
|
#define PRINTK_HEADER "dasd_gendisk:"
|
|
|
|
|
|
|
|
#include "dasd_int.h"
|
|
|
|
|
2022-09-28 22:39:45 +08:00
|
|
|
static unsigned int queue_depth = 32;
|
|
|
|
static unsigned int nr_hw_queues = 4;
|
|
|
|
|
|
|
|
module_param(queue_depth, uint, 0444);
|
|
|
|
MODULE_PARM_DESC(queue_depth, "Default queue depth for new DASD devices");
|
|
|
|
|
|
|
|
module_param(nr_hw_queues, uint, 0444);
|
|
|
|
MODULE_PARM_DESC(nr_hw_queues, "Default number of hardware queues for new DASD devices");
|
2021-08-16 21:19:06 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Allocate and register gendisk structure for device.
|
|
|
|
*/
|
2008-01-26 21:11:23 +08:00
|
|
|
int dasd_gendisk_alloc(struct dasd_block *block)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct gendisk *gdp;
|
2008-01-26 21:11:23 +08:00
|
|
|
struct dasd_device *base;
|
2021-09-28 06:02:30 +08:00
|
|
|
int len, rc;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Make sure the minor for this device exists. */
|
2008-01-26 21:11:23 +08:00
|
|
|
base = block->base;
|
|
|
|
if (base->devindex >= DASD_PER_MAJOR)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EBUSY;
|
|
|
|
|
2022-09-28 22:39:45 +08:00
|
|
|
block->tag_set.ops = &dasd_mq_ops;
|
|
|
|
block->tag_set.cmd_size = sizeof(struct dasd_ccw_req);
|
|
|
|
block->tag_set.nr_hw_queues = nr_hw_queues;
|
|
|
|
block->tag_set.queue_depth = queue_depth;
|
|
|
|
block->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
|
|
|
|
block->tag_set.numa_node = NUMA_NO_NODE;
|
|
|
|
rc = blk_mq_alloc_tag_set(&block->tag_set);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
gdp = blk_mq_alloc_disk(&block->tag_set, block);
|
|
|
|
if (IS_ERR(gdp)) {
|
|
|
|
blk_mq_free_tag_set(&block->tag_set);
|
|
|
|
return PTR_ERR(gdp);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Initialize gendisk structure. */
|
|
|
|
gdp->major = DASD_MAJOR;
|
2008-01-26 21:11:23 +08:00
|
|
|
gdp->first_minor = base->devindex << DASD_PARTN_BITS;
|
2021-08-16 21:19:07 +08:00
|
|
|
gdp->minors = 1 << DASD_PARTN_BITS;
|
2005-04-17 06:20:36 +08:00
|
|
|
gdp->fops = &dasd_device_operations;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set device name.
|
|
|
|
* dasda - dasdz : 26 devices
|
|
|
|
* dasdaa - dasdzz : 676 devices, added up = 702
|
|
|
|
* dasdaaa - dasdzzz : 17576 devices, added up = 18278
|
|
|
|
* dasdaaaa - dasdzzzz : 456976 devices, added up = 475252
|
|
|
|
*/
|
|
|
|
len = sprintf(gdp->disk_name, "dasd");
|
2008-01-26 21:11:23 +08:00
|
|
|
if (base->devindex > 25) {
|
|
|
|
if (base->devindex > 701) {
|
|
|
|
if (base->devindex > 18277)
|
2005-04-17 06:20:36 +08:00
|
|
|
len += sprintf(gdp->disk_name + len, "%c",
|
2008-01-26 21:11:23 +08:00
|
|
|
'a'+(((base->devindex-18278)
|
2005-04-17 06:20:36 +08:00
|
|
|
/17576)%26));
|
|
|
|
len += sprintf(gdp->disk_name + len, "%c",
|
2008-01-26 21:11:23 +08:00
|
|
|
'a'+(((base->devindex-702)/676)%26));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
len += sprintf(gdp->disk_name + len, "%c",
|
2008-01-26 21:11:23 +08:00
|
|
|
'a'+(((base->devindex-26)/26)%26));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-01-26 21:11:23 +08:00
|
|
|
len += sprintf(gdp->disk_name + len, "%c", 'a'+(base->devindex%26));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-08 19:26:24 +08:00
|
|
|
if (base->features & DASD_FEATURE_READONLY ||
|
|
|
|
test_bit(DASD_FLAG_DEVICE_RO, &base->flags))
|
2005-04-17 06:20:36 +08:00
|
|
|
set_disk_ro(gdp, 1);
|
2011-04-20 16:15:30 +08:00
|
|
|
dasd_add_link_to_gendisk(gdp, base);
|
2008-01-26 21:11:23 +08:00
|
|
|
block->gdp = gdp;
|
|
|
|
set_capacity(block->gdp, 0);
|
2021-09-28 06:02:30 +08:00
|
|
|
|
|
|
|
rc = device_add_disk(&base->cdev->dev, block->gdp, NULL);
|
|
|
|
if (rc) {
|
|
|
|
dasd_gendisk_free(block);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unregister and free gendisk structure for device.
|
|
|
|
*/
|
2008-01-26 21:11:23 +08:00
|
|
|
void dasd_gendisk_free(struct dasd_block *block)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-01-26 21:11:23 +08:00
|
|
|
if (block->gdp) {
|
|
|
|
del_gendisk(block->gdp);
|
2010-02-27 05:37:46 +08:00
|
|
|
block->gdp->private_data = NULL;
|
2008-01-26 21:11:23 +08:00
|
|
|
put_disk(block->gdp);
|
|
|
|
block->gdp = NULL;
|
2022-09-28 22:39:45 +08:00
|
|
|
blk_mq_free_tag_set(&block->tag_set);
|
2006-08-30 20:33:33 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Trigger a partition detection.
|
|
|
|
*/
|
2008-01-26 21:11:23 +08:00
|
|
|
int dasd_scan_partitions(struct dasd_block *block)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct block_device *bdev;
|
2015-05-06 12:26:28 +08:00
|
|
|
int rc;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2020-09-21 15:19:52 +08:00
|
|
|
bdev = blkdev_get_by_dev(disk_devt(block->gdp), FMODE_READ, NULL);
|
|
|
|
if (IS_ERR(bdev)) {
|
2014-11-24 22:04:09 +08:00
|
|
|
DBF_DEV_EVENT(DBF_ERR, block->base,
|
2020-09-21 15:19:52 +08:00
|
|
|
"scan partitions error, blkdev_get returned %ld",
|
|
|
|
PTR_ERR(bdev));
|
2014-11-24 22:04:09 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
2015-05-06 12:26:26 +08:00
|
|
|
|
2021-05-25 14:12:56 +08:00
|
|
|
mutex_lock(&block->gdp->open_mutex);
|
2021-06-24 20:32:40 +08:00
|
|
|
rc = bdev_disk_changed(block->gdp, false);
|
2021-05-25 14:12:56 +08:00
|
|
|
mutex_unlock(&block->gdp->open_mutex);
|
2015-05-06 12:26:28 +08:00
|
|
|
if (rc)
|
2014-11-24 22:04:09 +08:00
|
|
|
DBF_DEV_EVENT(DBF_ERR, block->base,
|
2015-05-06 12:26:28 +08:00
|
|
|
"scan partitions error, rc %d", rc);
|
2014-11-24 22:04:09 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Since the matching blkdev_put call to the blkdev_get in
|
|
|
|
* this function is not called before dasd_destroy_partitions
|
|
|
|
* the offline open_count limit needs to be increased from
|
|
|
|
* 0 to 1. This is done by setting device->bdev (see
|
|
|
|
* dasd_generic_set_offline). As long as the partition
|
|
|
|
* detection is running no offline should be allowed. That
|
|
|
|
* is why the assignment to device->bdev is done AFTER
|
|
|
|
* the BLKRRPART ioctl.
|
|
|
|
*/
|
2008-01-26 21:11:23 +08:00
|
|
|
block->bdev = bdev;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove all inodes in the system for a device, delete the
|
|
|
|
* partitions and make device unusable by setting its size to zero.
|
|
|
|
*/
|
2008-01-26 21:11:23 +08:00
|
|
|
void dasd_destroy_partitions(struct dasd_block *block)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct block_device *bdev;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the bdev pointer from the device structure and clear
|
|
|
|
* device->bdev to lower the offline open_count limit again.
|
|
|
|
*/
|
2008-01-26 21:11:23 +08:00
|
|
|
bdev = block->bdev;
|
|
|
|
block->bdev = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2021-05-25 14:12:56 +08:00
|
|
|
mutex_lock(&bdev->bd_disk->open_mutex);
|
2021-06-24 20:32:40 +08:00
|
|
|
bdev_disk_changed(bdev->bd_disk, true);
|
2021-05-25 14:12:56 +08:00
|
|
|
mutex_unlock(&bdev->bd_disk->open_mutex);
|
2020-04-14 15:28:58 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */
|
2008-02-23 09:40:24 +08:00
|
|
|
blkdev_put(bdev, FMODE_READ);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-01-26 21:11:23 +08:00
|
|
|
int dasd_gendisk_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* Register to static dasd major 94 */
|
|
|
|
rc = register_blkdev(DASD_MAJOR, "dasd");
|
|
|
|
if (rc != 0) {
|
2016-03-04 12:49:57 +08:00
|
|
|
pr_warn("Registering the device driver with major number %d failed\n",
|
|
|
|
DASD_MAJOR);
|
2005-04-17 06:20:36 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-26 21:11:23 +08:00
|
|
|
void dasd_gendisk_exit(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unregister_blkdev(DASD_MAJOR, "dasd");
|
|
|
|
}
|