aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorAlex Shi <alex.shi@linaro.org>2016-10-19 11:10:19 +0800
committerAlex Shi <alex.shi@linaro.org>2016-10-19 11:10:19 +0800
commit1fde384c30fb25ff0d7a3e7ed793019479b31e18 (patch)
tree68b563bcab65d8c03dcb20d11622e5b8b904dcf8 /block
parenta44038112d3379f49df8a9db3e1259d9e945faee (diff)
parentc67d235857a13b609e664f901fb990f49796ddcc (diff)
Merge branch 'linux-linaro-lsk-v3.18' into linux-linaro-lsk-v3.18-rt
Conflicts: fs/dcache.c
Diffstat (limited to 'block')
-rw-r--r--block/bio.c15
-rw-r--r--block/genhd.c1
2 files changed, 13 insertions, 3 deletions
diff --git a/block/bio.c b/block/bio.c
index 3e6e1986a5b2..78803e99c154 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1824,8 +1824,9 @@ EXPORT_SYMBOL(bio_endio_nodec);
* Allocates and returns a new bio which represents @sectors from the start of
* @bio, and updates @bio to represent the remaining sectors.
*
- * The newly allocated bio will point to @bio's bi_io_vec; it is the caller's
- * responsibility to ensure that @bio is not freed before the split.
+ * Unless this is a discard request the newly allocated bio will point
+ * to @bio's bi_io_vec; it is the caller's responsibility to ensure that
+ * @bio is not freed before the split.
*/
struct bio *bio_split(struct bio *bio, int sectors,
gfp_t gfp, struct bio_set *bs)
@@ -1835,7 +1836,15 @@ struct bio *bio_split(struct bio *bio, int sectors,
BUG_ON(sectors <= 0);
BUG_ON(sectors >= bio_sectors(bio));
- split = bio_clone_fast(bio, gfp, bs);
+ /*
+ * Discards need a mutable bio_vec to accommodate the payload
+ * required by the DSM TRIM and UNMAP commands.
+ */
+ if (bio->bi_rw & REQ_DISCARD)
+ split = bio_clone_bioset(bio, gfp, bs);
+ else
+ split = bio_clone_fast(bio, gfp, bs);
+
if (!split)
return NULL;
diff --git a/block/genhd.c b/block/genhd.c
index c2fb3f7bdec4..40a06b934b1f 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -829,6 +829,7 @@ static void disk_seqf_stop(struct seq_file *seqf, void *v)
if (iter) {
class_dev_iter_exit(iter);
kfree(iter);
+ seqf->private = NULL;
}
}