diff options
Diffstat (limited to 'fs/ext4/xattr.c')
-rw-r--r-- | fs/ext4/xattr.c | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index b4c5aa8489d8..3a8cd8dff1ad 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -97,7 +97,7 @@ static int ext4_xattr_list(struct dentry *dentry, char *buffer, | |||
97 | 97 | ||
98 | static struct mb_cache *ext4_xattr_cache; | 98 | static struct mb_cache *ext4_xattr_cache; |
99 | 99 | ||
100 | static struct xattr_handler *ext4_xattr_handler_map[] = { | 100 | static const struct xattr_handler *ext4_xattr_handler_map[] = { |
101 | [EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler, | 101 | [EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler, |
102 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 102 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
103 | [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext4_xattr_acl_access_handler, | 103 | [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext4_xattr_acl_access_handler, |
@@ -109,7 +109,7 @@ static struct xattr_handler *ext4_xattr_handler_map[] = { | |||
109 | #endif | 109 | #endif |
110 | }; | 110 | }; |
111 | 111 | ||
112 | struct xattr_handler *ext4_xattr_handlers[] = { | 112 | const struct xattr_handler *ext4_xattr_handlers[] = { |
113 | &ext4_xattr_user_handler, | 113 | &ext4_xattr_user_handler, |
114 | &ext4_xattr_trusted_handler, | 114 | &ext4_xattr_trusted_handler, |
115 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 115 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
@@ -122,10 +122,10 @@ struct xattr_handler *ext4_xattr_handlers[] = { | |||
122 | NULL | 122 | NULL |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static inline struct xattr_handler * | 125 | static inline const struct xattr_handler * |
126 | ext4_xattr_handler(int name_index) | 126 | ext4_xattr_handler(int name_index) |
127 | { | 127 | { |
128 | struct xattr_handler *handler = NULL; | 128 | const struct xattr_handler *handler = NULL; |
129 | 129 | ||
130 | if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map)) | 130 | if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map)) |
131 | handler = ext4_xattr_handler_map[name_index]; | 131 | handler = ext4_xattr_handler_map[name_index]; |
@@ -228,9 +228,8 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, | |||
228 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); | 228 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); |
229 | if (ext4_xattr_check_block(bh)) { | 229 | if (ext4_xattr_check_block(bh)) { |
230 | bad_block: | 230 | bad_block: |
231 | ext4_error(inode->i_sb, | 231 | EXT4_ERROR_INODE(inode, "bad block %llu", |
232 | "inode %lu: bad block %llu", inode->i_ino, | 232 | EXT4_I(inode)->i_file_acl); |
233 | EXT4_I(inode)->i_file_acl); | ||
234 | error = -EIO; | 233 | error = -EIO; |
235 | goto cleanup; | 234 | goto cleanup; |
236 | } | 235 | } |
@@ -332,7 +331,7 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry, | |||
332 | size_t rest = buffer_size; | 331 | size_t rest = buffer_size; |
333 | 332 | ||
334 | for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) { | 333 | for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) { |
335 | struct xattr_handler *handler = | 334 | const struct xattr_handler *handler = |
336 | ext4_xattr_handler(entry->e_name_index); | 335 | ext4_xattr_handler(entry->e_name_index); |
337 | 336 | ||
338 | if (handler) { | 337 | if (handler) { |
@@ -372,9 +371,8 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
372 | ea_bdebug(bh, "b_count=%d, refcount=%d", | 371 | ea_bdebug(bh, "b_count=%d, refcount=%d", |
373 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); | 372 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); |
374 | if (ext4_xattr_check_block(bh)) { | 373 | if (ext4_xattr_check_block(bh)) { |
375 | ext4_error(inode->i_sb, | 374 | EXT4_ERROR_INODE(inode, "bad block %llu", |
376 | "inode %lu: bad block %llu", inode->i_ino, | 375 | EXT4_I(inode)->i_file_acl); |
377 | EXT4_I(inode)->i_file_acl); | ||
378 | error = -EIO; | 376 | error = -EIO; |
379 | goto cleanup; | 377 | goto cleanup; |
380 | } | 378 | } |
@@ -460,8 +458,7 @@ static void ext4_xattr_update_super_block(handle_t *handle, | |||
460 | 458 | ||
461 | if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { | 459 | if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { |
462 | EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR); | 460 | EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR); |
463 | sb->s_dirt = 1; | 461 | ext4_handle_dirty_super(handle, sb); |
464 | ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); | ||
465 | } | 462 | } |
466 | } | 463 | } |
467 | 464 | ||
@@ -666,8 +663,8 @@ ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i, | |||
666 | atomic_read(&(bs->bh->b_count)), | 663 | atomic_read(&(bs->bh->b_count)), |
667 | le32_to_cpu(BHDR(bs->bh)->h_refcount)); | 664 | le32_to_cpu(BHDR(bs->bh)->h_refcount)); |
668 | if (ext4_xattr_check_block(bs->bh)) { | 665 | if (ext4_xattr_check_block(bs->bh)) { |
669 | ext4_error(sb, "inode %lu: bad block %llu", | 666 | EXT4_ERROR_INODE(inode, "bad block %llu", |
670 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 667 | EXT4_I(inode)->i_file_acl); |
671 | error = -EIO; | 668 | error = -EIO; |
672 | goto cleanup; | 669 | goto cleanup; |
673 | } | 670 | } |
@@ -820,7 +817,7 @@ inserted: | |||
820 | EXT4_I(inode)->i_block_group); | 817 | EXT4_I(inode)->i_block_group); |
821 | 818 | ||
822 | /* non-extent files can't have physical blocks past 2^32 */ | 819 | /* non-extent files can't have physical blocks past 2^32 */ |
823 | if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | 820 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) |
824 | goal = goal & EXT4_MAX_BLOCK_FILE_PHYS; | 821 | goal = goal & EXT4_MAX_BLOCK_FILE_PHYS; |
825 | 822 | ||
826 | block = ext4_new_meta_blocks(handle, inode, | 823 | block = ext4_new_meta_blocks(handle, inode, |
@@ -828,7 +825,7 @@ inserted: | |||
828 | if (error) | 825 | if (error) |
829 | goto cleanup; | 826 | goto cleanup; |
830 | 827 | ||
831 | if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | 828 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) |
832 | BUG_ON(block > EXT4_MAX_BLOCK_FILE_PHYS); | 829 | BUG_ON(block > EXT4_MAX_BLOCK_FILE_PHYS); |
833 | 830 | ||
834 | ea_idebug(inode, "creating block %d", block); | 831 | ea_idebug(inode, "creating block %d", block); |
@@ -880,8 +877,8 @@ cleanup_dquot: | |||
880 | goto cleanup; | 877 | goto cleanup; |
881 | 878 | ||
882 | bad_block: | 879 | bad_block: |
883 | ext4_error(inode->i_sb, "inode %lu: bad block %llu", | 880 | EXT4_ERROR_INODE(inode, "bad block %llu", |
884 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 881 | EXT4_I(inode)->i_file_acl); |
885 | goto cleanup; | 882 | goto cleanup; |
886 | 883 | ||
887 | #undef header | 884 | #undef header |
@@ -1194,8 +1191,8 @@ retry: | |||
1194 | if (!bh) | 1191 | if (!bh) |
1195 | goto cleanup; | 1192 | goto cleanup; |
1196 | if (ext4_xattr_check_block(bh)) { | 1193 | if (ext4_xattr_check_block(bh)) { |
1197 | ext4_error(inode->i_sb, "inode %lu: bad block %llu", | 1194 | EXT4_ERROR_INODE(inode, "bad block %llu", |
1198 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 1195 | EXT4_I(inode)->i_file_acl); |
1199 | error = -EIO; | 1196 | error = -EIO; |
1200 | goto cleanup; | 1197 | goto cleanup; |
1201 | } | 1198 | } |
@@ -1372,14 +1369,14 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) | |||
1372 | goto cleanup; | 1369 | goto cleanup; |
1373 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); | 1370 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); |
1374 | if (!bh) { | 1371 | if (!bh) { |
1375 | ext4_error(inode->i_sb, "inode %lu: block %llu read error", | 1372 | EXT4_ERROR_INODE(inode, "block %llu read error", |
1376 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 1373 | EXT4_I(inode)->i_file_acl); |
1377 | goto cleanup; | 1374 | goto cleanup; |
1378 | } | 1375 | } |
1379 | if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || | 1376 | if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || |
1380 | BHDR(bh)->h_blocks != cpu_to_le32(1)) { | 1377 | BHDR(bh)->h_blocks != cpu_to_le32(1)) { |
1381 | ext4_error(inode->i_sb, "inode %lu: bad block %llu", | 1378 | EXT4_ERROR_INODE(inode, "bad block %llu", |
1382 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 1379 | EXT4_I(inode)->i_file_acl); |
1383 | goto cleanup; | 1380 | goto cleanup; |
1384 | } | 1381 | } |
1385 | ext4_xattr_release_block(handle, inode, bh); | 1382 | ext4_xattr_release_block(handle, inode, bh); |
@@ -1420,7 +1417,7 @@ ext4_xattr_cache_insert(struct buffer_head *bh) | |||
1420 | ea_bdebug(bh, "out of memory"); | 1417 | ea_bdebug(bh, "out of memory"); |
1421 | return; | 1418 | return; |
1422 | } | 1419 | } |
1423 | error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, &hash); | 1420 | error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, hash); |
1424 | if (error) { | 1421 | if (error) { |
1425 | mb_cache_entry_free(ce); | 1422 | mb_cache_entry_free(ce); |
1426 | if (error == -EBUSY) { | 1423 | if (error == -EBUSY) { |
@@ -1492,8 +1489,8 @@ ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header, | |||
1492 | return NULL; /* never share */ | 1489 | return NULL; /* never share */ |
1493 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); | 1490 | ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); |
1494 | again: | 1491 | again: |
1495 | ce = mb_cache_entry_find_first(ext4_xattr_cache, 0, | 1492 | ce = mb_cache_entry_find_first(ext4_xattr_cache, inode->i_sb->s_bdev, |
1496 | inode->i_sb->s_bdev, hash); | 1493 | hash); |
1497 | while (ce) { | 1494 | while (ce) { |
1498 | struct buffer_head *bh; | 1495 | struct buffer_head *bh; |
1499 | 1496 | ||
@@ -1504,9 +1501,8 @@ again: | |||
1504 | } | 1501 | } |
1505 | bh = sb_bread(inode->i_sb, ce->e_block); | 1502 | bh = sb_bread(inode->i_sb, ce->e_block); |
1506 | if (!bh) { | 1503 | if (!bh) { |
1507 | ext4_error(inode->i_sb, | 1504 | EXT4_ERROR_INODE(inode, "block %lu read error", |
1508 | "inode %lu: block %lu read error", | 1505 | (unsigned long) ce->e_block); |
1509 | inode->i_ino, (unsigned long) ce->e_block); | ||
1510 | } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= | 1506 | } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= |
1511 | EXT4_XATTR_REFCOUNT_MAX) { | 1507 | EXT4_XATTR_REFCOUNT_MAX) { |
1512 | ea_idebug(inode, "block %lu refcount %d>=%d", | 1508 | ea_idebug(inode, "block %lu refcount %d>=%d", |
@@ -1518,7 +1514,7 @@ again: | |||
1518 | return bh; | 1514 | return bh; |
1519 | } | 1515 | } |
1520 | brelse(bh); | 1516 | brelse(bh); |
1521 | ce = mb_cache_entry_find_next(ce, 0, inode->i_sb->s_bdev, hash); | 1517 | ce = mb_cache_entry_find_next(ce, inode->i_sb->s_bdev, hash); |
1522 | } | 1518 | } |
1523 | return NULL; | 1519 | return NULL; |
1524 | } | 1520 | } |
@@ -1594,9 +1590,7 @@ static void ext4_xattr_rehash(struct ext4_xattr_header *header, | |||
1594 | int __init | 1590 | int __init |
1595 | init_ext4_xattr(void) | 1591 | init_ext4_xattr(void) |
1596 | { | 1592 | { |
1597 | ext4_xattr_cache = mb_cache_create("ext4_xattr", NULL, | 1593 | ext4_xattr_cache = mb_cache_create("ext4_xattr", 6); |
1598 | sizeof(struct mb_cache_entry) + | ||
1599 | sizeof(((struct mb_cache_entry *) 0)->e_indexes[0]), 1, 6); | ||
1600 | if (!ext4_xattr_cache) | 1594 | if (!ext4_xattr_cache) |
1601 | return -ENOMEM; | 1595 | return -ENOMEM; |
1602 | return 0; | 1596 | return 0; |