]> err.no Git - linux-2.6/blobdiff - fs/gfs2/quota.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6] / fs / gfs2 / quota.c
index fe1828ffebfa713bea1babda9eba212ba3df54ae..c186857e48a80a49433b81fe2f11986b58c188f7 100644 (file)
 #include <linux/buffer_head.h>
 #include <linux/sort.h>
 #include <linux/fs.h>
+#include <linux/bio.h>
 #include <linux/gfs2_ondisk.h>
+#include <linux/lm_interface.h>
 
 #include "gfs2.h"
-#include "lm_interface.h"
 #include "incore.h"
 #include "bmap.h"
 #include "glock.h"
@@ -248,11 +249,9 @@ static int bh_get(struct gfs2_quota_data *qd)
        struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
        struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
        unsigned int block, offset;
-       u64 dblock;
-       int new = 0;
        struct buffer_head *bh;
        int error;
-       int boundary;
+       struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
 
        mutex_lock(&sdp->sd_quota_mutex);
 
@@ -264,10 +263,11 @@ static int bh_get(struct gfs2_quota_data *qd)
        block = qd->qd_slot / sdp->sd_qc_per_block;
        offset = qd->qd_slot % sdp->sd_qc_per_block;;
 
-       error = gfs2_block_map(&ip->i_inode, block, &new, &dblock, &boundary);
+       bh_map.b_size = 1 << ip->i_inode.i_blkbits;
+       error = gfs2_block_map(&ip->i_inode, block, 0, &bh_map);
        if (error)
                goto fail;
-       error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, &bh);
+       error = gfs2_meta_read(ip->i_gl, bh_map.b_blocknr, DIO_WAIT, &bh);
        if (error)
                goto fail;
        error = -EIO;
@@ -279,7 +279,7 @@ static int bh_get(struct gfs2_quota_data *qd)
                (bh->b_data + sizeof(struct gfs2_meta_header) +
                 offset * sizeof(struct gfs2_quota_change));
 
-       mutex_lock(&sdp->sd_quota_mutex);
+       mutex_unlock(&sdp->sd_quota_mutex);
 
        return 0;
 
@@ -452,19 +452,19 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
        if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
                return 0;
 
-       error = qdsb_get(sdp, QUOTA_USER, ip->i_di.di_uid, CREATE, qd);
+       error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, CREATE, qd);
        if (error)
                goto out;
        al->al_qd_num++;
        qd++;
 
-       error = qdsb_get(sdp, QUOTA_GROUP, ip->i_di.di_gid, CREATE, qd);
+       error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, CREATE, qd);
        if (error)
                goto out;
        al->al_qd_num++;
        qd++;
 
-       if (uid != NO_QUOTA_CHANGE && uid != ip->i_di.di_uid) {
+       if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) {
                error = qdsb_get(sdp, QUOTA_USER, uid, CREATE, qd);
                if (error)
                        goto out;
@@ -472,7 +472,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
                qd++;
        }
 
-       if (gid != NO_QUOTA_CHANGE && gid != ip->i_di.di_gid) {
+       if (gid != NO_QUOTA_CHANGE && gid != ip->i_inode.i_gid) {
                error = qdsb_get(sdp, QUOTA_GROUP, gid, CREATE, qd);
                if (error)
                        goto out;
@@ -539,8 +539,7 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)
                qc->qc_id = cpu_to_be32(qd->qd_id);
        }
 
-       x = qc->qc_change;
-       x = be64_to_cpu(x) + change;
+       x = be64_to_cpu(qc->qc_change) + change;
        qc->qc_change = cpu_to_be64(x);
 
        spin_lock(&sdp->sd_quota_spin);
@@ -558,7 +557,7 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)
                qd_hold(qd);
                slot_hold(qd);
        }
-                       
+
        mutex_unlock(&sdp->sd_quota_mutex);
 }
 
@@ -611,7 +610,7 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
                set_buffer_uptodate(bh);
 
        if (!buffer_uptodate(bh)) {
-               ll_rw_block(READ, 1, &bh);
+               ll_rw_block(READ_META, 1, &bh);
                wait_on_buffer(bh);
                if (!buffer_uptodate(bh))
                        goto unlock;
@@ -743,7 +742,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
        struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
        struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode);
        struct gfs2_holder i_gh;
-       struct gfs2_quota q;
+       struct gfs2_quota_host q;
        char buf[sizeof(struct gfs2_quota)];
        struct file_ra_state ra_state;
        int error;
@@ -779,7 +778,7 @@ restart:
 
                gfs2_glock_dq_uninit(&i_gh);
 
-               
+
                gfs2_quota_in(&q, buf);
                qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lvb;
                qlvb->qb_magic = cpu_to_be32(GFS2_MAGIC);
@@ -1061,11 +1060,10 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
        u32 extlen = 0;
        int error;
 
-       if (!ip->i_di.di_size ||
-           ip->i_di.di_size > (64 << 20) ||
+       if (!ip->i_di.di_size || ip->i_di.di_size > (64 << 20) ||
            ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1)) {
                gfs2_consist_inode(ip);
-               return -EIO;            
+               return -EIO;
        }
        sdp->sd_quota_slots = blocks * sdp->sd_qc_per_block;
        sdp->sd_quota_chunks = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * PAGE_SIZE);
@@ -1093,21 +1091,18 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
                        if (error)
                                goto fail;
                }
-               gfs2_meta_ra(ip->i_gl,  dblock, extlen);
-               error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT,
-                                      &bh);
-               if (error)
-                       goto fail;
                error = -EIO;
+               bh = gfs2_meta_ra(ip->i_gl, dblock, extlen);
+               if (!bh)
+                       goto fail;
                if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_QC)) {
                        brelse(bh);
                        goto fail;
                }
 
-               for (y = 0;
-                    y < sdp->sd_qc_per_block && slot < sdp->sd_quota_slots;
+               for (y = 0; y < sdp->sd_qc_per_block && slot < sdp->sd_quota_slots;
                     y++, slot++) {
-                       struct gfs2_quota_change qc;
+                       struct gfs2_quota_change_host qc;
                        struct gfs2_quota_data *qd;
 
                        gfs2_quota_change_in(&qc, bh->b_data +