This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / ntfs / lcnalloc.h
1 /*
2  * lcnalloc.h - Exports for NTFS kernel cluster (de)allocation.  Part of the
3  *              Linux-NTFS project.
4  *
5  * Copyright (c) 2004 Anton Altaparmakov
6  *
7  * This program/include file is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program/include file is distributed in the hope that it will be
13  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program (in the main directory of the Linux-NTFS
19  * distribution in the file COPYING); if not, write to the Free Software
20  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef _LINUX_NTFS_LCNALLOC_H
24 #define _LINUX_NTFS_LCNALLOC_H
25
26 #ifdef NTFS_RW
27
28 #include <linux/fs.h>
29
30 #include "types.h"
31 #include "volume.h"
32
33 typedef enum {
34         FIRST_ZONE      = 0,    /* For sanity checking. */
35         MFT_ZONE        = 0,    /* Allocate from $MFT zone. */
36         DATA_ZONE       = 1,    /* Allocate from $DATA zone. */
37         LAST_ZONE       = 1,    /* For sanity checking. */
38 } NTFS_CLUSTER_ALLOCATION_ZONES;
39
40 extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol,
41                 const VCN start_vcn, const s64 count, const LCN start_lcn,
42                 const NTFS_CLUSTER_ALLOCATION_ZONES zone);
43
44 extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn,
45                 s64 count, const BOOL is_rollback);
46
47 /**
48  * ntfs_cluster_free - free clusters on an ntfs volume
49  * @vi:         vfs inode whose runlist describes the clusters to free
50  * @start_vcn:  vcn in the runlist of @vi at which to start freeing clusters
51  * @count:      number of clusters to free or -1 for all clusters
52  *
53  * Free @count clusters starting at the cluster @start_vcn in the runlist
54  * described by the vfs inode @vi.
55  *
56  * If @count is -1, all clusters from @start_vcn to the end of the runlist are
57  * deallocated.  Thus, to completely free all clusters in a runlist, use
58  * @start_vcn = 0 and @count = -1.
59  *
60  * Note, ntfs_cluster_free() does not modify the runlist at all, so the caller
61  * has to deal with it later.
62  *
63  * Return the number of deallocated clusters (not counting sparse ones) on
64  * success and -errno on error.
65  *
66  * Locking: - The runlist described by @vi must be unlocked on entry and is
67  *            unlocked on return.
68  *          - This function takes the runlist lock of @vi for reading and
69  *            sometimes for writing and sometimes modifies the runlist.
70  *          - The volume lcn bitmap must be unlocked on entry and is unlocked
71  *            on return.
72  *          - This function takes the volume lcn bitmap lock for writing and
73  *            modifies the bitmap contents.
74  */
75 static inline s64 ntfs_cluster_free(struct inode *vi, const VCN start_vcn,
76                 s64 count)
77 {
78         return __ntfs_cluster_free(vi, start_vcn, count, FALSE);
79 }
80
81 #endif /* NTFS_RW */
82
83 #endif /* defined _LINUX_NTFS_LCNALLOC_H */