From: Jaegeuk Kim <jaegeuk.kim@samsung.com>
To: Oded Gabbay <ogabbay@advaoptical.com>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH 1/2] lib, mkfs: fix endian conversion for crc calculation
Date: Wed, 19 Jun 2013 21:45:14 +0900 [thread overview]
Message-ID: <1371645914.2072.23.camel@kjgkr> (raw)
In-Reply-To: <1371645828.2072.22.camel@kjgkr>
>From 860da681961e6891d625abffa02d6df7dea4f5b2 Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Date: Wed, 19 Jun 2013 20:49:47 +0900
Subject: [PATCH 1/2] lib, mkfs: fix endian conversion for crc calculation
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Let's store the crc value for the checkpoint blocks with __le32.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
---
include/f2fs_fs.h | 1 +
mkfs/f2fs_format.c | 19 ++++++++-----------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index b4ac876..ad10815 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -124,6 +124,7 @@
#define PAGE_CACHE_SIZE 4096
#define BITS_PER_BYTE 8
#define F2FS_SUPER_MAGIC 0xF2F52010 /* F2FS Magic Number */
+#define CHECKSUM_OFFSET 4092
/* for mkfs */
#define F2FS_MIN_VOLUME_SIZE 104857600
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 8e49ed4..9115520 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -525,7 +525,7 @@ static int f2fs_write_check_point_pack(void)
}
/* 1. cp page 1 of checkpoint pack 1 */
- ckp->checkpoint_ver = 1;
+ ckp->checkpoint_ver = cpu_to_le64(1);
ckp->cur_node_segno[0] =
cpu_to_le32(config.cur_seg[CURSEG_HOT_NODE]);
ckp->cur_node_segno[1] =
@@ -578,12 +578,11 @@ static int f2fs_write_check_point_pack(void)
((le32_to_cpu(super_block.segment_count_nat) / 2) <<
le32_to_cpu(super_block.log_blocks_per_seg)) / 8);
- ckp->checksum_offset = cpu_to_le32(4092);
+ ckp->checksum_offset = cpu_to_le32(CHECKSUM_OFFSET);
- crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, ckp,
- le32_to_cpu(ckp->checksum_offset));
- *((u_int32_t *)((unsigned char *)ckp +
- le32_to_cpu(ckp->checksum_offset))) = crc;
+ crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, ckp, CHECKSUM_OFFSET);
+ *((__le32 *)((unsigned char *)ckp + CHECKSUM_OFFSET)) =
+ cpu_to_le32(crc);
blk_size_bytes = 1 << le32_to_cpu(super_block.log_blocksize);
cp_seg_blk_offset = le32_to_cpu(super_block.segment0_blkaddr);
@@ -690,11 +689,9 @@ static int f2fs_write_check_point_pack(void)
*/
ckp->checkpoint_ver = 0;
- crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, ckp,
- le32_to_cpu(ckp->checksum_offset));
- *((u_int32_t *)((unsigned char *)ckp +
- le32_to_cpu(ckp->checksum_offset))) = crc;
-
+ crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, ckp, CHECKSUM_OFFSET);
+ *((__le32 *)((unsigned char *)ckp + CHECKSUM_OFFSET)) =
+ cpu_to_le32(crc);
cp_seg_blk_offset = (le32_to_cpu(super_block.segment0_blkaddr) +
config.blks_per_seg) *
blk_size_bytes;
--
1.8.3.1.437.g0dbd812
--
Jaegeuk Kim
Samsung
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
next prev parent reply other threads:[~2013-06-19 12:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-16 11:51 [f2fs-dev] Kernel BUG when writing to f2fs drive, PowerPC, SD card, USB3 Oded Gabbay
2013-06-17 7:20 ` Huajun Li
2013-06-17 12:38 ` Oded Gabbay
2013-06-17 12:11 ` Jaegeuk Kim
2013-06-17 14:21 ` [f2fs-dev] [Virus Scan Error!] " Oded Gabbay
2013-06-18 9:44 ` [f2fs-dev] " Oded Gabbay
2013-06-18 12:10 ` Oded Gabbay
2013-06-19 12:43 ` Jaegeuk Kim
2013-06-19 12:45 ` Jaegeuk Kim [this message]
2013-06-19 12:45 ` [f2fs-dev] [PATCH 2/2] mkfs: fix to store __le32 for checkpoint flags Jaegeuk Kim
2013-06-19 12:46 ` [f2fs-dev] [PATCH] f2fs: fix crc endian conversion Jaegeuk Kim
2013-06-19 13:07 ` [f2fs-dev] Kernel BUG when writing to f2fs drive, PowerPC, SD card, USB3 Oded Gabbay
2013-06-20 4:48 ` Oded Gabbay
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=1371645914.2072.23.camel@kjgkr \
--to=jaegeuk.kim@samsung.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=ogabbay@advaoptical.com \
/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).