Explorar o código

ext4: Update i_disksize properly when allocating from fallocate area.

When allocating unitialized space at the end of file which had been
preallocated with the FALLOC_FL_KEEP_SIZE option, the file size is not
updated at that time.  But the later we are not updating the file size
when writing to that preallocated space.

These changes are for code correctness.  This patch allows us to update
the i_disksize at the write_end() callback of filesystem properly.

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 %!s(int64=17) %!d(string=hai) anos
pai
achega
a379cd1d6b
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      fs/ext4/extents.c

+ 3 - 3
fs/ext4/extents.c

@@ -2716,13 +2716,13 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
 		goto out2;
 		goto out2;
 	}
 	}
 
 
-	if (extend_disksize && inode->i_size > EXT4_I(inode)->i_disksize)
-		EXT4_I(inode)->i_disksize = inode->i_size;
-
 	/* previous routine could use block we allocated */
 	/* previous routine could use block we allocated */
 	newblock = ext_pblock(&newex);
 	newblock = ext_pblock(&newex);
 	allocated = ext4_ext_get_actual_len(&newex);
 	allocated = ext4_ext_get_actual_len(&newex);
 outnew:
 outnew:
+	if (extend_disksize && inode->i_size > EXT4_I(inode)->i_disksize)
+		EXT4_I(inode)->i_disksize = inode->i_size;
+
 	__set_bit(BH_New, &bh_result->b_state);
 	__set_bit(BH_New, &bh_result->b_state);
 
 
 	/* Cache only when it is _not_ an uninitialized extent */
 	/* Cache only when it is _not_ an uninitialized extent */