btrfs: Use locked_end rather than open coding it
[sfrench/cifs-2.6.git] / fs / btrfs / file.c
index eb1bac7c8553c7a4172735027765bf16619e9d00..559d716221dfa0dddf9bb55a7abdcd67af73fc22 100644 (file)
@@ -2896,8 +2896,8 @@ static long btrfs_fallocate(struct file *file, int mode,
                 */
                lock_extent_bits(&BTRFS_I(inode)->io_tree, alloc_start,
                                 locked_end, &cached_state);
-               ordered = btrfs_lookup_first_ordered_extent(inode,
-                                                           alloc_end - 1);
+               ordered = btrfs_lookup_first_ordered_extent(inode, locked_end);
+
                if (ordered &&
                    ordered->file_offset + ordered->len > alloc_start &&
                    ordered->file_offset < alloc_end) {
@@ -2922,7 +2922,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 
        /* First, check if we exceed the qgroup limit */
        INIT_LIST_HEAD(&reserve_list);
-       while (1) {
+       while (cur_offset < alloc_end) {
                em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, cur_offset,
                                      alloc_end - cur_offset, 0);
                if (IS_ERR(em)) {
@@ -2958,8 +2958,6 @@ static long btrfs_fallocate(struct file *file, int mode,
                }
                free_extent_map(em);
                cur_offset = last_byte;
-               if (cur_offset >= alloc_end)
-                       break;
        }
 
        /*