Lines Matching +full:cache +full:- +full:block

1 // SPDX-License-Identifier: GPL-2.0
5 * (c) 1996 Hans-Joachim Widmaier - Rewritten
7 * (C) 1993 Ray Burr - Modified for Amiga FFS filesystem.
11 * (C) 1991 Linus Torvalds - minix filesystem
27 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); in affs_file_open()
28 atomic_inc(&AFFS_I(inode)->i_opencnt); in affs_file_open()
36 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); in affs_file_release()
38 if (atomic_dec_and_test(&AFFS_I(inode)->i_opencnt)) { in affs_file_release()
40 if (inode->i_size != AFFS_I(inode)->mmu_private) in affs_file_release()
52 struct super_block *sb = inode->i_sb; in affs_grow_extcache()
57 if (!AFFS_I(inode)->i_lc) { in affs_grow_extcache()
60 return -ENOMEM; in affs_grow_extcache()
61 AFFS_I(inode)->i_lc = (u32 *)ptr; in affs_grow_extcache()
62 AFFS_I(inode)->i_ac = (struct affs_ext_key *)(ptr + AFFS_CACHE_SIZE / 2); in affs_grow_extcache()
65 lc_max = AFFS_LC_SIZE << AFFS_I(inode)->i_lc_shift; in affs_grow_extcache()
67 if (AFFS_I(inode)->i_extcnt > lc_max) { in affs_grow_extcache()
70 /* need to recalculate linear cache, start from old size */ in affs_grow_extcache()
71 lc_shift = AFFS_I(inode)->i_lc_shift; in affs_grow_extcache()
72 tmp = (AFFS_I(inode)->i_extcnt / AFFS_LC_SIZE) >> lc_shift; in affs_grow_extcache()
75 lc_mask = (1 << lc_shift) - 1; in affs_grow_extcache()
78 lc_idx >>= (lc_shift - AFFS_I(inode)->i_lc_shift); in affs_grow_extcache()
79 AFFS_I(inode)->i_lc_size >>= (lc_shift - AFFS_I(inode)->i_lc_shift); in affs_grow_extcache()
81 /* first shrink old cache to make more space */ in affs_grow_extcache()
82 off = 1 << (lc_shift - AFFS_I(inode)->i_lc_shift); in affs_grow_extcache()
84 AFFS_I(inode)->i_ac[i] = AFFS_I(inode)->i_ac[j]; in affs_grow_extcache()
86 AFFS_I(inode)->i_lc_shift = lc_shift; in affs_grow_extcache()
87 AFFS_I(inode)->i_lc_mask = lc_mask; in affs_grow_extcache()
90 /* fill cache to the needed index */ in affs_grow_extcache()
91 i = AFFS_I(inode)->i_lc_size; in affs_grow_extcache()
92 AFFS_I(inode)->i_lc_size = lc_idx + 1; in affs_grow_extcache()
95 AFFS_I(inode)->i_lc[0] = inode->i_ino; in affs_grow_extcache()
98 key = AFFS_I(inode)->i_lc[i - 1]; in affs_grow_extcache()
99 j = AFFS_I(inode)->i_lc_mask + 1; in affs_grow_extcache()
100 // unlock cache in affs_grow_extcache()
101 for (; j > 0; j--) { in affs_grow_extcache()
105 key = be32_to_cpu(AFFS_TAIL(sb, bh)->extension); in affs_grow_extcache()
108 // lock cache in affs_grow_extcache()
109 AFFS_I(inode)->i_lc[i] = key; in affs_grow_extcache()
115 // lock cache in affs_grow_extcache()
116 return -EIO; in affs_grow_extcache()
122 struct super_block *sb = inode->i_sb; in affs_alloc_extblock()
126 blocknr = affs_alloc_block(inode, bh->b_blocknr); in affs_alloc_extblock()
128 return ERR_PTR(-ENOSPC); in affs_alloc_extblock()
133 return ERR_PTR(-EIO); in affs_alloc_extblock()
136 AFFS_HEAD(new_bh)->ptype = cpu_to_be32(T_LIST); in affs_alloc_extblock()
137 AFFS_HEAD(new_bh)->key = cpu_to_be32(blocknr); in affs_alloc_extblock()
138 AFFS_TAIL(sb, new_bh)->stype = cpu_to_be32(ST_FILE); in affs_alloc_extblock()
139 AFFS_TAIL(sb, new_bh)->parent = cpu_to_be32(inode->i_ino); in affs_alloc_extblock()
144 tmp = be32_to_cpu(AFFS_TAIL(sb, bh)->extension); in affs_alloc_extblock()
147 AFFS_TAIL(sb, bh)->extension = cpu_to_be32(blocknr); in affs_alloc_extblock()
148 affs_adjust_checksum(bh, blocknr - tmp); in affs_alloc_extblock()
151 AFFS_I(inode)->i_extcnt++; in affs_alloc_extblock()
160 /* inline the simplest case: same extended block as last time */ in affs_get_extblock()
161 struct buffer_head *bh = AFFS_I(inode)->i_ext_bh; in affs_get_extblock()
162 if (ext == AFFS_I(inode)->i_ext_last) in affs_get_extblock()
174 struct super_block *sb = inode->i_sb; in affs_get_extblock_slow()
180 if (ext == AFFS_I(inode)->i_ext_last + 1) { in affs_get_extblock_slow()
181 /* read the next extended block from the current one */ in affs_get_extblock_slow()
182 bh = AFFS_I(inode)->i_ext_bh; in affs_get_extblock_slow()
183 ext_key = be32_to_cpu(AFFS_TAIL(sb, bh)->extension); in affs_get_extblock_slow()
184 if (ext < AFFS_I(inode)->i_extcnt) in affs_get_extblock_slow()
186 BUG_ON(ext > AFFS_I(inode)->i_extcnt); in affs_get_extblock_slow()
194 /* we seek back to the file header block */ in affs_get_extblock_slow()
195 ext_key = inode->i_ino; in affs_get_extblock_slow()
199 if (ext >= AFFS_I(inode)->i_extcnt) { in affs_get_extblock_slow()
202 /* allocate a new extended block */ in affs_get_extblock_slow()
203 BUG_ON(ext > AFFS_I(inode)->i_extcnt); in affs_get_extblock_slow()
205 /* get previous extended block */ in affs_get_extblock_slow()
206 prev_bh = affs_get_extblock(inode, ext - 1); in affs_get_extblock_slow()
217 /* check if there is an extended cache and whether it's large enough */ in affs_get_extblock_slow()
218 lc_idx = ext >> AFFS_I(inode)->i_lc_shift; in affs_get_extblock_slow()
219 lc_off = ext & AFFS_I(inode)->i_lc_mask; in affs_get_extblock_slow()
221 if (lc_idx >= AFFS_I(inode)->i_lc_size) { in affs_get_extblock_slow()
230 /* every n'th key we find in the linear cache */ in affs_get_extblock_slow()
232 ext_key = AFFS_I(inode)->i_lc[lc_idx]; in affs_get_extblock_slow()
236 /* maybe it's still in the associative cache */ in affs_get_extblock_slow()
237 ac_idx = (ext - lc_idx - 1) & AFFS_AC_MASK; in affs_get_extblock_slow()
238 if (AFFS_I(inode)->i_ac[ac_idx].ext == ext) { in affs_get_extblock_slow()
239 ext_key = AFFS_I(inode)->i_ac[ac_idx].key; in affs_get_extblock_slow()
246 while (--tmp, --lc_off > 0) { in affs_get_extblock_slow()
247 idx = (idx - 1) & AFFS_AC_MASK; in affs_get_extblock_slow()
248 if (AFFS_I(inode)->i_ac[idx].ext == tmp) { in affs_get_extblock_slow()
249 ext_key = AFFS_I(inode)->i_ac[idx].key; in affs_get_extblock_slow()
254 /* fall back to the linear cache */ in affs_get_extblock_slow()
255 ext_key = AFFS_I(inode)->i_lc[lc_idx]; in affs_get_extblock_slow()
258 //unlock cache in affs_get_extblock_slow()
263 ext_key = be32_to_cpu(AFFS_TAIL(sb, bh)->extension); in affs_get_extblock_slow()
267 //lock cache in affs_get_extblock_slow()
269 /* store it in the associative cache */ in affs_get_extblock_slow()
271 AFFS_I(inode)->i_ac[ac_idx].ext = ext; in affs_get_extblock_slow()
272 AFFS_I(inode)->i_ac[ac_idx].key = ext_key; in affs_get_extblock_slow()
275 /* finally read the right extended block */ in affs_get_extblock_slow()
276 //unlock cache in affs_get_extblock_slow()
280 //lock cache in affs_get_extblock_slow()
283 /* release old cached extended block and store the new one */ in affs_get_extblock_slow()
284 affs_brelse(AFFS_I(inode)->i_ext_bh); in affs_get_extblock_slow()
285 AFFS_I(inode)->i_ext_last = ext; in affs_get_extblock_slow()
286 AFFS_I(inode)->i_ext_bh = bh; in affs_get_extblock_slow()
293 return ERR_PTR(-EIO); in affs_get_extblock_slow()
297 affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_result, int create) in affs_get_block() argument
299 struct super_block *sb = inode->i_sb; in affs_get_block()
303 pr_debug("%s(%lu, %llu)\n", __func__, inode->i_ino, in affs_get_block()
304 (unsigned long long)block); in affs_get_block()
306 BUG_ON(block > (sector_t)0x7fffffffUL); in affs_get_block()
308 if (block >= AFFS_I(inode)->i_blkcnt) { in affs_get_block()
309 if (block > AFFS_I(inode)->i_blkcnt || !create) in affs_get_block()
314 //lock cache in affs_get_block()
317 ext = (u32)block / AFFS_SB(sb)->s_hashsize; in affs_get_block()
318 block -= ext * AFFS_SB(sb)->s_hashsize; in affs_get_block()
322 map_bh(bh_result, sb, (sector_t)be32_to_cpu(AFFS_BLOCK(sb, ext_bh, block))); in affs_get_block()
325 u32 blocknr = affs_alloc_block(inode, ext_bh->b_blocknr); in affs_get_block()
329 AFFS_I(inode)->mmu_private += AFFS_SB(sb)->s_data_blksize; in affs_get_block()
330 AFFS_I(inode)->i_blkcnt++; in affs_get_block()
332 /* store new block */ in affs_get_block()
333 if (bh_result->b_blocknr) in affs_get_block()
335 "block already set (%llx)", in affs_get_block()
336 (unsigned long long)bh_result->b_blocknr); in affs_get_block()
337 AFFS_BLOCK(sb, ext_bh, block) = cpu_to_be32(blocknr); in affs_get_block()
338 AFFS_HEAD(ext_bh)->block_count = cpu_to_be32(block + 1); in affs_get_block()
339 affs_adjust_checksum(ext_bh, blocknr - bh_result->b_blocknr + 1); in affs_get_block()
340 bh_result->b_blocknr = blocknr; in affs_get_block()
342 if (!block) { in affs_get_block()
343 /* insert first block into header block */ in affs_get_block()
344 u32 tmp = be32_to_cpu(AFFS_HEAD(ext_bh)->first_data); in affs_get_block()
346 affs_warning(sb, "get_block", "first block already set (%d)", tmp); in affs_get_block()
347 AFFS_HEAD(ext_bh)->first_data = cpu_to_be32(blocknr); in affs_get_block()
348 affs_adjust_checksum(ext_bh, blocknr - tmp); in affs_get_block()
353 //unlock cache in affs_get_block()
358 affs_error(inode->i_sb, "get_block", "strange block request %llu", in affs_get_block()
359 (unsigned long long)block); in affs_get_block()
360 return -EIO; in affs_get_block()
362 // unlock cache in affs_get_block()
368 bh_result->b_bdev = NULL; in affs_get_block()
369 // unlock cache in affs_get_block()
371 return -ENOSPC; in affs_get_block()
387 struct inode *inode = mapping->host; in affs_write_failed()
389 if (to > inode->i_size) { in affs_write_failed()
390 truncate_pagecache(inode, inode->i_size); in affs_write_failed()
398 struct file *file = iocb->ki_filp; in affs_direct_IO()
399 struct address_space *mapping = file->f_mapping; in affs_direct_IO()
400 struct inode *inode = mapping->host; in affs_direct_IO()
402 loff_t offset = iocb->ki_pos; in affs_direct_IO()
408 if (AFFS_I(inode)->mmu_private < size) in affs_direct_IO()
426 &AFFS_I(mapping->host)->mmu_private); in affs_write_begin()
437 struct inode *inode = mapping->host; in affs_write_end()
443 if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) { in affs_write_end()
444 AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED; in affs_write_end()
451 static sector_t _affs_bmap(struct address_space *mapping, sector_t block) in _affs_bmap() argument
453 return generic_block_bmap(mapping,block,affs_get_block); in _affs_bmap()
469 affs_bread_ino(struct inode *inode, int block, int create) in affs_bread_ino() argument
475 err = affs_get_block(inode, block, &tmp_bh, create); in affs_bread_ino()
477 bh = affs_bread(inode->i_sb, tmp_bh.b_blocknr); in affs_bread_ino()
479 bh->b_state |= tmp_bh.b_state; in affs_bread_ino()
482 err = -EIO; in affs_bread_ino()
488 affs_getzeroblk_ino(struct inode *inode, int block) in affs_getzeroblk_ino() argument
494 err = affs_get_block(inode, block, &tmp_bh, 1); in affs_getzeroblk_ino()
496 bh = affs_getzeroblk(inode->i_sb, tmp_bh.b_blocknr); in affs_getzeroblk_ino()
498 bh->b_state |= tmp_bh.b_state; in affs_getzeroblk_ino()
501 err = -EIO; in affs_getzeroblk_ino()
507 affs_getemptyblk_ino(struct inode *inode, int block) in affs_getemptyblk_ino() argument
513 err = affs_get_block(inode, block, &tmp_bh, 1); in affs_getemptyblk_ino()
515 bh = affs_getemptyblk(inode->i_sb, tmp_bh.b_blocknr); in affs_getemptyblk_ino()
517 bh->b_state |= tmp_bh.b_state; in affs_getemptyblk_ino()
520 err = -EIO; in affs_getemptyblk_ino()
527 struct inode *inode = folio->mapping->host; in affs_do_read_folio_ofs()
528 struct super_block *sb = inode->i_sb; in affs_do_read_folio_ofs()
534 pr_debug("%s(%lu, %ld, 0, %zu)\n", __func__, inode->i_ino, in affs_do_read_folio_ofs()
535 folio->index, to); in affs_do_read_folio_ofs()
537 bsize = AFFS_SB(sb)->s_data_blksize; in affs_do_read_folio_ofs()
546 tmp = min(bsize - boff, to - pos); in affs_do_read_folio_ofs()
560 struct super_block *sb = inode->i_sb; in affs_extent_file_ofs()
566 pr_debug("%s(%lu, %d)\n", __func__, inode->i_ino, newsize); in affs_extent_file_ofs()
567 bsize = AFFS_SB(sb)->s_data_blksize; in affs_extent_file_ofs()
569 size = AFFS_I(inode)->mmu_private; in affs_extent_file_ofs()
576 tmp = min(bsize - boff, newsize - size); in affs_extent_file_ofs()
579 be32_add_cpu(&AFFS_DATA_HEAD(bh)->size, tmp); in affs_extent_file_ofs()
585 bh = affs_bread_ino(inode, bidx - 1, 0); in affs_extent_file_ofs()
595 tmp = min(bsize, newsize - size); in affs_extent_file_ofs()
597 AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); in affs_extent_file_ofs()
598 AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino); in affs_extent_file_ofs()
599 AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx); in affs_extent_file_ofs()
600 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(tmp); in affs_extent_file_ofs()
602 bh->b_state &= ~(1UL << BH_New); in affs_extent_file_ofs()
605 u32 tmp_next = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next); in affs_extent_file_ofs()
609 "next block already set for %d (%d)", in affs_extent_file_ofs()
611 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr); in affs_extent_file_ofs()
612 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp_next); in affs_extent_file_ofs()
620 inode->i_size = AFFS_I(inode)->mmu_private = newsize; in affs_extent_file_ofs()
624 inode->i_size = AFFS_I(inode)->mmu_private = newsize; in affs_extent_file_ofs()
630 struct inode *inode = folio->mapping->host; in affs_read_folio_ofs()
634 pr_debug("%s(%lu, %ld)\n", __func__, inode->i_ino, folio->index); in affs_read_folio_ofs()
636 if (folio_pos(folio) + to > inode->i_size) { in affs_read_folio_ofs()
637 to = inode->i_size - folio_pos(folio); in affs_read_folio_ofs()
652 struct inode *inode = mapping->host; in affs_write_begin_ofs()
657 pr_debug("%s(%lu, %llu, %llu)\n", __func__, inode->i_ino, pos, in affs_write_begin_ofs()
659 if (pos > AFFS_I(inode)->mmu_private) { in affs_write_begin_ofs()
660 /* XXX: this probably leaves a too-big i_size in case of in affs_write_begin_ofs()
691 struct inode *inode = mapping->host; in affs_write_end_ofs()
692 struct super_block *sb = inode->i_sb; in affs_write_end_ofs()
700 from = pos & (PAGE_SIZE - 1); in affs_write_end_ofs()
708 pr_debug("%s(%lu, %llu, %llu)\n", __func__, inode->i_ino, pos, in affs_write_end_ofs()
710 bsize = AFFS_SB(sb)->s_data_blksize; in affs_write_end_ofs()
715 tmp = (folio->index << PAGE_SHIFT) + from; in affs_write_end_ofs()
724 tmp = min(bsize - boff, to - from); in affs_write_end_ofs()
727 be32_add_cpu(&AFFS_DATA_HEAD(bh)->size, tmp); in affs_write_end_ofs()
734 bh = affs_bread_ino(inode, bidx - 1, 0); in affs_write_end_ofs()
747 AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); in affs_write_end_ofs()
748 AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino); in affs_write_end_ofs()
749 AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx); in affs_write_end_ofs()
750 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(bsize); in affs_write_end_ofs()
751 AFFS_DATA_HEAD(bh)->next = 0; in affs_write_end_ofs()
752 bh->b_state &= ~(1UL << BH_New); in affs_write_end_ofs()
754 u32 tmp_next = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next); in affs_write_end_ofs()
758 "next block already set for %d (%d)", in affs_write_end_ofs()
760 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr); in affs_write_end_ofs()
761 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp_next); in affs_write_end_ofs()
777 tmp = min(bsize, to - from); in affs_write_end_ofs()
781 AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); in affs_write_end_ofs()
782 AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino); in affs_write_end_ofs()
783 AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx); in affs_write_end_ofs()
784 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(tmp); in affs_write_end_ofs()
785 AFFS_DATA_HEAD(bh)->next = 0; in affs_write_end_ofs()
786 bh->b_state &= ~(1UL << BH_New); in affs_write_end_ofs()
788 u32 tmp_next = be32_to_cpu(AFFS_DATA_HEAD(prev_bh)->next); in affs_write_end_ofs()
792 "next block already set for %d (%d)", in affs_write_end_ofs()
794 AFFS_DATA_HEAD(prev_bh)->next = cpu_to_be32(bh->b_blocknr); in affs_write_end_ofs()
795 affs_adjust_checksum(prev_bh, bh->b_blocknr - tmp_next); in affs_write_end_ofs()
798 } else if (be32_to_cpu(AFFS_DATA_HEAD(bh)->size) < tmp) in affs_write_end_ofs()
799 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(tmp); in affs_write_end_ofs()
811 tmp = (folio->index << PAGE_SHIFT) + from; in affs_write_end_ofs()
812 if (tmp > inode->i_size) in affs_write_end_ofs()
813 inode->i_size = AFFS_I(inode)->mmu_private = tmp; in affs_write_end_ofs()
816 if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) { in affs_write_end_ofs()
817 AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED; in affs_write_end_ofs()
849 struct super_block *sb = inode->i_sb; in affs_free_prealloc()
851 pr_debug("free_prealloc(ino=%lu)\n", inode->i_ino); in affs_free_prealloc()
853 while (AFFS_I(inode)->i_pa_cnt) { in affs_free_prealloc()
854 AFFS_I(inode)->i_pa_cnt--; in affs_free_prealloc()
855 affs_free_block(sb, ++AFFS_I(inode)->i_lastalloc); in affs_free_prealloc()
864 struct super_block *sb = inode->i_sb; in affs_truncate()
872 inode->i_ino, AFFS_I(inode)->mmu_private, inode->i_size); in affs_truncate()
876 if (inode->i_size) { in affs_truncate()
877 last_blk = ((u32)inode->i_size - 1) / AFFS_SB(sb)->s_data_blksize; in affs_truncate()
878 ext = last_blk / AFFS_SB(sb)->s_hashsize; in affs_truncate()
881 if (inode->i_size > AFFS_I(inode)->mmu_private) { in affs_truncate()
882 struct address_space *mapping = inode->i_mapping; in affs_truncate()
885 loff_t isize = inode->i_size; in affs_truncate()
888 res = mapping->a_ops->write_begin(NULL, mapping, isize, 0, &folio, &fsdata); in affs_truncate()
890 res = mapping->a_ops->write_end(NULL, mapping, isize, 0, 0, folio, fsdata); in affs_truncate()
892 inode->i_size = AFFS_I(inode)->mmu_private; in affs_truncate()
895 } else if (inode->i_size == AFFS_I(inode)->mmu_private) in affs_truncate()
898 // lock cache in affs_truncate()
902 "unexpected read error for ext block %u (%ld)", in affs_truncate()
906 if (AFFS_I(inode)->i_lc) { in affs_truncate()
907 /* clear linear cache */ in affs_truncate()
908 i = (ext + 1) >> AFFS_I(inode)->i_lc_shift; in affs_truncate()
909 if (AFFS_I(inode)->i_lc_size > i) { in affs_truncate()
910 AFFS_I(inode)->i_lc_size = i; in affs_truncate()
912 AFFS_I(inode)->i_lc[i] = 0; in affs_truncate()
914 /* clear associative cache */ in affs_truncate()
916 if (AFFS_I(inode)->i_ac[i].ext >= ext) in affs_truncate()
917 AFFS_I(inode)->i_ac[i].ext = 0; in affs_truncate()
919 ext_key = be32_to_cpu(AFFS_TAIL(sb, ext_bh)->extension); in affs_truncate()
921 blkcnt = AFFS_I(inode)->i_blkcnt; in affs_truncate()
924 if (inode->i_size) { in affs_truncate()
925 i = last_blk % AFFS_SB(sb)->s_hashsize + 1; in affs_truncate()
928 AFFS_HEAD(ext_bh)->first_data = 0; in affs_truncate()
929 AFFS_HEAD(ext_bh)->block_count = cpu_to_be32(i); in affs_truncate()
930 size = AFFS_SB(sb)->s_hashsize; in affs_truncate()
931 if (size > blkcnt - blk + i) in affs_truncate()
932 size = blkcnt - blk + i; in affs_truncate()
937 AFFS_TAIL(sb, ext_bh)->extension = 0; in affs_truncate()
942 if (inode->i_size) { in affs_truncate()
943 AFFS_I(inode)->i_blkcnt = last_blk + 1; in affs_truncate()
944 AFFS_I(inode)->i_extcnt = ext + 1; in affs_truncate()
945 if (affs_test_opt(AFFS_SB(sb)->s_flags, SF_OFS)) { in affs_truncate()
950 "unexpected read error for last block %u (%ld)", in affs_truncate()
954 tmp = be32_to_cpu(AFFS_DATA_HEAD(bh)->next); in affs_truncate()
955 AFFS_DATA_HEAD(bh)->next = 0; in affs_truncate()
956 affs_adjust_checksum(bh, -tmp); in affs_truncate()
960 AFFS_I(inode)->i_blkcnt = 0; in affs_truncate()
961 AFFS_I(inode)->i_extcnt = 1; in affs_truncate()
963 AFFS_I(inode)->mmu_private = inode->i_size; in affs_truncate()
964 // unlock cache in affs_truncate()
968 size = AFFS_SB(sb)->s_hashsize; in affs_truncate()
969 if (size > blkcnt - blk) in affs_truncate()
970 size = blkcnt - blk; in affs_truncate()
974 ext_key = be32_to_cpu(AFFS_TAIL(sb, ext_bh)->extension); in affs_truncate()
982 struct inode *inode = filp->f_mapping->host; in affs_file_fsync()
991 err = sync_blockdev(inode->i_sb->s_bdev); in affs_file_fsync()