]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/nilfs2/inode.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[net-next-2.6.git] / fs / nilfs2 / inode.c
index 7e883d5a50337530489ab1e14de818ee61582572..71d4bc8464e09b793b6c4eb23b97ff09ee093002 100644 (file)
@@ -306,7 +306,7 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
                goto failed_ifile_create_inode;
        /* reference count of i_bh inherits from nilfs_mdt_read_block() */
 
-       atomic_inc(&sbi->s_inodes_count);
+       atomic_inc(&root->inodes_count);
        inode_init_owner(inode, dir, mode);
        inode->i_ino = ino;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
@@ -506,16 +506,33 @@ static int nilfs_iget_set(struct inode *inode, void *opaque)
        return 0;
 }
 
-struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,
-                        unsigned long ino)
+struct inode *nilfs_ilookup(struct super_block *sb, struct nilfs_root *root,
+                           unsigned long ino)
+{
+       struct nilfs_iget_args args = {
+               .ino = ino, .root = root, .cno = 0, .for_gc = 0
+       };
+
+       return ilookup5(sb, ino, nilfs_iget_test, &args);
+}
+
+struct inode *nilfs_iget_locked(struct super_block *sb, struct nilfs_root *root,
+                               unsigned long ino)
 {
        struct nilfs_iget_args args = {
                .ino = ino, .root = root, .cno = 0, .for_gc = 0
        };
+
+       return iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args);
+}
+
+struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,
+                        unsigned long ino)
+{
        struct inode *inode;
        int err;
 
-       inode = iget5_locked(sb, ino, nilfs_iget_test, nilfs_iget_set, &args);
+       inode = nilfs_iget_locked(sb, root, ino);
        if (unlikely(!inode))
                return ERR_PTR(-ENOMEM);
        if (!(inode->i_state & I_NEW))
@@ -674,6 +691,7 @@ void nilfs_truncate(struct inode *inode)
 static void nilfs_clear_inode(struct inode *inode)
 {
        struct nilfs_inode_info *ii = NILFS_I(inode);
+       struct nilfs_mdt_info *mdi = NILFS_MDT(inode);
 
        /*
         * Free resources allocated in nilfs_read_inode(), here.
@@ -682,6 +700,9 @@ static void nilfs_clear_inode(struct inode *inode)
        brelse(ii->i_bh);
        ii->i_bh = NULL;
 
+       if (mdi && mdi->mi_palloc_cache)
+               nilfs_palloc_destroy_cache(inode);
+
        if (test_bit(NILFS_I_BMAP, &ii->i_state))
                nilfs_bmap_clear(ii->i_bmap);
 
@@ -715,7 +736,7 @@ void nilfs_evict_inode(struct inode *inode)
        end_writeback(inode);
 
        nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino);
-       atomic_dec(&NILFS_SB(sb)->s_inodes_count);
+       atomic_dec(&ii->i_root->inodes_count);
 
        nilfs_clear_inode(inode);
 
@@ -764,6 +785,17 @@ out_err:
        return err;
 }
 
+int nilfs_permission(struct inode *inode, int mask)
+{
+       struct nilfs_root *root = NILFS_I(inode)->i_root;
+
+       if ((mask & MAY_WRITE) && root &&
+           root->cno != NILFS_CPTREE_CURRENT_CNO)
+               return -EROFS; /* snapshot is not writable */
+
+       return generic_permission(inode, mask, NULL);
+}
+
 int nilfs_load_inode_block(struct nilfs_sb_info *sbi, struct inode *inode,
                           struct buffer_head **pbh)
 {