public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: setattr: Forbid setting data journalling when delalloc enabled
@ 2012-01-09 15:45 Lukas Czerner
  2012-01-09 15:55 ` Ted Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Lukas Czerner @ 2012-01-09 15:45 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, Lukas Czerner

Ext4 does not support data journalling with delayed allocation enabled.
We even does not allow to mount the file system with delayed allocation
and data journalling enabled, but it can be set via FS_IOC_SETFLAGS
which is wrong.

When data journalling and delayed allocation is enabled it can lead to
troubles. Here is one example how to reproduce an oops:

 mkfs.ext4 /dev/sdd
 mount /dev/sdd /mnt/test1
 dd if=/dev/zero of=/mnt/test1/file bs=1M count=4
 chattr +j /mnt/test1/file
 dd if=/dev/zero of=/mnt/test1/file bs=1M count=4 conv=notrunc
 chattr -j /mnt/test1/file

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/ext4/ioctl.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index a567968..f1b8226 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -126,7 +126,21 @@ flags_err:
 		if (err)
 			goto flags_out;
 
+		/*
+		 * We absolutely can not journal data when delayed allocation
+		 * is enabled. This is not possible to do via mount option
+		 * and it should not be possible to do via setattr as well.
+		 * Delayed allocation with data=journal is simply not
+		 * supported.
+		 */
 		if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
+			if (test_opt(sb, DELALLOC)) {
+				ext4_msg(sb, KERN_ERR,
+					 "Data journalling not supported "
+					 "with delayed allocation.");
+				err = -EOPNOTSUPP;
+				goto flags_out;
+			}
 			err = ext4_change_inode_journal_flag(inode, jflag);
 		if (err)
 			goto flags_out;
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-09 16:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-09 15:45 [PATCH] ext4: setattr: Forbid setting data journalling when delalloc enabled Lukas Czerner
2012-01-09 15:55 ` Ted Ts'o
2012-01-09 16:22   ` Lukas Czerner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox