Blame view
fs/nilfs2/nilfs.h
12 KB
ae98043f5
|
1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
65b4643d3
|
2 3 4 5 6 |
/* * nilfs.h - NILFS local header file. * * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. * |
4b420ab4e
|
7 |
* Written by Koji Sato and Ryusuke Konishi. |
65b4643d3
|
8 9 10 11 12 13 14 15 16 |
*/ #ifndef _NILFS_H #define _NILFS_H #include <linux/kernel.h> #include <linux/buffer_head.h> #include <linux/spinlock.h> #include <linux/blkdev.h> |
e63e88bc5
|
17 18 |
#include <linux/nilfs2_api.h> #include <linux/nilfs2_ondisk.h> |
65b4643d3
|
19 |
#include "the_nilfs.h" |
65b4643d3
|
20 |
#include "bmap.h" |
65b4643d3
|
21 |
|
f5974c8f8
|
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/** * struct nilfs_inode_info - nilfs inode data in memory * @i_flags: inode flags * @i_state: dynamic state flags * @i_bmap: pointer on i_bmap_data * @i_bmap_data: raw block mapping * @i_xattr: <TODO> * @i_dir_start_lookup: page index of last successful search * @i_cno: checkpoint number for GC inode * @i_btnode_cache: cached pages of b-tree nodes * @i_dirty: list for connecting dirty files * @xattr_sem: semaphore for extended attributes processing * @i_bh: buffer contains disk inode * @i_root: root object of the current filesystem tree * @vfs_inode: VFS inode object |
65b4643d3
|
37 38 39 40 41 |
*/ struct nilfs_inode_info { __u32 i_flags; unsigned long i_state; /* Dynamic state flags */ struct nilfs_bmap *i_bmap; |
05d0e94b6
|
42 |
struct nilfs_bmap i_bmap_data; |
65b4643d3
|
43 |
__u64 i_xattr; /* sector_t ??? */ |
65b4643d3
|
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
__u32 i_dir_start_lookup; __u64 i_cno; /* check point number for GC inode */ struct address_space i_btnode_cache; struct list_head i_dirty; /* List for connecting dirty files */ #ifdef CONFIG_NILFS_XATTR /* * Extended attributes can be read independently of the main file * data. Taking i_sem even when reading would cause contention * between readers of EAs and writers of regular file data, so * instead we synchronize on xattr_sem when reading or changing * EAs. */ struct rw_semaphore xattr_sem; #endif |
076a378ba
|
59 60 61 62 |
struct buffer_head *i_bh; /* * i_bh contains a new or dirty * disk inode. */ |
4d8d9293d
|
63 |
struct nilfs_root *i_root; |
65b4643d3
|
64 65 66 67 68 69 70 71 72 73 74 |
struct inode vfs_inode; }; static inline struct nilfs_inode_info *NILFS_I(const struct inode *inode) { return container_of(inode, struct nilfs_inode_info, vfs_inode); } static inline struct nilfs_inode_info * NILFS_BMAP_I(const struct nilfs_bmap *bmap) { |
05d0e94b6
|
75 |
return container_of(bmap, struct nilfs_inode_info, i_bmap_data); |
65b4643d3
|
76 77 78 79 80 81 82 83 |
} static inline struct inode *NILFS_BTNC_I(struct address_space *btnc) { struct nilfs_inode_info *ii = container_of(btnc, struct nilfs_inode_info, i_btnode_cache); return &ii->vfs_inode; } |
65b4643d3
|
84 85 86 87 88 89 90 |
/* * Dynamic state flags of NILFS on-memory inode (i_state) */ enum { NILFS_I_NEW = 0, /* Inode is newly created */ NILFS_I_DIRTY, /* The file is dirty */ NILFS_I_QUEUED, /* inode is in dirty_files list */ |
076a378ba
|
91 92 93 94 |
NILFS_I_BUSY, /* * Inode is grabbed by a segment * constructor */ |
65b4643d3
|
95 96 |
NILFS_I_COLLECTED, /* All dirty blocks are collected */ NILFS_I_UPDATED, /* The file has been written back */ |
b9f661407
|
97 |
NILFS_I_INODE_SYNC, /* dsync is not allowed for inode */ |
65b4643d3
|
98 99 |
NILFS_I_BMAP, /* has bmap and btnode_cache */ NILFS_I_GCINODE, /* inode for GC, on memory only */ |
65b4643d3
|
100 101 102 |
}; /* |
b2ac86e1a
|
103 104 105 106 107 108 109 110 |
* commit flags for nilfs_commit_super and nilfs_sync_super */ enum { NILFS_SB_COMMIT = 0, /* Commit a super block alternately */ NILFS_SB_COMMIT_ALL /* Commit both super blocks */ }; /* |
65b4643d3
|
111 112 |
* Macros to check inode numbers */ |
4ce5c3426
|
113 114 115 116 |
#define NILFS_MDT_INO_BITS \ (BIT(NILFS_DAT_INO) | BIT(NILFS_CPFILE_INO) | \ BIT(NILFS_SUFILE_INO) | BIT(NILFS_IFILE_INO) | \ BIT(NILFS_ATIME_INO) | BIT(NILFS_SKETCH_INO)) |
65b4643d3
|
117 |
|
4ce5c3426
|
118 |
#define NILFS_SYS_INO_BITS (BIT(NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) |
65b4643d3
|
119 |
|
e3154e974
|
120 |
#define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino) |
65b4643d3
|
121 122 |
#define NILFS_MDT_INODE(sb, ino) \ |
4ce5c3426
|
123 |
((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & BIT(ino))) |
65b4643d3
|
124 |
#define NILFS_VALID_INODE(sb, ino) \ |
4ce5c3426
|
125 |
((ino) >= NILFS_FIRST_INO(sb) || (NILFS_SYS_INO_BITS & BIT(ino))) |
65b4643d3
|
126 127 128 129 130 131 132 |
/** * struct nilfs_transaction_info: context information for synchronization * @ti_magic: Magic number * @ti_save: Backup of journal_info field of task_struct * @ti_flags: Flags * @ti_count: Nest level |
65b4643d3
|
133 134 135 136 |
*/ struct nilfs_transaction_info { u32 ti_magic; void *ti_save; |
076a378ba
|
137 138 139 140 |
/* * This should never be used. If it happens, * one of other filesystems has a bug. */ |
65b4643d3
|
141 142 |
unsigned short ti_flags; unsigned short ti_count; |
65b4643d3
|
143 144 145 146 147 148 149 |
}; /* ti_magic */ #define NILFS_TI_MAGIC 0xd9e392fb /* ti_flags */ #define NILFS_TI_DYNAMIC_ALLOC 0x0001 /* Allocated from slab */ |
076a378ba
|
150 151 152 153 |
#define NILFS_TI_SYNC 0x0002 /* * Force to construct segment at the * end of transaction. */ |
65b4643d3
|
154 155 156 157 158 159 160 |
#define NILFS_TI_GC 0x0004 /* GC context */ #define NILFS_TI_COMMIT 0x0008 /* Change happened or not */ #define NILFS_TI_WRITER 0x0010 /* Constructor context */ int nilfs_transaction_begin(struct super_block *, struct nilfs_transaction_info *, int); |
47420c799
|
161 162 |
int nilfs_transaction_commit(struct super_block *); void nilfs_transaction_abort(struct super_block *); |
65b4643d3
|
163 164 165 166 |
static inline void nilfs_set_transaction_flag(unsigned int flag) { struct nilfs_transaction_info *ti = current->journal_info; |
65b4643d3
|
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
ti->ti_flags |= flag; } static inline int nilfs_test_transaction_flag(unsigned int flag) { struct nilfs_transaction_info *ti = current->journal_info; if (ti == NULL || ti->ti_magic != NILFS_TI_MAGIC) return 0; return !!(ti->ti_flags & flag); } static inline int nilfs_doing_gc(void) { return nilfs_test_transaction_flag(NILFS_TI_GC); } static inline int nilfs_doing_construction(void) { return nilfs_test_transaction_flag(NILFS_TI_WRITER); } |
65b4643d3
|
188 189 190 191 192 |
/* * function prototype */ #ifdef CONFIG_NILFS_POSIX_ACL #error "NILFS: not yet supported POSIX ACL" |
65b4643d3
|
193 194 195 |
extern int nilfs_acl_chmod(struct inode *); extern int nilfs_init_acl(struct inode *, struct inode *); #else |
65b4643d3
|
196 197 198 199 200 201 202 203 204 205 206 207 208 |
static inline int nilfs_acl_chmod(struct inode *inode) { return 0; } static inline int nilfs_init_acl(struct inode *inode, struct inode *dir) { inode->i_mode &= ~current_umask(); return 0; } #endif #define NILFS_ATIME_DISABLE |
b253a3e4f
|
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
/* Flags that should be inherited by new inodes from their parent. */ #define NILFS_FL_INHERITED \ (FS_SECRM_FL | FS_UNRM_FL | FS_COMPR_FL | FS_SYNC_FL | \ FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL |\ FS_COMPRBLK_FL | FS_NOCOMP_FL | FS_NOTAIL_FL | FS_DIRSYNC_FL) /* Mask out flags that are inappropriate for the given type of inode. */ static inline __u32 nilfs_mask_flags(umode_t mode, __u32 flags) { if (S_ISDIR(mode)) return flags; else if (S_ISREG(mode)) return flags & ~(FS_DIRSYNC_FL | FS_TOPDIR_FL); else return flags & (FS_NODUMP_FL | FS_NOATIME_FL); } |
65b4643d3
|
225 226 |
/* dir.c */ extern int nilfs_add_link(struct dentry *, struct inode *); |
0319003d0
|
227 |
extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); |
65b4643d3
|
228 229 |
extern int nilfs_make_empty(struct inode *, struct inode *); extern struct nilfs_dir_entry * |
0319003d0
|
230 |
nilfs_find_entry(struct inode *, const struct qstr *, struct page **); |
65b4643d3
|
231 232 233 234 235 236 237 |
extern int nilfs_delete_entry(struct nilfs_dir_entry *, struct page *); extern int nilfs_empty_dir(struct inode *); extern struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct page **); extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *, struct page *, struct inode *); /* file.c */ |
02c24a821
|
238 |
extern int nilfs_sync_file(struct file *, loff_t, loff_t, int); |
65b4643d3
|
239 240 |
/* ioctl.c */ |
7a9461939
|
241 |
long nilfs_ioctl(struct file *, unsigned int, unsigned long); |
828b1c50a
|
242 |
long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
4f6b82883
|
243 244 |
int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *, void **); |
65b4643d3
|
245 246 |
/* inode.c */ |
be667377a
|
247 248 |
void nilfs_inode_add_blocks(struct inode *inode, int n); void nilfs_inode_sub_blocks(struct inode *inode, int n); |
c6e49e3f2
|
249 |
extern struct inode *nilfs_new_inode(struct inode *, umode_t); |
65b4643d3
|
250 251 252 253 |
extern int nilfs_get_block(struct inode *, sector_t, struct buffer_head *, int); extern void nilfs_set_inode_flags(struct inode *); extern int nilfs_read_inode_common(struct inode *, struct nilfs_inode *); extern void nilfs_write_inode_common(struct inode *, struct nilfs_inode *, int); |
032dbb3b5
|
254 255 |
struct inode *nilfs_ilookup(struct super_block *sb, struct nilfs_root *root, unsigned long ino); |
f1e89c86f
|
256 257 |
struct inode *nilfs_iget_locked(struct super_block *sb, struct nilfs_root *root, unsigned long ino); |
4d8d9293d
|
258 259 |
struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root, unsigned long ino); |
263d90cef
|
260 261 |
extern struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino, __u64 cno); |
b9f661407
|
262 |
extern void nilfs_update_inode(struct inode *, struct buffer_head *, int); |
65b4643d3
|
263 |
extern void nilfs_truncate(struct inode *); |
6fd1e5c99
|
264 |
extern void nilfs_evict_inode(struct inode *); |
65b4643d3
|
265 |
extern int nilfs_setattr(struct dentry *, struct iattr *); |
2d1b399b2
|
266 |
extern void nilfs_write_failed(struct address_space *mapping, loff_t to); |
10556cb21
|
267 |
int nilfs_permission(struct inode *inode, int mask); |
bcbc8c648
|
268 |
int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh); |
65b4643d3
|
269 |
extern int nilfs_inode_dirty(struct inode *); |
0c6c44cb9
|
270 |
int nilfs_set_file_dirty(struct inode *inode, unsigned int nr_dirty); |
b9f661407
|
271 |
extern int __nilfs_mark_inode_dirty(struct inode *, int); |
aa3857295
|
272 |
extern void nilfs_dirty_inode(struct inode *, int flags); |
622daaff0
|
273 274 |
int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, __u64 start, __u64 len); |
b9f661407
|
275 276 277 278 279 280 281 282 |
static inline int nilfs_mark_inode_dirty(struct inode *inode) { return __nilfs_mark_inode_dirty(inode, I_DIRTY); } static inline int nilfs_mark_inode_dirty_sync(struct inode *inode) { return __nilfs_mark_inode_dirty(inode, I_DIRTY_SYNC); } |
65b4643d3
|
283 |
|
65b4643d3
|
284 285 |
/* super.c */ extern struct inode *nilfs_alloc_inode(struct super_block *); |
cae3d4ca6
|
286 |
|
b9075fa96
|
287 |
extern __printf(3, 4) |
a66dfb0a9
|
288 289 290 |
void __nilfs_msg(struct super_block *sb, const char *level, const char *fmt, ...); extern __printf(3, 4) |
cae3d4ca6
|
291 292 |
void __nilfs_error(struct super_block *sb, const char *function, const char *fmt, ...); |
cae3d4ca6
|
293 294 |
#ifdef CONFIG_PRINTK |
a66dfb0a9
|
295 296 |
#define nilfs_msg(sb, level, fmt, ...) \ __nilfs_msg(sb, level, fmt, ##__VA_ARGS__) |
cae3d4ca6
|
297 298 299 300 |
#define nilfs_error(sb, fmt, ...) \ __nilfs_error(sb, __func__, fmt, ##__VA_ARGS__) #else |
a66dfb0a9
|
301 |
#define nilfs_msg(sb, level, fmt, ...) \ |
d6517deb0
|
302 303 304 305 |
do { \ no_printk(fmt, ##__VA_ARGS__); \ (void)(sb); \ } while (0) |
cae3d4ca6
|
306 307 308 309 310 311 312 |
#define nilfs_error(sb, fmt, ...) \ do { \ no_printk(fmt, ##__VA_ARGS__); \ __nilfs_error(sb, "", " "); \ } while (0) #endif /* CONFIG_PRINTK */ |
65b4643d3
|
313 |
extern struct nilfs_super_block * |
e339ad31f
|
314 |
nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **); |
65b4643d3
|
315 316 |
extern int nilfs_store_magic_and_option(struct super_block *, struct nilfs_super_block *, char *); |
c5ca48aab
|
317 318 |
extern int nilfs_check_feature_compatibility(struct super_block *, struct nilfs_super_block *); |
60f46b7ef
|
319 320 |
extern void nilfs_set_log_cursor(struct nilfs_super_block *, struct the_nilfs *); |
f7545144c
|
321 322 323 324 |
struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb, int flip); int nilfs_commit_super(struct super_block *sb, int flag); int nilfs_cleanup_super(struct super_block *sb); |
4e33f9eab
|
325 |
int nilfs_resize_fs(struct super_block *sb, __u64 newsize); |
f7545144c
|
326 |
int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, |
4d8d9293d
|
327 |
struct nilfs_root **root); |
032dbb3b5
|
328 |
int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno); |
65b4643d3
|
329 330 331 332 333 334 335 |
/* gcinode.c */ int nilfs_gccache_submit_read_data(struct inode *, sector_t, sector_t, __u64, struct buffer_head **); int nilfs_gccache_submit_read_node(struct inode *, sector_t, __u64, struct buffer_head **); int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *); |
263d90cef
|
336 337 |
int nilfs_init_gcinode(struct inode *inode); void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs); |
65b4643d3
|
338 |
|
dd70edbde
|
339 340 341 342 343 344 345 |
/* sysfs.c */ int __init nilfs_sysfs_init(void); void nilfs_sysfs_exit(void); int nilfs_sysfs_create_device_group(struct super_block *); void nilfs_sysfs_delete_device_group(struct the_nilfs *); int nilfs_sysfs_create_snapshot_group(struct nilfs_root *); void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *); |
65b4643d3
|
346 347 348 |
/* * Inodes and files operations */ |
828c09509
|
349 |
extern const struct file_operations nilfs_dir_operations; |
6e1d5dcc2
|
350 |
extern const struct inode_operations nilfs_file_inode_operations; |
828c09509
|
351 |
extern const struct file_operations nilfs_file_operations; |
7f09410bb
|
352 |
extern const struct address_space_operations nilfs_aops; |
6e1d5dcc2
|
353 354 355 |
extern const struct inode_operations nilfs_dir_inode_operations; extern const struct inode_operations nilfs_special_inode_operations; extern const struct inode_operations nilfs_symlink_inode_operations; |
65b4643d3
|
356 357 358 359 360 361 362 363 |
/* * filesystem type */ extern struct file_system_type nilfs_fs_type; #endif /* _NILFS_H */ |