|
@@ -4694,16 +4694,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
|
|
inode, bh, block);
|
|
inode, bh, block);
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
- * We need to make sure we don't reuse the freed block until
|
|
|
|
- * after the transaction is committed, which we can do by
|
|
|
|
- * treating the block as metadata, below. We make an
|
|
|
|
- * exception if the inode is to be written in writeback mode
|
|
|
|
- * since writeback mode has weak data consistency guarantees.
|
|
|
|
- */
|
|
|
|
- if (!ext4_should_writeback_data(inode))
|
|
|
|
- flags |= EXT4_FREE_BLOCKS_METADATA;
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* If the extent to be freed does not begin on a cluster
|
|
* If the extent to be freed does not begin on a cluster
|
|
* boundary, we need to deal with partial clusters at the
|
|
* boundary, we need to deal with partial clusters at the
|
|
@@ -4738,14 +4728,13 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
|
|
|
|
|
|
if (!bh && (flags & EXT4_FREE_BLOCKS_FORGET)) {
|
|
if (!bh && (flags & EXT4_FREE_BLOCKS_FORGET)) {
|
|
int i;
|
|
int i;
|
|
|
|
+ int is_metadata = flags & EXT4_FREE_BLOCKS_METADATA;
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
for (i = 0; i < count; i++) {
|
|
cond_resched();
|
|
cond_resched();
|
|
- bh = sb_find_get_block(inode->i_sb, block + i);
|
|
|
|
- if (!bh)
|
|
|
|
- continue;
|
|
|
|
- ext4_forget(handle, flags & EXT4_FREE_BLOCKS_METADATA,
|
|
|
|
- inode, bh, block + i);
|
|
|
|
|
|
+ if (is_metadata)
|
|
|
|
+ bh = sb_find_get_block(inode->i_sb, block + i);
|
|
|
|
+ ext4_forget(handle, is_metadata, inode, bh, block + i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4819,12 +4808,17 @@ do_more:
|
|
if (err)
|
|
if (err)
|
|
goto error_return;
|
|
goto error_return;
|
|
|
|
|
|
- if ((flags & EXT4_FREE_BLOCKS_METADATA) && ext4_handle_valid(handle)) {
|
|
|
|
|
|
+ /*
|
|
|
|
+ * We need to make sure we don't reuse the freed block until after the
|
|
|
|
+ * transaction is committed. We make an exception if the inode is to be
|
|
|
|
+ * written in writeback mode since writeback mode has weak data
|
|
|
|
+ * consistency guarantees.
|
|
|
|
+ */
|
|
|
|
+ if (ext4_handle_valid(handle) &&
|
|
|
|
+ ((flags & EXT4_FREE_BLOCKS_METADATA) ||
|
|
|
|
+ !ext4_should_writeback_data(inode))) {
|
|
struct ext4_free_data *new_entry;
|
|
struct ext4_free_data *new_entry;
|
|
/*
|
|
/*
|
|
- * blocks being freed are metadata. these blocks shouldn't
|
|
|
|
- * be used until this transaction is committed
|
|
|
|
- *
|
|
|
|
* We use __GFP_NOFAIL because ext4_free_blocks() is not allowed
|
|
* We use __GFP_NOFAIL because ext4_free_blocks() is not allowed
|
|
* to fail.
|
|
* to fail.
|
|
*/
|
|
*/
|