btrfs: preallocate path for snapshot creation at ioctl time
We can also preallocate btrfs_path that's used during pending snapshot
creation and avoid another late ENOMEM failure.
Signed-off-by: David Sterba <dsterba@suse.com>
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 2074106..be463b7 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1319,11 +1319,8 @@
u64 root_flags;
uuid_le new_uuid;
- path = btrfs_alloc_path();
- if (!path) {
- pending->error = -ENOMEM;
- return 0;
- }
+ ASSERT(pending->path);
+ path = pending->path;
ASSERT(pending->root_item);
new_root_item = pending->root_item;
@@ -1561,6 +1558,8 @@
kfree(new_root_item);
pending->root_item = NULL;
btrfs_free_path(path);
+ pending->path = NULL;
+
return ret;
}