Skip to content

Commit 21e75ff

Browse files
jeffmahoneykdave
authored andcommitted
btrfs: btrfs_truncate_free_space_cache always allocates path
btrfs_truncate_free_space_cache always allocates a btrfs_path structure but only uses it when the caller passes a block group. Let's move the allocation and free into the conditional. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 77ab86b commit 21e75ff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/btrfs/free-space-cache.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
232232
{
233233
struct btrfs_root *root = BTRFS_I(inode)->root;
234234
int ret = 0;
235-
struct btrfs_path *path = btrfs_alloc_path();
236235
bool locked = false;
237236

238-
if (!path) {
239-
ret = -ENOMEM;
240-
goto fail;
241-
}
242-
243237
if (block_group) {
238+
struct btrfs_path *path = btrfs_alloc_path();
239+
240+
if (!path) {
241+
ret = -ENOMEM;
242+
goto fail;
243+
}
244244
locked = true;
245245
mutex_lock(&trans->transaction->cache_write_mutex);
246246
if (!list_empty(&block_group->io_list)) {
@@ -257,8 +257,8 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
257257
spin_lock(&block_group->lock);
258258
block_group->disk_cache_state = BTRFS_DC_CLEAR;
259259
spin_unlock(&block_group->lock);
260+
btrfs_free_path(path);
260261
}
261-
btrfs_free_path(path);
262262

263263
btrfs_i_size_write(inode, 0);
264264
truncate_pagecache(inode, 0);

0 commit comments

Comments
 (0)