Skip to content

Commit dcc5827

Browse files
Ye Bintytso
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent fdc2a3c commit dcc5827

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

fs/ext4/fast_commit.c

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ struct dentry_info_args {
13381338
};
13391339

13401340
static inline void tl_to_darg(struct dentry_info_args *darg,
1341-
struct ext4_fc_tl *tl, u8 *val)
1341+
struct ext4_fc_tl *tl, u8 *val)
13421342
{
13431343
struct ext4_fc_dentry_info fcd;
13441344

@@ -1347,8 +1347,14 @@ static inline void tl_to_darg(struct dentry_info_args *darg,
13471347
darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino);
13481348
darg->ino = le32_to_cpu(fcd.fc_ino);
13491349
darg->dname = val + offsetof(struct ext4_fc_dentry_info, fc_dname);
1350-
darg->dname_len = le16_to_cpu(tl->fc_len) -
1351-
sizeof(struct ext4_fc_dentry_info);
1350+
darg->dname_len = tl->fc_len - sizeof(struct ext4_fc_dentry_info);
1351+
}
1352+
1353+
static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val)
1354+
{
1355+
memcpy(tl, val, EXT4_FC_TAG_BASE_LEN);
1356+
tl->fc_len = le16_to_cpu(tl->fc_len);
1357+
tl->fc_tag = le16_to_cpu(tl->fc_tag);
13521358
}
13531359

13541360
/* Unlink replay function */
@@ -1513,7 +1519,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
15131519
struct ext4_inode *raw_fc_inode;
15141520
struct inode *inode = NULL;
15151521
struct ext4_iloc iloc;
1516-
int inode_len, ino, ret, tag = le16_to_cpu(tl->fc_tag);
1522+
int inode_len, ino, ret, tag = tl->fc_tag;
15171523
struct ext4_extent_header *eh;
15181524

15191525
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,
15381544
if (ret)
15391545
goto out;
15401546

1541-
inode_len = le16_to_cpu(tl->fc_len) - sizeof(struct ext4_fc_inode);
1547+
inode_len = tl->fc_len - sizeof(struct ext4_fc_inode);
15421548
raw_inode = ext4_raw_inode(&iloc);
15431549

15441550
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,
20272033

20282034
state->fc_replay_expected_off++;
20292035
for (cur = start; cur < end;
2030-
cur = cur + EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len)) {
2031-
memcpy(&tl, cur, EXT4_FC_TAG_BASE_LEN);
2036+
cur = cur + EXT4_FC_TAG_BASE_LEN + tl.fc_len) {
2037+
ext4_fc_get_tl(&tl, cur);
20322038
val = cur + EXT4_FC_TAG_BASE_LEN;
20332039
ext4_debug("Scan phase, tag:%s, blk %lld\n",
2034-
tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr);
2035-
switch (le16_to_cpu(tl.fc_tag)) {
2040+
tag2str(tl.fc_tag), bh->b_blocknr);
2041+
switch (tl.fc_tag) {
20362042
case EXT4_FC_TAG_ADD_RANGE:
20372043
memcpy(&ext, val, sizeof(ext));
20382044
ex = (struct ext4_extent *)&ext.fc_ex;
@@ -2052,7 +2058,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
20522058
case EXT4_FC_TAG_PAD:
20532059
state->fc_cur_tag++;
20542060
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
2055-
EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len));
2061+
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
20562062
break;
20572063
case EXT4_FC_TAG_TAIL:
20582064
state->fc_cur_tag++;
@@ -2085,7 +2091,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
20852091
}
20862092
state->fc_cur_tag++;
20872093
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
2088-
EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len));
2094+
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
20892095
break;
20902096
default:
20912097
ret = state->fc_replay_num_tags ?
@@ -2141,19 +2147,18 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
21412147
end = (__u8 *)bh->b_data + journal->j_blocksize - 1;
21422148

21432149
for (cur = start; cur < end;
2144-
cur = cur + EXT4_FC_TAG_BASE_LEN + le16_to_cpu(tl.fc_len)) {
2145-
memcpy(&tl, cur, EXT4_FC_TAG_BASE_LEN);
2150+
cur = cur + EXT4_FC_TAG_BASE_LEN + tl.fc_len) {
2151+
ext4_fc_get_tl(&tl, cur);
21462152
val = cur + EXT4_FC_TAG_BASE_LEN;
21472153

21482154
if (state->fc_replay_num_tags == 0) {
21492155
ret = JBD2_FC_REPLAY_STOP;
21502156
ext4_fc_set_bitmaps_and_counters(sb);
21512157
break;
21522158
}
2153-
ext4_debug("Replay phase, tag:%s\n",
2154-
tag2str(le16_to_cpu(tl.fc_tag)));
2159+
ext4_debug("Replay phase, tag:%s\n", tag2str(tl.fc_tag));
21552160
state->fc_replay_num_tags--;
2156-
switch (le16_to_cpu(tl.fc_tag)) {
2161+
switch (tl.fc_tag) {
21572162
case EXT4_FC_TAG_LINK:
21582163
ret = ext4_fc_replay_link(sb, &tl, val);
21592164
break;
@@ -2174,19 +2179,18 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
21742179
break;
21752180
case EXT4_FC_TAG_PAD:
21762181
trace_ext4_fc_replay(sb, EXT4_FC_TAG_PAD, 0,
2177-
le16_to_cpu(tl.fc_len), 0);
2182+
tl.fc_len, 0);
21782183
break;
21792184
case EXT4_FC_TAG_TAIL:
2180-
trace_ext4_fc_replay(sb, EXT4_FC_TAG_TAIL, 0,
2181-
le16_to_cpu(tl.fc_len), 0);
2185+
trace_ext4_fc_replay(sb, EXT4_FC_TAG_TAIL,
2186+
0, tl.fc_len, 0);
21822187
memcpy(&tail, val, sizeof(tail));
21832188
WARN_ON(le32_to_cpu(tail.fc_tid) != expected_tid);
21842189
break;
21852190
case EXT4_FC_TAG_HEAD:
21862191
break;
21872192
default:
2188-
trace_ext4_fc_replay(sb, le16_to_cpu(tl.fc_tag), 0,
2189-
le16_to_cpu(tl.fc_len), 0);
2193+
trace_ext4_fc_replay(sb, tl.fc_tag, 0, tl.fc_len, 0);
21902194
ret = -ECANCELED;
21912195
break;
21922196
}

0 commit comments

Comments
 (0)