diff options
author | David Sterba <dsterba@suse.cz> | 2011-05-05 07:13:16 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2011-05-06 06:34:10 -0400 |
commit | 182608c8294b5fe90d7bbd4b026c82bf0a24b736 (patch) | |
tree | 5705e84960e66caa84ac059a3528a31493e35d16 /fs/btrfs/inode.c | |
parent | f2a97a9dbd86eb1ef956bdf20e05c507b32beb96 (diff) |
btrfs: remove old unused commented out code
Remove code which has been #if0-ed out for a very long time and does not
seem to be related to current codebase anymore.
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 172 |
1 files changed, 0 insertions, 172 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 57122a5e8473..5ff52b644a60 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3093,178 +3093,6 @@ out: | |||
3093 | return err; | 3093 | return err; |
3094 | } | 3094 | } |
3095 | 3095 | ||
3096 | #if 0 | ||
3097 | /* | ||
3098 | * when truncating bytes in a file, it is possible to avoid reading | ||
3099 | * the leaves that contain only checksum items. This can be the | ||
3100 | * majority of the IO required to delete a large file, but it must | ||
3101 | * be done carefully. | ||
3102 | * | ||
3103 | * The keys in the level just above the leaves are checked to make sure | ||
3104 | * the lowest key in a given leaf is a csum key, and starts at an offset | ||
3105 | * after the new size. | ||
3106 | * | ||
3107 | * Then the key for the next leaf is checked to make sure it also has | ||
3108 | * a checksum item for the same file. If it does, we know our target leaf | ||
3109 | * contains only checksum items, and it can be safely freed without reading | ||
3110 | * it. | ||
3111 | * | ||
3112 | * This is just an optimization targeted at large files. It may do | ||
3113 | * nothing. It will return 0 unless things went badly. | ||
3114 | */ | ||
3115 | static noinline int drop_csum_leaves(struct btrfs_trans_handle *trans, | ||
3116 | struct btrfs_root *root, | ||
3117 | struct btrfs_path *path, | ||
3118 | struct inode *inode, u64 new_size) | ||
3119 | { | ||
3120 | struct btrfs_key key; | ||
3121 | int ret; | ||
3122 | int nritems; | ||
3123 | struct btrfs_key found_key; | ||
3124 | struct btrfs_key other_key; | ||
3125 | struct btrfs_leaf_ref *ref; | ||
3126 | u64 leaf_gen; | ||
3127 | u64 leaf_start; | ||
3128 | |||
3129 | path->lowest_level = 1; | ||
3130 | key.objectid = inode->i_ino; | ||
3131 | key.type = BTRFS_CSUM_ITEM_KEY; | ||
3132 | key.offset = new_size; | ||
3133 | again: | ||
3134 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); | ||
3135 | if (ret < 0) | ||
3136 | goto out; | ||
3137 | |||
3138 | if (path->nodes[1] == NULL) { | ||
3139 | ret = 0; | ||
3140 | goto out; | ||
3141 | } | ||
3142 | ret = 0; | ||
3143 | btrfs_node_key_to_cpu(path->nodes[1], &found_key, path->slots[1]); | ||
3144 | nritems = btrfs_header_nritems(path->nodes[1]); | ||
3145 | |||
3146 | if (!nritems) | ||
3147 | goto out; | ||
3148 | |||
3149 | if (path->slots[1] >= nritems) | ||
3150 | goto next_node; | ||
3151 | |||
3152 | /* did we find a key greater than anything we want to delete? */ | ||
3153 | if (found_key.objectid > inode->i_ino || | ||
3154 | (found_key.objectid == inode->i_ino && found_key.type > key.type)) | ||
3155 | goto out; | ||
3156 | |||
3157 | /* we check the next key in the node to make sure the leave contains | ||
3158 | * only checksum items. This comparison doesn't work if our | ||
3159 | * leaf is the last one in the node | ||
3160 | */ | ||
3161 | if (path->slots[1] + 1 >= nritems) { | ||
3162 | next_node: | ||
3163 | /* search forward from the last key in the node, this | ||
3164 | * will bring us into the next node in the tree | ||
3165 | */ | ||
3166 | btrfs_node_key_to_cpu(path->nodes[1], &found_key, nritems - 1); | ||
3167 | |||
3168 | /* unlikely, but we inc below, so check to be safe */ | ||
3169 | if (found_key.offset == (u64)-1) | ||
3170 | goto out; | ||
3171 | |||
3172 | /* search_forward needs a path with locks held, do the | ||
3173 | * search again for the original key. It is possible | ||
3174 | * this will race with a balance and return a path that | ||
3175 | * we could modify, but this drop is just an optimization | ||
3176 | * and is allowed to miss some leaves. | ||
3177 | */ | ||
3178 | btrfs_release_path(root, path); | ||
3179 | found_key.offset++; | ||
3180 | |||
3181 | /* setup a max key for search_forward */ | ||
3182 | other_key.offset = (u64)-1; | ||
3183 | other_key.type = key.type; | ||
3184 | other_key.objectid = key.objectid; | ||
3185 | |||
3186 | path->keep_locks = 1; | ||
3187 | ret = btrfs_search_forward(root, &found_key, &other_key, | ||
3188 | path, 0, 0); | ||
3189 | path->keep_locks = 0; | ||
3190 | if (ret || found_key.objectid != key.objectid || | ||
3191 | found_key.type != key.type) { | ||
3192 | ret = 0; | ||
3193 | goto out; | ||
3194 | } | ||
3195 | |||
3196 | key.offset = found_key.offset; | ||
3197 | btrfs_release_path(root, path); | ||
3198 | cond_resched(); | ||
3199 | goto again; | ||
3200 | } | ||
3201 | |||
3202 | /* we know there's one more slot after us in the tree, | ||
3203 | * read that key so we can verify it is also a checksum item | ||
3204 | */ | ||
3205 | btrfs_node_key_to_cpu(path->nodes[1], &other_key, path->slots[1] + 1); | ||
3206 | |||
3207 | if (found_key.objectid < inode->i_ino) | ||
3208 | goto next_key; | ||
3209 | |||
3210 | if (found_key.type != key.type || found_key.offset < new_size) | ||
3211 | goto next_key; | ||
3212 | |||
3213 | /* | ||
3214 | * if the key for the next leaf isn't a csum key from this objectid, | ||
3215 | * we can't be sure there aren't good items inside this leaf. | ||
3216 | * Bail out | ||
3217 | */ | ||
3218 | if (other_key.objectid != inode->i_ino || other_key.type != key.type) | ||
3219 | goto out; | ||
3220 | |||
3221 | leaf_start = btrfs_node_blockptr(path->nodes[1], path->slots[1]); | ||
3222 | leaf_gen = btrfs_node_ptr_generation(path->nodes[1], path->slots[1]); | ||
3223 | /* | ||
3224 | * it is safe to delete this leaf, it contains only | ||
3225 | * csum items from this inode at an offset >= new_size | ||
3226 | */ | ||
3227 | ret = btrfs_del_leaf(trans, root, path, leaf_start); | ||
3228 | BUG_ON(ret); | ||
3229 | |||
3230 | if (root->ref_cows && leaf_gen < trans->transid) { | ||
3231 | ref = btrfs_alloc_leaf_ref(root, 0); | ||
3232 | if (ref) { | ||
3233 | ref->root_gen = root->root_key.offset; | ||
3234 | ref->bytenr = leaf_start; | ||
3235 | ref->owner = 0; | ||
3236 | ref->generation = leaf_gen; | ||
3237 | ref->nritems = 0; | ||
3238 | |||
3239 | btrfs_sort_leaf_ref(ref); | ||
3240 | |||
3241 | ret = btrfs_add_leaf_ref(root, ref, 0); | ||
3242 | WARN_ON(ret); | ||
3243 | btrfs_free_leaf_ref(root, ref); | ||
3244 | } else { | ||
3245 | WARN_ON(1); | ||
3246 | } | ||
3247 | } | ||
3248 | next_key: | ||
3249 | btrfs_release_path(root, path); | ||
3250 | |||
3251 | if (other_key.objectid == inode->i_ino && | ||
3252 | other_key.type == key.type && other_key.offset > key.offset) { | ||
3253 | key.offset = other_key.offset; | ||
3254 | cond_resched(); | ||
3255 | goto again; | ||
3256 | } | ||
3257 | ret = 0; | ||
3258 | out: | ||
3259 | /* fixup any changes we've made to the path */ | ||
3260 | path->lowest_level = 0; | ||
3261 | path->keep_locks = 0; | ||
3262 | btrfs_release_path(root, path); | ||
3263 | return ret; | ||
3264 | } | ||
3265 | |||
3266 | #endif | ||
3267 | |||
3268 | /* | 3096 | /* |
3269 | * this can truncate away extent items, csum items and directory items. | 3097 | * this can truncate away extent items, csum items and directory items. |
3270 | * It starts at a high offset and removes keys until it can't find | 3098 | * It starts at a high offset and removes keys until it can't find |