summaryrefslogtreecommitdiffstats
path: root/fs/ntfs/runlist.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 16:26:56 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 16:26:56 -0800
commita1a051b1870f9e4607526c7e403abab06526c6d9 (patch)
tree08942e39ca8477c4b0f594deac9e966bb376db83 /fs/ntfs/runlist.c
parentaca361c1a0dc0165ac3148137983cb4b1458b5c1 (diff)
parentb425c8c5922562c562dc55a636c3c8d758ed6d17 (diff)
downloadlinux-a1a051b1870f9e4607526c7e403abab06526c6d9.tar.gz
linux-a1a051b1870f9e4607526c7e403abab06526c6d9.tar.bz2
linux-a1a051b1870f9e4607526c7e403abab06526c6d9.zip
Merge git://git.kernel.org/pub/scm/linux/kernel/git/aia21/ntfs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/aia21/ntfs-2.6: NTFS: 2.1.27 - Various bug fixes and cleanups. NTFS: Semaphore to mutex conversion. NTFS: Handle the recently introduced -ENAMETOOLONG return value from NTFS: Add a missing call to flush_dcache_mft_record_page() in NTFS: Fix a bug in fs/ntfs/inode.c::ntfs_read_locked_index_inode() where we NTFS: Improve comments on file attribute flags in fs/ntfs/layout.h. NTFS: Limit name length in fs/ntfs/unistr.c::ntfs_nlstoucs() to maximum NTFS: Remove all the make_bad_inode() calls. This should only be called NTFS: Add support for sparse files which have a compression unit of 0. NTFS: Fix comparison of $MFT and $MFTMirr to not bail out when there are NTFS: Use buffer_migrate_page() for the ->migratepage function of all ntfs NTFS: Fix a buggette in an "should be impossible" case handling where we NTFS: Fix an (innocent) off-by-one error in the runlist code. NTFS: Fix two compiler warnings on Alpha. Thanks to Andrew Morton for
Diffstat (limited to 'fs/ntfs/runlist.c')
-rw-r--r--fs/ntfs/runlist.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c
index 061b5ff6b73c..eb52b801512b 100644
--- a/fs/ntfs/runlist.c
+++ b/fs/ntfs/runlist.c
@@ -381,6 +381,7 @@ static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
int dsize, runlist_element *src, int ssize, int loc)
{
+ signed delta;
BOOL left = FALSE; /* Left end of @src needs merging. */
BOOL right = FALSE; /* Right end of @src needs merging. */
int tail; /* Start of tail of @dst. */
@@ -396,11 +397,14 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
left = ntfs_are_rl_mergeable(dst + loc - 1, src);
/*
* Allocate some space. We will need less if the left, right, or both
- * ends get merged.
+ * ends get merged. The -1 accounts for the run being replaced.
*/
- dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left - right);
- if (IS_ERR(dst))
- return dst;
+ delta = ssize - 1 - left - right;
+ if (delta > 0) {
+ dst = ntfs_rl_realloc(dst, dsize, dsize + delta);
+ if (IS_ERR(dst))
+ return dst;
+ }
/*
* We are guaranteed to succeed from here so can start modifying the
* original runlists.