Skip to content

Commit 6140ceb

Browse files
Kemeng Shitytso
authored andcommitted
jbd2: remove unneeded check of ret in jbd2_fc_get_buf
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>
1 parent 1862304 commit 6140ceb

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

fs/jbd2/journal.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -837,17 +837,12 @@ int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out)
837837

838838
*bh_out = NULL;
839839

840-
if (journal->j_fc_off + journal->j_fc_first < journal->j_fc_last) {
841-
fc_off = journal->j_fc_off;
842-
blocknr = journal->j_fc_first + fc_off;
843-
journal->j_fc_off++;
844-
} else {
845-
ret = -EINVAL;
846-
}
847-
848-
if (ret)
849-
return ret;
840+
if (journal->j_fc_off + journal->j_fc_first >= journal->j_fc_last)
841+
return -EINVAL;
850842

843+
fc_off = journal->j_fc_off;
844+
blocknr = journal->j_fc_first + fc_off;
845+
journal->j_fc_off++;
851846
ret = jbd2_journal_bmap(journal, blocknr, &pblock);
852847
if (ret)
853848
return ret;
@@ -856,7 +851,6 @@ int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out)
856851
if (!bh)
857852
return -ENOMEM;
858853

859-
860854
journal->j_fc_wbuf[fc_off] = bh;
861855

862856
*bh_out = bh;

0 commit comments

Comments
 (0)