Skip to content

Commit

Permalink
jbd2: remove unneeded check of ret in jbd2_fc_get_buf
Browse files Browse the repository at this point in the history
Simply return -EINVAL if j_fc_off is invalid to avoid repeated check of
ret.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20240801013815.2393869-9-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
Kemeng Shi authored and tytso committed Aug 27, 2024
1 parent 1862304 commit 6140ceb
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,17 +837,12 @@ int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out)

*bh_out = NULL;

if (journal->j_fc_off + journal->j_fc_first < journal->j_fc_last) {
fc_off = journal->j_fc_off;
blocknr = journal->j_fc_first + fc_off;
journal->j_fc_off++;
} else {
ret = -EINVAL;
}

if (ret)
return ret;
if (journal->j_fc_off + journal->j_fc_first >= journal->j_fc_last)
return -EINVAL;

fc_off = journal->j_fc_off;
blocknr = journal->j_fc_first + fc_off;
journal->j_fc_off++;
ret = jbd2_journal_bmap(journal, blocknr, &pblock);
if (ret)
return ret;
Expand All @@ -856,7 +851,6 @@ int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out)
if (!bh)
return -ENOMEM;


journal->j_fc_wbuf[fc_off] = bh;

*bh_out = bh;
Expand Down

0 comments on commit 6140ceb

Please sign in to comment.