aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-06-01 13:12:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-06-01 13:12:15 -0400
commit4edebed86690eb8db9af3ab85baf4a34e73266cc (patch)
tree8ab144b08f490f239fa62be52470860c9311664d /include/linux
parent51eab603f5c86dd1eae4c525df3e7f7eeab401d6 (diff)
parent5e44f8c374dc4f8eadf61cd18b2c0d46bc87c1b7 (diff)
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull Ext4 updates from Theodore Ts'o: "The major new feature added in this update is Darrick J Wong's metadata checksum feature, which adds crc32 checksums to ext4's metadata fields. There is also the usual set of cleanups and bug fixes." * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (44 commits) ext4: hole-punch use truncate_pagecache_range jbd2: use kmem_cache_zalloc wrapper instead of flag ext4: remove mb_groups before tearing down the buddy_cache ext4: add ext4_mb_unload_buddy in the error path ext4: don't trash state flags in EXT4_IOC_SETFLAGS ext4: let getattr report the right blocks in delalloc+bigalloc ext4: add missing save_error_info() to ext4_error() ext4: add debugging trigger for ext4_error() ext4: protect group inode free counting with group lock ext4: use consistent ssize_t type in ext4_file_write() ext4: fix format flag in ext4_ext_binsearch_idx() ext4: cleanup in ext4_discard_allocated_blocks() ext4: return ENOMEM when mounts fail due to lack of memory ext4: remove redundundant "(char *) bh->b_data" casts ext4: disallow hard-linked directory in ext4_lookup ext4: fix potential integer overflow in alloc_flex_gd() ext4: remove needs_recovery in ext4_mb_init() ext4: force ro mount if ext4_setup_super() fails ext4: fix potential NULL dereference in ext4_free_inodes_counts() ext4/jbd2: add metadata checksumming to the list of supported features ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/jbd2.h59
-rw-r--r--include/linux/jbd_common.h2
2 files changed, 58 insertions, 3 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 912c30a8ddb1..f334c7fab967 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -31,6 +31,7 @@
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <crypto/hash.h>
34#endif 35#endif
35 36
36#define journal_oom_retry 1 37#define journal_oom_retry 1
@@ -147,12 +148,24 @@ typedef struct journal_header_s
147#define JBD2_CRC32_CHKSUM 1 148#define JBD2_CRC32_CHKSUM 1
148#define JBD2_MD5_CHKSUM 2 149#define JBD2_MD5_CHKSUM 2
149#define JBD2_SHA1_CHKSUM 3 150#define JBD2_SHA1_CHKSUM 3
151#define JBD2_CRC32C_CHKSUM 4
150 152
151#define JBD2_CRC32_CHKSUM_SIZE 4 153#define JBD2_CRC32_CHKSUM_SIZE 4
152 154
153#define JBD2_CHECKSUM_BYTES (32 / sizeof(u32)) 155#define JBD2_CHECKSUM_BYTES (32 / sizeof(u32))
154/* 156/*
155 * Commit block header for storing transactional checksums: 157 * Commit block header for storing transactional checksums:
158 *
159 * NOTE: If FEATURE_COMPAT_CHECKSUM (checksum v1) is set, the h_chksum*
160 * fields are used to store a checksum of the descriptor and data blocks.
161 *
162 * If FEATURE_INCOMPAT_CSUM_V2 (checksum v2) is set, then the h_chksum
163 * field is used to store crc32c(uuid+commit_block). Each journal metadata
164 * block gets its own checksum, and data block checksums are stored in
165 * journal_block_tag (in the descriptor). The other h_chksum* fields are
166 * not used.
167 *
168 * Checksum v1 and v2 are mutually exclusive features.
156 */ 169 */
157struct commit_header { 170struct commit_header {
158 __be32 h_magic; 171 __be32 h_magic;
@@ -175,13 +188,19 @@ struct commit_header {
175typedef struct journal_block_tag_s 188typedef struct journal_block_tag_s
176{ 189{
177 __be32 t_blocknr; /* The on-disk block number */ 190 __be32 t_blocknr; /* The on-disk block number */
178 __be32 t_flags; /* See below */ 191 __be16 t_checksum; /* truncated crc32c(uuid+seq+block) */
192 __be16 t_flags; /* See below */
179 __be32 t_blocknr_high; /* most-significant high 32bits. */ 193 __be32 t_blocknr_high; /* most-significant high 32bits. */
180} journal_block_tag_t; 194} journal_block_tag_t;
181 195
182#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high)) 196#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
183#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t)) 197#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
184 198
199/* Tail of descriptor block, for checksumming */
200struct jbd2_journal_block_tail {
201 __be32 t_checksum; /* crc32c(uuid+descr_block) */
202};
203
185/* 204/*
186 * The revoke descriptor: used on disk to describe a series of blocks to 205 * The revoke descriptor: used on disk to describe a series of blocks to
187 * be revoked from the log 206 * be revoked from the log
@@ -192,6 +211,10 @@ typedef struct jbd2_journal_revoke_header_s
192 __be32 r_count; /* Count of bytes used in the block */ 211 __be32 r_count; /* Count of bytes used in the block */
193} jbd2_journal_revoke_header_t; 212} jbd2_journal_revoke_header_t;
194 213
214/* Tail of revoke block, for checksumming */
215struct jbd2_journal_revoke_tail {
216 __be32 r_checksum; /* crc32c(uuid+revoke_block) */
217};
195 218
196/* Definitions for the journal tag flags word: */ 219/* Definitions for the journal tag flags word: */
197#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */ 220#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
@@ -241,7 +264,10 @@ typedef struct journal_superblock_s
241 __be32 s_max_trans_data; /* Limit of data blocks per trans. */ 264 __be32 s_max_trans_data; /* Limit of data blocks per trans. */
242 265
243/* 0x0050 */ 266/* 0x0050 */
244 __u32 s_padding[44]; 267 __u8 s_checksum_type; /* checksum type */
268 __u8 s_padding2[3];
269 __u32 s_padding[42];
270 __be32 s_checksum; /* crc32c(superblock) */
245 271
246/* 0x0100 */ 272/* 0x0100 */
247 __u8 s_users[16*48]; /* ids of all fs'es sharing the log */ 273 __u8 s_users[16*48]; /* ids of all fs'es sharing the log */
@@ -263,13 +289,15 @@ typedef struct journal_superblock_s
263#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001 289#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
264#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 290#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
265#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004 291#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
292#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
266 293
267/* Features known to this kernel version: */ 294/* Features known to this kernel version: */
268#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM 295#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
269#define JBD2_KNOWN_ROCOMPAT_FEATURES 0 296#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
270#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ 297#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
271 JBD2_FEATURE_INCOMPAT_64BIT | \ 298 JBD2_FEATURE_INCOMPAT_64BIT | \
272 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) 299 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
300 JBD2_FEATURE_INCOMPAT_CSUM_V2)
273 301
274#ifdef __KERNEL__ 302#ifdef __KERNEL__
275 303
@@ -939,6 +967,12 @@ struct journal_s
939 * superblock pointer here 967 * superblock pointer here
940 */ 968 */
941 void *j_private; 969 void *j_private;
970
971 /* Reference to checksum algorithm driver via cryptoapi */
972 struct crypto_shash *j_chksum_driver;
973
974 /* Precomputed journal UUID checksum for seeding other checksums */
975 __u32 j_csum_seed;
942}; 976};
943 977
944/* 978/*
@@ -1268,6 +1302,25 @@ static inline int jbd_space_needed(journal_t *journal)
1268 1302
1269extern int jbd_blocks_per_page(struct inode *inode); 1303extern int jbd_blocks_per_page(struct inode *inode);
1270 1304
1305static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
1306 const void *address, unsigned int length)
1307{
1308 struct {
1309 struct shash_desc shash;
1310 char ctx[crypto_shash_descsize(journal->j_chksum_driver)];
1311 } desc;
1312 int err;
1313
1314 desc.shash.tfm = journal->j_chksum_driver;
1315 desc.shash.flags = 0;
1316 *(u32 *)desc.ctx = crc;
1317
1318 err = crypto_shash_update(&desc.shash, address, length);
1319 BUG_ON(err);
1320
1321 return *(u32 *)desc.ctx;
1322}
1323
1271#ifdef __KERNEL__ 1324#ifdef __KERNEL__
1272 1325
1273#define buffer_trace_init(bh) do {} while (0) 1326#define buffer_trace_init(bh) do {} while (0)
diff --git a/include/linux/jbd_common.h b/include/linux/jbd_common.h
index 6230f8556a4e..6133679bc4c0 100644
--- a/include/linux/jbd_common.h
+++ b/include/linux/jbd_common.h
@@ -12,6 +12,7 @@ enum jbd_state_bits {
12 BH_State, /* Pins most journal_head state */ 12 BH_State, /* Pins most journal_head state */
13 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */ 13 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
14 BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */ 14 BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */
15 BH_Verified, /* Metadata block has been verified ok */
15 BH_JBDPrivateStart, /* First bit available for private use by FS */ 16 BH_JBDPrivateStart, /* First bit available for private use by FS */
16}; 17};
17 18
@@ -24,6 +25,7 @@ TAS_BUFFER_FNS(Revoked, revoked)
24BUFFER_FNS(RevokeValid, revokevalid) 25BUFFER_FNS(RevokeValid, revokevalid)
25TAS_BUFFER_FNS(RevokeValid, revokevalid) 26TAS_BUFFER_FNS(RevokeValid, revokevalid)
26BUFFER_FNS(Freed, freed) 27BUFFER_FNS(Freed, freed)
28BUFFER_FNS(Verified, verified)
27 29
28static inline struct buffer_head *jh2bh(struct journal_head *jh) 30static inline struct buffer_head *jh2bh(struct journal_head *jh)
29{ 31{