aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/block/switching-sched.txt6
-rw-r--r--block/blk-core.c13
-rw-r--r--block/blk-merge.c2
-rw-r--r--block/bsg.c12
-rw-r--r--block/scsi_ioctl.c21
-rw-r--r--drivers/block/cciss.c7
-rw-r--r--drivers/block/cpqarray.c1
-rw-r--r--drivers/block/loop.c48
-rw-r--r--fs/bio-integrity.c85
-rw-r--r--fs/bio.c87
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/super.c11
-rw-r--r--fs/sync.c14
-rw-r--r--include/linux/bio.h18
-rw-r--r--include/linux/bsg.h8
-rw-r--r--include/linux/genhd.h5
-rw-r--r--mm/backing-dev.c26
-rw-r--r--mm/readahead.c25
18 files changed, 205 insertions, 186 deletions
diff --git a/Documentation/block/switching-sched.txt b/Documentation/block/switching-sched.txt
index 634c952e1964..d5af3f630814 100644
--- a/Documentation/block/switching-sched.txt
+++ b/Documentation/block/switching-sched.txt
@@ -35,9 +35,3 @@ noop anticipatory deadline [cfq]
35# echo anticipatory > /sys/block/hda/queue/scheduler 35# echo anticipatory > /sys/block/hda/queue/scheduler
36# cat /sys/block/hda/queue/scheduler 36# cat /sys/block/hda/queue/scheduler
37noop [anticipatory] deadline cfq 37noop [anticipatory] deadline cfq
38
39Each io queue has a set of io scheduler tunables associated with it. These
40tunables control how the io scheduler works. You can find these entries
41in:
42
43/sys/block/<device>/queue/iosched
diff --git a/block/blk-core.c b/block/blk-core.c
index 29bcfac6c688..996ed906d8ca 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -603,13 +603,10 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
603 q->queue_flags = QUEUE_FLAG_DEFAULT; 603 q->queue_flags = QUEUE_FLAG_DEFAULT;
604 q->queue_lock = lock; 604 q->queue_lock = lock;
605 605
606 blk_queue_segment_boundary(q, BLK_SEG_BOUNDARY_MASK); 606 /*
607 607 * This also sets hw/phys segments, boundary and size
608 */
608 blk_queue_make_request(q, __make_request); 609 blk_queue_make_request(q, __make_request);
609 blk_queue_max_segment_size(q, MAX_SEGMENT_SIZE);
610
611 blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
612 blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
613 610
614 q->sg_reserved_size = INT_MAX; 611 q->sg_reserved_size = INT_MAX;
615 612
@@ -735,7 +732,6 @@ static void freed_request(struct request_queue *q, int rw, int priv)
735 __freed_request(q, rw ^ 1); 732 __freed_request(q, rw ^ 1);
736} 733}
737 734
738#define blkdev_free_rq(list) list_entry((list)->next, struct request, queuelist)
739/* 735/*
740 * Get a free request, queue_lock must be held. 736 * Get a free request, queue_lock must be held.
741 * Returns NULL on failure, with queue_lock held. 737 * Returns NULL on failure, with queue_lock held.
@@ -1066,6 +1062,9 @@ void __blk_put_request(struct request_queue *q, struct request *req)
1066 1062
1067 elv_completed_request(q, req); 1063 elv_completed_request(q, req);
1068 1064
1065 /* this is a bio leak */
1066 WARN_ON(req->bio != NULL);
1067
1069 /* 1068 /*
1070 * Request may not have originated from ll_rw_blk. if not, 1069 * Request may not have originated from ll_rw_blk. if not,
1071 * it didn't come out of our reserved rq pools 1070 * it didn't come out of our reserved rq pools
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 5a244f05360f..e39cb24b7679 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -403,6 +403,8 @@ static int attempt_merge(struct request_queue *q, struct request *req,
403 if (blk_rq_cpu_valid(next)) 403 if (blk_rq_cpu_valid(next))
404 req->cpu = next->cpu; 404 req->cpu = next->cpu;
405 405
406 /* owner-ship of bio passed from next to req */
407 next->bio = NULL;
406 __blk_put_request(q, next); 408 __blk_put_request(q, next);
407 return 1; 409 return 1;
408} 410}
diff --git a/block/bsg.c b/block/bsg.c
index 0ce8806dd0c1..206060e795da 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -218,9 +218,6 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)
218 218
219 if (hdr->guard != 'Q') 219 if (hdr->guard != 'Q')
220 return -EINVAL; 220 return -EINVAL;
221 if (hdr->dout_xfer_len > (q->max_sectors << 9) ||
222 hdr->din_xfer_len > (q->max_sectors << 9))
223 return -EIO;
224 221
225 switch (hdr->protocol) { 222 switch (hdr->protocol) {
226 case BSG_PROTOCOL_SCSI: 223 case BSG_PROTOCOL_SCSI:
@@ -353,6 +350,8 @@ static void bsg_rq_end_io(struct request *rq, int uptodate)
353static void bsg_add_command(struct bsg_device *bd, struct request_queue *q, 350static void bsg_add_command(struct bsg_device *bd, struct request_queue *q,
354 struct bsg_command *bc, struct request *rq) 351 struct bsg_command *bc, struct request *rq)
355{ 352{
353 int at_head = (0 == (bc->hdr.flags & BSG_FLAG_Q_AT_TAIL));
354
356 /* 355 /*
357 * add bc command to busy queue and submit rq for io 356 * add bc command to busy queue and submit rq for io
358 */ 357 */
@@ -368,7 +367,7 @@ static void bsg_add_command(struct bsg_device *bd, struct request_queue *q,
368 dprintk("%s: queueing rq %p, bc %p\n", bd->name, rq, bc); 367 dprintk("%s: queueing rq %p, bc %p\n", bd->name, rq, bc);
369 368
370 rq->end_io_data = bc; 369 rq->end_io_data = bc;
371 blk_execute_rq_nowait(q, NULL, rq, 1, bsg_rq_end_io); 370 blk_execute_rq_nowait(q, NULL, rq, at_head, bsg_rq_end_io);
372} 371}
373 372
374static struct bsg_command *bsg_next_done_cmd(struct bsg_device *bd) 373static struct bsg_command *bsg_next_done_cmd(struct bsg_device *bd)
@@ -924,6 +923,7 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
924 struct request *rq; 923 struct request *rq;
925 struct bio *bio, *bidi_bio = NULL; 924 struct bio *bio, *bidi_bio = NULL;
926 struct sg_io_v4 hdr; 925 struct sg_io_v4 hdr;
926 int at_head;
927 u8 sense[SCSI_SENSE_BUFFERSIZE]; 927 u8 sense[SCSI_SENSE_BUFFERSIZE];
928 928
929 if (copy_from_user(&hdr, uarg, sizeof(hdr))) 929 if (copy_from_user(&hdr, uarg, sizeof(hdr)))
@@ -936,7 +936,9 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
936 bio = rq->bio; 936 bio = rq->bio;
937 if (rq->next_rq) 937 if (rq->next_rq)
938 bidi_bio = rq->next_rq->bio; 938 bidi_bio = rq->next_rq->bio;
939 blk_execute_rq(bd->queue, NULL, rq, 0); 939
940 at_head = (0 == (hdr.flags & BSG_FLAG_Q_AT_TAIL));
941 blk_execute_rq(bd->queue, NULL, rq, at_head);
940 ret = blk_complete_sgv4_hdr_rq(rq, &hdr, bio, bidi_bio); 942 ret = blk_complete_sgv4_hdr_rq(rq, &hdr, bio, bidi_bio);
941 943
942 if (copy_to_user(uarg, &hdr, sizeof(hdr))) 944 if (copy_to_user(uarg, &hdr, sizeof(hdr)))
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index ee9c67d7e1be..626ee274c5c4 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -214,21 +214,10 @@ static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
214 return 0; 214 return 0;
215} 215}
216 216
217/*
218 * unmap a request that was previously mapped to this sg_io_hdr. handles
219 * both sg and non-sg sg_io_hdr.
220 */
221static int blk_unmap_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr)
222{
223 blk_rq_unmap_user(rq->bio);
224 blk_put_request(rq);
225 return 0;
226}
227
228static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, 217static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
229 struct bio *bio) 218 struct bio *bio)
230{ 219{
231 int r, ret = 0; 220 int ret = 0;
232 221
233 /* 222 /*
234 * fill in all the output members 223 * fill in all the output members
@@ -253,12 +242,10 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
253 ret = -EFAULT; 242 ret = -EFAULT;
254 } 243 }
255 244
256 rq->bio = bio; 245 blk_rq_unmap_user(bio);
257 r = blk_unmap_sghdr_rq(rq, hdr); 246 blk_put_request(rq);
258 if (ret)
259 r = ret;
260 247
261 return r; 248 return ret;
262} 249}
263 250
264static int sg_io(struct request_queue *q, struct gendisk *bd_disk, 251static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 4f9b6d792017..5d0e135824f9 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3898,6 +3898,13 @@ static struct pci_driver cciss_pci_driver = {
3898 */ 3898 */
3899static int __init cciss_init(void) 3899static int __init cciss_init(void)
3900{ 3900{
3901 /*
3902 * The hardware requires that commands are aligned on a 64-bit
3903 * boundary. Given that we use pci_alloc_consistent() to allocate an
3904 * array of them, the size must be a multiple of 8 bytes.
3905 */
3906 BUILD_BUG_ON(sizeof(CommandList_struct) % 8);
3907
3901 printk(KERN_INFO DRIVER_NAME "\n"); 3908 printk(KERN_INFO DRIVER_NAME "\n");
3902 3909
3903 /* Register for our PCI devices */ 3910 /* Register for our PCI devices */
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 5d39df14ed90..ca268ca11159 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -617,6 +617,7 @@ static int cpqarray_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
617 int i; 617 int i;
618 618
619 c->pci_dev = pdev; 619 c->pci_dev = pdev;
620 pci_set_master(pdev);
620 if (pci_enable_device(pdev)) { 621 if (pci_enable_device(pdev)) {
621 printk(KERN_ERR "cpqarray: Unable to Enable PCI device\n"); 622 printk(KERN_ERR "cpqarray: Unable to Enable PCI device\n");
622 return -1; 623 return -1;
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index bf0345577672..2621ed2ce6d2 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -474,10 +474,35 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
474 int ret; 474 int ret;
475 475
476 pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset; 476 pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
477 if (bio_rw(bio) == WRITE) 477
478 if (bio_rw(bio) == WRITE) {
479 int barrier = bio_barrier(bio);
480 struct file *file = lo->lo_backing_file;
481
482 if (barrier) {
483 if (unlikely(!file->f_op->fsync)) {
484 ret = -EOPNOTSUPP;
485 goto out;
486 }
487
488 ret = vfs_fsync(file, file->f_path.dentry, 0);
489 if (unlikely(ret)) {
490 ret = -EIO;
491 goto out;
492 }
493 }
494
478 ret = lo_send(lo, bio, pos); 495 ret = lo_send(lo, bio, pos);
479 else 496
497 if (barrier && !ret) {
498 ret = vfs_fsync(file, file->f_path.dentry, 0);
499 if (unlikely(ret))
500 ret = -EIO;
501 }
502 } else
480 ret = lo_receive(lo, bio, lo->lo_blocksize, pos); 503 ret = lo_receive(lo, bio, lo->lo_blocksize, pos);
504
505out:
481 return ret; 506 return ret;
482} 507}
483 508
@@ -826,6 +851,9 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
826 lo->lo_queue->queuedata = lo; 851 lo->lo_queue->queuedata = lo;
827 lo->lo_queue->unplug_fn = loop_unplug; 852 lo->lo_queue->unplug_fn = loop_unplug;
828 853
854 if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
855 blk_queue_ordered(lo->lo_queue, QUEUE_ORDERED_DRAIN, NULL);
856
829 set_capacity(lo->lo_disk, size); 857 set_capacity(lo->lo_disk, size);
830 bd_set_size(bdev, size << 9); 858 bd_set_size(bdev, size << 9);
831 859
@@ -941,11 +969,18 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
941 bd_set_size(bdev, 0); 969 bd_set_size(bdev, 0);
942 mapping_set_gfp_mask(filp->f_mapping, gfp); 970 mapping_set_gfp_mask(filp->f_mapping, gfp);
943 lo->lo_state = Lo_unbound; 971 lo->lo_state = Lo_unbound;
944 fput(filp);
945 /* This is safe: open() is still holding a reference. */ 972 /* This is safe: open() is still holding a reference. */
946 module_put(THIS_MODULE); 973 module_put(THIS_MODULE);
947 if (max_part > 0) 974 if (max_part > 0)
948 ioctl_by_bdev(bdev, BLKRRPART, 0); 975 ioctl_by_bdev(bdev, BLKRRPART, 0);
976 mutex_unlock(&lo->lo_ctl_mutex);
977 /*
978 * Need not hold lo_ctl_mutex to fput backing file.
979 * Calling fput holding lo_ctl_mutex triggers a circular
980 * lock dependency possibility warning as fput can take
981 * bd_mutex which is usually taken before lo_ctl_mutex.
982 */
983 fput(filp);
949 return 0; 984 return 0;
950} 985}
951 986
@@ -1163,7 +1198,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
1163 struct loop_device *lo = bdev->bd_disk->private_data; 1198 struct loop_device *lo = bdev->bd_disk->private_data;
1164 int err; 1199 int err;
1165 1200
1166 mutex_lock(&lo->lo_ctl_mutex); 1201 mutex_lock_nested(&lo->lo_ctl_mutex, 1);
1167 switch (cmd) { 1202 switch (cmd) {
1168 case LOOP_SET_FD: 1203 case LOOP_SET_FD:
1169 err = loop_set_fd(lo, mode, bdev, arg); 1204 err = loop_set_fd(lo, mode, bdev, arg);
@@ -1172,7 +1207,10 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
1172 err = loop_change_fd(lo, bdev, arg); 1207 err = loop_change_fd(lo, bdev, arg);
1173 break; 1208 break;
1174 case LOOP_CLR_FD: 1209 case LOOP_CLR_FD:
1210 /* loop_clr_fd would have unlocked lo_ctl_mutex on success */
1175 err = loop_clr_fd(lo, bdev); 1211 err = loop_clr_fd(lo, bdev);
1212 if (!err)
1213 goto out_unlocked;
1176 break; 1214 break;
1177 case LOOP_SET_STATUS: 1215 case LOOP_SET_STATUS:
1178 err = loop_set_status_old(lo, (struct loop_info __user *) arg); 1216 err = loop_set_status_old(lo, (struct loop_info __user *) arg);
@@ -1190,6 +1228,8 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
1190 err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL; 1228 err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
1191 } 1229 }
1192 mutex_unlock(&lo->lo_ctl_mutex); 1230 mutex_unlock(&lo->lo_ctl_mutex);
1231
1232out_unlocked:
1193 return err; 1233 return err;
1194} 1234}
1195 1235
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index fe2b1aa2464e..31c46a241bac 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -26,23 +26,23 @@
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27 27
28static struct kmem_cache *bio_integrity_slab __read_mostly; 28static struct kmem_cache *bio_integrity_slab __read_mostly;
29static mempool_t *bio_integrity_pool;
30static struct bio_set *integrity_bio_set;
29static struct workqueue_struct *kintegrityd_wq; 31static struct workqueue_struct *kintegrityd_wq;
30 32
31/** 33/**
32 * bio_integrity_alloc_bioset - Allocate integrity payload and attach it to bio 34 * bio_integrity_alloc - Allocate integrity payload and attach it to bio
33 * @bio: bio to attach integrity metadata to 35 * @bio: bio to attach integrity metadata to
34 * @gfp_mask: Memory allocation mask 36 * @gfp_mask: Memory allocation mask
35 * @nr_vecs: Number of integrity metadata scatter-gather elements 37 * @nr_vecs: Number of integrity metadata scatter-gather elements
36 * @bs: bio_set to allocate from
37 * 38 *
38 * Description: This function prepares a bio for attaching integrity 39 * Description: This function prepares a bio for attaching integrity
39 * metadata. nr_vecs specifies the maximum number of pages containing 40 * metadata. nr_vecs specifies the maximum number of pages containing
40 * integrity metadata that can be attached. 41 * integrity metadata that can be attached.
41 */ 42 */
42struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio, 43struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
43 gfp_t gfp_mask, 44 gfp_t gfp_mask,
44 unsigned int nr_vecs, 45 unsigned int nr_vecs)
45 struct bio_set *bs)
46{ 46{
47 struct bio_integrity_payload *bip; 47 struct bio_integrity_payload *bip;
48 struct bio_vec *iv; 48 struct bio_vec *iv;
@@ -50,7 +50,7 @@ struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio,
50 50
51 BUG_ON(bio == NULL); 51 BUG_ON(bio == NULL);
52 52
53 bip = mempool_alloc(bs->bio_integrity_pool, gfp_mask); 53 bip = mempool_alloc(bio_integrity_pool, gfp_mask);
54 if (unlikely(bip == NULL)) { 54 if (unlikely(bip == NULL)) {
55 printk(KERN_ERR "%s: could not alloc bip\n", __func__); 55 printk(KERN_ERR "%s: could not alloc bip\n", __func__);
56 return NULL; 56 return NULL;
@@ -58,10 +58,10 @@ struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio,
58 58
59 memset(bip, 0, sizeof(*bip)); 59 memset(bip, 0, sizeof(*bip));
60 60
61 iv = bvec_alloc_bs(gfp_mask, nr_vecs, &idx, bs); 61 iv = bvec_alloc_bs(gfp_mask, nr_vecs, &idx, integrity_bio_set);
62 if (unlikely(iv == NULL)) { 62 if (unlikely(iv == NULL)) {
63 printk(KERN_ERR "%s: could not alloc bip_vec\n", __func__); 63 printk(KERN_ERR "%s: could not alloc bip_vec\n", __func__);
64 mempool_free(bip, bs->bio_integrity_pool); 64 mempool_free(bip, bio_integrity_pool);
65 return NULL; 65 return NULL;
66 } 66 }
67 67
@@ -72,35 +72,16 @@ struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio,
72 72
73 return bip; 73 return bip;
74} 74}
75EXPORT_SYMBOL(bio_integrity_alloc_bioset);
76
77/**
78 * bio_integrity_alloc - Allocate integrity payload and attach it to bio
79 * @bio: bio to attach integrity metadata to
80 * @gfp_mask: Memory allocation mask
81 * @nr_vecs: Number of integrity metadata scatter-gather elements
82 *
83 * Description: This function prepares a bio for attaching integrity
84 * metadata. nr_vecs specifies the maximum number of pages containing
85 * integrity metadata that can be attached.
86 */
87struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
88 gfp_t gfp_mask,
89 unsigned int nr_vecs)
90{
91 return bio_integrity_alloc_bioset(bio, gfp_mask, nr_vecs, fs_bio_set);
92}
93EXPORT_SYMBOL(bio_integrity_alloc); 75EXPORT_SYMBOL(bio_integrity_alloc);
94 76
95/** 77/**
96 * bio_integrity_free - Free bio integrity payload 78 * bio_integrity_free - Free bio integrity payload
97 * @bio: bio containing bip to be freed 79 * @bio: bio containing bip to be freed
98 * @bs: bio_set this bio was allocated from
99 * 80 *
100 * Description: Used to free the integrity portion of a bio. Usually 81 * Description: Used to free the integrity portion of a bio. Usually
101 * called from bio_free(). 82 * called from bio_free().
102 */ 83 */
103void bio_integrity_free(struct bio *bio, struct bio_set *bs) 84void bio_integrity_free(struct bio *bio)
104{ 85{
105 struct bio_integrity_payload *bip = bio->bi_integrity; 86 struct bio_integrity_payload *bip = bio->bi_integrity;
106 87
@@ -111,8 +92,8 @@ void bio_integrity_free(struct bio *bio, struct bio_set *bs)
111 && bip->bip_buf != NULL) 92 && bip->bip_buf != NULL)
112 kfree(bip->bip_buf); 93 kfree(bip->bip_buf);
113 94
114 bvec_free_bs(bs, bip->bip_vec, bip->bip_pool); 95 bvec_free_bs(integrity_bio_set, bip->bip_vec, bip->bip_pool);
115 mempool_free(bip, bs->bio_integrity_pool); 96 mempool_free(bip, bio_integrity_pool);
116 97
117 bio->bi_integrity = NULL; 98 bio->bi_integrity = NULL;
118} 99}
@@ -686,19 +667,17 @@ EXPORT_SYMBOL(bio_integrity_split);
686 * @bio: New bio 667 * @bio: New bio
687 * @bio_src: Original bio 668 * @bio_src: Original bio
688 * @gfp_mask: Memory allocation mask 669 * @gfp_mask: Memory allocation mask
689 * @bs: bio_set to allocate bip from
690 * 670 *
691 * Description: Called to allocate a bip when cloning a bio 671 * Description: Called to allocate a bip when cloning a bio
692 */ 672 */
693int bio_integrity_clone(struct bio *bio, struct bio *bio_src, 673int bio_integrity_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp_mask)
694 gfp_t gfp_mask, struct bio_set *bs)
695{ 674{
696 struct bio_integrity_payload *bip_src = bio_src->bi_integrity; 675 struct bio_integrity_payload *bip_src = bio_src->bi_integrity;
697 struct bio_integrity_payload *bip; 676 struct bio_integrity_payload *bip;
698 677
699 BUG_ON(bip_src == NULL); 678 BUG_ON(bip_src == NULL);
700 679
701 bip = bio_integrity_alloc_bioset(bio, gfp_mask, bip_src->bip_vcnt, bs); 680 bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt);
702 681
703 if (bip == NULL) 682 if (bip == NULL)
704 return -EIO; 683 return -EIO;
@@ -714,37 +693,25 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
714} 693}
715EXPORT_SYMBOL(bio_integrity_clone); 694EXPORT_SYMBOL(bio_integrity_clone);
716 695
717int bioset_integrity_create(struct bio_set *bs, int pool_size) 696static int __init bio_integrity_init(void)
718{ 697{
719 bs->bio_integrity_pool = mempool_create_slab_pool(pool_size, 698 kintegrityd_wq = create_workqueue("kintegrityd");
720 bio_integrity_slab);
721 if (!bs->bio_integrity_pool)
722 return -1;
723
724 return 0;
725}
726EXPORT_SYMBOL(bioset_integrity_create);
727 699
728void bioset_integrity_free(struct bio_set *bs) 700 if (!kintegrityd_wq)
729{ 701 panic("Failed to create kintegrityd\n");
730 if (bs->bio_integrity_pool)
731 mempool_destroy(bs->bio_integrity_pool);
732}
733EXPORT_SYMBOL(bioset_integrity_free);
734 702
735void __init bio_integrity_init_slab(void)
736{
737 bio_integrity_slab = KMEM_CACHE(bio_integrity_payload, 703 bio_integrity_slab = KMEM_CACHE(bio_integrity_payload,
738 SLAB_HWCACHE_ALIGN|SLAB_PANIC); 704 SLAB_HWCACHE_ALIGN|SLAB_PANIC);
739}
740 705
741static int __init integrity_init(void) 706 bio_integrity_pool = mempool_create_slab_pool(BIO_POOL_SIZE,
742{ 707 bio_integrity_slab);
743 kintegrityd_wq = create_workqueue("kintegrityd"); 708 if (!bio_integrity_pool)
709 panic("bio_integrity: can't allocate bip pool\n");
744 710
745 if (!kintegrityd_wq) 711 integrity_bio_set = bioset_create(BIO_POOL_SIZE, 0);
746 panic("Failed to create kintegrityd\n"); 712 if (!integrity_bio_set)
713 panic("bio_integrity: can't allocate bio_set\n");
747 714
748 return 0; 715 return 0;
749} 716}
750subsys_initcall(integrity_init); 717subsys_initcall(bio_integrity_init);
diff --git a/fs/bio.c b/fs/bio.c
index d4f06327c810..a040cde7f6fd 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -248,7 +248,7 @@ void bio_free(struct bio *bio, struct bio_set *bs)
248 bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio)); 248 bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio));
249 249
250 if (bio_integrity(bio)) 250 if (bio_integrity(bio))
251 bio_integrity_free(bio, bs); 251 bio_integrity_free(bio);
252 252
253 /* 253 /*
254 * If we have front padding, adjust the bio pointer before freeing 254 * If we have front padding, adjust the bio pointer before freeing
@@ -301,48 +301,51 @@ void bio_init(struct bio *bio)
301 **/ 301 **/
302struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs) 302struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
303{ 303{
304 struct bio_vec *bvl = NULL;
304 struct bio *bio = NULL; 305 struct bio *bio = NULL;
305 void *uninitialized_var(p); 306 unsigned long idx = 0;
307 void *p = NULL;
306 308
307 if (bs) { 309 if (bs) {
308 p = mempool_alloc(bs->bio_pool, gfp_mask); 310 p = mempool_alloc(bs->bio_pool, gfp_mask);
309 311 if (!p)
310 if (p) 312 goto err;
311 bio = p + bs->front_pad; 313 bio = p + bs->front_pad;
312 } else 314 } else {
313 bio = kmalloc(sizeof(*bio), gfp_mask); 315 bio = kmalloc(sizeof(*bio), gfp_mask);
316 if (!bio)
317 goto err;
318 }
314 319
315 if (likely(bio)) { 320 bio_init(bio);
316 struct bio_vec *bvl = NULL; 321
317 322 if (unlikely(!nr_iovecs))
318 bio_init(bio); 323 goto out_set;
319 if (likely(nr_iovecs)) { 324
320 unsigned long uninitialized_var(idx); 325 if (nr_iovecs <= BIO_INLINE_VECS) {
321 326 bvl = bio->bi_inline_vecs;
322 if (nr_iovecs <= BIO_INLINE_VECS) { 327 nr_iovecs = BIO_INLINE_VECS;
323 idx = 0; 328 } else {
324 bvl = bio->bi_inline_vecs; 329 bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
325 nr_iovecs = BIO_INLINE_VECS; 330 if (unlikely(!bvl))
326 } else { 331 goto err_free;
327 bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, 332
328 bs); 333 nr_iovecs = bvec_nr_vecs(idx);
329 nr_iovecs = bvec_nr_vecs(idx);
330 }
331 if (unlikely(!bvl)) {
332 if (bs)
333 mempool_free(p, bs->bio_pool);
334 else
335 kfree(bio);
336 bio = NULL;
337 goto out;
338 }
339 bio->bi_flags |= idx << BIO_POOL_OFFSET;
340 bio->bi_max_vecs = nr_iovecs;
341 }
342 bio->bi_io_vec = bvl;
343 } 334 }
344out: 335 bio->bi_flags |= idx << BIO_POOL_OFFSET;
336 bio->bi_max_vecs = nr_iovecs;
337out_set:
338 bio->bi_io_vec = bvl;
339
345 return bio; 340 return bio;
341
342err_free:
343 if (bs)
344 mempool_free(p, bs->bio_pool);
345 else
346 kfree(bio);
347err:
348 return NULL;
346} 349}
347 350
348struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs) 351struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs)
@@ -463,7 +466,7 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
463 if (bio_integrity(bio)) { 466 if (bio_integrity(bio)) {
464 int ret; 467 int ret;
465 468
466 ret = bio_integrity_clone(b, bio, gfp_mask, fs_bio_set); 469 ret = bio_integrity_clone(b, bio, gfp_mask);
467 470
468 if (ret < 0) { 471 if (ret < 0) {
469 bio_put(b); 472 bio_put(b);
@@ -1526,7 +1529,6 @@ void bioset_free(struct bio_set *bs)
1526 if (bs->bio_pool) 1529 if (bs->bio_pool)
1527 mempool_destroy(bs->bio_pool); 1530 mempool_destroy(bs->bio_pool);
1528 1531
1529 bioset_integrity_free(bs);
1530 biovec_free_pools(bs); 1532 biovec_free_pools(bs);
1531 bio_put_slab(bs); 1533 bio_put_slab(bs);
1532 1534
@@ -1567,9 +1569,6 @@ struct bio_set *bioset_create(unsigned int pool_size, unsigned int front_pad)
1567 if (!bs->bio_pool) 1569 if (!bs->bio_pool)
1568 goto bad; 1570 goto bad;
1569 1571
1570 if (bioset_integrity_create(bs, pool_size))
1571 goto bad;
1572
1573 if (!biovec_create_pools(bs, pool_size)) 1572 if (!biovec_create_pools(bs, pool_size))
1574 return bs; 1573 return bs;
1575 1574
@@ -1586,6 +1585,13 @@ static void __init biovec_init_slabs(void)
1586 int size; 1585 int size;
1587 struct biovec_slab *bvs = bvec_slabs + i; 1586 struct biovec_slab *bvs = bvec_slabs + i;
1588 1587
1588#ifndef CONFIG_BLK_DEV_INTEGRITY
1589 if (bvs->nr_vecs <= BIO_INLINE_VECS) {
1590 bvs->slab = NULL;
1591 continue;
1592 }
1593#endif
1594
1589 size = bvs->nr_vecs * sizeof(struct bio_vec); 1595 size = bvs->nr_vecs * sizeof(struct bio_vec);
1590 bvs->slab = kmem_cache_create(bvs->name, size, 0, 1596 bvs->slab = kmem_cache_create(bvs->name, size, 0,
1591 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 1597 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
@@ -1600,7 +1606,6 @@ static int __init init_bio(void)
1600 if (!bio_slabs) 1606 if (!bio_slabs)
1601 panic("bio: can't allocate bios\n"); 1607 panic("bio: can't allocate bios\n");
1602 1608
1603 bio_integrity_init_slab();
1604 biovec_init_slabs(); 1609 biovec_init_slabs();
1605 1610
1606 fs_bio_set = bioset_create(BIO_POOL_SIZE, 0); 1611 fs_bio_set = bioset_create(BIO_POOL_SIZE, 0);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 3e18175248e0..6ec80c0fc869 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2385,7 +2385,7 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr)
2385 unsigned long thresh = 32 * 1024 * 1024; 2385 unsigned long thresh = 32 * 1024 * 1024;
2386 tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree; 2386 tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree;
2387 2387
2388 if (current_is_pdflush() || current->flags & PF_MEMALLOC) 2388 if (current->flags & PF_MEMALLOC)
2389 return; 2389 return;
2390 2390
2391 num_dirty = count_range_bits(tree, &start, (u64)-1, 2391 num_dirty = count_range_bits(tree, &start, (u64)-1,
diff --git a/fs/super.c b/fs/super.c
index 6ce501447ada..dd4acb158b5e 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -674,7 +674,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
674 return 0; 674 return 0;
675} 675}
676 676
677static void do_emergency_remount(unsigned long foo) 677static void do_emergency_remount(struct work_struct *work)
678{ 678{
679 struct super_block *sb; 679 struct super_block *sb;
680 680
@@ -697,12 +697,19 @@ static void do_emergency_remount(unsigned long foo)
697 spin_lock(&sb_lock); 697 spin_lock(&sb_lock);
698 } 698 }
699 spin_unlock(&sb_lock); 699 spin_unlock(&sb_lock);
700 kfree(work);
700 printk("Emergency Remount complete\n"); 701 printk("Emergency Remount complete\n");
701} 702}
702 703
703void emergency_remount(void) 704void emergency_remount(void)
704{ 705{
705 pdflush_operation(do_emergency_remount, 0); 706 struct work_struct *work;
707
708 work = kmalloc(sizeof(*work), GFP_ATOMIC);
709 if (work) {
710 INIT_WORK(work, do_emergency_remount);
711 schedule_work(work);
712 }
706} 713}
707 714
708/* 715/*
diff --git a/fs/sync.c b/fs/sync.c
index a16d53e5fe9d..ec95a69d17aa 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -42,9 +42,21 @@ SYSCALL_DEFINE0(sync)
42 return 0; 42 return 0;
43} 43}
44 44
45static void do_sync_work(struct work_struct *work)
46{
47 do_sync(0);
48 kfree(work);
49}
50
45void emergency_sync(void) 51void emergency_sync(void)
46{ 52{
47 pdflush_operation(do_sync, 0); 53 struct work_struct *work;
54
55 work = kmalloc(sizeof(*work), GFP_ATOMIC);
56 if (work) {
57 INIT_WORK(work, do_sync_work);
58 schedule_work(work);
59 }
48} 60}
49 61
50/* 62/*
diff --git a/include/linux/bio.h b/include/linux/bio.h
index d8bd43bfdcf5..b05b1d4d17d2 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -426,9 +426,6 @@ struct bio_set {
426 unsigned int front_pad; 426 unsigned int front_pad;
427 427
428 mempool_t *bio_pool; 428 mempool_t *bio_pool;
429#if defined(CONFIG_BLK_DEV_INTEGRITY)
430 mempool_t *bio_integrity_pool;
431#endif
432 mempool_t *bvec_pool; 429 mempool_t *bvec_pool;
433}; 430};
434 431
@@ -519,9 +516,8 @@ static inline int bio_has_data(struct bio *bio)
519 516
520#define bio_integrity(bio) (bio->bi_integrity != NULL) 517#define bio_integrity(bio) (bio->bi_integrity != NULL)
521 518
522extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
523extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); 519extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
524extern void bio_integrity_free(struct bio *, struct bio_set *); 520extern void bio_integrity_free(struct bio *);
525extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); 521extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
526extern int bio_integrity_enabled(struct bio *bio); 522extern int bio_integrity_enabled(struct bio *bio);
527extern int bio_integrity_set_tag(struct bio *, void *, unsigned int); 523extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
@@ -531,27 +527,21 @@ extern void bio_integrity_endio(struct bio *, int);
531extern void bio_integrity_advance(struct bio *, unsigned int); 527extern void bio_integrity_advance(struct bio *, unsigned int);
532extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); 528extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int);
533extern void bio_integrity_split(struct bio *, struct bio_pair *, int); 529extern void bio_integrity_split(struct bio *, struct bio_pair *, int);
534extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t, struct bio_set *); 530extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t);
535extern int bioset_integrity_create(struct bio_set *, int);
536extern void bioset_integrity_free(struct bio_set *);
537extern void bio_integrity_init_slab(void);
538 531
539#else /* CONFIG_BLK_DEV_INTEGRITY */ 532#else /* CONFIG_BLK_DEV_INTEGRITY */
540 533
541#define bio_integrity(a) (0) 534#define bio_integrity(a) (0)
542#define bioset_integrity_create(a, b) (0)
543#define bio_integrity_prep(a) (0) 535#define bio_integrity_prep(a) (0)
544#define bio_integrity_enabled(a) (0) 536#define bio_integrity_enabled(a) (0)
545#define bio_integrity_clone(a, b, c,d ) (0) 537#define bio_integrity_clone(a, b, c) (0)
546#define bioset_integrity_free(a) do { } while (0) 538#define bio_integrity_free(a) do { } while (0)
547#define bio_integrity_free(a, b) do { } while (0)
548#define bio_integrity_endio(a, b) do { } while (0) 539#define bio_integrity_endio(a, b) do { } while (0)
549#define bio_integrity_advance(a, b) do { } while (0) 540#define bio_integrity_advance(a, b) do { } while (0)
550#define bio_integrity_trim(a, b, c) do { } while (0) 541#define bio_integrity_trim(a, b, c) do { } while (0)
551#define bio_integrity_split(a, b, c) do { } while (0) 542#define bio_integrity_split(a, b, c) do { } while (0)
552#define bio_integrity_set_tag(a, b, c) do { } while (0) 543#define bio_integrity_set_tag(a, b, c) do { } while (0)
553#define bio_integrity_get_tag(a, b, c) do { } while (0) 544#define bio_integrity_get_tag(a, b, c) do { } while (0)
554#define bio_integrity_init_slab(a) do { } while (0)
555 545
556#endif /* CONFIG_BLK_DEV_INTEGRITY */ 546#endif /* CONFIG_BLK_DEV_INTEGRITY */
557 547
diff --git a/include/linux/bsg.h b/include/linux/bsg.h
index cf0303a60611..3f0c64ace424 100644
--- a/include/linux/bsg.h
+++ b/include/linux/bsg.h
@@ -7,6 +7,14 @@
7#define BSG_SUB_PROTOCOL_SCSI_TMF 1 7#define BSG_SUB_PROTOCOL_SCSI_TMF 1
8#define BSG_SUB_PROTOCOL_SCSI_TRANSPORT 2 8#define BSG_SUB_PROTOCOL_SCSI_TRANSPORT 2
9 9
10/*
11 * For flags member below
12 * sg.h sg_io_hdr also has bits defined for it's flags member. However
13 * none of these bits are implemented/used by bsg. The bits below are
14 * allocated to not conflict with sg.h ones anyway.
15 */
16#define BSG_FLAG_Q_AT_TAIL 0x10 /* default, == 0 at this bit, is Q_AT_HEAD */
17
10struct sg_io_v4 { 18struct sg_io_v4 {
11 __s32 guard; /* [i] 'Q' to differentiate from v3 */ 19 __s32 guard; /* [i] 'Q' to differentiate from v3 */
12 __u32 protocol; /* [i] 0 -> SCSI , .... */ 20 __u32 protocol; /* [i] 0 -> SCSI , .... */
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 16948eaecae3..634c53028fb8 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -333,11 +333,10 @@ static inline void part_dec_in_flight(struct hd_struct *part)
333 part_to_disk(part)->part0.in_flight--; 333 part_to_disk(part)->part0.in_flight--;
334} 334}
335 335
336/* drivers/block/ll_rw_blk.c */ 336/* block/blk-core.c */
337extern void part_round_stats(int cpu, struct hd_struct *part); 337extern void part_round_stats(int cpu, struct hd_struct *part);
338 338
339/* drivers/block/genhd.c */ 339/* block/genhd.c */
340extern int get_blkdev_list(char *, int);
341extern void add_disk(struct gendisk *disk); 340extern void add_disk(struct gendisk *disk);
342extern void del_gendisk(struct gendisk *gp); 341extern void del_gendisk(struct gendisk *gp);
343extern void unlink_gendisk(struct gendisk *gp); 342extern void unlink_gendisk(struct gendisk *gp);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 8e8587444132..be68c956a660 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -2,11 +2,24 @@
2#include <linux/wait.h> 2#include <linux/wait.h>
3#include <linux/backing-dev.h> 3#include <linux/backing-dev.h>
4#include <linux/fs.h> 4#include <linux/fs.h>
5#include <linux/pagemap.h>
5#include <linux/sched.h> 6#include <linux/sched.h>
6#include <linux/module.h> 7#include <linux/module.h>
7#include <linux/writeback.h> 8#include <linux/writeback.h>
8#include <linux/device.h> 9#include <linux/device.h>
9 10
11void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
12{
13}
14EXPORT_SYMBOL(default_unplug_io_fn);
15
16struct backing_dev_info default_backing_dev_info = {
17 .ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE,
18 .state = 0,
19 .capabilities = BDI_CAP_MAP_COPY,
20 .unplug_io_fn = default_unplug_io_fn,
21};
22EXPORT_SYMBOL_GPL(default_backing_dev_info);
10 23
11static struct class *bdi_class; 24static struct class *bdi_class;
12 25
@@ -166,9 +179,20 @@ static __init int bdi_class_init(void)
166 bdi_debug_init(); 179 bdi_debug_init();
167 return 0; 180 return 0;
168} 181}
169
170postcore_initcall(bdi_class_init); 182postcore_initcall(bdi_class_init);
171 183
184static int __init default_bdi_init(void)
185{
186 int err;
187
188 err = bdi_init(&default_backing_dev_info);
189 if (!err)
190 bdi_register(&default_backing_dev_info, NULL, "default");
191
192 return err;
193}
194subsys_initcall(default_bdi_init);
195
172int bdi_register(struct backing_dev_info *bdi, struct device *parent, 196int bdi_register(struct backing_dev_info *bdi, struct device *parent,
173 const char *fmt, ...) 197 const char *fmt, ...)
174{ 198{
diff --git a/mm/readahead.c b/mm/readahead.c
index bec83c15a78f..9ce303d4b810 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -17,19 +17,6 @@
17#include <linux/pagevec.h> 17#include <linux/pagevec.h>
18#include <linux/pagemap.h> 18#include <linux/pagemap.h>
19 19
20void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
21{
22}
23EXPORT_SYMBOL(default_unplug_io_fn);
24
25struct backing_dev_info default_backing_dev_info = {
26 .ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE,
27 .state = 0,
28 .capabilities = BDI_CAP_MAP_COPY,
29 .unplug_io_fn = default_unplug_io_fn,
30};
31EXPORT_SYMBOL_GPL(default_backing_dev_info);
32
33/* 20/*
34 * Initialise a struct file's readahead state. Assumes that the caller has 21 * Initialise a struct file's readahead state. Assumes that the caller has
35 * memset *ra to zero. 22 * memset *ra to zero.
@@ -233,18 +220,6 @@ unsigned long max_sane_readahead(unsigned long nr)
233 + node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2); 220 + node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
234} 221}
235 222
236static int __init readahead_init(void)
237{
238 int err;
239
240 err = bdi_init(&default_backing_dev_info);
241 if (!err)
242 bdi_register(&default_backing_dev_info, NULL, "default");
243
244 return err;
245}
246subsys_initcall(readahead_init);
247
248/* 223/*
249 * Submit IO for the read-ahead request in file_ra_state. 224 * Submit IO for the read-ahead request in file_ra_state.
250 */ 225 */