[PATCH] block: warn when write a bdev which already mounted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux