blob: 053166038bfe50ed9d794bc9cbae7d371d0524d1 [file] [log] [blame]
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +09001/*
Jaegeuk Kim39a53e02012-11-28 13:37:31 +09002 * fs/f2fs/segment.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
9 * published by the Free Software Foundation.
10 */
Jaegeuk Kimac5d1562013-04-29 16:58:39 +090011#include <linux/blkdev.h>
Tejun Heo66114ca2015-05-22 17:13:32 -040012#include <linux/backing-dev.h>
Jaegeuk Kimac5d1562013-04-29 16:58:39 +090013
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090014/* constant macro */
15#define NULL_SEGNO ((unsigned int)(~0))
Jaegeuk Kim5ec4e492013-03-31 13:26:03 +090016#define NULL_SECNO ((unsigned int)(~0))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090017
Jaegeuk Kim58c41032014-03-19 14:17:21 +090018#define DEF_RECLAIM_PREFREE_SEGMENTS 5 /* 5% over total segments */
Jaegeuk Kim44a83492016-07-13 18:23:35 -070019#define DEF_MAX_RECLAIM_PREFREE_SEGMENTS 4096 /* 8GB in maximum */
Jaegeuk Kim81eb8d62013-10-24 13:31:34 +090020
Jaegeuk Kim2040fce82016-12-05 13:56:04 -080021#define F2FS_MIN_SEGMENTS 9 /* SB + 2 (CP + SIT + NAT) + SSA + MAIN */
22
Namjae Jeon6224da82013-04-06 14:44:32 +090023/* L: Logical segment # in volume, R: Relative segment # in main area */
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030024#define GET_L2R_SEGNO(free_i, segno) ((segno) - (free_i)->start_segno)
25#define GET_R2L_SEGNO(free_i, segno) ((segno) + (free_i)->start_segno)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090026
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030027#define IS_DATASEG(t) ((t) <= CURSEG_COLD_DATA)
28#define IS_NODESEG(t) ((t) >= CURSEG_HOT_NODE)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090029
Jaegeuk Kim5c773ba2013-03-31 12:30:04 +090030#define IS_CURSEG(sbi, seg) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030031 (((seg) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno) || \
32 ((seg) == CURSEG_I(sbi, CURSEG_WARM_DATA)->segno) || \
33 ((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \
34 ((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \
35 ((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \
36 ((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090037
38#define IS_CURSEC(sbi, secno) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030039 (((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \
40 (sbi)->segs_per_sec) || \
41 ((secno) == CURSEG_I(sbi, CURSEG_WARM_DATA)->segno / \
42 (sbi)->segs_per_sec) || \
43 ((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno / \
44 (sbi)->segs_per_sec) || \
45 ((secno) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno / \
46 (sbi)->segs_per_sec) || \
47 ((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \
48 (sbi)->segs_per_sec) || \
49 ((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \
50 (sbi)->segs_per_sec)) \
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090051
Jaegeuk Kim7cd85582014-09-23 11:23:01 -070052#define MAIN_BLKADDR(sbi) (SM_I(sbi)->main_blkaddr)
53#define SEG0_BLKADDR(sbi) (SM_I(sbi)->seg0_blkaddr)
54
55#define MAIN_SEGS(sbi) (SM_I(sbi)->main_segments)
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030056#define MAIN_SECS(sbi) ((sbi)->total_sections)
Jaegeuk Kim7cd85582014-09-23 11:23:01 -070057
58#define TOTAL_SEGS(sbi) (SM_I(sbi)->segment_count)
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030059#define TOTAL_BLKS(sbi) (TOTAL_SEGS(sbi) << (sbi)->log_blocks_per_seg)
Jaegeuk Kim7cd85582014-09-23 11:23:01 -070060
61#define MAX_BLKADDR(sbi) (SEG0_BLKADDR(sbi) + TOTAL_BLKS(sbi))
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030062#define SEGMENT_SIZE(sbi) (1ULL << ((sbi)->log_blocksize + \
63 (sbi)->log_blocks_per_seg))
Jaegeuk Kim7cd85582014-09-23 11:23:01 -070064
65#define START_BLOCK(sbi, segno) (SEG0_BLKADDR(sbi) + \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030066 (GET_R2L_SEGNO(FREE_I(sbi), segno) << (sbi)->log_blocks_per_seg))
Jaegeuk Kim7cd85582014-09-23 11:23:01 -070067
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090068#define NEXT_FREE_BLKADDR(sbi, curseg) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030069 (START_BLOCK(sbi, (curseg)->segno) + (curseg)->next_blkoff)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090070
Jaegeuk Kim7cd85582014-09-23 11:23:01 -070071#define GET_SEGOFF_FROM_SEG0(sbi, blk_addr) ((blk_addr) - SEG0_BLKADDR(sbi))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090072#define GET_SEGNO_FROM_SEG0(sbi, blk_addr) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030073 (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) >> (sbi)->log_blocks_per_seg)
Jaegeuk Kim491c0852014-02-04 13:01:10 +090074#define GET_BLKOFF_FROM_SEG0(sbi, blk_addr) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030075 (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & ((sbi)->blocks_per_seg - 1))
Jaegeuk Kim491c0852014-02-04 13:01:10 +090076
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090077#define GET_SEGNO(sbi, blk_addr) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030078 ((((blk_addr) == NULL_ADDR) || ((blk_addr) == NEW_ADDR)) ? \
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090079 NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \
80 GET_SEGNO_FROM_SEG0(sbi, blk_addr)))
81#define GET_SECNO(sbi, segno) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030082 ((segno) / (sbi)->segs_per_sec)
Jaegeuk Kim63fcf8e2017-04-07 14:27:07 -070083#define GET_SEGNO_FROM_SECNO(sbi, secno) \
84 ((secno) * (sbi)->segs_per_sec)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090085#define GET_ZONENO_FROM_SEGNO(sbi, segno) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030086 (((segno) / (sbi)->segs_per_sec) / (sbi)->secs_per_zone)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090087
88#define GET_SUM_BLOCK(sbi, segno) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030089 ((sbi)->sm_info->ssa_blkaddr + (segno))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090090
91#define GET_SUM_TYPE(footer) ((footer)->entry_type)
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030092#define SET_SUM_TYPE(footer, type) ((footer)->entry_type = (type))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +090093
94#define SIT_ENTRY_OFFSET(sit_i, segno) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030095 ((segno) % (sit_i)->sents_per_block)
Chao Yud3a14af2014-09-04 18:11:47 +080096#define SIT_BLOCK_OFFSET(segno) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +030097 ((segno) / SIT_ENTRY_PER_BLOCK)
Chao Yud3a14af2014-09-04 18:11:47 +080098#define START_SEGNO(segno) \
99 (SIT_BLOCK_OFFSET(segno) * SIT_ENTRY_PER_BLOCK)
Chao Yu74de5932013-11-22 09:09:59 +0800100#define SIT_BLK_CNT(sbi) \
Jaegeuk Kim7cd85582014-09-23 11:23:01 -0700101 ((MAIN_SEGS(sbi) + SIT_ENTRY_PER_BLOCK - 1) / SIT_ENTRY_PER_BLOCK)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900102#define f2fs_bitmap_size(nr) \
103 (BITS_TO_LONGS(nr) * sizeof(unsigned long))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900104
Chao Yu55cf9cb2014-09-15 18:01:10 +0800105#define SECTOR_FROM_BLOCK(blk_addr) \
106 (((sector_t)blk_addr) << F2FS_LOG_SECTORS_PER_BLOCK)
107#define SECTOR_TO_BLOCK(sectors) \
Tomohiro Kusumi68afcf22017-04-09 02:11:36 +0300108 ((sectors) >> F2FS_LOG_SECTORS_PER_BLOCK)
Jaegeuk Kim3cd8a232012-12-10 09:26:05 +0900109
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900110/*
111 * indicate a block allocation direction: RIGHT and LEFT.
112 * RIGHT means allocating new sections towards the end of volume.
113 * LEFT means the opposite direction.
114 */
115enum {
116 ALLOC_RIGHT = 0,
117 ALLOC_LEFT
118};
119
120/*
121 * In the victim_sel_policy->alloc_mode, there are two block allocation modes.
122 * LFS writes data sequentially with cleaning operations.
123 * SSR (Slack Space Recycle) reuses obsolete space without cleaning operations.
124 */
125enum {
126 LFS = 0,
127 SSR
128};
129
130/*
131 * In the victim_sel_policy->gc_mode, there are two gc, aka cleaning, modes.
132 * GC_CB is based on cost-benefit algorithm.
133 * GC_GREEDY is based on greedy algorithm.
134 */
135enum {
136 GC_CB = 0,
137 GC_GREEDY
138};
139
140/*
141 * BG_GC means the background cleaning job.
142 * FG_GC means the on-demand cleaning job.
Jaegeuk Kim6aefd932015-10-05 11:02:54 -0700143 * FORCE_FG_GC means on-demand cleaning job in background.
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900144 */
145enum {
146 BG_GC = 0,
Jaegeuk Kim6aefd932015-10-05 11:02:54 -0700147 FG_GC,
148 FORCE_FG_GC,
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900149};
150
151/* for a function parameter to select a victim segment */
152struct victim_sel_policy {
153 int alloc_mode; /* LFS or SSR */
154 int gc_mode; /* GC_CB or GC_GREEDY */
155 unsigned long *dirty_segmap; /* dirty segment bitmap */
Jin Xua26b7c82013-09-05 12:45:26 +0800156 unsigned int max_search; /* maximum # of segments to search */
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900157 unsigned int offset; /* last scanned bitmap offset */
158 unsigned int ofs_unit; /* bitmap search unit */
159 unsigned int min_cost; /* minimum cost */
160 unsigned int min_segno; /* segment # having min. cost */
161};
162
163struct seg_entry {
Chao Yuf51b4ce2016-05-04 23:19:48 +0800164 unsigned int type:6; /* segment type like CURSEG_XXX_TYPE */
165 unsigned int valid_blocks:10; /* # of valid blocks */
166 unsigned int ckpt_valid_blocks:10; /* # of valid blocks last cp */
167 unsigned int padding:6; /* padding */
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900168 unsigned char *cur_valid_map; /* validity bitmap of blocks */
Chao Yu355e7892017-01-07 18:51:01 +0800169#ifdef CONFIG_F2FS_CHECK_FS
170 unsigned char *cur_valid_map_mir; /* mirror of current valid bitmap */
171#endif
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900172 /*
173 * # of valid blocks and the validity bitmap stored in the the last
174 * checkpoint pack. This information is used by the SSR mode.
175 */
Chao Yuf51b4ce2016-05-04 23:19:48 +0800176 unsigned char *ckpt_valid_map; /* validity bitmap of blocks last cp */
Jaegeuk Kima66cdd92015-04-30 22:37:50 -0700177 unsigned char *discard_map;
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900178 unsigned long long mtime; /* modification time of the segment */
179};
180
181struct sec_entry {
182 unsigned int valid_blocks; /* # of valid blocks in a section */
183};
184
185struct segment_allocation {
186 void (*allocate_segment)(struct f2fs_sb_info *, int, bool);
187};
188
Chao Yudecd36b2015-08-07 18:42:09 +0800189/*
190 * this value is set in page as a private data which indicate that
191 * the page is atomically written, and it is in inmem_pages list.
192 */
Jaegeuk Kimd48dfc22016-01-29 16:21:15 -0800193#define ATOMIC_WRITTEN_PAGE ((unsigned long)-1)
Jaegeuk Kim0a595eb2016-12-14 10:12:56 -0800194#define DUMMY_WRITTEN_PAGE ((unsigned long)-2)
Chao Yudecd36b2015-08-07 18:42:09 +0800195
196#define IS_ATOMIC_WRITTEN_PAGE(page) \
197 (page_private(page) == (unsigned long)ATOMIC_WRITTEN_PAGE)
Jaegeuk Kim0a595eb2016-12-14 10:12:56 -0800198#define IS_DUMMY_WRITTEN_PAGE(page) \
199 (page_private(page) == (unsigned long)DUMMY_WRITTEN_PAGE)
Chao Yudecd36b2015-08-07 18:42:09 +0800200
Jaegeuk Kim88b88a62014-10-06 17:39:50 -0700201struct inmem_pages {
202 struct list_head list;
203 struct page *page;
Chao Yu28bc1062016-02-06 14:40:34 +0800204 block_t old_addr; /* for revoking when fail to commit */
Jaegeuk Kim88b88a62014-10-06 17:39:50 -0700205};
206
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900207struct sit_info {
208 const struct segment_allocation *s_ops;
209
210 block_t sit_base_addr; /* start block address of SIT area */
211 block_t sit_blocks; /* # of blocks used by SIT area */
212 block_t written_valid_blocks; /* # of valid blocks in main area */
213 char *sit_bitmap; /* SIT bitmap pointer */
Chao Yuae27d622017-01-07 18:52:34 +0800214#ifdef CONFIG_F2FS_CHECK_FS
215 char *sit_bitmap_mir; /* SIT bitmap mirror */
216#endif
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900217 unsigned int bitmap_size; /* SIT bitmap size */
218
Jaegeuk Kim60a3b782015-02-10 16:44:29 -0800219 unsigned long *tmp_map; /* bitmap for temporal use */
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900220 unsigned long *dirty_sentries_bitmap; /* bitmap for dirty sentries */
221 unsigned int dirty_sentries; /* # of dirty sentries */
222 unsigned int sents_per_block; /* # of SIT entries per block */
223 struct mutex sentry_lock; /* to protect SIT cache */
224 struct seg_entry *sentries; /* SIT segment-level cache */
225 struct sec_entry *sec_entries; /* SIT section-level cache */
226
227 /* for cost-benefit algorithm in cleaning procedure */
228 unsigned long long elapsed_time; /* elapsed time after mount */
229 unsigned long long mounted_time; /* mount time */
230 unsigned long long min_mtime; /* min. modification time */
231 unsigned long long max_mtime; /* max. modification time */
232};
233
234struct free_segmap_info {
235 unsigned int start_segno; /* start segment number logically */
236 unsigned int free_segments; /* # of free segments */
237 unsigned int free_sections; /* # of free sections */
Chao Yu1a118cc2015-02-11 18:20:38 +0800238 spinlock_t segmap_lock; /* free segmap lock */
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900239 unsigned long *free_segmap; /* free segment bitmap */
240 unsigned long *free_secmap; /* free section bitmap */
241};
242
243/* Notice: The order of dirty type is same with CURSEG_XXX in f2fs.h */
244enum dirty_type {
245 DIRTY_HOT_DATA, /* dirty segments assigned as hot data logs */
246 DIRTY_WARM_DATA, /* dirty segments assigned as warm data logs */
247 DIRTY_COLD_DATA, /* dirty segments assigned as cold data logs */
248 DIRTY_HOT_NODE, /* dirty segments assigned as hot node logs */
249 DIRTY_WARM_NODE, /* dirty segments assigned as warm node logs */
250 DIRTY_COLD_NODE, /* dirty segments assigned as cold node logs */
251 DIRTY, /* to count # of dirty segments */
252 PRE, /* to count # of entirely obsolete segments */
253 NR_DIRTY_TYPE
254};
255
256struct dirty_seglist_info {
257 const struct victim_selection *v_ops; /* victim selction operation */
258 unsigned long *dirty_segmap[NR_DIRTY_TYPE];
259 struct mutex seglist_lock; /* lock for segment bitmaps */
260 int nr_dirty[NR_DIRTY_TYPE]; /* # of dirty segments */
Jaegeuk Kim5ec4e492013-03-31 13:26:03 +0900261 unsigned long *victim_secmap; /* background GC victims */
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900262};
263
264/* victim selection function for cleaning and SSR */
265struct victim_selection {
266 int (*get_victim)(struct f2fs_sb_info *, unsigned int *,
267 int, int, char);
268};
269
270/* for active log information */
271struct curseg_info {
272 struct mutex curseg_mutex; /* lock for consistency */
273 struct f2fs_summary_block *sum_blk; /* cached summary block */
Chao Yub7ad7512016-02-19 18:08:46 +0800274 struct rw_semaphore journal_rwsem; /* protect journal area */
275 struct f2fs_journal *journal; /* cached journal info */
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900276 unsigned char alloc_type; /* current allocation type */
277 unsigned int segno; /* current segment number */
278 unsigned short next_blkoff; /* next block offset to write */
279 unsigned int zone; /* current zone number */
280 unsigned int next_segno; /* preallocated segment */
281};
282
Chao Yu184a5cd2014-09-04 18:13:01 +0800283struct sit_entry_set {
284 struct list_head set_list; /* link with all sit sets */
285 unsigned int start_segno; /* start segno of sits in set */
286 unsigned int entry_cnt; /* the # of sit entries in set */
287};
288
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900289/*
290 * inline functions
291 */
292static inline struct curseg_info *CURSEG_I(struct f2fs_sb_info *sbi, int type)
293{
294 return (struct curseg_info *)(SM_I(sbi)->curseg_array + type);
295}
296
297static inline struct seg_entry *get_seg_entry(struct f2fs_sb_info *sbi,
298 unsigned int segno)
299{
300 struct sit_info *sit_i = SIT_I(sbi);
301 return &sit_i->sentries[segno];
302}
303
304static inline struct sec_entry *get_sec_entry(struct f2fs_sb_info *sbi,
305 unsigned int segno)
306{
307 struct sit_info *sit_i = SIT_I(sbi);
308 return &sit_i->sec_entries[GET_SECNO(sbi, segno)];
309}
310
311static inline unsigned int get_valid_blocks(struct f2fs_sb_info *sbi,
Jaegeuk Kim302bd342017-04-07 14:33:22 -0700312 unsigned int segno, bool use_section)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900313{
314 /*
315 * In order to get # of valid blocks in a section instantly from many
316 * segments, f2fs manages two counting structures separately.
317 */
Jaegeuk Kim302bd342017-04-07 14:33:22 -0700318 if (use_section && sbi->segs_per_sec > 1)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900319 return get_sec_entry(sbi, segno)->valid_blocks;
320 else
321 return get_seg_entry(sbi, segno)->valid_blocks;
322}
323
324static inline void seg_info_from_raw_sit(struct seg_entry *se,
325 struct f2fs_sit_entry *rs)
326{
327 se->valid_blocks = GET_SIT_VBLOCKS(rs);
328 se->ckpt_valid_blocks = GET_SIT_VBLOCKS(rs);
329 memcpy(se->cur_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
330 memcpy(se->ckpt_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
Chao Yu355e7892017-01-07 18:51:01 +0800331#ifdef CONFIG_F2FS_CHECK_FS
332 memcpy(se->cur_valid_map_mir, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
333#endif
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900334 se->type = GET_SIT_TYPE(rs);
335 se->mtime = le64_to_cpu(rs->mtime);
336}
337
338static inline void seg_info_to_raw_sit(struct seg_entry *se,
339 struct f2fs_sit_entry *rs)
340{
341 unsigned short raw_vblocks = (se->type << SIT_VBLOCKS_SHIFT) |
342 se->valid_blocks;
343 rs->vblocks = cpu_to_le16(raw_vblocks);
344 memcpy(rs->valid_map, se->cur_valid_map, SIT_VBLOCK_MAP_SIZE);
345 memcpy(se->ckpt_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
346 se->ckpt_valid_blocks = se->valid_blocks;
347 rs->mtime = cpu_to_le64(se->mtime);
348}
349
350static inline unsigned int find_next_inuse(struct free_segmap_info *free_i,
351 unsigned int max, unsigned int segno)
352{
353 unsigned int ret;
Chao Yu1a118cc2015-02-11 18:20:38 +0800354 spin_lock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900355 ret = find_next_bit(free_i->free_segmap, max, segno);
Chao Yu1a118cc2015-02-11 18:20:38 +0800356 spin_unlock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900357 return ret;
358}
359
360static inline void __set_free(struct f2fs_sb_info *sbi, unsigned int segno)
361{
362 struct free_segmap_info *free_i = FREE_I(sbi);
363 unsigned int secno = segno / sbi->segs_per_sec;
364 unsigned int start_segno = secno * sbi->segs_per_sec;
365 unsigned int next;
366
Chao Yu1a118cc2015-02-11 18:20:38 +0800367 spin_lock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900368 clear_bit(segno, free_i->free_segmap);
369 free_i->free_segments++;
370
Wanpeng Li7fd97012015-03-06 15:00:55 +0800371 next = find_next_bit(free_i->free_segmap,
372 start_segno + sbi->segs_per_sec, start_segno);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900373 if (next >= start_segno + sbi->segs_per_sec) {
374 clear_bit(secno, free_i->free_secmap);
375 free_i->free_sections++;
376 }
Chao Yu1a118cc2015-02-11 18:20:38 +0800377 spin_unlock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900378}
379
380static inline void __set_inuse(struct f2fs_sb_info *sbi,
381 unsigned int segno)
382{
383 struct free_segmap_info *free_i = FREE_I(sbi);
384 unsigned int secno = segno / sbi->segs_per_sec;
385 set_bit(segno, free_i->free_segmap);
386 free_i->free_segments--;
387 if (!test_and_set_bit(secno, free_i->free_secmap))
388 free_i->free_sections--;
389}
390
391static inline void __set_test_and_free(struct f2fs_sb_info *sbi,
392 unsigned int segno)
393{
394 struct free_segmap_info *free_i = FREE_I(sbi);
395 unsigned int secno = segno / sbi->segs_per_sec;
396 unsigned int start_segno = secno * sbi->segs_per_sec;
397 unsigned int next;
398
Chao Yu1a118cc2015-02-11 18:20:38 +0800399 spin_lock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900400 if (test_and_clear_bit(segno, free_i->free_segmap)) {
401 free_i->free_segments++;
402
Chao Yuf1121ab2014-07-14 16:45:15 +0800403 next = find_next_bit(free_i->free_segmap,
404 start_segno + sbi->segs_per_sec, start_segno);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900405 if (next >= start_segno + sbi->segs_per_sec) {
406 if (test_and_clear_bit(secno, free_i->free_secmap))
407 free_i->free_sections++;
408 }
409 }
Chao Yu1a118cc2015-02-11 18:20:38 +0800410 spin_unlock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900411}
412
413static inline void __set_test_and_inuse(struct f2fs_sb_info *sbi,
414 unsigned int segno)
415{
416 struct free_segmap_info *free_i = FREE_I(sbi);
417 unsigned int secno = segno / sbi->segs_per_sec;
Chao Yu1a118cc2015-02-11 18:20:38 +0800418 spin_lock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900419 if (!test_and_set_bit(segno, free_i->free_segmap)) {
420 free_i->free_segments--;
421 if (!test_and_set_bit(secno, free_i->free_secmap))
422 free_i->free_sections--;
423 }
Chao Yu1a118cc2015-02-11 18:20:38 +0800424 spin_unlock(&free_i->segmap_lock);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900425}
426
427static inline void get_sit_bitmap(struct f2fs_sb_info *sbi,
428 void *dst_addr)
429{
430 struct sit_info *sit_i = SIT_I(sbi);
Chao Yuae27d622017-01-07 18:52:34 +0800431
432#ifdef CONFIG_F2FS_CHECK_FS
433 if (memcmp(sit_i->sit_bitmap, sit_i->sit_bitmap_mir,
434 sit_i->bitmap_size))
435 f2fs_bug_on(sbi, 1);
436#endif
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900437 memcpy(dst_addr, sit_i->sit_bitmap, sit_i->bitmap_size);
438}
439
440static inline block_t written_block_count(struct f2fs_sb_info *sbi)
441{
Jaegeuk Kim8b8343f2014-02-24 13:00:13 +0900442 return SIT_I(sbi)->written_valid_blocks;
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900443}
444
445static inline unsigned int free_segments(struct f2fs_sb_info *sbi)
446{
Jaegeuk Kim8b8343f2014-02-24 13:00:13 +0900447 return FREE_I(sbi)->free_segments;
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900448}
449
450static inline int reserved_segments(struct f2fs_sb_info *sbi)
451{
452 return SM_I(sbi)->reserved_segments;
453}
454
455static inline unsigned int free_sections(struct f2fs_sb_info *sbi)
456{
Jaegeuk Kim8b8343f2014-02-24 13:00:13 +0900457 return FREE_I(sbi)->free_sections;
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900458}
459
460static inline unsigned int prefree_segments(struct f2fs_sb_info *sbi)
461{
462 return DIRTY_I(sbi)->nr_dirty[PRE];
463}
464
465static inline unsigned int dirty_segments(struct f2fs_sb_info *sbi)
466{
467 return DIRTY_I(sbi)->nr_dirty[DIRTY_HOT_DATA] +
468 DIRTY_I(sbi)->nr_dirty[DIRTY_WARM_DATA] +
469 DIRTY_I(sbi)->nr_dirty[DIRTY_COLD_DATA] +
470 DIRTY_I(sbi)->nr_dirty[DIRTY_HOT_NODE] +
471 DIRTY_I(sbi)->nr_dirty[DIRTY_WARM_NODE] +
472 DIRTY_I(sbi)->nr_dirty[DIRTY_COLD_NODE];
473}
474
475static inline int overprovision_segments(struct f2fs_sb_info *sbi)
476{
477 return SM_I(sbi)->ovp_segments;
478}
479
480static inline int overprovision_sections(struct f2fs_sb_info *sbi)
481{
482 return ((unsigned int) overprovision_segments(sbi)) / sbi->segs_per_sec;
483}
484
485static inline int reserved_sections(struct f2fs_sb_info *sbi)
486{
487 return ((unsigned int) reserved_segments(sbi)) / sbi->segs_per_sec;
488}
489
490static inline bool need_SSR(struct f2fs_sb_info *sbi)
491{
Jaegeuk Kim95dd8972014-09-17 17:52:58 -0700492 int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES);
493 int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS);
Jaegeuk Kimb9610bd2016-10-14 13:28:05 -0700494 int imeta_secs = get_blocktype_secs(sbi, F2FS_DIRTY_IMETA);
Jaegeuk Kim36abef42016-06-03 19:29:38 -0700495
496 if (test_opt(sbi, LFS))
497 return false;
498
Jaegeuk Kimb9610bd2016-10-14 13:28:05 -0700499 return free_sections(sbi) <= (node_secs + 2 * dent_secs + imeta_secs +
Jaegeuk Kim796dbbf2017-03-24 21:08:56 -0400500 2 * reserved_sections(sbi));
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900501}
502
Jaegeuk Kim7f3037a2016-09-01 12:02:51 -0700503static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi,
504 int freed, int needed)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900505{
Namjae Jeon5ac206c2013-02-02 23:52:59 +0900506 int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES);
507 int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS);
Jaegeuk Kimb9610bd2016-10-14 13:28:05 -0700508 int imeta_secs = get_blocktype_secs(sbi, F2FS_DIRTY_IMETA);
Jaegeuk Kim0f18b462016-05-20 11:10:10 -0700509
Chao Yucaf00472015-01-28 17:48:42 +0800510 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
Jaegeuk Kim029cd282012-12-21 17:20:21 +0900511 return false;
512
Jaegeuk Kim7f3037a2016-09-01 12:02:51 -0700513 return (free_sections(sbi) + freed) <=
Jaegeuk Kimb9610bd2016-10-14 13:28:05 -0700514 (node_secs + 2 * dent_secs + imeta_secs +
515 reserved_sections(sbi) + needed);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900516}
517
Jaegeuk Kim81eb8d62013-10-24 13:31:34 +0900518static inline bool excess_prefree_segs(struct f2fs_sb_info *sbi)
519{
Chris Fries6c311ec2014-01-17 14:44:39 -0600520 return prefree_segments(sbi) > SM_I(sbi)->rec_prefree_segments;
Jaegeuk Kim81eb8d62013-10-24 13:31:34 +0900521}
522
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900523static inline int utilization(struct f2fs_sb_info *sbi)
524{
Chris Fries6c311ec2014-01-17 14:44:39 -0600525 return div_u64((u64)valid_user_blocks(sbi) * 100,
526 sbi->user_block_count);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900527}
528
529/*
530 * Sometimes f2fs may be better to drop out-of-place update policy.
Jaegeuk Kim216fbd62013-11-07 13:13:42 +0900531 * And, users can control the policy through sysfs entries.
532 * There are five policies with triggering conditions as follows.
533 * F2FS_IPU_FORCE - all the time,
534 * F2FS_IPU_SSR - if SSR mode is activated,
535 * F2FS_IPU_UTIL - if FS utilization is over threashold,
536 * F2FS_IPU_SSR_UTIL - if SSR mode is activated and FS utilization is over
537 * threashold,
Jaegeuk Kimc1ce1b02014-09-10 16:53:02 -0700538 * F2FS_IPU_FSYNC - activated in fsync path only for high performance flash
539 * storages. IPU will be triggered only if the # of dirty
540 * pages over min_fsync_blocks.
Jaegeuk Kim216fbd62013-11-07 13:13:42 +0900541 * F2FS_IPUT_DISABLE - disable IPU. (=default option)
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900542 */
Jaegeuk Kim216fbd62013-11-07 13:13:42 +0900543#define DEF_MIN_IPU_UTIL 70
Jaegeuk Kimc1ce1b02014-09-10 16:53:02 -0700544#define DEF_MIN_FSYNC_BLOCKS 8
Jaegeuk Kimef095d12017-03-24 20:05:13 -0400545#define DEF_MIN_HOT_BLOCKS 16
Jaegeuk Kim216fbd62013-11-07 13:13:42 +0900546
547enum {
548 F2FS_IPU_FORCE,
549 F2FS_IPU_SSR,
550 F2FS_IPU_UTIL,
551 F2FS_IPU_SSR_UTIL,
Jaegeuk Kimc1ce1b02014-09-10 16:53:02 -0700552 F2FS_IPU_FSYNC,
Jaegeuk Kim216fbd62013-11-07 13:13:42 +0900553};
554
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900555static inline bool need_inplace_update(struct inode *inode)
556{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700557 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kim9b5f1362014-09-16 18:30:54 -0700558 unsigned int policy = SM_I(sbi)->ipu_policy;
Jaegeuk Kim216fbd62013-11-07 13:13:42 +0900559
560 /* IPU can be done only for the user data */
Jaegeuk Kim88b88a62014-10-06 17:39:50 -0700561 if (S_ISDIR(inode->i_mode) || f2fs_is_atomic_file(inode))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900562 return false;
Jaegeuk Kim216fbd62013-11-07 13:13:42 +0900563
Jaegeuk Kim36abef42016-06-03 19:29:38 -0700564 if (test_opt(sbi, LFS))
565 return false;
566
Jaegeuk Kim9b5f1362014-09-16 18:30:54 -0700567 if (policy & (0x1 << F2FS_IPU_FORCE))
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900568 return true;
Jaegeuk Kim9b5f1362014-09-16 18:30:54 -0700569 if (policy & (0x1 << F2FS_IPU_SSR) && need_SSR(sbi))
570 return true;
571 if (policy & (0x1 << F2FS_IPU_UTIL) &&
572 utilization(sbi) > SM_I(sbi)->min_ipu_util)
573 return true;
574 if (policy & (0x1 << F2FS_IPU_SSR_UTIL) && need_SSR(sbi) &&
575 utilization(sbi) > SM_I(sbi)->min_ipu_util)
576 return true;
577
578 /* this is only set during fdatasync */
579 if (policy & (0x1 << F2FS_IPU_FSYNC) &&
Jaegeuk Kim91942322016-05-20 10:13:22 -0700580 is_inode_flag_set(inode, FI_NEED_IPU))
Jaegeuk Kim9b5f1362014-09-16 18:30:54 -0700581 return true;
582
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900583 return false;
584}
585
586static inline unsigned int curseg_segno(struct f2fs_sb_info *sbi,
587 int type)
588{
589 struct curseg_info *curseg = CURSEG_I(sbi, type);
590 return curseg->segno;
591}
592
593static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
594 int type)
595{
596 struct curseg_info *curseg = CURSEG_I(sbi, type);
597 return curseg->alloc_type;
598}
599
600static inline unsigned short curseg_blkoff(struct f2fs_sb_info *sbi, int type)
601{
602 struct curseg_info *curseg = CURSEG_I(sbi, type);
603 return curseg->next_blkoff;
604}
605
606static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
607{
Liu Xue7a04f642015-07-27 10:17:59 +0000608 f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900609}
610
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900611static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t blk_addr)
612{
Yunlei Hebb413d62016-07-28 12:12:38 +0800613 BUG_ON(blk_addr < SEG0_BLKADDR(sbi)
614 || blk_addr >= MAX_BLKADDR(sbi));
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900615}
616
617/*
arter97e1c42042014-08-06 23:22:50 +0900618 * Summary block is always treated as an invalid block
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900619 */
620static inline void check_block_count(struct f2fs_sb_info *sbi,
621 int segno, struct f2fs_sit_entry *raw_sit)
622{
Jaegeuk Kim4c278392015-08-11 16:01:30 -0700623#ifdef CONFIG_F2FS_CHECK_FS
Chao Yu44c60bf2013-10-29 14:50:40 +0800624 bool is_valid = test_bit_le(0, raw_sit->valid_map) ? true : false;
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900625 int valid_blocks = 0;
Chao Yu44c60bf2013-10-29 14:50:40 +0800626 int cur_pos = 0, next_pos;
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900627
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900628 /* check bitmap with valid block count */
Chao Yu44c60bf2013-10-29 14:50:40 +0800629 do {
630 if (is_valid) {
631 next_pos = find_next_zero_bit_le(&raw_sit->valid_map,
632 sbi->blocks_per_seg,
633 cur_pos);
634 valid_blocks += next_pos - cur_pos;
635 } else
636 next_pos = find_next_bit_le(&raw_sit->valid_map,
637 sbi->blocks_per_seg,
638 cur_pos);
639 cur_pos = next_pos;
640 is_valid = !is_valid;
641 } while (cur_pos < sbi->blocks_per_seg);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900642 BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);
Jaegeuk Kim5d56b672013-10-29 15:14:54 +0900643#endif
Jaegeuk Kim4c278392015-08-11 16:01:30 -0700644 /* check segment usage, and check boundary of a given segment number */
645 f2fs_bug_on(sbi, GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
646 || segno > TOTAL_SEGS(sbi) - 1);
Liu Xue7a04f642015-07-27 10:17:59 +0000647}
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900648
649static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,
650 unsigned int start)
651{
652 struct sit_info *sit_i = SIT_I(sbi);
Chao Yud3a14af2014-09-04 18:11:47 +0800653 unsigned int offset = SIT_BLOCK_OFFSET(start);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900654 block_t blk_addr = sit_i->sit_base_addr + offset;
655
656 check_seg_range(sbi, start);
657
Chao Yuae27d622017-01-07 18:52:34 +0800658#ifdef CONFIG_F2FS_CHECK_FS
659 if (f2fs_test_bit(offset, sit_i->sit_bitmap) !=
660 f2fs_test_bit(offset, sit_i->sit_bitmap_mir))
661 f2fs_bug_on(sbi, 1);
662#endif
663
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900664 /* calculate sit block address */
665 if (f2fs_test_bit(offset, sit_i->sit_bitmap))
666 blk_addr += sit_i->sit_blocks;
667
668 return blk_addr;
669}
670
671static inline pgoff_t next_sit_addr(struct f2fs_sb_info *sbi,
672 pgoff_t block_addr)
673{
674 struct sit_info *sit_i = SIT_I(sbi);
675 block_addr -= sit_i->sit_base_addr;
676 if (block_addr < sit_i->sit_blocks)
677 block_addr += sit_i->sit_blocks;
678 else
679 block_addr -= sit_i->sit_blocks;
680
681 return block_addr + sit_i->sit_base_addr;
682}
683
684static inline void set_to_next_sit(struct sit_info *sit_i, unsigned int start)
685{
Chao Yud3a14af2014-09-04 18:11:47 +0800686 unsigned int block_off = SIT_BLOCK_OFFSET(start);
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900687
Gu Zhengc6ac4c02014-10-20 17:45:50 +0800688 f2fs_change_bit(block_off, sit_i->sit_bitmap);
Chao Yuae27d622017-01-07 18:52:34 +0800689#ifdef CONFIG_F2FS_CHECK_FS
690 f2fs_change_bit(block_off, sit_i->sit_bitmap_mir);
691#endif
Jaegeuk Kim39a53e02012-11-28 13:37:31 +0900692}
693
694static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
695{
696 struct sit_info *sit_i = SIT_I(sbi);
697 return sit_i->elapsed_time + CURRENT_TIME_SEC.tv_sec -
698 sit_i->mounted_time;
699}
700
701static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
702 unsigned int ofs_in_node, unsigned char version)
703{
704 sum->nid = cpu_to_le32(nid);
705 sum->ofs_in_node = cpu_to_le16(ofs_in_node);
706 sum->version = version;
707}
708
709static inline block_t start_sum_block(struct f2fs_sb_info *sbi)
710{
711 return __start_cp_addr(sbi) +
712 le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_start_sum);
713}
714
715static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
716{
717 return __start_cp_addr(sbi) +
718 le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_total_block_count)
719 - (base + 1) + type;
720}
Jaegeuk Kim5ec4e492013-03-31 13:26:03 +0900721
Hou Pengyange93b9862017-02-16 12:34:31 +0000722static inline bool no_fggc_candidate(struct f2fs_sb_info *sbi,
723 unsigned int secno)
724{
Jaegeuk Kim302bd342017-04-07 14:33:22 -0700725 if (get_valid_blocks(sbi, GET_SEGNO_FROM_SECNO(sbi, secno), true) >=
726 sbi->fggc_threshold)
Hou Pengyange93b9862017-02-16 12:34:31 +0000727 return true;
728 return false;
729}
730
Jaegeuk Kim5ec4e492013-03-31 13:26:03 +0900731static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno)
732{
733 if (IS_CURSEC(sbi, secno) || (sbi->cur_victim_sec == secno))
734 return true;
735 return false;
736}
Jaegeuk Kimac5d1562013-04-29 16:58:39 +0900737
Jaegeuk Kim87d6f892014-03-18 12:40:49 +0900738/*
739 * It is very important to gather dirty pages and write at once, so that we can
740 * submit a big bio without interfering other data writes.
741 * By default, 512 pages for directory data,
Kinglong Mee727ebb02017-02-25 19:32:21 +0800742 * 512 pages (2MB) * 8 for nodes, and
743 * 256 pages * 8 for meta are set.
Jaegeuk Kim87d6f892014-03-18 12:40:49 +0900744 */
745static inline int nr_pages_to_skip(struct f2fs_sb_info *sbi, int type)
746{
Tejun Heoa88a3412015-05-22 17:13:28 -0400747 if (sbi->sb->s_bdi->wb.dirty_exceeded)
Jaegeuk Kim510184c2014-11-06 17:23:08 -0800748 return 0;
749
Jaegeuk Kima1257022015-10-08 10:40:07 -0700750 if (type == DATA)
751 return sbi->blocks_per_seg;
752 else if (type == NODE)
Jaegeuk Kim2c237eb2016-06-16 16:44:11 -0700753 return 8 * sbi->blocks_per_seg;
Jaegeuk Kim87d6f892014-03-18 12:40:49 +0900754 else if (type == META)
Jaegeuk Kim664ba972016-10-18 11:07:45 -0700755 return 8 * BIO_MAX_PAGES;
Jaegeuk Kim87d6f892014-03-18 12:40:49 +0900756 else
757 return 0;
758}
Jaegeuk Kim50c8cdb2014-03-18 13:47:11 +0900759
760/*
761 * When writing pages, it'd better align nr_to_write for segment size.
762 */
763static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
764 struct writeback_control *wbc)
765{
766 long nr_to_write, desired;
767
768 if (wbc->sync_mode != WB_SYNC_NONE)
769 return 0;
770
771 nr_to_write = wbc->nr_to_write;
Jaegeuk Kim664ba972016-10-18 11:07:45 -0700772 desired = BIO_MAX_PAGES;
Jaegeuk Kim28ea6162016-05-25 17:17:56 -0700773 if (type == NODE)
Jaegeuk Kim664ba972016-10-18 11:07:45 -0700774 desired <<= 1;
Jaegeuk Kim50c8cdb2014-03-18 13:47:11 +0900775
776 wbc->nr_to_write = desired;
777 return desired - nr_to_write;
778}