NFS: Kill the obsolete NFS_PARANOIA
[powerpc.git] / fs / gfs2 / rgrp.c
index baa93c5..1727f50 100644 (file)
@@ -7,16 +7,15 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
 #include <linux/gfs2_ondisk.h>
+#include <linux/lm_interface.h>
 
 #include "gfs2.h"
-#include "lm_interface.h"
 #include "incore.h"
 #include "glock.h"
 #include "glops.h"
@@ -28,8 +27,9 @@
 #include "trans.h"
 #include "ops_file.h"
 #include "util.h"
+#include "log.h"
 
-#define BFITNOENT (u32)~0
+#define BFITNOENT ((u32)~0)
 
 /*
  * These routines are used by the resource group routines (rgrp.c)
@@ -253,7 +253,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd)
 
 }
 
-static inline int rgrp_contains_block(struct gfs2_rindex *ri, u64 block)
+static inline int rgrp_contains_block(struct gfs2_rindex_host *ri, u64 block)
 {
        u64 first = ri->ri_data0;
        u64 last = first + ri->ri_data;
@@ -575,15 +575,14 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd)
 
        for (x = 0; x < length; x++) {
                bi = rgd->rd_bits + x;
-               error = gfs2_meta_read(gl, rgd->rd_ri.ri_addr + x, DIO_START,
-                                      &bi->bi_bh);
+               error = gfs2_meta_read(gl, rgd->rd_ri.ri_addr + x, 0, &bi->bi_bh);
                if (error)
                        goto fail;
        }
 
        for (y = length; y--;) {
                bi = rgd->rd_bits + y;
-               error = gfs2_meta_reread(sdp, bi->bi_bh, DIO_WAIT);
+               error = gfs2_meta_wait(sdp, bi->bi_bh);
                if (error)
                        goto fail;
                if (gfs2_metatype_check(sdp, bi->bi_bh, y ? GFS2_METATYPE_RB :
@@ -693,25 +692,12 @@ struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip)
        return al;
 }
 
-/**
- * gfs2_alloc_put - throw away the struct gfs2_alloc for an inode
- * @ip: the inode
- *
- */
-
-void gfs2_alloc_put(struct gfs2_inode *ip)
-{
-       return;
-}
-
 /**
  * try_rgrp_fit - See if a given reservation will fit in a given RG
  * @rgd: the RG data
  * @al: the struct gfs2_alloc structure describing the reservation
  *
  * If there's room for the requested blocks to be allocated from the RG:
- *   Sets the $al_reserved_data field in @al.
- *   Sets the $al_reserved_meta field in @al.
  *   Sets the $al_rgd field in @al.
  *
  * Returns: 1 on success (it fits), 0 on failure (it doesn't fit)
@@ -722,6 +708,9 @@ static int try_rgrp_fit(struct gfs2_rgrpd *rgd, struct gfs2_alloc *al)
        struct gfs2_sbd *sdp = rgd->rd_sbd;
        int ret = 0;
 
+       if (rgd->rd_rg.rg_flags & GFS2_RGF_NOALLOC)
+               return 0;
+
        spin_lock(&sdp->sd_rindex_spin);
        if (rgd->rd_free_clone >= al->al_requested) {
                al->al_rgd = rgd;
@@ -908,7 +897,7 @@ static int get_local_rgrp(struct gfs2_inode *ip)
        rgd = recent_rgrp_first(sdp, ip->i_last_rg_alloc);
 
        while (rgd) {
-               error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 
+               error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE,
                                           LM_FLAG_TRY, &al->al_rgd_gh);
                switch (error) {
                case 0:
@@ -954,9 +943,13 @@ static int get_local_rgrp(struct gfs2_inode *ip)
                        rgd = gfs2_rgrpd_get_first(sdp);
 
                if (rgd == begin) {
-                       if (++loops >= 2 || !skipped)
+                       if (++loops >= 3)
                                return -ENOSPC;
+                       if (!skipped)
+                               loops++;
                        flags = 0;
+                       if (loops == 2)
+                               gfs2_log_flush(sdp, NULL);
                }
        }
 
@@ -1229,7 +1222,7 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip)
        al->al_alloced++;
 
        gfs2_statfs_change(sdp, 0, -1, 0);
-       gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
 
        spin_lock(&sdp->sd_rindex_spin);
        rgd->rd_free_clone--;
@@ -1273,7 +1266,7 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip)
        al->al_alloced++;
 
        gfs2_statfs_change(sdp, 0, -1, 0);
-       gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
        gfs2_trans_add_unrevoke(sdp, block);
 
        spin_lock(&sdp->sd_rindex_spin);
@@ -1349,8 +1342,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
        gfs2_trans_add_rg(rgd);
 
        gfs2_statfs_change(sdp, 0, +blen, 0);
-       gfs2_quota_change(ip, -(s64)blen,
-                        ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
 }
 
 /**
@@ -1378,7 +1370,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
        gfs2_trans_add_rg(rgd);
 
        gfs2_statfs_change(sdp, 0, +blen, 0);
-       gfs2_quota_change(ip, -(s64)blen, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
        gfs2_meta_wipe(ip, bstart, blen);
 }
 
@@ -1423,7 +1415,7 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)
 void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
 {
        gfs2_free_uninit_di(rgd, ip->i_num.no_addr);
-       gfs2_quota_change(ip, -1, ip->i_di.di_uid, ip->i_di.di_gid);
+       gfs2_quota_change(ip, -1, ip->i_inode.i_uid, ip->i_inode.i_gid);
        gfs2_meta_wipe(ip, ip->i_num.no_addr, 1);
 }