Skip to contentSkip to conversation

block_dev: Add size check before doing async write on block device.

PATCH In review majianpeng 1 participant 1 message Sep 17, 2013 VFS

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH v2 2/2 block_dev: Add size check before doing async write on block device.

For async-write on block device,when disk removed,the vfs don't know. It will continue do async-write.Add this check it will stop async-write when disk removed.

---
 fs/block_dev.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/block_dev.c +4 -0
index 1173a4e..e308b52 100644
@@ -1514,6 +1514,10 @@ ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
 	struct file *file = iocb->ki_filp;
 	struct blk_plug plug;
 	ssize_t ret;
+	loff_t size = i_size_read(file->f_mapping->host);
+
+	if (pos >= size)
+		return 0;
 
 	BUG_ON(iocb->ki_pos != pos);
 
Signature · 1 line
1.8.4-rc0