[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <20080317172254.GF3542@webber.adilger.int>
Date: Tue, 18 Mar 2008 01:22:54 +0800
From: Andreas Dilger <adilger@....com>
To: "Theodore Ts'o" <tytso@....edu>
Cc: linux-ext4@...r.kernel.org, "Jose R. Santos" <jrs@...ibm.com>,
Andreas Dilger <adilger@...sterfs.com>
Subject: Re: [PATCH, REWORKED 01/11] Add initial checksum support for the
gdt_checksum/uninit_group feature
On Mar 17, 2008 09:28 -0400, Theodore Ts'o wrote:
> +STATIC __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group)
> +{
> + __u16 crc = 0;
> + struct ext2_group_desc *desc;
> +
> + desc = &fs->group_desc[group];
> +
> + if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
> + int offset = offsetof(struct ext2_group_desc, bg_checksum);
> +
> +#ifdef WORDS_BIGENDIAN
> + struct ext2_group_desc swabdesc = *desc;
> +
> + /* Have to swab back to little-endian to do the checksum */
> + ext2fs_swap_group_desc(&swabdesc);
> + desc = &swabdesc;
> +
> + group = ext2fs_swab32(group);
> +#endif
> + crc = crc16(~0, fs->super->s_uuid, sizeof(fs->super->s_uuid));
> + crc = crc16(crc, &group, sizeof(group));
> + crc = crc16(crc, desc, offset);
> + offset += sizeof(desc->bg_checksum); /* skip checksum */
> + assert(offset == sizeof(*desc));
Note that this assertion needs to be removed when the group descriptor
becomes larger, unless ext2_group_desc never changes in the future..
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists