inode.c (00361589d2eebd90fca022148c763e40d3e90871) inode.c (c1c9ff7c94e83fae89a742df74db51156869bad5)
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

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

2781
2782 kunmap_atomic(kaddr);
2783good:
2784 return 0;
2785
2786zeroit:
2787 if (__ratelimit(&_rs))
2788 btrfs_info(root->fs_info, "csum failed ino %llu off %llu csum %u expected csum %u",
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

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

2781
2782 kunmap_atomic(kaddr);
2783good:
2784 return 0;
2785
2786zeroit:
2787 if (__ratelimit(&_rs))
2788 btrfs_info(root->fs_info, "csum failed ino %llu off %llu csum %u expected csum %u",
2789 (unsigned long long)btrfs_ino(page->mapping->host),
2790 (unsigned long long)start, csum, csum_expected);
2789 btrfs_ino(page->mapping->host), start, csum, csum_expected);
2791 memset(kaddr + offset, 1, end - start + 1);
2792 flush_dcache_page(page);
2793 kunmap_atomic(kaddr);
2794 if (csum_expected == 0)
2795 return 0;
2796 return -EIO;
2797}
2798

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

3567 goto err;
3568 btrfs_release_path(path);
3569
3570 ret = btrfs_del_inode_ref(trans, root, name, name_len, ino,
3571 dir_ino, &index);
3572 if (ret) {
3573 btrfs_info(root->fs_info,
3574 "failed to delete reference to %.*s, inode %llu parent %llu",
2790 memset(kaddr + offset, 1, end - start + 1);
2791 flush_dcache_page(page);
2792 kunmap_atomic(kaddr);
2793 if (csum_expected == 0)
2794 return 0;
2795 return -EIO;
2796}
2797

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

3566 goto err;
3567 btrfs_release_path(path);
3568
3569 ret = btrfs_del_inode_ref(trans, root, name, name_len, ino,
3570 dir_ino, &index);
3571 if (ret) {
3572 btrfs_info(root->fs_info,
3573 "failed to delete reference to %.*s, inode %llu parent %llu",
3575 name_len, name,
3576 (unsigned long long)ino, (unsigned long long)dir_ino);
3574 name_len, name, ino, dir_ino);
3577 btrfs_abort_transaction(trans, root, ret);
3578 goto err;
3579 }
3580
3581 ret = btrfs_delete_delayed_dir_index(trans, root, dir, index);
3582 if (ret) {
3583 btrfs_abort_transaction(trans, root, ret);
3584 goto err;

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

6076 em->len = len;
6077not_found_em:
6078 em->block_start = EXTENT_MAP_HOLE;
6079 set_bit(EXTENT_FLAG_VACANCY, &em->flags);
6080insert:
6081 btrfs_release_path(path);
6082 if (em->start > start || extent_map_end(em) <= start) {
6083 btrfs_err(root->fs_info, "bad extent! em: [%llu %llu] passed [%llu %llu]",
3575 btrfs_abort_transaction(trans, root, ret);
3576 goto err;
3577 }
3578
3579 ret = btrfs_delete_delayed_dir_index(trans, root, dir, index);
3580 if (ret) {
3581 btrfs_abort_transaction(trans, root, ret);
3582 goto err;

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

6074 em->len = len;
6075not_found_em:
6076 em->block_start = EXTENT_MAP_HOLE;
6077 set_bit(EXTENT_FLAG_VACANCY, &em->flags);
6078insert:
6079 btrfs_release_path(path);
6080 if (em->start > start || extent_map_end(em) <= start) {
6081 btrfs_err(root->fs_info, "bad extent! em: [%llu %llu] passed [%llu %llu]",
6084 (unsigned long long)em->start,
6085 (unsigned long long)em->len,
6086 (unsigned long long)start,
6087 (unsigned long long)len);
6082 em->start, em->len, start, len);
6088 err = -EIO;
6089 goto out;
6090 }
6091
6092 err = 0;
6093 write_lock(&em_tree->lock);
6094 ret = add_extent_mapping(em_tree, em, 0);
6095 /* it is possible that someone inserted the extent into the tree

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

6748 csum, bvec->bv_len);
6749 btrfs_csum_final(csum, (char *)&csum);
6750 kunmap_atomic(kaddr);
6751 local_irq_restore(flags);
6752
6753 flush_dcache_page(bvec->bv_page);
6754 if (csum != csums[index]) {
6755 btrfs_err(root->fs_info, "csum failed ino %llu off %llu csum %u expected csum %u",
6083 err = -EIO;
6084 goto out;
6085 }
6086
6087 err = 0;
6088 write_lock(&em_tree->lock);
6089 ret = add_extent_mapping(em_tree, em, 0);
6090 /* it is possible that someone inserted the extent into the tree

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

6743 csum, bvec->bv_len);
6744 btrfs_csum_final(csum, (char *)&csum);
6745 kunmap_atomic(kaddr);
6746 local_irq_restore(flags);
6747
6748 flush_dcache_page(bvec->bv_page);
6749 if (csum != csums[index]) {
6750 btrfs_err(root->fs_info, "csum failed ino %llu off %llu csum %u expected csum %u",
6756 (unsigned long long)btrfs_ino(inode),
6757 (unsigned long long)start,
6758 csum, csums[index]);
6751 btrfs_ino(inode), start, csum,
6752 csums[index]);
6759 err = -EIO;
6760 }
6761 }
6762
6763 start += bvec->bv_len;
6764 bvec++;
6765 index++;
6766 } while (bvec <= bvec_end);

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

6838
6839static void btrfs_end_dio_bio(struct bio *bio, int err)
6840{
6841 struct btrfs_dio_private *dip = bio->bi_private;
6842
6843 if (err) {
6844 printk(KERN_ERR "btrfs direct IO failed ino %llu rw %lu "
6845 "sector %#Lx len %u err no %d\n",
6753 err = -EIO;
6754 }
6755 }
6756
6757 start += bvec->bv_len;
6758 bvec++;
6759 index++;
6760 } while (bvec <= bvec_end);

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

6832
6833static void btrfs_end_dio_bio(struct bio *bio, int err)
6834{
6835 struct btrfs_dio_private *dip = bio->bi_private;
6836
6837 if (err) {
6838 printk(KERN_ERR "btrfs direct IO failed ino %llu rw %lu "
6839 "sector %#Lx len %u err no %d\n",
6846 (unsigned long long)btrfs_ino(dip->inode), bio->bi_rw,
6840 btrfs_ino(dip->inode), bio->bi_rw,
6847 (unsigned long long)bio->bi_sector, bio->bi_size, err);
6848 dip->errors = 1;
6849
6850 /*
6851 * before atomic variable goto zero, we must make sure
6852 * dip->errors is perceived to be set.
6853 */
6854 smp_mb__before_atomic_dec();

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

7770 spin_lock(&root->fs_info->ordered_root_lock);
7771 list_del_init(&BTRFS_I(inode)->ordered_operations);
7772 spin_unlock(&root->fs_info->ordered_root_lock);
7773 }
7774
7775 if (test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
7776 &BTRFS_I(inode)->runtime_flags)) {
7777 btrfs_info(root->fs_info, "inode %llu still on the orphan list",
6841 (unsigned long long)bio->bi_sector, bio->bi_size, err);
6842 dip->errors = 1;
6843
6844 /*
6845 * before atomic variable goto zero, we must make sure
6846 * dip->errors is perceived to be set.
6847 */
6848 smp_mb__before_atomic_dec();

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

7764 spin_lock(&root->fs_info->ordered_root_lock);
7765 list_del_init(&BTRFS_I(inode)->ordered_operations);
7766 spin_unlock(&root->fs_info->ordered_root_lock);
7767 }
7768
7769 if (test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
7770 &BTRFS_I(inode)->runtime_flags)) {
7771 btrfs_info(root->fs_info, "inode %llu still on the orphan list",
7778 (unsigned long long)btrfs_ino(inode));
7772 btrfs_ino(inode));
7779 atomic_dec(&root->orphan_inodes);
7780 }
7781
7782 while (1) {
7783 ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1);
7784 if (!ordered)
7785 break;
7786 else {
7787 btrfs_err(root->fs_info, "found ordered extent %llu %llu on inode cleanup",
7773 atomic_dec(&root->orphan_inodes);
7774 }
7775
7776 while (1) {
7777 ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1);
7778 if (!ordered)
7779 break;
7780 else {
7781 btrfs_err(root->fs_info, "found ordered extent %llu %llu on inode cleanup",
7788 (unsigned long long)ordered->file_offset,
7789 (unsigned long long)ordered->len);
7782 ordered->file_offset, ordered->len);
7790 btrfs_remove_ordered_extent(inode, ordered);
7791 btrfs_put_ordered_extent(ordered);
7792 btrfs_put_ordered_extent(ordered);
7793 }
7794 }
7795 inode_tree_del(inode);
7796 btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
7797free:

--- 873 unchanged lines hidden ---
7783 btrfs_remove_ordered_extent(inode, ordered);
7784 btrfs_put_ordered_extent(ordered);
7785 btrfs_put_ordered_extent(ordered);
7786 }
7787 }
7788 inode_tree_del(inode);
7789 btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
7790free:

--- 873 unchanged lines hidden ---