aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/lcnalloc.h
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2005-09-08 16:09:06 -0400
committerAnton Altaparmakov <aia21@cantab.net>2005-09-08 16:09:06 -0400
commitbbf1813fb8ff9d21171bf22e6d1f0e0393601e86 (patch)
tree2b8474019c1320df290d5df03514eaed56e44cc6 /fs/ntfs/lcnalloc.h
parent807c453de7c5487d2e5eece76bafdea8f39d249e (diff)
NTFS: Fix cluster (de)allocators to work when the runlist is NULL and more
importantly to take a locked runlist rather than them locking it which leads to lock reversal. Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs/lcnalloc.h')
-rw-r--r--fs/ntfs/lcnalloc.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/ntfs/lcnalloc.h b/fs/ntfs/lcnalloc.h
index 4cac1c024af6..e4d7fb98d685 100644
--- a/fs/ntfs/lcnalloc.h
+++ b/fs/ntfs/lcnalloc.h
@@ -43,13 +43,14 @@ extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol,
43 const NTFS_CLUSTER_ALLOCATION_ZONES zone); 43 const NTFS_CLUSTER_ALLOCATION_ZONES zone);
44 44
45extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, 45extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn,
46 s64 count, const BOOL is_rollback); 46 s64 count, const BOOL write_locked, const BOOL is_rollback);
47 47
48/** 48/**
49 * ntfs_cluster_free - free clusters on an ntfs volume 49 * ntfs_cluster_free - free clusters on an ntfs volume
50 * @vi: vfs inode whose runlist describes the clusters to free 50 * @vi: vfs inode whose runlist describes the clusters to free
51 * @start_vcn: vcn in the runlist of @vi at which to start freeing clusters 51 * @start_vcn: vcn in the runlist of @vi at which to start freeing clusters
52 * @count: number of clusters to free or -1 for all clusters 52 * @count: number of clusters to free or -1 for all clusters
53 * @write_locked: true if the runlist is locked for writing
53 * 54 *
54 * Free @count clusters starting at the cluster @start_vcn in the runlist 55 * Free @count clusters starting at the cluster @start_vcn in the runlist
55 * described by the vfs inode @vi. 56 * described by the vfs inode @vi.
@@ -64,19 +65,19 @@ extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn,
64 * Return the number of deallocated clusters (not counting sparse ones) on 65 * Return the number of deallocated clusters (not counting sparse ones) on
65 * success and -errno on error. 66 * success and -errno on error.
66 * 67 *
67 * Locking: - The runlist described by @vi must be unlocked on entry and is 68 * Locking: - The runlist described by @vi must be locked on entry and is
68 * unlocked on return. 69 * locked on return. Note if the runlist is locked for reading the
69 * - This function takes the runlist lock of @vi for reading and 70 * lock may be dropped and reacquired. Note the runlist may be
70 * sometimes for writing and sometimes modifies the runlist. 71 * modified when needed runlist fragments need to be mapped.
71 * - The volume lcn bitmap must be unlocked on entry and is unlocked 72 * - The volume lcn bitmap must be unlocked on entry and is unlocked
72 * on return. 73 * on return.
73 * - This function takes the volume lcn bitmap lock for writing and 74 * - This function takes the volume lcn bitmap lock for writing and
74 * modifies the bitmap contents. 75 * modifies the bitmap contents.
75 */ 76 */
76static inline s64 ntfs_cluster_free(struct inode *vi, const VCN start_vcn, 77static inline s64 ntfs_cluster_free(struct inode *vi, const VCN start_vcn,
77 s64 count) 78 s64 count, const BOOL write_locked)
78{ 79{
79 return __ntfs_cluster_free(vi, start_vcn, count, FALSE); 80 return __ntfs_cluster_free(vi, start_vcn, count, write_locked, FALSE);
80} 81}
81 82
82extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, 83extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol,
@@ -93,8 +94,10 @@ extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol,
93 * 94 *
94 * Return 0 on success and -errno on error. 95 * Return 0 on success and -errno on error.
95 * 96 *
96 * Locking: This function takes the volume lcn bitmap lock for writing and 97 * Locking: - This function takes the volume lcn bitmap lock for writing and
97 * modifies the bitmap contents. 98 * modifies the bitmap contents.
99 * - The caller must have locked the runlist @rl for reading or
100 * writing.
98 */ 101 */
99static inline int ntfs_cluster_free_from_rl(ntfs_volume *vol, 102static inline int ntfs_cluster_free_from_rl(ntfs_volume *vol,
100 const runlist_element *rl) 103 const runlist_element *rl)