diff options
-rw-r--r-- | fs/ext2/ext2.h | 2 | ||||
-rw-r--r-- | fs/ext2/super.c | 16 | ||||
-rw-r--r-- | fs/ext2/xattr.c | 36 | ||||
-rw-r--r-- | fs/ext4/ext4.h | 2 | ||||
-rw-r--r-- | fs/ext4/super.c | 18 | ||||
-rw-r--r-- | fs/ext4/xattr.c | 71 |
6 files changed, 75 insertions, 70 deletions
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 03f5ce1d3dbe..23ebb92484c6 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -113,7 +113,7 @@ struct ext2_sb_info { | |||
113 | * of the mount options. | 113 | * of the mount options. |
114 | */ | 114 | */ |
115 | spinlock_t s_lock; | 115 | spinlock_t s_lock; |
116 | struct mb_cache *s_mb_cache; | 116 | struct mb_cache *s_ea_block_cache; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | static inline spinlock_t * | 119 | static inline spinlock_t * |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 9c2028b50e5c..7b1bc9059863 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -147,9 +147,9 @@ static void ext2_put_super (struct super_block * sb) | |||
147 | 147 | ||
148 | ext2_quota_off_umount(sb); | 148 | ext2_quota_off_umount(sb); |
149 | 149 | ||
150 | if (sbi->s_mb_cache) { | 150 | if (sbi->s_ea_block_cache) { |
151 | ext2_xattr_destroy_cache(sbi->s_mb_cache); | 151 | ext2_xattr_destroy_cache(sbi->s_ea_block_cache); |
152 | sbi->s_mb_cache = NULL; | 152 | sbi->s_ea_block_cache = NULL; |
153 | } | 153 | } |
154 | if (!(sb->s_flags & MS_RDONLY)) { | 154 | if (!(sb->s_flags & MS_RDONLY)) { |
155 | struct ext2_super_block *es = sbi->s_es; | 155 | struct ext2_super_block *es = sbi->s_es; |
@@ -1131,9 +1131,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | #ifdef CONFIG_EXT2_FS_XATTR | 1133 | #ifdef CONFIG_EXT2_FS_XATTR |
1134 | sbi->s_mb_cache = ext2_xattr_create_cache(); | 1134 | sbi->s_ea_block_cache = ext2_xattr_create_cache(); |
1135 | if (!sbi->s_mb_cache) { | 1135 | if (!sbi->s_ea_block_cache) { |
1136 | ext2_msg(sb, KERN_ERR, "Failed to create an mb_cache"); | 1136 | ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache"); |
1137 | goto failed_mount3; | 1137 | goto failed_mount3; |
1138 | } | 1138 | } |
1139 | #endif | 1139 | #endif |
@@ -1182,8 +1182,8 @@ cantfind_ext2: | |||
1182 | sb->s_id); | 1182 | sb->s_id); |
1183 | goto failed_mount; | 1183 | goto failed_mount; |
1184 | failed_mount3: | 1184 | failed_mount3: |
1185 | if (sbi->s_mb_cache) | 1185 | if (sbi->s_ea_block_cache) |
1186 | ext2_xattr_destroy_cache(sbi->s_mb_cache); | 1186 | ext2_xattr_destroy_cache(sbi->s_ea_block_cache); |
1187 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 1187 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
1188 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 1188 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
1189 | percpu_counter_destroy(&sbi->s_dirs_counter); | 1189 | percpu_counter_destroy(&sbi->s_dirs_counter); |
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 1e5f76070580..1b9b1268d418 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c | |||
@@ -121,6 +121,8 @@ const struct xattr_handler *ext2_xattr_handlers[] = { | |||
121 | NULL | 121 | NULL |
122 | }; | 122 | }; |
123 | 123 | ||
124 | #define EA_BLOCK_CACHE(inode) (EXT2_SB(inode->i_sb)->s_ea_block_cache) | ||
125 | |||
124 | static inline const struct xattr_handler * | 126 | static inline const struct xattr_handler * |
125 | ext2_xattr_handler(int name_index) | 127 | ext2_xattr_handler(int name_index) |
126 | { | 128 | { |
@@ -150,7 +152,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name, | |||
150 | size_t name_len, size; | 152 | size_t name_len, size; |
151 | char *end; | 153 | char *end; |
152 | int error; | 154 | int error; |
153 | struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; | 155 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
154 | 156 | ||
155 | ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", | 157 | ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", |
156 | name_index, name, buffer, (long)buffer_size); | 158 | name_index, name, buffer, (long)buffer_size); |
@@ -195,7 +197,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get", | |||
195 | goto found; | 197 | goto found; |
196 | entry = next; | 198 | entry = next; |
197 | } | 199 | } |
198 | if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) | 200 | if (ext2_xattr_cache_insert(ea_block_cache, bh)) |
199 | ea_idebug(inode, "cache insert failed"); | 201 | ea_idebug(inode, "cache insert failed"); |
200 | error = -ENODATA; | 202 | error = -ENODATA; |
201 | goto cleanup; | 203 | goto cleanup; |
@@ -208,7 +210,7 @@ found: | |||
208 | le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize) | 210 | le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize) |
209 | goto bad_block; | 211 | goto bad_block; |
210 | 212 | ||
211 | if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) | 213 | if (ext2_xattr_cache_insert(ea_block_cache, bh)) |
212 | ea_idebug(inode, "cache insert failed"); | 214 | ea_idebug(inode, "cache insert failed"); |
213 | if (buffer) { | 215 | if (buffer) { |
214 | error = -ERANGE; | 216 | error = -ERANGE; |
@@ -246,7 +248,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
246 | char *end; | 248 | char *end; |
247 | size_t rest = buffer_size; | 249 | size_t rest = buffer_size; |
248 | int error; | 250 | int error; |
249 | struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; | 251 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
250 | 252 | ||
251 | ea_idebug(inode, "buffer=%p, buffer_size=%ld", | 253 | ea_idebug(inode, "buffer=%p, buffer_size=%ld", |
252 | buffer, (long)buffer_size); | 254 | buffer, (long)buffer_size); |
@@ -281,7 +283,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list", | |||
281 | goto bad_block; | 283 | goto bad_block; |
282 | entry = next; | 284 | entry = next; |
283 | } | 285 | } |
284 | if (ext2_xattr_cache_insert(ext2_mb_cache, bh)) | 286 | if (ext2_xattr_cache_insert(ea_block_cache, bh)) |
285 | ea_idebug(inode, "cache insert failed"); | 287 | ea_idebug(inode, "cache insert failed"); |
286 | 288 | ||
287 | /* list the attribute names */ | 289 | /* list the attribute names */ |
@@ -493,7 +495,7 @@ bad_block: ext2_error(sb, "ext2_xattr_set", | |||
493 | * This must happen under buffer lock for | 495 | * This must happen under buffer lock for |
494 | * ext2_xattr_set2() to reliably detect modified block | 496 | * ext2_xattr_set2() to reliably detect modified block |
495 | */ | 497 | */ |
496 | mb_cache_entry_delete(EXT2_SB(sb)->s_mb_cache, hash, | 498 | mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash, |
497 | bh->b_blocknr); | 499 | bh->b_blocknr); |
498 | 500 | ||
499 | /* keep the buffer locked while modifying it. */ | 501 | /* keep the buffer locked while modifying it. */ |
@@ -627,7 +629,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
627 | struct super_block *sb = inode->i_sb; | 629 | struct super_block *sb = inode->i_sb; |
628 | struct buffer_head *new_bh = NULL; | 630 | struct buffer_head *new_bh = NULL; |
629 | int error; | 631 | int error; |
630 | struct mb_cache *ext2_mb_cache = EXT2_SB(sb)->s_mb_cache; | 632 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
631 | 633 | ||
632 | if (header) { | 634 | if (header) { |
633 | new_bh = ext2_xattr_cache_find(inode, header); | 635 | new_bh = ext2_xattr_cache_find(inode, header); |
@@ -655,7 +657,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
655 | don't need to change the reference count. */ | 657 | don't need to change the reference count. */ |
656 | new_bh = old_bh; | 658 | new_bh = old_bh; |
657 | get_bh(new_bh); | 659 | get_bh(new_bh); |
658 | ext2_xattr_cache_insert(ext2_mb_cache, new_bh); | 660 | ext2_xattr_cache_insert(ea_block_cache, new_bh); |
659 | } else { | 661 | } else { |
660 | /* We need to allocate a new block */ | 662 | /* We need to allocate a new block */ |
661 | ext2_fsblk_t goal = ext2_group_first_block_no(sb, | 663 | ext2_fsblk_t goal = ext2_group_first_block_no(sb, |
@@ -676,7 +678,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
676 | memcpy(new_bh->b_data, header, new_bh->b_size); | 678 | memcpy(new_bh->b_data, header, new_bh->b_size); |
677 | set_buffer_uptodate(new_bh); | 679 | set_buffer_uptodate(new_bh); |
678 | unlock_buffer(new_bh); | 680 | unlock_buffer(new_bh); |
679 | ext2_xattr_cache_insert(ext2_mb_cache, new_bh); | 681 | ext2_xattr_cache_insert(ea_block_cache, new_bh); |
680 | 682 | ||
681 | ext2_xattr_update_super_block(sb); | 683 | ext2_xattr_update_super_block(sb); |
682 | } | 684 | } |
@@ -721,7 +723,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
721 | * This must happen under buffer lock for | 723 | * This must happen under buffer lock for |
722 | * ext2_xattr_set2() to reliably detect freed block | 724 | * ext2_xattr_set2() to reliably detect freed block |
723 | */ | 725 | */ |
724 | mb_cache_entry_delete(ext2_mb_cache, hash, | 726 | mb_cache_entry_delete(ea_block_cache, hash, |
725 | old_bh->b_blocknr); | 727 | old_bh->b_blocknr); |
726 | /* Free the old block. */ | 728 | /* Free the old block. */ |
727 | ea_bdebug(old_bh, "freeing"); | 729 | ea_bdebug(old_bh, "freeing"); |
@@ -795,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode) | |||
795 | * This must happen under buffer lock for ext2_xattr_set2() to | 797 | * This must happen under buffer lock for ext2_xattr_set2() to |
796 | * reliably detect freed block | 798 | * reliably detect freed block |
797 | */ | 799 | */ |
798 | mb_cache_entry_delete(EXT2_SB(inode->i_sb)->s_mb_cache, hash, | 800 | mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash, |
799 | bh->b_blocknr); | 801 | bh->b_blocknr); |
800 | ext2_free_blocks(inode, EXT2_I(inode)->i_file_acl, 1); | 802 | ext2_free_blocks(inode, EXT2_I(inode)->i_file_acl, 1); |
801 | get_bh(bh); | 803 | get_bh(bh); |
@@ -897,13 +899,13 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header) | |||
897 | { | 899 | { |
898 | __u32 hash = le32_to_cpu(header->h_hash); | 900 | __u32 hash = le32_to_cpu(header->h_hash); |
899 | struct mb_cache_entry *ce; | 901 | struct mb_cache_entry *ce; |
900 | struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache; | 902 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
901 | 903 | ||
902 | if (!header->h_hash) | 904 | if (!header->h_hash) |
903 | return NULL; /* never share */ | 905 | return NULL; /* never share */ |
904 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); | 906 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); |
905 | again: | 907 | again: |
906 | ce = mb_cache_entry_find_first(ext2_mb_cache, hash); | 908 | ce = mb_cache_entry_find_first(ea_block_cache, hash); |
907 | while (ce) { | 909 | while (ce) { |
908 | struct buffer_head *bh; | 910 | struct buffer_head *bh; |
909 | 911 | ||
@@ -924,7 +926,7 @@ again: | |||
924 | * entry is still hashed is reliable. | 926 | * entry is still hashed is reliable. |
925 | */ | 927 | */ |
926 | if (hlist_bl_unhashed(&ce->e_hash_list)) { | 928 | if (hlist_bl_unhashed(&ce->e_hash_list)) { |
927 | mb_cache_entry_put(ext2_mb_cache, ce); | 929 | mb_cache_entry_put(ea_block_cache, ce); |
928 | unlock_buffer(bh); | 930 | unlock_buffer(bh); |
929 | brelse(bh); | 931 | brelse(bh); |
930 | goto again; | 932 | goto again; |
@@ -937,14 +939,14 @@ again: | |||
937 | } else if (!ext2_xattr_cmp(header, HDR(bh))) { | 939 | } else if (!ext2_xattr_cmp(header, HDR(bh))) { |
938 | ea_bdebug(bh, "b_count=%d", | 940 | ea_bdebug(bh, "b_count=%d", |
939 | atomic_read(&(bh->b_count))); | 941 | atomic_read(&(bh->b_count))); |
940 | mb_cache_entry_touch(ext2_mb_cache, ce); | 942 | mb_cache_entry_touch(ea_block_cache, ce); |
941 | mb_cache_entry_put(ext2_mb_cache, ce); | 943 | mb_cache_entry_put(ea_block_cache, ce); |
942 | return bh; | 944 | return bh; |
943 | } | 945 | } |
944 | unlock_buffer(bh); | 946 | unlock_buffer(bh); |
945 | brelse(bh); | 947 | brelse(bh); |
946 | } | 948 | } |
947 | ce = mb_cache_entry_find_next(ext2_mb_cache, ce); | 949 | ce = mb_cache_entry_find_next(ea_block_cache, ce); |
948 | } | 950 | } |
949 | return NULL; | 951 | return NULL; |
950 | } | 952 | } |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 6b7c517498c9..caf004d0d1b3 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -1516,7 +1516,7 @@ struct ext4_sb_info { | |||
1516 | struct list_head s_es_list; /* List of inodes with reclaimable extents */ | 1516 | struct list_head s_es_list; /* List of inodes with reclaimable extents */ |
1517 | long s_es_nr_inode; | 1517 | long s_es_nr_inode; |
1518 | struct ext4_es_stats s_es_stats; | 1518 | struct ext4_es_stats s_es_stats; |
1519 | struct mb_cache *s_mb_cache; | 1519 | struct mb_cache *s_ea_block_cache; |
1520 | spinlock_t s_es_lock ____cacheline_aligned_in_smp; | 1520 | spinlock_t s_es_lock ____cacheline_aligned_in_smp; |
1521 | 1521 | ||
1522 | /* Ratelimit ext4 messages. */ | 1522 | /* Ratelimit ext4 messages. */ |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index b02a23ec92ca..380389740575 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -927,9 +927,9 @@ static void ext4_put_super(struct super_block *sb) | |||
927 | invalidate_bdev(sbi->journal_bdev); | 927 | invalidate_bdev(sbi->journal_bdev); |
928 | ext4_blkdev_remove(sbi); | 928 | ext4_blkdev_remove(sbi); |
929 | } | 929 | } |
930 | if (sbi->s_mb_cache) { | 930 | if (sbi->s_ea_block_cache) { |
931 | ext4_xattr_destroy_cache(sbi->s_mb_cache); | 931 | ext4_xattr_destroy_cache(sbi->s_ea_block_cache); |
932 | sbi->s_mb_cache = NULL; | 932 | sbi->s_ea_block_cache = NULL; |
933 | } | 933 | } |
934 | if (sbi->s_mmp_tsk) | 934 | if (sbi->s_mmp_tsk) |
935 | kthread_stop(sbi->s_mmp_tsk); | 935 | kthread_stop(sbi->s_mmp_tsk); |
@@ -4061,9 +4061,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
4061 | sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; | 4061 | sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; |
4062 | 4062 | ||
4063 | no_journal: | 4063 | no_journal: |
4064 | sbi->s_mb_cache = ext4_xattr_create_cache(); | 4064 | sbi->s_ea_block_cache = ext4_xattr_create_cache(); |
4065 | if (!sbi->s_mb_cache) { | 4065 | if (!sbi->s_ea_block_cache) { |
4066 | ext4_msg(sb, KERN_ERR, "Failed to create an mb_cache"); | 4066 | ext4_msg(sb, KERN_ERR, "Failed to create ea_block_cache"); |
4067 | goto failed_mount_wq; | 4067 | goto failed_mount_wq; |
4068 | } | 4068 | } |
4069 | 4069 | ||
@@ -4296,9 +4296,9 @@ failed_mount4: | |||
4296 | if (EXT4_SB(sb)->rsv_conversion_wq) | 4296 | if (EXT4_SB(sb)->rsv_conversion_wq) |
4297 | destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); | 4297 | destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); |
4298 | failed_mount_wq: | 4298 | failed_mount_wq: |
4299 | if (sbi->s_mb_cache) { | 4299 | if (sbi->s_ea_block_cache) { |
4300 | ext4_xattr_destroy_cache(sbi->s_mb_cache); | 4300 | ext4_xattr_destroy_cache(sbi->s_ea_block_cache); |
4301 | sbi->s_mb_cache = NULL; | 4301 | sbi->s_ea_block_cache = NULL; |
4302 | } | 4302 | } |
4303 | if (sbi->s_journal) { | 4303 | if (sbi->s_journal) { |
4304 | jbd2_journal_destroy(sbi->s_journal); | 4304 | jbd2_journal_destroy(sbi->s_journal); |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 85da7792afd0..53980ee164ed 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -72,10 +72,11 @@ | |||
72 | # define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__) | 72 | # define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__) |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | static void ext4_xattr_cache_insert(struct mb_cache *, struct buffer_head *); | 75 | static void ext4_xattr_block_cache_insert(struct mb_cache *, |
76 | static struct buffer_head *ext4_xattr_cache_find(struct inode *, | 76 | struct buffer_head *); |
77 | struct ext4_xattr_header *, | 77 | static struct buffer_head * |
78 | struct mb_cache_entry **); | 78 | ext4_xattr_block_cache_find(struct inode *, struct ext4_xattr_header *, |
79 | struct mb_cache_entry **); | ||
79 | static void ext4_xattr_rehash(struct ext4_xattr_header *, | 80 | static void ext4_xattr_rehash(struct ext4_xattr_header *, |
80 | struct ext4_xattr_entry *); | 81 | struct ext4_xattr_entry *); |
81 | 82 | ||
@@ -104,8 +105,8 @@ const struct xattr_handler *ext4_xattr_handlers[] = { | |||
104 | NULL | 105 | NULL |
105 | }; | 106 | }; |
106 | 107 | ||
107 | #define EXT4_GET_MB_CACHE(inode) (((struct ext4_sb_info *) \ | 108 | #define EA_BLOCK_CACHE(inode) (((struct ext4_sb_info *) \ |
108 | inode->i_sb->s_fs_info)->s_mb_cache) | 109 | inode->i_sb->s_fs_info)->s_ea_block_cache) |
109 | 110 | ||
110 | #ifdef CONFIG_LOCKDEP | 111 | #ifdef CONFIG_LOCKDEP |
111 | void ext4_xattr_inode_set_class(struct inode *ea_inode) | 112 | void ext4_xattr_inode_set_class(struct inode *ea_inode) |
@@ -374,7 +375,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, | |||
374 | struct ext4_xattr_entry *entry; | 375 | struct ext4_xattr_entry *entry; |
375 | size_t size; | 376 | size_t size; |
376 | int error; | 377 | int error; |
377 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | 378 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
378 | 379 | ||
379 | ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", | 380 | ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld", |
380 | name_index, name, buffer, (long)buffer_size); | 381 | name_index, name, buffer, (long)buffer_size); |
@@ -395,7 +396,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, | |||
395 | error = -EFSCORRUPTED; | 396 | error = -EFSCORRUPTED; |
396 | goto cleanup; | 397 | goto cleanup; |
397 | } | 398 | } |
398 | ext4_xattr_cache_insert(ext4_mb_cache, bh); | 399 | ext4_xattr_block_cache_insert(ea_block_cache, bh); |
399 | entry = BFIRST(bh); | 400 | entry = BFIRST(bh); |
400 | error = ext4_xattr_find_entry(&entry, name_index, name, 1); | 401 | error = ext4_xattr_find_entry(&entry, name_index, name, 1); |
401 | if (error) | 402 | if (error) |
@@ -541,7 +542,6 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
541 | struct inode *inode = d_inode(dentry); | 542 | struct inode *inode = d_inode(dentry); |
542 | struct buffer_head *bh = NULL; | 543 | struct buffer_head *bh = NULL; |
543 | int error; | 544 | int error; |
544 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | ||
545 | 545 | ||
546 | ea_idebug(inode, "buffer=%p, buffer_size=%ld", | 546 | ea_idebug(inode, "buffer=%p, buffer_size=%ld", |
547 | buffer, (long)buffer_size); | 547 | buffer, (long)buffer_size); |
@@ -563,7 +563,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
563 | error = -EFSCORRUPTED; | 563 | error = -EFSCORRUPTED; |
564 | goto cleanup; | 564 | goto cleanup; |
565 | } | 565 | } |
566 | ext4_xattr_cache_insert(ext4_mb_cache, bh); | 566 | ext4_xattr_block_cache_insert(EA_BLOCK_CACHE(inode), bh); |
567 | error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); | 567 | error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
568 | 568 | ||
569 | cleanup: | 569 | cleanup: |
@@ -660,7 +660,7 @@ static void | |||
660 | ext4_xattr_release_block(handle_t *handle, struct inode *inode, | 660 | ext4_xattr_release_block(handle_t *handle, struct inode *inode, |
661 | struct buffer_head *bh) | 661 | struct buffer_head *bh) |
662 | { | 662 | { |
663 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | 663 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
664 | u32 hash, ref; | 664 | u32 hash, ref; |
665 | int error = 0; | 665 | int error = 0; |
666 | 666 | ||
@@ -678,7 +678,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
678 | * This must happen under buffer lock for | 678 | * This must happen under buffer lock for |
679 | * ext4_xattr_block_set() to reliably detect freed block | 679 | * ext4_xattr_block_set() to reliably detect freed block |
680 | */ | 680 | */ |
681 | mb_cache_entry_delete(ext4_mb_cache, hash, bh->b_blocknr); | 681 | mb_cache_entry_delete(ea_block_cache, hash, bh->b_blocknr); |
682 | get_bh(bh); | 682 | get_bh(bh); |
683 | unlock_buffer(bh); | 683 | unlock_buffer(bh); |
684 | ext4_free_blocks(handle, inode, bh, 0, 1, | 684 | ext4_free_blocks(handle, inode, bh, 0, 1, |
@@ -690,11 +690,11 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
690 | if (ref == EXT4_XATTR_REFCOUNT_MAX - 1) { | 690 | if (ref == EXT4_XATTR_REFCOUNT_MAX - 1) { |
691 | struct mb_cache_entry *ce; | 691 | struct mb_cache_entry *ce; |
692 | 692 | ||
693 | ce = mb_cache_entry_get(ext4_mb_cache, hash, | 693 | ce = mb_cache_entry_get(ea_block_cache, hash, |
694 | bh->b_blocknr); | 694 | bh->b_blocknr); |
695 | if (ce) { | 695 | if (ce) { |
696 | ce->e_reusable = 1; | 696 | ce->e_reusable = 1; |
697 | mb_cache_entry_put(ext4_mb_cache, ce); | 697 | mb_cache_entry_put(ea_block_cache, ce); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | 700 | ||
@@ -1094,7 +1094,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
1094 | struct ext4_xattr_search *s = &s_copy; | 1094 | struct ext4_xattr_search *s = &s_copy; |
1095 | struct mb_cache_entry *ce = NULL; | 1095 | struct mb_cache_entry *ce = NULL; |
1096 | int error = 0; | 1096 | int error = 0; |
1097 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | 1097 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
1098 | 1098 | ||
1099 | #define header(x) ((struct ext4_xattr_header *)(x)) | 1099 | #define header(x) ((struct ext4_xattr_header *)(x)) |
1100 | 1100 | ||
@@ -1113,7 +1113,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
1113 | * ext4_xattr_block_set() to reliably detect modified | 1113 | * ext4_xattr_block_set() to reliably detect modified |
1114 | * block | 1114 | * block |
1115 | */ | 1115 | */ |
1116 | mb_cache_entry_delete(ext4_mb_cache, hash, | 1116 | mb_cache_entry_delete(ea_block_cache, hash, |
1117 | bs->bh->b_blocknr); | 1117 | bs->bh->b_blocknr); |
1118 | ea_bdebug(bs->bh, "modifying in-place"); | 1118 | ea_bdebug(bs->bh, "modifying in-place"); |
1119 | error = ext4_xattr_set_entry(i, s, handle, inode); | 1119 | error = ext4_xattr_set_entry(i, s, handle, inode); |
@@ -1121,8 +1121,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
1121 | if (!IS_LAST_ENTRY(s->first)) | 1121 | if (!IS_LAST_ENTRY(s->first)) |
1122 | ext4_xattr_rehash(header(s->base), | 1122 | ext4_xattr_rehash(header(s->base), |
1123 | s->here); | 1123 | s->here); |
1124 | ext4_xattr_cache_insert(ext4_mb_cache, | 1124 | ext4_xattr_block_cache_insert(ea_block_cache, |
1125 | bs->bh); | 1125 | bs->bh); |
1126 | } | 1126 | } |
1127 | ext4_xattr_block_csum_set(inode, bs->bh); | 1127 | ext4_xattr_block_csum_set(inode, bs->bh); |
1128 | unlock_buffer(bs->bh); | 1128 | unlock_buffer(bs->bh); |
@@ -1175,7 +1175,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, | |||
1175 | 1175 | ||
1176 | inserted: | 1176 | inserted: |
1177 | if (!IS_LAST_ENTRY(s->first)) { | 1177 | if (!IS_LAST_ENTRY(s->first)) { |
1178 | new_bh = ext4_xattr_cache_find(inode, header(s->base), &ce); | 1178 | new_bh = ext4_xattr_block_cache_find(inode, header(s->base), |
1179 | &ce); | ||
1179 | if (new_bh) { | 1180 | if (new_bh) { |
1180 | /* We found an identical block in the cache. */ | 1181 | /* We found an identical block in the cache. */ |
1181 | if (new_bh == bs->bh) | 1182 | if (new_bh == bs->bh) |
@@ -1220,7 +1221,7 @@ inserted: | |||
1220 | EXT4_C2B(EXT4_SB(sb), | 1221 | EXT4_C2B(EXT4_SB(sb), |
1221 | 1)); | 1222 | 1)); |
1222 | brelse(new_bh); | 1223 | brelse(new_bh); |
1223 | mb_cache_entry_put(ext4_mb_cache, ce); | 1224 | mb_cache_entry_put(ea_block_cache, ce); |
1224 | ce = NULL; | 1225 | ce = NULL; |
1225 | new_bh = NULL; | 1226 | new_bh = NULL; |
1226 | goto inserted; | 1227 | goto inserted; |
@@ -1239,8 +1240,8 @@ inserted: | |||
1239 | if (error) | 1240 | if (error) |
1240 | goto cleanup_dquot; | 1241 | goto cleanup_dquot; |
1241 | } | 1242 | } |
1242 | mb_cache_entry_touch(ext4_mb_cache, ce); | 1243 | mb_cache_entry_touch(ea_block_cache, ce); |
1243 | mb_cache_entry_put(ext4_mb_cache, ce); | 1244 | mb_cache_entry_put(ea_block_cache, ce); |
1244 | ce = NULL; | 1245 | ce = NULL; |
1245 | } else if (bs->bh && s->base == bs->bh->b_data) { | 1246 | } else if (bs->bh && s->base == bs->bh->b_data) { |
1246 | /* We were modifying this block in-place. */ | 1247 | /* We were modifying this block in-place. */ |
@@ -1290,7 +1291,7 @@ getblk_failed: | |||
1290 | ext4_xattr_block_csum_set(inode, new_bh); | 1291 | ext4_xattr_block_csum_set(inode, new_bh); |
1291 | set_buffer_uptodate(new_bh); | 1292 | set_buffer_uptodate(new_bh); |
1292 | unlock_buffer(new_bh); | 1293 | unlock_buffer(new_bh); |
1293 | ext4_xattr_cache_insert(ext4_mb_cache, new_bh); | 1294 | ext4_xattr_block_cache_insert(ea_block_cache, new_bh); |
1294 | error = ext4_handle_dirty_metadata(handle, inode, | 1295 | error = ext4_handle_dirty_metadata(handle, inode, |
1295 | new_bh); | 1296 | new_bh); |
1296 | if (error) | 1297 | if (error) |
@@ -1308,7 +1309,7 @@ getblk_failed: | |||
1308 | 1309 | ||
1309 | cleanup: | 1310 | cleanup: |
1310 | if (ce) | 1311 | if (ce) |
1311 | mb_cache_entry_put(ext4_mb_cache, ce); | 1312 | mb_cache_entry_put(ea_block_cache, ce); |
1312 | brelse(new_bh); | 1313 | brelse(new_bh); |
1313 | if (!(bs->bh && s->base == bs->bh->b_data)) | 1314 | if (!(bs->bh && s->base == bs->bh->b_data)) |
1314 | kfree(s->base); | 1315 | kfree(s->base); |
@@ -2148,15 +2149,16 @@ void ext4_xattr_inode_array_free(struct ext4_xattr_inode_array *ea_inode_array) | |||
2148 | } | 2149 | } |
2149 | 2150 | ||
2150 | /* | 2151 | /* |
2151 | * ext4_xattr_cache_insert() | 2152 | * ext4_xattr_block_cache_insert() |
2152 | * | 2153 | * |
2153 | * Create a new entry in the extended attribute cache, and insert | 2154 | * Create a new entry in the extended attribute block cache, and insert |
2154 | * it unless such an entry is already in the cache. | 2155 | * it unless such an entry is already in the cache. |
2155 | * | 2156 | * |
2156 | * Returns 0, or a negative error number on failure. | 2157 | * Returns 0, or a negative error number on failure. |
2157 | */ | 2158 | */ |
2158 | static void | 2159 | static void |
2159 | ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh) | 2160 | ext4_xattr_block_cache_insert(struct mb_cache *ea_block_cache, |
2161 | struct buffer_head *bh) | ||
2160 | { | 2162 | { |
2161 | struct ext4_xattr_header *header = BHDR(bh); | 2163 | struct ext4_xattr_header *header = BHDR(bh); |
2162 | __u32 hash = le32_to_cpu(header->h_hash); | 2164 | __u32 hash = le32_to_cpu(header->h_hash); |
@@ -2164,7 +2166,7 @@ ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh) | |||
2164 | EXT4_XATTR_REFCOUNT_MAX; | 2166 | EXT4_XATTR_REFCOUNT_MAX; |
2165 | int error; | 2167 | int error; |
2166 | 2168 | ||
2167 | error = mb_cache_entry_create(ext4_mb_cache, GFP_NOFS, hash, | 2169 | error = mb_cache_entry_create(ea_block_cache, GFP_NOFS, hash, |
2168 | bh->b_blocknr, reusable); | 2170 | bh->b_blocknr, reusable); |
2169 | if (error) { | 2171 | if (error) { |
2170 | if (error == -EBUSY) | 2172 | if (error == -EBUSY) |
@@ -2214,7 +2216,7 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1, | |||
2214 | } | 2216 | } |
2215 | 2217 | ||
2216 | /* | 2218 | /* |
2217 | * ext4_xattr_cache_find() | 2219 | * ext4_xattr_block_cache_find() |
2218 | * | 2220 | * |
2219 | * Find an identical extended attribute block. | 2221 | * Find an identical extended attribute block. |
2220 | * | 2222 | * |
@@ -2222,17 +2224,18 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1, | |||
2222 | * not found or an error occurred. | 2224 | * not found or an error occurred. |
2223 | */ | 2225 | */ |
2224 | static struct buffer_head * | 2226 | static struct buffer_head * |
2225 | ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header, | 2227 | ext4_xattr_block_cache_find(struct inode *inode, |
2226 | struct mb_cache_entry **pce) | 2228 | struct ext4_xattr_header *header, |
2229 | struct mb_cache_entry **pce) | ||
2227 | { | 2230 | { |
2228 | __u32 hash = le32_to_cpu(header->h_hash); | 2231 | __u32 hash = le32_to_cpu(header->h_hash); |
2229 | struct mb_cache_entry *ce; | 2232 | struct mb_cache_entry *ce; |
2230 | struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode); | 2233 | struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode); |
2231 | 2234 | ||
2232 | if (!header->h_hash) | 2235 | if (!header->h_hash) |
2233 | return NULL; /* never share */ | 2236 | return NULL; /* never share */ |
2234 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); | 2237 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); |
2235 | ce = mb_cache_entry_find_first(ext4_mb_cache, hash); | 2238 | ce = mb_cache_entry_find_first(ea_block_cache, hash); |
2236 | while (ce) { | 2239 | while (ce) { |
2237 | struct buffer_head *bh; | 2240 | struct buffer_head *bh; |
2238 | 2241 | ||
@@ -2245,7 +2248,7 @@ ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header, | |||
2245 | return bh; | 2248 | return bh; |
2246 | } | 2249 | } |
2247 | brelse(bh); | 2250 | brelse(bh); |
2248 | ce = mb_cache_entry_find_next(ext4_mb_cache, ce); | 2251 | ce = mb_cache_entry_find_next(ea_block_cache, ce); |
2249 | } | 2252 | } |
2250 | return NULL; | 2253 | return NULL; |
2251 | } | 2254 | } |