From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: Chao Yu <chao@kernel.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: use crc and cp version to determine roll-forward recovery
Date: Sat, 24 Sep 2016 11:20:11 -0700 [thread overview]
Message-ID: <20160924182011.GC25123@jaegeuk> (raw)
In-Reply-To: <64ec1af3-f9ca-77ce-9f99-3ceaee48e9f8@huawei.com>
On Sat, Sep 24, 2016 at 02:00:41PM +0800, Chao Yu wrote:
> On 2016/9/21 8:45, Jaegeuk Kim wrote:
> > @@ -259,40 +290,26 @@ static inline void fill_node_footer_blkaddr(struct page *page, block_t blkaddr)
> > {
> > struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
> > struct f2fs_node *rn = F2FS_NODE(page);
> > + size_t crc_offset = le32_to_cpu(ckpt->checksum_offset);
> > + __u64 cp_ver = le64_to_cpu(ckpt->checkpoint_ver);
> > + __u64 crc;
> >
> > - rn->footer.cp_ver = ckpt->checkpoint_ver;
> > + crc = le32_to_cpu(*((__le32 *)((unsigned char *)ckpt + crc_offset)));
> > + cp_ver |= (crc << 32);
>
> How about using '^=' here?
The crc is already random enough, but has 32bits only.
The cp_ver is not easy to use over 32bits, so we don't need to keep the other
32bits untouched in most of life.
Thanks,
>
> > + rn->footer.cp_ver = cpu_to_le64(cp_ver);
> > rn->footer.next_blkaddr = cpu_to_le32(blkaddr);
> > }
> >
> > -static inline nid_t ino_of_node(struct page *node_page)
> > -{
> > - struct f2fs_node *rn = F2FS_NODE(node_page);
> > - return le32_to_cpu(rn->footer.ino);
> > -}
> > -
> > -static inline nid_t nid_of_node(struct page *node_page)
> > -{
> > - struct f2fs_node *rn = F2FS_NODE(node_page);
> > - return le32_to_cpu(rn->footer.nid);
> > -}
> > -
> > -static inline unsigned int ofs_of_node(struct page *node_page)
> > -{
> > - struct f2fs_node *rn = F2FS_NODE(node_page);
> > - unsigned flag = le32_to_cpu(rn->footer.flag);
> > - return flag >> OFFSET_BIT_SHIFT;
> > -}
> > -
> > -static inline unsigned long long cpver_of_node(struct page *node_page)
> > +static inline bool is_recoverable_dnode(struct page *page)
> > {
> > - struct f2fs_node *rn = F2FS_NODE(node_page);
> > - return le64_to_cpu(rn->footer.cp_ver);
> > -}
> > + struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
> > + size_t crc_offset = le32_to_cpu(ckpt->checksum_offset);
> > + __u64 cp_ver = cur_cp_version(ckpt);
> > + __u64 crc;
> >
> > -static inline block_t next_blkaddr_of_node(struct page *node_page)
> > -{
> > - struct f2fs_node *rn = F2FS_NODE(node_page);
> > - return le32_to_cpu(rn->footer.next_blkaddr);
> > + crc = le32_to_cpu(*((__le32 *)((unsigned char *)ckpt + crc_offset)));
> > + cp_ver |= (crc << 32);
> > + return cpu_to_le64(cp_ver) == cpver_of_node(page);
> > }
>
> cpu_to_le64(cp_ver) == cpver_of_node(page) ^ (crc << 32)
>
> Thanks,
next prev parent reply other threads:[~2016-09-24 18:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 2:55 [PATCH 1/2] f2fs: use crc and cp version to determine roll-forward recovery Jaegeuk Kim
2016-09-20 2:55 ` [PATCH 2/2] f2fs: put directory inodes before checkpoint in " Jaegeuk Kim
2016-09-20 15:48 ` [f2fs-dev] [PATCH 1/2] f2fs: use crc and cp version to determine " Chao Yu
2016-09-21 0:45 ` Jaegeuk Kim
2016-09-24 6:00 ` Chao Yu
2016-09-24 18:20 ` Jaegeuk Kim [this message]
2016-09-29 12:01 ` Chao Yu
2016-09-30 0:53 ` Jaegeuk Kim
2016-09-30 1:04 ` Chao Yu
2016-09-30 17:10 ` [PATCH 1/2 v2] " Jaegeuk Kim
2016-10-01 0:26 ` [f2fs-dev] " Chao Yu
2016-10-01 0:54 ` Jaegeuk Kim
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=20160924182011.GC25123@jaegeuk \
--to=jaegeuk@kernel.org \
--cc=chao@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.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).