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 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2010-09-08 12:39:52 +00:00
|
|
|
/*
|
|
|
|
* zfcp device driver
|
|
|
|
*
|
|
|
|
* Tracking of manually configured LUNs and helper functions to
|
|
|
|
* register the LUNs with the SCSI midlayer.
|
|
|
|
*
|
2012-07-20 09:15:04 +00:00
|
|
|
* Copyright IBM Corp. 2010
|
2010-09-08 12:39:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "zfcp_def.h"
|
|
|
|
#include "zfcp_ext.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_scsi_scan - Register LUN with SCSI midlayer
|
|
|
|
* @unit: The zfcp LUN/unit to register
|
|
|
|
*
|
|
|
|
* When the SCSI midlayer is not allowed to automatically scan and
|
|
|
|
* attach SCSI devices, zfcp has to register the single devices with
|
|
|
|
* the SCSI midlayer.
|
|
|
|
*/
|
|
|
|
void zfcp_unit_scsi_scan(struct zfcp_unit *unit)
|
|
|
|
{
|
|
|
|
struct fc_rport *rport = unit->port->rport;
|
2014-06-25 13:27:36 +00:00
|
|
|
u64 lun;
|
2010-09-08 12:39:52 +00:00
|
|
|
|
|
|
|
lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
|
|
|
|
|
|
|
|
if (rport && rport->port_state == FC_PORTSTATE_ONLINE)
|
2016-03-17 07:39:45 +00:00
|
|
|
scsi_scan_target(&rport->dev, 0, rport->scsi_target_id, lun,
|
2016-04-08 06:14:54 +00:00
|
|
|
SCSI_SCAN_MANUAL);
|
2010-09-08 12:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void zfcp_unit_scsi_scan_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit = container_of(work, struct zfcp_unit,
|
|
|
|
scsi_work);
|
|
|
|
|
|
|
|
zfcp_unit_scsi_scan(unit);
|
|
|
|
put_device(&unit->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_queue_scsi_scan - Register configured units on port
|
|
|
|
* @port: The zfcp_port where to register units
|
|
|
|
*
|
|
|
|
* After opening a port, all units configured on this port have to be
|
|
|
|
* registered with the SCSI midlayer. This function should be called
|
|
|
|
* after calling fc_remote_port_add, so that the fc_rport is already
|
|
|
|
* ONLINE and the call to scsi_scan_target runs the same way as the
|
|
|
|
* call in the FC transport class.
|
|
|
|
*/
|
|
|
|
void zfcp_unit_queue_scsi_scan(struct zfcp_port *port)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit;
|
|
|
|
|
|
|
|
read_lock_irq(&port->unit_list_lock);
|
|
|
|
list_for_each_entry(unit, &port->unit_list, list) {
|
|
|
|
get_device(&unit->dev);
|
|
|
|
if (scsi_queue_work(port->adapter->scsi_host,
|
|
|
|
&unit->scsi_work) <= 0)
|
|
|
|
put_device(&unit->dev);
|
|
|
|
}
|
|
|
|
read_unlock_irq(&port->unit_list_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct zfcp_unit *_zfcp_unit_find(struct zfcp_port *port, u64 fcp_lun)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit;
|
|
|
|
|
|
|
|
list_for_each_entry(unit, &port->unit_list, list)
|
|
|
|
if (unit->fcp_lun == fcp_lun) {
|
|
|
|
get_device(&unit->dev);
|
|
|
|
return unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_find - Find and return zfcp_unit with specified FCP LUN
|
|
|
|
* @port: zfcp_port where to look for the unit
|
|
|
|
* @fcp_lun: 64 Bit FCP LUN used to identify the zfcp_unit
|
|
|
|
*
|
|
|
|
* If zfcp_unit is found, a reference is acquired that has to be
|
|
|
|
* released later.
|
|
|
|
*
|
|
|
|
* Returns: Pointer to the zfcp_unit, or NULL if there is no zfcp_unit
|
|
|
|
* with the specified FCP LUN.
|
|
|
|
*/
|
|
|
|
struct zfcp_unit *zfcp_unit_find(struct zfcp_port *port, u64 fcp_lun)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit;
|
|
|
|
|
|
|
|
read_lock_irq(&port->unit_list_lock);
|
|
|
|
unit = _zfcp_unit_find(port, fcp_lun);
|
|
|
|
read_unlock_irq(&port->unit_list_lock);
|
|
|
|
return unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_release - Drop reference to zfcp_port and free memory of zfcp_unit.
|
|
|
|
* @dev: pointer to device in zfcp_unit
|
|
|
|
*/
|
|
|
|
static void zfcp_unit_release(struct device *dev)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
|
|
|
|
|
2012-09-04 13:23:34 +00:00
|
|
|
atomic_dec(&unit->port->units);
|
2010-09-08 12:39:52 +00:00
|
|
|
kfree(unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_enqueue - enqueue unit to unit list of a port.
|
|
|
|
* @port: pointer to port where unit is added
|
|
|
|
* @fcp_lun: FCP LUN of unit to be enqueued
|
|
|
|
* Returns: 0 success
|
|
|
|
*
|
|
|
|
* Sets up some unit internal structures and creates sysfs entry.
|
|
|
|
*/
|
|
|
|
int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit;
|
2012-09-04 13:23:34 +00:00
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
mutex_lock(&zfcp_sysfs_port_units_mutex);
|
2019-05-23 13:23:46 +00:00
|
|
|
if (zfcp_sysfs_port_is_removing(port)) {
|
2012-09-04 13:23:34 +00:00
|
|
|
/* port is already gone */
|
|
|
|
retval = -ENODEV;
|
|
|
|
goto out;
|
|
|
|
}
|
2010-09-08 12:39:52 +00:00
|
|
|
|
|
|
|
unit = zfcp_unit_find(port, fcp_lun);
|
|
|
|
if (unit) {
|
|
|
|
put_device(&unit->dev);
|
2012-09-04 13:23:34 +00:00
|
|
|
retval = -EEXIST;
|
|
|
|
goto out;
|
2010-09-08 12:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unit = kzalloc(sizeof(struct zfcp_unit), GFP_KERNEL);
|
2012-09-04 13:23:34 +00:00
|
|
|
if (!unit) {
|
|
|
|
retval = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2010-09-08 12:39:52 +00:00
|
|
|
|
|
|
|
unit->port = port;
|
|
|
|
unit->fcp_lun = fcp_lun;
|
|
|
|
unit->dev.parent = &port->dev;
|
|
|
|
unit->dev.release = zfcp_unit_release;
|
2013-04-26 14:13:49 +00:00
|
|
|
unit->dev.groups = zfcp_unit_attr_groups;
|
2010-09-08 12:39:52 +00:00
|
|
|
INIT_WORK(&unit->scsi_work, zfcp_unit_scsi_scan_work);
|
|
|
|
|
|
|
|
if (dev_set_name(&unit->dev, "0x%016llx",
|
|
|
|
(unsigned long long) fcp_lun)) {
|
|
|
|
kfree(unit);
|
2012-09-04 13:23:34 +00:00
|
|
|
retval = -ENOMEM;
|
|
|
|
goto out;
|
2010-09-08 12:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_register(&unit->dev)) {
|
|
|
|
put_device(&unit->dev);
|
2012-09-04 13:23:34 +00:00
|
|
|
retval = -ENOMEM;
|
|
|
|
goto out;
|
2010-09-08 12:39:52 +00:00
|
|
|
}
|
|
|
|
|
2012-09-04 13:23:34 +00:00
|
|
|
atomic_inc(&port->units); /* under zfcp_sysfs_port_units_mutex ! */
|
|
|
|
|
2010-09-08 12:39:52 +00:00
|
|
|
write_lock_irq(&port->unit_list_lock);
|
|
|
|
list_add_tail(&unit->list, &port->unit_list);
|
|
|
|
write_unlock_irq(&port->unit_list_lock);
|
2019-05-23 13:23:46 +00:00
|
|
|
/*
|
|
|
|
* lock order: shost->scan_mutex before zfcp_sysfs_port_units_mutex
|
|
|
|
* due to zfcp_unit_scsi_scan() => zfcp_scsi_slave_alloc()
|
|
|
|
*/
|
|
|
|
mutex_unlock(&zfcp_sysfs_port_units_mutex);
|
2010-09-08 12:39:52 +00:00
|
|
|
|
|
|
|
zfcp_unit_scsi_scan(unit);
|
2019-05-23 13:23:46 +00:00
|
|
|
return retval;
|
2010-09-08 12:39:52 +00:00
|
|
|
|
2012-09-04 13:23:34 +00:00
|
|
|
out:
|
|
|
|
mutex_unlock(&zfcp_sysfs_port_units_mutex);
|
|
|
|
return retval;
|
2010-09-08 12:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_sdev - Return SCSI device for zfcp_unit
|
|
|
|
* @unit: The zfcp_unit where to get the SCSI device for
|
|
|
|
*
|
|
|
|
* Returns: scsi_device pointer on success, NULL if there is no SCSI
|
|
|
|
* device for this zfcp_unit
|
|
|
|
*
|
|
|
|
* On success, the caller also holds a reference to the SCSI device
|
|
|
|
* that must be released with scsi_device_put.
|
|
|
|
*/
|
|
|
|
struct scsi_device *zfcp_unit_sdev(struct zfcp_unit *unit)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost;
|
|
|
|
struct zfcp_port *port;
|
2014-06-25 13:27:36 +00:00
|
|
|
u64 lun;
|
2010-09-08 12:39:52 +00:00
|
|
|
|
|
|
|
lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
|
|
|
|
port = unit->port;
|
|
|
|
shost = port->adapter->scsi_host;
|
|
|
|
return scsi_device_lookup(shost, 0, port->starget_id, lun);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_sdev_status - Return zfcp LUN status for SCSI device
|
|
|
|
* @unit: The unit to lookup the SCSI device for
|
|
|
|
*
|
|
|
|
* Returns the zfcp LUN status field of the SCSI device if the SCSI device
|
|
|
|
* for the zfcp_unit exists, 0 otherwise.
|
|
|
|
*/
|
|
|
|
unsigned int zfcp_unit_sdev_status(struct zfcp_unit *unit)
|
|
|
|
{
|
|
|
|
unsigned int status = 0;
|
|
|
|
struct scsi_device *sdev;
|
|
|
|
struct zfcp_scsi_dev *zfcp_sdev;
|
|
|
|
|
|
|
|
sdev = zfcp_unit_sdev(unit);
|
|
|
|
if (sdev) {
|
|
|
|
zfcp_sdev = sdev_to_zfcp(sdev);
|
|
|
|
status = atomic_read(&zfcp_sdev->status);
|
|
|
|
scsi_device_put(sdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zfcp_unit_remove - Remove entry from list of configured units
|
|
|
|
* @port: The port where to remove the unit from the configuration
|
|
|
|
* @fcp_lun: The 64 bit LUN of the unit to remove
|
|
|
|
*
|
|
|
|
* Returns: -EINVAL if a unit with the specified LUN does not exist,
|
|
|
|
* 0 on success.
|
|
|
|
*/
|
|
|
|
int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit;
|
|
|
|
struct scsi_device *sdev;
|
|
|
|
|
|
|
|
write_lock_irq(&port->unit_list_lock);
|
|
|
|
unit = _zfcp_unit_find(port, fcp_lun);
|
|
|
|
if (unit)
|
|
|
|
list_del(&unit->list);
|
|
|
|
write_unlock_irq(&port->unit_list_lock);
|
|
|
|
|
|
|
|
if (!unit)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
sdev = zfcp_unit_sdev(unit);
|
|
|
|
if (sdev) {
|
|
|
|
scsi_remove_device(sdev);
|
|
|
|
scsi_device_put(sdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
put_device(&unit->dev);
|
|
|
|
|
2013-04-26 14:13:49 +00:00
|
|
|
device_unregister(&unit->dev);
|
2010-09-08 12:39:52 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|