LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 6/7] omfs: add checksumming routines
@ 2008-04-12 22:58 Bob Copeland
2008-04-13 8:09 ` Christoph Hellwig
0 siblings, 1 reply; 8+ messages in thread
From: Bob Copeland @ 2008-04-12 22:58 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-fsdevel, akpm, Bob Copeland
OMFS checksums the metadata of all filesystem objects. This change adds
the necessary functions to do so.
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
fs/omfs/checksum.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
create mode 100644 fs/omfs/checksum.c
diff --git a/fs/omfs/checksum.c b/fs/omfs/checksum.c
new file mode 100644
index 0000000..cbd0471
--- /dev/null
+++ b/fs/omfs/checksum.c
@@ -0,0 +1,31 @@
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+#include <linux/crc-itu-t.h>
+#include "omfs.h"
+
+/*
+ * Update the header checksums for a dirty inode based on its contents.
+ * Caller is expected to hold the buffer head underlying oi and mark it
+ * dirty.
+ */
+int omfs_update_checksums(struct omfs_inode *oi)
+{
+ int ret = 0;
+ int xor, i, ofs = 0, count;
+ u16 crc = 0;
+ unsigned char *ptr = (unsigned char *) oi;
+
+ count = be32_to_cpu(oi->i_head.h_body_size);
+ ofs = sizeof(struct omfs_header);
+
+ crc = crc_itu_t(crc, ptr + ofs, count);
+ oi->i_head.h_crc = cpu_to_be16(crc);
+
+ xor = ptr[0];
+ for (i = 1; i < OMFS_XOR_COUNT; i++)
+ xor ^= ptr[i];
+
+ oi->i_head.h_check_xor = xor;
+
+ return ret;
+}
--
1.5.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 6/7] omfs: add checksumming routines
2008-04-12 22:58 [PATCH 6/7] omfs: add checksumming routines Bob Copeland
@ 2008-04-13 8:09 ` Christoph Hellwig
0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2008-04-13 8:09 UTC (permalink / raw)
To: Bob Copeland; +Cc: linux-kernel, linux-fsdevel, akpm
On Sat, Apr 12, 2008 at 06:58:40PM -0400, Bob Copeland wrote:
> OMFS checksums the metadata of all filesystem objects. This change adds
> the necessary functions to do so.
Looks good, but do we really need a separate source file for this one
routine?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 6/7] omfs: add checksumming routines
2008-03-27 13:41 ` Sergey Vlasov
2008-03-27 14:34 ` Bob Copeland
@ 2008-03-30 3:30 ` Bob Copeland
1 sibling, 0 replies; 8+ messages in thread
From: Bob Copeland @ 2008-03-30 3:30 UTC (permalink / raw)
To: Sergey Vlasov, Harvey Harrison; +Cc: linux-kernel, linux-fsdevel
Version 2 of this patch, with changes:
- use lib/crc-itu-t.c instead of open-coded version
>From 6ce3bb9ce2faaf937df0ec8e64c39e1adc403b2e Mon Sep 17 00:00:00 2001
From: Bob Copeland <me@bobcopeland.com>
Date: Thu, 27 Mar 2008 17:23:12 -0400
Subject: [PATCH] omfs: add checksumming routines
OMFS checksums the metadata of all filesystem objects. This change adds
the necessary functions to do so.
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
fs/omfs/checksum.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
create mode 100644 fs/omfs/checksum.c
diff --git a/fs/omfs/checksum.c b/fs/omfs/checksum.c
new file mode 100644
index 0000000..cbd0471
--- /dev/null
+++ b/fs/omfs/checksum.c
@@ -0,0 +1,31 @@
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+#include <linux/crc-itu-t.h>
+#include "omfs.h"
+
+/*
+ * Update the header checksums for a dirty inode based on its contents.
+ * Caller is expected to hold the buffer head underlying oi and mark it
+ * dirty.
+ */
+int omfs_update_checksums(struct omfs_inode *oi)
+{
+ int ret = 0;
+ int xor, i, ofs = 0, count;
+ u16 crc = 0;
+ unsigned char *ptr = (unsigned char *) oi;
+
+ count = be32_to_cpu(oi->i_head.h_body_size);
+ ofs = sizeof(struct omfs_header);
+
+ crc = crc_itu_t(crc, ptr + ofs, count);
+ oi->i_head.h_crc = cpu_to_be16(crc);
+
+ xor = ptr[0];
+ for (i = 1; i < OMFS_XOR_COUNT; i++)
+ xor ^= ptr[i];
+
+ oi->i_head.h_check_xor = xor;
+
+ return ret;
+}
--
1.5.4.2.182.gb3092
--
Bob Copeland %% www.bobcopeland.com
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 6/7] omfs: add checksumming routines
2008-03-27 13:41 ` Sergey Vlasov
@ 2008-03-27 14:34 ` Bob Copeland
2008-03-30 3:30 ` Bob Copeland
1 sibling, 0 replies; 8+ messages in thread
From: Bob Copeland @ 2008-03-27 14:34 UTC (permalink / raw)
To: Sergey Vlasov; +Cc: linux-kernel, linux-fsdevel, harvey.harrison
On Thu, Mar 27, 2008 at 9:41 AM, Sergey Vlasov <vsu@altlinux.ru> wrote:
> On Wed, 26 Mar 2008 20:45:59 -0400 Bob Copeland wrote:
> > +static u16 omfs_crc(u16 crc, unsigned char *buf, int count)
>
> Is this the same as crc_itu_t() from lib/crc-itu-t.c (also duplicated
> in fs/udf/crc.c)?
Ah, thanks, that is the one. I'll update the patch.
-Bob
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 6/7] omfs: add checksumming routines
2008-03-27 0:45 Bob Copeland
2008-03-27 1:22 ` Harvey Harrison
@ 2008-03-27 13:41 ` Sergey Vlasov
2008-03-27 14:34 ` Bob Copeland
2008-03-30 3:30 ` Bob Copeland
1 sibling, 2 replies; 8+ messages in thread
From: Sergey Vlasov @ 2008-03-27 13:41 UTC (permalink / raw)
To: Bob Copeland; +Cc: linux-kernel, linux-fsdevel
[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]
On Wed, 26 Mar 2008 20:45:59 -0400 Bob Copeland wrote:
> OMFS checksums the metadata of all filesystem objects. This change adds
> the necessary functions to do so.
>
> Signed-off-by: Bob Copeland <me@bobcopeland.com>
> ---
> fs/omfs/checksum.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 48 insertions(+), 0 deletions(-)
> create mode 100644 fs/omfs/checksum.c
>
> diff --git a/fs/omfs/checksum.c b/fs/omfs/checksum.c
> new file mode 100644
> index 0000000..d6f1023
> --- /dev/null
> +++ b/fs/omfs/checksum.c
> @@ -0,0 +1,48 @@
> +#include <linux/fs.h>
> +#include <linux/buffer_head.h>
> +#include "omfs.h"
> +
> +#define POLY 0x1021
> +
> +/*
> + * crc-ccitt with MSB first (i.e., backwards), so we can't use the
> + * kernel table as-is.
> + */
> +static u16 omfs_crc(u16 crc, unsigned char *buf, int count)
> +{
> + int i, j;
> + for (i = 0; i < count; i++) {
> + crc ^= buf[i] << 8;
> + for (j = 0; j < 8; j++)
> + crc = (crc << 1) ^ ((crc & 0x8000) ? POLY : 0);
> + }
> + return crc;
> +}
Is this the same as crc_itu_t() from lib/crc-itu-t.c (also duplicated
in fs/udf/crc.c)?
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 6/7] omfs: add checksumming routines
2008-03-27 1:22 ` Harvey Harrison
@ 2008-03-27 12:24 ` Bob Copeland
0 siblings, 0 replies; 8+ messages in thread
From: Bob Copeland @ 2008-03-27 12:24 UTC (permalink / raw)
To: Harvey Harrison; +Cc: linux-kernel, linux-fsdevel
On Wed, Mar 26, 2008 at 06:22:01PM -0700, Harvey Harrison wrote:
> > +/*
> > + * crc-ccitt with MSB first (i.e., backwards), so we can't use the
> > + * kernel table as-is.
> > + */
>
> Why not just add a be-bitwise table, similar to the crc32_le and
> crc32_be implementation.
Yeah, that is probably a better idea. I didn't do it before since
this lived outside the tree and I didn't want to patch the kernel.
Will that add 1k for everyone?
--
Bob Copeland %% www.bobcopeland.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 6/7] omfs: add checksumming routines
2008-03-27 0:45 Bob Copeland
@ 2008-03-27 1:22 ` Harvey Harrison
2008-03-27 12:24 ` Bob Copeland
2008-03-27 13:41 ` Sergey Vlasov
1 sibling, 1 reply; 8+ messages in thread
From: Harvey Harrison @ 2008-03-27 1:22 UTC (permalink / raw)
To: Bob Copeland; +Cc: linux-kernel, linux-fsdevel
On Wed, 2008-03-26 at 20:45 -0400, Bob Copeland wrote:
> OMFS checksums the metadata of all filesystem objects. This change adds
> the necessary functions to do so.
>
> Signed-off-by: Bob Copeland <me@bobcopeland.com>
> ---
> fs/omfs/checksum.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 48 insertions(+), 0 deletions(-)
> create mode 100644 fs/omfs/checksum.c
>
> diff --git a/fs/omfs/checksum.c b/fs/omfs/checksum.c
> new file mode 100644
> index 0000000..d6f1023
> --- /dev/null
> +++ b/fs/omfs/checksum.c
> @@ -0,0 +1,48 @@
> +#include <linux/fs.h>
> +#include <linux/buffer_head.h>
> +#include "omfs.h"
> +
> +#define POLY 0x1021
> +
> +/*
> + * crc-ccitt with MSB first (i.e., backwards), so we can't use the
> + * kernel table as-is.
> + */
Why not just add a be-bitwise table, similar to the crc32_le and
crc32_be implementation.
Harvey
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6/7] omfs: add checksumming routines
@ 2008-03-27 0:45 Bob Copeland
2008-03-27 1:22 ` Harvey Harrison
2008-03-27 13:41 ` Sergey Vlasov
0 siblings, 2 replies; 8+ messages in thread
From: Bob Copeland @ 2008-03-27 0:45 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-fsdevel, Bob Copeland
OMFS checksums the metadata of all filesystem objects. This change adds
the necessary functions to do so.
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
fs/omfs/checksum.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
create mode 100644 fs/omfs/checksum.c
diff --git a/fs/omfs/checksum.c b/fs/omfs/checksum.c
new file mode 100644
index 0000000..d6f1023
--- /dev/null
+++ b/fs/omfs/checksum.c
@@ -0,0 +1,48 @@
+#include <linux/fs.h>
+#include <linux/buffer_head.h>
+#include "omfs.h"
+
+#define POLY 0x1021
+
+/*
+ * crc-ccitt with MSB first (i.e., backwards), so we can't use the
+ * kernel table as-is.
+ */
+static u16 omfs_crc(u16 crc, unsigned char *buf, int count)
+{
+ int i, j;
+ for (i = 0; i < count; i++) {
+ crc ^= buf[i] << 8;
+ for (j = 0; j < 8; j++)
+ crc = (crc << 1) ^ ((crc & 0x8000) ? POLY : 0);
+ }
+ return crc;
+}
+
+/*
+ * Update the header checksums for a dirty inode based on its contents.
+ * Caller is expected to hold the buffer head underlying oi and mark it
+ * dirty.
+ */
+int omfs_update_checksums(struct omfs_inode *oi, struct super_block *sb,
+ ino_t ino)
+{
+ int ret = 0;
+ int xor, i, ofs = 0, count;
+ u16 crc = 0;
+ unsigned char *ptr = (unsigned char *) oi;
+
+ count = be32_to_cpu(oi->i_head.h_body_size);
+ ofs = sizeof(struct omfs_header);
+
+ crc = omfs_crc(crc, ptr + ofs, count);
+ oi->i_head.h_crc = cpu_to_be16(crc);
+
+ xor = ptr[0];
+ for (i = 1; i < OMFS_XOR_COUNT; i++)
+ xor ^= ptr[i];
+
+ oi->i_head.h_check_xor = xor;
+
+ return ret;
+}
--
1.5.4.2.182.gb3092
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-04-13 8:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-12 22:58 [PATCH 6/7] omfs: add checksumming routines Bob Copeland
2008-04-13 8:09 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2008-03-27 0:45 Bob Copeland
2008-03-27 1:22 ` Harvey Harrison
2008-03-27 12:24 ` Bob Copeland
2008-03-27 13:41 ` Sergey Vlasov
2008-03-27 14:34 ` Bob Copeland
2008-03-30 3:30 ` Bob Copeland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).