Skip to content

Commit

Permalink
NTFS: Change ntfs_rl_truncate_nolock() to throw away the runlist if t…
Browse files Browse the repository at this point in the history
…he new

      length is zero.

Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
  • Loading branch information
Anton Altaparmakov committed Sep 8, 2005
1 parent f94ad38 commit 3ffc5a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions fs/ntfs/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ ToDo/Notes:
- Report unrepresentable inodes during ntfs_readdir() as KERN_WARNING
messages and include the inode number. Thanks to Yura Pakhuchiy for
pointing this out.
- Change ntfs_rl_truncate_nolock() to throw away the runlist if the new
length is zero.

2.1.23 - Implement extension of resident files and make writing safe as well as
many bug fixes, cleanups, and enhancements...
Expand Down
14 changes: 13 additions & 1 deletion fs/ntfs/runlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1455,19 +1455,24 @@ int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst,

/**
* ntfs_rl_truncate_nolock - truncate a runlist starting at a specified vcn
* @vol: ntfs volume (needed for error output)
* @runlist: runlist to truncate
* @new_length: the new length of the runlist in VCNs
*
* Truncate the runlist described by @runlist as well as the memory buffer
* holding the runlist elements to a length of @new_length VCNs.
*
* If @new_length lies within the runlist, the runlist elements with VCNs of
* @new_length and above are discarded.
* @new_length and above are discarded. As a special case if @new_length is
* zero, the runlist is discarded and set to NULL.
*
* If @new_length lies beyond the runlist, a sparse runlist element is added to
* the end of the runlist @runlist or if the last runlist element is a sparse
* one already, this is extended.
*
* Note, no checking is done for unmapped runlist elements. It is assumed that
* the caller has mapped any elements that need to be mapped already.
*
* Return 0 on success and -errno on error.
*
* Locking: The caller must hold @runlist->lock for writing.
Expand All @@ -1482,6 +1487,13 @@ int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist,
BUG_ON(!runlist);
BUG_ON(new_length < 0);
rl = runlist->rl;
if (!new_length) {
ntfs_debug("Freeing runlist.");
runlist->rl = NULL;
if (rl)
ntfs_free(rl);
return 0;
}
if (unlikely(!rl)) {
/*
* Create a runlist consisting of a sparse runlist element of
Expand Down

0 comments on commit 3ffc5a4

Please sign in to comment.