Btrfs: Fix an off by one in the extent_map prepare write code
authorChris Mason <chris.mason@oracle.com>
Fri, 21 Dec 2007 21:27:23 +0000 (16:27 -0500)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:03:58 +0000 (11:03 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent_map.c
fs/btrfs/inode.c

index 2b92f10702745c92dc57b2a07150e8edd425cca1..f53d8c976219ecccee2c38ca0e02ea324f40cfe4 100644 (file)
@@ -2270,7 +2270,7 @@ int extent_prepare_write(struct extent_map_tree *tree,
                        kunmap_atomic(kaddr, KM_USER0);
                }
                if ((em->block_start != EXTENT_MAP_HOLE &&
-                    em->block_start != EXTENT_MAP_INLINE) && 
+                    em->block_start != EXTENT_MAP_INLINE) &&
                    !isnew && !PageUptodate(page) &&
                    (block_off_end > to || block_off_start < from) &&
                    !test_range_bit(tree, block_start, cur_end,
@@ -2279,7 +2279,7 @@ int extent_prepare_write(struct extent_map_tree *tree,
                        u64 extent_offset = block_start - em->start;
                        size_t iosize;
                        sector = (em->block_start + extent_offset) >> 9;
-                       iosize = (cur_end - block_start + blocksize - 1) &
+                       iosize = (cur_end - block_start + blocksize) &
                                ~((u64)blocksize - 1);
                        /*
                         * we've already got the extent locked, but we
index a9f5d6d417f0e0f3451e8961d44b9ca9afd25d24..5f5b7b89b144c0e414738c81da32d13106c60fec 100644 (file)
@@ -1956,7 +1956,7 @@ static int btrfs_prepare_write(struct file *file, struct page *page,
 
        mutex_lock(&root->fs_info->fs_mutex);
        err = btrfs_check_free_space(root, PAGE_CACHE_SIZE, 0);
-       mutex_lock(&root->fs_info->fs_mutex);
+       mutex_unlock(&root->fs_info->fs_mutex);
        if (err)
                return -ENOSPC;