Skip to content

Commit 8340743

Browse files
saschahauerrichardweinberger
authored andcommitted
ubifs: Drop write_node
write_node() is used only once and can easily be replaced with calls to ubifs_prepare_node()/write_head() which makes the code a bit shorter. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent e635cf8 commit 8340743

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

fs/ubifs/journal.c

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -228,36 +228,6 @@ static int reserve_space(struct ubifs_info *c, int jhead, int len)
228228
return err;
229229
}
230230

231-
/**
232-
* write_node - write node to a journal head.
233-
* @c: UBIFS file-system description object
234-
* @jhead: journal head
235-
* @node: node to write
236-
* @len: node length
237-
* @lnum: LEB number written is returned here
238-
* @offs: offset written is returned here
239-
*
240-
* This function writes a node to reserved space of journal head @jhead.
241-
* Returns zero in case of success and a negative error code in case of
242-
* failure.
243-
*/
244-
static int write_node(struct ubifs_info *c, int jhead, void *node, int len,
245-
int *lnum, int *offs)
246-
{
247-
struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf;
248-
249-
ubifs_assert(c, jhead != GCHD);
250-
251-
*lnum = c->jheads[jhead].wbuf.lnum;
252-
*offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used;
253-
254-
dbg_jnl("jhead %s, LEB %d:%d, len %d",
255-
dbg_jhead(jhead), *lnum, *offs, len);
256-
ubifs_prepare_node(c, node, len, 0);
257-
258-
return ubifs_wbuf_write_nolock(wbuf, node, len);
259-
}
260-
261231
/**
262232
* write_head - write data to a journal head.
263233
* @c: UBIFS file-system description object
@@ -268,9 +238,9 @@ static int write_node(struct ubifs_info *c, int jhead, void *node, int len,
268238
* @offs: offset written is returned here
269239
* @sync: non-zero if the write-buffer has to by synchronized
270240
*
271-
* This function is the same as 'write_node()' but it does not assume the
272-
* buffer it is writing is a node, so it does not prepare it (which means
273-
* initializing common header and calculating CRC).
241+
* This function writes data to the reserved space of journal head @jhead.
242+
* Returns zero in case of success and a negative error code in case of
243+
* failure.
274244
*/
275245
static int write_head(struct ubifs_info *c, int jhead, void *buf, int len,
276246
int *lnum, int *offs, int sync)
@@ -764,7 +734,8 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
764734
if (err)
765735
goto out_free;
766736

767-
err = write_node(c, DATAHD, data, dlen, &lnum, &offs);
737+
ubifs_prepare_node(c, data, dlen, 0);
738+
err = write_head(c, DATAHD, data, dlen, &lnum, &offs, 0);
768739
if (err)
769740
goto out_release;
770741
ubifs_wbuf_add_ino_nolock(&c->jheads[DATAHD].wbuf, key_inum(c, key));

0 commit comments

Comments
 (0)