f2fs.h (b10778a00d40b3d9fdaaf5891e802794781ff71c) f2fs.h (67298804f34452a53a9ec9e609d95aa35084132b)
1/*
2 * fs/f2fs/f2fs.h
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 7 unchanged lines hidden (view full) ---

16#include <linux/buffer_head.h>
17#include <linux/slab.h>
18#include <linux/crc32.h>
19#include <linux/magic.h>
20#include <linux/kobject.h>
21#include <linux/sched.h>
22
23#ifdef CONFIG_F2FS_CHECK_FS
1/*
2 * fs/f2fs/f2fs.h
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 7 unchanged lines hidden (view full) ---

16#include <linux/buffer_head.h>
17#include <linux/slab.h>
18#include <linux/crc32.h>
19#include <linux/magic.h>
20#include <linux/kobject.h>
21#include <linux/sched.h>
22
23#ifdef CONFIG_F2FS_CHECK_FS
24#define f2fs_bug_on(condition) BUG_ON(condition)
24#define f2fs_bug_on(sbi, condition) BUG_ON(condition)
25#define f2fs_down_write(x, y) down_write_nest_lock(x, y)
26#else
25#define f2fs_down_write(x, y) down_write_nest_lock(x, y)
26#else
27#define f2fs_bug_on(condition) WARN_ON(condition)
27#define f2fs_bug_on(sbi, condition) \
28 do { \
29 if (unlikely(condition)) { \
30 WARN_ON(1); \
31 sbi->need_fsck = true; \
32 } \
33 } while (0)
28#define f2fs_down_write(x, y) down_write(x)
29#endif
30
31/*
32 * For mount options
33 */
34#define F2FS_MOUNT_BG_GC 0x00000001
35#define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002
36#define F2FS_MOUNT_DISCARD 0x00000004
37#define F2FS_MOUNT_NOHEAP 0x00000008
38#define F2FS_MOUNT_XATTR_USER 0x00000010
39#define F2FS_MOUNT_POSIX_ACL 0x00000020
40#define F2FS_MOUNT_DISABLE_EXT_IDENTIFY 0x00000040
41#define F2FS_MOUNT_INLINE_XATTR 0x00000080
42#define F2FS_MOUNT_INLINE_DATA 0x00000100
34#define f2fs_down_write(x, y) down_write(x)
35#endif
36
37/*
38 * For mount options
39 */
40#define F2FS_MOUNT_BG_GC 0x00000001
41#define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002
42#define F2FS_MOUNT_DISCARD 0x00000004
43#define F2FS_MOUNT_NOHEAP 0x00000008
44#define F2FS_MOUNT_XATTR_USER 0x00000010
45#define F2FS_MOUNT_POSIX_ACL 0x00000020
46#define F2FS_MOUNT_DISABLE_EXT_IDENTIFY 0x00000040
47#define F2FS_MOUNT_INLINE_XATTR 0x00000080
48#define F2FS_MOUNT_INLINE_DATA 0x00000100
43#define F2FS_MOUNT_FLUSH_MERGE 0x00000200
44#define F2FS_MOUNT_NOBARRIER 0x00000400
49#define F2FS_MOUNT_INLINE_DENTRY 0x00000200
50#define F2FS_MOUNT_FLUSH_MERGE 0x00000400
51#define F2FS_MOUNT_NOBARRIER 0x00000800
52#define F2FS_MOUNT_FASTBOOT 0x00001000
45
46#define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)
47#define set_opt(sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
48#define test_opt(sbi, option) (sbi->mount_opt.opt & F2FS_MOUNT_##option)
49
50#define ver_after(a, b) (typecheck(unsigned long long, a) && \
51 typecheck(unsigned long long, b) && \
52 ((long long)((a) - (b)) > 0))

--- 32 unchanged lines hidden (view full) ---

85/*
86 * For checkpoint manager
87 */
88enum {
89 NAT_BITMAP,
90 SIT_BITMAP
91};
92
53
54#define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)
55#define set_opt(sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
56#define test_opt(sbi, option) (sbi->mount_opt.opt & F2FS_MOUNT_##option)
57
58#define ver_after(a, b) (typecheck(unsigned long long, a) && \
59 typecheck(unsigned long long, b) && \
60 ((long long)((a) - (b)) > 0))

--- 32 unchanged lines hidden (view full) ---

93/*
94 * For checkpoint manager
95 */
96enum {
97 NAT_BITMAP,
98 SIT_BITMAP
99};
100
101enum {
102 CP_UMOUNT,
103 CP_SYNC,
104 CP_DISCARD,
105};
106
107struct cp_control {
108 int reason;
109 __u64 trim_start;
110 __u64 trim_end;
111 __u64 trim_minlen;
112 __u64 trimmed;
113};
114
93/*
94 * For CP/NAT/SIT/SSA readahead
95 */
96enum {
97 META_CP,
98 META_NAT,
99 META_SIT,
115/*
116 * For CP/NAT/SIT/SSA readahead
117 */
118enum {
119 META_CP,
120 META_NAT,
121 META_SIT,
100 META_SSA
122 META_SSA,
123 META_POR,
101};
102
103/* for the list of ino */
104enum {
105 ORPHAN_INO, /* for orphan ino list */
106 APPEND_INO, /* for append ino list */
107 UPDATE_INO, /* for update ino list */
108 MAX_INO_ENTRY, /* max. list */

--- 16 unchanged lines hidden (view full) ---

125 block_t blkaddr; /* block address to be discarded */
126 int len; /* # of consecutive blocks of the discard */
127};
128
129/* for the list of fsync inodes, used only during recovery */
130struct fsync_inode_entry {
131 struct list_head list; /* list head */
132 struct inode *inode; /* vfs inode pointer */
124};
125
126/* for the list of ino */
127enum {
128 ORPHAN_INO, /* for orphan ino list */
129 APPEND_INO, /* for append ino list */
130 UPDATE_INO, /* for update ino list */
131 MAX_INO_ENTRY, /* max. list */

--- 16 unchanged lines hidden (view full) ---

148 block_t blkaddr; /* block address to be discarded */
149 int len; /* # of consecutive blocks of the discard */
150};
151
152/* for the list of fsync inodes, used only during recovery */
153struct fsync_inode_entry {
154 struct list_head list; /* list head */
155 struct inode *inode; /* vfs inode pointer */
133 block_t blkaddr; /* block address locating the last inode */
156 block_t blkaddr; /* block address locating the last fsync */
157 block_t last_dentry; /* block address locating the last dentry */
158 block_t last_inode; /* block address locating the last inode */
134};
135
136#define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats))
137#define sits_in_cursum(sum) (le16_to_cpu(sum->n_sits))
138
139#define nat_in_journal(sum, i) (sum->nat_j.entries[i].ne)
140#define nid_in_journal(sum, i) (sum->nat_j.entries[i].nid)
141#define sit_in_journal(sum, i) (sum->sit_j.entries[i].se)
142#define segno_in_journal(sum, i) (sum->sit_j.entries[i].segno)
143
159};
160
161#define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats))
162#define sits_in_cursum(sum) (le16_to_cpu(sum->n_sits))
163
164#define nat_in_journal(sum, i) (sum->nat_j.entries[i].ne)
165#define nid_in_journal(sum, i) (sum->nat_j.entries[i].nid)
166#define sit_in_journal(sum, i) (sum->sit_j.entries[i].se)
167#define segno_in_journal(sum, i) (sum->sit_j.entries[i].segno)
168
169#define MAX_NAT_JENTRIES(sum) (NAT_JOURNAL_ENTRIES - nats_in_cursum(sum))
170#define MAX_SIT_JENTRIES(sum) (SIT_JOURNAL_ENTRIES - sits_in_cursum(sum))
171
144static inline int update_nats_in_cursum(struct f2fs_summary_block *rs, int i)
145{
146 int before = nats_in_cursum(rs);
147 rs->n_nats = cpu_to_le16(before + i);
148 return before;
149}
150
151static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
152{
153 int before = sits_in_cursum(rs);
154 rs->n_sits = cpu_to_le16(before + i);
155 return before;
156}
157
172static inline int update_nats_in_cursum(struct f2fs_summary_block *rs, int i)
173{
174 int before = nats_in_cursum(rs);
175 rs->n_nats = cpu_to_le16(before + i);
176 return before;
177}
178
179static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
180{
181 int before = sits_in_cursum(rs);
182 rs->n_sits = cpu_to_le16(before + i);
183 return before;
184}
185
186static inline bool __has_cursum_space(struct f2fs_summary_block *sum, int size,
187 int type)
188{
189 if (type == NAT_JOURNAL)
190 return size <= MAX_NAT_JENTRIES(sum);
191 return size <= MAX_SIT_JENTRIES(sum);
192}
193
158/*
159 * ioctl commands
160 */
194/*
195 * ioctl commands
196 */
161#define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS
162#define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS
197#define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS
198#define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS
163
199
200#define F2FS_IOCTL_MAGIC 0xf5
201#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
202#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
203#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
204
164#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
165/*
166 * ioctl commands in 32 bit emulation
167 */
168#define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS
169#define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS
170#endif
171
172/*
173 * For INODE and NODE manager
174 */
205#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
206/*
207 * ioctl commands in 32 bit emulation
208 */
209#define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS
210#define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS
211#endif
212
213/*
214 * For INODE and NODE manager
215 */
216/* for directory operations */
217struct f2fs_dentry_ptr {
218 const void *bitmap;
219 struct f2fs_dir_entry *dentry;
220 __u8 (*filename)[F2FS_SLOT_LEN];
221 int max;
222};
223
224static inline void make_dentry_ptr(struct f2fs_dentry_ptr *d,
225 void *src, int type)
226{
227 if (type == 1) {
228 struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src;
229 d->max = NR_DENTRY_IN_BLOCK;
230 d->bitmap = &t->dentry_bitmap;
231 d->dentry = t->dentry;
232 d->filename = t->filename;
233 } else {
234 struct f2fs_inline_dentry *t = (struct f2fs_inline_dentry *)src;
235 d->max = NR_INLINE_DENTRY;
236 d->bitmap = &t->dentry_bitmap;
237 d->dentry = t->dentry;
238 d->filename = t->filename;
239 }
240}
241
175/*
176 * XATTR_NODE_OFFSET stores xattrs to one node block per file keeping -1
177 * as its node offset to distinguish from index node blocks.
178 * But some bits are used to mark the node block.
179 */
180#define XATTR_NODE_OFFSET ((((unsigned int)-1) << OFFSET_BIT_SHIFT) \
181 >> OFFSET_BIT_SHIFT)
182enum {

--- 34 unchanged lines hidden (view full) ---

217 unsigned char i_dir_level; /* use for dentry level for large dir */
218 unsigned int i_current_depth; /* use only in directory structure */
219 unsigned int i_pino; /* parent inode number */
220 umode_t i_acl_mode; /* keep file acl mode temporarily */
221
222 /* Use below internally in f2fs*/
223 unsigned long flags; /* use to pass per-file flags */
224 struct rw_semaphore i_sem; /* protect fi info */
242/*
243 * XATTR_NODE_OFFSET stores xattrs to one node block per file keeping -1
244 * as its node offset to distinguish from index node blocks.
245 * But some bits are used to mark the node block.
246 */
247#define XATTR_NODE_OFFSET ((((unsigned int)-1) << OFFSET_BIT_SHIFT) \
248 >> OFFSET_BIT_SHIFT)
249enum {

--- 34 unchanged lines hidden (view full) ---

284 unsigned char i_dir_level; /* use for dentry level for large dir */
285 unsigned int i_current_depth; /* use only in directory structure */
286 unsigned int i_pino; /* parent inode number */
287 umode_t i_acl_mode; /* keep file acl mode temporarily */
288
289 /* Use below internally in f2fs*/
290 unsigned long flags; /* use to pass per-file flags */
291 struct rw_semaphore i_sem; /* protect fi info */
225 atomic_t dirty_dents; /* # of dirty dentry pages */
292 atomic_t dirty_pages; /* # of dirty pages */
226 f2fs_hash_t chash; /* hash value of given file name */
227 unsigned int clevel; /* maximum level of given file name */
228 nid_t i_xattr_nid; /* node id that contains xattrs */
229 unsigned long long xattr_ver; /* cp version of xattr modification */
230 struct extent_info ext; /* in-memory extent cache entry */
231 struct dir_inode_entry *dirty_dir; /* the pointer of dirty dir */
293 f2fs_hash_t chash; /* hash value of given file name */
294 unsigned int clevel; /* maximum level of given file name */
295 nid_t i_xattr_nid; /* node id that contains xattrs */
296 unsigned long long xattr_ver; /* cp version of xattr modification */
297 struct extent_info ext; /* in-memory extent cache entry */
298 struct dir_inode_entry *dirty_dir; /* the pointer of dirty dir */
299
300 struct radix_tree_root inmem_root; /* radix tree for inmem pages */
301 struct list_head inmem_pages; /* inmemory pages managed by f2fs */
302 struct mutex inmem_lock; /* lock for inmemory pages */
232};
233
234static inline void get_extent_info(struct extent_info *ext,
235 struct f2fs_extent i_ext)
236{
237 write_lock(&ext->ext_lock);
238 ext->fofs = le32_to_cpu(i_ext.fofs);
239 ext->blk_addr = le32_to_cpu(i_ext.blk_addr);

--- 15 unchanged lines hidden (view full) ---

255 block_t nat_blkaddr; /* base disk address of NAT */
256 nid_t max_nid; /* maximum possible node ids */
257 nid_t available_nids; /* maximum available node ids */
258 nid_t next_scan_nid; /* the next nid to be scanned */
259 unsigned int ram_thresh; /* control the memory footprint */
260
261 /* NAT cache management */
262 struct radix_tree_root nat_root;/* root of the nat entry cache */
303};
304
305static inline void get_extent_info(struct extent_info *ext,
306 struct f2fs_extent i_ext)
307{
308 write_lock(&ext->ext_lock);
309 ext->fofs = le32_to_cpu(i_ext.fofs);
310 ext->blk_addr = le32_to_cpu(i_ext.blk_addr);

--- 15 unchanged lines hidden (view full) ---

326 block_t nat_blkaddr; /* base disk address of NAT */
327 nid_t max_nid; /* maximum possible node ids */
328 nid_t available_nids; /* maximum available node ids */
329 nid_t next_scan_nid; /* the next nid to be scanned */
330 unsigned int ram_thresh; /* control the memory footprint */
331
332 /* NAT cache management */
333 struct radix_tree_root nat_root;/* root of the nat entry cache */
334 struct radix_tree_root nat_set_root;/* root of the nat set cache */
263 rwlock_t nat_tree_lock; /* protect nat_tree_lock */
335 rwlock_t nat_tree_lock; /* protect nat_tree_lock */
264 unsigned int nat_cnt; /* the # of cached nat entries */
265 struct list_head nat_entries; /* cached nat entry list (clean) */
336 struct list_head nat_entries; /* cached nat entry list (clean) */
266 struct list_head dirty_nat_entries; /* cached nat entry list (dirty) */
267 struct list_head nat_entry_set; /* nat entry set list */
337 unsigned int nat_cnt; /* the # of cached nat entries */
268 unsigned int dirty_nat_cnt; /* total num of nat entries in set */
269
270 /* free node ids management */
271 struct radix_tree_root free_nid_root;/* root of the free_nid cache */
272 struct list_head free_nid_list; /* a list for free nids */
273 spinlock_t free_nid_list_lock; /* protect free nid list */
274 unsigned int fcnt; /* the number of free node id */
275 struct mutex build_lock; /* lock for build free nids */

--- 51 unchanged lines hidden (view full) ---

327 CURSEG_COLD_DATA, /* multimedia or GCed data blocks */
328 CURSEG_HOT_NODE, /* direct node blocks of directory files */
329 CURSEG_WARM_NODE, /* direct node blocks of normal files */
330 CURSEG_COLD_NODE, /* indirect node blocks */
331 NO_CHECK_TYPE
332};
333
334struct flush_cmd {
338 unsigned int dirty_nat_cnt; /* total num of nat entries in set */
339
340 /* free node ids management */
341 struct radix_tree_root free_nid_root;/* root of the free_nid cache */
342 struct list_head free_nid_list; /* a list for free nids */
343 spinlock_t free_nid_list_lock; /* protect free nid list */
344 unsigned int fcnt; /* the number of free node id */
345 struct mutex build_lock; /* lock for build free nids */

--- 51 unchanged lines hidden (view full) ---

397 CURSEG_COLD_DATA, /* multimedia or GCed data blocks */
398 CURSEG_HOT_NODE, /* direct node blocks of directory files */
399 CURSEG_WARM_NODE, /* direct node blocks of normal files */
400 CURSEG_COLD_NODE, /* indirect node blocks */
401 NO_CHECK_TYPE
402};
403
404struct flush_cmd {
335 struct flush_cmd *next;
336 struct completion wait;
405 struct completion wait;
406 struct llist_node llnode;
337 int ret;
338};
339
340struct flush_cmd_control {
341 struct task_struct *f2fs_issue_flush; /* flush thread */
342 wait_queue_head_t flush_wait_queue; /* waiting queue for wake-up */
407 int ret;
408};
409
410struct flush_cmd_control {
411 struct task_struct *f2fs_issue_flush; /* flush thread */
412 wait_queue_head_t flush_wait_queue; /* waiting queue for wake-up */
343 struct flush_cmd *issue_list; /* list for command issue */
344 struct flush_cmd *dispatch_list; /* list for command dispatch */
345 spinlock_t issue_lock; /* for issue list lock */
346 struct flush_cmd *issue_tail; /* list tail of issue list */
413 struct llist_head issue_list; /* list for command issue */
414 struct llist_node *dispatch_list; /* list for command dispatch */
347};
348
349struct f2fs_sm_info {
350 struct sit_info *sit_info; /* whole segment information */
351 struct free_segmap_info *free_info; /* free segment information */
352 struct dirty_seglist_info *dirty_info; /* dirty segment information */
353 struct curseg_info *curseg_array; /* active segment information */
354

--- 9 unchanged lines hidden (view full) ---

364 /* a threshold to reclaim prefree segments */
365 unsigned int rec_prefree_segments;
366
367 /* for small discard management */
368 struct list_head discard_list; /* 4KB discard list */
369 int nr_discards; /* # of discards in the list */
370 int max_discards; /* max. discards to be issued */
371
415};
416
417struct f2fs_sm_info {
418 struct sit_info *sit_info; /* whole segment information */
419 struct free_segmap_info *free_info; /* free segment information */
420 struct dirty_seglist_info *dirty_info; /* dirty segment information */
421 struct curseg_info *curseg_array; /* active segment information */
422

--- 9 unchanged lines hidden (view full) ---

432 /* a threshold to reclaim prefree segments */
433 unsigned int rec_prefree_segments;
434
435 /* for small discard management */
436 struct list_head discard_list; /* 4KB discard list */
437 int nr_discards; /* # of discards in the list */
438 int max_discards; /* max. discards to be issued */
439
440 struct list_head sit_entry_set; /* sit entry set list */
441
372 unsigned int ipu_policy; /* in-place-update policy */
373 unsigned int min_ipu_util; /* in-place-update threshold */
442 unsigned int ipu_policy; /* in-place-update policy */
443 unsigned int min_ipu_util; /* in-place-update threshold */
444 unsigned int min_fsync_blocks; /* threshold for fsync */
374
375 /* for flush command control */
376 struct flush_cmd_control *cmd_control_info;
377
378};
379
380/*
381 * For superblock

--- 41 unchanged lines hidden (view full) ---

423struct f2fs_bio_info {
424 struct f2fs_sb_info *sbi; /* f2fs superblock */
425 struct bio *bio; /* bios to merge */
426 sector_t last_block_in_bio; /* last block number */
427 struct f2fs_io_info fio; /* store buffered io info. */
428 struct rw_semaphore io_rwsem; /* blocking op for bio */
429};
430
445
446 /* for flush command control */
447 struct flush_cmd_control *cmd_control_info;
448
449};
450
451/*
452 * For superblock

--- 41 unchanged lines hidden (view full) ---

494struct f2fs_bio_info {
495 struct f2fs_sb_info *sbi; /* f2fs superblock */
496 struct bio *bio; /* bios to merge */
497 sector_t last_block_in_bio; /* last block number */
498 struct f2fs_io_info fio; /* store buffered io info. */
499 struct rw_semaphore io_rwsem; /* blocking op for bio */
500};
501
502/* for inner inode cache management */
503struct inode_management {
504 struct radix_tree_root ino_root; /* ino entry array */
505 spinlock_t ino_lock; /* for ino entry lock */
506 struct list_head ino_list; /* inode list head */
507 unsigned long ino_num; /* number of entries */
508};
509
431struct f2fs_sb_info {
432 struct super_block *sb; /* pointer to VFS super block */
433 struct proc_dir_entry *s_proc; /* proc entry */
434 struct buffer_head *raw_super_buf; /* buffer head of raw sb */
435 struct f2fs_super_block *raw_super; /* raw super block pointer */
436 int s_dirty; /* dirty flag for checkpoint */
510struct f2fs_sb_info {
511 struct super_block *sb; /* pointer to VFS super block */
512 struct proc_dir_entry *s_proc; /* proc entry */
513 struct buffer_head *raw_super_buf; /* buffer head of raw sb */
514 struct f2fs_super_block *raw_super; /* raw super block pointer */
515 int s_dirty; /* dirty flag for checkpoint */
516 bool need_fsck; /* need fsck.f2fs to fix */
437
438 /* for node-related operations */
439 struct f2fs_nm_info *nm_info; /* node manager */
440 struct inode *node_inode; /* cache node blocks */
441
442 /* for segment-related operations */
443 struct f2fs_sm_info *sm_info; /* segment manager */
444
445 /* for bio operations */
446 struct f2fs_bio_info read_io; /* for read bios */
447 struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */
517
518 /* for node-related operations */
519 struct f2fs_nm_info *nm_info; /* node manager */
520 struct inode *node_inode; /* cache node blocks */
521
522 /* for segment-related operations */
523 struct f2fs_sm_info *sm_info; /* segment manager */
524
525 /* for bio operations */
526 struct f2fs_bio_info read_io; /* for read bios */
527 struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */
448 struct completion *wait_io; /* for completion bios */
449
450 /* for checkpoint */
451 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
452 struct inode *meta_inode; /* cache meta blocks */
453 struct mutex cp_mutex; /* checkpoint procedure lock */
454 struct rw_semaphore cp_rwsem; /* blocking FS operations */
455 struct rw_semaphore node_write; /* locking node writes */
456 struct mutex writepages; /* mutex for writepages() */
457 bool por_doing; /* recovery is doing or not */
458 wait_queue_head_t cp_wait;
459
528
529 /* for checkpoint */
530 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
531 struct inode *meta_inode; /* cache meta blocks */
532 struct mutex cp_mutex; /* checkpoint procedure lock */
533 struct rw_semaphore cp_rwsem; /* blocking FS operations */
534 struct rw_semaphore node_write; /* locking node writes */
535 struct mutex writepages; /* mutex for writepages() */
536 bool por_doing; /* recovery is doing or not */
537 wait_queue_head_t cp_wait;
538
460 /* for inode management */
461 struct radix_tree_root ino_root[MAX_INO_ENTRY]; /* ino entry array */
462 spinlock_t ino_lock[MAX_INO_ENTRY]; /* for ino entry lock */
463 struct list_head ino_list[MAX_INO_ENTRY]; /* inode list head */
539 struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */
464
465 /* for orphan inode, use 0'th array */
540
541 /* for orphan inode, use 0'th array */
466 unsigned int n_orphans; /* # of orphan inodes */
467 unsigned int max_orphans; /* max orphan inodes */
468
469 /* for directory inode management */
470 struct list_head dir_inode_list; /* dir inode list */
471 spinlock_t dir_inode_lock; /* for dir inode list lock */
472
473 /* basic filesystem units */
474 unsigned int log_sectors_per_block; /* log2 sectors per block */

--- 35 unchanged lines hidden (view full) ---

510 * one is for the LFS mode, and the other is for the SSR mode.
511 */
512#ifdef CONFIG_F2FS_STAT_FS
513 struct f2fs_stat_info *stat_info; /* FS status information */
514 unsigned int segment_count[2]; /* # of allocated segments */
515 unsigned int block_count[2]; /* # of allocated blocks */
516 int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
517 int inline_inode; /* # of inline_data inodes */
542 unsigned int max_orphans; /* max orphan inodes */
543
544 /* for directory inode management */
545 struct list_head dir_inode_list; /* dir inode list */
546 spinlock_t dir_inode_lock; /* for dir inode list lock */
547
548 /* basic filesystem units */
549 unsigned int log_sectors_per_block; /* log2 sectors per block */

--- 35 unchanged lines hidden (view full) ---

585 * one is for the LFS mode, and the other is for the SSR mode.
586 */
587#ifdef CONFIG_F2FS_STAT_FS
588 struct f2fs_stat_info *stat_info; /* FS status information */
589 unsigned int segment_count[2]; /* # of allocated segments */
590 unsigned int block_count[2]; /* # of allocated blocks */
591 int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
592 int inline_inode; /* # of inline_data inodes */
593 int inline_dir; /* # of inline_dentry inodes */
518 int bg_gc; /* background gc calls */
519 unsigned int n_dirty_dirs; /* # of dir inodes */
520#endif
521 unsigned int last_victim[2]; /* last victim segment # */
522 spinlock_t stat_lock; /* lock for stat operations */
523
524 /* For sysfs suppport */
525 struct kobject s_kobj;

--- 8 unchanged lines hidden (view full) ---

534 return container_of(inode, struct f2fs_inode_info, vfs_inode);
535}
536
537static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb)
538{
539 return sb->s_fs_info;
540}
541
594 int bg_gc; /* background gc calls */
595 unsigned int n_dirty_dirs; /* # of dir inodes */
596#endif
597 unsigned int last_victim[2]; /* last victim segment # */
598 spinlock_t stat_lock; /* lock for stat operations */
599
600 /* For sysfs suppport */
601 struct kobject s_kobj;

