]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/ocfs2/namei.c
Merge branch 'discontig-bg' of git://oss.oracle.com/git/tma/linux-2.6 into ocfs2...
[net-next-2.6.git] / fs / ocfs2 / namei.c
index 50fb26a6a5f55f88a93c84e29b9d4386e181cbdb..b0fa6b6507518edbbccb2098fe6e88e93dbb8b0d 100644 (file)
@@ -212,7 +212,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
        } else
                inode->i_gid = current_fsgid();
        inode->i_mode = mode;
-       vfs_dq_init(inode);
+       dquot_initialize(inode);
        return inode;
 }
 
@@ -239,11 +239,15 @@ static int ocfs2_mknod(struct inode *dir,
        };
        int did_quota_inode = 0;
        struct ocfs2_dir_lookup_result lookup = { NULL, };
+       sigset_t oldset;
+       int did_block_signals = 0;
 
        mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
                   (unsigned long)dev, dentry->d_name.len,
                   dentry->d_name.name);
 
+       dquot_initialize(dir);
+
        /* get our super block */
        osb = OCFS2_SB(dir->i_sb);
 
@@ -348,13 +352,13 @@ static int ocfs2_mknod(struct inode *dir,
                goto leave;
        }
 
-       /* We don't use standard VFS wrapper because we don't want vfs_dq_init
-        * to be called. */
-       if (sb_any_quota_active(osb->sb) &&
-           osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
-               status = -EDQUOT;
+       /* Starting to change things, restart is no longer possible. */
+       ocfs2_block_signals(&oldset);
+       did_block_signals = 1;
+
+       status = dquot_alloc_inode(inode);
+       if (status)
                goto leave;
-       }
        did_quota_inode = 1;
 
        mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry,
@@ -386,11 +390,7 @@ static int ocfs2_mknod(struct inode *dir,
                        goto leave;
                }
                ocfs2_add_links_count(dirfe, 1);
-               status = ocfs2_journal_dirty(handle, parent_fe_bh);
-               if (status < 0) {
-                       mlog_errno(status);
-                       goto leave;
-               }
+               ocfs2_journal_dirty(handle, parent_fe_bh);
                inc_nlink(dir);
        }
 
@@ -431,11 +431,13 @@ static int ocfs2_mknod(struct inode *dir,
        status = 0;
 leave:
        if (status < 0 && did_quota_inode)
-               vfs_dq_free_inode(inode);
+               dquot_free_inode(inode);
        if (handle)
                ocfs2_commit_trans(osb, handle);
 
        ocfs2_inode_unlock(dir, 1);
+       if (did_block_signals)
+               ocfs2_unblock_signals(&oldset);
 
        if (status == -ENOSPC)
                mlog(0, "Disk is full\n");
@@ -478,14 +480,15 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
        int status = 0;
        struct ocfs2_dinode *fe = NULL;
        struct ocfs2_extent_list *fel;
-       u64 fe_blkno = 0;
+       u64 suballoc_loc, fe_blkno = 0;
        u16 suballoc_bit;
        u16 feat;
 
        *new_fe_bh = NULL;
 
-       status = ocfs2_claim_new_inode(osb, handle, dir, parent_fe_bh,
-                                      inode_ac, &suballoc_bit, &fe_blkno);
+       status = ocfs2_claim_new_inode(handle, dir, parent_fe_bh,
+                                      inode_ac, &suballoc_loc,
+                                      &suballoc_bit, &fe_blkno);
        if (status < 0) {
                mlog_errno(status);
                goto leave;
@@ -522,6 +525,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
        fe->i_generation = cpu_to_le32(inode->i_generation);
        fe->i_fs_generation = cpu_to_le32(osb->fs_generation);
        fe->i_blkno = cpu_to_le64(fe_blkno);
+       fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
        fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
        fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
        fe->i_uid = cpu_to_le32(inode->i_uid);
@@ -558,11 +562,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
                fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb));
        }
 
-       status = ocfs2_journal_dirty(handle, *new_fe_bh);
-       if (status < 0) {
-               mlog_errno(status);
-               goto leave;
-       }
+       ocfs2_journal_dirty(handle, *new_fe_bh);
 
        ocfs2_populate_inode(inode, fe, 1);
        ocfs2_ci_set_new(osb, INODE_CACHE(inode));
@@ -628,6 +628,7 @@ static int ocfs2_link(struct dentry *old_dentry,
        struct ocfs2_dinode *fe = NULL;
        struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
        struct ocfs2_dir_lookup_result lookup = { NULL, };
+       sigset_t oldset;
 
        mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino,
                   old_dentry->d_name.len, old_dentry->d_name.name,
@@ -636,6 +637,8 @@ static int ocfs2_link(struct dentry *old_dentry,
        if (S_ISDIR(inode->i_mode))
                return -EPERM;
 
+       dquot_initialize(dir);
+
        err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT);
        if (err < 0) {
                if (err != -ENOENT)
@@ -682,6 +685,9 @@ static int ocfs2_link(struct dentry *old_dentry,
                goto out_unlock_inode;
        }
 
+       /* Starting to change things, restart is no longer possible. */
+       ocfs2_block_signals(&oldset);
+
        err = ocfs2_journal_access_di(handle, INODE_CACHE(inode), fe_bh,
                                      OCFS2_JOURNAL_ACCESS_WRITE);
        if (err < 0) {
@@ -694,14 +700,7 @@ static int ocfs2_link(struct dentry *old_dentry,
        ocfs2_set_links_count(fe, inode->i_nlink);
        fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
        fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
-
-       err = ocfs2_journal_dirty(handle, fe_bh);
-       if (err < 0) {
-               ocfs2_add_links_count(fe, -1);
-               drop_nlink(inode);
-               mlog_errno(err);
-               goto out_commit;
-       }
+       ocfs2_journal_dirty(handle, fe_bh);
 
        err = ocfs2_add_entry(handle, dentry, inode,
                              OCFS2_I(inode)->ip_blkno,
@@ -725,6 +724,7 @@ static int ocfs2_link(struct dentry *old_dentry,
 
 out_commit:
        ocfs2_commit_trans(osb, handle);
+       ocfs2_unblock_signals(&oldset);
 out_unlock_inode:
        ocfs2_inode_unlock(inode, 1);
 
@@ -791,6 +791,8 @@ static int ocfs2_unlink(struct inode *dir,
        mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
                   dentry->d_name.len, dentry->d_name.name);
 
+       dquot_initialize(dir);
+
        BUG_ON(dentry->d_parent->d_inode != dir);
 
        mlog(0, "ino = %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -896,12 +898,7 @@ static int ocfs2_unlink(struct inode *dir,
                drop_nlink(inode);
        drop_nlink(inode);
        ocfs2_set_links_count(fe, inode->i_nlink);
-
-       status = ocfs2_journal_dirty(handle, fe_bh);
-       if (status < 0) {
-               mlog_errno(status);
-               goto leave;
-       }
+       ocfs2_journal_dirty(handle, fe_bh);
 
        dir->i_ctime = dir->i_mtime = CURRENT_TIME;
        if (S_ISDIR(inode->i_mode))
@@ -1051,6 +1048,9 @@ static int ocfs2_rename(struct inode *old_dir,
                   old_dentry->d_name.len, old_dentry->d_name.name,
                   new_dentry->d_name.len, new_dentry->d_name.name);
 
+       dquot_initialize(old_dir);
+       dquot_initialize(new_dir);
+
        osb = OCFS2_SB(old_dir->i_sb);
 
        if (new_inode) {
@@ -1316,12 +1316,7 @@ static int ocfs2_rename(struct inode *old_dir,
                        ocfs2_set_links_count(newfe, 0);
                else
                        ocfs2_add_links_count(newfe, -1);
-
-               status = ocfs2_journal_dirty(handle, newfe_bh);
-               if (status < 0) {
-                       mlog_errno(status);
-                       goto bail;
-               }
+               ocfs2_journal_dirty(handle, newfe_bh);
        } else {
                /* if the name was not found in new_dir, add it now */
                status = ocfs2_add_entry(handle, new_dentry, old_inode,
@@ -1340,10 +1335,7 @@ static int ocfs2_rename(struct inode *old_dir,
 
                old_di->i_ctime = cpu_to_le64(old_inode->i_ctime.tv_sec);
                old_di->i_ctime_nsec = cpu_to_le32(old_inode->i_ctime.tv_nsec);
-
-               status = ocfs2_journal_dirty(handle, old_inode_bh);
-               if (status < 0)
-                       mlog_errno(status);
+               ocfs2_journal_dirty(handle, old_inode_bh);
        } else
                mlog_errno(status);
 
@@ -1415,7 +1407,7 @@ static int ocfs2_rename(struct inode *old_dir,
                                                         OCFS2_JOURNAL_ACCESS_WRITE);
                        fe = (struct ocfs2_dinode *) old_dir_bh->b_data;
                        ocfs2_set_links_count(fe, old_dir->i_nlink);
-                       status = ocfs2_journal_dirty(handle, old_dir_bh);
+                       ocfs2_journal_dirty(handle, old_dir_bh);
                }
        }
        ocfs2_dentry_move(old_dentry, new_dentry, old_dir, new_dir);
@@ -1547,11 +1539,7 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
                       (bytes_left > sb->s_blocksize) ? sb->s_blocksize :
                       bytes_left);
 
-               status = ocfs2_journal_dirty(handle, bhs[virtual]);
-               if (status < 0) {
-                       mlog_errno(status);
-                       goto bail;
-               }
+               ocfs2_journal_dirty(handle, bhs[virtual]);
 
                virtual++;
                p_blkno++;
@@ -1595,10 +1583,14 @@ static int ocfs2_symlink(struct inode *dir,
        };
        int did_quota = 0, did_quota_inode = 0;
        struct ocfs2_dir_lookup_result lookup = { NULL, };
+       sigset_t oldset;
+       int did_block_signals = 0;
 
        mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
                   dentry, symname, dentry->d_name.len, dentry->d_name.name);
 
+       dquot_initialize(dir);
+
        sb = dir->i_sb;
        osb = OCFS2_SB(sb);
 
@@ -1688,13 +1680,13 @@ static int ocfs2_symlink(struct inode *dir,
                goto bail;
        }
 
-       /* We don't use standard VFS wrapper because we don't want vfs_dq_init
-        * to be called. */
-       if (sb_any_quota_active(osb->sb) &&
-           osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
-               status = -EDQUOT;
+       /* Starting to change things, restart is no longer possible. */
+       ocfs2_block_signals(&oldset);
+       did_block_signals = 1;
+
+       status = dquot_alloc_inode(inode);
+       if (status)
                goto bail;
-       }
        did_quota_inode = 1;
 
        mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry,
@@ -1716,11 +1708,10 @@ static int ocfs2_symlink(struct inode *dir,
                u32 offset = 0;
 
                inode->i_op = &ocfs2_symlink_inode_operations;
-               if (vfs_dq_alloc_space_nodirty(inode,
-                   ocfs2_clusters_to_bytes(osb->sb, 1))) {
-                       status = -EDQUOT;
+               status = dquot_alloc_space_nodirty(inode,
+                   ocfs2_clusters_to_bytes(osb->sb, 1));
+               if (status)
                        goto bail;
-               }
                did_quota = 1;
                status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0,
                                              new_fe_bh,
@@ -1788,14 +1779,16 @@ static int ocfs2_symlink(struct inode *dir,
        d_instantiate(dentry, inode);
 bail:
        if (status < 0 && did_quota)
-               vfs_dq_free_space_nodirty(inode,
+               dquot_free_space_nodirty(inode,
                                        ocfs2_clusters_to_bytes(osb->sb, 1));
        if (status < 0 && did_quota_inode)
-               vfs_dq_free_inode(inode);
+               dquot_free_inode(inode);
        if (handle)
                ocfs2_commit_trans(osb, handle);
 
        ocfs2_inode_unlock(dir, 1);
+       if (did_block_signals)
+               ocfs2_unblock_signals(&oldset);
 
        brelse(new_fe_bh);
        brelse(parent_fe_bh);
@@ -1941,12 +1934,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
        if (S_ISDIR(inode->i_mode))
                ocfs2_add_links_count(orphan_fe, 1);
        orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe);
-
-       status = ocfs2_journal_dirty(handle, orphan_dir_bh);
-       if (status < 0) {
-               mlog_errno(status);
-               goto leave;
-       }
+       ocfs2_journal_dirty(handle, orphan_dir_bh);
 
        status = __ocfs2_add_entry(handle, orphan_dir_inode, name,
                                   OCFS2_ORPHAN_NAMELEN, inode,
@@ -2027,12 +2015,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
        if (S_ISDIR(inode->i_mode))
                ocfs2_add_links_count(orphan_fe, -1);
        orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe);
-
-       status = ocfs2_journal_dirty(handle, orphan_dir_bh);
-       if (status < 0) {
-               mlog_errno(status);
-               goto leave;
-       }
+       ocfs2_journal_dirty(handle, orphan_dir_bh);
 
 leave:
        ocfs2_free_dir_lookup_result(&lookup);
@@ -2099,13 +2082,9 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
                goto leave;
        }
 
-       /* We don't use standard VFS wrapper because we don't want vfs_dq_init
-        * to be called. */
-       if (sb_any_quota_active(osb->sb) &&
-           osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
-               status = -EDQUOT;
+       status = dquot_alloc_inode(inode);
+       if (status)
                goto leave;
-       }
        did_quota_inode = 1;
 
        inode->i_nlink = 0;
@@ -2140,7 +2119,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
        insert_inode_hash(inode);
 leave:
        if (status < 0 && did_quota_inode)
-               vfs_dq_free_inode(inode);
+               dquot_free_inode(inode);
        if (handle)
                ocfs2_commit_trans(osb, handle);