From: Ilya Dryomov <idryomov@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Josef Bacik <josef@redhat.com>,
Chris Mason <chris.mason@oracle.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] Btrfs: use checksums_len instead of first_page_offset
Date: Wed, 19 Jan 2011 21:19:24 +0200 [thread overview]
Message-ID: <20110119191924.GC1358@kwango.lan.net> (raw)
Minimizes the number of (sizeof(u32) * num_checksums) we have to do,
removes now useless first_page_offset variable.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
fs/btrfs/free-space-cache.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
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) "
--
1.7.2.3
next reply other threads:[~2011-01-19 19:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-19 19:19 Ilya Dryomov [this message]
2011-01-19 20:55 ` [PATCH] Btrfs: use checksums_len instead of first_page_offset Josef Bacik
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=20110119191924.GC1358@kwango.lan.net \
--to=idryomov@gmail.com \
--cc=chris.mason@oracle.com \
--cc=josef@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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