Lines Matching refs:inode
21 void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync) in f2fs_mark_inode_dirty_sync() argument
23 if (is_inode_flag_set(inode, FI_NEW_INODE)) in f2fs_mark_inode_dirty_sync()
26 if (f2fs_inode_dirtied(inode, sync)) in f2fs_mark_inode_dirty_sync()
29 mark_inode_dirty_sync(inode); in f2fs_mark_inode_dirty_sync()
32 void f2fs_set_inode_flags(struct inode *inode) in f2fs_set_inode_flags() argument
34 unsigned int flags = F2FS_I(inode)->i_flags; in f2fs_set_inode_flags()
47 if (file_is_encrypt(inode)) in f2fs_set_inode_flags()
49 if (file_is_verity(inode)) in f2fs_set_inode_flags()
53 inode_set_flags(inode, new_fl, in f2fs_set_inode_flags()
58 static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri) in __get_inode_rdev() argument
60 int extra_size = get_extra_isize(inode); in __get_inode_rdev()
62 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || in __get_inode_rdev()
63 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { in __get_inode_rdev()
65 inode->i_rdev = old_decode_dev( in __get_inode_rdev()
68 inode->i_rdev = new_decode_dev( in __get_inode_rdev()
85 static void __set_inode_rdev(struct inode *inode, struct f2fs_inode *ri) in __set_inode_rdev() argument
87 int extra_size = get_extra_isize(inode); in __set_inode_rdev()
89 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { in __set_inode_rdev()
90 if (old_valid_dev(inode->i_rdev)) { in __set_inode_rdev()
92 cpu_to_le32(old_encode_dev(inode->i_rdev)); in __set_inode_rdev()
97 cpu_to_le32(new_encode_dev(inode->i_rdev)); in __set_inode_rdev()
103 static void __recover_inline_status(struct inode *inode, struct page *ipage) in __recover_inline_status() argument
105 void *inline_data = inline_data_addr(inode, ipage); in __recover_inline_status()
107 __le32 *end = start + MAX_INLINE_DATA(inode) / sizeof(__le32); in __recover_inline_status()
113 set_inode_flag(inode, FI_DATA_EXIST); in __recover_inline_status()
114 set_raw_inline(inode, F2FS_INODE(ipage)); in __recover_inline_status()
199 static bool sanity_check_inode(struct inode *inode, struct page *node_page) in sanity_check_inode() argument
201 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in sanity_check_inode()
202 struct f2fs_inode_info *fi = F2FS_I(inode); in sanity_check_inode()
210 __func__, inode->i_ino, iblocks); in sanity_check_inode()
217 __func__, inode->i_ino, in sanity_check_inode()
223 && !f2fs_has_extra_attr(inode)) { in sanity_check_inode()
226 __func__, inode->i_ino); in sanity_check_inode()
230 if (f2fs_has_extra_attr(inode) && in sanity_check_inode()
234 __func__, inode->i_ino); in sanity_check_inode()
242 __func__, inode->i_ino, fi->i_extra_isize, in sanity_check_inode()
247 if (f2fs_has_extra_attr(inode) && in sanity_check_inode()
249 f2fs_has_inline_xattr(inode) && in sanity_check_inode()
254 __func__, inode->i_ino, fi->i_inline_xattr_size, in sanity_check_inode()
259 if (F2FS_I(inode)->extent_tree) { in sanity_check_inode()
260 struct extent_info *ei = &F2FS_I(inode)->extent_tree->largest; in sanity_check_inode()
269 __func__, inode->i_ino, in sanity_check_inode()
275 if (f2fs_sanity_check_inline_data(inode)) { in sanity_check_inode()
278 __func__, inode->i_ino, inode->i_mode); in sanity_check_inode()
282 if (f2fs_has_inline_dentry(inode) && !S_ISDIR(inode->i_mode)) { in sanity_check_inode()
285 __func__, inode->i_ino, inode->i_mode); in sanity_check_inode()
292 __func__, inode->i_ino); in sanity_check_inode()
296 if (f2fs_has_extra_attr(inode) && f2fs_sb_has_compression(sbi) && in sanity_check_inode()
304 __func__, inode->i_ino, in sanity_check_inode()
309 SECTOR_TO_BLOCK(inode->i_blocks)) { in sanity_check_inode()
313 __func__, inode->i_ino, in sanity_check_inode()
315 SECTOR_TO_BLOCK(inode->i_blocks)); in sanity_check_inode()
323 __func__, inode->i_ino, in sanity_check_inode()
332 static int do_read_inode(struct inode *inode) in do_read_inode() argument
334 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in do_read_inode()
335 struct f2fs_inode_info *fi = F2FS_I(inode); in do_read_inode()
342 if (f2fs_check_nid_range(sbi, inode->i_ino)) in do_read_inode()
345 node_page = f2fs_get_node_page(sbi, inode->i_ino); in do_read_inode()
351 inode->i_mode = le16_to_cpu(ri->i_mode); in do_read_inode()
352 i_uid_write(inode, le32_to_cpu(ri->i_uid)); in do_read_inode()
353 i_gid_write(inode, le32_to_cpu(ri->i_gid)); in do_read_inode()
354 set_nlink(inode, le32_to_cpu(ri->i_links)); in do_read_inode()
355 inode->i_size = le64_to_cpu(ri->i_size); in do_read_inode()
356 inode->i_blocks = SECTOR_FROM_BLOCK(le64_to_cpu(ri->i_blocks) - 1); in do_read_inode()
358 inode->i_atime.tv_sec = le64_to_cpu(ri->i_atime); in do_read_inode()
359 inode->i_ctime.tv_sec = le64_to_cpu(ri->i_ctime); in do_read_inode()
360 inode->i_mtime.tv_sec = le64_to_cpu(ri->i_mtime); in do_read_inode()
361 inode->i_atime.tv_nsec = le32_to_cpu(ri->i_atime_nsec); in do_read_inode()
362 inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec); in do_read_inode()
363 inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec); in do_read_inode()
364 inode->i_generation = le32_to_cpu(ri->i_generation); in do_read_inode()
365 if (S_ISDIR(inode->i_mode)) in do_read_inode()
367 else if (S_ISREG(inode->i_mode)) in do_read_inode()
372 if (S_ISREG(inode->i_mode)) in do_read_inode()
379 f2fs_init_extent_tree(inode, node_page); in do_read_inode()
381 get_inline_info(inode, ri); in do_read_inode()
383 fi->i_extra_isize = f2fs_has_extra_attr(inode) ? in do_read_inode()
388 } else if (f2fs_has_inline_xattr(inode) || in do_read_inode()
389 f2fs_has_inline_dentry(inode)) { in do_read_inode()
402 if (!sanity_check_inode(inode, node_page)) { in do_read_inode()
408 if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode)) in do_read_inode()
409 __recover_inline_status(inode, node_page); in do_read_inode()
412 if (!S_ISDIR(inode->i_mode) && !is_cold_node(node_page)) { in do_read_inode()
419 __get_inode_rdev(inode, ri); in do_read_inode()
421 if (S_ISREG(inode->i_mode)) { in do_read_inode()
428 set_inode_flag(inode, FI_FIRST_BLOCK_WRITTEN); in do_read_inode()
431 if (!f2fs_need_inode_block_update(sbi, inode->i_ino)) in do_read_inode()
432 fi->last_disk_size = inode->i_size; in do_read_inode()
435 set_inode_flag(inode, FI_PROJ_INHERIT); in do_read_inode()
437 if (f2fs_has_extra_attr(inode) && f2fs_sb_has_project_quota(sbi) && in do_read_inode()
444 if (f2fs_has_extra_attr(inode) && f2fs_sb_has_inode_crtime(sbi) && in do_read_inode()
450 if (f2fs_has_extra_attr(inode) && f2fs_sb_has_compression(sbi) && in do_read_inode()
459 set_inode_flag(inode, FI_COMPRESSED_FILE); in do_read_inode()
463 F2FS_I(inode)->i_disk_time[0] = inode->i_atime; in do_read_inode()
464 F2FS_I(inode)->i_disk_time[1] = inode->i_ctime; in do_read_inode()
465 F2FS_I(inode)->i_disk_time[2] = inode->i_mtime; in do_read_inode()
466 F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime; in do_read_inode()
469 stat_inc_inline_xattr(inode); in do_read_inode()
470 stat_inc_inline_inode(inode); in do_read_inode()
471 stat_inc_inline_dir(inode); in do_read_inode()
472 stat_inc_compr_inode(inode); in do_read_inode()
473 stat_add_compr_blocks(inode, atomic_read(&fi->i_compr_blocks)); in do_read_inode()
478 struct inode *f2fs_iget(struct super_block *sb, unsigned long ino) in f2fs_iget()
481 struct inode *inode; in f2fs_iget() local
484 inode = iget_locked(sb, ino); in f2fs_iget()
485 if (!inode) in f2fs_iget()
488 if (!(inode->i_state & I_NEW)) { in f2fs_iget()
489 trace_f2fs_iget(inode); in f2fs_iget()
490 return inode; in f2fs_iget()
495 ret = do_read_inode(inode); in f2fs_iget()
500 inode->i_mapping->a_ops = &f2fs_node_aops; in f2fs_iget()
501 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); in f2fs_iget()
503 inode->i_mapping->a_ops = &f2fs_meta_aops; in f2fs_iget()
504 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); in f2fs_iget()
505 } else if (S_ISREG(inode->i_mode)) { in f2fs_iget()
506 inode->i_op = &f2fs_file_inode_operations; in f2fs_iget()
507 inode->i_fop = &f2fs_file_operations; in f2fs_iget()
508 inode->i_mapping->a_ops = &f2fs_dblock_aops; in f2fs_iget()
509 } else if (S_ISDIR(inode->i_mode)) { in f2fs_iget()
510 inode->i_op = &f2fs_dir_inode_operations; in f2fs_iget()
511 inode->i_fop = &f2fs_dir_operations; in f2fs_iget()
512 inode->i_mapping->a_ops = &f2fs_dblock_aops; in f2fs_iget()
513 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); in f2fs_iget()
514 } else if (S_ISLNK(inode->i_mode)) { in f2fs_iget()
515 if (file_is_encrypt(inode)) in f2fs_iget()
516 inode->i_op = &f2fs_encrypted_symlink_inode_operations; in f2fs_iget()
518 inode->i_op = &f2fs_symlink_inode_operations; in f2fs_iget()
519 inode_nohighmem(inode); in f2fs_iget()
520 inode->i_mapping->a_ops = &f2fs_dblock_aops; in f2fs_iget()
521 } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || in f2fs_iget()
522 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { in f2fs_iget()
523 inode->i_op = &f2fs_special_inode_operations; in f2fs_iget()
524 init_special_inode(inode, inode->i_mode, inode->i_rdev); in f2fs_iget()
529 f2fs_set_inode_flags(inode); in f2fs_iget()
530 unlock_new_inode(inode); in f2fs_iget()
531 trace_f2fs_iget(inode); in f2fs_iget()
532 return inode; in f2fs_iget()
535 f2fs_inode_synced(inode); in f2fs_iget()
536 iget_failed(inode); in f2fs_iget()
537 trace_f2fs_iget_exit(inode, ret); in f2fs_iget()
541 struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino) in f2fs_iget_retry()
543 struct inode *inode; in f2fs_iget_retry() local
545 inode = f2fs_iget(sb, ino); in f2fs_iget_retry()
546 if (IS_ERR(inode)) { in f2fs_iget_retry()
547 if (PTR_ERR(inode) == -ENOMEM) { in f2fs_iget_retry()
552 return inode; in f2fs_iget_retry()
555 void f2fs_update_inode(struct inode *inode, struct page *node_page) in f2fs_update_inode() argument
558 struct extent_tree *et = F2FS_I(inode)->extent_tree; in f2fs_update_inode()
563 f2fs_inode_synced(inode); in f2fs_update_inode()
567 ri->i_mode = cpu_to_le16(inode->i_mode); in f2fs_update_inode()
568 ri->i_advise = F2FS_I(inode)->i_advise; in f2fs_update_inode()
569 ri->i_uid = cpu_to_le32(i_uid_read(inode)); in f2fs_update_inode()
570 ri->i_gid = cpu_to_le32(i_gid_read(inode)); in f2fs_update_inode()
571 ri->i_links = cpu_to_le32(inode->i_nlink); in f2fs_update_inode()
572 ri->i_size = cpu_to_le64(i_size_read(inode)); in f2fs_update_inode()
573 ri->i_blocks = cpu_to_le64(SECTOR_TO_BLOCK(inode->i_blocks) + 1); in f2fs_update_inode()
582 set_raw_inline(inode, ri); in f2fs_update_inode()
584 ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec); in f2fs_update_inode()
585 ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); in f2fs_update_inode()
586 ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec); in f2fs_update_inode()
587 ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec); in f2fs_update_inode()
588 ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); in f2fs_update_inode()
589 ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); in f2fs_update_inode()
590 if (S_ISDIR(inode->i_mode)) in f2fs_update_inode()
592 cpu_to_le32(F2FS_I(inode)->i_current_depth); in f2fs_update_inode()
593 else if (S_ISREG(inode->i_mode)) in f2fs_update_inode()
595 cpu_to_le16(F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN]); in f2fs_update_inode()
596 ri->i_xattr_nid = cpu_to_le32(F2FS_I(inode)->i_xattr_nid); in f2fs_update_inode()
597 ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags); in f2fs_update_inode()
598 ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino); in f2fs_update_inode()
599 ri->i_generation = cpu_to_le32(inode->i_generation); in f2fs_update_inode()
600 ri->i_dir_level = F2FS_I(inode)->i_dir_level; in f2fs_update_inode()
602 if (f2fs_has_extra_attr(inode)) { in f2fs_update_inode()
603 ri->i_extra_isize = cpu_to_le16(F2FS_I(inode)->i_extra_isize); in f2fs_update_inode()
605 if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode))) in f2fs_update_inode()
607 cpu_to_le16(F2FS_I(inode)->i_inline_xattr_size); in f2fs_update_inode()
609 if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)) && in f2fs_update_inode()
610 F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, in f2fs_update_inode()
615 F2FS_I(inode)->i_projid); in f2fs_update_inode()
619 if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) && in f2fs_update_inode()
620 F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, in f2fs_update_inode()
623 cpu_to_le64(F2FS_I(inode)->i_crtime.tv_sec); in f2fs_update_inode()
625 cpu_to_le32(F2FS_I(inode)->i_crtime.tv_nsec); in f2fs_update_inode()
628 if (f2fs_sb_has_compression(F2FS_I_SB(inode)) && in f2fs_update_inode()
629 F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, in f2fs_update_inode()
633 &F2FS_I(inode)->i_compr_blocks)); in f2fs_update_inode()
635 F2FS_I(inode)->i_compress_algorithm; in f2fs_update_inode()
637 F2FS_I(inode)->i_log_cluster_size; in f2fs_update_inode()
641 __set_inode_rdev(inode, ri); in f2fs_update_inode()
644 if (inode->i_nlink == 0) in f2fs_update_inode()
647 F2FS_I(inode)->i_disk_time[0] = inode->i_atime; in f2fs_update_inode()
648 F2FS_I(inode)->i_disk_time[1] = inode->i_ctime; in f2fs_update_inode()
649 F2FS_I(inode)->i_disk_time[2] = inode->i_mtime; in f2fs_update_inode()
650 F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime; in f2fs_update_inode()
653 f2fs_inode_chksum_set(F2FS_I_SB(inode), node_page); in f2fs_update_inode()
657 void f2fs_update_inode_page(struct inode *inode) in f2fs_update_inode_page() argument
659 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_update_inode_page()
662 node_page = f2fs_get_node_page(sbi, inode->i_ino); in f2fs_update_inode_page()
673 f2fs_update_inode(inode, node_page); in f2fs_update_inode_page()
677 int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) in f2fs_write_inode() argument
679 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_write_inode()
681 if (inode->i_ino == F2FS_NODE_INO(sbi) || in f2fs_write_inode()
682 inode->i_ino == F2FS_META_INO(sbi)) in f2fs_write_inode()
688 if (f2fs_is_time_consistent(inode) && in f2fs_write_inode()
689 !is_inode_flag_set(inode, FI_DIRTY_INODE)) in f2fs_write_inode()
699 f2fs_update_inode_page(inode); in f2fs_write_inode()
708 void f2fs_evict_inode(struct inode *inode) in f2fs_evict_inode() argument
710 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_evict_inode()
711 nid_t xnid = F2FS_I(inode)->i_xattr_nid; in f2fs_evict_inode()
715 if (f2fs_is_atomic_file(inode)) in f2fs_evict_inode()
716 f2fs_drop_inmem_pages(inode); in f2fs_evict_inode()
718 trace_f2fs_evict_inode(inode); in f2fs_evict_inode()
719 truncate_inode_pages_final(&inode->i_data); in f2fs_evict_inode()
721 if (inode->i_ino == F2FS_NODE_INO(sbi) || in f2fs_evict_inode()
722 inode->i_ino == F2FS_META_INO(sbi)) in f2fs_evict_inode()
725 f2fs_bug_on(sbi, get_dirty_pages(inode)); in f2fs_evict_inode()
726 f2fs_remove_dirty_inode(inode); in f2fs_evict_inode()
728 f2fs_destroy_extent_tree(inode); in f2fs_evict_inode()
730 if (inode->i_nlink || is_bad_inode(inode)) in f2fs_evict_inode()
733 err = dquot_initialize(inode); in f2fs_evict_inode()
739 f2fs_remove_ino_entry(sbi, inode->i_ino, APPEND_INO); in f2fs_evict_inode()
740 f2fs_remove_ino_entry(sbi, inode->i_ino, UPDATE_INO); in f2fs_evict_inode()
741 f2fs_remove_ino_entry(sbi, inode->i_ino, FLUSH_INO); in f2fs_evict_inode()
743 sb_start_intwrite(inode->i_sb); in f2fs_evict_inode()
744 set_inode_flag(inode, FI_NO_ALLOC); in f2fs_evict_inode()
745 i_size_write(inode, 0); in f2fs_evict_inode()
747 if (F2FS_HAS_BLOCKS(inode)) in f2fs_evict_inode()
748 err = f2fs_truncate(inode); in f2fs_evict_inode()
757 err = f2fs_remove_inode_page(inode); in f2fs_evict_inode()
767 if (is_inode_flag_set(inode, FI_DIRTY_INODE)) { in f2fs_evict_inode()
768 f2fs_warn(F2FS_I_SB(inode), in f2fs_evict_inode()
770 inode->i_ino); in f2fs_evict_inode()
771 f2fs_inode_synced(inode); in f2fs_evict_inode()
784 f2fs_update_inode_page(inode); in f2fs_evict_inode()
785 if (dquot_initialize_needed(inode)) in f2fs_evict_inode()
788 sb_end_intwrite(inode->i_sb); in f2fs_evict_inode()
790 dquot_drop(inode); in f2fs_evict_inode()
792 stat_dec_inline_xattr(inode); in f2fs_evict_inode()
793 stat_dec_inline_dir(inode); in f2fs_evict_inode()
794 stat_dec_inline_inode(inode); in f2fs_evict_inode()
795 stat_dec_compr_inode(inode); in f2fs_evict_inode()
796 stat_sub_compr_blocks(inode, in f2fs_evict_inode()
797 atomic_read(&F2FS_I(inode)->i_compr_blocks)); in f2fs_evict_inode()
801 f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE)); in f2fs_evict_inode()
803 f2fs_inode_synced(inode); in f2fs_evict_inode()
806 if (inode->i_ino) in f2fs_evict_inode()
807 invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino, in f2fs_evict_inode()
808 inode->i_ino); in f2fs_evict_inode()
811 if (inode->i_nlink) { in f2fs_evict_inode()
812 if (is_inode_flag_set(inode, FI_APPEND_WRITE)) in f2fs_evict_inode()
813 f2fs_add_ino_entry(sbi, inode->i_ino, APPEND_INO); in f2fs_evict_inode()
814 if (is_inode_flag_set(inode, FI_UPDATE_WRITE)) in f2fs_evict_inode()
815 f2fs_add_ino_entry(sbi, inode->i_ino, UPDATE_INO); in f2fs_evict_inode()
817 if (is_inode_flag_set(inode, FI_FREE_NID)) { in f2fs_evict_inode()
818 f2fs_alloc_nid_failed(sbi, inode->i_ino); in f2fs_evict_inode()
819 clear_inode_flag(inode, FI_FREE_NID); in f2fs_evict_inode()
828 fscrypt_put_encryption_info(inode); in f2fs_evict_inode()
829 fsverity_cleanup_inode(inode); in f2fs_evict_inode()
830 clear_inode(inode); in f2fs_evict_inode()
834 void f2fs_handle_failed_inode(struct inode *inode) in f2fs_handle_failed_inode() argument
836 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); in f2fs_handle_failed_inode()
844 clear_nlink(inode); in f2fs_handle_failed_inode()
850 f2fs_update_inode_page(inode); in f2fs_handle_failed_inode()
851 f2fs_inode_synced(inode); in f2fs_handle_failed_inode()
854 unlock_new_inode(inode); in f2fs_handle_failed_inode()
861 err = f2fs_get_node_info(sbi, inode->i_ino, &ni); in f2fs_handle_failed_inode()
864 set_inode_flag(inode, FI_FREE_NID); in f2fs_handle_failed_inode()
875 f2fs_add_orphan_inode(inode); in f2fs_handle_failed_inode()
877 f2fs_alloc_nid_done(sbi, inode->i_ino); in f2fs_handle_failed_inode()
879 set_inode_flag(inode, FI_FREE_NID); in f2fs_handle_failed_inode()
886 iput(inode); in f2fs_handle_failed_inode()