Lines Matching refs:inode

47 static int ufs_block_to_path(struct inode *inode, sector_t i_block, unsigned offsets[4])  in ufs_block_to_path()  argument
49 struct ufs_sb_private_info *uspi = UFS_SB(inode->i_sb)->s_uspi; in ufs_block_to_path()
74 ufs_warning(inode->i_sb, "ufs_block_to_path", "block > big"); in ufs_block_to_path()
125 static u64 ufs_frag_map(struct inode *inode, unsigned offsets[4], int depth) in ufs_frag_map() argument
127 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs_frag_map()
128 struct super_block *sb = inode->i_sb; in ufs_frag_map()
222 ufs_extend_tail(struct inode *inode, u64 writes_to, in ufs_extend_tail() argument
225 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs_extend_tail()
226 struct super_block *sb = inode->i_sb; in ufs_extend_tail()
240 tmp = ufs_new_fragments(inode, p, lastfrag, ufs_data_ptr_to_cpu(sb, p), in ufs_extend_tail()
255 static u64 ufs_inode_getfrag(struct inode *inode, unsigned index, in ufs_inode_getfrag() argument
259 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs_inode_getfrag()
260 struct super_block *sb = inode->i_sb; in ufs_inode_getfrag()
284 tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), in ufs_inode_getfrag()
294 inode_set_ctime_current(inode); in ufs_inode_getfrag()
295 if (IS_SYNC(inode)) in ufs_inode_getfrag()
296 ufs_sync_inode (inode); in ufs_inode_getfrag()
297 mark_inode_dirty(inode); in ufs_inode_getfrag()
313 static u64 ufs_inode_getblock(struct inode *inode, u64 ind_block, in ufs_inode_getblock() argument
317 struct super_block *sb = inode->i_sb; in ufs_inode_getblock()
349 tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal, in ufs_inode_getblock()
358 if (IS_SYNC(inode)) in ufs_inode_getblock()
360 inode_set_ctime_current(inode); in ufs_inode_getblock()
361 mark_inode_dirty(inode); in ufs_inode_getblock()
375 static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head *bh_result,… in ufs_getfrag_block() argument
377 struct super_block *sb = inode->i_sb; in ufs_getfrag_block()
381 int depth = ufs_block_to_path(inode, fragment >> uspi->s_fpbshift, offsets); in ufs_getfrag_block()
385 phys64 = ufs_frag_map(inode, offsets, depth); in ufs_getfrag_block()
392 read_seqlock_excl(&UFS_I(inode)->meta_lock); in ufs_getfrag_block()
393 if (fragment < UFS_I(inode)->i_lastfrag) { in ufs_getfrag_block()
394 read_sequnlock_excl(&UFS_I(inode)->meta_lock); in ufs_getfrag_block()
397 read_sequnlock_excl(&UFS_I(inode)->meta_lock); in ufs_getfrag_block()
401 mutex_lock(&UFS_I(inode)->truncate_mutex); in ufs_getfrag_block()
403 UFSD("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment); in ufs_getfrag_block()
410 if (UFS_I(inode)->i_lastfrag < UFS_NDIR_FRAGMENT) { in ufs_getfrag_block()
411 unsigned lastfrag = UFS_I(inode)->i_lastfrag; in ufs_getfrag_block()
414 if (!ufs_extend_tail(inode, fragment, in ufs_getfrag_block()
421 phys64 = ufs_inode_getfrag(inode, offsets[0], fragment, in ufs_getfrag_block()
425 phys64 = ufs_inode_getfrag(inode, offsets[0], fragment, in ufs_getfrag_block()
428 phys64 = ufs_inode_getblock(inode, phys64, offsets[i], in ufs_getfrag_block()
430 phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1], in ufs_getfrag_block()
440 mutex_unlock(&UFS_I(inode)->truncate_mutex); in ufs_getfrag_block()
465 static void ufs_truncate_blocks(struct inode *);
469 struct inode *inode = mapping->host; in ufs_write_failed() local
471 if (to > inode->i_size) { in ufs_write_failed()
472 truncate_pagecache(inode, inode->i_size); in ufs_write_failed()
473 ufs_truncate_blocks(inode); in ufs_write_failed()
518 static void ufs_set_inode_ops(struct inode *inode) in ufs_set_inode_ops() argument
520 if (S_ISREG(inode->i_mode)) { in ufs_set_inode_ops()
521 inode->i_op = &ufs_file_inode_operations; in ufs_set_inode_ops()
522 inode->i_fop = &ufs_file_operations; in ufs_set_inode_ops()
523 inode->i_mapping->a_ops = &ufs_aops; in ufs_set_inode_ops()
524 } else if (S_ISDIR(inode->i_mode)) { in ufs_set_inode_ops()
525 inode->i_op = &ufs_dir_inode_operations; in ufs_set_inode_ops()
526 inode->i_fop = &ufs_dir_operations; in ufs_set_inode_ops()
527 inode->i_mapping->a_ops = &ufs_aops; in ufs_set_inode_ops()
528 } else if (S_ISLNK(inode->i_mode)) { in ufs_set_inode_ops()
529 if (!inode->i_blocks) { in ufs_set_inode_ops()
530 inode->i_link = (char *)UFS_I(inode)->i_u1.i_symlink; in ufs_set_inode_ops()
531 inode->i_op = &simple_symlink_inode_operations; in ufs_set_inode_ops()
533 inode->i_mapping->a_ops = &ufs_aops; in ufs_set_inode_ops()
534 inode->i_op = &page_symlink_inode_operations; in ufs_set_inode_ops()
535 inode_nohighmem(inode); in ufs_set_inode_ops()
538 init_special_inode(inode, inode->i_mode, in ufs_set_inode_ops()
539 ufs_get_inode_dev(inode->i_sb, UFS_I(inode))); in ufs_set_inode_ops()
542 static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode) in ufs1_read_inode() argument
544 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs1_read_inode()
545 struct super_block *sb = inode->i_sb; in ufs1_read_inode()
551 inode->i_mode = mode = fs16_to_cpu(sb, ufs_inode->ui_mode); in ufs1_read_inode()
552 set_nlink(inode, fs16_to_cpu(sb, ufs_inode->ui_nlink)); in ufs1_read_inode()
553 if (inode->i_nlink == 0) in ufs1_read_inode()
559 i_uid_write(inode, ufs_get_inode_uid(sb, ufs_inode)); in ufs1_read_inode()
560 i_gid_write(inode, ufs_get_inode_gid(sb, ufs_inode)); in ufs1_read_inode()
562 inode->i_size = fs64_to_cpu(sb, ufs_inode->ui_size); in ufs1_read_inode()
563 inode_set_atime(inode, in ufs1_read_inode()
566 inode_set_ctime(inode, in ufs1_read_inode()
569 inode_set_mtime(inode, in ufs1_read_inode()
572 inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks); in ufs1_read_inode()
573 inode->i_generation = fs32_to_cpu(sb, ufs_inode->ui_gen); in ufs1_read_inode()
579 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { in ufs1_read_inode()
590 static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode) in ufs2_read_inode() argument
592 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs2_read_inode()
593 struct super_block *sb = inode->i_sb; in ufs2_read_inode()
596 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); in ufs2_read_inode()
600 inode->i_mode = mode = fs16_to_cpu(sb, ufs2_inode->ui_mode); in ufs2_read_inode()
601 set_nlink(inode, fs16_to_cpu(sb, ufs2_inode->ui_nlink)); in ufs2_read_inode()
602 if (inode->i_nlink == 0) in ufs2_read_inode()
608 i_uid_write(inode, fs32_to_cpu(sb, ufs2_inode->ui_uid)); in ufs2_read_inode()
609 i_gid_write(inode, fs32_to_cpu(sb, ufs2_inode->ui_gid)); in ufs2_read_inode()
611 inode->i_size = fs64_to_cpu(sb, ufs2_inode->ui_size); in ufs2_read_inode()
612 inode_set_atime(inode, fs64_to_cpu(sb, ufs2_inode->ui_atime), in ufs2_read_inode()
614 inode_set_ctime(inode, fs64_to_cpu(sb, ufs2_inode->ui_ctime), in ufs2_read_inode()
616 inode_set_mtime(inode, fs64_to_cpu(sb, ufs2_inode->ui_mtime), in ufs2_read_inode()
618 inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks); in ufs2_read_inode()
619 inode->i_generation = fs32_to_cpu(sb, ufs2_inode->ui_gen); in ufs2_read_inode()
626 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { in ufs2_read_inode()
637 struct inode *ufs_iget(struct super_block *sb, unsigned long ino) in ufs_iget()
642 struct inode *inode; in ufs_iget() local
653 inode = iget_locked(sb, ino); in ufs_iget()
654 if (!inode) in ufs_iget()
656 if (!(inode->i_state & I_NEW)) in ufs_iget()
657 return inode; in ufs_iget()
659 ufsi = UFS_I(inode); in ufs_iget()
661 bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino)); in ufs_iget()
664 inode->i_ino); in ufs_iget()
670 err = ufs2_read_inode(inode, in ufs_iget()
671 ufs2_inode + ufs_inotofsbo(inode->i_ino)); in ufs_iget()
675 err = ufs1_read_inode(inode, in ufs_iget()
676 ufs_inode + ufs_inotofsbo(inode->i_ino)); in ufs_iget()
682 inode_inc_iversion(inode); in ufs_iget()
684 (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift; in ufs_iget()
688 ufs_set_inode_ops(inode); in ufs_iget()
691 unlock_new_inode(inode); in ufs_iget()
692 return inode; in ufs_iget()
695 iget_failed(inode); in ufs_iget()
699 static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode) in ufs1_update_inode() argument
701 struct super_block *sb = inode->i_sb; in ufs1_update_inode()
702 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs1_update_inode()
704 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); in ufs1_update_inode()
705 ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); in ufs1_update_inode()
707 ufs_set_inode_uid(sb, ufs_inode, i_uid_read(inode)); in ufs1_update_inode()
708 ufs_set_inode_gid(sb, ufs_inode, i_gid_read(inode)); in ufs1_update_inode()
710 ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size); in ufs1_update_inode()
712 inode_get_atime_sec(inode)); in ufs1_update_inode()
715 inode_get_ctime_sec(inode)); in ufs1_update_inode()
718 inode_get_mtime_sec(inode)); in ufs1_update_inode()
720 ufs_inode->ui_blocks = cpu_to_fs32(sb, inode->i_blocks); in ufs1_update_inode()
722 ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation); in ufs1_update_inode()
729 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { in ufs1_update_inode()
732 } else if (inode->i_blocks) { in ufs1_update_inode()
741 if (!inode->i_nlink) in ufs1_update_inode()
745 static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode) in ufs2_update_inode() argument
747 struct super_block *sb = inode->i_sb; in ufs2_update_inode()
748 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs2_update_inode()
751 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); in ufs2_update_inode()
752 ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); in ufs2_update_inode()
754 ufs_inode->ui_uid = cpu_to_fs32(sb, i_uid_read(inode)); in ufs2_update_inode()
755 ufs_inode->ui_gid = cpu_to_fs32(sb, i_gid_read(inode)); in ufs2_update_inode()
757 ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size); in ufs2_update_inode()
758 ufs_inode->ui_atime = cpu_to_fs64(sb, inode_get_atime_sec(inode)); in ufs2_update_inode()
760 inode_get_atime_nsec(inode)); in ufs2_update_inode()
761 ufs_inode->ui_ctime = cpu_to_fs64(sb, inode_get_ctime_sec(inode)); in ufs2_update_inode()
763 inode_get_ctime_nsec(inode)); in ufs2_update_inode()
764 ufs_inode->ui_mtime = cpu_to_fs64(sb, inode_get_mtime_sec(inode)); in ufs2_update_inode()
766 inode_get_mtime_nsec(inode)); in ufs2_update_inode()
768 ufs_inode->ui_blocks = cpu_to_fs64(sb, inode->i_blocks); in ufs2_update_inode()
770 ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation); in ufs2_update_inode()
772 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { in ufs2_update_inode()
775 } else if (inode->i_blocks) { in ufs2_update_inode()
783 if (!inode->i_nlink) in ufs2_update_inode()
788 static int ufs_update_inode(struct inode * inode, int do_sync) in ufs_update_inode() argument
790 struct super_block *sb = inode->i_sb; in ufs_update_inode()
794 UFSD("ENTER, ino %lu\n", inode->i_ino); in ufs_update_inode()
796 if (inode->i_ino < UFS_ROOTINO || in ufs_update_inode()
797 inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) { in ufs_update_inode()
798 ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino); in ufs_update_inode()
802 bh = sb_bread(sb, ufs_inotofsba(inode->i_ino)); in ufs_update_inode()
804 ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino); in ufs_update_inode()
810 ufs2_update_inode(inode, in ufs_update_inode()
811 ufs2_inode + ufs_inotofsbo(inode->i_ino)); in ufs_update_inode()
815 ufs1_update_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino)); in ufs_update_inode()
827 int ufs_write_inode(struct inode *inode, struct writeback_control *wbc) in ufs_write_inode() argument
829 return ufs_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL); in ufs_write_inode()
832 int ufs_sync_inode (struct inode *inode) in ufs_sync_inode() argument
834 return ufs_update_inode (inode, 1); in ufs_sync_inode()
837 void ufs_evict_inode(struct inode * inode) in ufs_evict_inode() argument
841 if (!inode->i_nlink && !is_bad_inode(inode)) in ufs_evict_inode()
844 truncate_inode_pages_final(&inode->i_data); in ufs_evict_inode()
846 inode->i_size = 0; in ufs_evict_inode()
847 if (inode->i_blocks && in ufs_evict_inode()
848 (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || in ufs_evict_inode()
849 S_ISLNK(inode->i_mode))) in ufs_evict_inode()
850 ufs_truncate_blocks(inode); in ufs_evict_inode()
851 ufs_update_inode(inode, inode_needs_sync(inode)); in ufs_evict_inode()
854 invalidate_inode_buffers(inode); in ufs_evict_inode()
855 clear_inode(inode); in ufs_evict_inode()
858 ufs_free_inode(inode); in ufs_evict_inode()
862 struct inode *inode; member
870 ufs_free_blocks(ctx->inode, ctx->to - ctx->count, ctx->count); in free_data()
877 #define DIRECT_FRAGMENT ((inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift)
882 static void ufs_trunc_direct(struct inode *inode) in ufs_trunc_direct() argument
884 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs_trunc_direct()
885 struct super_block *sb = inode->i_sb; in ufs_trunc_direct()
890 struct to_free ctx = {.inode = inode}; in ufs_trunc_direct()
892 UFSD("ENTER: ino %lu\n", inode->i_ino); in ufs_trunc_direct()
917 ufs_free_fragments(inode, tmp + new_tail, old_tail - new_tail); in ufs_trunc_direct()
927 ufs_free_fragments(inode, tmp + new_tail, in ufs_trunc_direct()
953 ufs_free_fragments(inode, tmp, old_tail); in ufs_trunc_direct()
957 UFSD("EXIT: ino %lu\n", inode->i_ino); in ufs_trunc_direct()
960 static void free_full_branch(struct inode *inode, u64 ind_block, int depth) in free_full_branch() argument
962 struct super_block *sb = inode->i_sb; in free_full_branch()
975 free_full_branch(inode, block, depth); in free_full_branch()
978 struct to_free ctx = {.inode = inode}; in free_full_branch()
990 ufs_free_blocks(inode, ind_block, uspi->s_fpb); in free_full_branch()
993 static void free_branch_tail(struct inode *inode, unsigned from, struct ufs_buffer_head *ubh, int d… in free_branch_tail() argument
995 struct super_block *sb = inode->i_sb; in free_branch_tail()
1004 write_seqlock(&UFS_I(inode)->meta_lock); in free_branch_tail()
1006 write_sequnlock(&UFS_I(inode)->meta_lock); in free_branch_tail()
1008 free_full_branch(inode, block, depth); in free_branch_tail()
1012 struct to_free ctx = {.inode = inode}; in free_branch_tail()
1018 write_seqlock(&UFS_I(inode)->meta_lock); in free_branch_tail()
1020 write_sequnlock(&UFS_I(inode)->meta_lock); in free_branch_tail()
1027 if (IS_SYNC(inode) && ubh_buffer_dirty(ubh)) in free_branch_tail()
1032 static int ufs_alloc_lastblock(struct inode *inode, loff_t size) in ufs_alloc_lastblock() argument
1035 struct super_block *sb = inode->i_sb; in ufs_alloc_lastblock()
1036 struct address_space *mapping = inode->i_mapping; in ufs_alloc_lastblock()
1052 (PAGE_SHIFT - inode->i_blkbits)); in ufs_alloc_lastblock()
1058 end = lastfrag & ((1 << (PAGE_SHIFT - inode->i_blkbits)) - 1); in ufs_alloc_lastblock()
1063 err = ufs_getfrag_block(inode, lastfrag, bh, 1); in ufs_alloc_lastblock()
1100 static void ufs_truncate_blocks(struct inode *inode) in ufs_truncate_blocks() argument
1102 struct ufs_inode_info *ufsi = UFS_I(inode); in ufs_truncate_blocks()
1103 struct super_block *sb = inode->i_sb; in ufs_truncate_blocks()
1113 if (inode->i_size) { in ufs_truncate_blocks()
1114 sector_t last = (inode->i_size - 1) >> uspi->s_bshift; in ufs_truncate_blocks()
1115 depth = ufs_block_to_path(inode, last, offsets); in ufs_truncate_blocks()
1128 ufs_trunc_direct(inode); in ufs_truncate_blocks()
1147 free_branch_tail(inode, offsets[i + 1], ubh[i], depth - i - 1); in ufs_truncate_blocks()
1156 free_full_branch(inode, block, i - UFS_IND_BLOCK + 1); in ufs_truncate_blocks()
1162 mark_inode_dirty(inode); in ufs_truncate_blocks()
1166 static int ufs_truncate(struct inode *inode, loff_t size) in ufs_truncate() argument
1171 inode->i_ino, (unsigned long long)size, in ufs_truncate()
1172 (unsigned long long)i_size_read(inode)); in ufs_truncate()
1174 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || in ufs_truncate()
1175 S_ISLNK(inode->i_mode))) in ufs_truncate()
1177 if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) in ufs_truncate()
1180 err = ufs_alloc_lastblock(inode, size); in ufs_truncate()
1185 block_truncate_page(inode->i_mapping, size, ufs_getfrag_block); in ufs_truncate()
1187 truncate_setsize(inode, size); in ufs_truncate()
1189 ufs_truncate_blocks(inode); in ufs_truncate()
1190 inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); in ufs_truncate()
1191 mark_inode_dirty(inode); in ufs_truncate()
1200 struct inode *inode = d_inode(dentry); in ufs_setattr() local
1208 if (ia_valid & ATTR_SIZE && attr->ia_size != inode->i_size) { in ufs_setattr()
1209 error = ufs_truncate(inode, attr->ia_size); in ufs_setattr()
1214 setattr_copy(&nop_mnt_idmap, inode, attr); in ufs_setattr()
1215 mark_inode_dirty(inode); in ufs_setattr()