Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
6295e6cf
Commit
6295e6cf
authored
Nov 20, 2002
by
Christoph Hellwig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] split busy check out of scsi_remove_host
just a simple code cleanup
parent
a61bd040
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
38 deletions
+45
-38
drivers/scsi/hosts.c
drivers/scsi/hosts.c
+45
-38
No files found.
drivers/scsi/hosts.c
View file @
6295e6cf
...
...
@@ -208,6 +208,48 @@ static int scsi_remove_legacy_host(struct Scsi_Host *shost)
return
0
;
}
static
int
scsi_check_device_busy
(
struct
scsi_device
*
sdev
)
{
struct
Scsi_Host
*
shost
=
sdev
->
host
;
struct
scsi_cmnd
*
scmd
;
/*
* Loop over all of the commands associated with the
* device. If any of them are busy, then set the state
* back to inactive and bail.
*/
for
(
scmd
=
sdev
->
device_queue
;
scmd
;
scmd
=
scmd
->
next
)
{
if
(
scmd
->
request
&&
scmd
->
request
->
rq_status
!=
RQ_INACTIVE
)
goto
active
;
/*
* No, this device is really free. Mark it as such, and
* continue on.
*/
scmd
->
state
=
SCSI_STATE_DISCONNECTING
;
if
(
scmd
->
request
)
scmd
->
request
->
rq_status
=
RQ_SCSI_DISCONNECTING
;
}
return
0
;
active:
printk
(
KERN_ERR
"SCSI device not inactive - rq_status=%d, target=%d, "
"pid=%ld, state=%d, owner=%d.
\n
"
,
scmd
->
request
->
rq_status
,
scmd
->
target
,
scmd
->
pid
,
scmd
->
state
,
scmd
->
owner
);
for
(
sdev
=
shost
->
host_queue
;
sdev
;
sdev
=
sdev
->
next
)
{
for
(
scmd
=
sdev
->
device_queue
;
scmd
;
scmd
=
scmd
->
next
)
{
if
(
scmd
->
request
->
rq_status
==
RQ_SCSI_DISCONNECTING
)
scmd
->
request
->
rq_status
=
RQ_INACTIVE
;
}
}
printk
(
KERN_ERR
"Device busy???
\n
"
);
return
1
;
}
/**
* scsi_remove_host - check a scsi host for release and release
* @shost: a pointer to a scsi host to release
...
...
@@ -218,7 +260,6 @@ static int scsi_remove_legacy_host(struct Scsi_Host *shost)
int
scsi_remove_host
(
struct
Scsi_Host
*
shost
)
{
struct
scsi_device
*
sdev
;
struct
scsi_cmnd
*
scmd
;
/*
* FIXME Do ref counting. We force all of the devices offline to
...
...
@@ -228,43 +269,9 @@ int scsi_remove_host(struct Scsi_Host *shost)
for
(
sdev
=
shost
->
host_queue
;
sdev
;
sdev
=
sdev
->
next
)
sdev
->
online
=
FALSE
;
for
(
sdev
=
shost
->
host_queue
;
sdev
;
sdev
=
sdev
->
next
)
{
/*
* Loop over all of the commands associated with the
* device. If any of them are busy, then set the state
* back to inactive and bail.
*/
for
(
scmd
=
sdev
->
device_queue
;
scmd
;
scmd
=
scmd
->
next
)
{
if
(
scmd
->
request
&&
scmd
->
request
->
rq_status
!=
RQ_INACTIVE
)
{
printk
(
KERN_ERR
"SCSI device not inactive"
"- rq_status=%d, target=%d, pid=%ld,"
"state=%d, owner=%d.
\n
"
,
scmd
->
request
->
rq_status
,
scmd
->
target
,
scmd
->
pid
,
scmd
->
state
,
scmd
->
owner
);
for
(
sdev
=
shost
->
host_queue
;
sdev
;
sdev
=
sdev
->
next
)
{
for
(
scmd
=
sdev
->
device_queue
;
scmd
;
scmd
=
scmd
->
next
)
if
(
scmd
->
request
->
rq_status
==
RQ_SCSI_DISCONNECTING
)
scmd
->
request
->
rq_status
=
RQ_INACTIVE
;
}
printk
(
KERN_ERR
"Device busy???
\n
"
);
return
1
;
}
/*
* No, this device is really free. Mark it as such, and
* continue on.
*/
scmd
->
state
=
SCSI_STATE_DISCONNECTING
;
if
(
scmd
->
request
)
scmd
->
request
->
rq_status
=
RQ_SCSI_DISCONNECTING
;
/* Mark as
busy */
}
}
for
(
sdev
=
shost
->
host_queue
;
sdev
;
sdev
=
sdev
->
next
)
if
(
scsi_check_device_busy
(
sdev
))
return
1
;
/*
* Next we detach the high level drivers from the Scsi_Device
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment