aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-10-12 06:35:23 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-12 06:37:32 -0400
commit365d46dc9be9b3c833990a06f3994b1987eda578 (patch)
tree9397d1304144a288411f2118707f44ff5e862fa6 /drivers/block
parent5dc64a3442b98eaa0e3730c35fcf00cf962a93e7 (diff)
parentfd048088306656824958e7783ffcee27e241b361 (diff)
Merge branch 'linus' into x86/xen
Conflicts: arch/x86/kernel/cpu/common.c arch/x86/kernel/process_64.c arch/x86/xen/enlighten.c
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/aoe/aoe.h9
-rw-r--r--drivers/block/aoe/aoeblk.c14
-rw-r--r--drivers/block/aoe/aoechr.c8
-rw-r--r--drivers/block/aoe/aoecmd.c104
-rw-r--r--drivers/block/aoe/aoedev.c14
-rw-r--r--drivers/block/aoe/aoemain.c1
-rw-r--r--drivers/block/aoe/aoenet.c9
-rw-r--r--drivers/block/cciss.c8
-rw-r--r--drivers/block/cciss_scsi.c151
-rw-r--r--drivers/block/cciss_scsi.h4
-rw-r--r--drivers/block/cpqarray.c2
-rw-r--r--drivers/block/floppy.c31
-rw-r--r--drivers/block/hd.c9
-rw-r--r--drivers/block/nbd.c4
-rw-r--r--drivers/block/pktcdvd.c4
-rw-r--r--drivers/block/ps3disk.c11
-rw-r--r--drivers/block/virtio_blk.c14
-rw-r--r--drivers/block/xen-blkfront.c76
18 files changed, 277 insertions, 196 deletions
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 5b4c6e649c11..93f3690396a5 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -159,11 +159,8 @@ struct aoedev {
159 sector_t ssize; 159 sector_t ssize;
160 struct timer_list timer; 160 struct timer_list timer;
161 spinlock_t lock; 161 spinlock_t lock;
162 struct sk_buff *sendq_hd; /* packets needing to be sent, list head */ 162 struct sk_buff_head sendq;
163 struct sk_buff *sendq_tl; 163 struct sk_buff_head skbpool;
164 struct sk_buff *skbpool_hd;
165 struct sk_buff *skbpool_tl;
166 int nskbpool;
167 mempool_t *bufpool; /* for deadlock-free Buf allocation */ 164 mempool_t *bufpool; /* for deadlock-free Buf allocation */
168 struct list_head bufq; /* queue of bios to work on */ 165 struct list_head bufq; /* queue of bios to work on */
169 struct buf *inprocess; /* the one we're currently working on */ 166 struct buf *inprocess; /* the one we're currently working on */
@@ -199,7 +196,7 @@ int aoedev_flush(const char __user *str, size_t size);
199 196
200int aoenet_init(void); 197int aoenet_init(void);
201void aoenet_exit(void); 198void aoenet_exit(void);
202void aoenet_xmit(struct sk_buff *); 199void aoenet_xmit(struct sk_buff_head *);
203int is_aoe_netif(struct net_device *ifp); 200int is_aoe_netif(struct net_device *ifp);
204int set_aoe_iflist(const char __user *str, size_t size); 201int set_aoe_iflist(const char __user *str, size_t size);
205 202
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 0c39782b2660..b82654e883a7 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -109,12 +109,12 @@ static const struct attribute_group attr_group = {
109static int 109static int
110aoedisk_add_sysfs(struct aoedev *d) 110aoedisk_add_sysfs(struct aoedev *d)
111{ 111{
112 return sysfs_create_group(&d->gd->dev.kobj, &attr_group); 112 return sysfs_create_group(&disk_to_dev(d->gd)->kobj, &attr_group);
113} 113}
114void 114void
115aoedisk_rm_sysfs(struct aoedev *d) 115aoedisk_rm_sysfs(struct aoedev *d)
116{ 116{
117 sysfs_remove_group(&d->gd->dev.kobj, &attr_group); 117 sysfs_remove_group(&disk_to_dev(d->gd)->kobj, &attr_group);
118} 118}
119 119
120static int 120static int
@@ -158,9 +158,9 @@ aoeblk_release(struct inode *inode, struct file *filp)
158static int 158static int
159aoeblk_make_request(struct request_queue *q, struct bio *bio) 159aoeblk_make_request(struct request_queue *q, struct bio *bio)
160{ 160{
161 struct sk_buff_head queue;
161 struct aoedev *d; 162 struct aoedev *d;
162 struct buf *buf; 163 struct buf *buf;
163 struct sk_buff *sl;
164 ulong flags; 164 ulong flags;
165 165
166 blk_queue_bounce(q, &bio); 166 blk_queue_bounce(q, &bio);
@@ -213,11 +213,11 @@ aoeblk_make_request(struct request_queue *q, struct bio *bio)
213 list_add_tail(&buf->bufs, &d->bufq); 213 list_add_tail(&buf->bufs, &d->bufq);
214 214
215 aoecmd_work(d); 215 aoecmd_work(d);
216 sl = d->sendq_hd; 216 __skb_queue_head_init(&queue);
217 d->sendq_hd = d->sendq_tl = NULL; 217 skb_queue_splice_init(&d->sendq, &queue);
218 218
219 spin_unlock_irqrestore(&d->lock, flags); 219 spin_unlock_irqrestore(&d->lock, flags);
220 aoenet_xmit(sl); 220 aoenet_xmit(&queue);
221 221
222 return 0; 222 return 0;
223} 223}
@@ -276,7 +276,7 @@ aoeblk_gdalloc(void *vp)
276 gd->first_minor = d->sysminor * AOE_PARTITIONS; 276 gd->first_minor = d->sysminor * AOE_PARTITIONS;
277 gd->fops = &aoe_bdops; 277 gd->fops = &aoe_bdops;
278 gd->private_data = d; 278 gd->private_data = d;
279 gd->capacity = d->ssize; 279 set_capacity(gd, d->ssize);
280 snprintf(gd->disk_name, sizeof gd->disk_name, "etherd/e%ld.%d", 280 snprintf(gd->disk_name, sizeof gd->disk_name, "etherd/e%ld.%d",
281 d->aoemajor, d->aoeminor); 281 d->aoemajor, d->aoeminor);
282 282
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 181ebb85f0be..1f56d2c5b7fc 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -9,6 +9,7 @@
9#include <linux/completion.h> 9#include <linux/completion.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/smp_lock.h> 11#include <linux/smp_lock.h>
12#include <linux/skbuff.h>
12#include "aoe.h" 13#include "aoe.h"
13 14
14enum { 15enum {
@@ -103,7 +104,12 @@ loop:
103 spin_lock_irqsave(&d->lock, flags); 104 spin_lock_irqsave(&d->lock, flags);
104 goto loop; 105 goto loop;
105 } 106 }
106 aoenet_xmit(skb); 107 if (skb) {
108 struct sk_buff_head queue;
109 __skb_queue_head_init(&queue);
110 __skb_queue_tail(&queue, skb);
111 aoenet_xmit(&queue);
112 }
107 aoecmd_cfg(major, minor); 113 aoecmd_cfg(major, minor);
108 return 0; 114 return 0;
109} 115}
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 2f1746295d06..71ff78c9e4d6 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -114,29 +114,22 @@ ifrotate(struct aoetgt *t)
114static void 114static void
115skb_pool_put(struct aoedev *d, struct sk_buff *skb) 115skb_pool_put(struct aoedev *d, struct sk_buff *skb)
116{ 116{
117 if (!d->skbpool_hd) 117 __skb_queue_tail(&d->skbpool, skb);
118 d->skbpool_hd = skb;
119 else
120 d->skbpool_tl->next = skb;
121 d->skbpool_tl = skb;
122} 118}
123 119
124static struct sk_buff * 120static struct sk_buff *
125skb_pool_get(struct aoedev *d) 121skb_pool_get(struct aoedev *d)
126{ 122{
127 struct sk_buff *skb; 123 struct sk_buff *skb = skb_peek(&d->skbpool);
128 124
129 skb = d->skbpool_hd;
130 if (skb && atomic_read(&skb_shinfo(skb)->dataref) == 1) { 125 if (skb && atomic_read(&skb_shinfo(skb)->dataref) == 1) {
131 d->skbpool_hd = skb->next; 126 __skb_unlink(skb, &d->skbpool);
132 skb->next = NULL;
133 return skb; 127 return skb;
134 } 128 }
135 if (d->nskbpool < NSKBPOOLMAX 129 if (skb_queue_len(&d->skbpool) < NSKBPOOLMAX &&
136 && (skb = new_skb(ETH_ZLEN))) { 130 (skb = new_skb(ETH_ZLEN)))
137 d->nskbpool++;
138 return skb; 131 return skb;
139 } 132
140 return NULL; 133 return NULL;
141} 134}
142 135
@@ -293,29 +286,22 @@ aoecmd_ata_rw(struct aoedev *d)
293 286
294 skb->dev = t->ifp->nd; 287 skb->dev = t->ifp->nd;
295 skb = skb_clone(skb, GFP_ATOMIC); 288 skb = skb_clone(skb, GFP_ATOMIC);
296 if (skb) { 289 if (skb)
297 if (d->sendq_hd) 290 __skb_queue_tail(&d->sendq, skb);
298 d->sendq_tl->next = skb;
299 else
300 d->sendq_hd = skb;
301 d->sendq_tl = skb;
302 }
303 return 1; 291 return 1;
304} 292}
305 293
306/* some callers cannot sleep, and they can call this function, 294/* some callers cannot sleep, and they can call this function,
307 * transmitting the packets later, when interrupts are on 295 * transmitting the packets later, when interrupts are on
308 */ 296 */
309static struct sk_buff * 297static void
310aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail) 298aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *queue)
311{ 299{
312 struct aoe_hdr *h; 300 struct aoe_hdr *h;
313 struct aoe_cfghdr *ch; 301 struct aoe_cfghdr *ch;
314 struct sk_buff *skb, *sl, *sl_tail; 302 struct sk_buff *skb;
315 struct net_device *ifp; 303 struct net_device *ifp;
316 304
317 sl = sl_tail = NULL;
318
319 read_lock(&dev_base_lock); 305 read_lock(&dev_base_lock);
320 for_each_netdev(&init_net, ifp) { 306 for_each_netdev(&init_net, ifp) {
321 dev_hold(ifp); 307 dev_hold(ifp);
@@ -329,8 +315,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
329 } 315 }
330 skb_put(skb, sizeof *h + sizeof *ch); 316 skb_put(skb, sizeof *h + sizeof *ch);
331 skb->dev = ifp; 317 skb->dev = ifp;
332 if (sl_tail == NULL) 318 __skb_queue_tail(queue, skb);
333 sl_tail = skb;
334 h = (struct aoe_hdr *) skb_mac_header(skb); 319 h = (struct aoe_hdr *) skb_mac_header(skb);
335 memset(h, 0, sizeof *h + sizeof *ch); 320 memset(h, 0, sizeof *h + sizeof *ch);
336 321
@@ -342,16 +327,10 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
342 h->minor = aoeminor; 327 h->minor = aoeminor;
343 h->cmd = AOECMD_CFG; 328 h->cmd = AOECMD_CFG;
344 329
345 skb->next = sl;
346 sl = skb;
347cont: 330cont:
348 dev_put(ifp); 331 dev_put(ifp);
349 } 332 }
350 read_unlock(&dev_base_lock); 333 read_unlock(&dev_base_lock);
351
352 if (tail != NULL)
353 *tail = sl_tail;
354 return sl;
355} 334}
356 335
357static void 336static void
@@ -406,11 +385,7 @@ resend(struct aoedev *d, struct aoetgt *t, struct frame *f)
406 skb = skb_clone(skb, GFP_ATOMIC); 385 skb = skb_clone(skb, GFP_ATOMIC);
407 if (skb == NULL) 386 if (skb == NULL)
408 return; 387 return;
409 if (d->sendq_hd) 388 __skb_queue_tail(&d->sendq, skb);
410 d->sendq_tl->next = skb;
411 else
412 d->sendq_hd = skb;
413 d->sendq_tl = skb;
414} 389}
415 390
416static int 391static int
@@ -508,16 +483,15 @@ ata_scnt(unsigned char *packet) {
508static void 483static void
509rexmit_timer(ulong vp) 484rexmit_timer(ulong vp)
510{ 485{
486 struct sk_buff_head queue;
511 struct aoedev *d; 487 struct aoedev *d;
512 struct aoetgt *t, **tt, **te; 488 struct aoetgt *t, **tt, **te;
513 struct aoeif *ifp; 489 struct aoeif *ifp;
514 struct frame *f, *e; 490 struct frame *f, *e;
515 struct sk_buff *sl;
516 register long timeout; 491 register long timeout;
517 ulong flags, n; 492 ulong flags, n;
518 493
519 d = (struct aoedev *) vp; 494 d = (struct aoedev *) vp;
520 sl = NULL;
521 495
522 /* timeout is always ~150% of the moving average */ 496 /* timeout is always ~150% of the moving average */
523 timeout = d->rttavg; 497 timeout = d->rttavg;
@@ -589,7 +563,7 @@ rexmit_timer(ulong vp)
589 } 563 }
590 } 564 }
591 565
592 if (d->sendq_hd) { 566 if (!skb_queue_empty(&d->sendq)) {
593 n = d->rttavg <<= 1; 567 n = d->rttavg <<= 1;
594 if (n > MAXTIMER) 568 if (n > MAXTIMER)
595 d->rttavg = MAXTIMER; 569 d->rttavg = MAXTIMER;
@@ -600,15 +574,15 @@ rexmit_timer(ulong vp)
600 aoecmd_work(d); 574 aoecmd_work(d);
601 } 575 }
602 576
603 sl = d->sendq_hd; 577 __skb_queue_head_init(&queue);
604 d->sendq_hd = d->sendq_tl = NULL; 578 skb_queue_splice_init(&d->sendq, &queue);
605 579
606 d->timer.expires = jiffies + TIMERTICK; 580 d->timer.expires = jiffies + TIMERTICK;
607 add_timer(&d->timer); 581 add_timer(&d->timer);
608 582
609 spin_unlock_irqrestore(&d->lock, flags); 583 spin_unlock_irqrestore(&d->lock, flags);
610 584
611 aoenet_xmit(sl); 585 aoenet_xmit(&queue);
612} 586}
613 587
614/* enters with d->lock held */ 588/* enters with d->lock held */
@@ -645,7 +619,7 @@ aoecmd_sleepwork(struct work_struct *work)
645 unsigned long flags; 619 unsigned long flags;
646 u64 ssize; 620 u64 ssize;
647 621
648 ssize = d->gd->capacity; 622 ssize = get_capacity(d->gd);
649 bd = bdget_disk(d->gd, 0); 623 bd = bdget_disk(d->gd, 0);
650 624
651 if (bd) { 625 if (bd) {
@@ -707,7 +681,7 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
707 if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) 681 if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE))
708 return; 682 return;
709 if (d->gd != NULL) { 683 if (d->gd != NULL) {
710 d->gd->capacity = ssize; 684 set_capacity(d->gd, ssize);
711 d->flags |= DEVFL_NEWSIZE; 685 d->flags |= DEVFL_NEWSIZE;
712 } else 686 } else
713 d->flags |= DEVFL_GDALLOC; 687 d->flags |= DEVFL_GDALLOC;
@@ -756,23 +730,28 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector
756 unsigned long n_sect = bio->bi_size >> 9; 730 unsigned long n_sect = bio->bi_size >> 9;
757 const int rw = bio_data_dir(bio); 731 const int rw = bio_data_dir(bio);
758 struct hd_struct *part; 732 struct hd_struct *part;
733 int cpu;
734
735 cpu = part_stat_lock();
736 part = disk_map_sector_rcu(disk, sector);
737
738 part_stat_inc(cpu, part, ios[rw]);
739 part_stat_add(cpu, part, ticks[rw], duration);
740 part_stat_add(cpu, part, sectors[rw], n_sect);
741 part_stat_add(cpu, part, io_ticks, duration);
759 742
760 part = get_part(disk, sector); 743 part_stat_unlock();
761 all_stat_inc(disk, part, ios[rw], sector);
762 all_stat_add(disk, part, ticks[rw], duration, sector);
763 all_stat_add(disk, part, sectors[rw], n_sect, sector);
764 all_stat_add(disk, part, io_ticks, duration, sector);
765} 744}
766 745
767void 746void
768aoecmd_ata_rsp(struct sk_buff *skb) 747aoecmd_ata_rsp(struct sk_buff *skb)
769{ 748{
749 struct sk_buff_head queue;
770 struct aoedev *d; 750 struct aoedev *d;
771 struct aoe_hdr *hin, *hout; 751 struct aoe_hdr *hin, *hout;
772 struct aoe_atahdr *ahin, *ahout; 752 struct aoe_atahdr *ahin, *ahout;
773 struct frame *f; 753 struct frame *f;
774 struct buf *buf; 754 struct buf *buf;
775 struct sk_buff *sl;
776 struct aoetgt *t; 755 struct aoetgt *t;
777 struct aoeif *ifp; 756 struct aoeif *ifp;
778 register long n; 757 register long n;
@@ -893,21 +872,21 @@ aoecmd_ata_rsp(struct sk_buff *skb)
893 872
894 aoecmd_work(d); 873 aoecmd_work(d);
895xmit: 874xmit:
896 sl = d->sendq_hd; 875 __skb_queue_head_init(&queue);
897 d->sendq_hd = d->sendq_tl = NULL; 876 skb_queue_splice_init(&d->sendq, &queue);
898 877
899 spin_unlock_irqrestore(&d->lock, flags); 878 spin_unlock_irqrestore(&d->lock, flags);
900 aoenet_xmit(sl); 879 aoenet_xmit(&queue);
901} 880}
902 881
903void 882void
904aoecmd_cfg(ushort aoemajor, unsigned char aoeminor) 883aoecmd_cfg(ushort aoemajor, unsigned char aoeminor)
905{ 884{
906 struct sk_buff *sl; 885 struct sk_buff_head queue;
907 886
908 sl = aoecmd_cfg_pkts(aoemajor, aoeminor, NULL); 887 __skb_queue_head_init(&queue);
909 888 aoecmd_cfg_pkts(aoemajor, aoeminor, &queue);
910 aoenet_xmit(sl); 889 aoenet_xmit(&queue);
911} 890}
912 891
913struct sk_buff * 892struct sk_buff *
@@ -1076,7 +1055,12 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
1076 1055
1077 spin_unlock_irqrestore(&d->lock, flags); 1056 spin_unlock_irqrestore(&d->lock, flags);
1078 1057
1079 aoenet_xmit(sl); 1058 if (sl) {
1059 struct sk_buff_head queue;
1060 __skb_queue_head_init(&queue);
1061 __skb_queue_tail(&queue, sl);
1062 aoenet_xmit(&queue);
1063 }
1080} 1064}
1081 1065
1082void 1066void
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index a1d813ab0d6b..cc250577d405 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -91,7 +91,7 @@ aoedev_downdev(struct aoedev *d)
91 } 91 }
92 92
93 if (d->gd) 93 if (d->gd)
94 d->gd->capacity = 0; 94 set_capacity(d->gd, 0);
95 95
96 d->flags &= ~DEVFL_UP; 96 d->flags &= ~DEVFL_UP;
97} 97}
@@ -188,14 +188,12 @@ skbfree(struct sk_buff *skb)
188static void 188static void
189skbpoolfree(struct aoedev *d) 189skbpoolfree(struct aoedev *d)
190{ 190{
191 struct sk_buff *skb; 191 struct sk_buff *skb, *tmp;
192 192
193 while ((skb = d->skbpool_hd)) { 193 skb_queue_walk_safe(&d->skbpool, skb, tmp)
194 d->skbpool_hd = skb->next;
195 skb->next = NULL;
196 skbfree(skb); 194 skbfree(skb);
197 } 195
198 d->skbpool_tl = NULL; 196 __skb_queue_head_init(&d->skbpool);
199} 197}
200 198
201/* find it or malloc it */ 199/* find it or malloc it */
@@ -217,6 +215,8 @@ aoedev_by_sysminor_m(ulong sysminor)
217 goto out; 215 goto out;
218 INIT_WORK(&d->work, aoecmd_sleepwork); 216 INIT_WORK(&d->work, aoecmd_sleepwork);
219 spin_lock_init(&d->lock); 217 spin_lock_init(&d->lock);
218 skb_queue_head_init(&d->sendq);
219 skb_queue_head_init(&d->skbpool);
220 init_timer(&d->timer); 220 init_timer(&d->timer);
221 d->timer.data = (ulong) d; 221 d->timer.data = (ulong) d;
222 d->timer.function = dummy_timer; 222 d->timer.function = dummy_timer;
diff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c
index 7b15a5e9cec0..7f83ad90e76f 100644
--- a/drivers/block/aoe/aoemain.c
+++ b/drivers/block/aoe/aoemain.c
@@ -7,6 +7,7 @@
7#include <linux/hdreg.h> 7#include <linux/hdreg.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/skbuff.h>
10#include "aoe.h" 11#include "aoe.h"
11 12
12MODULE_LICENSE("GPL"); 13MODULE_LICENSE("GPL");
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index 0c81ca731287..9157d64270cb 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -95,13 +95,12 @@ mac_addr(char addr[6])
95} 95}
96 96
97void 97void
98aoenet_xmit(struct sk_buff *sl) 98aoenet_xmit(struct sk_buff_head *queue)
99{ 99{
100 struct sk_buff *skb; 100 struct sk_buff *skb, *tmp;
101 101
102 while ((skb = sl)) { 102 skb_queue_walk_safe(queue, skb, tmp) {
103 sl = sl->next; 103 __skb_unlink(skb, queue);
104 skb->next = skb->prev = NULL;
105 dev_queue_xmit(skb); 104 dev_queue_xmit(skb);
106 } 105 }
107} 106}
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b73116ef9236..1e1f9153000c 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3460,8 +3460,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3460 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); 3460 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
3461 3461
3462 hba[i]->cmd_pool_bits = 3462 hba[i]->cmd_pool_bits =
3463 kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG - 3463 kmalloc(DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
3464 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); 3464 * sizeof(unsigned long), GFP_KERNEL);
3465 hba[i]->cmd_pool = (CommandList_struct *) 3465 hba[i]->cmd_pool = (CommandList_struct *)
3466 pci_alloc_consistent(hba[i]->pdev, 3466 pci_alloc_consistent(hba[i]->pdev,
3467 hba[i]->nr_cmds * sizeof(CommandList_struct), 3467 hba[i]->nr_cmds * sizeof(CommandList_struct),
@@ -3493,8 +3493,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3493 /* command and error info recs zeroed out before 3493 /* command and error info recs zeroed out before
3494 they are used */ 3494 they are used */
3495 memset(hba[i]->cmd_pool_bits, 0, 3495 memset(hba[i]->cmd_pool_bits, 0,
3496 ((hba[i]->nr_cmds + BITS_PER_LONG - 3496 DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG)
3497 1) / BITS_PER_LONG) * sizeof(unsigned long)); 3497 * sizeof(unsigned long));
3498 3498
3499 hba[i]->num_luns = 0; 3499 hba[i]->num_luns = 0;
3500 hba[i]->highest_lun = -1; 3500 hba[i]->highest_lun = -1;
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index e1233aabda77..a3fd87b41444 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -365,7 +365,7 @@ struct scsi2map {
365 365
366static int 366static int
367cciss_scsi_add_entry(int ctlr, int hostno, 367cciss_scsi_add_entry(int ctlr, int hostno,
368 unsigned char *scsi3addr, int devtype, 368 struct cciss_scsi_dev_t *device,
369 struct scsi2map *added, int *nadded) 369 struct scsi2map *added, int *nadded)
370{ 370{
371 /* assumes hba[ctlr]->scsi_ctlr->lock is held */ 371 /* assumes hba[ctlr]->scsi_ctlr->lock is held */
@@ -384,12 +384,12 @@ cciss_scsi_add_entry(int ctlr, int hostno,
384 lun = 0; 384 lun = 0;
385 /* Is this device a non-zero lun of a multi-lun device */ 385 /* Is this device a non-zero lun of a multi-lun device */
386 /* byte 4 of the 8-byte LUN addr will contain the logical unit no. */ 386 /* byte 4 of the 8-byte LUN addr will contain the logical unit no. */
387 if (scsi3addr[4] != 0) { 387 if (device->scsi3addr[4] != 0) {
388 /* Search through our list and find the device which */ 388 /* Search through our list and find the device which */
389 /* has the same 8 byte LUN address, excepting byte 4. */ 389 /* has the same 8 byte LUN address, excepting byte 4. */
390 /* Assign the same bus and target for this new LUN. */ 390 /* Assign the same bus and target for this new LUN. */
391 /* Use the logical unit number from the firmware. */ 391 /* Use the logical unit number from the firmware. */
392 memcpy(addr1, scsi3addr, 8); 392 memcpy(addr1, device->scsi3addr, 8);
393 addr1[4] = 0; 393 addr1[4] = 0;
394 for (i = 0; i < n; i++) { 394 for (i = 0; i < n; i++) {
395 sd = &ccissscsi[ctlr].dev[i]; 395 sd = &ccissscsi[ctlr].dev[i];
@@ -399,7 +399,7 @@ cciss_scsi_add_entry(int ctlr, int hostno,
399 if (memcmp(addr1, addr2, 8) == 0) { 399 if (memcmp(addr1, addr2, 8) == 0) {
400 bus = sd->bus; 400 bus = sd->bus;
401 target = sd->target; 401 target = sd->target;
402 lun = scsi3addr[4]; 402 lun = device->scsi3addr[4];
403 break; 403 break;
404 } 404 }
405 } 405 }
@@ -420,8 +420,12 @@ cciss_scsi_add_entry(int ctlr, int hostno,
420 added[*nadded].lun = sd->lun; 420 added[*nadded].lun = sd->lun;
421 (*nadded)++; 421 (*nadded)++;
422 422
423 memcpy(&sd->scsi3addr[0], scsi3addr, 8); 423 memcpy(sd->scsi3addr, device->scsi3addr, 8);
424 sd->devtype = devtype; 424 memcpy(sd->vendor, device->vendor, sizeof(sd->vendor));
425 memcpy(sd->revision, device->revision, sizeof(sd->revision));
426 memcpy(sd->device_id, device->device_id, sizeof(sd->device_id));
427 sd->devtype = device->devtype;
428
425 ccissscsi[ctlr].ndevices++; 429 ccissscsi[ctlr].ndevices++;
426 430
427 /* initially, (before registering with scsi layer) we don't 431 /* initially, (before registering with scsi layer) we don't
@@ -487,6 +491,22 @@ static void fixup_botched_add(int ctlr, char *scsi3addr)
487 CPQ_TAPE_UNLOCK(ctlr, flags); 491 CPQ_TAPE_UNLOCK(ctlr, flags);
488} 492}
489 493
494static int device_is_the_same(struct cciss_scsi_dev_t *dev1,
495 struct cciss_scsi_dev_t *dev2)
496{
497 return dev1->devtype == dev2->devtype &&
498 memcmp(dev1->scsi3addr, dev2->scsi3addr,
499 sizeof(dev1->scsi3addr)) == 0 &&
500 memcmp(dev1->device_id, dev2->device_id,
501 sizeof(dev1->device_id)) == 0 &&
502 memcmp(dev1->vendor, dev2->vendor,
503 sizeof(dev1->vendor)) == 0 &&
504 memcmp(dev1->model, dev2->model,
505 sizeof(dev1->model)) == 0 &&
506 memcmp(dev1->revision, dev2->revision,
507 sizeof(dev1->revision)) == 0;
508}
509
490static int 510static int
491adjust_cciss_scsi_table(int ctlr, int hostno, 511adjust_cciss_scsi_table(int ctlr, int hostno,
492 struct cciss_scsi_dev_t sd[], int nsds) 512 struct cciss_scsi_dev_t sd[], int nsds)
@@ -532,7 +552,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno,
532 for (j=0;j<nsds;j++) { 552 for (j=0;j<nsds;j++) {
533 if (SCSI3ADDR_EQ(sd[j].scsi3addr, 553 if (SCSI3ADDR_EQ(sd[j].scsi3addr,
534 csd->scsi3addr)) { 554 csd->scsi3addr)) {
535 if (sd[j].devtype == csd->devtype) 555 if (device_is_the_same(&sd[j], csd))
536 found=2; 556 found=2;
537 else 557 else
538 found=1; 558 found=1;
@@ -548,22 +568,26 @@ adjust_cciss_scsi_table(int ctlr, int hostno,
548 cciss_scsi_remove_entry(ctlr, hostno, i, 568 cciss_scsi_remove_entry(ctlr, hostno, i,
549 removed, &nremoved); 569 removed, &nremoved);
550 /* remove ^^^, hence i not incremented */ 570 /* remove ^^^, hence i not incremented */
551 } 571 } else if (found == 1) { /* device is different in some way */
552 else if (found == 1) { /* device is different kind */
553 changes++; 572 changes++;
554 printk("cciss%d: device c%db%dt%dl%d type changed " 573 printk("cciss%d: device c%db%dt%dl%d has changed.\n",
555 "(device type now %s).\n", 574 ctlr, hostno, csd->bus, csd->target, csd->lun);
556 ctlr, hostno, csd->bus, csd->target, csd->lun,
557 scsi_device_type(csd->devtype));
558 cciss_scsi_remove_entry(ctlr, hostno, i, 575 cciss_scsi_remove_entry(ctlr, hostno, i,
559 removed, &nremoved); 576 removed, &nremoved);
560 /* remove ^^^, hence i not incremented */ 577 /* remove ^^^, hence i not incremented */
561 if (cciss_scsi_add_entry(ctlr, hostno, 578 if (cciss_scsi_add_entry(ctlr, hostno, &sd[j],
562 &sd[j].scsi3addr[0], sd[j].devtype,
563 added, &nadded) != 0) 579 added, &nadded) != 0)
564 /* we just removed one, so add can't fail. */ 580 /* we just removed one, so add can't fail. */
565 BUG(); 581 BUG();
566 csd->devtype = sd[j].devtype; 582 csd->devtype = sd[j].devtype;
583 memcpy(csd->device_id, sd[j].device_id,
584 sizeof(csd->device_id));
585 memcpy(csd->vendor, sd[j].vendor,
586 sizeof(csd->vendor));
587 memcpy(csd->model, sd[j].model,
588 sizeof(csd->model));
589 memcpy(csd->revision, sd[j].revision,
590 sizeof(csd->revision));
567 } else /* device is same as it ever was, */ 591 } else /* device is same as it ever was, */
568 i++; /* so just move along. */ 592 i++; /* so just move along. */
569 } 593 }
@@ -577,7 +601,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno,
577 csd = &ccissscsi[ctlr].dev[j]; 601 csd = &ccissscsi[ctlr].dev[j];
578 if (SCSI3ADDR_EQ(sd[i].scsi3addr, 602 if (SCSI3ADDR_EQ(sd[i].scsi3addr,
579 csd->scsi3addr)) { 603 csd->scsi3addr)) {
580 if (sd[i].devtype == csd->devtype) 604 if (device_is_the_same(&sd[i], csd))
581 found=2; /* found device */ 605 found=2; /* found device */
582 else 606 else
583 found=1; /* found a bug. */ 607 found=1; /* found a bug. */
@@ -586,16 +610,14 @@ adjust_cciss_scsi_table(int ctlr, int hostno,
586 } 610 }
587 if (!found) { 611 if (!found) {
588 changes++; 612 changes++;
589 if (cciss_scsi_add_entry(ctlr, hostno, 613 if (cciss_scsi_add_entry(ctlr, hostno, &sd[i],
590
591 &sd[i].scsi3addr[0], sd[i].devtype,
592 added, &nadded) != 0) 614 added, &nadded) != 0)
593 break; 615 break;
594 } else if (found == 1) { 616 } else if (found == 1) {
595 /* should never happen... */ 617 /* should never happen... */
596 changes++; 618 changes++;
597 printk("cciss%d: device unexpectedly changed type\n", 619 printk(KERN_WARNING "cciss%d: device "
598 ctlr); 620 "unexpectedly changed\n", ctlr);
599 /* but if it does happen, we just ignore that device */ 621 /* but if it does happen, we just ignore that device */
600 } 622 }
601 } 623 }
@@ -1012,7 +1034,8 @@ cciss_scsi_interpret_error(CommandList_struct *cp)
1012 1034
1013static int 1035static int
1014cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, 1036cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr,
1015 unsigned char *buf, unsigned char bufsize) 1037 unsigned char page, unsigned char *buf,
1038 unsigned char bufsize)
1016{ 1039{
1017 int rc; 1040 int rc;
1018 CommandList_struct *cp; 1041 CommandList_struct *cp;
@@ -1032,8 +1055,8 @@ cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr,
1032 ei = cp->err_info; 1055 ei = cp->err_info;
1033 1056
1034 cdb[0] = CISS_INQUIRY; 1057 cdb[0] = CISS_INQUIRY;
1035 cdb[1] = 0; 1058 cdb[1] = (page != 0);
1036 cdb[2] = 0; 1059 cdb[2] = page;
1037 cdb[3] = 0; 1060 cdb[3] = 0;
1038 cdb[4] = bufsize; 1061 cdb[4] = bufsize;
1039 cdb[5] = 0; 1062 cdb[5] = 0;
@@ -1053,6 +1076,25 @@ cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr,
1053 return rc; 1076 return rc;
1054} 1077}
1055 1078
1079/* Get the device id from inquiry page 0x83 */
1080static int cciss_scsi_get_device_id(ctlr_info_t *c, unsigned char *scsi3addr,
1081 unsigned char *device_id, int buflen)
1082{
1083 int rc;
1084 unsigned char *buf;
1085
1086 if (buflen > 16)
1087 buflen = 16;
1088 buf = kzalloc(64, GFP_KERNEL);
1089 if (!buf)
1090 return -1;
1091 rc = cciss_scsi_do_inquiry(c, scsi3addr, 0x83, buf, 64);
1092 if (rc == 0)
1093 memcpy(device_id, &buf[8], buflen);
1094 kfree(buf);
1095 return rc != 0;
1096}
1097
1056static int 1098static int
1057cciss_scsi_do_report_phys_luns(ctlr_info_t *c, 1099cciss_scsi_do_report_phys_luns(ctlr_info_t *c,
1058 ReportLunData_struct *buf, int bufsize) 1100 ReportLunData_struct *buf, int bufsize)
@@ -1142,25 +1184,21 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1142 ctlr_info_t *c; 1184 ctlr_info_t *c;
1143 __u32 num_luns=0; 1185 __u32 num_luns=0;
1144 unsigned char *ch; 1186 unsigned char *ch;
1145 /* unsigned char found[CCISS_MAX_SCSI_DEVS_PER_HBA]; */ 1187 struct cciss_scsi_dev_t *currentsd, *this_device;
1146 struct cciss_scsi_dev_t currentsd[CCISS_MAX_SCSI_DEVS_PER_HBA];
1147 int ncurrent=0; 1188 int ncurrent=0;
1148 int reportlunsize = sizeof(*ld_buff) + CISS_MAX_PHYS_LUN * 8; 1189 int reportlunsize = sizeof(*ld_buff) + CISS_MAX_PHYS_LUN * 8;
1149 int i; 1190 int i;
1150 1191
1151 c = (ctlr_info_t *) hba[cntl_num]; 1192 c = (ctlr_info_t *) hba[cntl_num];
1152 ld_buff = kzalloc(reportlunsize, GFP_KERNEL); 1193 ld_buff = kzalloc(reportlunsize, GFP_KERNEL);
1153 if (ld_buff == NULL) {
1154 printk(KERN_ERR "cciss: out of memory\n");
1155 return;
1156 }
1157 inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); 1194 inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
1158 if (inq_buff == NULL) { 1195 currentsd = kzalloc(sizeof(*currentsd) *
1159 printk(KERN_ERR "cciss: out of memory\n"); 1196 (CCISS_MAX_SCSI_DEVS_PER_HBA+1), GFP_KERNEL);
1160 kfree(ld_buff); 1197 if (ld_buff == NULL || inq_buff == NULL || currentsd == NULL) {
1161 return; 1198 printk(KERN_ERR "cciss: out of memory\n");
1199 goto out;
1162 } 1200 }
1163 1201 this_device = &currentsd[CCISS_MAX_SCSI_DEVS_PER_HBA];
1164 if (cciss_scsi_do_report_phys_luns(c, ld_buff, reportlunsize) == 0) { 1202 if (cciss_scsi_do_report_phys_luns(c, ld_buff, reportlunsize) == 0) {
1165 ch = &ld_buff->LUNListLength[0]; 1203 ch = &ld_buff->LUNListLength[0];
1166 num_luns = ((ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | ch[3]) / 8; 1204 num_luns = ((ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | ch[3]) / 8;
@@ -1179,23 +1217,34 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1179 1217
1180 1218
1181 /* adjust our table of devices */ 1219 /* adjust our table of devices */
1182 for(i=0; i<num_luns; i++) 1220 for (i = 0; i < num_luns; i++) {
1183 {
1184 int devtype;
1185
1186 /* for each physical lun, do an inquiry */ 1221 /* for each physical lun, do an inquiry */
1187 if (ld_buff->LUN[i][3] & 0xC0) continue; 1222 if (ld_buff->LUN[i][3] & 0xC0) continue;
1188 memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE); 1223 memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE);
1189 memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8); 1224 memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8);
1190 1225
1191 if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, inq_buff, 1226 if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, 0, inq_buff,
1192 (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) { 1227 (unsigned char) OBDR_TAPE_INQ_SIZE) != 0)
1193 /* Inquiry failed (msg printed already) */ 1228 /* Inquiry failed (msg printed already) */
1194 devtype = 0; /* so we will skip this device. */ 1229 continue; /* so we will skip this device. */
1195 } else /* what kind of device is this? */ 1230
1196 devtype = (inq_buff[0] & 0x1f); 1231 this_device->devtype = (inq_buff[0] & 0x1f);
1197 1232 this_device->bus = -1;
1198 switch (devtype) 1233 this_device->target = -1;
1234 this_device->lun = -1;
1235 memcpy(this_device->scsi3addr, scsi3addr, 8);
1236 memcpy(this_device->vendor, &inq_buff[8],
1237 sizeof(this_device->vendor));
1238 memcpy(this_device->model, &inq_buff[16],
1239 sizeof(this_device->model));
1240 memcpy(this_device->revision, &inq_buff[32],
1241 sizeof(this_device->revision));
1242 memset(this_device->device_id, 0,
1243 sizeof(this_device->device_id));
1244 cciss_scsi_get_device_id(hba[cntl_num], scsi3addr,
1245 this_device->device_id, sizeof(this_device->device_id));
1246
1247 switch (this_device->devtype)
1199 { 1248 {
1200 case 0x05: /* CD-ROM */ { 1249 case 0x05: /* CD-ROM */ {
1201 1250
@@ -1220,15 +1269,10 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1220 if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) { 1269 if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) {
1221 printk(KERN_INFO "cciss%d: %s ignored, " 1270 printk(KERN_INFO "cciss%d: %s ignored, "
1222 "too many devices.\n", cntl_num, 1271 "too many devices.\n", cntl_num,
1223 scsi_device_type(devtype)); 1272 scsi_device_type(this_device->devtype));
1224 break; 1273 break;
1225 } 1274 }
1226 memcpy(&currentsd[ncurrent].scsi3addr[0], 1275 currentsd[ncurrent] = *this_device;
1227 &scsi3addr[0], 8);
1228 currentsd[ncurrent].devtype = devtype;
1229 currentsd[ncurrent].bus = -1;
1230 currentsd[ncurrent].target = -1;
1231 currentsd[ncurrent].lun = -1;
1232 ncurrent++; 1276 ncurrent++;
1233 break; 1277 break;
1234 default: 1278 default:
@@ -1240,6 +1284,7 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1240out: 1284out:
1241 kfree(inq_buff); 1285 kfree(inq_buff);
1242 kfree(ld_buff); 1286 kfree(ld_buff);
1287 kfree(currentsd);
1243 return; 1288 return;
1244} 1289}
1245 1290
diff --git a/drivers/block/cciss_scsi.h b/drivers/block/cciss_scsi.h
index d9c2c586502f..7b750245ae76 100644
--- a/drivers/block/cciss_scsi.h
+++ b/drivers/block/cciss_scsi.h
@@ -66,6 +66,10 @@ struct cciss_scsi_dev_t {
66 int devtype; 66 int devtype;
67 int bus, target, lun; /* as presented to the OS */ 67 int bus, target, lun; /* as presented to the OS */
68 unsigned char scsi3addr[8]; /* as presented to the HW */ 68 unsigned char scsi3addr[8]; /* as presented to the HW */
69 unsigned char device_id[16]; /* from inquiry pg. 0x83 */
70 unsigned char vendor[8]; /* bytes 8-15 of inquiry data */
71 unsigned char model[16]; /* bytes 16-31 of inquiry data */
72 unsigned char revision[4]; /* bytes 32-35 of inquiry data */
69}; 73};
70 74
71struct cciss_scsi_hba_t { 75struct cciss_scsi_hba_t {
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 09c14341e6e3..3d967525e9a9 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev)
424 hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t), 424 hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
425 &(hba[i]->cmd_pool_dhandle)); 425 &(hba[i]->cmd_pool_dhandle));
426 hba[i]->cmd_pool_bits = kcalloc( 426 hba[i]->cmd_pool_bits = kcalloc(
427 (NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG, sizeof(unsigned long), 427 DIV_ROUND_UP(NR_CMDS, BITS_PER_LONG), sizeof(unsigned long),
428 GFP_KERNEL); 428 GFP_KERNEL);
429 429
430 if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool) 430 if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 395f8ea7981c..cf64ddf5d839 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -423,8 +423,15 @@ static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
423 * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical 423 * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical
424 * side 0 is on physical side 0 (but with the misnamed sector IDs). 424 * side 0 is on physical side 0 (but with the misnamed sector IDs).
425 * 'stretch' should probably be renamed to something more general, like 425 * 'stretch' should probably be renamed to something more general, like
426 * 'options'. Other parameters should be self-explanatory (see also 426 * 'options'.
427 * setfdprm(8)). 427 *
428 * Bits 2 through 9 of 'stretch' tell the number of the first sector.
429 * The LSB (bit 2) is flipped. For most disks, the first sector
430 * is 1 (represented by 0x00<<2). For some CP/M and music sampler
431 * disks (such as Ensoniq EPS 16plus) it is 0 (represented as 0x01<<2).
432 * For Amstrad CPC disks it is 0xC1 (represented as 0xC0<<2).
433 *
434 * Other parameters should be self-explanatory (see also setfdprm(8)).
428 */ 435 */
429/* 436/*
430 Size 437 Size
@@ -1355,20 +1362,20 @@ static void fdc_specify(void)
1355 } 1362 }
1356 1363
1357 /* Convert step rate from microseconds to milliseconds and 4 bits */ 1364 /* Convert step rate from microseconds to milliseconds and 4 bits */
1358 srt = 16 - (DP->srt * scale_dtr / 1000 + NOMINAL_DTR - 1) / NOMINAL_DTR; 1365 srt = 16 - DIV_ROUND_UP(DP->srt * scale_dtr / 1000, NOMINAL_DTR);
1359 if (slow_floppy) { 1366 if (slow_floppy) {
1360 srt = srt / 4; 1367 srt = srt / 4;
1361 } 1368 }
1362 SUPBOUND(srt, 0xf); 1369 SUPBOUND(srt, 0xf);
1363 INFBOUND(srt, 0); 1370 INFBOUND(srt, 0);
1364 1371
1365 hlt = (DP->hlt * scale_dtr / 2 + NOMINAL_DTR - 1) / NOMINAL_DTR; 1372 hlt = DIV_ROUND_UP(DP->hlt * scale_dtr / 2, NOMINAL_DTR);
1366 if (hlt < 0x01) 1373 if (hlt < 0x01)
1367 hlt = 0x01; 1374 hlt = 0x01;
1368 else if (hlt > 0x7f) 1375 else if (hlt > 0x7f)
1369 hlt = hlt_max_code; 1376 hlt = hlt_max_code;
1370 1377
1371 hut = (DP->hut * scale_dtr / 16 + NOMINAL_DTR - 1) / NOMINAL_DTR; 1378 hut = DIV_ROUND_UP(DP->hut * scale_dtr / 16, NOMINAL_DTR);
1372 if (hut < 0x1) 1379 if (hut < 0x1)
1373 hut = 0x1; 1380 hut = 0x1;
1374 else if (hut > 0xf) 1381 else if (hut > 0xf)
@@ -2236,9 +2243,9 @@ static void setup_format_params(int track)
2236 } 2243 }
2237 } 2244 }
2238 } 2245 }
2239 if (_floppy->stretch & FD_ZEROBASED) { 2246 if (_floppy->stretch & FD_SECTBASEMASK) {
2240 for (count = 0; count < F_SECT_PER_TRACK; count++) 2247 for (count = 0; count < F_SECT_PER_TRACK; count++)
2241 here[count].sect--; 2248 here[count].sect += FD_SECTBASE(_floppy) - 1;
2242 } 2249 }
2243} 2250}
2244 2251
@@ -2385,7 +2392,7 @@ static void rw_interrupt(void)
2385 2392
2386#ifdef FLOPPY_SANITY_CHECK 2393#ifdef FLOPPY_SANITY_CHECK
2387 if (nr_sectors / ssize > 2394 if (nr_sectors / ssize >
2388 (in_sector_offset + current_count_sectors + ssize - 1) / ssize) { 2395 DIV_ROUND_UP(in_sector_offset + current_count_sectors, ssize)) {
2389 DPRINT("long rw: %x instead of %lx\n", 2396 DPRINT("long rw: %x instead of %lx\n",
2390 nr_sectors, current_count_sectors); 2397 nr_sectors, current_count_sectors);
2391 printk("rs=%d s=%d\n", R_SECTOR, SECTOR); 2398 printk("rs=%d s=%d\n", R_SECTOR, SECTOR);
@@ -2649,7 +2656,7 @@ static int make_raw_rw_request(void)
2649 } 2656 }
2650 HEAD = fsector_t / _floppy->sect; 2657 HEAD = fsector_t / _floppy->sect;
2651 2658
2652 if (((_floppy->stretch & (FD_SWAPSIDES | FD_ZEROBASED)) || 2659 if (((_floppy->stretch & (FD_SWAPSIDES | FD_SECTBASEMASK)) ||
2653 TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect) 2660 TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect)
2654 max_sector = _floppy->sect; 2661 max_sector = _floppy->sect;
2655 2662
@@ -2679,7 +2686,7 @@ static int make_raw_rw_request(void)
2679 CODE2SIZE; 2686 CODE2SIZE;
2680 SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; 2687 SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE;
2681 SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + 2688 SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) +
2682 ((_floppy->stretch & FD_ZEROBASED) ? 0 : 1); 2689 FD_SECTBASE(_floppy);
2683 2690
2684 /* tracksize describes the size which can be filled up with sectors 2691 /* tracksize describes the size which can be filled up with sectors
2685 * of size ssize. 2692 * of size ssize.
@@ -3311,7 +3318,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
3311 g->head <= 0 || 3318 g->head <= 0 ||
3312 g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) || 3319 g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) ||
3313 /* check if reserved bits are set */ 3320 /* check if reserved bits are set */
3314 (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_ZEROBASED)) != 0) 3321 (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_SECTBASEMASK)) != 0)
3315 return -EINVAL; 3322 return -EINVAL;
3316 if (type) { 3323 if (type) {
3317 if (!capable(CAP_SYS_ADMIN)) 3324 if (!capable(CAP_SYS_ADMIN))
@@ -3356,7 +3363,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
3356 if (DRS->maxblock > user_params[drive].sect || 3363 if (DRS->maxblock > user_params[drive].sect ||
3357 DRS->maxtrack || 3364 DRS->maxtrack ||
3358 ((user_params[drive].sect ^ oldStretch) & 3365 ((user_params[drive].sect ^ oldStretch) &
3359 (FD_SWAPSIDES | FD_ZEROBASED))) 3366 (FD_SWAPSIDES | FD_SECTBASEMASK)))
3360 invalidate_drive(bdev); 3367 invalidate_drive(bdev);
3361 else 3368 else
3362 process_fd_request(); 3369 process_fd_request();
diff --git a/drivers/block/hd.c b/drivers/block/hd.c
index 682243bf2e46..482c0c4b964f 100644
--- a/drivers/block/hd.c
+++ b/drivers/block/hd.c
@@ -39,6 +39,7 @@
39#include <linux/ioport.h> 39#include <linux/ioport.h>
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/blkpg.h> 41#include <linux/blkpg.h>
42#include <linux/ata.h>
42#include <linux/hdreg.h> 43#include <linux/hdreg.h>
43 44
44#define REALLY_SLOW_IO 45#define REALLY_SLOW_IO
@@ -370,7 +371,7 @@ repeat:
370 struct hd_i_struct *disk = &hd_info[i]; 371 struct hd_i_struct *disk = &hd_info[i];
371 disk->special_op = disk->recalibrate = 1; 372 disk->special_op = disk->recalibrate = 1;
372 hd_out(disk, disk->sect, disk->sect, disk->head-1, 373 hd_out(disk, disk->sect, disk->sect, disk->head-1,
373 disk->cyl, WIN_SPECIFY, &reset_hd); 374 disk->cyl, ATA_CMD_INIT_DEV_PARAMS, &reset_hd);
374 if (reset) 375 if (reset)
375 goto repeat; 376 goto repeat;
376 } else 377 } else
@@ -558,7 +559,7 @@ static int do_special_op(struct hd_i_struct *disk, struct request *req)
558{ 559{
559 if (disk->recalibrate) { 560 if (disk->recalibrate) {
560 disk->recalibrate = 0; 561 disk->recalibrate = 0;
561 hd_out(disk, disk->sect, 0, 0, 0, WIN_RESTORE, &recal_intr); 562 hd_out(disk, disk->sect, 0, 0, 0, ATA_CMD_RESTORE, &recal_intr);
562 return reset; 563 return reset;
563 } 564 }
564 if (disk->head > 16) { 565 if (disk->head > 16) {
@@ -631,13 +632,13 @@ repeat:
631 if (blk_fs_request(req)) { 632 if (blk_fs_request(req)) {
632 switch (rq_data_dir(req)) { 633 switch (rq_data_dir(req)) {
633 case READ: 634 case READ:
634 hd_out(disk, nsect, sec, head, cyl, WIN_READ, 635 hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_READ,
635 &read_intr); 636 &read_intr);
636 if (reset) 637 if (reset)
637 goto repeat; 638 goto repeat;
638 break; 639 break;
639 case WRITE: 640 case WRITE:
640 hd_out(disk, nsect, sec, head, cyl, WIN_WRITE, 641 hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_WRITE,
641 &write_intr); 642 &write_intr);
642 if (reset) 643 if (reset)
643 goto repeat; 644 goto repeat;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 1778e4a2c672..7b3351260d56 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -403,7 +403,7 @@ static int nbd_do_it(struct nbd_device *lo)
403 BUG_ON(lo->magic != LO_MAGIC); 403 BUG_ON(lo->magic != LO_MAGIC);
404 404
405 lo->pid = current->pid; 405 lo->pid = current->pid;
406 ret = sysfs_create_file(&lo->disk->dev.kobj, &pid_attr.attr); 406 ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
407 if (ret) { 407 if (ret) {
408 printk(KERN_ERR "nbd: sysfs_create_file failed!"); 408 printk(KERN_ERR "nbd: sysfs_create_file failed!");
409 return ret; 409 return ret;
@@ -412,7 +412,7 @@ static int nbd_do_it(struct nbd_device *lo)
412 while ((req = nbd_read_stat(lo)) != NULL) 412 while ((req = nbd_read_stat(lo)) != NULL)
413 nbd_end_request(req); 413 nbd_end_request(req);
414 414
415 sysfs_remove_file(&lo->disk->dev.kobj, &pid_attr.attr); 415 sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
416 return 0; 416 return 0;
417} 417}
418 418
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 29b7a648cc6e..0e077150568b 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2544,7 +2544,7 @@ static int pkt_make_request(struct request_queue *q, struct bio *bio)
2544 if (last_zone != zone) { 2544 if (last_zone != zone) {
2545 BUG_ON(last_zone != zone + pd->settings.size); 2545 BUG_ON(last_zone != zone + pd->settings.size);
2546 first_sectors = last_zone - bio->bi_sector; 2546 first_sectors = last_zone - bio->bi_sector;
2547 bp = bio_split(bio, bio_split_pool, first_sectors); 2547 bp = bio_split(bio, first_sectors);
2548 BUG_ON(!bp); 2548 BUG_ON(!bp);
2549 pkt_make_request(q, &bp->bio1); 2549 pkt_make_request(q, &bp->bio1);
2550 pkt_make_request(q, &bp->bio2); 2550 pkt_make_request(q, &bp->bio2);
@@ -2911,7 +2911,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
2911 if (!disk->queue) 2911 if (!disk->queue)
2912 goto out_mem2; 2912 goto out_mem2;
2913 2913
2914 pd->pkt_dev = MKDEV(disk->major, disk->first_minor); 2914 pd->pkt_dev = MKDEV(pktdev_major, idx);
2915 ret = pkt_new_dev(pd, dev); 2915 ret = pkt_new_dev(pd, dev);
2916 if (ret) 2916 if (ret)
2917 goto out_new_dev; 2917 goto out_new_dev;
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index d797e209951d..936466f62afd 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -199,7 +199,8 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
199 if (blk_fs_request(req)) { 199 if (blk_fs_request(req)) {
200 if (ps3disk_submit_request_sg(dev, req)) 200 if (ps3disk_submit_request_sg(dev, req))
201 break; 201 break;
202 } else if (req->cmd_type == REQ_TYPE_FLUSH) { 202 } else if (req->cmd_type == REQ_TYPE_LINUX_BLOCK &&
203 req->cmd[0] == REQ_LB_OP_FLUSH) {
203 if (ps3disk_submit_flush_request(dev, req)) 204 if (ps3disk_submit_flush_request(dev, req))
204 break; 205 break;
205 } else { 206 } else {
@@ -257,7 +258,8 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
257 return IRQ_HANDLED; 258 return IRQ_HANDLED;
258 } 259 }
259 260
260 if (req->cmd_type == REQ_TYPE_FLUSH) { 261 if (req->cmd_type == REQ_TYPE_LINUX_BLOCK &&
262 req->cmd[0] == REQ_LB_OP_FLUSH) {
261 read = 0; 263 read = 0;
262 num_sectors = req->hard_cur_sectors; 264 num_sectors = req->hard_cur_sectors;
263 op = "flush"; 265 op = "flush";
@@ -405,7 +407,8 @@ static void ps3disk_prepare_flush(struct request_queue *q, struct request *req)
405 407
406 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__); 408 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
407 409
408 req->cmd_type = REQ_TYPE_FLUSH; 410 req->cmd_type = REQ_TYPE_LINUX_BLOCK;
411 req->cmd[0] = REQ_LB_OP_FLUSH;
409} 412}
410 413
411static unsigned long ps3disk_mask; 414static unsigned long ps3disk_mask;
@@ -538,7 +541,7 @@ static int ps3disk_remove(struct ps3_system_bus_device *_dev)
538 struct ps3disk_private *priv = dev->sbd.core.driver_data; 541 struct ps3disk_private *priv = dev->sbd.core.driver_data;
539 542
540 mutex_lock(&ps3disk_mask_mutex); 543 mutex_lock(&ps3disk_mask_mutex);
541 __clear_bit(priv->gendisk->first_minor / PS3DISK_MINORS, 544 __clear_bit(MINOR(disk_devt(priv->gendisk)) / PS3DISK_MINORS,
542 &ps3disk_mask); 545 &ps3disk_mask);
543 mutex_unlock(&ps3disk_mask_mutex); 546 mutex_unlock(&ps3disk_mask_mutex);
544 del_gendisk(priv->gendisk); 547 del_gendisk(priv->gendisk);
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 42251095134f..6ec5fc052786 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -47,20 +47,20 @@ static void blk_done(struct virtqueue *vq)
47 47
48 spin_lock_irqsave(&vblk->lock, flags); 48 spin_lock_irqsave(&vblk->lock, flags);
49 while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) { 49 while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) {
50 int uptodate; 50 int error;
51 switch (vbr->status) { 51 switch (vbr->status) {
52 case VIRTIO_BLK_S_OK: 52 case VIRTIO_BLK_S_OK:
53 uptodate = 1; 53 error = 0;
54 break; 54 break;
55 case VIRTIO_BLK_S_UNSUPP: 55 case VIRTIO_BLK_S_UNSUPP:
56 uptodate = -ENOTTY; 56 error = -ENOTTY;
57 break; 57 break;
58 default: 58 default:
59 uptodate = 0; 59 error = -EIO;
60 break; 60 break;
61 } 61 }
62 62
63 end_dequeued_request(vbr->req, uptodate); 63 __blk_end_request(vbr->req, error, blk_rq_bytes(vbr->req));
64 list_del(&vbr->list); 64 list_del(&vbr->list);
65 mempool_free(vbr, vblk->pool); 65 mempool_free(vbr, vblk->pool);
66 } 66 }
@@ -84,11 +84,11 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
84 if (blk_fs_request(vbr->req)) { 84 if (blk_fs_request(vbr->req)) {
85 vbr->out_hdr.type = 0; 85 vbr->out_hdr.type = 0;
86 vbr->out_hdr.sector = vbr->req->sector; 86 vbr->out_hdr.sector = vbr->req->sector;
87 vbr->out_hdr.ioprio = vbr->req->ioprio; 87 vbr->out_hdr.ioprio = req_get_ioprio(vbr->req);
88 } else if (blk_pc_request(vbr->req)) { 88 } else if (blk_pc_request(vbr->req)) {
89 vbr->out_hdr.type = VIRTIO_BLK_T_SCSI_CMD; 89 vbr->out_hdr.type = VIRTIO_BLK_T_SCSI_CMD;
90 vbr->out_hdr.sector = 0; 90 vbr->out_hdr.sector = 0;
91 vbr->out_hdr.ioprio = vbr->req->ioprio; 91 vbr->out_hdr.ioprio = req_get_ioprio(vbr->req);
92 } else { 92 } else {
93 /* We don't put anything else in the queue. */ 93 /* We don't put anything else in the queue. */
94 BUG(); 94 BUG();
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index d5e753255153..1a50ae70f716 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -105,15 +105,17 @@ static DEFINE_SPINLOCK(blkif_io_lock);
105#define GRANT_INVALID_REF 0 105#define GRANT_INVALID_REF 0
106 106
107#define PARTS_PER_DISK 16 107#define PARTS_PER_DISK 16
108#define PARTS_PER_EXT_DISK 256
108 109
109#define BLKIF_MAJOR(dev) ((dev)>>8) 110#define BLKIF_MAJOR(dev) ((dev)>>8)
110#define BLKIF_MINOR(dev) ((dev) & 0xff) 111#define BLKIF_MINOR(dev) ((dev) & 0xff)
111 112
112#define DEV_NAME "xvd" /* name in /dev */ 113#define EXT_SHIFT 28
114#define EXTENDED (1<<EXT_SHIFT)
115#define VDEV_IS_EXTENDED(dev) ((dev)&(EXTENDED))
116#define BLKIF_MINOR_EXT(dev) ((dev)&(~EXTENDED))
113 117
114/* Information about our VBDs. */ 118#define DEV_NAME "xvd" /* name in /dev */
115#define MAX_VBDS 64
116static LIST_HEAD(vbds_list);
117 119
118static int get_id_from_freelist(struct blkfront_info *info) 120static int get_id_from_freelist(struct blkfront_info *info)
119{ 121{
@@ -386,31 +388,60 @@ static int xlvbd_barrier(struct blkfront_info *info)
386} 388}
387 389
388 390
389static int xlvbd_alloc_gendisk(int minor, blkif_sector_t capacity, 391static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
390 int vdevice, u16 vdisk_info, u16 sector_size, 392 struct blkfront_info *info,
391 struct blkfront_info *info) 393 u16 vdisk_info, u16 sector_size)
392{ 394{
393 struct gendisk *gd; 395 struct gendisk *gd;
394 int nr_minors = 1; 396 int nr_minors = 1;
395 int err = -ENODEV; 397 int err = -ENODEV;
398 unsigned int offset;
399 int minor;
400 int nr_parts;
396 401
397 BUG_ON(info->gd != NULL); 402 BUG_ON(info->gd != NULL);
398 BUG_ON(info->rq != NULL); 403 BUG_ON(info->rq != NULL);
399 404
400 if ((minor % PARTS_PER_DISK) == 0) 405 if ((info->vdevice>>EXT_SHIFT) > 1) {
401 nr_minors = PARTS_PER_DISK; 406 /* this is above the extended range; something is wrong */
407 printk(KERN_WARNING "blkfront: vdevice 0x%x is above the extended range; ignoring\n", info->vdevice);
408 return -ENODEV;
409 }
410
411 if (!VDEV_IS_EXTENDED(info->vdevice)) {
412 minor = BLKIF_MINOR(info->vdevice);
413 nr_parts = PARTS_PER_DISK;
414 } else {
415 minor = BLKIF_MINOR_EXT(info->vdevice);
416 nr_parts = PARTS_PER_EXT_DISK;
417 }
418
419 if ((minor % nr_parts) == 0)
420 nr_minors = nr_parts;
402 421
403 gd = alloc_disk(nr_minors); 422 gd = alloc_disk(nr_minors);
404 if (gd == NULL) 423 if (gd == NULL)
405 goto out; 424 goto out;
406 425
407 if (nr_minors > 1) 426 offset = minor / nr_parts;
408 sprintf(gd->disk_name, "%s%c", DEV_NAME, 427
409 'a' + minor / PARTS_PER_DISK); 428 if (nr_minors > 1) {
410 else 429 if (offset < 26)
411 sprintf(gd->disk_name, "%s%c%d", DEV_NAME, 430 sprintf(gd->disk_name, "%s%c", DEV_NAME, 'a' + offset);
412 'a' + minor / PARTS_PER_DISK, 431 else
413 minor % PARTS_PER_DISK); 432 sprintf(gd->disk_name, "%s%c%c", DEV_NAME,
433 'a' + ((offset / 26)-1), 'a' + (offset % 26));
434 } else {
435 if (offset < 26)
436 sprintf(gd->disk_name, "%s%c%d", DEV_NAME,
437 'a' + offset,
438 minor & (nr_parts - 1));
439 else
440 sprintf(gd->disk_name, "%s%c%c%d", DEV_NAME,
441 'a' + ((offset / 26) - 1),
442 'a' + (offset % 26),
443 minor & (nr_parts - 1));
444 }
414 445
415 gd->major = XENVBD_MAJOR; 446 gd->major = XENVBD_MAJOR;
416 gd->first_minor = minor; 447 gd->first_minor = minor;
@@ -699,8 +730,13 @@ static int blkfront_probe(struct xenbus_device *dev,
699 err = xenbus_scanf(XBT_NIL, dev->nodename, 730 err = xenbus_scanf(XBT_NIL, dev->nodename,
700 "virtual-device", "%i", &vdevice); 731 "virtual-device", "%i", &vdevice);
701 if (err != 1) { 732 if (err != 1) {
702 xenbus_dev_fatal(dev, err, "reading virtual-device"); 733 /* go looking in the extended area instead */
703 return err; 734 err = xenbus_scanf(XBT_NIL, dev->nodename, "virtual-device-ext",
735 "%i", &vdevice);
736 if (err != 1) {
737 xenbus_dev_fatal(dev, err, "reading virtual-device");
738 return err;
739 }
704 } 740 }
705 741
706 info = kzalloc(sizeof(*info), GFP_KERNEL); 742 info = kzalloc(sizeof(*info), GFP_KERNEL);
@@ -861,9 +897,7 @@ static void blkfront_connect(struct blkfront_info *info)
861 if (err) 897 if (err)
862 info->feature_barrier = 0; 898 info->feature_barrier = 0;
863 899
864 err = xlvbd_alloc_gendisk(BLKIF_MINOR(info->vdevice), 900 err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size);
865 sectors, info->vdevice,
866 binfo, sector_size, info);
867 if (err) { 901 if (err) {
868 xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", 902 xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s",
869 info->xbdev->otherend); 903 info->xbdev->otherend);