stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "block: Do a full clone when splitting discard bios" has been added to the 4.1-stable tree
@ 2015-07-30 19:12 gregkh
  2015-07-31 17:23 ` Holger Hoffstätte
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2015-07-30 19:12 UTC (permalink / raw)
  To: martin.petersen, axboe, gregkh, hch, kent.overstreet,
	seunguk.shin
  Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    block: Do a full clone when splitting discard bios

to the 4.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     block-do-a-full-clone-when-splitting-discard-bios.patch
and it can be found in the queue-4.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From f3f5da624e0a891c34d8cd513c57f1d9b0c7dadc Mon Sep 17 00:00:00 2001
From: "Martin K. Petersen" <martin.petersen@oracle.com>
Date: Wed, 22 Jul 2015 07:57:12 -0400
Subject: block: Do a full clone when splitting discard bios

From: "Martin K. Petersen" <martin.petersen@oracle.com>

commit f3f5da624e0a891c34d8cd513c57f1d9b0c7dadc upstream.

This fixes a data corruption bug when using discard on top of MD linear,
raid0 and raid10 personalities.

Commit 20d0189b1012 "block: Introduce new bio_split()" permits sharing
the bio_vec between the two resulting bios. That is fine for read/write
requests where the bio_vec is immutable. For discards, however, we need
to be able to attach a payload and update the bio_vec so the page can
get mapped to a scatterlist entry. Therefore the bio_vec can not be
shared when splitting discards and we must do a full clone.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: Seunguk Shin <seunguk.shin@samsung.com>
Tested-by: Seunguk Shin <seunguk.shin@samsung.com>
Cc: Seunguk Shin <seunguk.shin@samsung.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 block/bio.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

--- a/block/bio.c
+++ b/block/bio.c
@@ -1814,8 +1814,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)
@@ -1825,7 +1826,15 @@ struct bio *bio_split(struct bio *bio, i
 	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;
 


Patches currently in stable-queue which might be from martin.petersen@oracle.com are

queue-4.1/block-do-a-full-clone-when-splitting-discard-bios.patch
queue-4.1/libata-fall-back-to-unqueued-read-log-ext-if-the-dma-variant-fails.patch
queue-4.1/libata-expose-trim-capability-in-sysfs.patch
queue-4.1/libata-do-not-blacklist-micron-m500dc.patch
queue-4.1/libata-do-not-blacklist-m510dc.patch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch "block: Do a full clone when splitting discard bios" has been added to the 4.1-stable tree
  2015-07-30 19:12 Patch "block: Do a full clone when splitting discard bios" has been added to the 4.1-stable tree gregkh
@ 2015-07-31 17:23 ` Holger Hoffstätte
  2015-07-31 17:26   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Holger Hoffstätte @ 2015-07-31 17:23 UTC (permalink / raw)
  To: stable

On Thu, 30 Jul 2015 12:12:10 -0700, gregkh wrote:

> This is a note to let you know that I've just added the patch titled
> 
>     block: Do a full clone when splitting discard bios
> 
> to the 4.1-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

Greg,

not sure what the status of your backlog queue is, but since I've not yet seen
this queued for 3.14 just a note that it applies cleanly when you change the file
paths from /block/ to /fs/ to accommodate the later move of bio.c.

IMHO this is important to prevent more md/fstrim damage. If it's on the pile
then just ignore this. :)

thanks,
-h


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch "block: Do a full clone when splitting discard bios" has been added to the 4.1-stable tree
  2015-07-31 17:23 ` Holger Hoffstätte
@ 2015-07-31 17:26   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2015-07-31 17:26 UTC (permalink / raw)
  To: Holger Hoffstätte; +Cc: stable

On Fri, Jul 31, 2015 at 05:23:54PM +0000, Holger Hoffst�tte wrote:
> On Thu, 30 Jul 2015 12:12:10 -0700, gregkh wrote:
> 
> > This is a note to let you know that I've just added the patch titled
> > 
> >     block: Do a full clone when splitting discard bios
> > 
> > to the 4.1-stable tree which can be found at:
> >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> Greg,
> 
> not sure what the status of your backlog queue is, but since I've not yet seen
> this queued for 3.14 just a note that it applies cleanly when you change the file
> paths from /block/ to /fs/ to accommodate the later move of bio.c.
> 
> IMHO this is important to prevent more md/fstrim damage. If it's on the pile
> then just ignore this. :)

No, I didn't realize that, thanks, I'll go do that change now and queue
it up, thanks for letting me know.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-31 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-30 19:12 Patch "block: Do a full clone when splitting discard bios" has been added to the 4.1-stable tree gregkh
2015-07-31 17:23 ` Holger Hoffstätte
2015-07-31 17:26   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).