From patchwork Wed Jan 19 16:58:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 489321 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0JEuJEQ010815 for ; Wed, 19 Jan 2011 17:37:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754506Ab1ASQ6n (ORCPT ); Wed, 19 Jan 2011 11:58:43 -0500 Received: from mail-fx0-f46.google.com ([209.85.161.46]:44188 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752437Ab1ASQ6m (ORCPT ); Wed, 19 Jan 2011 11:58:42 -0500 Received: by fxm20 with SMTP id 20so1084738fxm.19 for ; Wed, 19 Jan 2011 08:58:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=Ryq8JTq5K6NVaVFBPA+YXMd0b4dNE8muhCfmqnMKH6I=; b=Gt8SQTcBHDiTZ0uqLeaFmucQpMuL3P4TsHW1VPUXc059wNh2+nCIBshpRk3WF5R8cF sejW7TlmGKPh2HPfzD0Ruk//74HAMNu8WHtvUpvgN4Mmpjp6byZue7ZNXevBthJchPRf AODdw7alOJkpytwlp+fuh39qSc4pf5UpN3SEw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=l8TNnU27mrbFQ9gcNsPuDD1g8t9qiJcE8HsL0jVnbCpsI/x7QAnQG2afycGV91bprU elUVp/rG8iyYK4Yuijo7fD+SEFbA+xGqg9qiPo936TRAOzOlx7q6gdEzVpuaJ2g0L7KT Uod5A0VRxAzdowN8RhxIDcukB8eBr5SAaAt80= Received: by 10.223.83.144 with SMTP id f16mr958773fal.4.1295456317300; Wed, 19 Jan 2011 08:58:37 -0800 (PST) Received: from localhost ([109.110.82.162]) by mx.google.com with ESMTPS id n1sm2674493fam.40.2011.01.19.08.58.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 Jan 2011 08:58:35 -0800 (PST) Date: Wed, 19 Jan 2011 18:58:37 +0200 From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Josef Bacik , Chris Mason , linux-kernel@vger.kernel.org Subject: [PATCH v2] Btrfs: remove unneeded allocation in load_free_space_cache() Message-ID: <20110119165836.GB1358@kwango.lan.net> References: <20110119153436.GA1358@kwango.lan.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110119153436.GA1358@kwango.lan.net> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 19 Jan 2011 17:37:09 +0000 (UTC) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 60d6842..ee0af41 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -215,14 +215,14 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, struct extent_buffer *leaf; struct page *page; struct btrfs_path *path; - u32 *checksums = NULL, *crc; + u32 *crc = NULL; char *disk_crcs = NULL; struct btrfs_key key; struct list_head bitmaps; u64 num_entries; u64 num_bitmaps; u64 generation; - u32 cur_crc = ~(u32)0; + u32 cur_crc; pgoff_t index = 0; unsigned long first_page_offset; int num_checksums; @@ -298,11 +298,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, /* Setup everything for doing checksumming */ num_checksums = i_size_read(inode) / PAGE_CACHE_SIZE; - checksums = crc = kzalloc(sizeof(u32) * num_checksums, GFP_NOFS); - if (!checksums) - goto out; first_page_offset = (sizeof(u32) * num_checksums) + sizeof(u64); - disk_crcs = kzalloc(first_page_offset, GFP_NOFS); + disk_crcs = kzalloc(sizeof(u32) * num_checksums, GFP_NOFS); if (!disk_crcs) goto out; @@ -352,7 +349,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, if (index == 0) { u64 *gen; - memcpy(disk_crcs, addr, first_page_offset); + memcpy(disk_crcs, addr, sizeof(u32) * num_checksums); gen = addr + (sizeof(u32) * num_checksums); if (*gen != BTRFS_I(inode)->generation) { printk(KERN_ERR "btrfs: space cache generation" @@ -467,7 +464,6 @@ next: ret = 1; out: - kfree(checksums); kfree(disk_crcs); iput(inode); return ret;