From: Shaohua Li <shli@fusionio.com>
To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org
Cc: neilb@suse.de, axboe@kernel.dk, Shaohua Li <shli@fusionio.com>
Subject: [patch 2/7] md: linear supports TRIM
Date: Mon, 12 Mar 2012 11:04:14 +0800 [thread overview]
Message-ID: <20120312031305.556706935@fusionio.com> (raw)
In-Reply-To: 20120312030412.375458948@fusionio.com
[-- Attachment #1: md-linear-discard-support.patch --]
[-- Type: text/plain, Size: 1621 bytes --]
This makes md linear support TRIM.
Signed-off-by: Shaohua Li <shli@fusionio.com>
---
drivers/md/linear.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Index: linux/drivers/md/linear.c
===================================================================
--- linux.orig/drivers/md/linear.c 2012-03-09 16:56:41.173790011 +0800
+++ linux/drivers/md/linear.c 2012-03-12 10:15:44.916611071 +0800
@@ -129,6 +129,7 @@ static struct linear_conf *linear_conf(s
struct linear_conf *conf;
struct md_rdev *rdev;
int i, cnt;
+ bool discard_supported = false;
conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info),
GFP_KERNEL);
@@ -171,6 +172,8 @@ static struct linear_conf *linear_conf(s
conf->array_sectors += rdev->sectors;
cnt++;
+ if (blk_queue_discard(bdev_get_queue(rdev->bdev)))
+ discard_supported = true;
}
if (cnt != raid_disks) {
printk(KERN_ERR "md/linear:%s: not enough drives present. Aborting!\n",
@@ -178,6 +181,11 @@ static struct linear_conf *linear_conf(s
goto out;
}
+ if (!discard_supported)
+ queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
+ else
+ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
+
/*
* Here we calculate the device offsets.
*/
@@ -319,6 +327,14 @@ static void linear_make_request(struct m
bio->bi_sector = bio->bi_sector - start_sector
+ tmp_dev->rdev->data_offset;
rcu_read_unlock();
+
+ if (unlikely((bio->bi_rw & REQ_DISCARD) &&
+ !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) {
+ /* Just ignore it */
+ bio_endio(bio, 0);
+ return;
+ }
+
generic_make_request(bio);
}
next prev parent reply other threads:[~2012-03-12 3:04 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-12 3:04 [patch 0/7] Add TRIM support for raid linear/0/1/10 Shaohua Li
2012-03-12 3:04 ` [patch 1/7] block: makes bio_split support bio without data Shaohua Li
2012-03-12 3:04 ` Shaohua Li [this message]
2012-03-12 3:04 ` [patch 3/7] md: raid 0 supports TRIM Shaohua Li
2012-03-12 3:04 ` [patch 4/7] md: raid 1 " Shaohua Li
2012-03-12 3:04 ` [patch 5/7] md: raid 10 " Shaohua Li
2012-03-12 3:04 ` [patch 6/7] blk: add plug for blkdev_issue_discard Shaohua Li
2012-03-13 15:51 ` Vivek Goyal
2012-03-13 15:51 ` Vivek Goyal
2012-03-13 17:04 ` Martin K. Petersen
2012-03-13 17:14 ` Vivek Goyal
2012-03-13 17:19 ` Martin K. Petersen
2012-03-12 3:04 ` [patch 7/7] blk: use correct sectors limitation for discard request Shaohua Li
2012-03-13 16:00 ` Vivek Goyal
2012-03-13 16:00 ` Vivek Goyal
2012-03-12 3:18 ` [patch 0/7] Add TRIM support for raid linear/0/1/10 Roberto Spadim
2012-03-12 3:18 ` Roberto Spadim
2012-03-12 18:22 ` Holger Kiehl
[not found] ` <4F5EFEB6.4060402@kernel.org>
2012-03-13 12:22 ` Holger Kiehl
2012-03-13 14:15 ` Shaohua Li
2012-03-13 14:15 ` Shaohua Li
2012-03-13 14:58 ` Roberto Spadim
2012-03-13 14:58 ` Roberto Spadim
2012-03-13 15:44 ` Holger Kiehl
2012-03-14 1:30 ` Shaohua Li
2012-03-14 10:25 ` Holger Kiehl
2012-03-14 11:14 ` Shaohua Li
2012-03-14 11:14 ` Shaohua Li
2012-03-14 11:32 ` Shaohua Li
2012-03-14 21:01 ` Holger Kiehl
2012-03-14 21:13 ` Holger Kiehl
2012-03-15 2:39 ` Shaohua Li
2012-03-15 9:08 ` Holger Kiehl
2012-03-16 2:19 ` Shaohua Li
[not found] ` <4F5EA8E9.5010502@fusionio.com>
2012-03-14 2:25 ` NeilBrown
2012-03-14 2:25 ` NeilBrown
2012-03-14 2:24 ` NeilBrown
2012-03-14 2:47 ` Shaohua Li
2012-03-17 18:14 ` Mark Lord
2012-03-18 2:03 ` Shaohua Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120312031305.556706935@fusionio.com \
--to=shli@fusionio.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.