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
|
2008-01-26 20:11:23 +07:00
|
|
|
/*
|
|
|
|
* PAV alias management for the DASD ECKD discipline
|
|
|
|
*
|
2012-07-20 16:15:04 +07:00
|
|
|
* Copyright IBM Corp. 2007
|
2008-01-26 20:11:23 +07:00
|
|
|
* Author(s): Stefan Weinhuber <wein@de.ibm.com>
|
|
|
|
*/
|
|
|
|
|
2009-09-11 15:28:30 +07:00
|
|
|
#define KMSG_COMPONENT "dasd-eckd"
|
2009-03-26 21:23:49 +07:00
|
|
|
|
2008-01-26 20:11:23 +07:00
|
|
|
#include <linux/list.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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-01-26 20:11:23 +07:00
|
|
|
#include <asm/ebcdic.h>
|
|
|
|
#include "dasd_int.h"
|
|
|
|
#include "dasd_eckd.h"
|
|
|
|
|
|
|
|
#ifdef PRINTK_HEADER
|
|
|
|
#undef PRINTK_HEADER
|
|
|
|
#endif /* PRINTK_HEADER */
|
|
|
|
#define PRINTK_HEADER "dasd(eckd):"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* General concept of alias management:
|
|
|
|
* - PAV and DASD alias management is specific to the eckd discipline.
|
|
|
|
* - A device is connected to an lcu as long as the device exists.
|
|
|
|
* dasd_alias_make_device_known_to_lcu will be called wenn the
|
|
|
|
* device is checked by the eckd discipline and
|
|
|
|
* dasd_alias_disconnect_device_from_lcu will be called
|
|
|
|
* before the device is deleted.
|
|
|
|
* - The dasd_alias_add_device / dasd_alias_remove_device
|
|
|
|
* functions mark the point when a device is 'ready for service'.
|
|
|
|
* - A summary unit check is a rare occasion, but it is mandatory to
|
|
|
|
* support it. It requires some complex recovery actions before the
|
|
|
|
* devices can be used again (see dasd_alias_handle_summary_unit_check).
|
|
|
|
* - dasd_alias_get_start_dev will find an alias device that can be used
|
|
|
|
* instead of the base device and does some (very simple) load balancing.
|
|
|
|
* This is the function that gets called for each I/O, so when improving
|
|
|
|
* something, this function should get faster or better, the rest has just
|
|
|
|
* to be correct.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static void summary_unit_check_handling_work(struct work_struct *);
|
|
|
|
static void lcu_update_work(struct work_struct *);
|
|
|
|
static int _schedule_lcu_update(struct alias_lcu *, struct dasd_device *);
|
|
|
|
|
|
|
|
static struct alias_root aliastree = {
|
|
|
|
.serverlist = LIST_HEAD_INIT(aliastree.serverlist),
|
|
|
|
.lock = __SPIN_LOCK_UNLOCKED(aliastree.lock),
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct alias_server *_find_server(struct dasd_uid *uid)
|
|
|
|
{
|
|
|
|
struct alias_server *pos;
|
|
|
|
list_for_each_entry(pos, &aliastree.serverlist, server) {
|
|
|
|
if (!strncmp(pos->uid.vendor, uid->vendor,
|
|
|
|
sizeof(uid->vendor))
|
|
|
|
&& !strncmp(pos->uid.serial, uid->serial,
|
|
|
|
sizeof(uid->serial)))
|
|
|
|
return pos;
|
2015-08-04 22:11:15 +07:00
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct alias_lcu *_find_lcu(struct alias_server *server,
|
|
|
|
struct dasd_uid *uid)
|
|
|
|
{
|
|
|
|
struct alias_lcu *pos;
|
|
|
|
list_for_each_entry(pos, &server->lculist, lcu) {
|
|
|
|
if (pos->uid.ssid == uid->ssid)
|
|
|
|
return pos;
|
2015-08-04 22:11:15 +07:00
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct alias_pav_group *_find_group(struct alias_lcu *lcu,
|
|
|
|
struct dasd_uid *uid)
|
|
|
|
{
|
|
|
|
struct alias_pav_group *pos;
|
|
|
|
__u8 search_unit_addr;
|
|
|
|
|
|
|
|
/* for hyper pav there is only one group */
|
|
|
|
if (lcu->pav == HYPER_PAV) {
|
|
|
|
if (list_empty(&lcu->grouplist))
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
return list_first_entry(&lcu->grouplist,
|
|
|
|
struct alias_pav_group, group);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for base pav we have to find the group that matches the base */
|
|
|
|
if (uid->type == UA_BASE_DEVICE)
|
|
|
|
search_unit_addr = uid->real_unit_addr;
|
|
|
|
else
|
|
|
|
search_unit_addr = uid->base_unit_addr;
|
|
|
|
list_for_each_entry(pos, &lcu->grouplist, group) {
|
2008-08-01 21:39:09 +07:00
|
|
|
if (pos->uid.base_unit_addr == search_unit_addr &&
|
|
|
|
!strncmp(pos->uid.vduit, uid->vduit, sizeof(uid->vduit)))
|
2008-01-26 20:11:23 +07:00
|
|
|
return pos;
|
2015-08-04 22:11:15 +07:00
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct alias_server *_allocate_server(struct dasd_uid *uid)
|
|
|
|
{
|
|
|
|
struct alias_server *server;
|
|
|
|
|
|
|
|
server = kzalloc(sizeof(*server), GFP_KERNEL);
|
|
|
|
if (!server)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
memcpy(server->uid.vendor, uid->vendor, sizeof(uid->vendor));
|
|
|
|
memcpy(server->uid.serial, uid->serial, sizeof(uid->serial));
|
|
|
|
INIT_LIST_HEAD(&server->server);
|
|
|
|
INIT_LIST_HEAD(&server->lculist);
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _free_server(struct alias_server *server)
|
|
|
|
{
|
|
|
|
kfree(server);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct alias_lcu *_allocate_lcu(struct dasd_uid *uid)
|
|
|
|
{
|
|
|
|
struct alias_lcu *lcu;
|
|
|
|
|
|
|
|
lcu = kzalloc(sizeof(*lcu), GFP_KERNEL);
|
|
|
|
if (!lcu)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
lcu->uac = kzalloc(sizeof(*(lcu->uac)), GFP_KERNEL | GFP_DMA);
|
|
|
|
if (!lcu->uac)
|
|
|
|
goto out_err1;
|
|
|
|
lcu->rsu_cqr = kzalloc(sizeof(*lcu->rsu_cqr), GFP_KERNEL | GFP_DMA);
|
|
|
|
if (!lcu->rsu_cqr)
|
|
|
|
goto out_err2;
|
|
|
|
lcu->rsu_cqr->cpaddr = kzalloc(sizeof(struct ccw1),
|
|
|
|
GFP_KERNEL | GFP_DMA);
|
|
|
|
if (!lcu->rsu_cqr->cpaddr)
|
|
|
|
goto out_err3;
|
|
|
|
lcu->rsu_cqr->data = kzalloc(16, GFP_KERNEL | GFP_DMA);
|
|
|
|
if (!lcu->rsu_cqr->data)
|
|
|
|
goto out_err4;
|
|
|
|
|
|
|
|
memcpy(lcu->uid.vendor, uid->vendor, sizeof(uid->vendor));
|
|
|
|
memcpy(lcu->uid.serial, uid->serial, sizeof(uid->serial));
|
|
|
|
lcu->uid.ssid = uid->ssid;
|
|
|
|
lcu->pav = NO_PAV;
|
|
|
|
lcu->flags = NEED_UAC_UPDATE | UPDATE_PENDING;
|
|
|
|
INIT_LIST_HEAD(&lcu->lcu);
|
|
|
|
INIT_LIST_HEAD(&lcu->inactive_devices);
|
|
|
|
INIT_LIST_HEAD(&lcu->active_devices);
|
|
|
|
INIT_LIST_HEAD(&lcu->grouplist);
|
|
|
|
INIT_WORK(&lcu->suc_data.worker, summary_unit_check_handling_work);
|
|
|
|
INIT_DELAYED_WORK(&lcu->ruac_data.dwork, lcu_update_work);
|
|
|
|
spin_lock_init(&lcu->lock);
|
2009-12-07 18:51:53 +07:00
|
|
|
init_completion(&lcu->lcu_setup);
|
2008-01-26 20:11:23 +07:00
|
|
|
return lcu;
|
|
|
|
|
|
|
|
out_err4:
|
|
|
|
kfree(lcu->rsu_cqr->cpaddr);
|
|
|
|
out_err3:
|
|
|
|
kfree(lcu->rsu_cqr);
|
|
|
|
out_err2:
|
|
|
|
kfree(lcu->uac);
|
|
|
|
out_err1:
|
|
|
|
kfree(lcu);
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _free_lcu(struct alias_lcu *lcu)
|
|
|
|
{
|
|
|
|
kfree(lcu->rsu_cqr->data);
|
|
|
|
kfree(lcu->rsu_cqr->cpaddr);
|
|
|
|
kfree(lcu->rsu_cqr);
|
|
|
|
kfree(lcu->uac);
|
|
|
|
kfree(lcu);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the function that will allocate all the server and lcu data,
|
|
|
|
* so this function must be called first for a new device.
|
|
|
|
* If the return value is 1, the lcu was already known before, if it
|
|
|
|
* is 0, this is a new lcu.
|
|
|
|
* Negative return code indicates that something went wrong (e.g. -ENOMEM)
|
|
|
|
*/
|
|
|
|
int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
|
|
|
|
{
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
unsigned long flags;
|
|
|
|
struct alias_server *server, *newserver;
|
|
|
|
struct alias_lcu *lcu, *newlcu;
|
2010-05-17 15:00:11 +07:00
|
|
|
struct dasd_uid uid;
|
2008-01-26 20:11:23 +07:00
|
|
|
|
2010-05-17 15:00:11 +07:00
|
|
|
device->discipline->get_uid(device, &uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_lock_irqsave(&aliastree.lock, flags);
|
2010-05-17 15:00:11 +07:00
|
|
|
server = _find_server(&uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (!server) {
|
|
|
|
spin_unlock_irqrestore(&aliastree.lock, flags);
|
2010-05-17 15:00:11 +07:00
|
|
|
newserver = _allocate_server(&uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (IS_ERR(newserver))
|
|
|
|
return PTR_ERR(newserver);
|
|
|
|
spin_lock_irqsave(&aliastree.lock, flags);
|
2010-05-17 15:00:11 +07:00
|
|
|
server = _find_server(&uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (!server) {
|
|
|
|
list_add(&newserver->server, &aliastree.serverlist);
|
|
|
|
server = newserver;
|
|
|
|
} else {
|
|
|
|
/* someone was faster */
|
|
|
|
_free_server(newserver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-17 15:00:11 +07:00
|
|
|
lcu = _find_lcu(server, &uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (!lcu) {
|
|
|
|
spin_unlock_irqrestore(&aliastree.lock, flags);
|
2010-05-17 15:00:11 +07:00
|
|
|
newlcu = _allocate_lcu(&uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (IS_ERR(newlcu))
|
2009-12-18 23:43:17 +07:00
|
|
|
return PTR_ERR(newlcu);
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_lock_irqsave(&aliastree.lock, flags);
|
2010-05-17 15:00:11 +07:00
|
|
|
lcu = _find_lcu(server, &uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (!lcu) {
|
|
|
|
list_add(&newlcu->lcu, &server->lculist);
|
|
|
|
lcu = newlcu;
|
|
|
|
} else {
|
|
|
|
/* someone was faster */
|
|
|
|
_free_lcu(newlcu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_lock(&lcu->lock);
|
|
|
|
list_add(&device->alias_list, &lcu->inactive_devices);
|
|
|
|
private->lcu = lcu;
|
|
|
|
spin_unlock(&lcu->lock);
|
|
|
|
spin_unlock_irqrestore(&aliastree.lock, flags);
|
|
|
|
|
2012-01-19 00:03:40 +07:00
|
|
|
return 0;
|
2009-12-07 18:51:53 +07:00
|
|
|
}
|
|
|
|
|
2008-01-26 20:11:23 +07:00
|
|
|
/*
|
|
|
|
* This function removes a device from the scope of alias management.
|
|
|
|
* The complicated part is to make sure that it is not in use by
|
|
|
|
* any of the workers. If necessary cancel the work.
|
|
|
|
*/
|
|
|
|
void dasd_alias_disconnect_device_from_lcu(struct dasd_device *device)
|
|
|
|
{
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
unsigned long flags;
|
|
|
|
struct alias_lcu *lcu;
|
|
|
|
struct alias_server *server;
|
|
|
|
int was_pending;
|
2010-05-17 15:00:11 +07:00
|
|
|
struct dasd_uid uid;
|
2008-01-26 20:11:23 +07:00
|
|
|
|
|
|
|
lcu = private->lcu;
|
2011-01-31 17:30:03 +07:00
|
|
|
/* nothing to do if already disconnected */
|
|
|
|
if (!lcu)
|
|
|
|
return;
|
2010-05-17 15:00:11 +07:00
|
|
|
device->discipline->get_uid(device, &uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
list_del_init(&device->alias_list);
|
|
|
|
/* make sure that the workers don't use this device */
|
|
|
|
if (device == lcu->suc_data.device) {
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
cancel_work_sync(&lcu->suc_data.worker);
|
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
2015-12-15 16:45:05 +07:00
|
|
|
if (device == lcu->suc_data.device) {
|
|
|
|
dasd_put_device(device);
|
2008-01-26 20:11:23 +07:00
|
|
|
lcu->suc_data.device = NULL;
|
2015-12-15 16:45:05 +07:00
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
|
|
|
was_pending = 0;
|
|
|
|
if (device == lcu->ruac_data.device) {
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
was_pending = 1;
|
|
|
|
cancel_delayed_work_sync(&lcu->ruac_data.dwork);
|
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
2015-12-15 16:45:05 +07:00
|
|
|
if (device == lcu->ruac_data.device) {
|
|
|
|
dasd_put_device(device);
|
2008-01-26 20:11:23 +07:00
|
|
|
lcu->ruac_data.device = NULL;
|
2015-12-15 16:45:05 +07:00
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
|
|
|
private->lcu = NULL;
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&aliastree.lock, flags);
|
|
|
|
spin_lock(&lcu->lock);
|
|
|
|
if (list_empty(&lcu->grouplist) &&
|
|
|
|
list_empty(&lcu->active_devices) &&
|
|
|
|
list_empty(&lcu->inactive_devices)) {
|
|
|
|
list_del(&lcu->lcu);
|
|
|
|
spin_unlock(&lcu->lock);
|
|
|
|
_free_lcu(lcu);
|
|
|
|
lcu = NULL;
|
|
|
|
} else {
|
|
|
|
if (was_pending)
|
|
|
|
_schedule_lcu_update(lcu, NULL);
|
|
|
|
spin_unlock(&lcu->lock);
|
|
|
|
}
|
2010-05-17 15:00:11 +07:00
|
|
|
server = _find_server(&uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (server && list_empty(&server->lculist)) {
|
|
|
|
list_del(&server->server);
|
|
|
|
_free_server(server);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&aliastree.lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function assumes that the unit address configuration stored
|
|
|
|
* in the lcu is up to date and will update the device uid before
|
|
|
|
* adding it to a pav group.
|
|
|
|
*/
|
2010-05-17 15:00:11 +07:00
|
|
|
|
2008-01-26 20:11:23 +07:00
|
|
|
static int _add_device_to_lcu(struct alias_lcu *lcu,
|
2010-05-17 15:00:11 +07:00
|
|
|
struct dasd_device *device,
|
|
|
|
struct dasd_device *pos)
|
2008-01-26 20:11:23 +07:00
|
|
|
{
|
|
|
|
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
struct alias_pav_group *group;
|
2010-05-17 15:00:11 +07:00
|
|
|
struct dasd_uid uid;
|
2008-01-26 20:11:23 +07:00
|
|
|
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2010-05-17 15:00:11 +07:00
|
|
|
private->uid.type = lcu->uac->unit[private->uid.real_unit_addr].ua_type;
|
|
|
|
private->uid.base_unit_addr =
|
|
|
|
lcu->uac->unit[private->uid.real_unit_addr].base_ua;
|
|
|
|
uid = private->uid;
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
2008-01-26 20:11:23 +07:00
|
|
|
/* if we have no PAV anyway, we don't need to bother with PAV groups */
|
|
|
|
if (lcu->pav == NO_PAV) {
|
|
|
|
list_move(&device->alias_list, &lcu->active_devices);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-05-17 15:00:11 +07:00
|
|
|
group = _find_group(lcu, &uid);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (!group) {
|
|
|
|
group = kzalloc(sizeof(*group), GFP_ATOMIC);
|
|
|
|
if (!group)
|
|
|
|
return -ENOMEM;
|
2010-05-17 15:00:11 +07:00
|
|
|
memcpy(group->uid.vendor, uid.vendor, sizeof(uid.vendor));
|
|
|
|
memcpy(group->uid.serial, uid.serial, sizeof(uid.serial));
|
|
|
|
group->uid.ssid = uid.ssid;
|
|
|
|
if (uid.type == UA_BASE_DEVICE)
|
|
|
|
group->uid.base_unit_addr = uid.real_unit_addr;
|
2008-01-26 20:11:23 +07:00
|
|
|
else
|
2010-05-17 15:00:11 +07:00
|
|
|
group->uid.base_unit_addr = uid.base_unit_addr;
|
|
|
|
memcpy(group->uid.vduit, uid.vduit, sizeof(uid.vduit));
|
2008-01-26 20:11:23 +07:00
|
|
|
INIT_LIST_HEAD(&group->group);
|
|
|
|
INIT_LIST_HEAD(&group->baselist);
|
|
|
|
INIT_LIST_HEAD(&group->aliaslist);
|
|
|
|
list_add(&group->group, &lcu->grouplist);
|
|
|
|
}
|
2010-05-17 15:00:11 +07:00
|
|
|
if (uid.type == UA_BASE_DEVICE)
|
2008-01-26 20:11:23 +07:00
|
|
|
list_move(&device->alias_list, &group->baselist);
|
|
|
|
else
|
|
|
|
list_move(&device->alias_list, &group->aliaslist);
|
|
|
|
private->pavgroup = group;
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void _remove_device_from_lcu(struct alias_lcu *lcu,
|
|
|
|
struct dasd_device *device)
|
|
|
|
{
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
struct alias_pav_group *group;
|
|
|
|
|
|
|
|
list_move(&device->alias_list, &lcu->inactive_devices);
|
|
|
|
group = private->pavgroup;
|
|
|
|
if (!group)
|
|
|
|
return;
|
|
|
|
private->pavgroup = NULL;
|
|
|
|
if (list_empty(&group->baselist) && list_empty(&group->aliaslist)) {
|
|
|
|
list_del(&group->group);
|
|
|
|
kfree(group);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (group->next == device)
|
|
|
|
group->next = NULL;
|
|
|
|
};
|
|
|
|
|
2012-09-11 22:19:12 +07:00
|
|
|
static int
|
|
|
|
suborder_not_supported(struct dasd_ccw_req *cqr)
|
|
|
|
{
|
|
|
|
char *sense;
|
|
|
|
char reason;
|
|
|
|
char msg_format;
|
|
|
|
char msg_no;
|
|
|
|
|
2019-08-01 18:06:30 +07:00
|
|
|
/*
|
|
|
|
* intrc values ENODEV, ENOLINK and EPERM
|
|
|
|
* will be optained from sleep_on to indicate that no
|
|
|
|
* IO operation can be started
|
|
|
|
*/
|
|
|
|
if (cqr->intrc == -ENODEV)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (cqr->intrc == -ENOLINK)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (cqr->intrc == -EPERM)
|
|
|
|
return 1;
|
|
|
|
|
2012-09-11 22:19:12 +07:00
|
|
|
sense = dasd_get_sense(&cqr->irb);
|
|
|
|
if (!sense)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
reason = sense[0];
|
|
|
|
msg_format = (sense[7] & 0xF0);
|
|
|
|
msg_no = (sense[7] & 0x0F);
|
|
|
|
|
|
|
|
/* command reject, Format 0 MSG 4 - invalid parameter */
|
|
|
|
if ((reason == 0x80) && (msg_format == 0x00) && (msg_no == 0x04))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-26 20:11:23 +07:00
|
|
|
static int read_unit_address_configuration(struct dasd_device *device,
|
|
|
|
struct alias_lcu *lcu)
|
|
|
|
{
|
|
|
|
struct dasd_psf_prssd_data *prssdp;
|
|
|
|
struct dasd_ccw_req *cqr;
|
|
|
|
struct ccw1 *ccw;
|
|
|
|
int rc;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2018-06-05 00:18:03 +07:00
|
|
|
cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
|
2008-01-26 20:11:23 +07:00
|
|
|
(sizeof(struct dasd_psf_prssd_data)),
|
2018-06-05 00:18:03 +07:00
|
|
|
device, NULL);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (IS_ERR(cqr))
|
|
|
|
return PTR_ERR(cqr);
|
|
|
|
cqr->startdev = device;
|
|
|
|
cqr->memdev = device;
|
|
|
|
clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
|
|
|
|
cqr->retries = 10;
|
|
|
|
cqr->expires = 20 * HZ;
|
|
|
|
|
|
|
|
/* Prepare for Read Subsystem Data */
|
|
|
|
prssdp = (struct dasd_psf_prssd_data *) cqr->data;
|
|
|
|
memset(prssdp, 0, sizeof(struct dasd_psf_prssd_data));
|
|
|
|
prssdp->order = PSF_ORDER_PRSSD;
|
|
|
|
prssdp->suborder = 0x0e; /* Read unit address configuration */
|
|
|
|
/* all other bytes of prssdp must be zero */
|
|
|
|
|
|
|
|
ccw = cqr->cpaddr;
|
|
|
|
ccw->cmd_code = DASD_ECKD_CCW_PSF;
|
|
|
|
ccw->count = sizeof(struct dasd_psf_prssd_data);
|
|
|
|
ccw->flags |= CCW_FLAG_CC;
|
|
|
|
ccw->cda = (__u32)(addr_t) prssdp;
|
|
|
|
|
|
|
|
/* Read Subsystem Data - feature codes */
|
|
|
|
memset(lcu->uac, 0, sizeof(*(lcu->uac)));
|
|
|
|
|
|
|
|
ccw++;
|
|
|
|
ccw->cmd_code = DASD_ECKD_CCW_RSSD;
|
|
|
|
ccw->count = sizeof(*(lcu->uac));
|
|
|
|
ccw->cda = (__u32)(addr_t) lcu->uac;
|
|
|
|
|
2013-01-30 15:49:40 +07:00
|
|
|
cqr->buildclk = get_tod_clock();
|
2008-01-26 20:11:23 +07:00
|
|
|
cqr->status = DASD_CQR_FILLED;
|
|
|
|
|
|
|
|
/* need to unset flag here to detect race with summary unit check */
|
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
lcu->flags &= ~NEED_UAC_UPDATE;
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
|
2019-08-01 18:06:30 +07:00
|
|
|
rc = dasd_sleep_on(cqr);
|
|
|
|
if (rc && !suborder_not_supported(cqr)) {
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
lcu->flags |= NEED_UAC_UPDATE;
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
}
|
2018-06-05 00:18:03 +07:00
|
|
|
dasd_sfree_request(cqr, cqr->memdev);
|
2008-01-26 20:11:23 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _lcu_update(struct dasd_device *refdev, struct alias_lcu *lcu)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct alias_pav_group *pavgroup, *tempgroup;
|
|
|
|
struct dasd_device *device, *tempdev;
|
|
|
|
int i, rc;
|
|
|
|
struct dasd_eckd_private *private;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
list_for_each_entry_safe(pavgroup, tempgroup, &lcu->grouplist, group) {
|
|
|
|
list_for_each_entry_safe(device, tempdev, &pavgroup->baselist,
|
|
|
|
alias_list) {
|
|
|
|
list_move(&device->alias_list, &lcu->active_devices);
|
2016-03-04 16:34:05 +07:00
|
|
|
private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
private->pavgroup = NULL;
|
|
|
|
}
|
|
|
|
list_for_each_entry_safe(device, tempdev, &pavgroup->aliaslist,
|
|
|
|
alias_list) {
|
|
|
|
list_move(&device->alias_list, &lcu->active_devices);
|
2016-03-04 16:34:05 +07:00
|
|
|
private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
private->pavgroup = NULL;
|
|
|
|
}
|
|
|
|
list_del(&pavgroup->group);
|
|
|
|
kfree(pavgroup);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
|
|
|
|
rc = read_unit_address_configuration(refdev, lcu);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
2008-01-26 20:11:23 +07:00
|
|
|
lcu->pav = NO_PAV;
|
|
|
|
for (i = 0; i < MAX_DEVICES_PER_LCU; ++i) {
|
|
|
|
switch (lcu->uac->unit[i].ua_type) {
|
|
|
|
case UA_BASE_PAV_ALIAS:
|
|
|
|
lcu->pav = BASE_PAV;
|
|
|
|
break;
|
|
|
|
case UA_HYPER_PAV_ALIAS:
|
|
|
|
lcu->pav = HYPER_PAV;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (lcu->pav != NO_PAV)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry_safe(device, tempdev, &lcu->active_devices,
|
|
|
|
alias_list) {
|
2010-05-17 15:00:11 +07:00
|
|
|
_add_device_to_lcu(lcu, device, refdev);
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
2015-12-15 17:00:51 +07:00
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
2008-01-26 20:11:23 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lcu_update_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct alias_lcu *lcu;
|
|
|
|
struct read_uac_work_data *ruac_data;
|
|
|
|
struct dasd_device *device;
|
|
|
|
unsigned long flags;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
ruac_data = container_of(work, struct read_uac_work_data, dwork.work);
|
|
|
|
lcu = container_of(ruac_data, struct alias_lcu, ruac_data);
|
|
|
|
device = ruac_data->device;
|
|
|
|
rc = _lcu_update(device, lcu);
|
|
|
|
/*
|
|
|
|
* Need to check flags again, as there could have been another
|
|
|
|
* prepare_update or a new device a new device while we were still
|
|
|
|
* processing the data
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
2012-09-11 22:19:12 +07:00
|
|
|
if ((rc && (rc != -EOPNOTSUPP)) || (lcu->flags & NEED_UAC_UPDATE)) {
|
2009-03-26 21:23:49 +07:00
|
|
|
DBF_DEV_EVENT(DBF_WARNING, device, "could not update"
|
2008-01-26 20:11:23 +07:00
|
|
|
" alias data in lcu (rc = %d), retry later", rc);
|
2015-12-15 16:45:05 +07:00
|
|
|
if (!schedule_delayed_work(&lcu->ruac_data.dwork, 30*HZ))
|
|
|
|
dasd_put_device(device);
|
2008-01-26 20:11:23 +07:00
|
|
|
} else {
|
2015-12-15 16:45:05 +07:00
|
|
|
dasd_put_device(device);
|
2008-01-26 20:11:23 +07:00
|
|
|
lcu->ruac_data.device = NULL;
|
|
|
|
lcu->flags &= ~UPDATE_PENDING;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _schedule_lcu_update(struct alias_lcu *lcu,
|
|
|
|
struct dasd_device *device)
|
|
|
|
{
|
|
|
|
struct dasd_device *usedev = NULL;
|
|
|
|
struct alias_pav_group *group;
|
|
|
|
|
|
|
|
lcu->flags |= NEED_UAC_UPDATE;
|
|
|
|
if (lcu->ruac_data.device) {
|
|
|
|
/* already scheduled or running */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (device && !list_empty(&device->alias_list))
|
|
|
|
usedev = device;
|
|
|
|
|
|
|
|
if (!usedev && !list_empty(&lcu->grouplist)) {
|
|
|
|
group = list_first_entry(&lcu->grouplist,
|
|
|
|
struct alias_pav_group, group);
|
|
|
|
if (!list_empty(&group->baselist))
|
|
|
|
usedev = list_first_entry(&group->baselist,
|
|
|
|
struct dasd_device,
|
|
|
|
alias_list);
|
|
|
|
else if (!list_empty(&group->aliaslist))
|
|
|
|
usedev = list_first_entry(&group->aliaslist,
|
|
|
|
struct dasd_device,
|
|
|
|
alias_list);
|
|
|
|
}
|
|
|
|
if (!usedev && !list_empty(&lcu->active_devices)) {
|
|
|
|
usedev = list_first_entry(&lcu->active_devices,
|
|
|
|
struct dasd_device, alias_list);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* if we haven't found a proper device yet, give up for now, the next
|
|
|
|
* device that will be set active will trigger an lcu update
|
|
|
|
*/
|
|
|
|
if (!usedev)
|
|
|
|
return -EINVAL;
|
2015-12-15 16:45:05 +07:00
|
|
|
dasd_get_device(usedev);
|
2008-01-26 20:11:23 +07:00
|
|
|
lcu->ruac_data.device = usedev;
|
2015-12-15 16:45:05 +07:00
|
|
|
if (!schedule_delayed_work(&lcu->ruac_data.dwork, 0))
|
|
|
|
dasd_put_device(usedev);
|
2008-01-26 20:11:23 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dasd_alias_add_device(struct dasd_device *device)
|
|
|
|
{
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
2018-04-12 18:38:22 +07:00
|
|
|
__u8 uaddr = private->uid.real_unit_addr;
|
|
|
|
struct alias_lcu *lcu = private->lcu;
|
2008-01-26 20:11:23 +07:00
|
|
|
unsigned long flags;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = 0;
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
2018-04-12 18:38:22 +07:00
|
|
|
/*
|
|
|
|
* Check if device and lcu type differ. If so, the uac data may be
|
|
|
|
* outdated and needs to be updated.
|
|
|
|
*/
|
|
|
|
if (private->uid.type != lcu->uac->unit[uaddr].ua_type) {
|
|
|
|
lcu->flags |= UPDATE_PENDING;
|
|
|
|
DBF_DEV_EVENT(DBF_WARNING, device, "%s",
|
|
|
|
"uid type mismatch - trigger rescan");
|
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
if (!(lcu->flags & UPDATE_PENDING)) {
|
2010-05-17 15:00:11 +07:00
|
|
|
rc = _add_device_to_lcu(lcu, device, device);
|
2008-01-26 20:11:23 +07:00
|
|
|
if (rc)
|
|
|
|
lcu->flags |= UPDATE_PENDING;
|
|
|
|
}
|
|
|
|
if (lcu->flags & UPDATE_PENDING) {
|
|
|
|
list_move(&device->alias_list, &lcu->active_devices);
|
|
|
|
_schedule_lcu_update(lcu, device);
|
|
|
|
}
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
2008-01-26 20:11:23 +07:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-05-17 15:00:10 +07:00
|
|
|
int dasd_alias_update_add_device(struct dasd_device *device)
|
|
|
|
{
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
|
|
|
|
2010-05-17 15:00:10 +07:00
|
|
|
private->lcu->flags |= UPDATE_PENDING;
|
|
|
|
return dasd_alias_add_device(device);
|
|
|
|
}
|
|
|
|
|
2008-01-26 20:11:23 +07:00
|
|
|
int dasd_alias_remove_device(struct dasd_device *device)
|
|
|
|
{
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
|
|
|
struct alias_lcu *lcu = private->lcu;
|
2008-01-26 20:11:23 +07:00
|
|
|
unsigned long flags;
|
|
|
|
|
2011-01-31 17:30:03 +07:00
|
|
|
/* nothing to do if already removed */
|
|
|
|
if (!lcu)
|
|
|
|
return 0;
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
_remove_device_from_lcu(lcu, device);
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *base_device)
|
|
|
|
{
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *alias_priv, *private = base_device->private;
|
|
|
|
struct alias_pav_group *group = private->pavgroup;
|
|
|
|
struct alias_lcu *lcu = private->lcu;
|
2008-01-26 20:11:23 +07:00
|
|
|
struct dasd_device *alias_device;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (!group || !lcu)
|
|
|
|
return NULL;
|
|
|
|
if (lcu->pav == NO_PAV ||
|
|
|
|
lcu->flags & (NEED_UAC_UPDATE | UPDATE_PENDING))
|
|
|
|
return NULL;
|
2011-12-27 17:27:28 +07:00
|
|
|
if (unlikely(!(private->features.feature[8] & 0x01))) {
|
|
|
|
/*
|
|
|
|
* PAV enabled but prefix not, very unlikely
|
|
|
|
* seems to be a lost pathgroup
|
|
|
|
* use base device to do IO
|
|
|
|
*/
|
|
|
|
DBF_DEV_EVENT(DBF_ERR, base_device, "%s",
|
|
|
|
"Prefix not enabled with PAV enabled\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
|
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
alias_device = group->next;
|
|
|
|
if (!alias_device) {
|
|
|
|
if (list_empty(&group->aliaslist)) {
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
alias_device = list_first_entry(&group->aliaslist,
|
|
|
|
struct dasd_device,
|
|
|
|
alias_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (list_is_last(&alias_device->alias_list, &group->aliaslist))
|
|
|
|
group->next = list_first_entry(&group->aliaslist,
|
|
|
|
struct dasd_device, alias_list);
|
|
|
|
else
|
|
|
|
group->next = list_first_entry(&alias_device->alias_list,
|
|
|
|
struct dasd_device, alias_list);
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
2016-03-04 16:34:05 +07:00
|
|
|
alias_priv = alias_device->private;
|
2015-07-10 15:47:09 +07:00
|
|
|
if ((alias_priv->count < private->count) && !alias_device->stopped &&
|
|
|
|
!test_bit(DASD_FLAG_OFFLINE, &alias_device->flags))
|
2008-01-26 20:11:23 +07:00
|
|
|
return alias_device;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Summary unit check handling depends on the way alias devices
|
|
|
|
* are handled so it is done here rather then in dasd_eckd.c
|
|
|
|
*/
|
|
|
|
static int reset_summary_unit_check(struct alias_lcu *lcu,
|
|
|
|
struct dasd_device *device,
|
|
|
|
char reason)
|
|
|
|
{
|
|
|
|
struct dasd_ccw_req *cqr;
|
|
|
|
int rc = 0;
|
2009-03-26 21:23:48 +07:00
|
|
|
struct ccw1 *ccw;
|
2008-01-26 20:11:23 +07:00
|
|
|
|
|
|
|
cqr = lcu->rsu_cqr;
|
2018-06-17 17:18:56 +07:00
|
|
|
memcpy((char *) &cqr->magic, "ECKD", 4);
|
2008-01-26 20:11:23 +07:00
|
|
|
ASCEBC((char *) &cqr->magic, 4);
|
2009-03-26 21:23:48 +07:00
|
|
|
ccw = cqr->cpaddr;
|
|
|
|
ccw->cmd_code = DASD_ECKD_CCW_RSCK;
|
2015-12-15 16:16:43 +07:00
|
|
|
ccw->flags = CCW_FLAG_SLI;
|
2009-03-26 21:23:48 +07:00
|
|
|
ccw->count = 16;
|
|
|
|
ccw->cda = (__u32)(addr_t) cqr->data;
|
2008-01-26 20:11:23 +07:00
|
|
|
((char *)cqr->data)[0] = reason;
|
|
|
|
|
|
|
|
clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
|
|
|
|
cqr->retries = 255; /* set retry counter to enable basic ERP */
|
|
|
|
cqr->startdev = device;
|
|
|
|
cqr->memdev = device;
|
|
|
|
cqr->block = NULL;
|
|
|
|
cqr->expires = 5 * HZ;
|
2013-01-30 15:49:40 +07:00
|
|
|
cqr->buildclk = get_tod_clock();
|
2008-01-26 20:11:23 +07:00
|
|
|
cqr->status = DASD_CQR_FILLED;
|
|
|
|
|
|
|
|
rc = dasd_sleep_on_immediatly(cqr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _restart_all_base_devices_on_lcu(struct alias_lcu *lcu)
|
|
|
|
{
|
|
|
|
struct alias_pav_group *pavgroup;
|
|
|
|
struct dasd_device *device;
|
|
|
|
struct dasd_eckd_private *private;
|
|
|
|
|
|
|
|
/* active and inactive list can contain alias as well as base devices */
|
|
|
|
list_for_each_entry(device, &lcu->active_devices, alias_list) {
|
2016-03-04 16:34:05 +07:00
|
|
|
private = device->private;
|
2015-12-15 17:00:51 +07:00
|
|
|
if (private->uid.type != UA_BASE_DEVICE)
|
2008-01-26 20:11:23 +07:00
|
|
|
continue;
|
|
|
|
dasd_schedule_block_bh(device->block);
|
|
|
|
dasd_schedule_device_bh(device);
|
|
|
|
}
|
|
|
|
list_for_each_entry(device, &lcu->inactive_devices, alias_list) {
|
2016-03-04 16:34:05 +07:00
|
|
|
private = device->private;
|
2015-12-15 17:00:51 +07:00
|
|
|
if (private->uid.type != UA_BASE_DEVICE)
|
2008-01-26 20:11:23 +07:00
|
|
|
continue;
|
|
|
|
dasd_schedule_block_bh(device->block);
|
|
|
|
dasd_schedule_device_bh(device);
|
|
|
|
}
|
|
|
|
list_for_each_entry(pavgroup, &lcu->grouplist, group) {
|
|
|
|
list_for_each_entry(device, &pavgroup->baselist, alias_list) {
|
|
|
|
dasd_schedule_block_bh(device->block);
|
|
|
|
dasd_schedule_device_bh(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void flush_all_alias_devices_on_lcu(struct alias_lcu *lcu)
|
|
|
|
{
|
|
|
|
struct alias_pav_group *pavgroup;
|
|
|
|
struct dasd_device *device, *temp;
|
|
|
|
struct dasd_eckd_private *private;
|
|
|
|
unsigned long flags;
|
|
|
|
LIST_HEAD(active);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Problem here ist that dasd_flush_device_queue may wait
|
|
|
|
* for termination of a request to complete. We can't keep
|
|
|
|
* the lcu lock during that time, so we must assume that
|
|
|
|
* the lists may have changed.
|
|
|
|
* Idea: first gather all active alias devices in a separate list,
|
|
|
|
* then flush the first element of this list unlocked, and afterwards
|
|
|
|
* check if it is still on the list before moving it to the
|
|
|
|
* active_devices list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
list_for_each_entry_safe(device, temp, &lcu->active_devices,
|
|
|
|
alias_list) {
|
2016-03-04 16:34:05 +07:00
|
|
|
private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
if (private->uid.type == UA_BASE_DEVICE)
|
|
|
|
continue;
|
|
|
|
list_move(&device->alias_list, &active);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry(pavgroup, &lcu->grouplist, group) {
|
|
|
|
list_splice_init(&pavgroup->aliaslist, &active);
|
|
|
|
}
|
|
|
|
while (!list_empty(&active)) {
|
|
|
|
device = list_first_entry(&active, struct dasd_device,
|
|
|
|
alias_list);
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
2017-06-27 00:26:55 +07:00
|
|
|
dasd_flush_device_queue(device);
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
|
|
|
/*
|
|
|
|
* only move device around if it wasn't moved away while we
|
|
|
|
* were waiting for the flush
|
|
|
|
*/
|
|
|
|
if (device == list_first_entry(&active,
|
2015-10-14 16:01:05 +07:00
|
|
|
struct dasd_device, alias_list)) {
|
2008-01-26 20:11:23 +07:00
|
|
|
list_move(&device->alias_list, &lcu->active_devices);
|
2016-03-04 16:34:05 +07:00
|
|
|
private = device->private;
|
2015-10-14 16:01:05 +07:00
|
|
|
private->pavgroup = NULL;
|
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
}
|
|
|
|
|
2015-12-15 17:00:51 +07:00
|
|
|
static void _stop_all_devices_on_lcu(struct alias_lcu *lcu)
|
2008-01-26 20:11:23 +07:00
|
|
|
{
|
|
|
|
struct alias_pav_group *pavgroup;
|
2015-12-15 17:00:51 +07:00
|
|
|
struct dasd_device *device;
|
2008-01-26 20:11:23 +07:00
|
|
|
|
2016-02-23 16:15:27 +07:00
|
|
|
list_for_each_entry(device, &lcu->active_devices, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2015-12-15 17:00:51 +07:00
|
|
|
dasd_device_set_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
|
|
|
list_for_each_entry(device, &lcu->inactive_devices, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2015-12-15 17:00:51 +07:00
|
|
|
dasd_device_set_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
list_for_each_entry(pavgroup, &lcu->grouplist, group) {
|
2016-02-23 16:15:27 +07:00
|
|
|
list_for_each_entry(device, &pavgroup->baselist, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2015-12-15 17:00:51 +07:00
|
|
|
dasd_device_set_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
|
|
|
list_for_each_entry(device, &pavgroup->aliaslist, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2015-12-15 17:00:51 +07:00
|
|
|
dasd_device_set_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _unstop_all_devices_on_lcu(struct alias_lcu *lcu)
|
|
|
|
{
|
|
|
|
struct alias_pav_group *pavgroup;
|
|
|
|
struct dasd_device *device;
|
|
|
|
|
2016-02-23 16:15:27 +07:00
|
|
|
list_for_each_entry(device, &lcu->active_devices, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2009-12-07 18:51:51 +07:00
|
|
|
dasd_device_remove_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
|
|
|
list_for_each_entry(device, &lcu->inactive_devices, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2009-12-07 18:51:51 +07:00
|
|
|
dasd_device_remove_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
list_for_each_entry(pavgroup, &lcu->grouplist, group) {
|
2016-02-23 16:15:27 +07:00
|
|
|
list_for_each_entry(device, &pavgroup->baselist, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2009-12-07 18:51:51 +07:00
|
|
|
dasd_device_remove_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
|
|
|
list_for_each_entry(device, &pavgroup->aliaslist, alias_list) {
|
|
|
|
spin_lock(get_ccwdev_lock(device->cdev));
|
2009-12-07 18:51:51 +07:00
|
|
|
dasd_device_remove_stop_bits(device, DASD_STOPPED_SU);
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_unlock(get_ccwdev_lock(device->cdev));
|
|
|
|
}
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void summary_unit_check_handling_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct alias_lcu *lcu;
|
|
|
|
struct summary_unit_check_work_data *suc_data;
|
|
|
|
unsigned long flags;
|
|
|
|
struct dasd_device *device;
|
|
|
|
|
|
|
|
suc_data = container_of(work, struct summary_unit_check_work_data,
|
|
|
|
worker);
|
|
|
|
lcu = container_of(suc_data, struct alias_lcu, suc_data);
|
|
|
|
device = suc_data->device;
|
|
|
|
|
|
|
|
/* 1. flush alias devices */
|
|
|
|
flush_all_alias_devices_on_lcu(lcu);
|
|
|
|
|
|
|
|
/* 2. reset summary unit check */
|
|
|
|
spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
|
2009-12-07 18:51:51 +07:00
|
|
|
dasd_device_remove_stop_bits(device,
|
|
|
|
(DASD_STOPPED_SU | DASD_STOPPED_PENDING));
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
|
|
|
|
reset_summary_unit_check(lcu, device, suc_data->reason);
|
|
|
|
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
2008-01-26 20:11:23 +07:00
|
|
|
_unstop_all_devices_on_lcu(lcu);
|
|
|
|
_restart_all_base_devices_on_lcu(lcu);
|
|
|
|
/* 3. read new alias configuration */
|
|
|
|
_schedule_lcu_update(lcu, device);
|
|
|
|
lcu->suc_data.device = NULL;
|
2015-12-15 16:45:05 +07:00
|
|
|
dasd_put_device(device);
|
2008-01-26 20:11:23 +07:00
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:15:27 +07:00
|
|
|
void dasd_alias_handle_summary_unit_check(struct work_struct *work)
|
2008-01-26 20:11:23 +07:00
|
|
|
{
|
2016-02-23 16:15:27 +07:00
|
|
|
struct dasd_device *device = container_of(work, struct dasd_device,
|
|
|
|
suc_work);
|
2016-03-04 16:34:05 +07:00
|
|
|
struct dasd_eckd_private *private = device->private;
|
2008-01-26 20:11:23 +07:00
|
|
|
struct alias_lcu *lcu;
|
2016-02-23 16:15:27 +07:00
|
|
|
unsigned long flags;
|
2008-01-26 20:11:23 +07:00
|
|
|
|
|
|
|
lcu = private->lcu;
|
|
|
|
if (!lcu) {
|
2009-03-26 21:23:49 +07:00
|
|
|
DBF_DEV_EVENT(DBF_WARNING, device, "%s",
|
2008-01-26 20:11:23 +07:00
|
|
|
"device not ready to handle summary"
|
|
|
|
" unit check (no lcu structure)");
|
2016-02-23 16:15:27 +07:00
|
|
|
goto out;
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
2016-02-23 16:15:27 +07:00
|
|
|
spin_lock_irqsave(&lcu->lock, flags);
|
2008-01-26 20:11:23 +07:00
|
|
|
/* If this device is about to be removed just return and wait for
|
|
|
|
* the next interrupt on a different device
|
|
|
|
*/
|
|
|
|
if (list_empty(&device->alias_list)) {
|
2009-03-26 21:23:49 +07:00
|
|
|
DBF_DEV_EVENT(DBF_WARNING, device, "%s",
|
2008-01-26 20:11:23 +07:00
|
|
|
"device is in offline processing,"
|
|
|
|
" don't do summary unit check handling");
|
2016-02-23 16:15:27 +07:00
|
|
|
goto out_unlock;
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
|
|
|
if (lcu->suc_data.device) {
|
|
|
|
/* already scheduled or running */
|
2009-03-26 21:23:49 +07:00
|
|
|
DBF_DEV_EVENT(DBF_WARNING, device, "%s",
|
2008-01-26 20:11:23 +07:00
|
|
|
"previous instance of summary unit check worker"
|
|
|
|
" still pending");
|
2016-02-23 16:15:27 +07:00
|
|
|
goto out_unlock;
|
2008-01-26 20:11:23 +07:00
|
|
|
}
|
2015-12-15 17:00:51 +07:00
|
|
|
_stop_all_devices_on_lcu(lcu);
|
|
|
|
/* prepare for lcu_update */
|
2016-02-23 16:15:27 +07:00
|
|
|
lcu->flags |= NEED_UAC_UPDATE | UPDATE_PENDING;
|
|
|
|
lcu->suc_data.reason = private->suc_reason;
|
2008-01-26 20:11:23 +07:00
|
|
|
lcu->suc_data.device = device;
|
2015-12-15 16:45:05 +07:00
|
|
|
dasd_get_device(device);
|
|
|
|
if (!schedule_work(&lcu->suc_data.worker))
|
|
|
|
dasd_put_device(device);
|
2016-02-23 16:15:27 +07:00
|
|
|
out_unlock:
|
|
|
|
spin_unlock_irqrestore(&lcu->lock, flags);
|
|
|
|
out:
|
|
|
|
clear_bit(DASD_FLAG_SUC, &device->flags);
|
|
|
|
dasd_put_device(device);
|
2008-01-26 20:11:23 +07:00
|
|
|
};
|