History

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

Pull block layer fixes from Jens Axboe: "Outside of bcache (which really isn't super big), these are all few-liners. There are a few important fixes in here: - Fix blk pm sleeping when holding the queue lock - A small collection of bcache fixes that have been done and tested since bcache was included in this merge window. - A fix for a raid5 regression introduced with the bio changes. - Two important fixes for mtip32xx, fixing an oops and potential data corruption (or hang) due to wrong bio iteration on stacked devices." * 'for-linus' of git://git.kernel.dk/linux-block: scatterlist: sg_set_buf() argument must be in linear mapping raid5: Initialize bi_vcnt pktcdvd: silence static checker warning block: remove refs to XD disks from documentation blkpm: avoid sleep when holding queue lock mtip32xx: Correctly handle bio->bi_idx != 0 conditions mtip32xx: Fix NULL pointer dereference during module unload bcache: Fix error handling in init code bcache: clarify free/available/unused space bcache: drop "select CLOSURES" bcache: Fix incompatible pointer type warning

Linus Torvalds committed 13 years ago

Commit b2cc9c12 parents a568fa1 ac4e97a14 files · +124 −143Browse files

Unified · Split

14 files
  1. Documentation/bcache.txt +9 −3
  2. Documentation/devices.txt +2 −6
  3. Documentation/kernel-parameters.txt +0 −3
  4. Documentation/m68k/kernel-options.txt +0 −2
  5. block/blk-core.c +1 −1
  6. drivers/block/mtip32xx/mtip32xx.c +5 −3
  7. drivers/block/pktcdvd.c +2 −1
  8. drivers/md/bcache/Kconfig +0 −1
  9. drivers/md/bcache/bcache.h +1 −1
  10. drivers/md/bcache/stats.c +16 −18
  11. drivers/md/bcache/super.c +82 −103
  12. drivers/md/bcache/writeback.c +1 −1
  13. drivers/md/raid5.c +2 −0
  14. include/linux/scatterlist.h +3 −0
