Skip to content

Commit

Permalink
[SCSI] zfcp: Move FSF request tracking code to new file
Browse files Browse the repository at this point in the history
Move the code for tracking FSF requests to new file to have this code
in one place. The functions for adding and removing requests on the
I/O path are already inline. The alloc and free functions are only
called once, so it does not hurt to inline them and add them to the
same file.

Reviewed-by: Swen Schillig <[email protected]>
Signed-off-by: Christof Schmitt <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
Christof Schmitt authored and James Bottomley committed Feb 17, 2010
1 parent e60a6d6 commit b6bd2fb
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 98 deletions.
36 changes: 3 additions & 33 deletions drivers/s390/scsi/zfcp_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/seq_file.h>
#include "zfcp_ext.h"
#include "zfcp_fc.h"
#include "zfcp_reqlist.h"

#define ZFCP_BUS_ID_SIZE 20

Expand All @@ -49,36 +50,6 @@ static struct kmem_cache *zfcp_cache_hw_align(const char *name,
return kmem_cache_create(name, size, roundup_pow_of_two(size), 0, NULL);
}

static int zfcp_reqlist_alloc(struct zfcp_adapter *adapter)
{
int idx;

adapter->req_list = kcalloc(REQUEST_LIST_SIZE, sizeof(struct list_head),
GFP_KERNEL);
if (!adapter->req_list)
return -ENOMEM;

for (idx = 0; idx < REQUEST_LIST_SIZE; idx++)
INIT_LIST_HEAD(&adapter->req_list[idx]);
return 0;
}

/**
* zfcp_reqlist_isempty - is the request list empty
* @adapter: pointer to struct zfcp_adapter
*
* Returns: true if list is empty, false otherwise
*/
int zfcp_reqlist_isempty(struct zfcp_adapter *adapter)
{
unsigned int idx;

for (idx = 0; idx < REQUEST_LIST_SIZE; idx++)
if (!list_empty(&adapter->req_list[idx]))
return 0;
return 1;
}

static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun)
{
struct ccw_device *cdev;
Expand Down Expand Up @@ -539,7 +510,8 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
if (zfcp_allocate_low_mem_buffers(adapter))
goto failed;

if (zfcp_reqlist_alloc(adapter))
adapter->req_list = zfcp_reqlist_alloc();
if (!adapter->req_list)
goto failed;

if (zfcp_dbf_adapter_register(adapter))
Expand All @@ -560,8 +532,6 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
INIT_LIST_HEAD(&adapter->erp_ready_head);
INIT_LIST_HEAD(&adapter->erp_running_head);

spin_lock_init(&adapter->req_list_lock);

rwlock_init(&adapter->erp_lock);
rwlock_init(&adapter->abort_lock);

Expand Down
3 changes: 2 additions & 1 deletion drivers/s390/scsi/zfcp_ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt

#include "zfcp_ext.h"
#include "zfcp_reqlist.h"

#define ZFCP_MODEL_PRIV 0x4

Expand Down Expand Up @@ -162,7 +163,7 @@ static int zfcp_ccw_set_online(struct ccw_device *cdev)
}

/* initialize request counter */
BUG_ON(!zfcp_reqlist_isempty(adapter));
BUG_ON(!zfcp_reqlist_isempty(adapter->req_list));
adapter->req_no = 0;

zfcp_erp_modify_adapter_status(adapter, "ccsonl1", NULL,
Expand Down
34 changes: 2 additions & 32 deletions drivers/s390/scsi/zfcp_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
#include <asm/sysinfo.h>
#include "zfcp_fsf.h"

/********************* GENERAL DEFINES *********************************/

#define REQUEST_LIST_SIZE 128
struct zfcp_reqlist;

/********************* SCSI SPECIFIC DEFINES *********************************/
#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
Expand Down Expand Up @@ -206,8 +204,7 @@ struct zfcp_adapter {
struct list_head port_list; /* remote port list */
rwlock_t port_list_lock; /* port list lock */
unsigned long req_no; /* unique FSF req number */
struct list_head *req_list; /* list of pending reqs */
spinlock_t req_list_lock; /* request list lock */
struct zfcp_reqlist *req_list;
u32 fsf_req_seq_no; /* FSF cmnd seq number */
rwlock_t abort_lock; /* Protects against SCSI
stack abort/command
Expand Down Expand Up @@ -351,31 +348,4 @@ struct zfcp_data {
#define ZFCP_SET 0x00000100
#define ZFCP_CLEAR 0x00000200

/*
* Helper functions for request ID management.
*/
static inline int zfcp_reqlist_hash(unsigned long req_id)
{
return req_id % REQUEST_LIST_SIZE;
}

static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
struct zfcp_fsf_req *fsf_req)
{
list_del(&fsf_req->list);
}

static inline struct zfcp_fsf_req *
zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id)
{
struct zfcp_fsf_req *request;
unsigned int idx;

idx = zfcp_reqlist_hash(req_id);
list_for_each_entry(request, &adapter->req_list[idx], list)
if (request->req_id == req_id)
return request;
return NULL;
}

