Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-5.1/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:

- Two queue_limits stacking fixes: disable discards if underlying
driver does. And propagate BDI_CAP_STABLE_WRITES to fix sporadic
checksum errors.

- Fix that reverts a DM core limit that wasn't needed given that
dm-crypt was already updated to impose an equivalent limit.

- Fix dm-init to properly establish 'const' for __initconst array.

- Fix deadlock in DM integrity target that occurs when overlapping IO
is being issued to it. And two smaller fixes to the DM integrity
target.

* tag 'for-5.1/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm integrity: fix deadlock with overlapping I/O
dm: disable DISCARD if the underlying storage no longer supports it
dm table: propagate BDI_CAP_STABLE_WRITES to fix sporadic checksum errors
dm: revert 8f50e358153d ("dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE")
dm init: fix const confusion for dm_allowed_targets array
dm integrity: make dm_integrity_init and dm_integrity_exit static
dm integrity: change memcmp to strncmp in dm_integrity_ctr

+72 -27
+1
drivers/md/dm-core.h
··· 115 115 struct srcu_struct io_barrier; 116 116 }; 117 117 118 + void disable_discard(struct mapped_device *md); 118 119 void disable_write_same(struct mapped_device *md); 119 120 void disable_write_zeroes(struct mapped_device *md); 120 121
+1 -1
drivers/md/dm-init.c
··· 36 36 struct list_head list; 37 37 }; 38 38 39 - const char *dm_allowed_targets[] __initconst = { 39 + const char * const dm_allowed_targets[] __initconst = { 40 40 "crypt", 41 41 "delay", 42 42 "linear",
+7 -9
drivers/md/dm-integrity.c
··· 913 913 static bool ranges_overlap(struct dm_integrity_range *range1, struct dm_integrity_range *range2) 914 914 { 915 915 return range1->logical_sector < range2->logical_sector + range2->n_sectors && 916 - range2->logical_sector + range2->n_sectors > range2->logical_sector; 916 + range1->logical_sector + range1->n_sectors > range2->logical_sector; 917 917 } 918 918 919 919 static bool add_new_range(struct dm_integrity_c *ic, struct dm_integrity_range *new_range, bool check_waiting) ··· 959 959 struct dm_integrity_range *last_range = 960 960 list_first_entry(&ic->wait_list, struct dm_integrity_range, wait_entry); 961 961 struct task_struct *last_range_task; 962 - if (!ranges_overlap(range, last_range)) 963 - break; 964 962 last_range_task = last_range->task; 965 963 list_del(&last_range->wait_entry); 966 964 if (!add_new_range(ic, last_range, false)) { ··· 3183 3185 journal_watermark = val; 3184 3186 else if (sscanf(opt_string, "commit_time:%u%c", &val, &dummy) == 1) 3185 3187 sync_msec = val; 3186 - else if (!memcmp(opt_string, "meta_device:", strlen("meta_device:"))) { 3188 + else if (!strncmp(opt_string, "meta_device:", strlen("meta_device:"))) { 3187 3189 if (ic->meta_dev) { 3188 3190 dm_put_device(ti, ic->meta_dev); 3189 3191 ic->meta_dev = NULL; ··· 3202 3204 goto bad; 3203 3205 } 3204 3206 ic->sectors_per_block = val >> SECTOR_SHIFT; 3205 - } else if (!memcmp(opt_string, "internal_hash:", strlen("internal_hash:"))) { 3207 + } else if (!strncmp(opt_string, "internal_hash:", strlen("internal_hash:"))) { 3206 3208 r = get_alg_and_key(opt_string, &ic->internal_hash_alg, &ti->error, 3207 3209 "Invalid internal_hash argument"); 3208 3210 if (r) 3209 3211 goto bad; 3210 - } else if (!memcmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) { 3212 + } else if (!strncmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) { 3211 3213 r = get_alg_and_key(opt_string, &ic->journal_crypt_alg, &ti->error, 3212 3214 "Invalid journal_crypt argument"); 3213 3215 if (r) 3214 3216 goto bad; 3215 - } else if (!memcmp(opt_string, "journal_mac:", strlen("journal_mac:"))) { 3217 + } else if (!strncmp(opt_string, "journal_mac:", strlen("journal_mac:"))) { 3216 3218 r = get_alg_and_key(opt_string, &ic->journal_mac_alg, &ti->error, 3217 3219 "Invalid journal_mac argument"); 3218 3220 if (r) ··· 3614 3616 .io_hints = dm_integrity_io_hints, 3615 3617 }; 3616 3618 3617 - int __init dm_integrity_init(void) 3619 + static int __init dm_integrity_init(void) 3618 3620 { 3619 3621 int r; 3620 3622 ··· 3633 3635 return r; 3634 3636 } 3635 3637 3636 - void dm_integrity_exit(void) 3638 + static void __exit dm_integrity_exit(void) 3637 3639 { 3638 3640 dm_unregister_target(&integrity_target); 3639 3641 kmem_cache_destroy(journal_io_cache);
+7 -4
drivers/md/dm-rq.c
··· 222 222 } 223 223 224 224 if (unlikely(error == BLK_STS_TARGET)) { 225 - if (req_op(clone) == REQ_OP_WRITE_SAME && 226 - !clone->q->limits.max_write_same_sectors) 225 + if (req_op(clone) == REQ_OP_DISCARD && 226 + !clone->q->limits.max_discard_sectors) 227 + disable_discard(tio->md); 228 + else if (req_op(clone) == REQ_OP_WRITE_SAME && 229 + !clone->q->limits.max_write_same_sectors) 227 230 disable_write_same(tio->md); 228 - if (req_op(clone) == REQ_OP_WRITE_ZEROES && 229 - !clone->q->limits.max_write_zeroes_sectors) 231 + else if (req_op(clone) == REQ_OP_WRITE_ZEROES && 232 + !clone->q->limits.max_write_zeroes_sectors) 230 233 disable_write_zeroes(tio->md); 231 234 } 232 235
+39
drivers/md/dm-table.c
··· 1844 1844 return true; 1845 1845 } 1846 1846 1847 + static int device_requires_stable_pages(struct dm_target *ti, 1848 + struct dm_dev *dev, sector_t start, 1849 + sector_t len, void *data) 1850 + { 1851 + struct request_queue *q = bdev_get_queue(dev->bdev); 1852 + 1853 + return q && bdi_cap_stable_pages_required(q->backing_dev_info); 1854 + } 1855 + 1856 + /* 1857 + * If any underlying device requires stable pages, a table must require 1858 + * them as well. Only targets that support iterate_devices are considered: 1859 + * don't want error, zero, etc to require stable pages. 1860 + */ 1861 + static bool dm_table_requires_stable_pages(struct dm_table *t) 1862 + { 1863 + struct dm_target *ti; 1864 + unsigned i; 1865 + 1866 + for (i = 0; i < dm_table_get_num_targets(t); i++) { 1867 + ti = dm_table_get_target(t, i); 1868 + 1869 + if (ti->type->iterate_devices && 1870 + ti->type->iterate_devices(ti, device_requires_stable_pages, NULL)) 1871 + return true; 1872 + } 1873 + 1874 + return false; 1875 + } 1876 + 1847 1877 void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, 1848 1878 struct queue_limits *limits) 1849 1879 { ··· 1925 1895 q->limits.max_write_zeroes_sectors = 0; 1926 1896 1927 1897 dm_table_verify_integrity(t); 1898 + 1899 + /* 1900 + * Some devices don't use blk_integrity but still want stable pages 1901 + * because they do their own checksumming. 1902 + */ 1903 + if (dm_table_requires_stable_pages(t)) 1904 + q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; 1905 + else 1906 + q->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES; 1928 1907 1929 1908 /* 1930 1909 * Determine whether or not this queue's I/O timings contribute
+17 -13
drivers/md/dm.c
··· 945 945 } 946 946 } 947 947 948 + void disable_discard(struct mapped_device *md) 949 + { 950 + struct queue_limits *limits = dm_get_queue_limits(md); 951 + 952 + /* device doesn't really support DISCARD, disable it */ 953 + limits->max_discard_sectors = 0; 954 + blk_queue_flag_clear(QUEUE_FLAG_DISCARD, md->queue); 955 + } 956 + 948 957 void disable_write_same(struct mapped_device *md) 949 958 { 950 959 struct queue_limits *limits = dm_get_queue_limits(md); ··· 979 970 dm_endio_fn endio = tio->ti->type->end_io; 980 971 981 972 if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) { 982 - if (bio_op(bio) == REQ_OP_WRITE_SAME && 983 - !bio->bi_disk->queue->limits.max_write_same_sectors) 973 + if (bio_op(bio) == REQ_OP_DISCARD && 974 + !bio->bi_disk->queue->limits.max_discard_sectors) 975 + disable_discard(md); 976 + else if (bio_op(bio) == REQ_OP_WRITE_SAME && 977 + !bio->bi_disk->queue->limits.max_write_same_sectors) 984 978 disable_write_same(md); 985 - if (bio_op(bio) == REQ_OP_WRITE_ZEROES && 986 - !bio->bi_disk->queue->limits.max_write_zeroes_sectors) 979 + else if (bio_op(bio) == REQ_OP_WRITE_ZEROES && 980 + !bio->bi_disk->queue->limits.max_write_zeroes_sectors) 987 981 disable_write_zeroes(md); 988 982 } 989 983 ··· 1054 1042 return -EINVAL; 1055 1043 } 1056 1044 1057 - /* 1058 - * BIO based queue uses its own splitting. When multipage bvecs 1059 - * is switched on, size of the incoming bio may be too big to 1060 - * be handled in some targets, such as crypt. 1061 - * 1062 - * When these targets are ready for the big bio, we can remove 1063 - * the limit. 1064 - */ 1065 - ti->max_io_len = min_t(uint32_t, len, BIO_MAX_PAGES * PAGE_SIZE); 1045 + ti->max_io_len = (uint32_t) len; 1066 1046 1067 1047 return 0; 1068 1048 }