int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno) { struct the_nilfs *nilfs = sbi->s_nilfs; struct nilfs_checkpoint *raw_cp; struct buffer_head *bh_cp; int err; down_write(&nilfs->ns_sem); list_add(&sbi->s_list, &nilfs->ns_supers); up_write(&nilfs->ns_sem); sbi->s_ifile = nilfs_mdt_new( nilfs, sbi->s_super, NILFS_IFILE_INO, NILFS_IFILE_GFP); if (!sbi->s_ifile) return -ENOMEM; err = nilfs_palloc_init_blockgroup(sbi->s_ifile, nilfs->ns_inode_size); if (unlikely(err)) goto failed; err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp, &bh_cp); if (unlikely(err)) { if (err == -ENOENT || err == -EINVAL) { printk(KERN_ERR "NILFS: Invalid checkpoint " "(checkpoint number=%llu)\n", (unsigned long long)cno); err = -EINVAL; } goto failed; } err = nilfs_read_inode_common(sbi->s_ifile, &raw_cp->cp_ifile_inode); if (unlikely(err)) goto failed_bh; atomic_set(&sbi->s_inodes_count, le64_to_cpu(raw_cp->cp_inodes_count)); atomic_set(&sbi->s_blocks_count, le64_to_cpu(raw_cp->cp_blocks_count)); nilfs_debug(2, "attached ifile (checkpoint number=%llu)\n", (unsigned long long)cno); nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp); return 0; failed_bh: nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp); failed: nilfs_debug(1, "failed to attach ifile " "(checkpoint number=%llu, err=%d)\n", (unsigned long long)cno, err); nilfs_mdt_destroy(sbi->s_ifile); sbi->s_ifile = NULL; down_write(&nilfs->ns_sem); list_del_init(&sbi->s_list); up_write(&nilfs->ns_sem); return err; }
struct inode *nilfs_cpfile_new(struct the_nilfs *nilfs, size_t cpsize) { struct inode *cpfile; cpfile = nilfs_mdt_new(nilfs, NULL, NILFS_CPFILE_INO, 0); if (cpfile) nilfs_mdt_set_entry_size(cpfile, cpsize, sizeof(struct nilfs_cpfile_header)); return cpfile; }
struct inode *nilfs_sufile_new(struct the_nilfs *nilfs, size_t susize) { struct inode *sufile; sufile = nilfs_mdt_new(nilfs, NULL, NILFS_SUFILE_INO, sizeof(struct nilfs_sufile_info)); if (sufile) nilfs_mdt_set_entry_size(sufile, susize, sizeof(struct nilfs_sufile_header)); return sufile; }