Commit ce932967 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block

* 'for-linus' of git://git.kernel.dk/linux-2.6-block:
  block: fix blkdev_issue_flush() not detecting and passing EOPNOTSUPP back
  block: fix shadowed variable warning in blk-map.c
  block: remove extern on function definition
  cciss: remove READ_AHEAD define and use block layer defaults
  make cdrom.c:check_for_audio_disc() static
  block/genhd.c: proper externs
  unexport blk_rq_map_user_iov
  unexport blk_{get,put}_queue
  block/genhd.c: cleanups
  proper prototype for blk_dev_init()
  block/blk-tag.c should #include "blk.h"
  Fix DMA access of block device in 64-bit kernel on some non-x86 systems with 4GB or upper 4GB memory
  block: separate out padding from alignment
  block: restore the meaning of rq->data_len to the true data length
  resubmit: cciss: procfs updates to display info about many
  splice: only return -EAGAIN if there's hope of more data
  block: fix kernel-docbook parameters and files
parents 8727e28d cc66b451
...@@ -361,12 +361,14 @@ X!Edrivers/pnp/system.c ...@@ -361,12 +361,14 @@ X!Edrivers/pnp/system.c
<chapter id="blkdev"> <chapter id="blkdev">
<title>Block Devices</title> <title>Block Devices</title>
!Eblock/blk-core.c !Eblock/blk-core.c
!Iblock/blk-core.c
!Eblock/blk-map.c !Eblock/blk-map.c
!Iblock/blk-sysfs.c !Iblock/blk-sysfs.c
!Eblock/blk-settings.c !Eblock/blk-settings.c
!Eblock/blk-exec.c !Eblock/blk-exec.c
!Eblock/blk-barrier.c !Eblock/blk-barrier.c
!Eblock/blk-tag.c !Eblock/blk-tag.c
!Iblock/blk-tag.c
</chapter> </chapter>
<chapter id="chrdev"> <chapter id="chrdev">
......
...@@ -259,8 +259,11 @@ int blk_do_ordered(struct request_queue *q, struct request **rqp) ...@@ -259,8 +259,11 @@ int blk_do_ordered(struct request_queue *q, struct request **rqp)
static void bio_end_empty_barrier(struct bio *bio, int err) static void bio_end_empty_barrier(struct bio *bio, int err)
{ {
if (err) if (err) {
if (err == -EOPNOTSUPP)
set_bit(BIO_EOPNOTSUPP, &bio->bi_flags);
clear_bit(BIO_UPTODATE, &bio->bi_flags); clear_bit(BIO_UPTODATE, &bio->bi_flags);
}
complete(bio->bi_private); complete(bio->bi_private);
} }
...@@ -309,7 +312,9 @@ int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector) ...@@ -309,7 +312,9 @@ int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector)
*error_sector = bio->bi_sector; *error_sector = bio->bi_sector;
ret = 0; ret = 0;
if (!bio_flagged(bio, BIO_UPTODATE)) if (bio_flagged(bio, BIO_EOPNOTSUPP))
ret = -EOPNOTSUPP;
else if (!bio_flagged(bio, BIO_UPTODATE))
ret = -EIO; ret = -EIO;
bio_put(bio); bio_put(bio);
......
...@@ -127,7 +127,6 @@ void rq_init(struct request_queue *q, struct request *rq) ...@@ -127,7 +127,6 @@ void rq_init(struct request_queue *q, struct request *rq)
rq->nr_hw_segments = 0; rq->nr_hw_segments = 0;
rq->ioprio = 0; rq->ioprio = 0;
rq->special = NULL; rq->special = NULL;
rq->raw_data_len = 0;
rq->buffer = NULL; rq->buffer = NULL;
rq->tag = -1; rq->tag = -1;
rq->errors = 0; rq->errors = 0;
...@@ -135,6 +134,7 @@ void rq_init(struct request_queue *q, struct request *rq) ...@@ -135,6 +134,7 @@ void rq_init(struct request_queue *q, struct request *rq)
rq->cmd_len = 0; rq->cmd_len = 0;
memset(rq->cmd, 0, sizeof(rq->cmd)); memset(rq->cmd, 0, sizeof(rq->cmd));
rq->data_len = 0; rq->data_len = 0;
rq->extra_len = 0;
rq->sense_len = 0; rq->sense_len = 0;
rq->data = NULL; rq->data = NULL;
rq->sense = NULL; rq->sense = NULL;
...@@ -424,7 +424,6 @@ void blk_put_queue(struct request_queue *q) ...@@ -424,7 +424,6 @@ void blk_put_queue(struct request_queue *q)
{ {
kobject_put(&q->kobj); kobject_put(&q->kobj);
} }
EXPORT_SYMBOL(blk_put_queue);
void blk_cleanup_queue(struct request_queue *q) void blk_cleanup_queue(struct request_queue *q)
{ {
...@@ -592,7 +591,6 @@ int blk_get_queue(struct request_queue *q) ...@@ -592,7 +591,6 @@ int blk_get_queue(struct request_queue *q)
return 1; return 1;
} }
EXPORT_SYMBOL(blk_get_queue);
static inline void blk_free_request(struct request_queue *q, struct request *rq) static inline void blk_free_request(struct request_queue *q, struct request *rq)
{ {
...@@ -1768,6 +1766,7 @@ static inline void __end_request(struct request *rq, int uptodate, ...@@ -1768,6 +1766,7 @@ static inline void __end_request(struct request *rq, int uptodate,
/** /**
* blk_rq_bytes - Returns bytes left to complete in the entire request * blk_rq_bytes - Returns bytes left to complete in the entire request
* @rq: the request being processed
**/ **/
unsigned int blk_rq_bytes(struct request *rq) unsigned int blk_rq_bytes(struct request *rq)
{ {
...@@ -1780,6 +1779,7 @@ EXPORT_SYMBOL_GPL(blk_rq_bytes); ...@@ -1780,6 +1779,7 @@ EXPORT_SYMBOL_GPL(blk_rq_bytes);
/** /**
* blk_rq_cur_bytes - Returns bytes left to complete in the current segment * blk_rq_cur_bytes - Returns bytes left to complete in the current segment
* @rq: the request being processed
**/ **/
unsigned int blk_rq_cur_bytes(struct request *rq) unsigned int blk_rq_cur_bytes(struct request *rq)
{ {
...@@ -2016,7 +2016,6 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq, ...@@ -2016,7 +2016,6 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
rq->hard_cur_sectors = rq->current_nr_sectors; rq->hard_cur_sectors = rq->current_nr_sectors;
rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio); rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio);
rq->buffer = bio_data(bio); rq->buffer = bio_data(bio);
rq->raw_data_len = bio->bi_size;
rq->data_len = bio->bi_size; rq->data_len = bio->bi_size;
rq->bio = rq->biotail = bio; rq->bio = rq->biotail = bio;
......
...@@ -19,7 +19,6 @@ int blk_rq_append_bio(struct request_queue *q, struct request *rq, ...@@ -19,7 +19,6 @@ int blk_rq_append_bio(struct request_queue *q, struct request *rq,
rq->biotail->bi_next = bio; rq->biotail->bi_next = bio;
rq->biotail = bio; rq->biotail = bio;
rq->raw_data_len += bio->bi_size;
rq->data_len += bio->bi_size; rq->data_len += bio->bi_size;
} }
return 0; return 0;
...@@ -44,6 +43,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq, ...@@ -44,6 +43,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
void __user *ubuf, unsigned int len) void __user *ubuf, unsigned int len)
{ {
unsigned long uaddr; unsigned long uaddr;
unsigned int alignment;
struct bio *bio, *orig_bio; struct bio *bio, *orig_bio;
int reading, ret; int reading, ret;
...@@ -54,8 +54,8 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq, ...@@ -54,8 +54,8 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
* direct dma. else, set up kernel bounce buffers * direct dma. else, set up kernel bounce buffers
*/ */
uaddr = (unsigned long) ubuf; uaddr = (unsigned long) ubuf;
if (!(uaddr & queue_dma_alignment(q)) && alignment = queue_dma_alignment(q) | q->dma_pad_mask;
!(len & queue_dma_alignment(q))) if (!(uaddr & alignment) && !(len & alignment))
bio = bio_map_user(q, NULL, uaddr, len, reading); bio = bio_map_user(q, NULL, uaddr, len, reading);
else else
bio = bio_copy_user(q, uaddr, len, reading); bio = bio_copy_user(q, uaddr, len, reading);
...@@ -142,20 +142,22 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq, ...@@ -142,20 +142,22 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
/* /*
* __blk_rq_map_user() copies the buffers if starting address * __blk_rq_map_user() copies the buffers if starting address
* or length isn't aligned. As the copied buffer is always * or length isn't aligned to dma_pad_mask. As the copied
* page aligned, we know that there's enough room for padding. * buffer is always page aligned, we know that there's enough
* Extend the last bio and update rq->data_len accordingly. * room for padding. Extend the last bio and update
* rq->data_len accordingly.
* *
* On unmap, bio_uncopy_user() will use unmodified * On unmap, bio_uncopy_user() will use unmodified
* bio_map_data pointed to by bio->bi_private. * bio_map_data pointed to by bio->bi_private.
*/ */
if (len & queue_dma_alignment(q)) { if (len & q->dma_pad_mask) {
unsigned int pad_len = (queue_dma_alignment(q) & ~len) + 1; unsigned int pad_len = (q->dma_pad_mask & ~len) + 1;
struct bio *bio = rq->biotail; struct bio *tail = rq->biotail;
bio->bi_io_vec[bio->bi_vcnt - 1].bv_len += pad_len; tail->bi_io_vec[tail->bi_vcnt - 1].bv_len += pad_len;
bio->bi_size += pad_len; tail->bi_size += pad_len;
rq->data_len += pad_len;
rq->extra_len += pad_len;
} }
rq->buffer = rq->data = NULL; rq->buffer = rq->data = NULL;
...@@ -215,7 +217,6 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, ...@@ -215,7 +217,6 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
rq->buffer = rq->data = NULL; rq->buffer = rq->data = NULL;
return 0; return 0;
} }
EXPORT_SYMBOL(blk_rq_map_user_iov);
/** /**
* blk_rq_unmap_user - unmap a request with user data * blk_rq_unmap_user - unmap a request with user data
......
...@@ -231,7 +231,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq, ...@@ -231,7 +231,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
((unsigned long)q->dma_drain_buffer) & ((unsigned long)q->dma_drain_buffer) &
(PAGE_SIZE - 1)); (PAGE_SIZE - 1));
nsegs++; nsegs++;
rq->data_len += q->dma_drain_size; rq->extra_len += q->dma_drain_size;
} }
if (sg) if (sg)
......
...@@ -140,7 +140,7 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 dma_addr) ...@@ -140,7 +140,7 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 dma_addr)
/* Assume anything <= 4GB can be handled by IOMMU. /* Assume anything <= 4GB can be handled by IOMMU.
Actually some IOMMUs can handle everything, but I don't Actually some IOMMUs can handle everything, but I don't
know of a way to test this here. */ know of a way to test this here. */
if (b_pfn < (min_t(u64, 0xffffffff, BLK_BOUNCE_HIGH) >> PAGE_SHIFT)) if (b_pfn <= (min_t(u64, 0xffffffff, BLK_BOUNCE_HIGH) >> PAGE_SHIFT))
dma = 1; dma = 1;
q->bounce_pfn = max_low_pfn; q->bounce_pfn = max_low_pfn;
#else #else
...@@ -293,8 +293,24 @@ void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b) ...@@ -293,8 +293,24 @@ void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
EXPORT_SYMBOL(blk_queue_stack_limits); EXPORT_SYMBOL(blk_queue_stack_limits);
/** /**
* blk_queue_dma_drain - Set up a drain buffer for excess dma. * blk_queue_dma_pad - set pad mask
* @q: the request queue for the device
* @mask: pad mask
*
* Set pad mask. Direct IO requests are padded to the mask specified.
* *
* Appending pad buffer to a request modifies ->data_len such that it
* includes the pad buffer. The original requested data length can be
* obtained using blk_rq_raw_data_len().
**/
void blk_queue_dma_pad(struct request_queue *q, unsigned int mask)
{
q->dma_pad_mask = mask;
}
EXPORT_SYMBOL(blk_queue_dma_pad);
/**
* blk_queue_dma_drain - Set up a drain buffer for excess dma.
* @q: the request queue for the device * @q: the request queue for the device
* @dma_drain_needed: fn which returns non-zero if drain is necessary * @dma_drain_needed: fn which returns non-zero if drain is necessary
* @buf: physically contiguous buffer * @buf: physically contiguous buffer
...@@ -316,7 +332,7 @@ EXPORT_SYMBOL(blk_queue_stack_limits); ...@@ -316,7 +332,7 @@ EXPORT_SYMBOL(blk_queue_stack_limits);
* device can support otherwise there won't be room for the drain * device can support otherwise there won't be room for the drain
* buffer. * buffer.
*/ */
extern int blk_queue_dma_drain(struct request_queue *q, int blk_queue_dma_drain(struct request_queue *q,
dma_drain_needed_fn *dma_drain_needed, dma_drain_needed_fn *dma_drain_needed,
void *buf, unsigned int size) void *buf, unsigned int size)
{ {
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include "blk.h"
/** /**
* blk_queue_find_tag - find a request by its tag and queue * blk_queue_find_tag - find a request by its tag and queue
* @q: The request queue for the device * @q: The request queue for the device
......
...@@ -32,6 +32,8 @@ void blk_recalc_rq_sectors(struct request *rq, int nsect); ...@@ -32,6 +32,8 @@ void blk_recalc_rq_sectors(struct request *rq, int nsect);
void blk_queue_congestion_threshold(struct request_queue *q); void blk_queue_congestion_threshold(struct request_queue *q);
int blk_dev_init(void);
/* /*
* Return the threshold (number of used requests) at which the queue is * Return the threshold (number of used requests) at which the queue is
* considered to be congested. It include a little hysteresis to keep the * considered to be congested. It include a little hysteresis to keep the
......
...@@ -437,14 +437,14 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, ...@@ -437,14 +437,14 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
} }
if (rq->next_rq) { if (rq->next_rq) {
hdr->dout_resid = rq->raw_data_len; hdr->dout_resid = rq->data_len;
hdr->din_resid = rq->next_rq->raw_data_len; hdr->din_resid = rq->next_rq->data_len;
blk_rq_unmap_user(bidi_bio); blk_rq_unmap_user(bidi_bio);
blk_put_request(rq->next_rq); blk_put_request(rq->next_rq);
} else if (rq_data_dir(rq) == READ) } else if (rq_data_dir(rq) == READ)
hdr->din_resid = rq->raw_data_len; hdr->din_resid = rq->data_len;
else else
hdr->dout_resid = rq->raw_data_len; hdr->dout_resid = rq->data_len;
/* /*
* If the request generated a negative error number, return it * If the request generated a negative error number, return it
......
...@@ -17,11 +17,15 @@ ...@@ -17,11 +17,15 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include "blk.h"
static DEFINE_MUTEX(block_class_lock); static DEFINE_MUTEX(block_class_lock);
#ifndef CONFIG_SYSFS_DEPRECATED #ifndef CONFIG_SYSFS_DEPRECATED
struct kobject *block_depr; struct kobject *block_depr;
#endif #endif
static struct device_type disk_type;
/* /*
* Can be deleted altogether. Later. * Can be deleted altogether. Later.
* *
...@@ -346,8 +350,6 @@ const struct seq_operations partitions_op = { ...@@ -346,8 +350,6 @@ const struct seq_operations partitions_op = {
#endif #endif
extern int blk_dev_init(void);
static struct kobject *base_probe(dev_t devt, int *part, void *data) static struct kobject *base_probe(dev_t devt, int *part, void *data)
{ {
if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0) if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
...@@ -502,7 +504,7 @@ struct class block_class = { ...@@ -502,7 +504,7 @@ struct class block_class = {
.name = "block", .name = "block",
}; };
struct device_type disk_type = { static struct device_type disk_type = {
.name = "disk", .name = "disk",
.groups = disk_attr_groups, .groups = disk_attr_groups,
.release = disk_release, .release = disk_release,
...@@ -632,12 +634,14 @@ static void media_change_notify_thread(struct work_struct *work) ...@@ -632,12 +634,14 @@ static void media_change_notify_thread(struct work_struct *work)
put_device(gd->driverfs_dev); put_device(gd->driverfs_dev);
} }
#if 0
void genhd_media_change_notify(struct gendisk *disk) void genhd_media_change_notify(struct gendisk *disk)
{ {
get_device(disk->driverfs_dev); get_device(disk->driverfs_dev);
schedule_work(&disk->async_notify); schedule_work(&disk->async_notify);
} }
EXPORT_SYMBOL_GPL(genhd_media_change_notify); EXPORT_SYMBOL_GPL(genhd_media_change_notify);
#endif /* 0 */
dev_t blk_lookup_devt(const char *name) dev_t blk_lookup_devt(const char *name)
{ {
......
...@@ -266,7 +266,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, ...@@ -266,7 +266,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
hdr->info = 0; hdr->info = 0;
if (hdr->masked_status || hdr->host_status || hdr->driver_status) if (hdr->masked_status || hdr->host_status || hdr->driver_status)
hdr->info |= SG_INFO_CHECK; hdr->info |= SG_INFO_CHECK;
hdr->resid = rq->raw_data_len; hdr->resid = rq->data_len;
hdr->sb_len_wr = 0; hdr->sb_len_wr = 0;
if (rq->sense_len && hdr->sbp) { if (rq->sense_len && hdr->sbp) {
...@@ -528,8 +528,8 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk, ...@@ -528,8 +528,8 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
rq = blk_get_request(q, WRITE, __GFP_WAIT); rq = blk_get_request(q, WRITE, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->cmd_type = REQ_TYPE_BLOCK_PC;
rq->data = NULL; rq->data = NULL;
rq->raw_data_len = 0;
rq->data_len = 0; rq->data_len = 0;
rq->extra_len = 0;
rq->timeout = BLK_DEFAULT_SG_TIMEOUT; rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
memset(rq->cmd, 0, sizeof(rq->cmd)); memset(rq->cmd, 0, sizeof(rq->cmd));
rq->cmd[0] = cmd; rq->cmd[0] = cmd;
......
...@@ -862,9 +862,10 @@ static int ata_scsi_dev_config(struct scsi_device *sdev, ...@@ -862,9 +862,10 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
struct request_queue *q = sdev->request_queue; struct request_queue *q = sdev->request_queue;
void *buf; void *buf;
/* set the min alignment */ /* set the min alignment and padding */
blk_queue_update_dma_alignment(sdev->request_queue, blk_queue_update_dma_alignment(sdev->request_queue,
ATA_DMA_PAD_SZ - 1); ATA_DMA_PAD_SZ - 1);
blk_queue_dma_pad(sdev->request_queue, ATA_DMA_PAD_SZ - 1);
/* configure draining */ /* configure draining */
buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL); buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL);
...@@ -2538,7 +2539,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) ...@@ -2538,7 +2539,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
} }
qc->tf.command = ATA_CMD_PACKET; qc->tf.command = ATA_CMD_PACKET;
qc->nbytes = scsi_bufflen(scmd); qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len;
/* check whether ATAPI DMA is safe */ /* check whether ATAPI DMA is safe */
if (!using_pio && ata_check_atapi_dma(qc)) if (!using_pio && ata_check_atapi_dma(qc))
...@@ -2549,7 +2550,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) ...@@ -2549,7 +2550,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
* want to set it properly, and for DMA where it is * want to set it properly, and for DMA where it is
* effectively meaningless. * effectively meaningless.
*/ */
nbytes = min(scmd->request->raw_data_len, (unsigned int)63 * 1024); nbytes = min(scmd->request->data_len, (unsigned int)63 * 1024);
/* Most ATAPI devices which honor transfer chunk size don't /* Most ATAPI devices which honor transfer chunk size don't
* behave according to the spec when odd chunk size which * behave according to the spec when odd chunk size which
...@@ -2875,7 +2876,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) ...@@ -2875,7 +2876,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
* TODO: find out if we need to do more here to * TODO: find out if we need to do more here to
* cover scatter/gather case. * cover scatter/gather case.
*/ */
qc->nbytes = scsi_bufflen(scmd); qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len;
/* request result TF and be quiet about device error */ /* request result TF and be quiet about device error */
qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/blkpg.h> #include <linux/blkpg.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -131,7 +132,6 @@ static struct board_type products[] = { ...@@ -131,7 +132,6 @@ static struct board_type products[] = {
/*define how many times we will try a command because of bus resets */ /*define how many times we will try a command because of bus resets */
#define MAX_CMD_RETRIES 3 #define MAX_CMD_RETRIES 3
#define READ_AHEAD 1024
#define MAX_CTLR 32 #define MAX_CTLR 32
/* Originally cciss driver only supports 8 major numbers */ /* Originally cciss driver only supports 8 major numbers */
...@@ -174,8 +174,6 @@ static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, ...@@ -174,8 +174,6 @@ static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size,
static void fail_all_cmds(unsigned long ctlr); static void fail_all_cmds(unsigned long ctlr);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
int length, int *eof, void *data);
static void cciss_procinit(int i); static void cciss_procinit(int i);
#else #else
static void cciss_procinit(int i) static void cciss_procinit(int i)
...@@ -240,65 +238,77 @@ static inline CommandList_struct *removeQ(CommandList_struct **Qptr, ...@@ -240,65 +238,77 @@ static inline CommandList_struct *removeQ(CommandList_struct **Qptr,
*/ */
#define ENG_GIG 1000000000 #define ENG_GIG 1000000000
#define ENG_GIG_FACTOR (ENG_GIG/512) #define ENG_GIG_FACTOR (ENG_GIG/512)
#define ENGAGE_SCSI "engage scsi"
static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
"UNKNOWN" "UNKNOWN"
}; };
static struct proc_dir_entry *proc_cciss; static struct proc_dir_entry *proc_cciss;
static int cciss_proc_get_info(char *buffer, char **start, off_t offset, static void cciss_seq_show_header(struct seq_file *seq)
int length, int *eof, void *data)
{ {
off_t pos = 0; ctlr_info_t *h = seq->private;
off_t len = 0;
int size, i, ctlr;
ctlr_info_t *h = (ctlr_info_t *) data;
drive_info_struct *drv;
unsigned long flags;
sector_t vol_sz, vol_sz_frac;
ctlr = h->ctlr; seq_printf(seq, "%s: HP %s Controller\n"
/* prevent displaying bogus info during configuration
* or deconfiguration of a logical volume
*/
spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
if (h->busy_configuring) {
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
return -EBUSY;
}
h->busy_configuring = 1;
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
size = sprintf(buffer, "%s: HP %s Controller\n"
"Board ID: 0x%08lx\n" "Board ID: 0x%08lx\n"
"Firmware Version: %c%c%c%c\n" "Firmware Version: %c%c%c%c\n"
"IRQ: %d\n" "IRQ: %d\n"
"Logical drives: %d\n" "Logical drives: %d\n"
"Max sectors: %d\n"
"Current Q depth: %d\n" "Current Q depth: %d\n"
"Current # commands on controller: %d\n" "Current # commands on controller: %d\n"
"Max Q depth since init: %d\n" "Max Q depth since init: %d\n"
"Max # commands on controller since init: %d\n" "Max # commands on controller since init: %d\n"
"Max SG entries since init: %d\n\n", "Max SG entries since init: %d\n",
h->devname, h->devname,
h->product_name, h->product_name,
(unsigned long)h->board_id, (unsigned long)h->board_id,
h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], h->firm_ver[0], h->firm_ver[1], h->firm_ver[2],
h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT], h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT],
h->num_luns, h->num_luns,
h->cciss_max_sectors,
h->Qdepth, h->commands_outstanding, h->Qdepth, h->commands_outstanding,
h->maxQsinceinit, h->max_outstanding, h->maxSG); h->maxQsinceinit, h->max_outstanding, h->maxSG);
pos += size; #ifdef CONFIG_CISS_SCSI_TAPE
len += size; cciss_seq_tape_report(seq, h->ctlr);
cciss_proc_tape_report(ctlr, buffer, &pos, &len); #endif /* CONFIG_CISS_SCSI_TAPE */
for (i = 0; i <= h->highest_lun; i++) { }
static void *cciss_seq_start(struct seq_file *seq, loff_t *pos)
{
ctlr_info_t *h = seq->private;
unsigned ctlr = h->ctlr;
unsigned long flags;
/* prevent displaying bogus info during configuration
* or deconfiguration of a logical volume
*/
spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
if (h->busy_configuring) {
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
return ERR_PTR(-EBUSY);
}
h->busy_configuring = 1;
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
if (*pos == 0)
cciss_seq_show_header(seq);
return pos;
}
static int cciss_seq_show(struct seq_file *seq, void *v)
{
sector_t vol_sz, vol_sz_frac;
ctlr_info_t *h = seq->private;
unsigned ctlr = h->ctlr;
loff_t *pos = v;
drive_info_struct *drv = &h->drv[*pos];
if (*pos > h->highest_lun)
return 0;
drv = &h->drv[i];
if (drv->heads == 0) if (drv->heads == 0)
continue; return 0;
vol_sz = drv->nr_blocks; vol_sz = drv->nr_blocks;
vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR); vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR);
...@@ -307,73 +317,123 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset, ...@@ -307,73 +317,123 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
if (drv->raid_level > 5) if (drv->raid_level > 5)
drv->raid_level = RAID_UNKNOWN; drv->raid_level = RAID_UNKNOWN;
size = sprintf(buffer + len, "cciss/c%dd%d:" seq_printf(seq, "cciss/c%dd%d:"
"\t%4u.%02uGB\tRAID %s\n", "\t%4u.%02uGB\tRAID %s\n",
ctlr, i, (int)vol_sz, (int)vol_sz_frac, ctlr, (int) *pos, (int)vol_sz, (int)vol_sz_frac,
raid_label[drv->raid_level]); raid_label[drv->raid_level]);
pos += size; return 0;
len += size; }
}
static void *cciss_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
ctlr_info_t *h = seq->private;
if (*pos > h->highest_lun)
return NULL;
*pos += 1;
return pos;
}
static void cciss_seq_stop(struct seq_file *seq, void *v)
{
ctlr_info_t *h = seq->private;
/* Only reset h->busy_configuring if we succeeded in setting
* it during cciss_seq_start. */
if (v == ERR_PTR(-EBUSY))
return;
*eof = 1;
*start = buffer + offset;
len -= offset;
if (len > length)
len = length;
h->busy_configuring = 0; h->busy_configuring = 0;
return len;
} }
static int static struct seq_operations cciss_seq_ops = {
cciss_proc_write(struct file *file, const char __user *buffer, .start = cciss_seq_start,
unsigned long count, void *data) .show = cciss_seq_show,
.next = cciss_seq_next,
.stop = cciss_seq_stop,
};
static int cciss_seq_open(struct inode *inode, struct file *file)
{ {
unsigned char cmd[80]; int ret = seq_open(file, &cciss_seq_ops);
int len; struct seq_file *seq = file->private_data;
#ifdef CONFIG_CISS_SCSI_TAPE
ctlr_info_t *h = (ctlr_info_t *) data; if (!ret)
int rc; seq->private = PDE(inode)->data;
return ret;
}
static ssize_t
cciss_proc_write(struct file *file, const char __user *buf,
size_t length, loff_t *ppos)
{
int err;
char *buffer;
#ifndef CONFIG_CISS_SCSI_TAPE
return -EINVAL;
#endif #endif
if (count > sizeof(cmd) - 1) if (!buf || length > PAGE_SIZE - 1)
return -EINVAL; return -EINVAL;
if (copy_from_user(cmd, buffer, count))
return -EFAULT; buffer = (char *)__get_free_page(GFP_KERNEL);
cmd[count] = '\0'; if (!buffer)
len = strlen(cmd); // above 3 lines ensure safety return -ENOMEM;
if (len && cmd[len - 1] == '\n')
cmd[--len] = '\0'; err = -EFAULT;
# ifdef CONFIG_CISS_SCSI_TAPE if (copy_from_user(buffer, buf, length))
if (strcmp("engage scsi", cmd) == 0) { goto out;
buffer[length] = '\0';
#ifdef CONFIG_CISS_SCSI_TAPE
if (strncmp(ENGAGE_SCSI, buffer, sizeof ENGAGE_SCSI - 1) == 0) {
struct seq_file *seq = file->private_data;
ctlr_info_t *h = seq->private;
int rc;
rc = cciss_engage_scsi(h->ctlr); rc = cciss_engage_scsi(h->ctlr);
if (rc != 0) if (rc != 0)
return -rc; err = -rc;
return count; else
} err = length;
} else
#endif /* CONFIG_CISS_SCSI_TAPE */
err = -EINVAL;
/* might be nice to have "disengage" too, but it's not /* might be nice to have "disengage" too, but it's not
safely possible. (only 1 module use count, lock issues.) */ safely possible. (only 1 module use count, lock issues.) */
# endif
return -EINVAL; out:
free_page((unsigned long)buffer);
return err;
} }
/* static struct file_operations cciss_proc_fops = {
* Get us a file in /proc/cciss that says something about each controller. .owner = THIS_MODULE,
* Create /proc/cciss if it doesn't exist yet. .open = cciss_seq_open,
*/ .read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
.write = cciss_proc_write,
};
static void __devinit cciss_procinit(int i) static void __devinit cciss_procinit(int i)
{ {
struct proc_dir_entry *pde; struct proc_dir_entry *pde;
if (proc_cciss == NULL) { if (proc_cciss == NULL)
proc_cciss = proc_mkdir("cciss", proc_root_driver); proc_cciss = proc_mkdir("cciss", proc_root_driver);
if (!proc_cciss) if (!proc_cciss)
return; return;
} pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP |
S_IROTH, proc_cciss,
&cciss_proc_fops);
if (!pde)
return;
pde = create_proc_read_entry(hba[i]->devname, pde->data = hba[i];
S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH,
proc_cciss, cciss_proc_get_info, hba[i]);
pde->write_proc = cciss_proc_write;
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
...@@ -1341,7 +1401,6 @@ static void cciss_update_drive_info(int ctlr, int drv_index) ...@@ -1341,7 +1401,6 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
disk->private_data = &h->drv[drv_index]; disk->private_data = &h->drv[drv_index];
/* Set up queue information */ /* Set up queue information */
disk->queue->backing_dev_info.ra_pages = READ_AHEAD;
blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask); blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask);
/* This is a hardware imposed limit. */ /* This is a hardware imposed limit. */
...@@ -3434,7 +3493,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, ...@@ -3434,7 +3493,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
} }
drv->queue = q; drv->queue = q;
q->backing_dev_info.ra_pages = READ_AHEAD;
blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
/* This is a hardware imposed limit. */ /* This is a hardware imposed limit. */
......
...@@ -1404,21 +1404,18 @@ cciss_engage_scsi(int ctlr) ...@@ -1404,21 +1404,18 @@ cciss_engage_scsi(int ctlr)
} }
static void static void
cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len) cciss_seq_tape_report(struct seq_file *seq, int ctlr)
{ {
unsigned long flags; unsigned long flags;
int size;
*pos = *pos -1; *len = *len - 1; // cut off the last trailing newline
CPQ_TAPE_LOCK(ctlr, flags); CPQ_TAPE_LOCK(ctlr, flags);
size = sprintf(buffer + *len, seq_printf(seq,
"Sequential access devices: %d\n\n", "Sequential access devices: %d\n\n",
ccissscsi[ctlr].ndevices); ccissscsi[ctlr].ndevices);
CPQ_TAPE_UNLOCK(ctlr, flags); CPQ_TAPE_UNLOCK(ctlr, flags);
*pos += size; *len += size;
} }
/* Need at least one of these error handlers to keep ../scsi/hosts.c from /* Need at least one of these error handlers to keep ../scsi/hosts.c from
* complaining. Doing a host- or bus-reset can't do anything good here. * complaining. Doing a host- or bus-reset can't do anything good here.
* Despite what it might say in scsi_error.c, there may well be commands * Despite what it might say in scsi_error.c, there may well be commands
...@@ -1498,6 +1495,5 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd) ...@@ -1498,6 +1495,5 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd)
#define cciss_scsi_setup(cntl_num) #define cciss_scsi_setup(cntl_num)
#define cciss_unregister_scsi(ctlr) #define cciss_unregister_scsi(ctlr)
#define cciss_register_scsi(ctlr) #define cciss_register_scsi(ctlr)
#define cciss_proc_tape_report(ctlr, buffer, pos, len)
#endif /* CONFIG_CISS_SCSI_TAPE */ #endif /* CONFIG_CISS_SCSI_TAPE */
...@@ -1152,7 +1152,7 @@ int open_for_data(struct cdrom_device_info * cdi) ...@@ -1152,7 +1152,7 @@ int open_for_data(struct cdrom_device_info * cdi)
/* This code is similar to that in open_for_data. The routine is called /* This code is similar to that in open_for_data. The routine is called
whenever an audio play operation is requested. whenever an audio play operation is requested.
*/ */
int check_for_audio_disc(struct cdrom_device_info * cdi, static int check_for_audio_disc(struct cdrom_device_info * cdi,
struct cdrom_device_ops * cdo) struct cdrom_device_ops * cdo)
{ {
int ret; int ret;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/genhd.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -377,7 +378,6 @@ static int stram_read_proc(char *page, char **start, off_t off, ...@@ -377,7 +378,6 @@ static int stram_read_proc(char *page, char **start, off_t off,
#endif #endif
#ifdef CONFIG_BLOCK #ifdef CONFIG_BLOCK
extern const struct seq_operations partitions_op;
static int partitions_open(struct inode *inode, struct file *file) static int partitions_open(struct inode *inode, struct file *file)
{ {
return seq_open(file, &partitions_op); return seq_open(file, &partitions_op);
...@@ -389,7 +389,6 @@ static const struct file_operations proc_partitions_operations = { ...@@ -389,7 +389,6 @@ static const struct file_operations proc_partitions_operations = {
.release = seq_release, .release = seq_release,
}; };
extern const struct seq_operations diskstats_op;
static int diskstats_open(struct inode *inode, struct file *file) static int diskstats_open(struct inode *inode, struct file *file)
{ {
return seq_open(file, &diskstats_op); return seq_open(file, &diskstats_op);
......
...@@ -1669,6 +1669,13 @@ static int link_pipe(struct pipe_inode_info *ipipe, ...@@ -1669,6 +1669,13 @@ static int link_pipe(struct pipe_inode_info *ipipe,
i++; i++;
} while (len); } while (len);
/*
* return EAGAIN if we have the potential of some data in the
* future, otherwise just return 0
*/
if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
ret = -EAGAIN;
inode_double_unlock(ipipe->inode, opipe->inode); inode_double_unlock(ipipe->inode, opipe->inode);
/* /*
...@@ -1709,11 +1716,8 @@ static long do_tee(struct file *in, struct file *out, size_t len, ...@@ -1709,11 +1716,8 @@ static long do_tee(struct file *in, struct file *out, size_t len,
ret = link_ipipe_prep(ipipe, flags); ret = link_ipipe_prep(ipipe, flags);
if (!ret) { if (!ret) {
ret = link_opipe_prep(opipe, flags); ret = link_opipe_prep(opipe, flags);
if (!ret) { if (!ret)
ret = link_pipe(ipipe, opipe, len, flags); ret = link_pipe(ipipe, opipe, len, flags);
if (!ret && (flags & SPLICE_F_NONBLOCK))
ret = -EAGAIN;
}
} }
} }
......
...@@ -216,8 +216,8 @@ struct request { ...@@ -216,8 +216,8 @@ struct request {
unsigned int cmd_len; unsigned int cmd_len;
unsigned char cmd[BLK_MAX_CDB]; unsigned char cmd[BLK_MAX_CDB];
unsigned int raw_data_len;
unsigned int data_len; unsigned int data_len;
unsigned int extra_len; /* length of alignment and padding */
unsigned int sense_len; unsigned int sense_len;
void *data; void *data;
void *sense; void *sense;
...@@ -362,6 +362,7 @@ struct request_queue ...@@ -362,6 +362,7 @@ struct request_queue
unsigned long seg_boundary_mask; unsigned long seg_boundary_mask;
void *dma_drain_buffer; void *dma_drain_buffer;
unsigned int dma_drain_size; unsigned int dma_drain_size;
unsigned int dma_pad_mask;
unsigned int dma_alignment; unsigned int dma_alignment;
struct blk_queue_tag *queue_tags; struct blk_queue_tag *queue_tags;
...@@ -701,6 +702,7 @@ extern void blk_queue_max_hw_segments(struct request_queue *, unsigned short); ...@@ -701,6 +702,7 @@ extern void blk_queue_max_hw_segments(struct request_queue *, unsigned short);
extern void blk_queue_max_segment_size(struct request_queue *, unsigned int); extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
extern void blk_queue_hardsect_size(struct request_queue *, unsigned short); extern void blk_queue_hardsect_size(struct request_queue *, unsigned short);
extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b); extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
extern void blk_queue_dma_pad(struct request_queue *, unsigned int);
extern int blk_queue_dma_drain(struct request_queue *q, extern int blk_queue_dma_drain(struct request_queue *q,
dma_drain_needed_fn *dma_drain_needed, dma_drain_needed_fn *dma_drain_needed,
void *buf, unsigned int size); void *buf, unsigned int size);
......
...@@ -18,11 +18,13 @@ ...@@ -18,11 +18,13 @@
#define dev_to_disk(device) container_of(device, struct gendisk, dev) #define dev_to_disk(device) container_of(device, struct gendisk, dev)
#define dev_to_part(device) container_of(device, struct hd_struct, dev) #define dev_to_part(device) container_of(device, struct hd_struct, dev)
extern struct device_type disk_type;
extern struct device_type part_type; extern struct device_type part_type;
extern struct kobject *block_depr; extern struct kobject *block_depr;
extern struct class block_class; extern struct class block_class;
extern const struct seq_operations partitions_op;
extern const struct seq_operations diskstats_op;
enum { enum {
/* These three have identical behaviour; use the second one if DOS FDISK gets /* These three have identical behaviour; use the second one if DOS FDISK gets
confused about extended/logical partitions starting past cylinder 1023. */ confused about extended/logical partitions starting past cylinder 1023. */
...@@ -556,7 +558,6 @@ extern struct gendisk *alloc_disk_node(int minors, int node_id); ...@@ -556,7 +558,6 @@ extern struct gendisk *alloc_disk_node(int minors, int node_id);
extern struct gendisk *alloc_disk(int minors); extern struct gendisk *alloc_disk(int minors);
extern struct kobject *get_disk(struct gendisk *disk); extern struct kobject *get_disk(struct gendisk *disk);
extern void put_disk(struct gendisk *disk); extern void put_disk(struct gendisk *disk);
extern void genhd_media_change_notify(struct gendisk *disk);
extern void blk_register_region(dev_t devt, unsigned long range, extern void blk_register_region(dev_t devt, unsigned long range,
struct module *module, struct module *module,
struct kobject *(*probe)(dev_t, int *, void *), struct kobject *(*probe)(dev_t, int *, void *),
......
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