super.c (a0acdfe05a954363861a65eb537573ab417cb7ed) super.c (6bacf52fb58aeb3e89d9a62970b85a5570aa8ace)
1/*
2 * fs/f2fs/super.c
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

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

621};
622
623static struct inode *f2fs_nfs_get_inode(struct super_block *sb,
624 u64 ino, u32 generation)
625{
626 struct f2fs_sb_info *sbi = F2FS_SB(sb);
627 struct inode *inode;
628
1/*
2 * fs/f2fs/super.c
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

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

621};
622
623static struct inode *f2fs_nfs_get_inode(struct super_block *sb,
624 u64 ino, u32 generation)
625{
626 struct f2fs_sb_info *sbi = F2FS_SB(sb);
627 struct inode *inode;
628
629 if (ino < F2FS_ROOT_INO(sbi))
629 if (unlikely(ino < F2FS_ROOT_INO(sbi)))
630 return ERR_PTR(-ESTALE);
631
632 /*
633 * f2fs_iget isn't quite right if the inode is currently unallocated!
634 * However f2fs_iget currently does appropriate checks to handle stale
635 * inodes so everything is OK.
636 */
637 inode = f2fs_iget(sb, ino);
638 if (IS_ERR(inode))
639 return ERR_CAST(inode);
630 return ERR_PTR(-ESTALE);
631
632 /*
633 * f2fs_iget isn't quite right if the inode is currently unallocated!
634 * However f2fs_iget currently does appropriate checks to handle stale
635 * inodes so everything is OK.
636 */
637 inode = f2fs_iget(sb, ino);
638 if (IS_ERR(inode))
639 return ERR_CAST(inode);
640 if (generation && inode->i_generation != generation) {
640 if (unlikely(generation && inode->i_generation != generation)) {
641 /* we didn't find the right inode.. */
642 iput(inode);
643 return ERR_PTR(-ESTALE);
644 }
645 return inode;
646}
647
648static struct dentry *f2fs_fh_to_dentry(struct super_block *sb, struct fid *fid,

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

735
736 total = le32_to_cpu(raw_super->segment_count);
737 fsmeta = le32_to_cpu(raw_super->segment_count_ckpt);
738 fsmeta += le32_to_cpu(raw_super->segment_count_sit);
739 fsmeta += le32_to_cpu(raw_super->segment_count_nat);
740 fsmeta += le32_to_cpu(ckpt->rsvd_segment_count);
741 fsmeta += le32_to_cpu(raw_super->segment_count_ssa);
742
641 /* we didn't find the right inode.. */
642 iput(inode);
643 return ERR_PTR(-ESTALE);
644 }
645 return inode;
646}
647
648static struct dentry *f2fs_fh_to_dentry(struct super_block *sb, struct fid *fid,

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

735
736 total = le32_to_cpu(raw_super->segment_count);
737 fsmeta = le32_to_cpu(raw_super->segment_count_ckpt);
738 fsmeta += le32_to_cpu(raw_super->segment_count_sit);
739 fsmeta += le32_to_cpu(raw_super->segment_count_nat);
740 fsmeta += le32_to_cpu(ckpt->rsvd_segment_count);
741 fsmeta += le32_to_cpu(raw_super->segment_count_ssa);
742
743 if (fsmeta >= total)
743 if (unlikely(fsmeta >= total))
744 return 1;
745
744 return 1;
745
746 if (is_set_ckpt_flags(ckpt, CP_ERROR_FLAG)) {
746 if (unlikely(is_set_ckpt_flags(ckpt, CP_ERROR_FLAG))) {
747 f2fs_msg(sbi->sb, KERN_ERR, "A bug case: need to run fsck");
748 return 1;
749 }
750 return 0;
751}
752
753static void init_sb_info(struct f2fs_sb_info *sbi)
754{

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

803 *raw_super = (struct f2fs_super_block *)
804 ((char *)(*raw_super_buf)->b_data + F2FS_SUPER_OFFSET);
805
806 /* sanity checking of raw super */
807 if (sanity_check_raw_super(sb, *raw_super)) {
808 brelse(*raw_super_buf);
809 f2fs_msg(sb, KERN_ERR, "Can't find a valid F2FS filesystem "
810 "in %dth superblock", block + 1);
747 f2fs_msg(sbi->sb, KERN_ERR, "A bug case: need to run fsck");
748 return 1;
749 }
750 return 0;
751}
752
753static void init_sb_info(struct f2fs_sb_info *sbi)
754{

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

803 *raw_super = (struct f2fs_super_block *)
804 ((char *)(*raw_super_buf)->b_data + F2FS_SUPER_OFFSET);
805
806 /* sanity checking of raw super */
807 if (sanity_check_raw_super(sb, *raw_super)) {
808 brelse(*raw_super_buf);
809 f2fs_msg(sb, KERN_ERR, "Can't find a valid F2FS filesystem "
810 "in %dth superblock", block + 1);
811 if(block == 0) {
811 if (block == 0) {
812 block++;
813 goto retry;
814 } else {
815 return -EINVAL;
816 }
817 }
818
819 return 0;

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

829 int i;
830
831 /* allocate memory for f2fs-specific super block info */
832 sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
833 if (!sbi)
834 return -ENOMEM;
835
836 /* set a block size */
812 block++;
813 goto retry;
814 } else {
815 return -EINVAL;
816 }
817 }
818
819 return 0;

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

829 int i;
830
831 /* allocate memory for f2fs-specific super block info */
832 sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
833 if (!sbi)
834 return -ENOMEM;
835
836 /* set a block size */
837 if (!sb_set_blocksize(sb, F2FS_BLKSIZE)) {
837 if (unlikely(!sb_set_blocksize(sb, F2FS_BLKSIZE))) {
838 f2fs_msg(sb, KERN_ERR, "unable to set blocksize");
839 goto free_sbi;
840 }
841
842 err = read_raw_super_block(sb, &raw_super, &raw_super_buf);
843 if (err)
844 goto free_sbi;
845

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

1061 .fs_flags = FS_REQUIRES_DEV,
1062};
1063MODULE_ALIAS_FS("f2fs");
1064
1065static int __init init_inodecache(void)
1066{
1067 f2fs_inode_cachep = f2fs_kmem_cache_create("f2fs_inode_cache",
1068 sizeof(struct f2fs_inode_info), NULL);
838 f2fs_msg(sb, KERN_ERR, "unable to set blocksize");
839 goto free_sbi;
840 }
841
842 err = read_raw_super_block(sb, &raw_super, &raw_super_buf);
843 if (err)
844 goto free_sbi;
845

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

1061 .fs_flags = FS_REQUIRES_DEV,
1062};
1063MODULE_ALIAS_FS("f2fs");
1064
1065static int __init init_inodecache(void)
1066{
1067 f2fs_inode_cachep = f2fs_kmem_cache_create("f2fs_inode_cache",
1068 sizeof(struct f2fs_inode_info), NULL);
1069 if (f2fs_inode_cachep == NULL)
1069 if (!f2fs_inode_cachep)
1070 return -ENOMEM;
1071 return 0;
1072}
1073
1074static void destroy_inodecache(void)
1075{
1076 /*
1077 * Make sure all delayed rcu free inodes are flushed before we

--- 71 unchanged lines hidden ---
1070 return -ENOMEM;
1071 return 0;
1072}
1073
1074static void destroy_inodecache(void)
1075{
1076 /*
1077 * Make sure all delayed rcu free inodes are flushed before we

--- 71 unchanged lines hidden ---