~ubuntu-branches/ubuntu/saucy/linux-ti-omap4/saucy-proposed

« back to all changes in this revision

Viewing changes to fs/ext4/mmp.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Stefan Bader, Upstream Kernel Changes
  • Date: 2012-08-15 17:17:43 UTC
  • Revision ID: package-import@ubuntu.com-20120815171743-h5wnuf51xe7pvdid
Tags: 3.5.0-207.13
[ Paolo Pisati ]

* Start new release

[ Stefan Bader ]

* (config) Enable getabis to use local package copies

[ Upstream Kernel Changes ]

* fixup: gargabe collect iva_seq[0|1] init
* [Config] enable all SND_OMAP_SOC_*s
* fixup: cm2xxx_3xxx.o is needed for omap2_cm_read|write_reg
* fixup: add some snd_soc_dai* helper functions
* fixup: s/snd_soc_dpcm_params/snd_soc_dpcm/g
* fixup: typo, no_host_mode and useless SDP4430 init
* fixup: enable again aess hwmod

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
#include "ext4.h"
8
8
 
 
9
/* Checksumming functions */
 
10
static __u32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
 
11
{
 
12
        struct ext4_sb_info *sbi = EXT4_SB(sb);
 
13
        int offset = offsetof(struct mmp_struct, mmp_checksum);
 
14
        __u32 csum;
 
15
 
 
16
        csum = ext4_chksum(sbi, sbi->s_csum_seed, (char *)mmp, offset);
 
17
 
 
18
        return cpu_to_le32(csum);
 
19
}
 
20
 
 
21
int ext4_mmp_csum_verify(struct super_block *sb, struct mmp_struct *mmp)
 
22
{
 
23
        if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
 
24
                                       EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
 
25
                return 1;
 
26
 
 
27
        return mmp->mmp_checksum == ext4_mmp_csum(sb, mmp);
 
28
}
 
29
 
 
30
void ext4_mmp_csum_set(struct super_block *sb, struct mmp_struct *mmp)
 
31
{
 
32
        if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
 
33
                                       EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
 
34
                return;
 
35
 
 
36
        mmp->mmp_checksum = ext4_mmp_csum(sb, mmp);
 
37
}
 
38
 
9
39
/*
10
40
 * Write the MMP block using WRITE_SYNC to try to get the block on-disk
11
41
 * faster.
12
42
 */
13
 
static int write_mmp_block(struct buffer_head *bh)
 
43
static int write_mmp_block(struct super_block *sb, struct buffer_head *bh)
14
44
{
 
45
        struct mmp_struct *mmp = (struct mmp_struct *)(bh->b_data);
 
46
 
 
47
        ext4_mmp_csum_set(sb, mmp);
15
48
        mark_buffer_dirty(bh);
16
49
        lock_buffer(bh);
17
50
        bh->b_end_io = end_buffer_write_sync;
59
92
        }
60
93
 
61
94
        mmp = (struct mmp_struct *)((*bh)->b_data);
62
 
        if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC)
 
95
        if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC ||
 
96
            !ext4_mmp_csum_verify(sb, mmp))
63
97
                return -EINVAL;
64
98
 
65
99
        return 0;
120
154
                mmp->mmp_time = cpu_to_le64(get_seconds());
121
155
                last_update_time = jiffies;
122
156
 
123
 
                retval = write_mmp_block(bh);
 
157
                retval = write_mmp_block(sb, bh);
124
158
                /*
125
159
                 * Don't spew too many error messages. Print one every
126
160
                 * (s_mmp_update_interval * 60) seconds.
200
234
        mmp->mmp_seq = cpu_to_le32(EXT4_MMP_SEQ_CLEAN);
201
235
        mmp->mmp_time = cpu_to_le64(get_seconds());
202
236
 
203
 
        retval = write_mmp_block(bh);
 
237
        retval = write_mmp_block(sb, bh);
204
238
 
205
239
failed:
206
240
        kfree(data);
299
333
        seq = mmp_new_seq();
300
334
        mmp->mmp_seq = cpu_to_le32(seq);
301
335
 
302
 
        retval = write_mmp_block(bh);
 
336
        retval = write_mmp_block(sb, bh);
303
337
        if (retval)
304
338
                goto failed;
305
339