we may write a bdev which already mounted by accidentally, and cause filesystem corrupt, add a warn log to notice user. Signed-off-by: Fengnan Chang <changfengnan@xxxxxxxxxxxxx> --- block/fops.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/fops.c b/block/fops.c index a286bf3325c5..5b679ad48df4 100644 --- a/block/fops.c +++ b/block/fops.c @@ -563,6 +563,11 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) if ((iocb->ki_flags & (IOCB_NOWAIT | IOCB_DIRECT)) == IOCB_NOWAIT) return -EOPNOTSUPP; + if (bdev->bd_super) + pr_warn_once("warn:try write bdev %s, which already mount with %s!!\n", + bdev->bd_disk->disk_name, + bdev->bd_super->s_type->name); + size -= iocb->ki_pos; if (iov_iter_count(from) > size) { shorted = iov_iter_count(from) - size; -- 2.20.1