Commit 95e159d6 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Christoph Hellwig

scsi: Implement sg_printk()

Update the sg driver to use dev_printk() variants instead of
plain printk(); this will prefix logging messages with the
appropriate device.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Acked-by: default avatarDoug Gilbert <dgilbert@interlog.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 96eefad2
...@@ -200,11 +200,11 @@ static ssize_t sg_new_write(Sg_fd *sfp, struct file *file, ...@@ -200,11 +200,11 @@ static ssize_t sg_new_write(Sg_fd *sfp, struct file *file,
static int sg_common_write(Sg_fd * sfp, Sg_request * srp, static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
unsigned char *cmnd, int timeout, int blocking); unsigned char *cmnd, int timeout, int blocking);
static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer); static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer);
static void sg_remove_scat(Sg_scatter_hold * schp); static void sg_remove_scat(Sg_fd * sfp, Sg_scatter_hold * schp);
static void sg_build_reserve(Sg_fd * sfp, int req_size); static void sg_build_reserve(Sg_fd * sfp, int req_size);
static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size); static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp); static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
static Sg_fd *sg_add_sfp(Sg_device * sdp, int dev); static Sg_fd *sg_add_sfp(Sg_device * sdp);
static void sg_remove_sfp(struct kref *); static void sg_remove_sfp(struct kref *);
static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id); static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
static Sg_request *sg_add_request(Sg_fd * sfp); static Sg_request *sg_add_request(Sg_fd * sfp);
...@@ -218,6 +218,10 @@ static void sg_device_destroy(struct kref *kref); ...@@ -218,6 +218,10 @@ static void sg_device_destroy(struct kref *kref);
#define SZ_SG_IOVEC sizeof(sg_iovec_t) #define SZ_SG_IOVEC sizeof(sg_iovec_t)
#define SZ_SG_REQ_INFO sizeof(sg_req_info_t) #define SZ_SG_REQ_INFO sizeof(sg_req_info_t)
#define sg_printk(prefix, sdp, fmt, a...) \
sdev_printk(prefix, (sdp)->device, "[%s] " fmt, \
(sdp)->disk->disk_name, ##a)
static int sg_allow_access(struct file *filp, unsigned char *cmd) static int sg_allow_access(struct file *filp, unsigned char *cmd)
{ {
struct sg_fd *sfp = filp->private_data; struct sg_fd *sfp = filp->private_data;
...@@ -276,13 +280,15 @@ sg_open(struct inode *inode, struct file *filp) ...@@ -276,13 +280,15 @@ sg_open(struct inode *inode, struct file *filp)
int retval; int retval;
nonseekable_open(inode, filp); nonseekable_open(inode, filp);
SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags));
if ((flags & O_EXCL) && (O_RDONLY == (flags & O_ACCMODE))) if ((flags & O_EXCL) && (O_RDONLY == (flags & O_ACCMODE)))
return -EPERM; /* Can't lock it with read only access */ return -EPERM; /* Can't lock it with read only access */
sdp = sg_get_dev(dev); sdp = sg_get_dev(dev);
if (IS_ERR(sdp)) if (IS_ERR(sdp))
return PTR_ERR(sdp); return PTR_ERR(sdp);
SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
"sg_open: flags=0x%x\n", flags));
/* This driver's module count bumped by fops_get in <linux/fs.h> */ /* This driver's module count bumped by fops_get in <linux/fs.h> */
/* Prevent the device driver from vanishing while we sleep */ /* Prevent the device driver from vanishing while we sleep */
retval = scsi_device_get(sdp->device); retval = scsi_device_get(sdp->device);
...@@ -331,7 +337,7 @@ sg_open(struct inode *inode, struct file *filp) ...@@ -331,7 +337,7 @@ sg_open(struct inode *inode, struct file *filp)
q = sdp->device->request_queue; q = sdp->device->request_queue;
sdp->sg_tablesize = queue_max_segments(q); sdp->sg_tablesize = queue_max_segments(q);
} }
sfp = sg_add_sfp(sdp, dev); sfp = sg_add_sfp(sdp);
if (IS_ERR(sfp)) { if (IS_ERR(sfp)) {
retval = PTR_ERR(sfp); retval = PTR_ERR(sfp);
goto out_undo; goto out_undo;
...@@ -370,7 +376,7 @@ sg_release(struct inode *inode, struct file *filp) ...@@ -370,7 +376,7 @@ sg_release(struct inode *inode, struct file *filp)
if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
return -ENXIO; return -ENXIO;
SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name)); SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp, "sg_release\n"));
mutex_lock(&sdp->open_rel_lock); mutex_lock(&sdp->open_rel_lock);
scsi_autopm_put_device(sdp->device); scsi_autopm_put_device(sdp->device);
...@@ -402,8 +408,8 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) ...@@ -402,8 +408,8 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
return -ENXIO; return -ENXIO;
SCSI_LOG_TIMEOUT(3, printk("sg_read: %s, count=%d\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
sdp->disk->disk_name, (int) count)); "sg_read: count=%d\n", (int) count));
if (!access_ok(VERIFY_WRITE, buf, count)) if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT; return -EFAULT;
...@@ -588,8 +594,8 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) ...@@ -588,8 +594,8 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
return -ENXIO; return -ENXIO;
SCSI_LOG_TIMEOUT(3, printk("sg_write: %s, count=%d\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
sdp->disk->disk_name, (int) count)); "sg_write: count=%d\n", (int) count));
if (atomic_read(&sdp->detaching)) if (atomic_read(&sdp->detaching))
return -ENODEV; return -ENODEV;
if (!((filp->f_flags & O_NONBLOCK) || if (!((filp->f_flags & O_NONBLOCK) ||
...@@ -610,7 +616,8 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) ...@@ -610,7 +616,8 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
return -EIO; /* The minimum scsi command length is 6 bytes. */ return -EIO; /* The minimum scsi command length is 6 bytes. */
if (!(srp = sg_add_request(sfp))) { if (!(srp = sg_add_request(sfp))) {
SCSI_LOG_TIMEOUT(1, printk("sg_write: queue full\n")); SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sdp,
"sg_write: queue full\n"));
return -EDOM; return -EDOM;
} }
buf += SZ_SG_HEADER; buf += SZ_SG_HEADER;
...@@ -623,7 +630,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) ...@@ -623,7 +630,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
if ((opcode >= 0xc0) && old_hdr.twelve_byte) if ((opcode >= 0xc0) && old_hdr.twelve_byte)
cmd_size = 12; cmd_size = 12;
} }
SCSI_LOG_TIMEOUT(4, printk( SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
"sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size)); "sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size));
/* Determine buffer size. */ /* Determine buffer size. */
input_size = count - cmd_size; input_size = count - cmd_size;
...@@ -698,7 +705,8 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, ...@@ -698,7 +705,8 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf,
sfp->cmd_q = 1; /* when sg_io_hdr seen, set command queuing on */ sfp->cmd_q = 1; /* when sg_io_hdr seen, set command queuing on */
if (!(srp = sg_add_request(sfp))) { if (!(srp = sg_add_request(sfp))) {
SCSI_LOG_TIMEOUT(1, printk("sg_new_write: queue full\n")); SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp,
"sg_new_write: queue full\n"));
return -EDOM; return -EDOM;
} }
srp->sg_io_owned = sg_io_owned; srp->sg_io_owned = sg_io_owned;
...@@ -767,12 +775,14 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp, ...@@ -767,12 +775,14 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
hp->host_status = 0; hp->host_status = 0;
hp->driver_status = 0; hp->driver_status = 0;
hp->resid = 0; hp->resid = 0;
SCSI_LOG_TIMEOUT(4, printk("sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n", SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n",
(int) cmnd[0], (int) hp->cmd_len)); (int) cmnd[0], (int) hp->cmd_len));
k = sg_start_req(srp, cmnd); k = sg_start_req(srp, cmnd);
if (k) { if (k) {
SCSI_LOG_TIMEOUT(1, printk("sg_common_write: start_req err=%d\n", k)); SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp,
"sg_common_write: start_req err=%d\n", k));
sg_finish_rem_req(srp); sg_finish_rem_req(srp);
return k; /* probably out of space --> ENOMEM */ return k; /* probably out of space --> ENOMEM */
} }
...@@ -846,8 +856,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) ...@@ -846,8 +856,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
return -ENXIO; return -ENXIO;
SCSI_LOG_TIMEOUT(3, printk("sg_ioctl: %s, cmd=0x%x\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
sdp->disk->disk_name, (int) cmd_in)); "sg_ioctl: cmd=0x%x\n", (int) cmd_in));
read_only = (O_RDWR != (filp->f_flags & O_ACCMODE)); read_only = (O_RDWR != (filp->f_flags & O_ACCMODE));
switch (cmd_in) { switch (cmd_in) {
...@@ -899,7 +909,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) ...@@ -899,7 +909,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
sfp->low_dma = 1; sfp->low_dma = 1;
if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) { if ((0 == sfp->low_dma) && (0 == sg_res_in_use(sfp))) {
val = (int) sfp->reserve.bufflen; val = (int) sfp->reserve.bufflen;
sg_remove_scat(&sfp->reserve); sg_remove_scat(sfp, &sfp->reserve);
sg_build_reserve(sfp, val); sg_build_reserve(sfp, val);
} }
} else { } else {
...@@ -975,7 +985,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) ...@@ -975,7 +985,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
if (val != sfp->reserve.bufflen) { if (val != sfp->reserve.bufflen) {
if (sg_res_in_use(sfp) || sfp->mmap_called) if (sg_res_in_use(sfp) || sfp->mmap_called)
return -EBUSY; return -EBUSY;
sg_remove_scat(&sfp->reserve); sg_remove_scat(sfp, &sfp->reserve);
sg_build_reserve(sfp, val); sg_build_reserve(sfp, val);
} }
return 0; return 0;
...@@ -1198,8 +1208,8 @@ sg_poll(struct file *filp, poll_table * wait) ...@@ -1198,8 +1208,8 @@ sg_poll(struct file *filp, poll_table * wait)
res |= POLLOUT | POLLWRNORM; res |= POLLOUT | POLLWRNORM;
} else if (count < SG_MAX_QUEUE) } else if (count < SG_MAX_QUEUE)
res |= POLLOUT | POLLWRNORM; res |= POLLOUT | POLLWRNORM;
SCSI_LOG_TIMEOUT(3, printk("sg_poll: %s, res=0x%x\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
sdp->disk->disk_name, (int) res)); "sg_poll: res=0x%x\n", (int) res));
return res; return res;
} }
...@@ -1211,8 +1221,8 @@ sg_fasync(int fd, struct file *filp, int mode) ...@@ -1211,8 +1221,8 @@ sg_fasync(int fd, struct file *filp, int mode)
if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
return -ENXIO; return -ENXIO;
SCSI_LOG_TIMEOUT(3, printk("sg_fasync: %s, mode=%d\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
sdp->disk->disk_name, mode)); "sg_fasync: mode=%d\n", mode));
return fasync_helper(fd, filp, mode, &sfp->async_qp); return fasync_helper(fd, filp, mode, &sfp->async_qp);
} }
...@@ -1231,7 +1241,8 @@ sg_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -1231,7 +1241,8 @@ sg_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
offset = vmf->pgoff << PAGE_SHIFT; offset = vmf->pgoff << PAGE_SHIFT;
if (offset >= rsv_schp->bufflen) if (offset >= rsv_schp->bufflen)
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
SCSI_LOG_TIMEOUT(3, printk("sg_vma_fault: offset=%lu, scatg=%d\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sfp->parentdp,
"sg_vma_fault: offset=%lu, scatg=%d\n",
offset, rsv_schp->k_use_sg)); offset, rsv_schp->k_use_sg));
sa = vma->vm_start; sa = vma->vm_start;
length = 1 << (PAGE_SHIFT + rsv_schp->page_order); length = 1 << (PAGE_SHIFT + rsv_schp->page_order);
...@@ -1267,7 +1278,8 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -1267,7 +1278,8 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data)))
return -ENXIO; return -ENXIO;
req_sz = vma->vm_end - vma->vm_start; req_sz = vma->vm_end - vma->vm_start;
SCSI_LOG_TIMEOUT(3, printk("sg_mmap starting, vm_start=%p, len=%d\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sfp->parentdp,
"sg_mmap starting, vm_start=%p, len=%d\n",
(void *) vma->vm_start, (int) req_sz)); (void *) vma->vm_start, (int) req_sz));
if (vma->vm_pgoff) if (vma->vm_pgoff)
return -EINVAL; /* want no offset */ return -EINVAL; /* want no offset */
...@@ -1330,8 +1342,9 @@ sg_rq_end_io(struct request *rq, int uptodate) ...@@ -1330,8 +1342,9 @@ sg_rq_end_io(struct request *rq, int uptodate)
result = rq->errors; result = rq->errors;
resid = rq->resid_len; resid = rq->resid_len;
SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n", SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
sdp->disk->disk_name, srp->header.pack_id, result)); "sg_cmd_done: pack_id=%d, res=0x%x\n",
srp->header.pack_id, result));
srp->header.resid = resid; srp->header.resid = resid;
ms = jiffies_to_msecs(jiffies); ms = jiffies_to_msecs(jiffies);
srp->header.duration = (ms > srp->header.duration) ? srp->header.duration = (ms > srp->header.duration) ?
...@@ -1441,7 +1454,8 @@ sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) ...@@ -1441,7 +1454,8 @@ sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
} }
k = error; k = error;
SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k)); SCSI_LOG_TIMEOUT(3, sdev_printk(KERN_INFO, scsidp,
"sg_alloc: dev=%d \n", k));
sprintf(disk->disk_name, "sg%d", k); sprintf(disk->disk_name, "sg%d", k);
disk->first_minor = k; disk->first_minor = k;
sdp->disk = disk; sdp->disk = disk;
...@@ -1561,8 +1575,7 @@ sg_device_destroy(struct kref *kref) ...@@ -1561,8 +1575,7 @@ sg_device_destroy(struct kref *kref)
write_unlock_irqrestore(&sg_index_lock, flags); write_unlock_irqrestore(&sg_index_lock, flags);
SCSI_LOG_TIMEOUT(3, SCSI_LOG_TIMEOUT(3,
printk("sg_device_destroy: %s\n", sg_printk(KERN_INFO, sdp, "sg_device_destroy\n"));
sdp->disk->disk_name));
put_disk(sdp->disk); put_disk(sdp->disk);
kfree(sdp); kfree(sdp);
...@@ -1584,8 +1597,8 @@ sg_remove_device(struct device *cl_dev, struct class_interface *cl_intf) ...@@ -1584,8 +1597,8 @@ sg_remove_device(struct device *cl_dev, struct class_interface *cl_intf)
if (val > 1) if (val > 1)
return; /* only want to do following once per device */ return; /* only want to do following once per device */
SCSI_LOG_TIMEOUT(3, printk("%s: %s\n", __func__, SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
sdp->disk->disk_name)); "%s\n", __func__));
read_lock_irqsave(&sdp->sfd_lock, iflags); read_lock_irqsave(&sdp->sfd_lock, iflags);
list_for_each_entry(sfp, &sdp->sfds, sfd_siblings) { list_for_each_entry(sfp, &sdp->sfds, sfd_siblings) {
...@@ -1687,7 +1700,8 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) ...@@ -1687,7 +1700,8 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? WRITE : READ; int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? WRITE : READ;
unsigned char *long_cmdp = NULL; unsigned char *long_cmdp = NULL;
SCSI_LOG_TIMEOUT(4, printk(KERN_INFO "sg_start_req: dxfer_len=%d\n", SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_start_req: dxfer_len=%d\n",
dxfer_len)); dxfer_len));
if (hp->cmd_len > BLK_MAX_CDB) { if (hp->cmd_len > BLK_MAX_CDB) {
...@@ -1786,7 +1800,9 @@ sg_finish_rem_req(Sg_request *srp) ...@@ -1786,7 +1800,9 @@ sg_finish_rem_req(Sg_request *srp)
Sg_fd *sfp = srp->parentfp; Sg_fd *sfp = srp->parentfp;
Sg_scatter_hold *req_schp = &srp->data; Sg_scatter_hold *req_schp = &srp->data;
SCSI_LOG_TIMEOUT(4, printk("sg_finish_rem_req: res_used=%d\n", (int) srp->res_used)); SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_finish_rem_req: res_used=%d\n",
(int) srp->res_used));
if (srp->rq) { if (srp->rq) {
if (srp->bio) if (srp->bio)
ret = blk_rq_unmap_user(srp->bio); ret = blk_rq_unmap_user(srp->bio);
...@@ -1799,7 +1815,7 @@ sg_finish_rem_req(Sg_request *srp) ...@@ -1799,7 +1815,7 @@ sg_finish_rem_req(Sg_request *srp)
if (srp->res_used) if (srp->res_used)
sg_unlink_reserve(sfp, srp); sg_unlink_reserve(sfp, srp);
else else
sg_remove_scat(req_schp); sg_remove_scat(sfp, req_schp);
sg_remove_request(sfp, srp); sg_remove_request(sfp, srp);
...@@ -1833,7 +1849,8 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) ...@@ -1833,7 +1849,8 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
++blk_size; /* don't know why */ ++blk_size; /* don't know why */
/* round request up to next highest SG_SECTOR_SZ byte boundary */ /* round request up to next highest SG_SECTOR_SZ byte boundary */
blk_size = ALIGN(blk_size, SG_SECTOR_SZ); blk_size = ALIGN(blk_size, SG_SECTOR_SZ);
SCSI_LOG_TIMEOUT(4, printk("sg_build_indirect: buff_size=%d, blk_size=%d\n", SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_build_indirect: buff_size=%d, blk_size=%d\n",
buff_size, blk_size)); buff_size, blk_size));
/* N.B. ret_sz carried into this block ... */ /* N.B. ret_sz carried into this block ... */
...@@ -1877,14 +1894,16 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) ...@@ -1877,14 +1894,16 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
} }
} }
SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " SCSI_LOG_TIMEOUT(5, sg_printk(KERN_INFO, sfp->parentdp,
"ret_sz=%d\n", k, num, ret_sz)); "sg_build_indirect: k=%d, num=%d, ret_sz=%d\n",
k, num, ret_sz));
} /* end of for loop */ } /* end of for loop */
schp->page_order = order; schp->page_order = order;
schp->k_use_sg = k; schp->k_use_sg = k;
SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, " SCSI_LOG_TIMEOUT(5, sg_printk(KERN_INFO, sfp->parentdp,
"rem_sz=%d\n", k, rem_sz)); "sg_build_indirect: k_use_sg=%d, rem_sz=%d\n",
k, rem_sz));
schp->bufflen = blk_size; schp->bufflen = blk_size;
if (rem_sz > 0) /* must have failed */ if (rem_sz > 0) /* must have failed */
...@@ -1901,15 +1920,17 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) ...@@ -1901,15 +1920,17 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
} }
static void static void
sg_remove_scat(Sg_scatter_hold * schp) sg_remove_scat(Sg_fd * sfp, Sg_scatter_hold * schp)
{ {
SCSI_LOG_TIMEOUT(4, printk("sg_remove_scat: k_use_sg=%d\n", schp->k_use_sg)); SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_remove_scat: k_use_sg=%d\n", schp->k_use_sg));
if (schp->pages && schp->sglist_len > 0) { if (schp->pages && schp->sglist_len > 0) {
if (!schp->dio_in_use) { if (!schp->dio_in_use) {
int k; int k;
for (k = 0; k < schp->k_use_sg && schp->pages[k]; k++) { for (k = 0; k < schp->k_use_sg && schp->pages[k]; k++) {
SCSI_LOG_TIMEOUT(5, printk( SCSI_LOG_TIMEOUT(5,
sg_printk(KERN_INFO, sfp->parentdp,
"sg_remove_scat: k=%d, pg=0x%p\n", "sg_remove_scat: k=%d, pg=0x%p\n",
k, schp->pages[k])); k, schp->pages[k]));
__free_pages(schp->pages[k], schp->page_order); __free_pages(schp->pages[k], schp->page_order);
...@@ -1927,7 +1948,8 @@ sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) ...@@ -1927,7 +1948,8 @@ sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer)
Sg_scatter_hold *schp = &srp->data; Sg_scatter_hold *schp = &srp->data;
int k, num; int k, num;
SCSI_LOG_TIMEOUT(4, printk("sg_read_oxfer: num_read_xfer=%d\n", SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp,
"sg_read_oxfer: num_read_xfer=%d\n",
num_read_xfer)); num_read_xfer));
if ((!outp) || (num_read_xfer <= 0)) if ((!outp) || (num_read_xfer <= 0))
return 0; return 0;
...@@ -1958,14 +1980,15 @@ sg_build_reserve(Sg_fd * sfp, int req_size) ...@@ -1958,14 +1980,15 @@ sg_build_reserve(Sg_fd * sfp, int req_size)
{ {
Sg_scatter_hold *schp = &sfp->reserve; Sg_scatter_hold *schp = &sfp->reserve;
SCSI_LOG_TIMEOUT(4, printk("sg_build_reserve: req_size=%d\n", req_size)); SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_build_reserve: req_size=%d\n", req_size));
do { do {
if (req_size < PAGE_SIZE) if (req_size < PAGE_SIZE)
req_size = PAGE_SIZE; req_size = PAGE_SIZE;
if (0 == sg_build_indirect(schp, sfp, req_size)) if (0 == sg_build_indirect(schp, sfp, req_size))
return; return;
else else
sg_remove_scat(schp); sg_remove_scat(sfp, schp);
req_size >>= 1; /* divide by 2 */ req_size >>= 1; /* divide by 2 */
} while (req_size > (PAGE_SIZE / 2)); } while (req_size > (PAGE_SIZE / 2));
} }
...@@ -1978,7 +2001,8 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) ...@@ -1978,7 +2001,8 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size)
int k, num, rem; int k, num, rem;
srp->res_used = 1; srp->res_used = 1;
SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_link_reserve: size=%d\n", size));
rem = size; rem = size;
num = 1 << (PAGE_SHIFT + rsv_schp->page_order); num = 1 << (PAGE_SHIFT + rsv_schp->page_order);
...@@ -1996,7 +2020,8 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) ...@@ -1996,7 +2020,8 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size)
} }
if (k >= rsv_schp->k_use_sg) if (k >= rsv_schp->k_use_sg)
SCSI_LOG_TIMEOUT(1, printk("sg_link_reserve: BAD size\n")); SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sfp->parentdp,
"sg_link_reserve: BAD size\n"));
} }
static void static void
...@@ -2004,7 +2029,8 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) ...@@ -2004,7 +2029,8 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp)
{ {
Sg_scatter_hold *req_schp = &srp->data; Sg_scatter_hold *req_schp = &srp->data;
SCSI_LOG_TIMEOUT(4, printk("sg_unlink_reserve: req->k_use_sg=%d\n", SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp,
"sg_unlink_reserve: req->k_use_sg=%d\n",
(int) req_schp->k_use_sg)); (int) req_schp->k_use_sg));
req_schp->k_use_sg = 0; req_schp->k_use_sg = 0;
req_schp->bufflen = 0; req_schp->bufflen = 0;
...@@ -2110,7 +2136,7 @@ sg_remove_request(Sg_fd * sfp, Sg_request * srp) ...@@ -2110,7 +2136,7 @@ sg_remove_request(Sg_fd * sfp, Sg_request * srp)
} }
static Sg_fd * static Sg_fd *
sg_add_sfp(Sg_device * sdp, int dev) sg_add_sfp(Sg_device * sdp)
{ {
Sg_fd *sfp; Sg_fd *sfp;
unsigned long iflags; unsigned long iflags;
...@@ -2139,15 +2165,18 @@ sg_add_sfp(Sg_device * sdp, int dev) ...@@ -2139,15 +2165,18 @@ sg_add_sfp(Sg_device * sdp, int dev)
} }
list_add_tail(&sfp->sfd_siblings, &sdp->sfds); list_add_tail(&sfp->sfd_siblings, &sdp->sfds);
write_unlock_irqrestore(&sdp->sfd_lock, iflags); write_unlock_irqrestore(&sdp->sfd_lock, iflags);
SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp)); SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
"sg_add_sfp: sfp=0x%p\n", sfp));
if (unlikely(sg_big_buff != def_reserved_size)) if (unlikely(sg_big_buff != def_reserved_size))
sg_big_buff = def_reserved_size; sg_big_buff = def_reserved_size;
bufflen = min_t(int, sg_big_buff, bufflen = min_t(int, sg_big_buff,
max_sectors_bytes(sdp->device->request_queue)); max_sectors_bytes(sdp->device->request_queue));
sg_build_reserve(sfp, bufflen); sg_build_reserve(sfp, bufflen);
SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n", SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
sfp->reserve.bufflen, sfp->reserve.k_use_sg)); "sg_add_sfp: bufflen=%d, k_use_sg=%d\n",
sfp->reserve.bufflen,
sfp->reserve.k_use_sg));
kref_get(&sdp->d_ref); kref_get(&sdp->d_ref);
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
...@@ -2165,17 +2194,15 @@ sg_remove_sfp_usercontext(struct work_struct *work) ...@@ -2165,17 +2194,15 @@ sg_remove_sfp_usercontext(struct work_struct *work)
sg_finish_rem_req(sfp->headrp); sg_finish_rem_req(sfp->headrp);
if (sfp->reserve.bufflen > 0) { if (sfp->reserve.bufflen > 0) {
SCSI_LOG_TIMEOUT(6, SCSI_LOG_TIMEOUT(6, sg_printk(KERN_INFO, sdp,
printk("sg_remove_sfp: bufflen=%d, k_use_sg=%d\n", "sg_remove_sfp: bufflen=%d, k_use_sg=%d\n",
(int) sfp->reserve.bufflen, (int) sfp->reserve.bufflen,
(int) sfp->reserve.k_use_sg)); (int) sfp->reserve.k_use_sg));
sg_remove_scat(&sfp->reserve); sg_remove_scat(sfp, &sfp->reserve);
} }
SCSI_LOG_TIMEOUT(6, SCSI_LOG_TIMEOUT(6, sg_printk(KERN_INFO, sdp,
printk("sg_remove_sfp: %s, sfp=0x%p\n", "sg_remove_sfp: sfp=0x%p\n", sfp));
sdp->disk->disk_name,
sfp));
kfree(sfp); kfree(sfp);
scsi_device_put(sdp->device); scsi_device_put(sdp->device);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment