Btrfs: always pin metadata in discard mode
[safe/jmp/linux-2.6] / fs / ufs / balloc.c
index b8fa34a..54c16ec 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #include <linux/fs.h>
-#include <linux/ufs_fs.h>
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <linux/string.h>
@@ -19,6 +18,8 @@
 #include <linux/bitops.h>
 #include <asm/byteorder.h>
 
+#include "ufs_fs.h"
+#include "ufs.h"
 #include "swab.h"
 #include "util.h"
 
@@ -84,7 +85,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)
                                   "bit already cleared for fragment %u", i);
        }
        
-       DQUOT_FREE_BLOCK (inode, count);
+       vfs_dq_free_block(inode, count);
 
        
        fs32_add(sb, &ucg->cg_cs.cs_nffree, count);
@@ -194,7 +195,7 @@ do_more:
                ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
                if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
                        ufs_clusteracct (sb, ucpi, blkno, 1);
-               DQUOT_FREE_BLOCK(inode, uspi->s_fpb);
+               vfs_dq_free_block(inode, uspi->s_fpb);
 
                fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1);
                uspi->cs_total.cs_nbfree++;
@@ -276,7 +277,7 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
                        if (!page)/* it was truncated */
                                continue;
                        if (IS_ERR(page)) {/* or EIO */
-                               ufs_error(inode->i_sb, __FUNCTION__,
+                               ufs_error(inode->i_sb, __func__,
                                          "read of page %llu failed\n",
                                          (unsigned long long)index);
                                continue;
@@ -307,15 +308,15 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
                                ll_rw_block(READ, 1, &bh);
                                wait_on_buffer(bh);
                                if (!buffer_uptodate(bh)) {
-                                       ufs_error(inode->i_sb, __FUNCTION__,
+                                       ufs_error(inode->i_sb, __func__,
                                                  "read of block failed\n");
                                        break;
                                }
                        }
 
                        UFSD(" change from %llu to %llu, pos %u\n",
-                            (unsigned long long)pos + oldb,
-                            (unsigned long long)pos + newb, pos);
+                            (unsigned long long)(pos + oldb),
+                            (unsigned long long)(pos + newb), pos);
 
                        bh->b_blocknr = newb + pos;
                        unmap_underlying_metadata(bh->b_bdev,
@@ -482,8 +483,9 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
        if (result) {
                ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
                                locked_page != NULL);
-               ufs_change_blocknr(inode, fragment - oldcount, oldcount, tmp,
-                                  result, locked_page);
+               ufs_change_blocknr(inode, fragment - oldcount, oldcount,
+                                  uspi->s_sbbase + tmp,
+                                  uspi->s_sbbase + result, locked_page);
                ufs_cpu_to_data_ptr(sb, p, result);
                *err = 0;
                UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
@@ -554,7 +556,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,
                fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1);
        for (i = oldcount; i < newcount; i++)
                ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i);
-       if(DQUOT_ALLOC_BLOCK(inode, count)) {
+       if (vfs_dq_alloc_block(inode, count)) {
                *err = -EDQUOT;
                return 0;
        }
@@ -662,7 +664,7 @@ cg_found:
                for (i = count; i < uspi->s_fpb; i++)
                        ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i);
                i = uspi->s_fpb - count;
-               DQUOT_FREE_BLOCK(inode, i);
+               vfs_dq_free_block(inode, i);
 
                fs32_add(sb, &ucg->cg_cs.cs_nffree, i);
                uspi->cs_total.cs_nffree += i;
@@ -674,7 +676,7 @@ cg_found:
        result = ufs_bitmap_search (sb, ucpi, goal, allocsize);
        if (result == INVBLOCK)
                return 0;
-       if(DQUOT_ALLOC_BLOCK(inode, count)) {
+       if (vfs_dq_alloc_block(inode, count)) {
                *err = -EDQUOT;
                return 0;
        }
@@ -745,7 +747,7 @@ gotit:
        ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno);
        if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD)
                ufs_clusteracct (sb, ucpi, blkno, -1);
-       if(DQUOT_ALLOC_BLOCK(inode, uspi->s_fpb)) {
+       if (vfs_dq_alloc_block(inode, uspi->s_fpb)) {
                *err = -EDQUOT;
                return INVBLOCK;
        }