All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Reardon <joel@clambassador.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [patch] Move CRC computation to separate function
Date: Sun, 25 Mar 2012 22:38:34 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1203252234440.5527@eristoteles.iwoars.net> (raw)
In-Reply-To: <1332521515.22278.2.camel@sauron.fi.intel.com>

CRC computation now an inline header function which will be used in
multiple places in the future.

--

Signed-off-by: Joel Reardon <reardonj@inf.ethz.ch>

 fs/ubifs/io.c   |    4 +---
 fs/ubifs/misc.h |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index 9228950..103532e 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -379,7 +379,6 @@ static unsigned long long next_sqnum(struct ubifs_info *c)
  */
 void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad)
 {
-	uint32_t crc;
 	struct ubifs_ch *ch = node;
 	unsigned long long sqnum = next_sqnum(c);

@@ -390,8 +389,7 @@ void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad)
 	ch->group_type = UBIFS_NO_NODE_GROUP;
 	ch->sqnum = cpu_to_le64(sqnum);
 	ch->padding[0] = ch->padding[1] = 0;
-	crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
-	ch->crc = cpu_to_le32(crc);
+	ubifs_set_node_crc(node);

 	if (pad) {
 		len = ALIGN(len, 8);
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
index ee7cb5e..ffda6a5 100644
--- a/fs/ubifs/misc.h
+++ b/fs/ubifs/misc.h
@@ -27,6 +27,9 @@
 #ifndef __UBIFS_MISC_H__
 #define __UBIFS_MISC_H__

+#include <linux/crc32.h>
+#include "ubifs-media.h"
+
 /**
  * ubifs_zn_dirty - check if znode is dirty.
  * @znode: znode to check
@@ -300,4 +303,16 @@ static inline int ubifs_next_log_lnum(const struct ubifs_info *c, int lnum)
 	return lnum;
 }

+/**
+ * ubifs_set_crc - computes and writes the crc for a ubifs node to the common
+ * header.
+ * @node: the data node
+ */
+static inline void ubifs_set_node_crc(void *node)
+{
+	struct ubifs_ch *ch = (struct ubifs_ch *) node;
+	int len = le32_to_cpu(ch->len);
+	ch->crc = cpu_to_le32(crc32(UBIFS_CRC32_INIT, node + 8, len - 8));
+}
+
 #endif /* __UBIFS_MISC_H__ */
-- 
1.7.1


WARNING: multiple messages have this Message-ID (diff)
From: Joel Reardon <joel@clambassador.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] Move CRC computation to separate function
Date: Sun, 25 Mar 2012 22:38:34 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1203252234440.5527@eristoteles.iwoars.net> (raw)
In-Reply-To: <1332521515.22278.2.camel@sauron.fi.intel.com>

CRC computation now an inline header function which will be used in
multiple places in the future.

--

Signed-off-by: Joel Reardon <reardonj@inf.ethz.ch>

 fs/ubifs/io.c   |    4 +---
 fs/ubifs/misc.h |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index 9228950..103532e 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -379,7 +379,6 @@ static unsigned long long next_sqnum(struct ubifs_info *c)
  */
 void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad)
 {
-	uint32_t crc;
 	struct ubifs_ch *ch = node;
 	unsigned long long sqnum = next_sqnum(c);

@@ -390,8 +389,7 @@ void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad)
 	ch->group_type = UBIFS_NO_NODE_GROUP;
 	ch->sqnum = cpu_to_le64(sqnum);
 	ch->padding[0] = ch->padding[1] = 0;
-	crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
-	ch->crc = cpu_to_le32(crc);
+	ubifs_set_node_crc(node);

 	if (pad) {
 		len = ALIGN(len, 8);
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
index ee7cb5e..ffda6a5 100644
--- a/fs/ubifs/misc.h
+++ b/fs/ubifs/misc.h
@@ -27,6 +27,9 @@
 #ifndef __UBIFS_MISC_H__
 #define __UBIFS_MISC_H__

+#include <linux/crc32.h>
+#include "ubifs-media.h"
+
 /**
  * ubifs_zn_dirty - check if znode is dirty.
  * @znode: znode to check
@@ -300,4 +303,16 @@ static inline int ubifs_next_log_lnum(const struct ubifs_info *c, int lnum)
 	return lnum;
 }

+/**
+ * ubifs_set_crc - computes and writes the crc for a ubifs node to the common
+ * header.
+ * @node: the data node
+ */
+static inline void ubifs_set_node_crc(void *node)
+{
+	struct ubifs_ch *ch = (struct ubifs_ch *) node;
+	int len = le32_to_cpu(ch->len);
+	ch->crc = cpu_to_le32(crc32(UBIFS_CRC32_INIT, node + 8, len - 8));
+}
+
 #endif /* __UBIFS_MISC_H__ */
-- 
1.7.1

  reply	other threads:[~2012-03-25 20:38 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09 15:24 [patch] Adding Secure Deletion to UBIFS Joel Reardon
2012-02-09 15:24 ` Joel Reardon
2012-02-09 15:24 ` Joel Reardon
2012-02-13 16:54 ` Artem Bityutskiy
2012-02-13 16:54   ` Artem Bityutskiy
2012-02-23 14:59   ` Joel Reardon
2012-02-23 14:59     ` Joel Reardon
2012-02-23 15:29     ` [patch] Add encryption key parameter to compress/decompress functions Joel Reardon
2012-02-23 15:29       ` Joel Reardon
2012-03-09  7:17       ` Artem Bityutskiy
2012-03-09  7:17         ` Artem Bityutskiy
2012-03-19 16:54         ` [patch] Add design document for UBIFS secure deletion Joel Reardon
2012-03-19 16:54           ` Joel Reardon
2012-03-20 20:10           ` Randy Dunlap
2012-03-20 20:10             ` Randy Dunlap
2012-03-21 13:26             ` Joel Reardon
2012-03-21 13:26               ` Joel Reardon
2012-03-21 16:20               ` Artem Bityutskiy
2012-03-21 16:20                 ` Artem Bityutskiy
2012-03-21 16:10           ` Artem Bityutskiy
2012-03-21 16:10             ` Artem Bityutskiy
2012-03-23 13:50             ` Joel Reardon
2012-03-23 13:50               ` Joel Reardon
2012-03-23 15:38               ` Artem Bityutskiy
2012-03-23 15:38                 ` Artem Bityutskiy
2012-03-23 16:38                 ` Joel Reardon
2012-03-23 16:38                   ` Joel Reardon
2012-03-26 15:03                   ` Artem Bityutskiy
2012-03-26 15:03                     ` Artem Bityutskiy
2012-02-29 17:09     ` [patch] Adding Secure Deletion to UBIFS Artem Bityutskiy
2012-02-29 17:09       ` Artem Bityutskiy
2012-03-15 14:48     ` [patch] Remove notion of key schemes Joel Reardon
2012-03-15 14:48       ` Joel Reardon
2012-03-16 12:43       ` Artem Bityutskiy
2012-03-16 12:43         ` Artem Bityutskiy
2012-03-16 12:51       ` Artem Bityutskiy
2012-03-16 12:51         ` Artem Bityutskiy
2012-03-16 13:34         ` Joel Reardon
2012-03-16 13:34           ` Joel Reardon
2012-03-16 13:41           ` Artem Bityutskiy
2012-03-16 13:41             ` Artem Bityutskiy
2012-03-16 15:02             ` Joel Reardon
2012-03-16 15:02               ` Joel Reardon
2012-03-19 14:56               ` Artem Bityutskiy
2012-03-19 14:56                 ` Artem Bityutskiy
2012-02-20 20:15 ` [patch] Move CRC computation to separate function Joel Reardon
2012-02-20 20:15   ` Joel Reardon
2012-02-29 16:10   ` Artem Bityutskiy
2012-02-29 16:10     ` Artem Bityutskiy
2012-03-19 22:46     ` Joel Reardon
2012-03-19 22:46       ` Joel Reardon
2012-03-23 14:09       ` Artem Bityutskiy
2012-03-23 14:09         ` Artem Bityutskiy
2012-03-23 16:45         ` Joel Reardon
2012-03-23 16:45           ` Joel Reardon
2012-03-23 16:51           ` Artem Bityutskiy
2012-03-23 16:51             ` Artem Bityutskiy
2012-03-25 20:38             ` Joel Reardon [this message]
2012-03-25 20:38               ` Joel Reardon
2012-03-26 15:34               ` Artem Bityutskiy
2012-03-26 15:34                 ` Artem Bityutskiy
2012-03-25 21:11             ` [patch] Add a encryption key parameter to the compress / decompress function Joel Reardon
2012-03-25 21:11               ` Joel Reardon
2012-03-25 21:38               ` [patch] Add cryptographic functionality when a key is passed to the compress / decompress functions Joel Reardon
2012-03-25 21:38                 ` Joel Reardon
2012-03-27  8:33                 ` Artem Bityutskiy
2012-03-27  8:33                   ` Artem Bityutskiy
2012-03-29 14:39                   ` [patch] UBIFS: " Joel Reardon
2012-03-29 14:39                     ` Joel Reardon
2012-04-02 14:36                     ` Artem Bityutskiy
2012-04-02 14:36                       ` Artem Bityutskiy
2012-04-02 14:48                       ` Joel Reardon
2012-04-02 14:48                         ` Joel Reardon
2012-04-02 14:57                         ` Artem Bityutskiy
2012-04-02 14:57                           ` Artem Bityutskiy
2012-04-02 14:58                           ` Joel Reardon
2012-04-02 14:58                             ` Joel Reardon
2012-04-03 10:29                           ` Joel Reardon
2012-04-03 10:29                             ` Joel Reardon
2012-04-03 10:41                             ` Guillaume LECERF
2012-04-03 10:41                               ` Guillaume LECERF
2012-04-03 10:41                               ` Guillaume LECERF
2012-04-03 11:35                               ` Joel Reardon
2012-04-03 11:35                                 ` Joel Reardon
2012-04-12 14:05                                 ` Artem Bityutskiy
2012-04-12 14:05                                   ` Artem Bityutskiy
2012-03-27  8:27               ` [patch] Add a encryption key parameter to the compress / decompress function Artem Bityutskiy
2012-03-27  8:27                 ` Artem Bityutskiy
2012-03-29 14:11                 ` [patch] UBIFS: " Joel Reardon
2012-03-29 14:11                   ` Joel Reardon
2012-04-02 14:02                   ` Artem Bityutskiy
2012-04-02 14:02                     ` Artem Bityutskiy
2012-02-29 17:25 ` [patch] Adding Secure Deletion to UBIFS Artem Bityutskiy
2012-02-29 17:25   ` Artem Bityutskiy
2012-03-01 13:41   ` Joel Reardon
2012-03-01 13:41     ` Joel Reardon
2012-03-09  7:36     ` Artem Bityutskiy
2012-03-09  7:36       ` Artem Bityutskiy
2012-03-09 19:29       ` Joel Reardon
2012-03-09 19:29         ` Joel Reardon
2012-03-12 13:30         ` Artem Bityutskiy
2012-03-12 13:30           ` Artem Bityutskiy
2012-03-12 13:34           ` Joel Reardon
2012-03-12 13:34             ` Joel Reardon
2012-03-12 13:36           ` Artem Bityutskiy
2012-03-12 13:36             ` Artem Bityutskiy
2012-03-12 13:37             ` Joel Reardon
2012-03-12 13:37               ` Joel Reardon
2012-03-14 10:20             ` Joel Reardon
2012-03-14 10:20               ` Joel Reardon
2012-03-14 10:27               ` Artem Bityutskiy
2012-03-14 10:27                 ` Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.1203252234440.5527@eristoteles.iwoars.net \
    --to=joel@clambassador.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.