--- 8 unchanged lines hidden (view full) ---

610 return container_of(inode, struct f2fs_inode_info, vfs_inode);
611}
612
613static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb)
614{
615 return sb->s_fs_info;
616}
617
618static inline struct f2fs_sb_info *F2FS_I_SB(struct inode *inode)
619{
620 return F2FS_SB(inode->i_sb);
621}
622
623static inline struct f2fs_sb_info *F2FS_M_SB(struct address_space *mapping)
624{
625 return F2FS_I_SB(mapping->host);
626}
627
628static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page)
629{
630 return F2FS_M_SB(page->mapping);
631}
632
542static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
543{
544 return (struct f2fs_super_block *)(sbi->raw_super);
545}
546
547static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi)
548{
549 return (struct f2fs_checkpoint *)(sbi->ckpt);

--- 148 unchanged lines hidden (view full) ---

698 return true;
699}
700
701static inline void dec_valid_block_count(struct f2fs_sb_info *sbi,
702 struct inode *inode,
703 blkcnt_t count)
704{
705 spin_lock(&sbi->stat_lock);
633static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
634{
635 return (struct f2fs_super_block *)(sbi->raw_super);
636}
637
638static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi)
639{
640 return (struct f2fs_checkpoint *)(sbi->ckpt);

--- 148 unchanged lines hidden (view full) ---

789 return true;
790}
791
792static inline void dec_valid_block_count(struct f2fs_sb_info *sbi,
793 struct inode *inode,
794 blkcnt_t count)
795{
796 spin_lock(&sbi->stat_lock);
706 f2fs_bug_on(sbi->total_valid_block_count < (block_t) count);
707 f2fs_bug_on(inode->i_blocks < count);
797 f2fs_bug_on(sbi, sbi->total_valid_block_count < (block_t) count);
798 f2fs_bug_on(sbi, inode->i_blocks < count);
708 inode->i_blocks -= count;
709 sbi->total_valid_block_count -= (block_t)count;
710 spin_unlock(&sbi->stat_lock);
711}
712
713static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
714{
715 atomic_inc(&sbi->nr_pages[count_type]);
716 F2FS_SET_SB_DIRT(sbi);
717}
718
799 inode->i_blocks -= count;
800 sbi->total_valid_block_count -= (block_t)count;
801 spin_unlock(&sbi->stat_lock);
802}
803
804static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
805{
806 atomic_inc(&sbi->nr_pages[count_type]);
807 F2FS_SET_SB_DIRT(sbi);
808}
809
719static inline void inode_inc_dirty_dents(struct inode *inode)
810static inline void inode_inc_dirty_pages(struct inode *inode)
720{
811{
721 inc_page_count(F2FS_SB(inode->i_sb), F2FS_DIRTY_DENTS);
722 atomic_inc(&F2FS_I(inode)->dirty_dents);
812 atomic_inc(&F2FS_I(inode)->dirty_pages);
813 if (S_ISDIR(inode->i_mode))
814 inc_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS);
723}
724
725static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type)
726{
727 atomic_dec(&sbi->nr_pages[count_type]);
728}
729
815}
816
817static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type)
818{
819 atomic_dec(&sbi->nr_pages[count_type]);
820}
821
730static inline void inode_dec_dirty_dents(struct inode *inode)
822static inline void inode_dec_dirty_pages(struct inode *inode)
731{
823{
732 if (!S_ISDIR(inode->i_mode))
824 if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode))
733 return;
734
825 return;
826
735 dec_page_count(F2FS_SB(inode->i_sb), F2FS_DIRTY_DENTS);
736 atomic_dec(&F2FS_I(inode)->dirty_dents);
827 atomic_dec(&F2FS_I(inode)->dirty_pages);
828
829 if (S_ISDIR(inode->i_mode))
830 dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS);
737}
738
739static inline int get_pages(struct f2fs_sb_info *sbi, int count_type)
740{
741 return atomic_read(&sbi->nr_pages[count_type]);
742}
743
831}
832
833static inline int get_pages(struct f2fs_sb_info *sbi, int count_type)
834{
835 return atomic_read(&sbi->nr_pages[count_type]);
836}
837
744static inline int get_dirty_dents(struct inode *inode)
838static inline int get_dirty_pages(struct inode *inode)
745{
839{
746 return atomic_read(&F2FS_I(inode)->dirty_dents);
840 return atomic_read(&F2FS_I(inode)->dirty_pages);
747}
748
749static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
750{
751 unsigned int pages_per_sec = sbi->segs_per_sec *
752 (1 << sbi->log_blocks_per_seg);
753 return ((get_pages(sbi, block_type) + pages_per_sec - 1)
754 >> sbi->log_blocks_per_seg) / sbi->segs_per_sec;

--- 88 unchanged lines hidden (view full) ---

843 return true;
844}
845
846static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
847 struct inode *inode)
848{
849 spin_lock(&sbi->stat_lock);
850
841}
842
843static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
844{
845 unsigned int pages_per_sec = sbi->segs_per_sec *
846 (1 << sbi->log_blocks_per_seg);
847 return ((get_pages(sbi, block_type) + pages_per_sec - 1)
848 >> sbi->log_blocks_per_seg) / sbi->segs_per_sec;

--- 88 unchanged lines hidden (view full) ---

937 return true;
938}
939
940static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
941 struct inode *inode)
942{
943 spin_lock(&sbi->stat_lock);
944
851 f2fs_bug_on(!sbi->total_valid_block_count);
852 f2fs_bug_on(!sbi->total_valid_node_count);
853 f2fs_bug_on(!inode->i_blocks);
945 f2fs_bug_on(sbi, !sbi->total_valid_block_count);
946 f2fs_bug_on(sbi, !sbi->total_valid_node_count);
947 f2fs_bug_on(sbi, !inode->i_blocks);
854
855 inode->i_blocks--;
856 sbi->total_valid_node_count--;
857 sbi->total_valid_block_count--;
858
859 spin_unlock(&sbi->stat_lock);
860}
861
862static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi)
863{
864 return sbi->total_valid_node_count;
865}
866
867static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi)
868{
869 spin_lock(&sbi->stat_lock);
948
949 inode->i_blocks--;
950 sbi->total_valid_node_count--;
951 sbi->total_valid_block_count--;
952
953 spin_unlock(&sbi->stat_lock);
954}
955
956static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi)
957{
958 return sbi->total_valid_node_count;
959}
960
961static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi)
962{
963 spin_lock(&sbi->stat_lock);
870 f2fs_bug_on(sbi->total_valid_inode_count == sbi->total_node_count);
964 f2fs_bug_on(sbi, sbi->total_valid_inode_count == sbi->total_node_count);
871 sbi->total_valid_inode_count++;
872 spin_unlock(&sbi->stat_lock);
873}
874
875static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi)
876{
877 spin_lock(&sbi->stat_lock);
965 sbi->total_valid_inode_count++;
966 spin_unlock(&sbi->stat_lock);
967}
968
969static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi)
970{
971 spin_lock(&sbi->stat_lock);
878 f2fs_bug_on(!sbi->total_valid_inode_count);
972 f2fs_bug_on(sbi, !sbi->total_valid_inode_count);
879 sbi->total_valid_inode_count--;
880 spin_unlock(&sbi->stat_lock);
881}
882
883static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi)
884{
885 return sbi->total_valid_inode_count;
886}
887
888static inline void f2fs_put_page(struct page *page, int unlock)
889{
890 if (!page)
891 return;
892
893 if (unlock) {
973 sbi->total_valid_inode_count--;
974 spin_unlock(&sbi->stat_lock);
975}
976
977static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi)
978{
979 return sbi->total_valid_inode_count;
980}
981
982static inline void f2fs_put_page(struct page *page, int unlock)
983{
984 if (!page)
985 return;
986
987 if (unlock) {
894 f2fs_bug_on(!PageLocked(page));
988 f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page));
895 unlock_page(page);
896 }
897 page_cache_release(page);
898}
899
900static inline void f2fs_put_dnode(struct dnode_of_data *dn)
901{
902 if (dn->node_page)

--- 51 unchanged lines hidden (view full) ---

954{
955 int mask;
956
957 addr += (nr >> 3);
958 mask = 1 << (7 - (nr & 0x07));
959 return mask & *addr;
960}
961
989 unlock_page(page);
990 }
991 page_cache_release(page);
992}
993
994static inline void f2fs_put_dnode(struct dnode_of_data *dn)
995{
996 if (dn->node_page)

--- 51 unchanged lines hidden (view full) ---

1048{
1049 int mask;
1050
1051 addr += (nr >> 3);
1052 mask = 1 << (7 - (nr & 0x07));
1053 return mask & *addr;
1054}
1055
962static inline int f2fs_set_bit(unsigned int nr, char *addr)
1056static inline int f2fs_test_and_set_bit(unsigned int nr, char *addr)
963{
964 int mask;
965 int ret;
966
967 addr += (nr >> 3);
968 mask = 1 << (7 - (nr & 0x07));
969 ret = mask & *addr;
970 *addr |= mask;
971 return ret;
972}
973
1057{
1058 int mask;
1059 int ret;
1060
1061 addr += (nr >> 3);
1062 mask = 1 << (7 - (nr & 0x07));
1063 ret = mask & *addr;
1064 *addr |= mask;
1065 return ret;
1066}
1067
974static inline int f2fs_clear_bit(unsigned int nr, char *addr)
1068static inline int f2fs_test_and_clear_bit(unsigned int nr, char *addr)
975{
976 int mask;
977 int ret;
978
979 addr += (nr >> 3);
980 mask = 1 << (7 - (nr & 0x07));
981 ret = mask & *addr;
982 *addr &= ~mask;
983 return ret;
984}
985
1069{
1070 int mask;
1071 int ret;
1072
1073 addr += (nr >> 3);
1074 mask = 1 << (7 - (nr & 0x07));
1075 ret = mask & *addr;
1076 *addr &= ~mask;
1077 return ret;
1078}
1079
1080static inline void f2fs_change_bit(unsigned int nr, char *addr)
1081{
1082 int mask;
1083
1084 addr += (nr >> 3);
1085 mask = 1 << (7 - (nr & 0x07));
1086 *addr ^= mask;
1087}
1088
986/* used for f2fs_inode_info->flags */
987enum {
988 FI_NEW_INODE, /* indicate newly allocated inode */
989 FI_DIRTY_INODE, /* indicate inode is dirty or not */
990 FI_DIRTY_DIR, /* indicate directory has dirty pages */
991 FI_INC_LINK, /* need to increment i_nlink */
992 FI_ACL_MODE, /* indicate acl mode */
993 FI_NO_ALLOC, /* should not allocate any blocks */
994 FI_UPDATE_DIR, /* should update inode block for consistency */
995 FI_DELAY_IPUT, /* used for the recovery */
996 FI_NO_EXTENT, /* not to use the extent cache */
997 FI_INLINE_XATTR, /* used for inline xattr */
998 FI_INLINE_DATA, /* used for inline data*/
1089/* used for f2fs_inode_info->flags */
1090enum {
1091 FI_NEW_INODE, /* indicate newly allocated inode */
1092 FI_DIRTY_INODE, /* indicate inode is dirty or not */
1093 FI_DIRTY_DIR, /* indicate directory has dirty pages */
1094 FI_INC_LINK, /* need to increment i_nlink */
1095 FI_ACL_MODE, /* indicate acl mode */
1096 FI_NO_ALLOC, /* should not allocate any blocks */
1097 FI_UPDATE_DIR, /* should update inode block for consistency */
1098 FI_DELAY_IPUT, /* used for the recovery */
1099 FI_NO_EXTENT, /* not to use the extent cache */
1100 FI_INLINE_XATTR, /* used for inline xattr */
1101 FI_INLINE_DATA, /* used for inline data*/
1102 FI_INLINE_DENTRY, /* used for inline dentry */
999 FI_APPEND_WRITE, /* inode has appended data */
1000 FI_UPDATE_WRITE, /* inode has in-place-update data */
1103 FI_APPEND_WRITE, /* inode has appended data */
1104 FI_UPDATE_WRITE, /* inode has in-place-update data */
1001 FI_NEED_IPU, /* used fo ipu for fdatasync */
1105 FI_NEED_IPU, /* used for ipu per file */
1106 FI_ATOMIC_FILE, /* indicate atomic file */
1107 FI_VOLATILE_FILE, /* indicate volatile file */
1108 FI_DATA_EXIST, /* indicate data exists */
1002};
1003
1004static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
1005{
1006 if (!test_bit(flag, &fi->flags))
1007 set_bit(flag, &fi->flags);
1008}
1009

--- 9 unchanged lines hidden (view full) ---

1019}
1020
1021static inline void set_acl_inode(struct f2fs_inode_info *fi, umode_t mode)
1022{
1023 fi->i_acl_mode = mode;
1024 set_inode_flag(fi, FI_ACL_MODE);
1025}
1026
1109};
1110
1111static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
1112{
1113 if (!test_bit(flag, &fi->flags))
1114 set_bit(flag, &fi->flags);
1115}
1116