#endif /* ZFCP_DEF_H */
7 changes: 4 additions & 3 deletions drivers/s390/scsi/zfcp_erp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <linux/kthread.h>
#include "zfcp_ext.h"
#include "zfcp_reqlist.h"

#define ZFCP_MAX_ERPS 3

Expand Down Expand Up @@ -483,8 +484,8 @@ static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act)
if (!act->fsf_req_id)
return;

spin_lock(&adapter->req_list_lock);
req = zfcp_reqlist_find(adapter, act->fsf_req_id);
spin_lock(&adapter->req_list->lock);
req = _zfcp_reqlist_find(adapter->req_list, act->fsf_req_id);
if (req && req->erp_action == act) {
if (act->status & (ZFCP_STATUS_ERP_DISMISSED |
ZFCP_STATUS_ERP_TIMEDOUT)) {
Expand All @@ -498,7 +499,7 @@ static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act)
act->fsf_req_id = 0;
} else
act->fsf_req_id = 0;
spin_unlock(&adapter->req_list_lock);
spin_unlock(&adapter->req_list->lock);
}

/**
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/scsi/zfcp_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *);
extern struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *, u64, u32,
u32);
extern struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *, u64);
extern int zfcp_reqlist_isempty(struct zfcp_adapter *);
extern void zfcp_sg_free_table(struct scatterlist *, int);
extern int zfcp_sg_setup_table(struct scatterlist *, int);
extern void zfcp_device_unregister(struct device *,
Expand Down
32 changes: 7 additions & 25 deletions drivers/s390/scsi/zfcp_fsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "zfcp_ext.h"
#include "zfcp_fc.h"
#include "zfcp_dbf.h"
#include "zfcp_reqlist.h"

static void zfcp_fsf_request_timeout_handler(unsigned long data)
{
Expand Down Expand Up @@ -457,15 +458,10 @@ static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
{
struct zfcp_fsf_req *req, *tmp;
unsigned long flags;
LIST_HEAD(remove_queue);
unsigned int i;

BUG_ON(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP);
spin_lock_irqsave(&adapter->req_list_lock, flags);
for (i = 0; i < REQUEST_LIST_SIZE; i++)
list_splice_init(&adapter->req_list[i], &remove_queue);
spin_unlock_irqrestore(&adapter->req_list_lock, flags);
zfcp_reqlist_move(adapter->req_list, &remove_queue);

list_for_each_entry_safe(req, tmp, &remove_queue, list) {
list_del(&req->list);
Expand Down Expand Up @@ -770,27 +766,17 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
{
struct zfcp_adapter *adapter = req->adapter;
struct zfcp_qdio *qdio = adapter->qdio;
unsigned long flags;
int idx;
int with_qtcb = (req->qtcb != NULL);
int with_qtcb = (req->qtcb != NULL);
int req_id = req->req_id;

/* put allocated FSF request into hash table */
spin_lock_irqsave(&adapter->req_list_lock, flags);
idx = zfcp_reqlist_hash(req_id);
list_add_tail(&req->list, &adapter->req_list[idx]);
spin_unlock_irqrestore(&adapter->req_list_lock, flags);
zfcp_reqlist_add(adapter->req_list, req);

req->queue_req.qdio_outb_usage = atomic_read(&qdio->req_q.count);
req->issued = get_clock();
if (zfcp_qdio_send(qdio, &req->queue_req)) {
del_timer(&req->timer);
spin_lock_irqsave(&adapter->req_list_lock, flags);
/* lookup request again, list might have changed */
req = zfcp_reqlist_find(adapter, req_id);
if (req)
zfcp_reqlist_remove(adapter, req);
spin_unlock_irqrestore(&adapter->req_list_lock, flags);
zfcp_reqlist_find_rm(adapter->req_list, req_id);
zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1", req);
return -EIO;
}
Expand Down Expand Up @@ -2518,15 +2504,14 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
struct qdio_buffer *sbal = qdio->resp_q.sbal[sbal_idx];
struct qdio_buffer_element *sbale;
struct zfcp_fsf_req *fsf_req;
unsigned long flags, req_id;
unsigned long req_id;
int idx;

for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) {

sbale = &sbal->element[idx];
req_id = (unsigned long) sbale->addr;
spin_lock_irqsave(&adapter->req_list_lock, flags);
fsf_req = zfcp_reqlist_find(adapter, req_id);
fsf_req = zfcp_reqlist_find_rm(adapter->req_list, req_id);

if (!fsf_req)
/*
Expand All @@ -2536,9 +2521,6 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
panic("error: unknown req_id (%lx) on adapter %s.\n",
req_id, dev_name(&adapter->ccw_device->dev));

list_del(&fsf_req->list);
spin_unlock_irqrestore(&adapter->req_list_lock, flags);

fsf_req->queue_req.sbal_response = sbal_idx;
fsf_req->queue_req.qdio_inb_usage =
atomic_read(&qdio->resp_q.count);
Expand Down
Loading

0 comments on commit b6bd2fb

Please sign in to comment.