diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 20:14:59 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 20:14:59 -0500 |
commit | 2150edc6c5cf00f7adb54538b9ea2a3e9cedca3f (patch) | |
tree | f72a0d85e66f500b4cead348a231e3d3b9f357bc /fs/ext3 | |
parent | cd764695b67386a81964f68e9c66efd9f13f4d29 (diff) | |
parent | 4b905671d2ea09fd48fed72c581df17e40823f39 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (57 commits)
jbd2: Fix oops in jbd2_journal_init_inode() on corrupted fs
ext4: Remove "extents" mount option
block: Add Kconfig help which notes that ext4 needs CONFIG_LBD
ext4: Make printk's consistently prefixed with "EXT4-fs: "
ext4: Add sanity checks for the superblock before mounting the filesystem
ext4: Add mount option to set kjournald's I/O priority
jbd2: Submit writes to the journal using WRITE_SYNC
jbd2: Add pid and journal device name to the "kjournald2 starting" message
ext4: Add markers for better debuggability
ext4: Remove code to create the journal inode
ext4: provide function to release metadata pages under memory pressure
ext3: provide function to release metadata pages under memory pressure
add releasepage hooks to block devices which can be used by file systems
ext4: Fix s_dirty_blocks_counter if block allocation failed with nodelalloc
ext4: Init the complete page while building buddy cache
ext4: Don't allow new groups to be added during block allocation
ext4: mark the blocks/inode bitmap beyond end of group as used
ext4: Use new buffer_head flag to check uninit group bitmaps initialization
ext4: Fix the race between read_inode_bitmap() and ext4_new_inode()
ext4: code cleanup
...
Diffstat (limited to 'fs/ext3')
-rw-r--r-- | fs/ext3/hash.c | 77 | ||||
-rw-r--r-- | fs/ext3/namei.c | 11 | ||||
-rw-r--r-- | fs/ext3/super.c | 33 |
3 files changed, 109 insertions, 12 deletions
diff --git a/fs/ext3/hash.c b/fs/ext3/hash.c index c30e149fbd2e..7d215b4d4f2e 100644 --- a/fs/ext3/hash.c +++ b/fs/ext3/hash.c | |||
@@ -35,23 +35,71 @@ static void TEA_transform(__u32 buf[4], __u32 const in[]) | |||
35 | 35 | ||
36 | 36 | ||
37 | /* The old legacy hash */ | 37 | /* The old legacy hash */ |
38 | static __u32 dx_hack_hash (const char *name, int len) | 38 | static __u32 dx_hack_hash_unsigned(const char *name, int len) |
39 | { | 39 | { |
40 | __u32 hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; | 40 | __u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; |
41 | const unsigned char *ucp = (const unsigned char *) name; | ||
42 | |||
43 | while (len--) { | ||
44 | hash = hash1 + (hash0 ^ (((int) *ucp++) * 7152373)); | ||
45 | |||
46 | if (hash & 0x80000000) | ||
47 | hash -= 0x7fffffff; | ||
48 | hash1 = hash0; | ||
49 | hash0 = hash; | ||
50 | } | ||
51 | return hash0 << 1; | ||
52 | } | ||
53 | |||
54 | static __u32 dx_hack_hash_signed(const char *name, int len) | ||
55 | { | ||
56 | __u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; | ||
57 | const signed char *scp = (const signed char *) name; | ||
58 | |||
41 | while (len--) { | 59 | while (len--) { |
42 | __u32 hash = hash1 + (hash0 ^ (*name++ * 7152373)); | 60 | hash = hash1 + (hash0 ^ (((int) *scp++) * 7152373)); |
43 | 61 | ||
44 | if (hash & 0x80000000) hash -= 0x7fffffff; | 62 | if (hash & 0x80000000) |
63 | hash -= 0x7fffffff; | ||
45 | hash1 = hash0; | 64 | hash1 = hash0; |
46 | hash0 = hash; | 65 | hash0 = hash; |
47 | } | 66 | } |
48 | return (hash0 << 1); | 67 | return hash0 << 1; |
49 | } | 68 | } |
50 | 69 | ||
51 | static void str2hashbuf(const char *msg, int len, __u32 *buf, int num) | 70 | static void str2hashbuf_signed(const char *msg, int len, __u32 *buf, int num) |
52 | { | 71 | { |
53 | __u32 pad, val; | 72 | __u32 pad, val; |
54 | int i; | 73 | int i; |
74 | const signed char *scp = (const signed char *) msg; | ||
75 | |||
76 | pad = (__u32)len | ((__u32)len << 8); | ||
77 | pad |= pad << 16; | ||
78 | |||
79 | val = pad; | ||
80 | if (len > num*4) | ||
81 | len = num * 4; | ||
82 | for (i = 0; i < len; i++) { | ||
83 | if ((i % 4) == 0) | ||
84 | val = pad; | ||
85 | val = ((int) scp[i]) + (val << 8); | ||
86 | if ((i % 4) == 3) { | ||
87 | *buf++ = val; | ||
88 | val = pad; | ||
89 | num--; | ||
90 | } | ||
91 | } | ||
92 | if (--num >= 0) | ||
93 | *buf++ = val; | ||
94 | while (--num >= 0) | ||
95 | *buf++ = pad; | ||
96 | } | ||
97 | |||
98 | static void str2hashbuf_unsigned(const char *msg, int len, __u32 *buf, int num) | ||
99 | { | ||
100 | __u32 pad, val; | ||
101 | int i; | ||
102 | const unsigned char *ucp = (const unsigned char *) msg; | ||
55 | 103 | ||
56 | pad = (__u32)len | ((__u32)len << 8); | 104 | pad = (__u32)len | ((__u32)len << 8); |
57 | pad |= pad << 16; | 105 | pad |= pad << 16; |
@@ -62,7 +110,7 @@ static void str2hashbuf(const char *msg, int len, __u32 *buf, int num) | |||
62 | for (i=0; i < len; i++) { | 110 | for (i=0; i < len; i++) { |
63 | if ((i % 4) == 0) | 111 | if ((i % 4) == 0) |
64 | val = pad; | 112 | val = pad; |
65 | val = msg[i] + (val << 8); | 113 | val = ((int) ucp[i]) + (val << 8); |
66 | if ((i % 4) == 3) { | 114 | if ((i % 4) == 3) { |
67 | *buf++ = val; | 115 | *buf++ = val; |
68 | val = pad; | 116 | val = pad; |
@@ -95,6 +143,8 @@ int ext3fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo) | |||
95 | const char *p; | 143 | const char *p; |
96 | int i; | 144 | int i; |
97 | __u32 in[8], buf[4]; | 145 | __u32 in[8], buf[4]; |
146 | void (*str2hashbuf)(const char *, int, __u32 *, int) = | ||
147 | str2hashbuf_signed; | ||
98 | 148 | ||
99 | /* Initialize the default seed for the hash checksum functions */ | 149 | /* Initialize the default seed for the hash checksum functions */ |
100 | buf[0] = 0x67452301; | 150 | buf[0] = 0x67452301; |
@@ -113,13 +163,18 @@ int ext3fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo) | |||
113 | } | 163 | } |
114 | 164 | ||
115 | switch (hinfo->hash_version) { | 165 | switch (hinfo->hash_version) { |
166 | case DX_HASH_LEGACY_UNSIGNED: | ||
167 | hash = dx_hack_hash_unsigned(name, len); | ||
168 | break; | ||
116 | case DX_HASH_LEGACY: | 169 | case DX_HASH_LEGACY: |
117 | hash = dx_hack_hash(name, len); | 170 | hash = dx_hack_hash_signed(name, len); |
118 | break; | 171 | break; |
172 | case DX_HASH_HALF_MD4_UNSIGNED: | ||
173 | str2hashbuf = str2hashbuf_unsigned; | ||
119 | case DX_HASH_HALF_MD4: | 174 | case DX_HASH_HALF_MD4: |
120 | p = name; | 175 | p = name; |
121 | while (len > 0) { | 176 | while (len > 0) { |
122 | str2hashbuf(p, len, in, 8); | 177 | (*str2hashbuf)(p, len, in, 8); |
123 | half_md4_transform(buf, in); | 178 | half_md4_transform(buf, in); |
124 | len -= 32; | 179 | len -= 32; |
125 | p += 32; | 180 | p += 32; |
@@ -127,10 +182,12 @@ int ext3fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo) | |||
127 | minor_hash = buf[2]; | 182 | minor_hash = buf[2]; |
128 | hash = buf[1]; | 183 | hash = buf[1]; |
129 | break; | 184 | break; |
185 | case DX_HASH_TEA_UNSIGNED: | ||
186 | str2hashbuf = str2hashbuf_unsigned; | ||
130 | case DX_HASH_TEA: | 187 | case DX_HASH_TEA: |
131 | p = name; | 188 | p = name; |
132 | while (len > 0) { | 189 | while (len > 0) { |
133 | str2hashbuf(p, len, in, 4); | 190 | (*str2hashbuf)(p, len, in, 4); |
134 | TEA_transform(buf, in); | 191 | TEA_transform(buf, in); |
135 | len -= 16; | 192 | len -= 16; |
136 | p += 16; | 193 | p += 16; |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 8d6f965e502c..69a3d19ca9fd 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -364,6 +364,8 @@ dx_probe(struct qstr *entry, struct inode *dir, | |||
364 | goto fail; | 364 | goto fail; |
365 | } | 365 | } |
366 | hinfo->hash_version = root->info.hash_version; | 366 | hinfo->hash_version = root->info.hash_version; |
367 | if (hinfo->hash_version <= DX_HASH_TEA) | ||
368 | hinfo->hash_version += EXT3_SB(dir->i_sb)->s_hash_unsigned; | ||
367 | hinfo->seed = EXT3_SB(dir->i_sb)->s_hash_seed; | 369 | hinfo->seed = EXT3_SB(dir->i_sb)->s_hash_seed; |
368 | if (entry) | 370 | if (entry) |
369 | ext3fs_dirhash(entry->name, entry->len, hinfo); | 371 | ext3fs_dirhash(entry->name, entry->len, hinfo); |
@@ -632,6 +634,9 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash, | |||
632 | dir = dir_file->f_path.dentry->d_inode; | 634 | dir = dir_file->f_path.dentry->d_inode; |
633 | if (!(EXT3_I(dir)->i_flags & EXT3_INDEX_FL)) { | 635 | if (!(EXT3_I(dir)->i_flags & EXT3_INDEX_FL)) { |
634 | hinfo.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version; | 636 | hinfo.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version; |
637 | if (hinfo.hash_version <= DX_HASH_TEA) | ||
638 | hinfo.hash_version += | ||
639 | EXT3_SB(dir->i_sb)->s_hash_unsigned; | ||
635 | hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed; | 640 | hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed; |
636 | count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo, | 641 | count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo, |
637 | start_hash, start_minor_hash); | 642 | start_hash, start_minor_hash); |
@@ -1152,9 +1157,9 @@ static struct ext3_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, | |||
1152 | u32 hash2; | 1157 | u32 hash2; |
1153 | struct dx_map_entry *map; | 1158 | struct dx_map_entry *map; |
1154 | char *data1 = (*bh)->b_data, *data2; | 1159 | char *data1 = (*bh)->b_data, *data2; |
1155 | unsigned split, move, size, i; | 1160 | unsigned split, move, size; |
1156 | struct ext3_dir_entry_2 *de = NULL, *de2; | 1161 | struct ext3_dir_entry_2 *de = NULL, *de2; |
1157 | int err = 0; | 1162 | int err = 0, i; |
1158 | 1163 | ||
1159 | bh2 = ext3_append (handle, dir, &newblock, &err); | 1164 | bh2 = ext3_append (handle, dir, &newblock, &err); |
1160 | if (!(bh2)) { | 1165 | if (!(bh2)) { |
@@ -1394,6 +1399,8 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, | |||
1394 | 1399 | ||
1395 | /* Initialize as for dx_probe */ | 1400 | /* Initialize as for dx_probe */ |
1396 | hinfo.hash_version = root->info.hash_version; | 1401 | hinfo.hash_version = root->info.hash_version; |
1402 | if (hinfo.hash_version <= DX_HASH_TEA) | ||
1403 | hinfo.hash_version += EXT3_SB(dir->i_sb)->s_hash_unsigned; | ||
1397 | hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed; | 1404 | hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed; |
1398 | ext3fs_dirhash(name, namelen, &hinfo); | 1405 | ext3fs_dirhash(name, namelen, &hinfo); |
1399 | frame = frames; | 1406 | frame = frames; |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 01c235bc2054..5d047a030a73 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -683,6 +683,26 @@ static struct dentry *ext3_fh_to_parent(struct super_block *sb, struct fid *fid, | |||
683 | ext3_nfs_get_inode); | 683 | ext3_nfs_get_inode); |
684 | } | 684 | } |
685 | 685 | ||
686 | /* | ||
687 | * Try to release metadata pages (indirect blocks, directories) which are | ||
688 | * mapped via the block device. Since these pages could have journal heads | ||
689 | * which would prevent try_to_free_buffers() from freeing them, we must use | ||
690 | * jbd layer's try_to_free_buffers() function to release them. | ||
691 | */ | ||
692 | static int bdev_try_to_free_page(struct super_block *sb, struct page *page, | ||
693 | gfp_t wait) | ||
694 | { | ||
695 | journal_t *journal = EXT3_SB(sb)->s_journal; | ||
696 | |||
697 | WARN_ON(PageChecked(page)); | ||
698 | if (!page_has_buffers(page)) | ||
699 | return 0; | ||
700 | if (journal) | ||
701 | return journal_try_to_free_buffers(journal, page, | ||
702 | wait & ~__GFP_WAIT); | ||
703 | return try_to_free_buffers(page); | ||
704 | } | ||
705 | |||
686 | #ifdef CONFIG_QUOTA | 706 | #ifdef CONFIG_QUOTA |
687 | #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") | 707 | #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") |
688 | #define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) | 708 | #define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA)) |
@@ -749,6 +769,7 @@ static const struct super_operations ext3_sops = { | |||
749 | .quota_read = ext3_quota_read, | 769 | .quota_read = ext3_quota_read, |
750 | .quota_write = ext3_quota_write, | 770 | .quota_write = ext3_quota_write, |
751 | #endif | 771 | #endif |
772 | .bdev_try_to_free_page = bdev_try_to_free_page, | ||
752 | }; | 773 | }; |
753 | 774 | ||
754 | static const struct export_operations ext3_export_ops = { | 775 | static const struct export_operations ext3_export_ops = { |
@@ -1750,6 +1771,18 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1750 | for (i=0; i < 4; i++) | 1771 | for (i=0; i < 4; i++) |
1751 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); | 1772 | sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); |
1752 | sbi->s_def_hash_version = es->s_def_hash_version; | 1773 | sbi->s_def_hash_version = es->s_def_hash_version; |
1774 | i = le32_to_cpu(es->s_flags); | ||
1775 | if (i & EXT2_FLAGS_UNSIGNED_HASH) | ||
1776 | sbi->s_hash_unsigned = 3; | ||
1777 | else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) { | ||
1778 | #ifdef __CHAR_UNSIGNED__ | ||
1779 | es->s_flags |= cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH); | ||
1780 | sbi->s_hash_unsigned = 3; | ||
1781 | #else | ||
1782 | es->s_flags |= cpu_to_le32(EXT2_FLAGS_SIGNED_HASH); | ||
1783 | #endif | ||
1784 | sb->s_dirt = 1; | ||
1785 | } | ||
1753 | 1786 | ||
1754 | if (sbi->s_blocks_per_group > blocksize * 8) { | 1787 | if (sbi->s_blocks_per_group > blocksize * 8) { |
1755 | printk (KERN_ERR | 1788 | printk (KERN_ERR |