[PATCH] sanitize ->permission() prototype
[pandora-kernel.git] / fs / hfs / extent.c
index 5ea6b3d..2c16316 100644 (file)
@@ -343,16 +343,16 @@ int hfs_get_block(struct inode *inode, sector_t block,
                goto done;
        }
 
-       down(&HFS_I(inode)->extents_lock);
+       mutex_lock(&HFS_I(inode)->extents_lock);
        res = hfs_ext_read_extent(inode, ablock);
        if (!res)
                dblock = hfs_ext_find_block(HFS_I(inode)->cached_extents,
                                            ablock - HFS_I(inode)->cached_start);
        else {
-               up(&HFS_I(inode)->extents_lock);
+               mutex_unlock(&HFS_I(inode)->extents_lock);
                return -EIO;
        }
-       up(&HFS_I(inode)->extents_lock);
+       mutex_unlock(&HFS_I(inode)->extents_lock);
 
 done:
        map_bh(bh_result, sb, HFS_SB(sb)->fs_start +
@@ -375,7 +375,7 @@ int hfs_extend_file(struct inode *inode)
        u32 start, len, goal;
        int res;
 
-       down(&HFS_I(inode)->extents_lock);
+       mutex_lock(&HFS_I(inode)->extents_lock);
        if (HFS_I(inode)->alloc_blocks == HFS_I(inode)->first_blocks)
                goal = hfs_ext_lastblock(HFS_I(inode)->first_extents);
        else {
@@ -425,7 +425,7 @@ int hfs_extend_file(struct inode *inode)
                        goto insert_extent;
        }
 out:
-       up(&HFS_I(inode)->extents_lock);
+       mutex_unlock(&HFS_I(inode)->extents_lock);
        if (!res) {
                HFS_I(inode)->alloc_blocks += len;
                mark_inode_dirty(inode);
@@ -464,23 +464,20 @@ void hfs_file_truncate(struct inode *inode)
               (long long)HFS_I(inode)->phys_size, inode->i_size);
        if (inode->i_size > HFS_I(inode)->phys_size) {
                struct address_space *mapping = inode->i_mapping;
+               void *fsdata;
                struct page *page;
                int res;
 
+               /* XXX: Can use generic_cont_expand? */
                size = inode->i_size - 1;
-               page = grab_cache_page(mapping, size >> PAGE_CACHE_SHIFT);
-               if (!page)
-                       return;
-               size &= PAGE_CACHE_SIZE - 1;
-               size++;
-               res = mapping->a_ops->prepare_write(NULL, page, size, size);
-               if (!res)
-                       res = mapping->a_ops->commit_write(NULL, page, size, size);
+               res = pagecache_write_begin(NULL, mapping, size+1, 0,
+                               AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata);
+               if (!res) {
+                       res = pagecache_write_end(NULL, mapping, size+1, 0, 0,
+                                       page, fsdata);
+               }
                if (res)
                        inode->i_size = HFS_I(inode)->phys_size;
-               unlock_page(page);
-               page_cache_release(page);
-               mark_inode_dirty(inode);
                return;
        } else if (inode->i_size == HFS_I(inode)->phys_size)
                return;
@@ -490,7 +487,7 @@ void hfs_file_truncate(struct inode *inode)
        if (blk_cnt == alloc_cnt)
                goto out;
 
-       down(&HFS_I(inode)->extents_lock);
+       mutex_lock(&HFS_I(inode)->extents_lock);
        hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
        while (1) {
                if (alloc_cnt == HFS_I(inode)->first_blocks) {
@@ -517,7 +514,7 @@ void hfs_file_truncate(struct inode *inode)
                hfs_brec_remove(&fd);
        }
        hfs_find_exit(&fd);
-       up(&HFS_I(inode)->extents_lock);
+       mutex_unlock(&HFS_I(inode)->extents_lock);
 
        HFS_I(inode)->alloc_blocks = blk_cnt;
 out: