Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lcnalloc.h
Go to the documentation of this file.
1 /*
2  * lcnalloc.h - Exports for NTFS kernel cluster (de)allocation. Part of the
3  * Linux-NTFS project.
4  *
5  * Copyright (c) 2004-2005 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 "attrib.h"
31 #include "types.h"
32 #include "inode.h"
33 #include "runlist.h"
34 #include "volume.h"
35 
36 typedef enum {
37  FIRST_ZONE = 0, /* For sanity checking. */
38  MFT_ZONE = 0, /* Allocate from $MFT zone. */
39  DATA_ZONE = 1, /* Allocate from $DATA zone. */
40  LAST_ZONE = 1, /* For sanity checking. */
41 } NTFS_CLUSTER_ALLOCATION_ZONES;
42 
43 extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol,
44  const VCN start_vcn, const s64 count, const LCN start_lcn,
45  const NTFS_CLUSTER_ALLOCATION_ZONES zone,
46  const bool is_extension);
47 
48 extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn,
49  s64 count, ntfs_attr_search_ctx *ctx, const bool is_rollback);
50 
107 static inline s64 ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn,
109 {
110  return __ntfs_cluster_free(ni, start_vcn, count, ctx, false);
111 }
112 
113 extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol,
114  const runlist_element *rl);
115 
132 static inline int ntfs_cluster_free_from_rl(ntfs_volume *vol,
133  const runlist_element *rl)
134 {
135  int ret;
136 
137  down_write(&vol->lcnbmp_lock);
138  ret = ntfs_cluster_free_from_rl_nolock(vol, rl);
139  up_write(&vol->lcnbmp_lock);
140  return ret;
141 }
142 
143 #endif /* NTFS_RW */
144 
145 #endif /* defined _LINUX_NTFS_LCNALLOC_H */