Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw
[cascardo/linux.git] / fs / gfs2 / inode.c
index 3ab192b..017960c 100644 (file)
@@ -333,7 +333,7 @@ out:
  */
 
 static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
-                    unsigned int mode)
+                    umode_t mode)
 {
        int error;
 
@@ -364,7 +364,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
        return 0;
 }
 
-static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode,
+static void munge_mode_uid_gid(struct gfs2_inode *dip, umode_t *mode,
                               unsigned int *uid, unsigned int *gid)
 {
        if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
@@ -389,13 +389,13 @@ static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
        int error;
-       int dblocks = 0;
+       int dblocks = 1;
 
-       if (gfs2_alloc_get(dip) == NULL)
-               return -ENOMEM;
+       error = gfs2_rindex_update(sdp);
+       if (error)
+               fs_warn(sdp, "rindex update returns %d\n", error);
 
-       dip->i_alloc->al_requested = RES_DINODE;
-       error = gfs2_inplace_reserve(dip);
+       error = gfs2_inplace_reserve(dip, RES_DINODE);
        if (error)
                goto out;
 
@@ -410,7 +410,6 @@ static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation)
 out_ipreserv:
        gfs2_inplace_release(dip);
 out:
-       gfs2_alloc_put(dip);
        return error;
 }
 
@@ -448,7 +447,7 @@ static void gfs2_init_dir(struct buffer_head *dibh,
  */
 
 static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
-                       const struct gfs2_inum_host *inum, unsigned int mode,
+                       const struct gfs2_inum_host *inum, umode_t mode,
                        unsigned int uid, unsigned int gid,
                        const u64 *generation, dev_t dev, const char *symname,
                        unsigned size, struct buffer_head **bhp)
@@ -517,7 +516,7 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
 }
 
 static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
-                      unsigned int mode, const struct gfs2_inum_host *inum,
+                      umode_t mode, const struct gfs2_inum_host *inum,
                       const u64 *generation, dev_t dev, const char *symname,
                       unsigned int size, struct buffer_head **bhp)
 {
@@ -526,7 +525,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
        int error;
 
        munge_mode_uid_gid(dip, &mode, &uid, &gid);
-       if (!gfs2_alloc_get(dip))
+       if (!gfs2_qadata_get(dip))
                return -ENOMEM;
 
        error = gfs2_quota_lock(dip, uid, gid);
@@ -548,7 +547,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
 out_quota:
        gfs2_quota_unlock(dip);
 out:
-       gfs2_alloc_put(dip);
+       gfs2_qadata_put(dip);
        return error;
 }
 
@@ -556,13 +555,13 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
                       struct gfs2_inode *ip)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
-       struct gfs2_alloc *al;
+       struct gfs2_qadata *qa;
        int alloc_required;
        struct buffer_head *dibh;
        int error;
 
-       al = gfs2_alloc_get(dip);
-       if (!al)
+       qa = gfs2_qadata_get(dip);
+       if (!qa)
                return -ENOMEM;
 
        error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
@@ -577,9 +576,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
                if (error)
                        goto fail_quota_locks;
 
-               al->al_requested = sdp->sd_max_dirres;
-
-               error = gfs2_inplace_reserve(dip);
+               error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
                if (error)
                        goto fail_quota_locks;
 
@@ -620,11 +617,11 @@ fail_quota_locks:
        gfs2_quota_unlock(dip);
 
 fail:
-       gfs2_alloc_put(dip);
+       gfs2_qadata_put(dip);
        return error;
 }
 
-int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
+static int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
                    void *fs_info)
 {
        const struct xattr *xattr;
@@ -660,7 +657,7 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip,
  */
 
 static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
-                            unsigned int mode, dev_t dev, const char *symname,
+                            umode_t mode, dev_t dev, const char *symname,
                             unsigned int size, int excl)
 {
        const struct qstr *name = &dentry->d_name;
@@ -729,9 +726,12 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
                brelse(bh);
 
        gfs2_trans_end(sdp);
-       gfs2_inplace_release(dip);
+       /* Check if we reserved space in the rgrp. Function link_dinode may
+          not, depending on whether alloc is required. */
+       if (dip->i_res)
+               gfs2_inplace_release(dip);
        gfs2_quota_unlock(dip);
-       gfs2_alloc_put(dip);
+       gfs2_qadata_put(dip);
        mark_inode_dirty(inode);
        gfs2_glock_dq_uninit_m(2, ghs);
        d_instantiate(dentry, inode);
@@ -761,7 +761,7 @@ fail:
  */
 
 static int gfs2_create(struct inode *dir, struct dentry *dentry,
-                      int mode, struct nameidata *nd)
+                      umode_t mode, struct nameidata *nd)
 {
        int excl = 0;
        if (nd && (nd->flags & LOOKUP_EXCL))
@@ -876,8 +876,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
        error = 0;
 
        if (alloc_required) {
-               struct gfs2_alloc *al = gfs2_alloc_get(dip);
-               if (!al) {
+               struct gfs2_qadata *qa = gfs2_qadata_get(dip);
+
+               if (!qa) {
                        error = -ENOMEM;
                        goto out_gunlock;
                }
@@ -886,9 +887,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
                if (error)
                        goto out_alloc;
 
-               al->al_requested = sdp->sd_max_dirres;
-
-               error = gfs2_inplace_reserve(dip);
+               error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
                if (error)
                        goto out_gunlock_q;
 
@@ -931,7 +930,7 @@ out_gunlock_q:
                gfs2_quota_unlock(dip);
 out_alloc:
        if (alloc_required)
-               gfs2_alloc_put(dip);
+               gfs2_qadata_put(dip);
 out_gunlock:
        gfs2_glock_dq(ghs + 1);
 out_child:
@@ -1133,7 +1132,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
  * Returns: errno
  */
 
-static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
        return gfs2_create_inode(dir, dentry, S_IFDIR | mode, 0, NULL, 0, 0);
 }
@@ -1147,7 +1146,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
  *
  */
 
-static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
+static int gfs2_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
                      dev_t dev)
 {
        return gfs2_create_inode(dir, dentry, mode, dev, NULL, 0, 0);
@@ -1354,8 +1353,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
        error = 0;
 
        if (alloc_required) {
-               struct gfs2_alloc *al = gfs2_alloc_get(ndip);
-               if (!al) {
+               struct gfs2_qadata *qa = gfs2_qadata_get(ndip);
+
+               if (!qa) {
                        error = -ENOMEM;
                        goto out_gunlock;
                }
@@ -1364,9 +1364,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                if (error)
                        goto out_alloc;
 
-               al->al_requested = sdp->sd_max_dirres;
-
-               error = gfs2_inplace_reserve(ndip);
+               error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres);
                if (error)
                        goto out_gunlock_q;
 
@@ -1427,7 +1425,7 @@ out_gunlock_q:
                gfs2_quota_unlock(ndip);
 out_alloc:
        if (alloc_required)
-               gfs2_alloc_put(ndip);
+               gfs2_qadata_put(ndip);
 out_gunlock:
        while (x--) {
                gfs2_glock_dq(ghs + x);
@@ -1588,7 +1586,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
        if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
                ogid = ngid = NO_QUOTA_CHANGE;
 
-       if (!gfs2_alloc_get(ip))
+       if (!gfs2_qadata_get(ip))
                return -ENOMEM;
 
        error = gfs2_quota_lock(ip, nuid, ngid);
@@ -1620,7 +1618,7 @@ out_end_trans:
 out_gunlock_q:
        gfs2_quota_unlock(ip);
 out_alloc:
-       gfs2_alloc_put(ip);
+       gfs2_qadata_put(ip);
        return error;
 }