]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - fs/xfs/xfs_bmap.c
[XFS] Allow xfs_bmbt_split() to fallback to the lowspace allocator
[mv-sheeva.git] / fs / xfs / xfs_bmap.c
index c21e01a9b2ddcd28bd6bf48b79b11c6d69062dce..cf4dee01983aa71594041415c6742d7ff30d2e9d 100644 (file)
@@ -1746,11 +1746,18 @@ xfs_bmap_add_extent_unwritten_real(
                        if ((error = xfs_bmbt_insert(cur, &i)))
                                goto done;
                        XFS_WANT_CORRUPTED_GOTO(i == 1, done);
-                       if ((error = xfs_bmbt_increment(cur, 0, &i)))
+                       /*
+                        * Reset the cursor to the position of the new extent
+                        * we are about to insert as we can't trust it after
+                        * the previous insert.
+                        */
+                       if ((error = xfs_bmbt_lookup_eq(cur, new->br_startoff,
+                                       new->br_startblock, new->br_blockcount,
+                                       &i)))
                                goto done;
-                       XFS_WANT_CORRUPTED_GOTO(i == 1, done);
+                       XFS_WANT_CORRUPTED_GOTO(i == 0, done);
                        /* new middle extent - newext */
-                       cur->bc_rec.b = *new;
+                       cur->bc_rec.b.br_state = new->br_state;
                        if ((error = xfs_bmbt_insert(cur, &i)))
                                goto done;
                        XFS_WANT_CORRUPTED_GOTO(i == 1, done);