Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2015671imm; Fri, 7 Sep 2018 09:31:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaWiSM6MqwthYLAU1PSce8i4eSjjnagFMXvmOKtMGpYBtnHFuiueoru7Wg0RL6ouh6CRkOQ X-Received: by 2002:a65:5c4b:: with SMTP id v11-v6mr8870531pgr.98.1536337885185; Fri, 07 Sep 2018 09:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536337885; cv=none; d=google.com; s=arc-20160816; b=xO+EPS3HH4MbpAPRt3SJPw6Pcigcm0U7FfsajAo9ia8HRAOg4nE6uSxblttzCYQ36s Tt4ISV4GrzkSD4L5mWmfZrNwK7HfChjGQxrrlBCbj/WXjBHD6FZ+9mnAEUUZUFxlI4kR qs/5eIHa0D61x5zpb+Gxdq/p7nGhkTWUNF1PMJPC1AIYlXC+1AyI3hTVAmLfAVz1patb CXEuq0FD2Zh2WMJZiJiNb8RKC7021gzf7L8RSlPqM1r3n/mD6QrMU74geF4W2Ps6YDrW AYYcBo1MXZiYx3VmBCxkbh3+gBMN7LNlnnxoyT3QoYf1t/useSaKyc2HG5HzcbOvvFd5 IPtQ== 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; bh=kMekEpNzpvYZt4HtG3jgRQ35A9dfnIQDvHiXxpfQ+eI=; b=KxPWGbTbwOScKPCP8ugzxSkDG391J/UmKRT7/RdvWV+PC4T53VvVLAcCyAQOaaUSHI aBJnek8OKfogIppYQpLR2qSQYQvNNgqr7kxmBS8Iuq34yprf5RpJnYo3C4Dm2o8tFRaX ZxuOqRwW8Z+iVoZlXlaAWR+teybkyZc1VtXHiciq0p32rpz1sypxd0EPR0IzfCf47ycq PNCxCzmecWxtINRQyl+47kIo0xiH8EhtkZBOQKnFOBkPZ8v/rV8MY0ZPn753VqmPxmSF szMONifsB/DEU4HTNWUY3SkhmglMYmBY4XkXH0cmXttXK69lc+2iZGPf1FnZs+tzqFd0 V8dQ== 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 d12-v6si8567099pla.421.2018.09.07.09.31.07; Fri, 07 Sep 2018 09:31:25 -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 S1728707AbeIGRVn (ORCPT + 99 others); Fri, 7 Sep 2018 13:21:43 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:58953 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729213AbeIGRTc (ORCPT ); Fri, 7 Sep 2018 13:19:32 -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 1fyG27-0007bs-DD; Fri, 07 Sep 2018 14:38:43 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.91) (envelope-from ) id 1fyG26-00061x-DA; Fri, 07 Sep 2018 14:38:42 +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 07/25] ubifs: drop write_node Date: Fri, 7 Sep 2018 14:36:28 +0200 Message-Id: <20180907123646.12688-8-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907123646.12688-1-s.hauer@pengutronix.de> References: <20180907123646.12688-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 802565a17733..de7ac9e7acce 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(c, 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) @@ -764,7 +734,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