--- 9 unchanged lines hidden (view full) ---

1126}
1127
1128static inline void set_acl_inode(struct f2fs_inode_info *fi, umode_t mode)
1129{
1130 fi->i_acl_mode = mode;
1131 set_inode_flag(fi, FI_ACL_MODE);
1132}
1133
1027static inline int cond_clear_inode_flag(struct f2fs_inode_info *fi, int flag)
1028{
1029 if (is_inode_flag_set(fi, FI_ACL_MODE)) {
1030 clear_inode_flag(fi, FI_ACL_MODE);
1031 return 1;
1032 }
1033 return 0;
1034}
1035
1036static inline void get_inline_info(struct f2fs_inode_info *fi,
1037 struct f2fs_inode *ri)
1038{
1039 if (ri->i_inline & F2FS_INLINE_XATTR)
1040 set_inode_flag(fi, FI_INLINE_XATTR);
1041 if (ri->i_inline & F2FS_INLINE_DATA)
1042 set_inode_flag(fi, FI_INLINE_DATA);
1134static inline void get_inline_info(struct f2fs_inode_info *fi,
1135 struct f2fs_inode *ri)
1136{
1137 if (ri->i_inline & F2FS_INLINE_XATTR)
1138 set_inode_flag(fi, FI_INLINE_XATTR);
1139 if (ri->i_inline & F2FS_INLINE_DATA)
1140 set_inode_flag(fi, FI_INLINE_DATA);
1141 if (ri->i_inline & F2FS_INLINE_DENTRY)
1142 set_inode_flag(fi, FI_INLINE_DENTRY);
1143 if (ri->i_inline & F2FS_DATA_EXIST)
1144 set_inode_flag(fi, FI_DATA_EXIST);
1043}
1044
1045static inline void set_raw_inline(struct f2fs_inode_info *fi,
1046 struct f2fs_inode *ri)
1047{
1048 ri->i_inline = 0;
1049
1050 if (is_inode_flag_set(fi, FI_INLINE_XATTR))
1051 ri->i_inline |= F2FS_INLINE_XATTR;
1052 if (is_inode_flag_set(fi, FI_INLINE_DATA))
1053 ri->i_inline |= F2FS_INLINE_DATA;
1145}
1146
1147static inline void set_raw_inline(struct f2fs_inode_info *fi,
1148 struct f2fs_inode *ri)
1149{
1150 ri->i_inline = 0;
1151
1152 if (is_inode_flag_set(fi, FI_INLINE_XATTR))
1153 ri->i_inline |= F2FS_INLINE_XATTR;
1154 if (is_inode_flag_set(fi, FI_INLINE_DATA))
1155 ri->i_inline |= F2FS_INLINE_DATA;
1156 if (is_inode_flag_set(fi, FI_INLINE_DENTRY))
1157 ri->i_inline |= F2FS_INLINE_DENTRY;
1158 if (is_inode_flag_set(fi, FI_DATA_EXIST))
1159 ri->i_inline |= F2FS_DATA_EXIST;
1054}
1055
1056static inline int f2fs_has_inline_xattr(struct inode *inode)
1057{
1058 return is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR);
1059}
1060
1061static inline unsigned int addrs_per_inode(struct f2fs_inode_info *fi)

--- 18 unchanged lines hidden (view full) ---

1080 return 0;
1081}
1082
1083static inline int f2fs_has_inline_data(struct inode *inode)
1084{
1085 return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DATA);
1086}
1087
1160}
1161
1162static inline int f2fs_has_inline_xattr(struct inode *inode)
1163{
1164 return is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR);
1165}
1166
1167static inline unsigned int addrs_per_inode(struct f2fs_inode_info *fi)

--- 18 unchanged lines hidden (view full) ---

1186 return 0;
1187}
1188
1189static inline int f2fs_has_inline_data(struct inode *inode)
1190{
1191 return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DATA);
1192}
1193
1194static inline void f2fs_clear_inline_inode(struct inode *inode)
1195{
1196 clear_inode_flag(F2FS_I(inode), FI_INLINE_DATA);
1197 clear_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
1198}
1199
1200static inline int f2fs_exist_data(struct inode *inode)
1201{
1202 return is_inode_flag_set(F2FS_I(inode), FI_DATA_EXIST);
1203}
1204
1205static inline bool f2fs_is_atomic_file(struct inode *inode)
1206{
1207 return is_inode_flag_set(F2FS_I(inode), FI_ATOMIC_FILE);
1208}
1209
1210static inline bool f2fs_is_volatile_file(struct inode *inode)
1211{
1212 return is_inode_flag_set(F2FS_I(inode), FI_VOLATILE_FILE);
1213}
1214
1088static inline void *inline_data_addr(struct page *page)
1089{
1090 struct f2fs_inode *ri = F2FS_INODE(page);
1091 return (void *)&(ri->i_addr[1]);
1092}
1093
1215static inline void *inline_data_addr(struct page *page)
1216{
1217 struct f2fs_inode *ri = F2FS_INODE(page);
1218 return (void *)&(ri->i_addr[1]);
1219}
1220
1221static inline int f2fs_has_inline_dentry(struct inode *inode)
1222{
1223 return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DENTRY);
1224}
1225
1226static inline void *inline_dentry_addr(struct page *page)
1227{
1228 struct f2fs_inode *ri = F2FS_INODE(page);
1229 return (void *)&(ri->i_addr[1]);
1230}
1231
1094static inline int f2fs_readonly(struct super_block *sb)
1095{
1096 return sb->s_flags & MS_RDONLY;
1097}
1098
1099static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi)
1100{
1101 return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);

--- 34 unchanged lines hidden (view full) ---

1136 */
1137void f2fs_set_inode_flags(struct inode *);
1138struct inode *f2fs_iget(struct super_block *, unsigned long);
1139int try_to_free_nats(struct f2fs_sb_info *, int);
1140void update_inode(struct inode *, struct page *);
1141void update_inode_page(struct inode *);
1142int f2fs_write_inode(struct inode *, struct writeback_control *);
1143void f2fs_evict_inode(struct inode *);
1232static inline int f2fs_readonly(struct super_block *sb)
1233{
1234 return sb->s_flags & MS_RDONLY;
1235}
1236
1237static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi)
1238{
1239 return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);

--- 34 unchanged lines hidden (view full) ---

1274 */
1275void f2fs_set_inode_flags(struct inode *);
1276struct inode *f2fs_iget(struct super_block *, unsigned long);
1277int try_to_free_nats(struct f2fs_sb_info *, int);
1278void update_inode(struct inode *, struct page *);
1279void update_inode_page(struct inode *);
1280int f2fs_write_inode(struct inode *, struct writeback_control *);
1281void f2fs_evict_inode(struct inode *);
1282void handle_failed_inode(struct inode *);
1144
1145/*
1146 * namei.c
1147 */
1148struct dentry *f2fs_get_parent(struct dentry *child);
1149
1150/*
1151 * dir.c
1152 */
1283
1284/*
1285 * namei.c
1286 */
1287struct dentry *f2fs_get_parent(struct dentry *child);
1288
1289/*
1290 * dir.c
1291 */
1292extern unsigned char f2fs_filetype_table[F2FS_FT_MAX];
1293void set_de_type(struct f2fs_dir_entry *, struct inode *);
1294struct f2fs_dir_entry *find_target_dentry(struct qstr *, int *,
1295 struct f2fs_dentry_ptr *);
1296bool f2fs_fill_dentries(struct dir_context *, struct f2fs_dentry_ptr *,
1297 unsigned int);
1298void do_make_empty_dir(struct inode *, struct inode *,
1299 struct f2fs_dentry_ptr *);
1300struct page *init_inode_metadata(struct inode *, struct inode *,
1301 const struct qstr *, struct page *);
1302void update_parent_metadata(struct inode *, struct inode *, unsigned int);
1303int room_for_filename(const void *, int, int);
1304void f2fs_drop_nlink(struct inode *, struct inode *, struct page *);
1153struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *,
1154 struct page **);
1155struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
1156ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
1157void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
1158 struct page *, struct inode *);
1159int update_dent_inode(struct inode *, const struct qstr *);
1160int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
1305struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *,
1306 struct page **);
1307struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
1308ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
1309void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
1310 struct page *, struct inode *);
1311int update_dent_inode(struct inode *, const struct qstr *);
1312int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
1161void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *);
1313void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *,
1314 struct inode *);
1162int f2fs_do_tmpfile(struct inode *, struct inode *);
1163int f2fs_make_empty(struct inode *, struct inode *);
1164bool f2fs_empty_dir(struct inode *);
1165
1166static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
1167{
1168 return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name,
1169 inode);

--- 13 unchanged lines hidden (view full) ---

1183
1184/*
1185 * node.c
1186 */
1187struct dnode_of_data;
1188struct node_info;
1189
1190bool available_free_memory(struct f2fs_sb_info *, int);
1315int f2fs_do_tmpfile(struct inode *, struct inode *);
1316int f2fs_make_empty(struct inode *, struct inode *);
1317bool f2fs_empty_dir(struct inode *);
1318
1319static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
1320{
1321 return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name,
1322 inode);

--- 13 unchanged lines hidden (view full) ---

1336
1337/*
1338 * node.c
1339 */
1340struct dnode_of_data;
1341struct node_info;
1342
1343bool available_free_memory(struct f2fs_sb_info *, int);
1191int is_checkpointed_node(struct f2fs_sb_info *, nid_t);
1192bool fsync_mark_done(struct f2fs_sb_info *, nid_t);
1193void fsync_mark_clear(struct f2fs_sb_info *, nid_t);
1344bool is_checkpointed_node(struct f2fs_sb_info *, nid_t);
1345bool has_fsynced_inode(struct f2fs_sb_info *, nid_t);
1346bool need_inode_block_update(struct f2fs_sb_info *, nid_t);
1194void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
1195int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int);
1196int truncate_inode_blocks(struct inode *, pgoff_t);
1197int truncate_xattr_node(struct inode *, struct page *);
1198int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t);
1199void remove_inode_page(struct inode *);
1200struct page *new_inode_page(struct inode *);
1201struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *);

--- 14 unchanged lines hidden (view full) ---

1216int build_node_manager(struct f2fs_sb_info *);
1217void destroy_node_manager(struct f2fs_sb_info *);
1218int __init create_node_manager_caches(void);
1219void destroy_node_manager_caches(void);
1220
1221/*
1222 * segment.c
1223 */
1347void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
1348int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int);
1349int truncate_inode_blocks(struct inode *, pgoff_t);
1350int truncate_xattr_node(struct inode *, struct page *);
1351int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t);
1352void remove_inode_page(struct inode *);
1353struct page *new_inode_page(struct inode *);
1354struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *);

