Parcourir la source

ext4: Get journal write access before modifying the extent tree

When the user was writing into an unitialized extent,
ext4_ext_convert_to_initialize() was not requesting journal write access
before it started to modify the extent tree.   Fix this oversight.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Aneesh Kumar K.V il y a 17 ans
Parent
commit
9df5643ad1
1 fichiers modifiés avec 8 ajouts et 3 suppressions
  1. 8 3
      fs/ext4/extents.c

+ 8 - 3
fs/ext4/extents.c

@@ -2168,6 +2168,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 	newblock = iblock - ee_block + ext_pblock(ex);
 	newblock = iblock - ee_block + ext_pblock(ex);
 	ex2 = ex;
 	ex2 = ex;
 
 
+	err = ext4_ext_get_access(handle, inode, path + depth);
+	if (err)
+		goto out;
+
 	/* ex1: ee_block to iblock - 1 : uninitialized */
 	/* ex1: ee_block to iblock - 1 : uninitialized */
 	if (iblock > ee_block) {
 	if (iblock > ee_block) {
 		ex1 = ex;
 		ex1 = ex;
@@ -2210,6 +2214,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 			ex = path[depth].p_ext;
 			ex = path[depth].p_ext;
 			if (ex2 != &newex)
 			if (ex2 != &newex)
 				ex2 = ex;
 				ex2 = ex;
+
+			err = ext4_ext_get_access(handle, inode, path + depth);
+			if (err)
+				goto out;
 		}
 		}
 		allocated = max_blocks;
 		allocated = max_blocks;
 	}
 	}
@@ -2230,9 +2238,6 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 	ex2->ee_len = cpu_to_le16(allocated);
 	ex2->ee_len = cpu_to_le16(allocated);
 	if (ex2 != ex)
 	if (ex2 != ex)
 		goto insert;
 		goto insert;
-	err = ext4_ext_get_access(handle, inode, path + depth);
-	if (err)
-		goto out;
 	/*
 	/*
 	 * New (initialized) extent starts from the first block
 	 * New (initialized) extent starts from the first block
 	 * in the current extent. i.e., ex2 == ex
 	 * in the current extent. i.e., ex2 == ex