aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-cgroup.c37
-rw-r--r--block/blk-core.c15
-rw-r--r--block/blk-softirq.c2
-rw-r--r--block/blk-sysfs.c10
-rw-r--r--block/cfq-iosched.c20
-rw-r--r--drivers/block/floppy.c8
-rw-r--r--drivers/block/xen-blkback/common.h2
-rw-r--r--drivers/block/xen-blkback/xenbus.c6
-rw-r--r--drivers/mmc/card/block.c3
-rw-r--r--fs/ext3/inode.c4
-rw-r--r--fs/ext3/namei.c3
-rw-r--r--fs/ext4/inode.c4
-rw-r--r--fs/ext4/namei.c3
-rw-r--r--fs/gfs2/log.c4
-rw-r--r--fs/gfs2/meta_io.c6
-rw-r--r--fs/gfs2/ops_fstype.c2
-rw-r--r--fs/gfs2/quota.c2
-rw-r--r--include/linux/blk_types.h6
-rw-r--r--include/linux/blkdev.h1
-rw-r--r--include/linux/fs.h2
-rw-r--r--mm/backing-dev.c30
21 files changed, 92 insertions, 78 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index bcaf16ee6ad1..b596e54ddd71 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -785,10 +785,10 @@ static int blkio_policy_parse_and_set(char *buf,
785{ 785{
786 char *s[4], *p, *major_s = NULL, *minor_s = NULL; 786 char *s[4], *p, *major_s = NULL, *minor_s = NULL;
787 int ret; 787 int ret;
788 unsigned long major, minor, temp; 788 unsigned long major, minor;
789 int i = 0; 789 int i = 0;
790 dev_t dev; 790 dev_t dev;
791 u64 bps, iops; 791 u64 temp;
792 792
793 memset(s, 0, sizeof(s)); 793 memset(s, 0, sizeof(s));
794 794
@@ -826,20 +826,23 @@ static int blkio_policy_parse_and_set(char *buf,
826 826
827 dev = MKDEV(major, minor); 827 dev = MKDEV(major, minor);
828 828
829 ret = blkio_check_dev_num(dev); 829 ret = strict_strtoull(s[1], 10, &temp);
830 if (ret) 830 if (ret)
831 return ret; 831 return -EINVAL;
832 832
833 newpn->dev = dev; 833 /* For rule removal, do not check for device presence. */
834 if (temp) {
835 ret = blkio_check_dev_num(dev);
836 if (ret)
837 return ret;
838 }
834 839
835 if (s[1] == NULL) 840 newpn->dev = dev;
836 return -EINVAL;
837 841
838 switch (plid) { 842 switch (plid) {
839 case BLKIO_POLICY_PROP: 843 case BLKIO_POLICY_PROP:
840 ret = strict_strtoul(s[1], 10, &temp); 844 if ((temp < BLKIO_WEIGHT_MIN && temp > 0) ||
841 if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) || 845 temp > BLKIO_WEIGHT_MAX)
842 temp > BLKIO_WEIGHT_MAX)
843 return -EINVAL; 846 return -EINVAL;
844 847
845 newpn->plid = plid; 848 newpn->plid = plid;
@@ -850,26 +853,18 @@ static int blkio_policy_parse_and_set(char *buf,
850 switch(fileid) { 853 switch(fileid) {
851 case BLKIO_THROTL_read_bps_device: 854 case BLKIO_THROTL_read_bps_device:
852 case BLKIO_THROTL_write_bps_device: 855 case BLKIO_THROTL_write_bps_device:
853 ret = strict_strtoull(s[1], 10, &bps);
854 if (ret)
855 return -EINVAL;
856
857 newpn->plid = plid; 856 newpn->plid = plid;
858 newpn->fileid = fileid; 857 newpn->fileid = fileid;
859 newpn->val.bps = bps; 858 newpn->val.bps = temp;
860 break; 859 break;
861 case BLKIO_THROTL_read_iops_device: 860 case BLKIO_THROTL_read_iops_device:
862 case BLKIO_THROTL_write_iops_device: 861 case BLKIO_THROTL_write_iops_device:
863 ret = strict_strtoull(s[1], 10, &iops); 862 if (temp > THROTL_IOPS_MAX)
864 if (ret)
865 return -EINVAL;
866
867 if (iops > THROTL_IOPS_MAX)
868 return -EINVAL; 863 return -EINVAL;
869 864
870 newpn->plid = plid; 865 newpn->plid = plid;
871 newpn->fileid = fileid; 866 newpn->fileid = fileid;
872 newpn->val.iops = (unsigned int)iops; 867 newpn->val.iops = (unsigned int)temp;
873 break; 868 break;
874 } 869 }
875 break; 870 break;
diff --git a/block/blk-core.c b/block/blk-core.c
index 90e1ffdeb415..b2ed78afd9f0 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1167,7 +1167,7 @@ static bool bio_attempt_front_merge(struct request_queue *q,
1167 * true if merge was successful, otherwise false. 1167 * true if merge was successful, otherwise false.
1168 */ 1168 */
1169static bool attempt_plug_merge(struct task_struct *tsk, struct request_queue *q, 1169static bool attempt_plug_merge(struct task_struct *tsk, struct request_queue *q,
1170 struct bio *bio) 1170 struct bio *bio, unsigned int *request_count)
1171{ 1171{
1172 struct blk_plug *plug; 1172 struct blk_plug *plug;
1173 struct request *rq; 1173 struct request *rq;
@@ -1176,10 +1176,13 @@ static bool attempt_plug_merge(struct task_struct *tsk, struct request_queue *q,
1176 plug = tsk->plug; 1176 plug = tsk->plug;
1177 if (!plug) 1177 if (!plug)
1178 goto out; 1178 goto out;
1179 *request_count = 0;
1179 1180
1180 list_for_each_entry_reverse(rq, &plug->list, queuelist) { 1181 list_for_each_entry_reverse(rq, &plug->list, queuelist) {
1181 int el_ret; 1182 int el_ret;
1182 1183
1184 (*request_count)++;
1185
1183 if (rq->q != q) 1186 if (rq->q != q)
1184 continue; 1187 continue;
1185 1188
@@ -1219,6 +1222,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)
1219 struct blk_plug *plug; 1222 struct blk_plug *plug;
1220 int el_ret, rw_flags, where = ELEVATOR_INSERT_SORT; 1223 int el_ret, rw_flags, where = ELEVATOR_INSERT_SORT;
1221 struct request *req; 1224 struct request *req;
1225 unsigned int request_count = 0;
1222 1226
1223 /* 1227 /*
1224 * low level driver can indicate that it wants pages above a 1228 * low level driver can indicate that it wants pages above a
@@ -1237,7 +1241,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)
1237 * Check if we can merge with the plugged list before grabbing 1241 * Check if we can merge with the plugged list before grabbing
1238 * any locks. 1242 * any locks.
1239 */ 1243 */
1240 if (attempt_plug_merge(current, q, bio)) 1244 if (attempt_plug_merge(current, q, bio, &request_count))
1241 goto out; 1245 goto out;
1242 1246
1243 spin_lock_irq(q->queue_lock); 1247 spin_lock_irq(q->queue_lock);
@@ -1302,11 +1306,10 @@ get_rq:
1302 if (__rq->q != q) 1306 if (__rq->q != q)
1303 plug->should_sort = 1; 1307 plug->should_sort = 1;
1304 } 1308 }
1309 if (request_count >= BLK_MAX_REQUEST_COUNT)
1310 blk_flush_plug_list(plug, false);
1305 list_add_tail(&req->queuelist, &plug->list); 1311 list_add_tail(&req->queuelist, &plug->list);
1306 plug->count++;
1307 drive_stat_acct(req, 1); 1312 drive_stat_acct(req, 1);
1308 if (plug->count >= BLK_MAX_REQUEST_COUNT)
1309 blk_flush_plug_list(plug, false);
1310 } else { 1313 } else {
1311 spin_lock_irq(q->queue_lock); 1314 spin_lock_irq(q->queue_lock);
1312 add_acct_request(q, req, where); 1315 add_acct_request(q, req, where);
@@ -2634,7 +2637,6 @@ void blk_start_plug(struct blk_plug *plug)
2634 INIT_LIST_HEAD(&plug->list); 2637 INIT_LIST_HEAD(&plug->list);
2635 INIT_LIST_HEAD(&plug->cb_list); 2638 INIT_LIST_HEAD(&plug->cb_list);
2636 plug->should_sort = 0; 2639 plug->should_sort = 0;
2637 plug->count = 0;
2638 2640
2639 /* 2641 /*
2640 * If this is a nested plug, don't actually assign it. It will be 2642 * If this is a nested plug, don't actually assign it. It will be
@@ -2718,7 +2720,6 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
2718 return; 2720 return;
2719 2721
2720 list_splice_init(&plug->list, &list); 2722 list_splice_init(&plug->list, &list);
2721 plug->count = 0;
2722 2723
2723 if (plug->should_sort) { 2724 if (plug->should_sort) {
2724 list_sort(NULL, &list, plug_rq_cmp); 2725 list_sort(NULL, &list, plug_rq_cmp);
diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index 58340d0cb23a..1366a89d8e66 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -115,7 +115,7 @@ void __blk_complete_request(struct request *req)
115 /* 115 /*
116 * Select completion CPU 116 * Select completion CPU
117 */ 117 */
118 if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) && req->cpu != -1) { 118 if (req->cpu != -1) {
119 ccpu = req->cpu; 119 ccpu = req->cpu;
120 if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags)) { 120 if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags)) {
121 ccpu = blk_cpu_to_group(ccpu); 121 ccpu = blk_cpu_to_group(ccpu);
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 0ee17b5e7fb6..e681805cdb47 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -258,11 +258,13 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
258 258
259 ret = queue_var_store(&val, page, count); 259 ret = queue_var_store(&val, page, count);
260 spin_lock_irq(q->queue_lock); 260 spin_lock_irq(q->queue_lock);
261 if (val) { 261 if (val == 2) {
262 queue_flag_set(QUEUE_FLAG_SAME_COMP, q); 262 queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
263 if (val == 2) 263 queue_flag_set(QUEUE_FLAG_SAME_FORCE, q);
264 queue_flag_set(QUEUE_FLAG_SAME_FORCE, q); 264 } else if (val == 1) {
265 } else { 265 queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
266 queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
267 } else if (val == 0) {
266 queue_flag_clear(QUEUE_FLAG_SAME_COMP, q); 268 queue_flag_clear(QUEUE_FLAG_SAME_COMP, q);
267 queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q); 269 queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
268 } 270 }
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index a33bd4377c61..16ace89613bc 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -130,8 +130,8 @@ struct cfq_queue {
130 unsigned long slice_end; 130 unsigned long slice_end;
131 long slice_resid; 131 long slice_resid;
132 132
133 /* pending metadata requests */ 133 /* pending priority requests */
134 int meta_pending; 134 int prio_pending;
135 /* number of requests that are on the dispatch list or inside driver */ 135 /* number of requests that are on the dispatch list or inside driver */
136 int dispatched; 136 int dispatched;
137 137
@@ -684,8 +684,8 @@ cfq_choose_req(struct cfq_data *cfqd, struct request *rq1, struct request *rq2,
684 if (rq_is_sync(rq1) != rq_is_sync(rq2)) 684 if (rq_is_sync(rq1) != rq_is_sync(rq2))
685 return rq_is_sync(rq1) ? rq1 : rq2; 685 return rq_is_sync(rq1) ? rq1 : rq2;
686 686
687 if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_META) 687 if ((rq1->cmd_flags ^ rq2->cmd_flags) & REQ_PRIO)
688 return rq1->cmd_flags & REQ_META ? rq1 : rq2; 688 return rq1->cmd_flags & REQ_PRIO ? rq1 : rq2;
689 689
690 s1 = blk_rq_pos(rq1); 690 s1 = blk_rq_pos(rq1);
691 s2 = blk_rq_pos(rq2); 691 s2 = blk_rq_pos(rq2);
@@ -1612,9 +1612,9 @@ static void cfq_remove_request(struct request *rq)
1612 cfqq->cfqd->rq_queued--; 1612 cfqq->cfqd->rq_queued--;
1613 cfq_blkiocg_update_io_remove_stats(&(RQ_CFQG(rq))->blkg, 1613 cfq_blkiocg_update_io_remove_stats(&(RQ_CFQG(rq))->blkg,
1614 rq_data_dir(rq), rq_is_sync(rq)); 1614 rq_data_dir(rq), rq_is_sync(rq));
1615 if (rq->cmd_flags & REQ_META) { 1615 if (rq->cmd_flags & REQ_PRIO) {
1616 WARN_ON(!cfqq->meta_pending); 1616 WARN_ON(!cfqq->prio_pending);
1617 cfqq->meta_pending--; 1617 cfqq->prio_pending--;
1618 } 1618 }
1619} 1619}
1620 1620
@@ -3372,7 +3372,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
3372 * So both queues are sync. Let the new request get disk time if 3372 * So both queues are sync. Let the new request get disk time if
3373 * it's a metadata request and the current queue is doing regular IO. 3373 * it's a metadata request and the current queue is doing regular IO.
3374 */ 3374 */
3375 if ((rq->cmd_flags & REQ_META) && !cfqq->meta_pending) 3375 if ((rq->cmd_flags & REQ_PRIO) && !cfqq->prio_pending)
3376 return true; 3376 return true;
3377 3377
3378 /* 3378 /*
@@ -3439,8 +3439,8 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
3439 struct cfq_io_context *cic = RQ_CIC(rq); 3439 struct cfq_io_context *cic = RQ_CIC(rq);
3440 3440
3441 cfqd->rq_queued++; 3441 cfqd->rq_queued++;
3442 if (rq->cmd_flags & REQ_META) 3442 if (rq->cmd_flags & REQ_PRIO)
3443 cfqq->meta_pending++; 3443 cfqq->prio_pending++;
3444 3444
3445 cfq_update_io_thinktime(cfqd, cfqq, cic); 3445 cfq_update_io_thinktime(cfqd, cfqq, cic);
3446 cfq_update_io_seektime(cfqd, cfqq, rq); 3446 cfq_update_io_seektime(cfqd, cfqq, rq);
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 98de8f418676..9955a53733b2 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4250,7 +4250,7 @@ static int __init floppy_init(void)
4250 use_virtual_dma = can_use_virtual_dma & 1; 4250 use_virtual_dma = can_use_virtual_dma & 1;
4251 fdc_state[0].address = FDC1; 4251 fdc_state[0].address = FDC1;
4252 if (fdc_state[0].address == -1) { 4252 if (fdc_state[0].address == -1) {
4253 del_timer(&fd_timeout); 4253 del_timer_sync(&fd_timeout);
4254 err = -ENODEV; 4254 err = -ENODEV;
4255 goto out_unreg_region; 4255 goto out_unreg_region;
4256 } 4256 }
@@ -4261,7 +4261,7 @@ static int __init floppy_init(void)
4261 fdc = 0; /* reset fdc in case of unexpected interrupt */ 4261 fdc = 0; /* reset fdc in case of unexpected interrupt */
4262 err = floppy_grab_irq_and_dma(); 4262 err = floppy_grab_irq_and_dma();
4263 if (err) { 4263 if (err) {
4264 del_timer(&fd_timeout); 4264 del_timer_sync(&fd_timeout);
4265 err = -EBUSY; 4265 err = -EBUSY;
4266 goto out_unreg_region; 4266 goto out_unreg_region;
4267 } 4267 }
@@ -4318,7 +4318,7 @@ static int __init floppy_init(void)
4318 user_reset_fdc(-1, FD_RESET_ALWAYS, false); 4318 user_reset_fdc(-1, FD_RESET_ALWAYS, false);
4319 } 4319 }
4320 fdc = 0; 4320 fdc = 0;
4321 del_timer(&fd_timeout); 4321 del_timer_sync(&fd_timeout);
4322 current_drive = 0; 4322 current_drive = 0;
4323 initialized = true; 4323 initialized = true;
4324 if (have_no_fdc) { 4324 if (have_no_fdc) {
@@ -4368,7 +4368,7 @@ out_unreg_blkdev:
4368 unregister_blkdev(FLOPPY_MAJOR, "fd"); 4368 unregister_blkdev(FLOPPY_MAJOR, "fd");
4369out_put_disk: 4369out_put_disk:
4370 while (dr--) { 4370 while (dr--) {
4371 del_timer(&motor_off_timer[dr]); 4371 del_timer_sync(&motor_off_timer[dr]);
4372 if (disks[dr]->queue) 4372 if (disks[dr]->queue)
4373 blk_cleanup_queue(disks[dr]->queue); 4373 blk_cleanup_queue(disks[dr]->queue);
4374 put_disk(disks[dr]); 4374 put_disk(disks[dr]);
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 9e40b283a468..00c57c90e2d6 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -46,7 +46,7 @@
46 46
47#define DRV_PFX "xen-blkback:" 47#define DRV_PFX "xen-blkback:"
48#define DPRINTK(fmt, args...) \ 48#define DPRINTK(fmt, args...) \
49 pr_debug(DRV_PFX "(%s:%d) " fmt ".\n", \ 49 pr_debug(DRV_PFX "(%s:%d) " fmt ".\n", \
50 __func__, __LINE__, ##args) 50 __func__, __LINE__, ##args)
51 51
52 52
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 3f129b45451a..5fd2010f7d2b 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -590,7 +590,7 @@ static void frontend_changed(struct xenbus_device *dev,
590 590
591 /* 591 /*
592 * Enforce precondition before potential leak point. 592 * Enforce precondition before potential leak point.
593 * blkif_disconnect() is idempotent. 593 * xen_blkif_disconnect() is idempotent.
594 */ 594 */
595 xen_blkif_disconnect(be->blkif); 595 xen_blkif_disconnect(be->blkif);
596 596
@@ -601,17 +601,17 @@ static void frontend_changed(struct xenbus_device *dev,
601 break; 601 break;
602 602
603 case XenbusStateClosing: 603 case XenbusStateClosing:
604 xen_blkif_disconnect(be->blkif);
605 xenbus_switch_state(dev, XenbusStateClosing); 604 xenbus_switch_state(dev, XenbusStateClosing);
606 break; 605 break;
607 606
608 case XenbusStateClosed: 607 case XenbusStateClosed:
608 xen_blkif_disconnect(be->blkif);
609 xenbus_switch_state(dev, XenbusStateClosed); 609 xenbus_switch_state(dev, XenbusStateClosed);
610 if (xenbus_dev_is_online(dev)) 610 if (xenbus_dev_is_online(dev))
611 break; 611 break;
612 /* fall through if not online */ 612 /* fall through if not online */
613 case XenbusStateUnknown: 613 case XenbusStateUnknown:
614 /* implies blkif_disconnect() via blkback_remove() */ 614 /* implies xen_blkif_disconnect() via xen_blkbk_remove() */
615 device_unregister(&dev->dev); 615 device_unregister(&dev->dev);
616 break; 616 break;
617 617
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1ff5486213fb..4c1a648d00fc 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -926,6 +926,9 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
926 /* 926 /*
927 * Reliable writes are used to implement Forced Unit Access and 927 * Reliable writes are used to implement Forced Unit Access and
928 * REQ_META accesses, and are supported only on MMCs. 928 * REQ_META accesses, and are supported only on MMCs.
929 *
930 * XXX: this really needs a good explanation of why REQ_META
931 * is treated special.
929 */ 932 */
930 bool do_rel_wr = ((req->cmd_flags & REQ_FUA) || 933 bool do_rel_wr = ((req->cmd_flags & REQ_FUA) ||
931 (req->cmd_flags & REQ_META)) && 934 (req->cmd_flags & REQ_META)) &&
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 04da6acde85d..12661e1deedd 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1134,7 +1134,7 @@ struct buffer_head *ext3_bread(handle_t *handle, struct inode *inode,
1134 return bh; 1134 return bh;
1135 if (buffer_uptodate(bh)) 1135 if (buffer_uptodate(bh))
1136 return bh; 1136 return bh;
1137 ll_rw_block(READ_META, 1, &bh); 1137 ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
1138 wait_on_buffer(bh); 1138 wait_on_buffer(bh);
1139 if (buffer_uptodate(bh)) 1139 if (buffer_uptodate(bh))
1140 return bh; 1140 return bh;
@@ -2807,7 +2807,7 @@ make_io:
2807 trace_ext3_load_inode(inode); 2807 trace_ext3_load_inode(inode);
2808 get_bh(bh); 2808 get_bh(bh);
2809 bh->b_end_io = end_buffer_read_sync; 2809 bh->b_end_io = end_buffer_read_sync;
2810 submit_bh(READ_META, bh); 2810 submit_bh(READ | REQ_META | REQ_PRIO, bh);
2811 wait_on_buffer(bh); 2811 wait_on_buffer(bh);
2812 if (!buffer_uptodate(bh)) { 2812 if (!buffer_uptodate(bh)) {
2813 ext3_error(inode->i_sb, "ext3_get_inode_loc", 2813 ext3_error(inode->i_sb, "ext3_get_inode_loc",
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 5571708b6a58..0629e09f6511 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -922,7 +922,8 @@ restart:
922 bh = ext3_getblk(NULL, dir, b++, 0, &err); 922 bh = ext3_getblk(NULL, dir, b++, 0, &err);
923 bh_use[ra_max] = bh; 923 bh_use[ra_max] = bh;
924 if (bh) 924 if (bh)
925 ll_rw_block(READ_META, 1, &bh); 925 ll_rw_block(READ | REQ_META | REQ_PRIO,
926 1, &bh);
926 } 927 }
927 } 928 }
928 if ((bh = bh_use[ra_ptr++]) == NULL) 929 if ((bh = bh_use[ra_ptr++]) == NULL)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 18d2558b7624..986e2388f031 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -647,7 +647,7 @@ struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
647 return bh; 647 return bh;
648 if (buffer_uptodate(bh)) 648 if (buffer_uptodate(bh))
649 return bh; 649 return bh;
650 ll_rw_block(READ_META, 1, &bh); 650 ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
651 wait_on_buffer(bh); 651 wait_on_buffer(bh);
652 if (buffer_uptodate(bh)) 652 if (buffer_uptodate(bh))
653 return bh; 653 return bh;
@@ -3298,7 +3298,7 @@ make_io:
3298 trace_ext4_load_inode(inode); 3298 trace_ext4_load_inode(inode);
3299 get_bh(bh); 3299 get_bh(bh);
3300 bh->b_end_io = end_buffer_read_sync; 3300 bh->b_end_io = end_buffer_read_sync;
3301 submit_bh(READ_META, bh); 3301 submit_bh(READ | REQ_META | REQ_PRIO, bh);
3302 wait_on_buffer(bh); 3302 wait_on_buffer(bh);
3303 if (!buffer_uptodate(bh)) { 3303 if (!buffer_uptodate(bh)) {
3304 EXT4_ERROR_INODE_BLOCK(inode, block, 3304 EXT4_ERROR_INODE_BLOCK(inode, block,
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index f8068c7bae9f..1c924faeb6c8 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -922,7 +922,8 @@ restart:
922 bh = ext4_getblk(NULL, dir, b++, 0, &err); 922 bh = ext4_getblk(NULL, dir, b++, 0, &err);
923 bh_use[ra_max] = bh; 923 bh_use[ra_max] = bh;
924 if (bh) 924 if (bh)
925 ll_rw_block(READ_META, 1, &bh); 925 ll_rw_block(READ | REQ_META | REQ_PRIO,
926 1, &bh);
926 } 927 }
927 } 928 }
928 if ((bh = bh_use[ra_ptr++]) == NULL) 929 if ((bh = bh_use[ra_ptr++]) == NULL)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 85c62923ee29..598646434362 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -624,9 +624,9 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull)
624 bh->b_end_io = end_buffer_write_sync; 624 bh->b_end_io = end_buffer_write_sync;
625 get_bh(bh); 625 get_bh(bh);
626 if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) 626 if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags))
627 submit_bh(WRITE_SYNC | REQ_META, bh); 627 submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh);
628 else 628 else
629 submit_bh(WRITE_FLUSH_FUA | REQ_META, bh); 629 submit_bh(WRITE_FLUSH_FUA | REQ_META | REQ_PRIO, bh);
630 wait_on_buffer(bh); 630 wait_on_buffer(bh);
631 631
632 if (!buffer_uptodate(bh)) 632 if (!buffer_uptodate(bh))
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 747238cd9f96..be29858900f6 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -37,7 +37,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
37{ 37{
38 struct buffer_head *bh, *head; 38 struct buffer_head *bh, *head;
39 int nr_underway = 0; 39 int nr_underway = 0;
40 int write_op = REQ_META | 40 int write_op = REQ_META | REQ_PRIO |
41 (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); 41 (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
42 42
43 BUG_ON(!PageLocked(page)); 43 BUG_ON(!PageLocked(page));
@@ -225,7 +225,7 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
225 } 225 }
226 bh->b_end_io = end_buffer_read_sync; 226 bh->b_end_io = end_buffer_read_sync;
227 get_bh(bh); 227 get_bh(bh);
228 submit_bh(READ_SYNC | REQ_META, bh); 228 submit_bh(READ_SYNC | REQ_META | REQ_PRIO, bh);
229 if (!(flags & DIO_WAIT)) 229 if (!(flags & DIO_WAIT))
230 return 0; 230 return 0;
231 231
@@ -435,7 +435,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
435 if (buffer_uptodate(first_bh)) 435 if (buffer_uptodate(first_bh))
436 goto out; 436 goto out;
437 if (!buffer_locked(first_bh)) 437 if (!buffer_locked(first_bh))
438 ll_rw_block(READ_SYNC | REQ_META, 1, &first_bh); 438 ll_rw_block(READ_SYNC | REQ_META | REQ_PRIO, 1, &first_bh);
439 439
440 dblock++; 440 dblock++;
441 extlen--; 441 extlen--;
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 3bc073a4cf82..079587e53849 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -224,7 +224,7 @@ static int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector, int silent)
224 224
225 bio->bi_end_io = end_bio_io_page; 225 bio->bi_end_io = end_bio_io_page;
226 bio->bi_private = page; 226 bio->bi_private = page;
227 submit_bio(READ_SYNC | REQ_META, bio); 227 submit_bio(READ_SYNC | REQ_META | REQ_PRIO, bio);
228 wait_on_page_locked(page); 228 wait_on_page_locked(page);
229 bio_put(bio); 229 bio_put(bio);
230 if (!PageUptodate(page)) { 230 if (!PageUptodate(page)) {
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 42e8d23bc047..0e8bb13381e4 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -709,7 +709,7 @@ get_a_page:
709 set_buffer_uptodate(bh); 709 set_buffer_uptodate(bh);
710 710
711 if (!buffer_uptodate(bh)) { 711 if (!buffer_uptodate(bh)) {
712 ll_rw_block(READ_META, 1, &bh); 712 ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &bh);
713 wait_on_buffer(bh); 713 wait_on_buffer(bh);
714 if (!buffer_uptodate(bh)) 714 if (!buffer_uptodate(bh))
715 goto unlock_out; 715 goto unlock_out;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 32f0076e844b..71fc53bb8f1c 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -124,6 +124,7 @@ enum rq_flag_bits {
124 124
125 __REQ_SYNC, /* request is sync (sync write or read) */ 125 __REQ_SYNC, /* request is sync (sync write or read) */
126 __REQ_META, /* metadata io request */ 126 __REQ_META, /* metadata io request */
127 __REQ_PRIO, /* boost priority in cfq */
127 __REQ_DISCARD, /* request to discard sectors */ 128 __REQ_DISCARD, /* request to discard sectors */
128 __REQ_SECURE, /* secure discard (used with __REQ_DISCARD) */ 129 __REQ_SECURE, /* secure discard (used with __REQ_DISCARD) */
129 130
@@ -161,14 +162,15 @@ enum rq_flag_bits {
161#define REQ_FAILFAST_DRIVER (1 << __REQ_FAILFAST_DRIVER) 162#define REQ_FAILFAST_DRIVER (1 << __REQ_FAILFAST_DRIVER)
162#define REQ_SYNC (1 << __REQ_SYNC) 163#define REQ_SYNC (1 << __REQ_SYNC)
163#define REQ_META (1 << __REQ_META) 164#define REQ_META (1 << __REQ_META)
165#define REQ_PRIO (1 << __REQ_PRIO)
164#define REQ_DISCARD (1 << __REQ_DISCARD) 166#define REQ_DISCARD (1 << __REQ_DISCARD)
165#define REQ_NOIDLE (1 << __REQ_NOIDLE) 167#define REQ_NOIDLE (1 << __REQ_NOIDLE)
166 168
167#define REQ_FAILFAST_MASK \ 169#define REQ_FAILFAST_MASK \
168 (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) 170 (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
169#define REQ_COMMON_MASK \ 171#define REQ_COMMON_MASK \
170 (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \ 172 (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | \
171 REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE) 173 REQ_DISCARD | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
172#define REQ_CLONE_MASK REQ_COMMON_MASK 174#define REQ_CLONE_MASK REQ_COMMON_MASK
173 175
174#define REQ_RAHEAD (1 << __REQ_RAHEAD) 176#define REQ_RAHEAD (1 << __REQ_RAHEAD)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 84b15d54f8c2..7fbaa9103344 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -873,7 +873,6 @@ struct blk_plug {
873 struct list_head list; 873 struct list_head list;
874 struct list_head cb_list; 874 struct list_head cb_list;
875 unsigned int should_sort; 875 unsigned int should_sort;
876 unsigned int count;
877}; 876};
878#define BLK_MAX_REQUEST_COUNT 16 877#define BLK_MAX_REQUEST_COUNT 16
879 878
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c2bd68f2277a..277f497923a2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -162,10 +162,8 @@ struct inodes_stat_t {
162#define READA RWA_MASK 162#define READA RWA_MASK
163 163
164#define READ_SYNC (READ | REQ_SYNC) 164#define READ_SYNC (READ | REQ_SYNC)
165#define READ_META (READ | REQ_META)
166#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE) 165#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE)
167#define WRITE_ODIRECT (WRITE | REQ_SYNC) 166#define WRITE_ODIRECT (WRITE | REQ_SYNC)
168#define WRITE_META (WRITE | REQ_META)
169#define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH) 167#define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH)
170#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA) 168#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
171#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA) 169#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index d6edf8d14f9c..a87da524a4a0 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -359,6 +359,17 @@ static unsigned long bdi_longest_inactive(void)
359 return max(5UL * 60 * HZ, interval); 359 return max(5UL * 60 * HZ, interval);
360} 360}
361 361
362/*
363 * Clear pending bit and wakeup anybody waiting for flusher thread creation or
364 * shutdown
365 */
366static void bdi_clear_pending(struct backing_dev_info *bdi)
367{
368 clear_bit(BDI_pending, &bdi->state);
369 smp_mb__after_clear_bit();
370 wake_up_bit(&bdi->state, BDI_pending);
371}
372
362static int bdi_forker_thread(void *ptr) 373static int bdi_forker_thread(void *ptr)
363{ 374{
364 struct bdi_writeback *me = ptr; 375 struct bdi_writeback *me = ptr;
@@ -390,6 +401,13 @@ static int bdi_forker_thread(void *ptr)
390 } 401 }
391 402
392 spin_lock_bh(&bdi_lock); 403 spin_lock_bh(&bdi_lock);
404 /*
405 * In the following loop we are going to check whether we have
406 * some work to do without any synchronization with tasks
407 * waking us up to do work for them. So we have to set task
408 * state already here so that we don't miss wakeups coming
409 * after we verify some condition.
410 */
393 set_current_state(TASK_INTERRUPTIBLE); 411 set_current_state(TASK_INTERRUPTIBLE);
394 412
395 list_for_each_entry(bdi, &bdi_list, bdi_list) { 413 list_for_each_entry(bdi, &bdi_list, bdi_list) {
@@ -469,11 +487,13 @@ static int bdi_forker_thread(void *ptr)
469 spin_unlock_bh(&bdi->wb_lock); 487 spin_unlock_bh(&bdi->wb_lock);
470 wake_up_process(task); 488 wake_up_process(task);
471 } 489 }
490 bdi_clear_pending(bdi);
472 break; 491 break;
473 492
474 case KILL_THREAD: 493 case KILL_THREAD:
475 __set_current_state(TASK_RUNNING); 494 __set_current_state(TASK_RUNNING);
476 kthread_stop(task); 495 kthread_stop(task);
496 bdi_clear_pending(bdi);
477 break; 497 break;
478 498
479 case NO_ACTION: 499 case NO_ACTION:
@@ -489,16 +509,8 @@ static int bdi_forker_thread(void *ptr)
489 else 509 else
490 schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10)); 510 schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10));
491 try_to_freeze(); 511 try_to_freeze();
492 /* Back to the main loop */ 512 break;
493 continue;
494 } 513 }
495
496 /*
497 * Clear pending bit and wakeup anybody waiting to tear us down.
498 */
499 clear_bit(BDI_pending, &bdi->state);
500 smp_mb__after_clear_bit();
501 wake_up_bit(&bdi->state, BDI_pending);
502 } 514 }
503 515
504 return 0; 516 return 0;