mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
ext4: factor out ext4_fc_get_tl()
Factor out ext4_fc_get_tl() to fill 'tl' with host byte order. Signed-off-by: Ye Bin <yebin10@huawei.com> Link: https://lore.kernel.org/r/20220924075233.2315259-3-yebin10@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
fdc2a3c75d
commit
dcc5827484
1 changed files with 25 additions and 21 deletions
|
@ -1338,7 +1338,7 @@ struct dentry_info_args {
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void tl_to_darg(struct dentry_info_args *darg,
|
static inline void tl_to_darg(struct dentry_info_args *darg,
|
||||||
struct ext4_fc_tl *tl, u8 *val)
|
struct ext4_fc_tl *tl, u8 *val)
|
||||||
{
|
{
|
||||||
struct ext4_fc_dentry_info fcd;
|
struct ext4_fc_dentry_info fcd;
|
||||||
|
|
||||||
|
@ -1347,8 +1347,14 @@ static inline void tl_to_darg(struct dentry_info_args *darg,
|
||||||
darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino);
|
darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino);
|
||||||
darg->ino = le32_to_cpu(fcd.fc_ino);
|
darg->ino = le32_to_cpu(fcd.fc_ino);
|
||||||
darg->dname = val + offsetof(struct ext4_fc_dentry_info, fc_dname);
|
darg->dname = val + offsetof(struct ext4_fc_dentry_info, fc_dname);
|
||||||
darg->dname_len = le16_to_cpu(tl->fc_len) -
|
darg->dname_len = tl->fc_len - sizeof(struct ext4_fc_dentry_info);
|
||||||
sizeof(struct ext4_fc_dentry_info);
|
}
|
||||||
|
|
||||||
|
static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val)
|
||||||
|
{
|
||||||
|
memcpy(tl, val, EXT4_FC_TAG_BASE_LEN);
|
||||||
|
tl->fc_len = le16_to_cpu(tl->fc_len);
|
||||||
|
tl->fc_tag = le16_to_cpu(tl->fc_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unlink replay function */
|
/* Unlink replay function */
|
||||||
|
@ -1513,7 +1519,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
|
||||||
struct ext4_inode *raw_fc_inode;
|
struct ext4_inode *raw_fc_inode;
|
||||||
struct inode *inode = NULL;
|
struct inode *inode = NULL;
|
||||||
struct ext4_iloc iloc;
|
struct ext4_iloc iloc;
|
||||||
int inode_len, ino, ret, tag = le16_to_cpu(tl->fc_tag);
|
int inode_len, ino, ret, tag = tl->fc_tag;
|
||||||
struct ext4_extent_header *eh;
|
struct ext4_extent_header *eh;
|
||||||
|
|
||||||
memcpy(&fc_inode, val, sizeof(fc_inode));
|
memcpy(&fc_inode, val, sizeof(fc_inode));
|
||||||
|
@ -1538,7 +1544,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
inode_len = le16_to_cpu(tl->fc_len) - sizeof(struct ext4_fc_inode);
|
inode_len = tl->fc_len - sizeof(struct ext4_fc_inode);
|
||||||
raw_inode = ext4_raw_inode(&iloc);
|
raw_inode = ext4_raw_inode(&iloc);
|
||||||
|
|
||||||
memcpy(raw_inode, raw_fc_inode, offsetof(struct ext4_inode, i_block));
|
memcpy(raw_inode, raw_fc_inode, offsetof(struct ext4_inode, i_block));
|
||||||
|
@ -2027,12 +2033,12 @@ static int ext4_fc_replay_scan(journal_t *journal,
|
||||||
|
|
||||||
state->fc_replay_expected_off++;
|
state->fc_replay_expected_off++;
|
||||||
for (cur = start; cur < end;
|
for (cur = start; cur < end;
|
||||||
cur = cur + EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len)) {
|
cur = cur + EXT4_FC_TAG_BASE_LEN + tl.fc_len) {
|
||||||
memcpy(&tl, cur, EXT4_FC_TAG_BASE_LEN);
|
ext4_fc_get_tl(&tl, cur);
|
||||||
val = cur + EXT4_FC_TAG_BASE_LEN;
|
val = cur + EXT4_FC_TAG_BASE_LEN;
|
||||||
ext4_debug("Scan phase, tag:%s, blk %lld\n",
|
ext4_debug("Scan phase, tag:%s, blk %lld\n",
|
||||||
tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr);
|
tag2str(tl.fc_tag), bh->b_blocknr);
|
||||||
switch (le16_to_cpu(tl.fc_tag)) {
|
switch (tl.fc_tag) {
|
||||||
case EXT4_FC_TAG_ADD_RANGE:
|
case EXT4_FC_TAG_ADD_RANGE:
|
||||||
memcpy(&ext, val, sizeof(ext));
|
memcpy(&ext, val, sizeof(ext));
|
||||||
ex = (struct ext4_extent *)&ext.fc_ex;
|
ex = (struct ext4_extent *)&ext.fc_ex;
|
||||||
|
@ -2052,7 +2058,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
|
||||||
case EXT4_FC_TAG_PAD:
|
case EXT4_FC_TAG_PAD:
|
||||||
state->fc_cur_tag++;
|
state->fc_cur_tag++;
|
||||||
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
|
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
|
||||||
EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len));
|
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
|
||||||
break;
|
break;
|
||||||
case EXT4_FC_TAG_TAIL:
|
case EXT4_FC_TAG_TAIL:
|
||||||
state->fc_cur_tag++;
|
state->fc_cur_tag++;
|
||||||
|
@ -2085,7 +2091,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
|
||||||
}
|
}
|
||||||
state->fc_cur_tag++;
|
state->fc_cur_tag++;
|
||||||
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
|
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
|
||||||
EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len));
|
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = state->fc_replay_num_tags ?
|
ret = state->fc_replay_num_tags ?
|
||||||
|
@ -2141,8 +2147,8 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
|
||||||
end = (__u8 *)bh->b_data + journal->j_blocksize - 1;
|
end = (__u8 *)bh->b_data + journal->j_blocksize - 1;
|
||||||
|
|
||||||
for (cur = start; cur < end;
|
for (cur = start; cur < end;
|
||||||
cur = cur + EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len)) {
|
cur = cur + EXT4_FC_TAG_BASE_LEN + tl.fc_len) {
|
||||||
memcpy(&tl, cur, EXT4_FC_TAG_BASE_LEN);
|
ext4_fc_get_tl(&tl, cur);
|
||||||
val = cur + EXT4_FC_TAG_BASE_LEN;
|
val = cur + EXT4_FC_TAG_BASE_LEN;
|
||||||
|
|
||||||
if (state->fc_replay_num_tags == 0) {
|
if (state->fc_replay_num_tags == 0) {
|
||||||
|
@ -2150,10 +2156,9 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
|
||||||
ext4_fc_set_bitmaps_and_counters(sb);
|
ext4_fc_set_bitmaps_and_counters(sb);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ext4_debug("Replay phase, tag:%s\n",
|
ext4_debug("Replay phase, tag:%s\n", tag2str(tl.fc_tag));
|
||||||
tag2str(le16_to_cpu(tl.fc_tag)));
|
|
||||||
state->fc_replay_num_tags--;
|
state->fc_replay_num_tags--;
|
||||||
switch (le16_to_cpu(tl.fc_tag)) {
|
switch (tl.fc_tag) {
|
||||||
case EXT4_FC_TAG_LINK:
|
case EXT4_FC_TAG_LINK:
|
||||||
ret = ext4_fc_replay_link(sb, &tl, val);
|
ret = ext4_fc_replay_link(sb, &tl, val);
|
||||||
break;
|
break;
|
||||||
|
@ -2174,19 +2179,18 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
|
||||||
break;
|
break;
|
||||||
case EXT4_FC_TAG_PAD:
|
case EXT4_FC_TAG_PAD:
|
||||||
trace_ext4_fc_replay(sb, EXT4_FC_TAG_PAD, 0,
|
trace_ext4_fc_replay(sb, EXT4_FC_TAG_PAD, 0,
|
||||||
le16_to_cpu(tl.fc_len), 0);
|
tl.fc_len, 0);
|
||||||
break;
|
break;
|
||||||
case EXT4_FC_TAG_TAIL:
|
case EXT4_FC_TAG_TAIL:
|
||||||
trace_ext4_fc_replay(sb, EXT4_FC_TAG_TAIL, 0,
|
trace_ext4_fc_replay(sb, EXT4_FC_TAG_TAIL,
|
||||||
le16_to_cpu(tl.fc_len), 0);
|
0, tl.fc_len, 0);
|
||||||
memcpy(&tail, val, sizeof(tail));
|
memcpy(&tail, val, sizeof(tail));
|
||||||
WARN_ON(le32_to_cpu(tail.fc_tid) != expected_tid);
|
WARN_ON(le32_to_cpu(tail.fc_tid) != expected_tid);
|
||||||
break;
|
break;
|
||||||
case EXT4_FC_TAG_HEAD:
|
case EXT4_FC_TAG_HEAD:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trace_ext4_fc_replay(sb, le16_to_cpu(tl.fc_tag), 0,
|
trace_ext4_fc_replay(sb, tl.fc_tag, 0, tl.fc_len, 0);
|
||||||
le16_to_cpu(tl.fc_len), 0);
|
|
||||||
ret = -ECANCELED;
|
ret = -ECANCELED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue