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 / jfs / inode.c
index 24a6891..11d65d9 100644 (file)
@@ -22,7 +22,9 @@
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
+#include <linux/vs_dlimit.h>
 #include "jfs_incore.h"
+#include "jfs_inode.h"
 #include "jfs_filsys.h"
 #include "jfs_imap.h"
 #include "jfs_extent.h"
 #include "jfs_debug.h"
 
 
-extern struct inode_operations jfs_dir_inode_operations;
-extern struct inode_operations jfs_file_inode_operations;
-extern struct inode_operations jfs_symlink_inode_operations;
-extern struct file_operations jfs_dir_operations;
-extern struct file_operations jfs_file_operations;
-struct address_space_operations jfs_aops;
-extern int freeZeroLink(struct inode *);
-
 void jfs_read_inode(struct inode *inode)
 {
        if (diRead(inode)) { 
@@ -62,6 +56,7 @@ void jfs_read_inode(struct inode *inode)
                inode->i_op = &jfs_file_inode_operations;
                init_special_inode(inode, inode->i_mode, inode->i_rdev);
        }
+       jfs_set_inode_flags(inode);
 }
 
 /*
@@ -96,16 +91,16 @@ int jfs_commit_inode(struct inode *inode, int wait)
        }
 
        tid = txBegin(inode->i_sb, COMMIT_INODE);
-       down(&JFS_IP(inode)->commit_sem);
+       mutex_lock(&JFS_IP(inode)->commit_mutex);
 
        /*
-        * Retest inode state after taking commit_sem
+        * Retest inode state after taking commit_mutex
         */
        if (inode->i_nlink && test_cflag(COMMIT_Dirty, inode))
                rc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0);
 
        txEnd(tid);
-       up(&JFS_IP(inode)->commit_sem);
+       mutex_unlock(&JFS_IP(inode)->commit_mutex);
        return rc;
 }
 
@@ -135,17 +130,23 @@ void jfs_delete_inode(struct inode *inode)
 {
        jfs_info("In jfs_delete_inode, inode = 0x%p", inode);
 
-       if (test_cflag(COMMIT_Freewmap, inode))
-               freeZeroLink(inode);
+       if (!is_bad_inode(inode) &&
+           (JFS_IP(inode)->fileset == FILESYSTEM_I)) {
+               truncate_inode_pages(&inode->i_data, 0);
 
-       diFree(inode);
+               if (test_cflag(COMMIT_Freewmap, inode))
+                       jfs_free_zero_link(inode);
 
-       /*
-        * Free the inode from the quota allocation.
-        */
-       DQUOT_INIT(inode);
-       DQUOT_FREE_INODE(inode);
-       DQUOT_DROP(inode);
+               diFree(inode);
+
+               /*
+                * Free the inode from the quota allocation.
+                */
+               DQUOT_INIT(inode);
+               DQUOT_FREE_INODE(inode);
+               DQUOT_DROP(inode);
+               DLIMIT_FREE_INODE(inode);
+       }
 
        clear_inode(inode);
 }
@@ -259,7 +260,8 @@ jfs_get_blocks(struct inode *ip, sector_t lblock, unsigned long max_blocks,
 static int jfs_get_block(struct inode *ip, sector_t lblock,
                         struct buffer_head *bh_result, int create)
 {
-       return jfs_get_blocks(ip, lblock, 1, bh_result, create);
+       return jfs_get_blocks(ip, lblock, bh_result->b_size >> ip->i_blkbits,
+                       bh_result, create);
 }
 
 static int jfs_writepage(struct page *page, struct writeback_control *wbc)
@@ -302,7 +304,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
        struct inode *inode = file->f_mapping->host;
 
        return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
-                               offset, nr_segs, jfs_get_blocks, NULL);
+                               offset, nr_segs, jfs_get_block, NULL);
 }
 
 struct address_space_operations jfs_aops = {
@@ -337,18 +339,18 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
                tid = txBegin(ip->i_sb, 0);
 
                /*
-                * The commit_sem cannot be taken before txBegin.
+                * The commit_mutex cannot be taken before txBegin.
                 * txBegin may block and there is a chance the inode
                 * could be marked dirty and need to be committed
                 * before txBegin unblocks
                 */
-               down(&JFS_IP(ip)->commit_sem);
+               mutex_lock(&JFS_IP(ip)->commit_mutex);
 
                newsize = xtTruncate(tid, ip, length,
                                     COMMIT_TRUNCATE | COMMIT_PWMAP);
                if (newsize < 0) {
                        txEnd(tid);
-                       up(&JFS_IP(ip)->commit_sem);
+                       mutex_unlock(&JFS_IP(ip)->commit_mutex);
                        break;
                }
 
@@ -357,7 +359,7 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
 
                txCommit(tid, 1, &ip, 0);
                txEnd(tid);
-               up(&JFS_IP(ip)->commit_sem);
+               mutex_unlock(&JFS_IP(ip)->commit_mutex);
        } while (newsize > length);     /* Truncate isn't always atomic */
 }