From patchwork Wed Jan 19 19:19:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 489831 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 p0JJTUl3016051 for ; Wed, 19 Jan 2011 19:29:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754662Ab1ASTT1 (ORCPT ); Wed, 19 Jan 2011 14:19:27 -0500 Received: from mail-fx0-f46.google.com ([209.85.161.46]:42179 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754646Ab1ASTTZ (ORCPT ); Wed, 19 Jan 2011 14:19:25 -0500 Received: by fxm20 with SMTP id 20so1224639fxm.19 for ; Wed, 19 Jan 2011 11:19:24 -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:mime-version :content-type:content-disposition:user-agent; bh=twQV6cUlf16dWgRN2ygqOSCHtL1qmHuZAc+6zfOc77A=; b=jyeSU3bjDcBqBsWVZ9pe+MlB4sMzKJcdNhLHGDzpJC9iHesOozMybzEusofAhciL0W ZhcHl+ZkfHUHQJd3dxJ6RJ3NqW0PR931ltuuAUgKqMwnRFnMqadQY6GuPoBeonXCkoA0 2pcwvNKDuru7NCCAB1VYm5OJVvSjtXirtGhK8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=NG4ohmxJFo3Okx/visX8u/uJFkLHWNXRclxmdD5s5guU8NGs49SbD1K0sBUpuIoK/D bnwhhNCLCJfvNwzwvRySgw0kX6cSmXmM7LvQBoky0Om202BC/rNjZBw1zZELO8LG0j1k sQr7P8dByqO9bmCYfnCsT0hm20r+JiiZ2E/ew= Received: by 10.223.116.1 with SMTP id k1mr1061133faq.51.1295464763835; Wed, 19 Jan 2011 11:19:23 -0800 (PST) Received: from localhost ([109.110.82.162]) by mx.google.com with ESMTPS id n2sm2761691fam.28.2011.01.19.11.19.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 Jan 2011 11:19:22 -0800 (PST) Date: Wed, 19 Jan 2011 21:19:24 +0200 From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Josef Bacik , Chris Mason , linux-kernel@vger.kernel.org Subject: [PATCH] Btrfs: use checksums_len instead of first_page_offset Message-ID: <20110119191924.GC1358@kwango.lan.net> MIME-Version: 1.0 Content-Disposition: inline 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 19:29:37 +0000 (UTC) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index ee0af41..46f7541 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -224,7 +224,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, u64 generation; u32 cur_crc; pgoff_t index = 0; - unsigned long first_page_offset; + unsigned long checksums_len; int num_checksums; int ret = 0; @@ -298,8 +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; - first_page_offset = (sizeof(u32) * num_checksums) + sizeof(u64); - disk_crcs = kzalloc(sizeof(u32) * num_checksums, GFP_NOFS); + checksums_len = sizeof(u32) * num_checksums; + disk_crcs = kzalloc(checksums_len, GFP_NOFS); if (!disk_crcs) goto out; @@ -321,7 +321,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, break; if (index == 0) { - start_offset = first_page_offset; + start_offset = checksums_len + sizeof(u64); offset = start_offset; } @@ -349,8 +349,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, if (index == 0) { u64 *gen; - memcpy(disk_crcs, addr, sizeof(u32) * num_checksums); - gen = addr + (sizeof(u32) * num_checksums); + memcpy(disk_crcs, addr, checksums_len); + gen = addr + checksums_len; if (*gen != BTRFS_I(inode)->generation) { printk(KERN_ERR "btrfs: space cache generation" " (%llu) does not match inode (%llu) "