Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp773069imm; Wed, 4 Jul 2018 05:51:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpctfS89bTA1VCWJjeIE27XtvoOnuhnC00iro4aq04sdO7ySCMzuOugMGZdT/1n1KsCBMXEi X-Received: by 2002:a17:902:9f81:: with SMTP id g1-v6mr2005871plq.304.1530708707220; Wed, 04 Jul 2018 05:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530708707; cv=none; d=google.com; s=arc-20160816; b=UXPFD5UMNni4Jumt5oX1VrgQRNgroP1gUw194nnmsmOoe8l8jJke8316IZA6qp3QH6 NZcnIJhGvJygDH/1LfaLDIYWnPyjWrGKDYcP6cNZ7nh6x9LVtYN22gopR+7Yj9dnqaNd iuZ6db6bJd+lzqqsitOXHjUMj1M6+Nf/WkTifDRkthqEfFX5+tszvxI0c6PCEGMbBYOM SWXgQsPTcjczQvm5lz+zzRCbb19edVJv8YZ6ljbVN0z9l6+F/l++ToF2bBdeRKeVNGTs pLE1O4uMrezudbfImIBJvfNB4wgVEczSd0gVbC8WGwTV9NATso8XG625qC7vJoswfySQ TWVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=GtXdumZo1Hd86Sv3mVXFiD33ykWdLyCnmzc0xCFYrhg=; b=pUOywHtdNdatsEjgTzWCsUOXfkJaBK4DA13u71yRVqDG+GdbyfW5SASPOTEXpmV/uH a7jpl35cEa42fnkZmcQ3lVy+ceJJHnFHbNOi04PlFE+/BbwtwkGI/9l9GB1dN+WKKINi cHNB8GzyAyikGN+pyhwopREfQwAyTONLjXP83V72ssotQlqKv11e7im3WO5Tf66OQ4A9 w1xpqNrhYIv2WvUPp0b3Rb59M2IBHV8S+vwvhk33f26TOAcFzCuJm1TYrUH2opQ+LYyP fSFbAeTCvFpbhT2kRnwT5tO0jGyj6Y0apVOii9AGhpsOMoTARxOPAhG1NXAD7WxWU9J1 3O3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12-v6si3398723plt.276.2018.07.04.05.51.32; Wed, 04 Jul 2018 05:51:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753404AbeGDMrb (ORCPT + 99 others); Wed, 4 Jul 2018 08:47:31 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:36905 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934537AbeGDMmW (ORCPT ); Wed, 4 Jul 2018 08:42:22 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fah6m-0001dO-CV; Wed, 04 Jul 2018 14:42:08 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.91) (envelope-from ) id 1fah6l-0005Z1-FS; Wed, 04 Jul 2018 14:42:07 +0200 From: Sascha Hauer To: linux-mtd@lists.infradead.org Cc: David Gstir , Richard Weinberger , kernel@pengutronix.de, linux-kernel@vger.kernel.org, Sascha Hauer Subject: [PATCH 06/25] ubifs: drop write_node Date: Wed, 4 Jul 2018 14:41:18 +0200 Message-Id: <20180704124137.13396-7-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180704124137.13396-1-s.hauer@pengutronix.de> References: <20180704124137.13396-1-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/ubifs/journal.c | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 07b4956e0425..754d969eb27e 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -228,36 +228,6 @@ static int reserve_space(struct ubifs_info *c, int jhead, int len) return err; } -/** - * write_node - write node to a journal head. - * @c: UBIFS file-system description object - * @jhead: journal head - * @node: node to write - * @len: node length - * @lnum: LEB number written is returned here - * @offs: offset written is returned here - * - * This function writes a node to reserved space of journal head @jhead. - * Returns zero in case of success and a negative error code in case of - * failure. - */ -static int write_node(struct ubifs_info *c, int jhead, void *node, int len, - int *lnum, int *offs) -{ - struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf; - - ubifs_assert(jhead != GCHD); - - *lnum = c->jheads[jhead].wbuf.lnum; - *offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used; - - dbg_jnl("jhead %s, LEB %d:%d, len %d", - dbg_jhead(jhead), *lnum, *offs, len); - ubifs_prepare_node(c, node, len, 0); - - return ubifs_wbuf_write_nolock(wbuf, node, len); -} - /** * write_head - write data to a journal head. * @c: UBIFS file-system description object @@ -268,9 +238,9 @@ static int write_node(struct ubifs_info *c, int jhead, void *node, int len, * @offs: offset written is returned here * @sync: non-zero if the write-buffer has to by synchronized * - * This function is the same as 'write_node()' but it does not assume the - * buffer it is writing is a node, so it does not prepare it (which means - * initializing common header and calculating CRC). + * This function writes data to the reserved space of journal head @jhead. + * Returns zero in case of success and a negative error code in case of + * failure. */ static int write_head(struct ubifs_info *c, int jhead, void *buf, int len, int *lnum, int *offs, int sync) @@ -758,7 +728,8 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, if (err) goto out_free; - err = write_node(c, DATAHD, data, dlen, &lnum, &offs); + ubifs_prepare_node(c, data, dlen, 0); + err = write_head(c, DATAHD, data, dlen, &lnum, &offs, 0); if (err) goto out_release; ubifs_wbuf_add_ino_nolock(&c->jheads[DATAHD].wbuf, key_inum(c, key)); -- 2.18.0