Commit 59fe27c0 authored by Joern Engel's avatar Joern Engel

Limit max_pages for insane devices

Intel SSDs have a limit of 0xffff as queue_max_hw_sectors(q).  Such a
limit may make sense from a hardware pov, but it causes bio_alloc() to
return NULL.
Signed-off-by: default avatarJoern Engel <joern@logfs.org>
parent 49137f2e
...@@ -97,8 +97,10 @@ static int __bdev_writeseg(struct super_block *sb, u64 ofs, pgoff_t index, ...@@ -97,8 +97,10 @@ static int __bdev_writeseg(struct super_block *sb, u64 ofs, pgoff_t index,
unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9); unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
int i; int i;
if (max_pages > BIO_MAX_PAGES)
max_pages = BIO_MAX_PAGES;
bio = bio_alloc(GFP_NOFS, max_pages); bio = bio_alloc(GFP_NOFS, max_pages);
BUG_ON(!bio); /* FIXME: handle this */ BUG_ON(!bio);
for (i = 0; i < nr_pages; i++) { for (i = 0; i < nr_pages; i++) {
if (i >= max_pages) { if (i >= max_pages) {
...@@ -191,8 +193,10 @@ static int do_erase(struct super_block *sb, u64 ofs, pgoff_t index, ...@@ -191,8 +193,10 @@ static int do_erase(struct super_block *sb, u64 ofs, pgoff_t index,
unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9); unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
int i; int i;
if (max_pages > BIO_MAX_PAGES)
max_pages = BIO_MAX_PAGES;
bio = bio_alloc(GFP_NOFS, max_pages); bio = bio_alloc(GFP_NOFS, max_pages);
BUG_ON(!bio); /* FIXME: handle this */ BUG_ON(!bio);
for (i = 0; i < nr_pages; i++) { for (i = 0; i < nr_pages; i++) {
if (i >= max_pages) { if (i >= max_pages) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment