Skip to contentSkip to conversation

bcache: For back device, stripe_size get the small value between "1 << 31" and the io_opt of request_queue of back device.

PATCH In review majianpeng 2 participants 2 messages Jan 8, 2014 bcache (block layer cache)

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/3 bcache: For back device, stripe_size get the small value between "1 << 31" and the io_opt of request_queue of back device.

Let's the stripe_size of back device is io_opt of request_queue make good sense.

---
 drivers/md/bcache/super.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/bcache/super.c +5 -1
index c57bfa0..21f77c1 100644
@@ -759,11 +759,15 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
 			      sector_t sectors)
 {
 	struct request_queue *q;
+	struct cached_dev *dc;
 	size_t n;
 	int minor;
 
+	dc = container_of(d, struct cached_dev, disk);
+	q = bdev_get_queue(dc->bdev);
+
 	if (!d->stripe_size)
-		d->stripe_size = 1 << 31;
+		d->stripe_size = min_t(unsigned, 1 << 31, q->limits.io_opt);
 
 	d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size);
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 18 lines · majianpeng

Let's the stripe_size of back device is io_opt of request_queue make good sense.

---
 drivers/md/bcache/super.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/bcache/super.c +1 -0
index c57bfa0..21f77c1 100644
@@ -759,11 +759,15 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
 			      sector_t sectors)
 {
 	struct request_queue *q;
+	struct cached_dev *dc;
 	size_t n;

drivers/md/bcache/super.c static int bcache_device_init(struct bcache_device *d, unsigned block_size, · line 772

Quoted 10 lines
drivers/md/bcache/super.c +4 -1
 	int minor;
 
+	dc = container_of(d, struct cached_dev, disk);
+	q = bdev_get_queue(dc->bdev);
+
 	if (!d->stripe_size)
-		d->stripe_size = 1 << 31;
+		d->stripe_size = min_t(unsigned, 1 << 31, q->limits.io_opt);
 
 	d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size);

We only care about stripe size if we're trying to flush dirty data by stripe - this is for writeback with raid5/6 stripe awareness. There's currently no way to enable this functionality, the patch that enables it is going into 3.14.

If we don't have that stuff enabled, we only care about stripes insofar as we have to track dirty data at _some_ granularity.