From d722b36e2032c0afba0f7ffda7e3ffc80b12a619 Mon Sep 17 00:00:00 2001 From: Liu Bo Date: Tue, 16 Apr 2013 09:20:28 +0000 Subject: [PATCH] --- yaml --- r: 374879 b: refs/heads/master c: 0abd5b17249ea5ca49a3a9ad4285cac3dfa8c30b h: refs/heads/master i: 374877: 95633547051e921a6afd22434e4afdb8c3873560 374875: 10795b21141113c89555faa5cc7dbe7a36977ba1 374871: 2f8db719f35977882897cbf7ebaeefeff1be2bb3 374863: 664ad5eb18698a15b0304895005f4d5a81fe1ade 374847: 1ecfc74d25e60116af4c605fa7f04ff3b9d69d8b v: v3 --- [refs] | 2 +- trunk/fs/btrfs/ioctl.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 826977d674de..5d32ff1acbe5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3c59ccd32abb8f636b1573533d3e77972e80a9c9 +refs/heads/master: 0abd5b17249ea5ca49a3a9ad4285cac3dfa8c30b diff --git a/trunk/fs/btrfs/ioctl.c b/trunk/fs/btrfs/ioctl.c index ace88c1df540..a74edc797531 100644 --- a/trunk/fs/btrfs/ioctl.c +++ b/trunk/fs/btrfs/ioctl.c @@ -1154,8 +1154,11 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, u64 new_align = ~((u64)128 * 1024 - 1); struct page **pages = NULL; - if (extent_thresh == 0) - extent_thresh = 256 * 1024; + if (isize == 0) + return 0; + + if (range->start >= isize) + return -EINVAL; if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) { if (range->compress_type > BTRFS_COMPRESS_TYPES) @@ -1164,8 +1167,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, compress_type = range->compress_type; } - if (isize == 0) - return 0; + if (extent_thresh == 0) + extent_thresh = 256 * 1024; /* * if we were not given a file, allocate a readahead