xattr.c (b65b34895437915f411882dd40d704eb0863ffb0) xattr.c (24676da469f50f433baa347845639662c561d1f6)
1/*
2 * linux/fs/ext4/xattr.c
3 *
4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
5 *
6 * Fix by Harrison Xing <harrison@mountainviewdata.com>.
7 * Ext4 code with a lot of help from Eric Jarman <ejarman@acm.org>.
8 * Extended attributes for symlinks and special files added per

--- 214 unchanged lines hidden (view full) ---

223 ea_idebug(inode, "reading block %u", EXT4_I(inode)->i_file_acl);
224 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
225 if (!bh)
226 goto cleanup;
227 ea_bdebug(bh, "b_count=%d, refcount=%d",
228 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
229 if (ext4_xattr_check_block(bh)) {
230bad_block:
1/*
2 * linux/fs/ext4/xattr.c
3 *
4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
5 *
6 * Fix by Harrison Xing <harrison@mountainviewdata.com>.
7 * Ext4 code with a lot of help from Eric Jarman <ejarman@acm.org>.
8 * Extended attributes for symlinks and special files added per

--- 214 unchanged lines hidden (view full) ---

223 ea_idebug(inode, "reading block %u", EXT4_I(inode)->i_file_acl);
224 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
225 if (!bh)
226 goto cleanup;
227 ea_bdebug(bh, "b_count=%d, refcount=%d",
228 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
229 if (ext4_xattr_check_block(bh)) {
230bad_block:
231 ext4_error(inode->i_sb,
232 "inode %lu: bad block %llu", inode->i_ino,
233 EXT4_I(inode)->i_file_acl);
231 EXT4_ERROR_INODE(inode, "bad block %llu",
232 EXT4_I(inode)->i_file_acl);
234 error = -EIO;
235 goto cleanup;
236 }
237 ext4_xattr_cache_insert(bh);
238 entry = BFIRST(bh);
239 error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
240 if (error == -EIO)
241 goto bad_block;

--- 125 unchanged lines hidden (view full) ---

367 ea_idebug(inode, "reading block %u", EXT4_I(inode)->i_file_acl);
368 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
369 error = -EIO;
370 if (!bh)
371 goto cleanup;
372 ea_bdebug(bh, "b_count=%d, refcount=%d",
373 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
374 if (ext4_xattr_check_block(bh)) {
233 error = -EIO;
234 goto cleanup;
235 }
236 ext4_xattr_cache_insert(bh);
237 entry = BFIRST(bh);
238 error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
239 if (error == -EIO)
240 goto bad_block;

--- 125 unchanged lines hidden (view full) ---

366 ea_idebug(inode, "reading block %u", EXT4_I(inode)->i_file_acl);
367 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
368 error = -EIO;
369 if (!bh)
370 goto cleanup;
371 ea_bdebug(bh, "b_count=%d, refcount=%d",
372 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
373 if (ext4_xattr_check_block(bh)) {
375 ext4_error(inode->i_sb,
376 "inode %lu: bad block %llu", inode->i_ino,
377 EXT4_I(inode)->i_file_acl);
374 EXT4_ERROR_INODE(inode, "bad block %llu",
375 EXT4_I(inode)->i_file_acl);
378 error = -EIO;
379 goto cleanup;
380 }
381 ext4_xattr_cache_insert(bh);
382 error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
383
384cleanup:
385 brelse(bh);

--- 275 unchanged lines hidden (view full) ---

661 bs->bh = sb_bread(sb, EXT4_I(inode)->i_file_acl);
662 error = -EIO;
663 if (!bs->bh)
664 goto cleanup;
665 ea_bdebug(bs->bh, "b_count=%d, refcount=%d",
666 atomic_read(&(bs->bh->b_count)),
667 le32_to_cpu(BHDR(bs->bh)->h_refcount));
668 if (ext4_xattr_check_block(bs->bh)) {
376 error = -EIO;
377 goto cleanup;
378 }
379 ext4_xattr_cache_insert(bh);
380 error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
381
382cleanup:
383 brelse(bh);

--- 275 unchanged lines hidden (view full) ---

659 bs->bh = sb_bread(sb, EXT4_I(inode)->i_file_acl);
660 error = -EIO;
661 if (!bs->bh)
662 goto cleanup;
663 ea_bdebug(bs->bh, "b_count=%d, refcount=%d",
664 atomic_read(&(bs->bh->b_count)),
665 le32_to_cpu(BHDR(bs->bh)->h_refcount));
666 if (ext4_xattr_check_block(bs->bh)) {
669 ext4_error(sb, "inode %lu: bad block %llu",
670 inode->i_ino, EXT4_I(inode)->i_file_acl);
667 EXT4_ERROR_INODE(inode, "bad block %llu",
668 EXT4_I(inode)->i_file_acl);
671 error = -EIO;
672 goto cleanup;
673 }
674 /* Find the named attribute. */
675 bs->s.base = BHDR(bs->bh);
676 bs->s.first = BFIRST(bs->bh);
677 bs->s.end = bs->bh->b_data + bs->bh->b_size;
678 bs->s.here = bs->s.first;

