From: Li Zefan <lizf@cn.fujitsu.com>
To: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: Josef Bacik <josef@redhat.com>
Subject: [PATCH] Btrfs: fix byte order issue in free space cache
Date: Wed, 03 Aug 2011 16:12:12 +0800 [thread overview]
Message-ID: <4E3902DC.4010105@cn.fujitsu.com> (raw)
We should convert the generation number to little endian before saving
it to disk.
We've just changed to use the normal checksumming infrastructure for
free space cache, so it's the perfect time to fix this bug.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.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 6377713..9277d65 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -325,7 +325,7 @@ int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
addr = kmap(page);
if (index == 0) {
- u64 *gen;
+ u64 gen;
/*
* We put a bogus crc in the front of the first page in
@@ -335,11 +335,11 @@ int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
addr += sizeof(u64);
offset += sizeof(u64);
- gen = addr;
- if (*gen != BTRFS_I(inode)->generation) {
+ gen = le64_to_cpu(*(__le64 *)addr);
+ if (gen != BTRFS_I(inode)->generation) {
printk(KERN_ERR "btrfs: space cache generation"
" (%llu) does not match inode (%llu)\n",
- (unsigned long long)*gen,
+ (unsigned long long)gen,
(unsigned long long)
BTRFS_I(inode)->generation);
kunmap(page);
@@ -636,7 +636,7 @@ int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
orig = addr = kmap(page);
if (index == 0) {
- u64 *gen;
+ __le64 *gen;
/*
* We're going to put in a bogus crc for this page to
@@ -647,7 +647,7 @@ int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
offset += sizeof(u64);
gen = addr;
- *gen = trans->transid;
+ *gen = cpu_to_le64(trans->transid);
addr += sizeof(u64);
offset += sizeof(u64);
}
--
1.7.3.1
next reply other threads:[~2011-08-03 8:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 8:12 Li Zefan [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-06-16 1:50 [PATCH] Btrfs: fix byte order issue in free space cache Li Zefan
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=4E3902DC.4010105@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=josef@redhat.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).