--- 14 unchanged lines hidden (view full) ---

1369int build_node_manager(struct f2fs_sb_info *);
1370void destroy_node_manager(struct f2fs_sb_info *);
1371int __init create_node_manager_caches(void);
1372void destroy_node_manager_caches(void);
1373
1374/*
1375 * segment.c
1376 */
1377void register_inmem_page(struct inode *, struct page *);
1378void invalidate_inmem_page(struct inode *, struct page *);
1379void commit_inmem_pages(struct inode *, bool);
1224void f2fs_balance_fs(struct f2fs_sb_info *);
1225void f2fs_balance_fs_bg(struct f2fs_sb_info *);
1226int f2fs_issue_flush(struct f2fs_sb_info *);
1227int create_flush_cmd_control(struct f2fs_sb_info *);
1228void destroy_flush_cmd_control(struct f2fs_sb_info *);
1229void invalidate_blocks(struct f2fs_sb_info *, block_t);
1230void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t);
1231void clear_prefree_segments(struct f2fs_sb_info *);
1380void f2fs_balance_fs(struct f2fs_sb_info *);
1381void f2fs_balance_fs_bg(struct f2fs_sb_info *);
1382int f2fs_issue_flush(struct f2fs_sb_info *);
1383int create_flush_cmd_control(struct f2fs_sb_info *);
1384void destroy_flush_cmd_control(struct f2fs_sb_info *);
1385void invalidate_blocks(struct f2fs_sb_info *, block_t);
1386void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t);
1387void clear_prefree_segments(struct f2fs_sb_info *);
1388void release_discard_addrs(struct f2fs_sb_info *);
1232void discard_next_dnode(struct f2fs_sb_info *, block_t);
1233int npages_for_summary_flush(struct f2fs_sb_info *);
1234void allocate_new_segments(struct f2fs_sb_info *);
1389void discard_next_dnode(struct f2fs_sb_info *, block_t);
1390int npages_for_summary_flush(struct f2fs_sb_info *);
1391void allocate_new_segments(struct f2fs_sb_info *);
1392int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *);
1235struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
1236void write_meta_page(struct f2fs_sb_info *, struct page *);
1237void write_node_page(struct f2fs_sb_info *, struct page *,
1238 struct f2fs_io_info *, unsigned int, block_t, block_t *);
1239void write_data_page(struct page *, struct dnode_of_data *, block_t *,
1240 struct f2fs_io_info *);
1241void rewrite_data_page(struct page *, block_t, struct f2fs_io_info *);
1242void recover_data_page(struct f2fs_sb_info *, struct page *,
1243 struct f2fs_summary *, block_t, block_t);
1244void allocate_data_block(struct f2fs_sb_info *, struct page *,
1245 block_t, block_t *, struct f2fs_summary *, int);
1246void f2fs_wait_on_page_writeback(struct page *, enum page_type);
1247void write_data_summaries(struct f2fs_sb_info *, block_t);
1248void write_node_summaries(struct f2fs_sb_info *, block_t);
1249int lookup_journal_in_cursum(struct f2fs_summary_block *,
1250 int, unsigned int, int);
1393struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
1394void write_meta_page(struct f2fs_sb_info *, struct page *);
1395void write_node_page(struct f2fs_sb_info *, struct page *,
1396 struct f2fs_io_info *, unsigned int, block_t, block_t *);
1397void write_data_page(struct page *, struct dnode_of_data *, block_t *,
1398 struct f2fs_io_info *);
1399void rewrite_data_page(struct page *, block_t, struct f2fs_io_info *);
1400void recover_data_page(struct f2fs_sb_info *, struct page *,
1401 struct f2fs_summary *, block_t, block_t);
1402void allocate_data_block(struct f2fs_sb_info *, struct page *,
1403 block_t, block_t *, struct f2fs_summary *, int);
1404void f2fs_wait_on_page_writeback(struct page *, enum page_type);
1405void write_data_summaries(struct f2fs_sb_info *, block_t);
1406void write_node_summaries(struct f2fs_sb_info *, block_t);
1407int lookup_journal_in_cursum(struct f2fs_summary_block *,
1408 int, unsigned int, int);
1251void flush_sit_entries(struct f2fs_sb_info *);
1409void flush_sit_entries(struct f2fs_sb_info *, struct cp_control *);
1252int build_segment_manager(struct f2fs_sb_info *);
1253void destroy_segment_manager(struct f2fs_sb_info *);
1254int __init create_segment_manager_caches(void);
1255void destroy_segment_manager_caches(void);
1256
1257/*
1258 * checkpoint.c
1259 */
1260struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t);
1261struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t);
1410int build_segment_manager(struct f2fs_sb_info *);
1411void destroy_segment_manager(struct f2fs_sb_info *);
1412int __init create_segment_manager_caches(void);
1413void destroy_segment_manager_caches(void);
1414
1415/*
1416 * checkpoint.c
1417 */
1418struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t);
1419struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t);
1262int ra_meta_pages(struct f2fs_sb_info *, int, int, int);
1420struct page *get_meta_page_ra(struct f2fs_sb_info *, pgoff_t);
1421int ra_meta_pages(struct f2fs_sb_info *, block_t, int, int);
1263long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long);
1264void add_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
1265void remove_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
1266void release_dirty_inode(struct f2fs_sb_info *);
1267bool exist_written_data(struct f2fs_sb_info *, nid_t, int);
1268int acquire_orphan_inode(struct f2fs_sb_info *);
1269void release_orphan_inode(struct f2fs_sb_info *);
1270void add_orphan_inode(struct f2fs_sb_info *, nid_t);
1271void remove_orphan_inode(struct f2fs_sb_info *, nid_t);
1272void recover_orphan_inodes(struct f2fs_sb_info *);
1273int get_valid_checkpoint(struct f2fs_sb_info *);
1422long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long);
1423void add_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
1424void remove_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
1425void release_dirty_inode(struct f2fs_sb_info *);
1426bool exist_written_data(struct f2fs_sb_info *, nid_t, int);
1427int acquire_orphan_inode(struct f2fs_sb_info *);
1428void release_orphan_inode(struct f2fs_sb_info *);
1429void add_orphan_inode(struct f2fs_sb_info *, nid_t);
1430void remove_orphan_inode(struct f2fs_sb_info *, nid_t);
1431void recover_orphan_inodes(struct f2fs_sb_info *);
1432int get_valid_checkpoint(struct f2fs_sb_info *);
1274void set_dirty_dir_page(struct inode *, struct page *);
1433void update_dirty_page(struct inode *, struct page *);
1275void add_dirty_dir_inode(struct inode *);
1276void remove_dirty_dir_inode(struct inode *);
1277void sync_dirty_dir_inodes(struct f2fs_sb_info *);
1434void add_dirty_dir_inode(struct inode *);
1435void remove_dirty_dir_inode(struct inode *);
1436void sync_dirty_dir_inodes(struct f2fs_sb_info *);
1278void write_checkpoint(struct f2fs_sb_info *, bool);
1437void write_checkpoint(struct f2fs_sb_info *, struct cp_control *);
1279void init_ino_entry_info(struct f2fs_sb_info *);
1280int __init create_checkpoint_caches(void);
1281void destroy_checkpoint_caches(void);
1282
1283/*
1284 * data.c
1285 */
1286void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int);

--- 34 unchanged lines hidden (view full) ---

1321 struct list_head stat_list;
1322 struct f2fs_sb_info *sbi;
1323 int all_area_segs, sit_area_segs, nat_area_segs, ssa_area_segs;
1324 int main_area_segs, main_area_sections, main_area_zones;
1325 int hit_ext, total_ext;
1326 int ndirty_node, ndirty_dent, ndirty_dirs, ndirty_meta;
1327 int nats, sits, fnids;
1328 int total_count, utilization;
1438void init_ino_entry_info(struct f2fs_sb_info *);
1439int __init create_checkpoint_caches(void);
1440void destroy_checkpoint_caches(void);
1441
1442/*
1443 * data.c
1444 */
1445void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int);

--- 34 unchanged lines hidden (view full) ---