Documentation/bcache.txt+9−3
@@ -319,7 +319,10 @@ cache<0..n> · 318 unmodified lines
319319 Symlink to each of the cache devices comprising this cache set.
320320
321321 cache_available_percent
322− Percentage of cache device free.
322+ Percentage of cache device which doesn't contain dirty data, and could
323+ potentially be used for writeback. This doesn't mean this space isn't used
324+ for clean cached data; the unused statistic (in priority_stats) is typically
325+ much lower.
323326
324327 clear_stats
325328 Clears the statistics associated with this cache
@@ -423,8 +426,11 @@ nbuckets · 97 unmodified lines
423426 Total buckets in this cache
424427
425428 priority_stats
426− Statistics about how recently data in the cache has been accessed. This can
427− reveal your working set size.
429+ Statistics about how recently data in the cache has been accessed.
430+ This can reveal your working set size. Unused is the percentage of
431+ the cache that doesn't contain any data. Metadata is bcache's
432+ metadata overhead. Average is the average priority of cache buckets.
433+ Next is a list of quantiles with the priority threshold of each.
428434
429435 written
430436 Sum of all data that has been written to the cache; comparison with
Documentation/devices.txt+2−6
@@ -498,12 +498,8 @@ Your cooperation is appreciated. · 497 unmodified lines
498498
499499 Each device type has 5 bits (32 minors).
500500
501− 13 block 8-bit MFM/RLL/IDE controller
502− 0 = /dev/xda First XT disk whole disk
503− 64 = /dev/xdb Second XT disk whole disk
504−
505− Partitions are handled in the same way as IDE disks
506− (see major number 3).
501+ 13 block Previously used for the XT disk (/dev/xdN)
502+ Deleted in kernel v3.9.
507503
508504 14 char Open Sound System (OSS)
509505 0 = /dev/mixer Mixer control
Documentation/kernel-parameters.txt+0−3
@@ -3351,9 +3351,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted. · 3350 unmodified lines
33513351 plus one apbt timer for broadcast timer.
33523352 x86_mrst_timer=apbt_only | lapic_and_apbt
33533353
3354− xd= [HW,XT] Original XT pre-IDE (RLL encoded) disks.
3355− xd_geo= See header of drivers/block/xd.c.
3356−
33573354 xen_emul_unplug= [HW,X86,XEN]
33583355 Unplug Xen emulated devices
33593356 Format: [unplug0,][unplug1]
Documentation/m68k/kernel-options.txt+0−2
@@ -80,8 +80,6 @@ Valid names are: · 79 unmodified lines
8080 /dev/sdd: -> 0x0830 (forth SCSI disk)
8181 /dev/sde: -> 0x0840 (fifth SCSI disk)
8282 /dev/fd : -> 0x0200 (floppy disk)
83− /dev/xda: -> 0x0c00 (first XT disk, unused in Linux/m68k)
84− /dev/xdb: -> 0x0c40 (second XT disk, unused in Linux/m68k)
8583
8684 The name must be followed by a decimal number, that stands for the
8785 partition number. Internally, the value of the number is just
block/blk-core.c+1−1
@@ -3164,7 +3164,7 @@ void blk_post_runtime_resume(struct request_queue *q, int err) · 3163 unmodified lines
31643164 q->rpm_status = RPM_ACTIVE;
31653165 __blk_run_queue(q);
31663166 pm_runtime_mark_last_busy(q->dev);
3167− pm_runtime_autosuspend(q->dev);
3167+ pm_request_autosuspend(q->dev);
31683168 } else {
31693169 q->rpm_status = RPM_SUSPENDED;
31703170 }
drivers/block/mtip32xx/mtip32xx.c+5−3
@@ -3002,7 +3002,8 @@ static int mtip_hw_debugfs_init(struct driver_data *dd) · 3001 unmodified lines
30023002
30033003 static void mtip_hw_debugfs_exit(struct driver_data *dd)
30043004 {
3005− debugfs_remove_recursive(dd->dfs_node);
3005+ if (dd->dfs_node)
3006+ debugfs_remove_recursive(dd->dfs_node);
30063007 }
30073008
30083009
@@ -3863,7 +3864,7 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio) · 854 unmodified lines
38633864 struct driver_data *dd = queue->queuedata;
38643865 struct scatterlist *sg;
38653866 struct bio_vec *bvec;
3866− int nents = 0;
3867+ int i, nents = 0;
38673868 int tag = 0, unaligned = 0;
38683869
38693870 if (unlikely(dd->dd_flag & MTIP_DDF_STOP_IO)) {
@@ -3921,11 +3922,12 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio) · 51 unmodified lines
39213922 }
39223923
39233924 /* Create the scatter list for this bio. */
3924− bio_for_each_segment(bvec, bio, nents) {
3925+ bio_for_each_segment(bvec, bio, i) {
39253926 sg_set_page(&sg[nents],
39263927 bvec->bv_page,
39273928 bvec->bv_len,
39283929 bvec->bv_offset);
3930+ nents++;
39293931 }
39303932
39313933 /* Issue the read/write. */
drivers/block/pktcdvd.c+2−1
@@ -83,7 +83,8 @@ · 82 unmodified lines
8383
8484 #define MAX_SPEED 0xffff
8585
86−#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
86+#define ZONE(sector, pd) (((sector) + (pd)->offset) & \
87+ ~(sector_t)((pd)->settings.size - 1))
8788
8889 static DEFINE_MUTEX(pktcdvd_mutex);
8990 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
drivers/md/bcache/Kconfig+0−1
@@ -1,7 +1,6 @@
11
22 config BCACHE
33 tristate "Block device as cache"
4− select CLOSURES
54 ---help---
65 Allows a block device to be used as cache for other devices; uses
76 a btree for indexing and the layout is optimized for SSDs.
drivers/md/bcache/bcache.h+1−1
@@ -1241,7 +1241,7 @@ void bch_cache_set_stop(struct cache_set *); · 1240 unmodified lines
12411241 struct cache_set *bch_cache_set_alloc(struct cache_sb *);
12421242 void bch_btree_cache_free(struct cache_set *);
12431243 int bch_btree_cache_alloc(struct cache_set *);
1244−void bch_writeback_init_cached_dev(struct cached_dev *);
1244+void bch_cached_dev_writeback_init(struct cached_dev *);
12451245 void bch_moving_init_cache_set(struct cache_set *);
12461246
12471247 void bch_cache_allocator_exit(struct cache *ca);
drivers/md/bcache/stats.c+16−18
@@ -93,24 +93,6 @@ static struct attribute *bch_stats_files[] = { · 92 unmodified lines
9393 };
9494 static KTYPE(bch_stats);
9595
96−static void scale_accounting(unsigned long data);
97−
98−void bch_cache_accounting_init(struct cache_accounting *acc,
99− struct closure *parent)
100−{
101− kobject_init(&acc->total.kobj, &bch_stats_ktype);
102− kobject_init(&acc->five_minute.kobj, &bch_stats_ktype);
103− kobject_init(&acc->hour.kobj, &bch_stats_ktype);
104− kobject_init(&acc->day.kobj, &bch_stats_ktype);
105−
106− closure_init(&acc->cl, parent);
107− init_timer(&acc->timer);
108− acc->timer.expires = jiffies + accounting_delay;
109− acc->timer.data = (unsigned long) acc;
110− acc->timer.function = scale_accounting;
111− add_timer(&acc->timer);
112−}
113−
11496 int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
11597 struct kobject *parent)
11698 {
@@ -244,3 +226,19 @@ void bch_mark_sectors_bypassed(struct search *s, int sectors) · 127 unmodified lines
244226 atomic_add(sectors, &dc->accounting.collector.sectors_bypassed);
245227 atomic_add(sectors, &s->op.c->accounting.collector.sectors_bypassed);
246228 }
229+
230+void bch_cache_accounting_init(struct cache_accounting *acc,
231+ struct closure *parent)
232+{
233+ kobject_init(&acc->total.kobj, &bch_stats_ktype);
234+ kobject_init(&acc->five_minute.kobj, &bch_stats_ktype);
235+ kobject_init(&acc->hour.kobj, &bch_stats_ktype);
236+ kobject_init(&acc->day.kobj, &bch_stats_ktype);
237+
238+ closure_init(&acc->cl, parent);
239+ init_timer(&acc->timer);
240+ acc->timer.expires = jiffies + accounting_delay;
241+ acc->timer.data = (unsigned long) acc;
242+ acc->timer.function = scale_accounting;
243+ add_timer(&acc->timer);
244+}
drivers/md/bcache/super.c+82−103
@@ -634,11 +634,10 @@ static int open_dev(struct block_device *b, fmode_t mode) · 633 unmodified lines
634634 return 0;
635635 }
636636
637−static int release_dev(struct gendisk *b, fmode_t mode)
637+static void release_dev(struct gendisk *b, fmode_t mode)
638638 {
639639 struct bcache_device *d = b->private_data;
640640 closure_put(&d->cl);
641− return 0;
642641 }
643642
644643 static int ioctl_dev(struct block_device *b, fmode_t mode,
@@ -732,8 +731,7 @@ static void bcache_device_free(struct bcache_device *d) · 87 unmodified lines
732731
733732 if (d->c)
734733 bcache_device_detach(d);
735−
736− if (d->disk)
734+ if (d->disk && d->disk->flags & GENHD_FL_UP)
737735 del_gendisk(d->disk);
738736 if (d->disk && d->disk->queue)
739737 blk_cleanup_queue(d->disk->queue);
@@ -756,12 +754,9 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size) · 16 unmodified lines
756754 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) ||
757755 !(d->unaligned_bvec = mempool_create_kmalloc_pool(1,
758756 sizeof(struct bio_vec) * BIO_MAX_PAGES)) ||
759− bio_split_pool_init(&d->bio_split_hook))
760−
761− return -ENOMEM;
762−
763− d->disk = alloc_disk(1);
764− if (!d->disk)
757+ bio_split_pool_init(&d->bio_split_hook) ||
758+ !(d->disk = alloc_disk(1)) ||
759+ !(q = blk_alloc_queue(GFP_KERNEL)))
765760 return -ENOMEM;
766761
767762 snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", bcache_minor);
@@ -771,10 +766,6 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size) · 3 unmodified lines
771766 d->disk->fops = &bcache_ops;
772767 d->disk->private_data = d;
773768
774− q = blk_alloc_queue(GFP_KERNEL);
775− if (!q)
776− return -ENOMEM;
777−
778769 blk_queue_make_request(q, NULL);
779770 d->disk->queue = q;
780771 q->queuedata = d;
@@ -999,14 +990,17 @@ static void cached_dev_free(struct closure *cl) · 218 unmodified lines
999990
1000991 mutex_lock(&bch_register_lock);
1001992
1002− bd_unlink_disk_holder(dc->bdev, dc->disk.disk);
993+ if (atomic_read(&dc->running))
994+ bd_unlink_disk_holder(dc->bdev, dc->disk.disk);
1003995 bcache_device_free(&dc->disk);
1004996 list_del(&dc->list);
1005997
1006998 mutex_unlock(&bch_register_lock);
1007999
10081000 if (!IS_ERR_OR_NULL(dc->bdev)) {
1009− blk_sync_queue(bdev_get_queue(dc->bdev));
1001+ if (dc->bdev->bd_disk)
1002+ blk_sync_queue(bdev_get_queue(dc->bdev));
1003+
10101004 blkdev_put(dc->bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
10111005 }
10121006
@@ -1028,73 +1022,67 @@ static void cached_dev_flush(struct closure *cl) · 15 unmodified lines
10281022
10291023 static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
10301024 {
1031− int err;
1025+ int ret;
10321026 struct io *io;
1033−
1034− closure_init(&dc->disk.cl, NULL);
1035− set_closure_fn(&dc->disk.cl, cached_dev_flush, system_wq);
1027+ struct request_queue *q = bdev_get_queue(dc->bdev);
10361028
10371029 __module_get(THIS_MODULE);
10381030 INIT_LIST_HEAD(&dc->list);
1031+ closure_init(&dc->disk.cl, NULL);
1032+ set_closure_fn(&dc->disk.cl, cached_dev_flush, system_wq);
10391033 kobject_init(&dc->disk.kobj, &bch_cached_dev_ktype);
1040−
1041− bch_cache_accounting_init(&dc->accounting, &dc->disk.cl);
1042−
1043− err = bcache_device_init(&dc->disk, block_size);
1044− if (err)
1045− goto err;
1046−
1047− spin_lock_init(&dc->io_lock);
1048− closure_init_unlocked(&dc->sb_write);
10491034 INIT_WORK(&dc->detach, cached_dev_detach_finish);
1035+ closure_init_unlocked(&dc->sb_write);
1036+ INIT_LIST_HEAD(&dc->io_lru);
1037+ spin_lock_init(&dc->io_lock);
1038+ bch_cache_accounting_init(&dc->accounting, &dc->disk.cl);
10501039
10511040 dc->sequential_merge = true;
10521041 dc->sequential_cutoff = 4 << 20;
10531042
1054− INIT_LIST_HEAD(&dc->io_lru);
1055− dc->sb_bio.bi_max_vecs = 1;
1056− dc->sb_bio.bi_io_vec = dc->sb_bio.bi_inline_vecs;
1057−
10581043 for (io = dc->io; io < dc->io + RECENT_IO; io++) {
10591044 list_add(&io->lru, &dc->io_lru);
10601045 hlist_add_head(&io->hash, dc->io_hash + RECENT_IO);
10611046 }
10621047
1063− bch_writeback_init_cached_dev(dc);
1048+ ret = bcache_device_init(&dc->disk, block_size);
1049+ if (ret)
1050+ return ret;
1051+
1052+ set_capacity(dc->disk.disk,
1053+ dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
1054+
1055+ dc->disk.disk->queue->backing_dev_info.ra_pages =
1056+ max(dc->disk.disk->queue->backing_dev_info.ra_pages,
1057+ q->backing_dev_info.ra_pages);
1058+
1059+ bch_cached_dev_request_init(dc);
1060+ bch_cached_dev_writeback_init(dc);
10641061 return 0;
1065−err:
1066− bcache_device_stop(&dc->disk);
1067− return err;
10681062 }
10691063
10701064 /* Cached device - bcache superblock */
10711065
1072−static const char *register_bdev(struct cache_sb *sb, struct page *sb_page,
1066+static void register_bdev(struct cache_sb *sb, struct page *sb_page,
10731067 struct block_device *bdev,
10741068 struct cached_dev *dc)
10751069 {
10761070 char name[BDEVNAME_SIZE];
10771071 const char *err = "cannot allocate memory";
1078− struct gendisk *g;
10791072 struct cache_set *c;
10801073
1081− if (!dc || cached_dev_init(dc, sb->block_size << 9) != 0)
1082− return err;
1083−
10841074 memcpy(&dc->sb, sb, sizeof(struct cache_sb));
1085− dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
10861075 dc->bdev = bdev;
10871076 dc->bdev->bd_holder = dc;
10881077
1089− g = dc->disk.disk;
1090−
1091− set_capacity(g, dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
1092−
1093− g->queue->backing_dev_info.ra_pages =
1094− max(g->queue->backing_dev_info.ra_pages,
1095− bdev->bd_queue->backing_dev_info.ra_pages);
1078+ bio_init(&dc->sb_bio);
1079+ dc->sb_bio.bi_max_vecs = 1;
1080+ dc->sb_bio.bi_io_vec = dc->sb_bio.bi_inline_vecs;
1081+ dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
1082+ get_page(sb_page);
10961083
1097− bch_cached_dev_request_init(dc);
1084+ if (cached_dev_init(dc, sb->block_size << 9))
1085+ goto err;
10981086
10991087 err = "error creating kobject";
11001088 if (kobject_add(&dc->disk.kobj, &part_to_dev(bdev->bd_part)->kobj,
@@ -1103,6 +1091,8 @@ static const char *register_bdev(struct cache_sb *sb, struct page *sb_page, · 2 unmodified lines
11031091 if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
11041092 goto err;
11051093
1094+ pr_info("registered backing device %s", bdevname(bdev, name));
1095+
11061096 list_add(&dc->list, &uncached_devices);
11071097 list_for_each_entry(c, &bch_cache_sets, list)
11081098 bch_cached_dev_attach(dc, c);
@@ -1111,15 +1101,10 @@ static const char *register_bdev(struct cache_sb *sb, struct page *sb_page, · 2 unmodified lines
11111101 BDEV_STATE(&dc->sb) == BDEV_STATE_STALE)
11121102 bch_cached_dev_run(dc);
11131103
1114− return NULL;
1104+ return;
11151105 err:
1116− kobject_put(&dc->disk.kobj);
11171106 pr_notice("error opening %s: %s", bdevname(bdev, name), err);
1118− /*
1119− * Return NULL instead of an error because kobject_put() cleans
1120− * everything up
1121− */
1122− return NULL;
1107+ bcache_device_stop(&dc->disk);
11231108 }
11241109
11251110 /* Flash only volumes */
@@ -1717,20 +1702,11 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca) · 591 unmodified lines
17171702 size_t free;
17181703 struct bucket *b;
17191704
1720− if (!ca)
1721− return -ENOMEM;
1722−
17231705 __module_get(THIS_MODULE);
17241706 kobject_init(&ca->kobj, &bch_cache_ktype);
17251707
1726− memcpy(&ca->sb, sb, sizeof(struct cache_sb));
1727−
17281708 INIT_LIST_HEAD(&ca->discards);
17291709
1730− bio_init(&ca->sb_bio);
1731− ca->sb_bio.bi_max_vecs = 1;
1732− ca->sb_bio.bi_io_vec = ca->sb_bio.bi_inline_vecs;
1733−
17341710 bio_init(&ca->journal.bio);
17351711 ca->journal.bio.bi_max_vecs = 8;
17361712 ca->journal.bio.bi_io_vec = ca->journal.bio.bi_inline_vecs;
@@ -1742,18 +1718,17 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca) · 5 unmodified lines
17421718 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) ||
17431719 !init_fifo(&ca->unused, free << 2, GFP_KERNEL) ||
17441720 !init_heap(&ca->heap, free << 3, GFP_KERNEL) ||
1745− !(ca->buckets = vmalloc(sizeof(struct bucket) *
1721+ !(ca->buckets = vzalloc(sizeof(struct bucket) *
17461722 ca->sb.nbuckets)) ||
17471723 !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) *
17481724 2, GFP_KERNEL)) ||
17491725 !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca)) ||
17501726 !(ca->alloc_workqueue = alloc_workqueue("bch_allocator", 0, 1)) ||
17511727 bio_split_pool_init(&ca->bio_split_hook))
1752− goto err;
1728+ return -ENOMEM;
17531729
17541730 ca->prio_last_buckets = ca->prio_buckets + prio_buckets(ca);
17551731
1756− memset(ca->buckets, 0, ca->sb.nbuckets * sizeof(struct bucket));
17571732 for_each_bucket(b, ca)
17581733 atomic_set(&b->pin, 0);
17591734
@@ -1766,22 +1741,28 @@ err: · 6 unmodified lines
17661741 return -ENOMEM;
17671742 }
17681743
1769−static const char *register_cache(struct cache_sb *sb, struct page *sb_page,
1744+static void register_cache(struct cache_sb *sb, struct page *sb_page,
17701745 struct block_device *bdev, struct cache *ca)
17711746 {
17721747 char name[BDEVNAME_SIZE];
17731748 const char *err = "cannot allocate memory";
17741749
1775− if (cache_alloc(sb, ca) != 0)
1776− return err;
1777−
1778− ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
1750+ memcpy(&ca->sb, sb, sizeof(struct cache_sb));
17791751 ca->bdev = bdev;
17801752 ca->bdev->bd_holder = ca;
17811753
1754+ bio_init(&ca->sb_bio);
1755+ ca->sb_bio.bi_max_vecs = 1;
1756+ ca->sb_bio.bi_io_vec = ca->sb_bio.bi_inline_vecs;
1757+ ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
1758+ get_page(sb_page);
1759+
17821760 if (blk_queue_discard(bdev_get_queue(ca->bdev)))
17831761 ca->discard = CACHE_DISCARD(&ca->sb);
17841762
1763+ if (cache_alloc(sb, ca) != 0)
1764+ goto err;
1765+
17851766 err = "error creating kobject";
17861767 if (kobject_add(&ca->kobj, &part_to_dev(bdev->bd_part)->kobj, "bcache"))
17871768 goto err;
@@ -1791,15 +1772,10 @@ static const char *register_cache(struct cache_sb *sb, struct page *sb_page, · 3 unmodified lines
17911772 goto err;
17921773
17931774 pr_info("registered cache device %s", bdevname(bdev, name));
1794−
1795− return NULL;
1775+ return;
17961776 err:
1777+ pr_notice("error opening %s: %s", bdevname(bdev, name), err);
17971778 kobject_put(&ca->kobj);
1798− pr_info("error opening %s: %s", bdevname(bdev, name), err);
1799− /* Return NULL instead of an error because kobject_put() cleans
1800− * everything up
1801− */
1802− return NULL;
18031779 }
18041780
18051781 /* Global interfaces/init */
@@ -1833,12 +1809,15 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, · 27 unmodified lines
18331809 bdev = blkdev_get_by_path(strim(path),
18341810 FMODE_READ|FMODE_WRITE|FMODE_EXCL,
18351811 sb);
1836− if (bdev == ERR_PTR(-EBUSY))
1837− err = "device busy";
1838−
1839− if (IS_ERR(bdev) ||
1840− set_blocksize(bdev, 4096))
1812+ if (IS_ERR(bdev)) {
1813+ if (bdev == ERR_PTR(-EBUSY))
1814+ err = "device busy";
18411815 goto err;
1816+ }
1817+
1818+ err = "failed to set blocksize";
1819+ if (set_blocksize(bdev, 4096))
1820+ goto err_close;
18421821
18431822 err = read_super(sb, bdev, &sb_page);
18441823 if (err)
@@ -1846,33 +1825,33 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, · 1 unmodified line
18461825
18471826 if (SB_IS_BDEV(sb)) {
18481827 struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
1828+ if (!dc)
1829+ goto err_close;
18491830
1850− err = register_bdev(sb, sb_page, bdev, dc);
1831+ register_bdev(sb, sb_page, bdev, dc);
18511832 } else {
18521833 struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
1834+ if (!ca)
1835+ goto err_close;
18531836
1854− err = register_cache(sb, sb_page, bdev, ca);
1837+ register_cache(sb, sb_page, bdev, ca);
18551838 }
1856−
1857− if (err) {
1858− /* register_(bdev|cache) will only return an error if they
1859− * didn't get far enough to create the kobject - if they did,
1860− * the kobject destructor will do this cleanup.
1861− */
1839+out:
1840+ if (sb_page)
18621841 put_page(sb_page);
1863−err_close:
1864− blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
1865−err:
1866− if (attr != &ksysfs_register_quiet)
1867− pr_info("error opening %s: %s", path, err);
1868− ret = -EINVAL;
1869− }
1870−
18711842 kfree(sb);
18721843 kfree(path);
18731844 mutex_unlock(&bch_register_lock);
18741845 module_put(THIS_MODULE);
18751846 return ret;
1847+
1848+err_close:
1849+ blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
1850+err:
1851+ if (attr != &ksysfs_register_quiet)
1852+ pr_info("error opening %s: %s", path, err);
1853+ ret = -EINVAL;
1854+ goto out;
18761855 }
18771856
18781857 static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
drivers/md/bcache/writeback.c+1−1
@@ -375,7 +375,7 @@ err: · 374 unmodified lines
375375 refill_dirty(cl);
376376 }
377377
378−void bch_writeback_init_cached_dev(struct cached_dev *dc)
378+void bch_cached_dev_writeback_init(struct cached_dev *dc)
379379 {
380380 closure_init_unlocked(&dc->writeback);
381381 init_rwsem(&dc->writeback_lock);
drivers/md/raid5.c+2−0
@@ -664,6 +664,7 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) · 663 unmodified lines
664664 if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
665665 bi->bi_rw |= REQ_FLUSH;
666666
667+ bi->bi_vcnt = 1;
667668 bi->bi_io_vec[0].bv_len = STRIPE_SIZE;
668669 bi->bi_io_vec[0].bv_offset = 0;
669670 bi->bi_size = STRIPE_SIZE;
@@ -701,6 +702,7 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) · 31 unmodified lines
701702 else
702703 rbi->bi_sector = (sh->sector
703704 + rrdev->data_offset);
705+ rbi->bi_vcnt = 1;
704706 rbi->bi_io_vec[0].bv_len = STRIPE_SIZE;
705707 rbi->bi_io_vec[0].bv_offset = 0;
706708 rbi->bi_size = STRIPE_SIZE;
include/linux/scatterlist.h+3−0
@@ -111,6 +111,9 @@ static inline struct page *sg_page(struct scatterlist *sg) · 110 unmodified lines
111111 static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
112112 unsigned int buflen)
113113 {
114+#ifdef CONFIG_DEBUG_SG
115+ BUG_ON(!virt_addr_valid(buf));
116+#endif
114117 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
115118 }
116119