scoutfs: warn if we try IO outside the device

We've had bugs in allocators that return success and crazy block
numbers.   The bad block numbers eventually make their way down to the
context-free kernel warning that IO was attempted outside the device.
This at least gives us a stack trace to help find where it's coming
from.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2018-06-29 14:42:06 -07:00
committed by Zach Brown
parent 2efba47b77
commit 876414065b
+7
View File
@@ -69,6 +69,7 @@ void scoutfs_bio_submit(struct super_block *sb, int rw, struct page **pages,
{
unsigned int nr_pages = DIV_ROUND_UP(nr_blocks,
SCOUTFS_BLOCKS_PER_PAGE);
struct scoutfs_super_block *super = &SCOUTFS_SB(sb)->super;
struct bio_end_io_args *args;
struct blk_plug plug;
unsigned int bytes;
@@ -77,6 +78,12 @@ void scoutfs_bio_submit(struct super_block *sb, int rw, struct page **pages,
int ret = 0;
int i;
if (super->total_blocks &&
WARN_ON_ONCE(blkno >= le64_to_cpu(super->total_blocks))) {
end_io(sb, data, -EIO);
return;
}
args = kmalloc(sizeof(struct bio_end_io_args), GFP_NOFS);
if (!args) {
end_io(sb, data, -ENOMEM);