1480 struct list_head stat_list;
1481 struct f2fs_sb_info *sbi;
1482 int all_area_segs, sit_area_segs, nat_area_segs, ssa_area_segs;
1483 int main_area_segs, main_area_sections, main_area_zones;
1484 int hit_ext, total_ext;
1485 int ndirty_node, ndirty_dent, ndirty_dirs, ndirty_meta;
1486 int nats, sits, fnids;
1487 int total_count, utilization;
1329 int bg_gc, inline_inode;
1488 int bg_gc, inline_inode, inline_dir;
1330 unsigned int valid_count, valid_node_count, valid_inode_count;
1331 unsigned int bimodal, avg_vblocks;
1332 int util_free, util_valid, util_invalid;
1333 int rsvd_segs, overp_segs;
1334 int dirty_count, node_pages, meta_pages;
1335 int prefree_count, call_count, cp_count;
1336 int tot_segs, node_segs, data_segs, free_segs, free_secs;
1337 int tot_blks, data_blks, node_blks;

--- 16 unchanged lines hidden (view full) ---

1354#define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++)
1355#define stat_inc_dirty_dir(sbi) ((sbi)->n_dirty_dirs++)
1356#define stat_dec_dirty_dir(sbi) ((sbi)->n_dirty_dirs--)
1357#define stat_inc_total_hit(sb) ((F2FS_SB(sb))->total_hit_ext++)
1358#define stat_inc_read_hit(sb) ((F2FS_SB(sb))->read_hit_ext++)
1359#define stat_inc_inline_inode(inode) \
1360 do { \
1361 if (f2fs_has_inline_data(inode)) \
1489 unsigned int valid_count, valid_node_count, valid_inode_count;
1490 unsigned int bimodal, avg_vblocks;
1491 int util_free, util_valid, util_invalid;
1492 int rsvd_segs, overp_segs;
1493 int dirty_count, node_pages, meta_pages;
1494 int prefree_count, call_count, cp_count;
1495 int tot_segs, node_segs, data_segs, free_segs, free_secs;
1496 int tot_blks, data_blks, node_blks;

--- 16 unchanged lines hidden (view full) ---

1513#define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++)
1514#define stat_inc_dirty_dir(sbi) ((sbi)->n_dirty_dirs++)
1515#define stat_dec_dirty_dir(sbi) ((sbi)->n_dirty_dirs--)
1516#define stat_inc_total_hit(sb) ((F2FS_SB(sb))->total_hit_ext++)
1517#define stat_inc_read_hit(sb) ((F2FS_SB(sb))->read_hit_ext++)
1518#define stat_inc_inline_inode(inode) \
1519 do { \
1520 if (f2fs_has_inline_data(inode)) \
1362 ((F2FS_SB(inode->i_sb))->inline_inode++); \
1521 ((F2FS_I_SB(inode))->inline_inode++); \
1363 } while (0)
1364#define stat_dec_inline_inode(inode) \
1365 do { \
1366 if (f2fs_has_inline_data(inode)) \
1522 } while (0)
1523#define stat_dec_inline_inode(inode) \
1524 do { \
1525 if (f2fs_has_inline_data(inode)) \
1367 ((F2FS_SB(inode->i_sb))->inline_inode--); \
1526 ((F2FS_I_SB(inode))->inline_inode--); \
1368 } while (0)
1527 } while (0)
1369
1528#define stat_inc_inline_dir(inode) \
1529 do { \
1530 if (f2fs_has_inline_dentry(inode)) \
1531 ((F2FS_I_SB(inode))->inline_dir++); \
1532 } while (0)
1533#define stat_dec_inline_dir(inode) \
1534 do { \
1535 if (f2fs_has_inline_dentry(inode)) \
1536 ((F2FS_I_SB(inode))->inline_dir--); \
1537 } while (0)
1370#define stat_inc_seg_type(sbi, curseg) \
1371 ((sbi)->segment_count[(curseg)->alloc_type]++)
1372#define stat_inc_block_count(sbi, curseg) \
1373 ((sbi)->block_count[(curseg)->alloc_type]++)
1374
1375#define stat_inc_seg_count(sbi, type) \
1376 do { \
1377 struct f2fs_stat_info *si = F2FS_STAT(sbi); \

--- 30 unchanged lines hidden (view full) ---

1408#define stat_inc_call_count(si)
1409#define stat_inc_bggc_count(si)
1410#define stat_inc_dirty_dir(sbi)
1411#define stat_dec_dirty_dir(sbi)
1412#define stat_inc_total_hit(sb)
1413#define stat_inc_read_hit(sb)
1414#define stat_inc_inline_inode(inode)
1415#define stat_dec_inline_inode(inode)
1538#define stat_inc_seg_type(sbi, curseg) \
1539 ((sbi)->segment_count[(curseg)->alloc_type]++)
1540#define stat_inc_block_count(sbi, curseg) \
1541 ((sbi)->block_count[(curseg)->alloc_type]++)
1542
1543#define stat_inc_seg_count(sbi, type) \
1544 do { \
1545 struct f2fs_stat_info *si = F2FS_STAT(sbi); \

--- 30 unchanged lines hidden (view full) ---

1576#define stat_inc_call_count(si)
1577#define stat_inc_bggc_count(si)
1578#define stat_inc_dirty_dir(sbi)
1579#define stat_dec_dirty_dir(sbi)
1580#define stat_inc_total_hit(sb)
1581#define stat_inc_read_hit(sb)
1582#define stat_inc_inline_inode(inode)
1583#define stat_dec_inline_inode(inode)
1584#define stat_inc_inline_dir(inode)
1585#define stat_dec_inline_dir(inode)
1416#define stat_inc_seg_type(sbi, curseg)
1417#define stat_inc_block_count(sbi, curseg)
1418#define stat_inc_seg_count(si, type)
1419#define stat_inc_tot_blk_count(si, blks)
1420#define stat_inc_data_blk_count(si, blks)
1421#define stat_inc_node_blk_count(sbi, blks)
1422
1423static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }

--- 11 unchanged lines hidden (view full) ---

1435extern const struct inode_operations f2fs_dir_inode_operations;
1436extern const struct inode_operations f2fs_symlink_inode_operations;
1437extern const struct inode_operations f2fs_special_inode_operations;
1438
1439/*
1440 * inline.c
1441 */
1442bool f2fs_may_inline(struct inode *);
1586#define stat_inc_seg_type(sbi, curseg)
1587#define stat_inc_block_count(sbi, curseg)
1588#define stat_inc_seg_count(si, type)
1589#define stat_inc_tot_blk_count(si, blks)
1590#define stat_inc_data_blk_count(si, blks)
1591#define stat_inc_node_blk_count(sbi, blks)
1592
1593static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }

--- 11 unchanged lines hidden (view full) ---

1605extern const struct inode_operations f2fs_dir_inode_operations;
1606extern const struct inode_operations f2fs_symlink_inode_operations;
1607extern const struct inode_operations f2fs_special_inode_operations;
1608
1609/*
1610 * inline.c
1611 */
1612bool f2fs_may_inline(struct inode *);
1613void read_inline_data(struct page *, struct page *);
1443int f2fs_read_inline_data(struct inode *, struct page *);
1614int f2fs_read_inline_data(struct inode *, struct page *);
1444int f2fs_convert_inline_data(struct inode *, pgoff_t, struct page *);
1445int f2fs_write_inline_data(struct inode *, struct page *, unsigned int);
1446void truncate_inline_data(struct inode *, u64);
1615int f2fs_convert_inline_page(struct dnode_of_data *, struct page *);
1616int f2fs_convert_inline_inode(struct inode *);
1617int f2fs_write_inline_data(struct inode *, struct page *);
1618void truncate_inline_data(struct page *, u64);
1447bool recover_inline_data(struct inode *, struct page *);
1619bool recover_inline_data(struct inode *, struct page *);
1620struct f2fs_dir_entry *find_in_inline_dir(struct inode *, struct qstr *,
1621 struct page **);
1622struct f2fs_dir_entry *f2fs_parent_inline_dir(struct inode *, struct page **);
1623int make_empty_inline_dir(struct inode *inode, struct inode *, struct page *);
1624int f2fs_add_inline_entry(struct inode *, const struct qstr *, struct inode *);
1625void f2fs_delete_inline_entry(struct f2fs_dir_entry *, struct page *,
1626 struct inode *, struct inode *);
1627bool f2fs_empty_inline_dir(struct inode *);
1628int f2fs_read_inline_dir(struct file *, struct dir_context *);
1448#endif
1629#endif