--- 196 unchanged lines hidden (view full) ---

875
876 return error;
877
878cleanup_dquot:
879 dquot_free_block(inode, 1);
880 goto cleanup;
881
882bad_block:
669 error = -EIO;
670 goto cleanup;
671 }
672 /* Find the named attribute. */
673 bs->s.base = BHDR(bs->bh);
674 bs->s.first = BFIRST(bs->bh);
675 bs->s.end = bs->bh->b_data + bs->bh->b_size;
676 bs->s.here = bs->s.first;

--- 196 unchanged lines hidden (view full) ---

873
874 return error;
875
876cleanup_dquot:
877 dquot_free_block(inode, 1);
878 goto cleanup;
879
880bad_block:
883 ext4_error(inode->i_sb, "inode %lu: bad block %llu",
884 inode->i_ino, EXT4_I(inode)->i_file_acl);
881 EXT4_ERROR_INODE(inode, "bad block %llu",
882 EXT4_I(inode)->i_file_acl);
885 goto cleanup;
886
887#undef header
888}
889
890struct ext4_xattr_ibody_find {
891 struct ext4_xattr_search s;
892 struct ext4_iloc iloc;

--- 296 unchanged lines hidden (view full) ---

1189 * EA block can hold new_extra_isize bytes.
1190 */
1191 if (EXT4_I(inode)->i_file_acl) {
1192 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1193 error = -EIO;
1194 if (!bh)
1195 goto cleanup;
1196 if (ext4_xattr_check_block(bh)) {
883 goto cleanup;
884
885#undef header
886}
887
888struct ext4_xattr_ibody_find {
889 struct ext4_xattr_search s;
890 struct ext4_iloc iloc;

--- 296 unchanged lines hidden (view full) ---

1187 * EA block can hold new_extra_isize bytes.
1188 */
1189 if (EXT4_I(inode)->i_file_acl) {
1190 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1191 error = -EIO;
1192 if (!bh)
1193 goto cleanup;
1194 if (ext4_xattr_check_block(bh)) {
1197 ext4_error(inode->i_sb, "inode %lu: bad block %llu",
1198 inode->i_ino, EXT4_I(inode)->i_file_acl);
1195 EXT4_ERROR_INODE(inode, "bad block %llu",
1196 EXT4_I(inode)->i_file_acl);
1199 error = -EIO;
1200 goto cleanup;
1201 }
1202 base = BHDR(bh);
1203 first = BFIRST(bh);
1204 end = bh->b_data + bh->b_size;
1205 min_offs = end - base;
1206 free = ext4_xattr_free_space(first, &min_offs, base,

--- 160 unchanged lines hidden (view full) ---

1367ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
1368{
1369 struct buffer_head *bh = NULL;
1370
1371 if (!EXT4_I(inode)->i_file_acl)
1372 goto cleanup;
1373 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1374 if (!bh) {
1197 error = -EIO;
1198 goto cleanup;
1199 }
1200 base = BHDR(bh);
1201 first = BFIRST(bh);
1202 end = bh->b_data + bh->b_size;
1203 min_offs = end - base;
1204 free = ext4_xattr_free_space(first, &min_offs, base,

--- 160 unchanged lines hidden (view full) ---

1365ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
1366{
1367 struct buffer_head *bh = NULL;
1368
1369 if (!EXT4_I(inode)->i_file_acl)
1370 goto cleanup;
1371 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1372 if (!bh) {
1375 ext4_error(inode->i_sb, "inode %lu: block %llu read error",
1376 inode->i_ino, EXT4_I(inode)->i_file_acl);
1373 EXT4_ERROR_INODE(inode, "block %llu read error",
1374 EXT4_I(inode)->i_file_acl);
1377 goto cleanup;
1378 }
1379 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
1380 BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1375 goto cleanup;
1376 }
1377 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
1378 BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1381 ext4_error(inode->i_sb, "inode %lu: bad block %llu",
1382 inode->i_ino, EXT4_I(inode)->i_file_acl);
1379 EXT4_ERROR_INODE(inode, "bad block %llu",
1380 EXT4_I(inode)->i_file_acl);
1383 goto cleanup;
1384 }
1385 ext4_xattr_release_block(handle, inode, bh);
1386 EXT4_I(inode)->i_file_acl = 0;
1387
1388cleanup:
1389 brelse(bh);
1390}

--- 108 unchanged lines hidden (view full) ---

1499
1500 if (IS_ERR(ce)) {
1501 if (PTR_ERR(ce) == -EAGAIN)
1502 goto again;
1503 break;
1504 }
1505 bh = sb_bread(inode->i_sb, ce->e_block);
1506 if (!bh) {
1381 goto cleanup;
1382 }
1383 ext4_xattr_release_block(handle, inode, bh);
1384 EXT4_I(inode)->i_file_acl = 0;
1385
1386cleanup:
1387 brelse(bh);
1388}

--- 108 unchanged lines hidden (view full) ---

1497
1498 if (IS_ERR(ce)) {
1499 if (PTR_ERR(ce) == -EAGAIN)
1500 goto again;
1501 break;
1502 }
1503 bh = sb_bread(inode->i_sb, ce->e_block);
1504 if (!bh) {
1507 ext4_error(inode->i_sb,
1508 "inode %lu: block %lu read error",
1509 inode->i_ino, (unsigned long) ce->e_block);
1505 EXT4_ERROR_INODE(inode, "block %lu read error",
1506 (unsigned long) ce->e_block);
1510 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
1511 EXT4_XATTR_REFCOUNT_MAX) {
1512 ea_idebug(inode, "block %lu refcount %d>=%d",
1513 (unsigned long) ce->e_block,
1514 le32_to_cpu(BHDR(bh)->h_refcount),
1515 EXT4_XATTR_REFCOUNT_MAX);
1516 } else if (ext4_xattr_cmp(header, BHDR(bh)) == 0) {
1517 *pce = ce;

--- 94 unchanged lines hidden ---
1507 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
1508 EXT4_XATTR_REFCOUNT_MAX) {
1509 ea_idebug(inode, "block %lu refcount %d>=%d",
1510 (unsigned long) ce->e_block,
1511 le32_to_cpu(BHDR(bh)->h_refcount),
1512 EXT4_XATTR_REFCOUNT_MAX);
1513 } else if (ext4_xattr_cmp(header, BHDR(bh)) == 0) {
1514 *pce = ce;

--- 94 unchanged lines hidden ---