Merge branch 'rcu/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck...
[firefly-linux-kernel-4.4.55.git] / fs / ocfs2 / alloc.c
index 9d8fcf2f3b947f0fe2a5feda7c0a849f154f349c..a93bf98922565ab120d85f995f0cb565deb1e144 100644 (file)
@@ -4961,6 +4961,15 @@ leftright:
 
                el = path_leaf_el(path);
                split_index = ocfs2_search_extent_list(el, cpos);
+               if (split_index == -1) {
+                       ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
+                                       "Owner %llu has an extent at cpos %u "
+                                       "which can no longer be found.\n",
+                                       (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
+                                       cpos);
+                       ret = -EROFS;
+                       goto out;
+               }
                goto leftright;
        }
 out:
@@ -5135,7 +5144,7 @@ int ocfs2_change_extent_flag(handle_t *handle,
        el = path_leaf_el(left_path);
 
        index = ocfs2_search_extent_list(el, cpos);
-       if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) {
+       if (index == -1) {
                ocfs2_error(sb,
                            "Owner %llu has an extent at cpos %u which can no "
                            "longer be found.\n",
@@ -5491,7 +5500,7 @@ int ocfs2_remove_extent(handle_t *handle,
 
        el = path_leaf_el(path);
        index = ocfs2_search_extent_list(el, cpos);
-       if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) {
+       if (index == -1) {
                ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
                            "Owner %llu has an extent at cpos %u which can no "
                            "longer be found.\n",
@@ -5557,7 +5566,7 @@ int ocfs2_remove_extent(handle_t *handle,
 
                el = path_leaf_el(path);
                index = ocfs2_search_extent_list(el, cpos);
-               if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) {
+               if (index == -1) {
                        ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
                                    "Owner %llu: split at cpos %u lost record.",
                                    (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),