diff options
Diffstat (limited to 'fs/ext4/xattr.c')
| -rw-r--r-- | fs/ext4/xattr.c | 64 | 
1 files changed, 31 insertions, 33 deletions
| diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index f3a2f7ed45aa..b4c5aa8489d8 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
| @@ -227,7 +227,8 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, | |||
| 227 | ea_bdebug(bh, "b_count=%d, refcount=%d", | 227 | ea_bdebug(bh, "b_count=%d, refcount=%d", | 
| 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: ext4_error(inode->i_sb, __func__, | 230 | bad_block: | 
| 231 | ext4_error(inode->i_sb, | ||
| 231 | "inode %lu: bad block %llu", inode->i_ino, | 232 | "inode %lu: bad block %llu", inode->i_ino, | 
| 232 | EXT4_I(inode)->i_file_acl); | 233 | EXT4_I(inode)->i_file_acl); | 
| 233 | error = -EIO; | 234 | error = -EIO; | 
| @@ -267,7 +268,7 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name, | |||
| 267 | void *end; | 268 | void *end; | 
| 268 | int error; | 269 | int error; | 
| 269 | 270 | ||
| 270 | if (!(EXT4_I(inode)->i_state & EXT4_STATE_XATTR)) | 271 | if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR)) | 
| 271 | return -ENODATA; | 272 | return -ENODATA; | 
| 272 | error = ext4_get_inode_loc(inode, &iloc); | 273 | error = ext4_get_inode_loc(inode, &iloc); | 
| 273 | if (error) | 274 | if (error) | 
| @@ -371,7 +372,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
| 371 | ea_bdebug(bh, "b_count=%d, refcount=%d", | 372 | ea_bdebug(bh, "b_count=%d, refcount=%d", | 
| 372 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); | 373 | atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); | 
| 373 | if (ext4_xattr_check_block(bh)) { | 374 | if (ext4_xattr_check_block(bh)) { | 
| 374 | ext4_error(inode->i_sb, __func__, | 375 | ext4_error(inode->i_sb, | 
| 375 | "inode %lu: bad block %llu", inode->i_ino, | 376 | "inode %lu: bad block %llu", inode->i_ino, | 
| 376 | EXT4_I(inode)->i_file_acl); | 377 | EXT4_I(inode)->i_file_acl); | 
| 377 | error = -EIO; | 378 | error = -EIO; | 
| @@ -396,7 +397,7 @@ ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
| 396 | void *end; | 397 | void *end; | 
| 397 | int error; | 398 | int error; | 
| 398 | 399 | ||
| 399 | if (!(EXT4_I(inode)->i_state & EXT4_STATE_XATTR)) | 400 | if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR)) | 
| 400 | return 0; | 401 | return 0; | 
| 401 | error = ext4_get_inode_loc(inode, &iloc); | 402 | error = ext4_get_inode_loc(inode, &iloc); | 
| 402 | if (error) | 403 | if (error) | 
| @@ -494,7 +495,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
| 494 | error = ext4_handle_dirty_metadata(handle, inode, bh); | 495 | error = ext4_handle_dirty_metadata(handle, inode, bh); | 
| 495 | if (IS_SYNC(inode)) | 496 | if (IS_SYNC(inode)) | 
| 496 | ext4_handle_sync(handle); | 497 | ext4_handle_sync(handle); | 
| 497 | vfs_dq_free_block(inode, 1); | 498 | dquot_free_block(inode, 1); | 
| 498 | ea_bdebug(bh, "refcount now=%d; releasing", | 499 | ea_bdebug(bh, "refcount now=%d; releasing", | 
| 499 | le32_to_cpu(BHDR(bh)->h_refcount)); | 500 | le32_to_cpu(BHDR(bh)->h_refcount)); | 
| 500 | if (ce) | 501 | if (ce) | 
| @@ -665,9 +666,8 @@ ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i, | |||
| 665 | atomic_read(&(bs->bh->b_count)), | 666 | atomic_read(&(bs->bh->b_count)), | 
| 666 | le32_to_cpu(BHDR(bs->bh)->h_refcount)); | 667 | le32_to_cpu(BHDR(bs->bh)->h_refcount)); | 
| 667 | if (ext4_xattr_check_block(bs->bh)) { | 668 | if (ext4_xattr_check_block(bs->bh)) { | 
| 668 | ext4_error(sb, __func__, | 669 | ext4_error(sb, "inode %lu: bad block %llu", | 
| 669 | "inode %lu: bad block %llu", inode->i_ino, | 670 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 
| 670 | EXT4_I(inode)->i_file_acl); | ||
| 671 | error = -EIO; | 671 | error = -EIO; | 
| 672 | goto cleanup; | 672 | goto cleanup; | 
| 673 | } | 673 | } | 
| @@ -787,8 +787,8 @@ inserted: | |||
| 787 | else { | 787 | else { | 
| 788 | /* The old block is released after updating | 788 | /* The old block is released after updating | 
| 789 | the inode. */ | 789 | the inode. */ | 
| 790 | error = -EDQUOT; | 790 | error = dquot_alloc_block(inode, 1); | 
| 791 | if (vfs_dq_alloc_block(inode, 1)) | 791 | if (error) | 
| 792 | goto cleanup; | 792 | goto cleanup; | 
| 793 | error = ext4_journal_get_write_access(handle, | 793 | error = ext4_journal_get_write_access(handle, | 
| 794 | new_bh); | 794 | new_bh); | 
| @@ -876,13 +876,12 @@ cleanup: | |||
| 876 | return error; | 876 | return error; | 
| 877 | 877 | ||
| 878 | cleanup_dquot: | 878 | cleanup_dquot: | 
| 879 | vfs_dq_free_block(inode, 1); | 879 | dquot_free_block(inode, 1); | 
| 880 | goto cleanup; | 880 | goto cleanup; | 
| 881 | 881 | ||
| 882 | bad_block: | 882 | bad_block: | 
| 883 | ext4_error(inode->i_sb, __func__, | 883 | ext4_error(inode->i_sb, "inode %lu: bad block %llu", | 
| 884 | "inode %lu: bad block %llu", inode->i_ino, | 884 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 
| 885 | EXT4_I(inode)->i_file_acl); | ||
| 886 | goto cleanup; | 885 | goto cleanup; | 
| 887 | 886 | ||
| 888 | #undef header | 887 | #undef header | 
| @@ -908,7 +907,7 @@ ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i, | |||
| 908 | is->s.base = is->s.first = IFIRST(header); | 907 | is->s.base = is->s.first = IFIRST(header); | 
| 909 | is->s.here = is->s.first; | 908 | is->s.here = is->s.first; | 
| 910 | is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; | 909 | is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; | 
| 911 | if (EXT4_I(inode)->i_state & EXT4_STATE_XATTR) { | 910 | if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) { | 
| 912 | error = ext4_xattr_check_names(IFIRST(header), is->s.end); | 911 | error = ext4_xattr_check_names(IFIRST(header), is->s.end); | 
| 913 | if (error) | 912 | if (error) | 
| 914 | return error; | 913 | return error; | 
| @@ -940,10 +939,10 @@ ext4_xattr_ibody_set(handle_t *handle, struct inode *inode, | |||
| 940 | header = IHDR(inode, ext4_raw_inode(&is->iloc)); | 939 | header = IHDR(inode, ext4_raw_inode(&is->iloc)); | 
| 941 | if (!IS_LAST_ENTRY(s->first)) { | 940 | if (!IS_LAST_ENTRY(s->first)) { | 
| 942 | header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC); | 941 | header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC); | 
| 943 | EXT4_I(inode)->i_state |= EXT4_STATE_XATTR; | 942 | ext4_set_inode_state(inode, EXT4_STATE_XATTR); | 
| 944 | } else { | 943 | } else { | 
| 945 | header->h_magic = cpu_to_le32(0); | 944 | header->h_magic = cpu_to_le32(0); | 
| 946 | EXT4_I(inode)->i_state &= ~EXT4_STATE_XATTR; | 945 | ext4_clear_inode_state(inode, EXT4_STATE_XATTR); | 
| 947 | } | 946 | } | 
| 948 | return 0; | 947 | return 0; | 
| 949 | } | 948 | } | 
| @@ -986,8 +985,8 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, | |||
| 986 | if (strlen(name) > 255) | 985 | if (strlen(name) > 255) | 
| 987 | return -ERANGE; | 986 | return -ERANGE; | 
| 988 | down_write(&EXT4_I(inode)->xattr_sem); | 987 | down_write(&EXT4_I(inode)->xattr_sem); | 
| 989 | no_expand = EXT4_I(inode)->i_state & EXT4_STATE_NO_EXPAND; | 988 | no_expand = ext4_test_inode_state(inode, EXT4_STATE_NO_EXPAND); | 
| 990 | EXT4_I(inode)->i_state |= EXT4_STATE_NO_EXPAND; | 989 | ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND); | 
| 991 | 990 | ||
| 992 | error = ext4_get_inode_loc(inode, &is.iloc); | 991 | error = ext4_get_inode_loc(inode, &is.iloc); | 
| 993 | if (error) | 992 | if (error) | 
| @@ -997,10 +996,10 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, | |||
| 997 | if (error) | 996 | if (error) | 
| 998 | goto cleanup; | 997 | goto cleanup; | 
| 999 | 998 | ||
| 1000 | if (EXT4_I(inode)->i_state & EXT4_STATE_NEW) { | 999 | if (ext4_test_inode_state(inode, EXT4_STATE_NEW)) { | 
| 1001 | struct ext4_inode *raw_inode = ext4_raw_inode(&is.iloc); | 1000 | struct ext4_inode *raw_inode = ext4_raw_inode(&is.iloc); | 
| 1002 | memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size); | 1001 | memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size); | 
| 1003 | EXT4_I(inode)->i_state &= ~EXT4_STATE_NEW; | 1002 | ext4_clear_inode_state(inode, EXT4_STATE_NEW); | 
| 1004 | } | 1003 | } | 
| 1005 | 1004 | ||
| 1006 | error = ext4_xattr_ibody_find(inode, &i, &is); | 1005 | error = ext4_xattr_ibody_find(inode, &i, &is); | 
| @@ -1052,7 +1051,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, | |||
| 1052 | ext4_xattr_update_super_block(handle, inode->i_sb); | 1051 | ext4_xattr_update_super_block(handle, inode->i_sb); | 
| 1053 | inode->i_ctime = ext4_current_time(inode); | 1052 | inode->i_ctime = ext4_current_time(inode); | 
| 1054 | if (!value) | 1053 | if (!value) | 
| 1055 | EXT4_I(inode)->i_state &= ~EXT4_STATE_NO_EXPAND; | 1054 | ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); | 
| 1056 | error = ext4_mark_iloc_dirty(handle, inode, &is.iloc); | 1055 | error = ext4_mark_iloc_dirty(handle, inode, &is.iloc); | 
| 1057 | /* | 1056 | /* | 
| 1058 | * The bh is consumed by ext4_mark_iloc_dirty, even with | 1057 | * The bh is consumed by ext4_mark_iloc_dirty, even with | 
| @@ -1067,7 +1066,7 @@ cleanup: | |||
| 1067 | brelse(is.iloc.bh); | 1066 | brelse(is.iloc.bh); | 
| 1068 | brelse(bs.bh); | 1067 | brelse(bs.bh); | 
| 1069 | if (no_expand == 0) | 1068 | if (no_expand == 0) | 
| 1070 | EXT4_I(inode)->i_state &= ~EXT4_STATE_NO_EXPAND; | 1069 | ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); | 
| 1071 | up_write(&EXT4_I(inode)->xattr_sem); | 1070 | up_write(&EXT4_I(inode)->xattr_sem); | 
| 1072 | return error; | 1071 | return error; | 
| 1073 | } | 1072 | } | 
| @@ -1195,9 +1194,8 @@ retry: | |||
| 1195 | if (!bh) | 1194 | if (!bh) | 
| 1196 | goto cleanup; | 1195 | goto cleanup; | 
| 1197 | if (ext4_xattr_check_block(bh)) { | 1196 | if (ext4_xattr_check_block(bh)) { | 
| 1198 | ext4_error(inode->i_sb, __func__, | 1197 | ext4_error(inode->i_sb, "inode %lu: bad block %llu", | 
| 1199 | "inode %lu: bad block %llu", inode->i_ino, | 1198 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 
| 1200 | EXT4_I(inode)->i_file_acl); | ||
| 1201 | error = -EIO; | 1199 | error = -EIO; | 
| 1202 | goto cleanup; | 1200 | goto cleanup; | 
| 1203 | } | 1201 | } | 
| @@ -1302,6 +1300,8 @@ retry: | |||
| 1302 | 1300 | ||
| 1303 | /* Remove the chosen entry from the inode */ | 1301 | /* Remove the chosen entry from the inode */ | 
| 1304 | error = ext4_xattr_ibody_set(handle, inode, &i, is); | 1302 | error = ext4_xattr_ibody_set(handle, inode, &i, is); | 
| 1303 | if (error) | ||
| 1304 | goto cleanup; | ||
| 1305 | 1305 | ||
| 1306 | entry = IFIRST(header); | 1306 | entry = IFIRST(header); | 
| 1307 | if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize) | 1307 | if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize) | 
| @@ -1372,16 +1372,14 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) | |||
| 1372 | goto cleanup; | 1372 | goto cleanup; | 
| 1373 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); | 1373 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); | 
| 1374 | if (!bh) { | 1374 | if (!bh) { | 
| 1375 | ext4_error(inode->i_sb, __func__, | 1375 | ext4_error(inode->i_sb, "inode %lu: block %llu read error", | 
| 1376 | "inode %lu: block %llu read error", inode->i_ino, | 1376 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 
| 1377 | EXT4_I(inode)->i_file_acl); | ||
| 1378 | goto cleanup; | 1377 | goto cleanup; | 
| 1379 | } | 1378 | } | 
| 1380 | if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || | 1379 | if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || | 
| 1381 | BHDR(bh)->h_blocks != cpu_to_le32(1)) { | 1380 | BHDR(bh)->h_blocks != cpu_to_le32(1)) { | 
| 1382 | ext4_error(inode->i_sb, __func__, | 1381 | ext4_error(inode->i_sb, "inode %lu: bad block %llu", | 
| 1383 | "inode %lu: bad block %llu", inode->i_ino, | 1382 | inode->i_ino, EXT4_I(inode)->i_file_acl); | 
| 1384 | EXT4_I(inode)->i_file_acl); | ||
| 1385 | goto cleanup; | 1383 | goto cleanup; | 
| 1386 | } | 1384 | } | 
| 1387 | ext4_xattr_release_block(handle, inode, bh); | 1385 | ext4_xattr_release_block(handle, inode, bh); | 
| @@ -1506,7 +1504,7 @@ again: | |||
| 1506 | } | 1504 | } | 
| 1507 | bh = sb_bread(inode->i_sb, ce->e_block); | 1505 | bh = sb_bread(inode->i_sb, ce->e_block); | 
| 1508 | if (!bh) { | 1506 | if (!bh) { | 
| 1509 | ext4_error(inode->i_sb, __func__, | 1507 | ext4_error(inode->i_sb, | 
| 1510 | "inode %lu: block %lu read error", | 1508 | "inode %lu: block %lu read error", | 
| 1511 | inode->i_ino, (unsigned long) ce->e_block); | 1509 | inode->i_ino, (unsigned long) ce->e_block); | 
| 1512 | } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= | 1510 | } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= | 
