lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100513051953.532821BC316@ruihe.smo.corp.google.com>
Date:	Wed, 12 May 2010 22:19:53 -0700 (PDT)
From:	jiayingz@...gle.com (Jiaying Zhang)
To:	hch@...radead.org, jens.axboe@...cle.com
Cc:	linux-kernel@...r.kernel.org, mrubin@...gle.com
Subject: [PATCH, RFC] addjust discard request to be aligned with hwsect size to support SSDs with larger sector size

The currect blkdev_issue_discard() function assumes 512 sector size.
We have seen some problem when using discard on a SSD that has larger
sector size. The following patch adjusts the starting address and size of
a discard request to be aligned with hwsect size.

Signed-off-by: Jiaying Zhang <jiayingz@...gle.com>

diff --git a/block/blk-barrier.c b/block/blk-barrier.c
index 6d88544..576b7a1 100644
--- a/block/blk-barrier.c
+++ b/block/blk-barrier.c
@@ -376,14 +376,22 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 		DISCARD_BARRIER : DISCARD_NOBARRIER;
 	struct bio *bio;
 	struct page *page;
+	int hwsect_shift = blksize_bits(bdev_logical_block_size(bdev)) - 9;
+	int hwsect_mask = (1 << hwsect_shift) - 1;
+	sector_t end_sector;
 	int ret = 0;
 
 	if (!q)
 		return -ENXIO;
 
-	if (!blk_queue_discard(q))
+	if (!blk_queue_discard(q) || q->limits.max_discard_sectors == 0)
 		return -EOPNOTSUPP;
 
+	if (hwsect_shift > 0) {
+		end_sector = (sector + nr_sects) & ~hwsect_mask;
+		sector = (sector + hwsect_mask) & ~hwsect_mask;
+		nr_sects = end_sector - sector;
+	}
 	while (nr_sects && !ret) {
 		unsigned int sector_size = q->limits.logical_block_size;
 		unsigned int max_discard_sectors =
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