Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1262413 > unrolled thread
| Started by | Jan Kara <jack@suse.com> |
|---|---|
| First post | 2015-11-04 17:20 +0100 |
| Last post | 2015-11-05 21:20 +0100 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH] brd: Refuse improperly aligned discard requests Jan Kara <jack@suse.com> - 2015-11-04 17:20 +0100
RE: [PATCH] brd: Refuse improperly aligned discard requests "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> - 2015-11-05 05:30 +0100
Re: [PATCH] brd: Refuse improperly aligned discard requests Jan Kara <jack@suse.cz> - 2015-11-05 09:10 +0100
Re: [PATCH] brd: Refuse improperly aligned discard requests Jens Axboe <axboe@kernel.dk> - 2015-11-05 21:20 +0100
| From | Jan Kara <jack@suse.com> |
|---|---|
| Date | 2015-11-04 17:20 +0100 |
| Subject | [PATCH] brd: Refuse improperly aligned discard requests |
| Message-ID | <qr8WZ-2KK-9@gated-at.bofh.it> |
Currently when improperly aligned discard request is submitted, we just
silently discard more / less data which results in filesystem corruption
in some cases. Refuse such misaligned requests.
Signed-off-by: Jan Kara <jack@suse.com>
---
drivers/block/brd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index b9794aeeb878..4ef4cdf67ede 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -337,6 +337,9 @@ static void brd_make_request(struct request_queue *q, struct bio *bio)
goto io_error;
if (unlikely(bio->bi_rw & REQ_DISCARD)) {
+ if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) ||
+ bio->bi_iter.bi_size & PAGE_MASK)
+ goto io_error;
discard_from_brd(brd, sector, bio->bi_iter.bi_size);
goto out;
}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> |
|---|---|
| Date | 2015-11-05 05:30 +0100 |
| Message-ID | <qrkls-1IA-1@gated-at.bofh.it> |
| In reply to | #1262413 |
> -----Original Message----- > From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel- > owner@vger.kernel.org] On Behalf Of Jan Kara > Sent: Wednesday, November 4, 2015 10:14 AM > To: axboe@kernel.dk > Cc: LKML <linux-kernel@vger.kernel.org>; linux-fsdevel@vger.kernel.org; > Christoph Hellwig <hch@infradead.org>; Jan Kara <jack@suse.com> > Subject: [PATCH] brd: Refuse improperly aligned discard requests > > Currently when improperly aligned discard request is submitted, we just > silently discard more / less data which results in filesystem corruption > in some cases. Refuse such misaligned requests. I agree discarding more than requested is very bad. If they are routed to SCSI or ATA devices, though, the discard commands (SCSI UNMAP or ATA DATA SET MANAGEMENT/TRIM) are just hints, so there is no guarantee the discard will do anything. Are you finding filesystems that still don't understand that? dm-raid held that mistaken assumption for a long time. --- Robert Elliott, HP Server Storage -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jan Kara <jack@suse.cz> |
|---|---|
| Date | 2015-11-05 09:10 +0100 |
| Message-ID | <qrnMm-3ZY-13@gated-at.bofh.it> |
| In reply to | #1262885 |
On Thu 05-11-15 04:18:49, Elliott, Robert (Persistent Memory) wrote: > > > -----Original Message----- > > From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel- > > owner@vger.kernel.org] On Behalf Of Jan Kara > > Sent: Wednesday, November 4, 2015 10:14 AM > > To: axboe@kernel.dk > > Cc: LKML <linux-kernel@vger.kernel.org>; linux-fsdevel@vger.kernel.org; > > Christoph Hellwig <hch@infradead.org>; Jan Kara <jack@suse.com> > > Subject: [PATCH] brd: Refuse improperly aligned discard requests > > > > Currently when improperly aligned discard request is submitted, we just > > silently discard more / less data which results in filesystem corruption > > in some cases. Refuse such misaligned requests. > > I agree discarding more than requested is very bad. > > If they are routed to SCSI or ATA devices, though, the discard commands > (SCSI UNMAP or ATA DATA SET MANAGEMENT/TRIM) are just hints, so there > is no guarantee the discard will do anything. Are you finding > filesystems that still don't understand that? dm-raid held that > mistaken assumption for a long time. So there is blkdev_issue_zeroout() which uses blkdev_issue_discard() if 'discard_zeroes_data' is set. I'd hope that in that case zeroing really happens as submitted or error is returned... Filesystems definitely depend on blkdev_issue_zeroout() doing what it is told. Honza -- Jan Kara <jack@suse.com> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jens Axboe <axboe@kernel.dk> |
|---|---|
| Date | 2015-11-05 21:20 +0100 |
| Message-ID | <qrzaO-2TZ-13@gated-at.bofh.it> |
| In reply to | #1262413 |
On 11/04/2015 09:13 AM, Jan Kara wrote: > Currently when improperly aligned discard request is submitted, we just > silently discard more / less data which results in filesystem corruption > in some cases. Refuse such misaligned requests. Applied, thanks Jan. -- Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web