From: Boaz Harrosh <boaz@plexistor.com>
To: Jens Axboe <axboe@fb.com>, Matthew Wilcox <willy@linux.intel.com>,
Dmitry Monakhov <dmonakhov@openvz.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 4/5] brd: Request from fdisk 4k alignment
Date: Wed, 05 Nov 2014 16:08:18 +0200 [thread overview]
Message-ID: <545A2F52.3040303@plexistor.com> (raw)
In-Reply-To: <545A2D69.8090003@plexistor.com>
From: Boaz Harrosh <boaz@plexistor.com>
Because of the direct_access() API which returns a PFN. partitions
better start on 4K boundary, else offset ZERO of a partition will
not be aligned and blk_direct_access() will fail the call.
By setting blk_queue_physical_block_size(PAGE_SIZE) we can communicate
this to fdisk and friends.
Note that blk_queue_physical_block_size() also trashes io_min, but
we can leave this one to be 512. io_min as opposed to physical_block_size
will actually change Kernel behavior, but physical_block_size is not
used by Kernel except being exported to user-mode.
before this patch running fdisk on a default size brd of 4M
the first sector offered is 34 (BAD), but after this patch it
will be 40, ie 8 sectors aligned. Also when entering some random
partition sizes the next partition-start sector is offered 8 sectors
aligned after this patch. (Please note that with fdisk the user
can still enter bad values, only the offered default values will
be correct)
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
drivers/block/brd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index a7463c959..0026998 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -486,10 +486,17 @@ static struct brd_device *brd_alloc(int i)
brd->brd_queue = blk_alloc_queue(GFP_KERNEL);
if (!brd->brd_queue)
goto out_free_dev;
+
blk_queue_make_request(brd->brd_queue, brd_make_request);
blk_queue_max_hw_sectors(brd->brd_queue, 1024);
blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY);
+ /* This is so fdisk will align partitions on 4k, because of
+ * direct_access API needing 4k alignment, returning a PFN
+ */
+ blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE);
+ brd->brd_queue->limits.io_min = 512; /* Don't use the accessor */
+
brd->brd_queue->limits.discard_granularity = PAGE_SIZE;
brd->brd_queue->limits.max_discard_sectors = UINT_MAX;
brd->brd_queue->limits.discard_zeroes_data = 1;
--
1.9.3
next prev parent reply other threads:[~2014-11-05 14:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 14:00 [PATCHSET 0/5 v3] brd: partition fixes Boaz Harrosh
2014-11-05 14:01 ` [PATCH 1/5] axonram: Fix bug in direct_access Boaz Harrosh
2014-11-05 14:02 ` [PATCH 2/5] block: Change direct_access calling convention Boaz Harrosh
2014-11-05 14:04 ` [PATCH 3/5] brd: Fix all partitions BUGs Boaz Harrosh
2014-11-05 14:08 ` Boaz Harrosh [this message]
2014-11-05 14:20 ` [PATCH 4/5] brd: Request from fdisk 4k alignment Martin K. Petersen
2014-11-05 14:43 ` Boaz Harrosh
2014-11-06 17:25 ` Martin K. Petersen
2014-11-07 9:10 ` Karel Zak
2014-11-09 17:52 ` Boaz Harrosh
2014-11-10 17:00 ` Martin K. Petersen
2014-11-05 14:10 ` [PATCH 5/5] brd: Add getgeo to block ops for fdisk Boaz Harrosh
2014-11-05 15:14 ` [PATCH 5/5 v4] " Boaz Harrosh
2014-11-05 15:18 ` Boaz Harrosh
2014-11-07 9:23 ` [PATCH 5/5] " Karel Zak
2014-11-09 16:57 ` Boaz Harrosh
2014-11-10 9:58 ` Karel Zak
2014-11-10 11:15 ` Boaz Harrosh
2014-11-10 13:26 ` Karel Zak
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=545A2F52.3040303@plexistor.com \
--to=boaz@plexistor.com \
--cc=axboe@fb.com \
--cc=dmonakhov@openvz.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@linux.intel.com \
/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.