Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / udf / balloc.c
index 235418f..ea521f8 100644 (file)
@@ -4,11 +4,6 @@
  * PURPOSE
  *     Block allocation handling routines for the OSTA-UDF(tm) filesystem.
  *
- * CONTACTS
- *     E-mail regarding any portion of the Linux UDF file system should be
- *     directed to the development team mailing list (run by majordomo):
- *             linux_udf@hpesjro.fc.hp.com
- *
  * COPYRIGHT
  *     This file is distributed under the terms of the GNU General Public
  *     License (GPL). Copies of the GPL can be obtained from:
@@ -28,7 +23,7 @@
 
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 
 #include "udf_i.h"
 #include "udf_sb.h"
@@ -46,7 +41,7 @@
 #define uint(x) xuint(x)
 #define xuint(x) __le ## x
 
-extern inline int find_next_one_bit (void * addr, int size, int offset)
+static inline int find_next_one_bit (void * addr, int size, int offset)
 {
        uintBPL_t * p = ((uintBPL_t *) addr) + (offset / BITS_PER_LONG);
        int result = offset & ~(BITS_PER_LONG-1);
@@ -148,6 +143,7 @@ static void udf_bitmap_free_blocks(struct super_block * sb,
        struct udf_bitmap *bitmap,
        kernel_lb_addr bloc, uint32_t offset, uint32_t count)
 {
+       struct udf_sb_info *sbi = UDF_SB(sb);
        struct buffer_head * bh = NULL;
        unsigned long block;
        unsigned long block_group;
@@ -156,7 +152,7 @@ static void udf_bitmap_free_blocks(struct super_block * sb,
        int bitmap_nr;
        unsigned long overflow;
 
-       lock_super(sb);
+       mutex_lock(&sbi->s_alloc_mutex);
        if (bloc.logicalBlockNum < 0 ||
                (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
        {
@@ -215,7 +211,7 @@ error_return:
        sb->s_dirt = 1;
        if (UDF_SB_LVIDBH(sb))
                mark_buffer_dirty(UDF_SB_LVIDBH(sb));
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_alloc_mutex);
        return;
 }
 
@@ -224,13 +220,13 @@ static int udf_bitmap_prealloc_blocks(struct super_block * sb,
        struct udf_bitmap *bitmap, uint16_t partition, uint32_t first_block,
        uint32_t block_count)
 {
+       struct udf_sb_info *sbi = UDF_SB(sb);
        int alloc_count = 0;
        int bit, block, block_group, group_start;
        int nr_groups, bitmap_nr;
        struct buffer_head *bh;
 
-       lock_super(sb);
-
+       mutex_lock(&sbi->s_alloc_mutex);
        if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
                goto out;
 
@@ -279,7 +275,7 @@ out:
                mark_buffer_dirty(UDF_SB_LVIDBH(sb));
        }
        sb->s_dirt = 1;
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_alloc_mutex);
        return alloc_count;
 }
 
@@ -287,6 +283,7 @@ static int udf_bitmap_new_block(struct super_block * sb,
        struct inode * inode,
        struct udf_bitmap *bitmap, uint16_t partition, uint32_t goal, int *err)
 {
+       struct udf_sb_info *sbi = UDF_SB(sb);
        int newbit, bit=0, block, block_group, group_start;
        int end_goal, nr_groups, bitmap_nr, i;
        struct buffer_head *bh = NULL;
@@ -294,7 +291,7 @@ static int udf_bitmap_new_block(struct super_block * sb,
        int newblock = 0;
 
        *err = -ENOSPC;
-       lock_super(sb);
+       mutex_lock(&sbi->s_alloc_mutex);
 
 repeat:
        if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
@@ -367,7 +364,7 @@ repeat:
        }
        if (i >= (nr_groups*2))
        {
-               unlock_super(sb);
+               mutex_unlock(&sbi->s_alloc_mutex);
                return newblock;
        }
        if (bit < sb->s_blocksize << 3)
@@ -376,7 +373,7 @@ repeat:
                bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3);
        if (bit >= sb->s_blocksize << 3)
        {
-               unlock_super(sb);
+               mutex_unlock(&sbi->s_alloc_mutex);
                return 0;
        }
 
@@ -390,7 +387,7 @@ got_block:
         */
        if (inode && DQUOT_ALLOC_BLOCK(inode, 1))
        {
-               unlock_super(sb);
+               mutex_unlock(&sbi->s_alloc_mutex);
                *err = -EDQUOT;
                return 0;
        }
@@ -413,13 +410,13 @@ got_block:
                mark_buffer_dirty(UDF_SB_LVIDBH(sb));
        }
        sb->s_dirt = 1;
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_alloc_mutex);
        *err = 0;
        return newblock;
 
 error_return:
        *err = -EIO;
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_alloc_mutex);
        return 0;
 }
 
