linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: linux-btrfs@vger.kernel.org
Cc: Omar Sandoval <osandov@osandov.com>
Subject: [PATCH v3 1/3] btrfs-progs: use calloc instead of malloc+memset for tree roots
Date: Sun, 13 Sep 2015 23:08:22 -0700	[thread overview]
Message-ID: <0ed7db75e4bebd2b538d7c48c9f43c05c9b14f46.1442210847.git.osandov@osandov.com> (raw)
In-Reply-To: <cover.1442209006.git.osandov@osandov.com>

From: Omar Sandoval <osandov@fb.com>

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 disk-io.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index 1d4889322411..8496aded31c4 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -833,13 +833,13 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr)
 
 	memset(fs_info, 0, sizeof(struct btrfs_fs_info));
 
-	fs_info->tree_root = malloc(sizeof(struct btrfs_root));
-	fs_info->extent_root = malloc(sizeof(struct btrfs_root));
-	fs_info->chunk_root = malloc(sizeof(struct btrfs_root));
-	fs_info->dev_root = malloc(sizeof(struct btrfs_root));
-	fs_info->csum_root = malloc(sizeof(struct btrfs_root));
-	fs_info->quota_root = malloc(sizeof(struct btrfs_root));
-	fs_info->super_copy = malloc(BTRFS_SUPER_INFO_SIZE);
+	fs_info->tree_root = calloc(1, sizeof(struct btrfs_root));
+	fs_info->extent_root = calloc(1, sizeof(struct btrfs_root));
+	fs_info->chunk_root = calloc(1, sizeof(struct btrfs_root));
+	fs_info->dev_root = calloc(1, sizeof(struct btrfs_root));
+	fs_info->csum_root = calloc(1, sizeof(struct btrfs_root));
+	fs_info->quota_root = calloc(1, sizeof(struct btrfs_root));
+	fs_info->super_copy = calloc(1, BTRFS_SUPER_INFO_SIZE);
 
 	if (!fs_info->tree_root || !fs_info->extent_root ||
 	    !fs_info->chunk_root || !fs_info->dev_root ||
@@ -847,14 +847,6 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr)
 	    !fs_info->super_copy)
 		goto free_all;
 
-	memset(fs_info->super_copy, 0, BTRFS_SUPER_INFO_SIZE);
-	memset(fs_info->tree_root, 0, sizeof(struct btrfs_root));
-	memset(fs_info->extent_root, 0, sizeof(struct btrfs_root));
-	memset(fs_info->chunk_root, 0, sizeof(struct btrfs_root));
-	memset(fs_info->dev_root, 0, sizeof(struct btrfs_root));
-	memset(fs_info->csum_root, 0, sizeof(struct btrfs_root));
-	memset(fs_info->quota_root, 0, sizeof(struct btrfs_root));
-
 	extent_io_tree_init(&fs_info->extent_cache);
 	extent_io_tree_init(&fs_info->free_space_cache);
 	extent_io_tree_init(&fs_info->block_group_cache);
-- 
2.5.2


  parent reply	other threads:[~2015-09-14  6:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14  6:04 [PATCH v3 0/9] Btrfs: free space B-tree Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 1/9] Btrfs: add extent buffer bitmap operations Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 2/9] Btrfs: add extent buffer bitmap sanity tests Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 3/9] Btrfs: add helpers for read-only compat bits Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 4/9] Btrfs: refactor caching_thread() Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 5/9] Btrfs: introduce the free space B-tree on-disk format Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 6/9] Btrfs: implement the free space B-tree Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 7/9] Btrfs: add free space tree sanity tests Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 8/9] Btrfs: wire up the free space tree to the extent tree Omar Sandoval
2015-09-14  6:04 ` [PATCH v3 9/9] Btrfs: add free space tree mount option Omar Sandoval
2015-09-14  6:08 ` Omar Sandoval [this message]
2015-09-14  6:08   ` [PATCH v3 2/3] btrfs-progs: add basic awareness of the free space tree Omar Sandoval
2015-09-14  6:08   ` [PATCH v3 3/3] btrfs-progs: check the free space tree in btrfsck Omar Sandoval
2015-09-14 20:05   ` [PATCH v3 1/3] btrfs-progs: use calloc instead of malloc+memset for tree roots David Sterba
2015-09-14 14:51 ` [PATCH v3 0/9] Btrfs: free space B-tree Holger Hoffstätte
2015-09-15  2:56   ` Omar Sandoval
2015-09-14 15:18 ` Austin S Hemmelgarn
2015-09-15  2:56   ` Omar Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0ed7db75e4bebd2b538d7c48c9f43c05c9b14f46.1442210847.git.osandov@osandov.com \
    --to=osandov@osandov.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).