From patchwork Mon Nov 28 23:27:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 128104 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B0C5BB6F7B for ; Tue, 29 Nov 2011 10:27:49 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755468Ab1K1X1Q (ORCPT ); Mon, 28 Nov 2011 18:27:16 -0500 Received: from e6.ny.us.ibm.com ([32.97.182.146]:40601 "EHLO e6.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755394Ab1K1X1L (ORCPT ); Mon, 28 Nov 2011 18:27:11 -0500 Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Nov 2011 18:27:10 -0500 Received: from d01relay04.pok.ibm.com ([9.56.227.236]) by e6.ny.us.ibm.com ([192.168.1.106]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Nov 2011 18:27:07 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pASNR7k1311786; Mon, 28 Nov 2011 18:27:07 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pASNR5Ti017802; Mon, 28 Nov 2011 21:27:06 -0200 Received: from elm3c44.beaverton.ibm.com (elm3c44.beaverton.ibm.com [9.47.69.44]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pASNR3kY017689; Mon, 28 Nov 2011 21:27:03 -0200 Subject: [PATCH 07/22] ext4: Create bitmap checksum helper functions To: Andreas Dilger , Theodore Tso , "Darrick J. Wong" From: "Darrick J. Wong" Cc: Sunil Mushran , Martin K Petersen , Greg Freemyer , Amir Goldstein , linux-kernel , Andi Kleen , Mingming Cao , Joel Becker , linux-fsdevel , linux-ext4@vger.kernel.org, Coly Li Date: Mon, 28 Nov 2011 15:27:03 -0800 Message-ID: <20111128232703.19194.55084.stgit@elm3c44.beaverton.ibm.com> In-Reply-To: <20111128232615.19194.80081.stgit@elm3c44.beaverton.ibm.com> References: <20111128232615.19194.80081.stgit@elm3c44.beaverton.ibm.com> User-Agent: StGit/0.15 MIME-Version: 1.0 x-cbid: 11112823-1976-0000-0000-000006F0565A Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org These helper functions will be used to calculate and verify the block and inode bitmap checksums. Signed-off-by: Darrick J. Wong --- fs/ext4/bitmap.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c index fa3af81..285d23a 100644 --- a/fs/ext4/bitmap.c +++ b/fs/ext4/bitmap.c @@ -29,3 +29,16 @@ unsigned int ext4_count_free(struct buffer_head *map, unsigned int numchars) #endif /* EXT4FS_DEBUG */ +static __u32 ext4_bitmap_csum(struct super_block *sb, ext4_group_t group, + struct buffer_head *bh, int sz) +{ + __u32 csum; + struct ext4_sb_info *sbi = EXT4_SB(sb); + + group = cpu_to_le32(group); + csum = ext4_chksum(sbi, sbi->s_uuid_csum, (__u8 *)&group, + sizeof(group)); + csum = ext4_chksum(sbi, csum, (__u8 *)bh->b_data, sz); + + return csum; +}