@@ -428,6 +425,7 @@ static void udf_table_free_blocks(struct super_block * sb,
        struct inode * table,
        kernel_lb_addr bloc, uint32_t offset, uint32_t count)
 {
+       struct udf_sb_info *sbi = UDF_SB(sb);
        uint32_t start, end;
        uint32_t nextoffset, oextoffset, elen;
        kernel_lb_addr nbloc, obloc, eloc;
@@ -435,7 +433,7 @@ static void udf_table_free_blocks(struct super_block * sb,
        int8_t etype;
        int i;
 
-       lock_super(sb);
+       mutex_lock(&sbi->s_alloc_mutex);
        if (bloc.logicalBlockNum < 0 ||
                (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
        {
@@ -581,10 +579,9 @@ static void udf_table_free_blocks(struct super_block * sb,
                        {
                                loffset = nextoffset;
                                aed->lengthAllocDescs = cpu_to_le32(adsize);
-                               if (obh)
-                                       sptr = UDF_I_DATA(inode) + nextoffset -  udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode) - adsize;
-                               else
-                                       sptr = obh->b_data + nextoffset - adsize;
+                               sptr = UDF_I_DATA(inode) + nextoffset -
+                                       udf_file_entry_alloc_offset(inode) +
+                                       UDF_I_LENEATTR(inode) - adsize;
                                dptr = nbh->b_data + sizeof(struct allocExtDesc);
                                memcpy(dptr, sptr, adsize);
                                nextoffset = sizeof(struct allocExtDesc) + adsize;
@@ -669,7 +666,7 @@ static void udf_table_free_blocks(struct super_block * sb,
 
 error_return:
        sb->s_dirt = 1;
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_alloc_mutex);
        return;
 }
 
@@ -678,6 +675,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
        struct inode *table, uint16_t partition, uint32_t first_block,
        uint32_t block_count)
 {
+       struct udf_sb_info *sbi = UDF_SB(sb);
        int alloc_count = 0;
        uint32_t extoffset, elen, adsize;
        kernel_lb_addr bloc, eloc;
@@ -694,8 +692,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
        else
                return 0;
 
-       lock_super(sb);
-
+       mutex_lock(&sbi->s_alloc_mutex);
        extoffset = sizeof(struct unallocSpaceEntry);
        bloc = UDF_I_LOCATION(table);
 
@@ -739,7 +736,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
                mark_buffer_dirty(UDF_SB_LVIDBH(sb));
                sb->s_dirt = 1;
        }
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_alloc_mutex);
        return alloc_count;
 }
 
@@ -747,6 +744,7 @@ static int udf_table_new_block(struct super_block * sb,
        struct inode * inode,
        struct inode *table, uint16_t partition, uint32_t goal, int *err)
 {
+       struct udf_sb_info *sbi = UDF_SB(sb);
        uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
        uint32_t newblock = 0, adsize;
        uint32_t extoffset, goal_extoffset, elen, goal_elen = 0;
@@ -763,8 +761,7 @@ static int udf_table_new_block(struct super_block * sb,
        else
                return newblock;
 
-       lock_super(sb);
-
+       mutex_lock(&sbi->s_alloc_mutex);
        if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
                goal = 0;
 
@@ -814,7 +811,7 @@ static int udf_table_new_block(struct super_block * sb,
        if (spread == 0xFFFFFFFF)
        {
                udf_release_data(goal_bh);
-               unlock_super(sb);
+               mutex_unlock(&sbi->s_alloc_mutex);
                return 0;
        }
 
@@ -830,7 +827,7 @@ static int udf_table_new_block(struct super_block * sb,
        if (inode && DQUOT_ALLOC_BLOCK(inode, 1))
        {
                udf_release_data(goal_bh);
-               unlock_super(sb);
+               mutex_unlock(&sbi->s_alloc_mutex);
                *err = -EDQUOT;
                return 0;
        }
@@ -849,7 +846,7 @@ static int udf_table_new_block(struct super_block * sb,
        }
 
        sb->s_dirt = 1;
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_alloc_mutex);
        *err = 0;
        return newblock;
 }