Blame view
fs/nilfs2/nilfs.h
12.3 KB
ae98043f5 nilfs2: convert t... |
1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
65b4643d3 nilfs2: add inode... |
2 3 4 5 6 |
/* * nilfs.h - NILFS local header file. * * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. * |
4b420ab4e nilfs2: clean up ... |
7 |
* Written by Koji Sato and Ryusuke Konishi. |
65b4643d3 nilfs2: add inode... |
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 nilfs2: move ioct... |
17 18 |
#include <linux/nilfs2_api.h> #include <linux/nilfs2_ondisk.h> |
65b4643d3 nilfs2: add inode... |
19 |
#include "the_nilfs.h" |
65b4643d3 nilfs2: add inode... |
20 |
#include "bmap.h" |
65b4643d3 nilfs2: add inode... |
21 |
|
f5974c8f8 nilfs2: add omitt... |
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 nilfs2: add inode... |
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 nilfs2: get rid o... |
42 |
struct nilfs_bmap i_bmap_data; |
65b4643d3 nilfs2: add inode... |
43 |
__u64 i_xattr; /* sector_t ??? */ |
65b4643d3 nilfs2: add inode... |
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 nilfs2: fix block... |
59 60 61 62 |
struct buffer_head *i_bh; /* * i_bh contains a new or dirty * disk inode. */ |
4d8d9293d nilfs2: set point... |
63 |
struct nilfs_root *i_root; |
65b4643d3 nilfs2: add inode... |
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 nilfs2: get rid o... |
75 |
return container_of(bmap, struct nilfs_inode_info, i_bmap_data); |
65b4643d3 nilfs2: add inode... |
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 nilfs2: add inode... |
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 nilfs2: fix block... |
91 92 93 94 |
NILFS_I_BUSY, /* * Inode is grabbed by a segment * constructor */ |
65b4643d3 nilfs2: add inode... |
95 96 |
NILFS_I_COLLECTED, /* All dirty blocks are collected */ NILFS_I_UPDATED, /* The file has been written back */ |
b9f661407 nilfs2: improve t... |
97 |
NILFS_I_INODE_SYNC, /* dsync is not allowed for inode */ |
65b4643d3 nilfs2: add inode... |
98 99 |
NILFS_I_BMAP, /* has bmap and btnode_cache */ NILFS_I_GCINODE, /* inode for GC, on memory only */ |
65b4643d3 nilfs2: add inode... |
100 101 102 |
}; /* |
b2ac86e1a nilfs2: sync supe... |
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 nilfs2: add inode... |
111 112 |
* Macros to check inode numbers */ |
4ce5c3426 nilfs2: use BIT()... |
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 nilfs2: add inode... |
117 |
|
4ce5c3426 nilfs2: use BIT()... |
118 |
#define NILFS_SYS_INO_BITS (BIT(NILFS_ROOT_INO) | NILFS_MDT_INO_BITS) |
65b4643d3 nilfs2: add inode... |
119 |
|
e3154e974 nilfs2: get rid o... |
120 |
#define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino) |
65b4643d3 nilfs2: add inode... |
121 122 |
#define NILFS_MDT_INODE(sb, ino) \ |
4ce5c3426 nilfs2: use BIT()... |
123 |
((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & BIT(ino))) |
65b4643d3 nilfs2: add inode... |
124 |
#define NILFS_VALID_INODE(sb, ino) \ |
4ce5c3426 nilfs2: use BIT()... |
125 |
((ino) >= NILFS_FIRST_INO(sb) || (NILFS_SYS_INO_BITS & BIT(ino))) |
65b4643d3 nilfs2: add inode... |
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 nilfs2: add inode... |
133 134 135 136 |
*/ struct nilfs_transaction_info { u32 ti_magic; void *ti_save; |
076a378ba nilfs2: fix block... |
137 138 139 140 |
/* * This should never be used. If it happens, * one of other filesystems has a bug. */ |
65b4643d3 nilfs2: add inode... |
141 142 |
unsigned short ti_flags; unsigned short ti_count; |
65b4643d3 nilfs2: add inode... |
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 nilfs2: fix block... |
150 151 152 153 |
#define NILFS_TI_SYNC 0x0002 /* * Force to construct segment at the * end of transaction. */ |
65b4643d3 nilfs2: add inode... |
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 nilfs2: avoid dou... |
161 162 |
int nilfs_transaction_commit(struct super_block *); void nilfs_transaction_abort(struct super_block *); |
65b4643d3 nilfs2: add inode... |
163 164 165 166 |
static inline void nilfs_set_transaction_flag(unsigned int flag) { struct nilfs_transaction_info *ti = current->journal_info; |
65b4643d3 nilfs2: add inode... |
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 nilfs2: add inode... |
188 189 190 191 192 |
/* * function prototype */ #ifdef CONFIG_NILFS_POSIX_ACL #error "NILFS: not yet supported POSIX ACL" |
65b4643d3 nilfs2: add inode... |
193 194 195 |
extern int nilfs_acl_chmod(struct inode *); extern int nilfs_init_acl(struct inode *, struct inode *); #else |
65b4643d3 nilfs2: add inode... |
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 nilfs2: tighten r... |
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 nilfs2: add inode... |
225 226 |
/* dir.c */ extern int nilfs_add_link(struct dentry *, struct inode *); |
0319003d0 nilfs really shou... |
227 |
extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); |
65b4643d3 nilfs2: add inode... |
228 229 |
extern int nilfs_make_empty(struct inode *, struct inode *); extern struct nilfs_dir_entry * |
0319003d0 nilfs really shou... |
230 |
nilfs_find_entry(struct inode *, const struct qstr *, struct page **); |
65b4643d3 nilfs2: add inode... |
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 fs: push i_mutex ... |
238 |
extern int nilfs_sync_file(struct file *, loff_t, loff_t, int); |
65b4643d3 nilfs2: add inode... |
239 240 |
/* ioctl.c */ |
7a9461939 nilfs2: use unloc... |
241 |
long nilfs_ioctl(struct file *, unsigned int, unsigned long); |
828b1c50a nilfs2: add compa... |
242 |
long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
4f6b82883 nilfs2: fix lock ... |
243 244 |
int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *, void **); |
65b4643d3 nilfs2: add inode... |
245 246 |
/* inode.c */ |
be667377a nilfs2: record us... |
247 248 |
void nilfs_inode_add_blocks(struct inode *inode, int n); void nilfs_inode_sub_blocks(struct inode *inode, int n); |
c6e49e3f2 nilfs: propagate ... |
249 |
extern struct inode *nilfs_new_inode(struct inode *, umode_t); |
65b4643d3 nilfs2: add inode... |
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 nilfs2: see state... |
254 255 |
struct inode *nilfs_ilookup(struct super_block *sb, struct nilfs_root *root, unsigned long ino); |
f1e89c86f nilfs2: use iget ... |
256 257 |
struct inode *nilfs_iget_locked(struct super_block *sb, struct nilfs_root *root, unsigned long ino); |
4d8d9293d nilfs2: set point... |
258 259 |
struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root, unsigned long ino); |
263d90cef nilfs2: remove ow... |
260 261 |
extern struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino, __u64 cno); |
b9f661407 nilfs2: improve t... |
262 |
extern void nilfs_update_inode(struct inode *, struct buffer_head *, int); |
65b4643d3 nilfs2: add inode... |
263 |
extern void nilfs_truncate(struct inode *); |
6fd1e5c99 convert nilfs2 to... |
264 |
extern void nilfs_evict_inode(struct inode *); |
65b4643d3 nilfs2: add inode... |
265 |
extern int nilfs_setattr(struct dentry *, struct iattr *); |
2d1b399b2 nilfs2: drop vmtr... |
266 |
extern void nilfs_write_failed(struct address_space *mapping, loff_t to); |
10556cb21 ->permission() sa... |
267 |
int nilfs_permission(struct inode *inode, int mask); |
bcbc8c648 nilfs2: do not pa... |
268 |
int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh); |
65b4643d3 nilfs2: add inode... |
269 |
extern int nilfs_inode_dirty(struct inode *); |
0c6c44cb9 nilfs2: avoid bar... |
270 |
int nilfs_set_file_dirty(struct inode *inode, unsigned int nr_dirty); |
b9f661407 nilfs2: improve t... |
271 |
extern int __nilfs_mark_inode_dirty(struct inode *, int); |
aa3857295 fs: pass exact ty... |
272 |
extern void nilfs_dirty_inode(struct inode *, int flags); |
622daaff0 nilfs2: fiemap su... |
273 274 |
int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, __u64 start, __u64 len); |
b9f661407 nilfs2: improve t... |
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 nilfs2: add inode... |
283 |
|
65b4643d3 nilfs2: add inode... |
284 285 |
/* super.c */ extern struct inode *nilfs_alloc_inode(struct super_block *); |
cae3d4ca6 nilfs2: hide func... |
286 |
|
2987a4cfc nilfs2: convert _... |
287 288 |
__printf(2, 3) void __nilfs_msg(struct super_block *sb, const char *fmt, ...); |
a66dfb0a9 nilfs2: add nilfs... |
289 |
extern __printf(3, 4) |
cae3d4ca6 nilfs2: hide func... |
290 291 |
void __nilfs_error(struct super_block *sb, const char *function, const char *fmt, ...); |
cae3d4ca6 nilfs2: hide func... |
292 293 |
#ifdef CONFIG_PRINTK |
a66dfb0a9 nilfs2: add nilfs... |
294 |
#define nilfs_msg(sb, level, fmt, ...) \ |
2987a4cfc nilfs2: convert _... |
295 |
__nilfs_msg(sb, level fmt, ##__VA_ARGS__) |
cae3d4ca6 nilfs2: hide func... |
296 297 298 299 |
#define nilfs_error(sb, fmt, ...) \ __nilfs_error(sb, __func__, fmt, ##__VA_ARGS__) #else |
a66dfb0a9 nilfs2: add nilfs... |
300 |
#define nilfs_msg(sb, level, fmt, ...) \ |
d6517deb0 nilfs2: replace n... |
301 |
do { \ |
2987a4cfc nilfs2: convert _... |
302 |
no_printk(level fmt, ##__VA_ARGS__); \ |
d6517deb0 nilfs2: replace n... |
303 304 |
(void)(sb); \ } while (0) |
cae3d4ca6 nilfs2: hide func... |
305 306 307 308 309 310 311 |
#define nilfs_error(sb, fmt, ...) \ do { \ no_printk(fmt, ##__VA_ARGS__); \ __nilfs_error(sb, "", " "); \ } while (0) #endif /* CONFIG_PRINTK */ |
a1d0747a3 nilfs2: use a mor... |
312 313 314 315 316 317 318 319 |
#define nilfs_crit(sb, fmt, ...) \ nilfs_msg(sb, KERN_CRIT, fmt, ##__VA_ARGS__) #define nilfs_err(sb, fmt, ...) \ nilfs_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__) #define nilfs_warn(sb, fmt, ...) \ nilfs_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__) #define nilfs_info(sb, fmt, ...) \ nilfs_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__) |
65b4643d3 nilfs2: add inode... |
320 |
extern struct nilfs_super_block * |
e339ad31f nilfs2: introduce... |
321 |
nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **); |
65b4643d3 nilfs2: add inode... |
322 323 |
extern int nilfs_store_magic_and_option(struct super_block *, struct nilfs_super_block *, char *); |
c5ca48aab nilfs2: reject in... |
324 325 |
extern int nilfs_check_feature_compatibility(struct super_block *, struct nilfs_super_block *); |
60f46b7ef nilfs2: separate ... |
326 327 |
extern void nilfs_set_log_cursor(struct nilfs_super_block *, struct the_nilfs *); |
f7545144c nilfs2: use sb in... |
328 329 330 331 |
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 nilfs2: implement... |
332 |
int nilfs_resize_fs(struct super_block *sb, __u64 newsize); |
f7545144c nilfs2: use sb in... |
333 |
int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, |
4d8d9293d nilfs2: set point... |
334 |
struct nilfs_root **root); |
032dbb3b5 nilfs2: see state... |
335 |
int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno); |
65b4643d3 nilfs2: add inode... |
336 337 338 339 340 341 342 |
/* 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 nilfs2: remove ow... |
343 344 |
int nilfs_init_gcinode(struct inode *inode); void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs); |
65b4643d3 nilfs2: add inode... |
345 |
|
dd70edbde nilfs2: integrate... |
346 347 348 349 350 351 352 |
/* 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 nilfs2: add inode... |
353 354 355 |
/* * Inodes and files operations */ |
828c09509 const: constify r... |
356 |
extern const struct file_operations nilfs_dir_operations; |
6e1d5dcc2 const: mark remai... |
357 |
extern const struct inode_operations nilfs_file_inode_operations; |
828c09509 const: constify r... |
358 |
extern const struct file_operations nilfs_file_operations; |
7f09410bb const: mark remai... |
359 |
extern const struct address_space_operations nilfs_aops; |
6e1d5dcc2 const: mark remai... |
360 361 362 |
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 nilfs2: add inode... |
363 364 365 366 367 368 369 370 |
/* * filesystem type */ extern struct file_system_type nilfs_fs_type; #endif /* _NILFS_H */ |