fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / jfs / jfs_dtree.c
index bde0df4..2050170 100644 (file)
@@ -3,16 +3,16 @@
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or 
+ *   the Free Software Foundation; either version 2 of the License, or
  *   (at your option) any later version.
- * 
+ *
  *   This program is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
  *   the GNU General Public License for more details.
  *
  *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software 
+ *   along with this program;  if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
@@ -78,7 +78,7 @@
  *
  * case-insensitive search:
  *
- *     fold search key;
+ *     fold search key;
  *
  *     case-insensitive search of B-tree:
  *     for internal entry, router key is already folded;
@@ -93,7 +93,7 @@
  *     else
  *             return no match;
  *
- *     serialization:
+ *     serialization:
  * target directory inode lock is being held on entry/exit
  * of all main directory service routines.
  *
@@ -385,9 +385,9 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
                if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage))
                        goto clean_up;
                if (DLIMIT_ALLOC_BLOCK(ip, sbi->nbperpage))
-                       goto clean_up_quota;
+                       goto clean_up_dquot;
                if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr))
-                       goto clean_up_dlim;
+                       goto clean_up_dlimit;
 
                /*
                 * Save the table, we're going to overwrite it with the
@@ -480,10 +480,12 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
 
        return index;
 
-      clean_up_dlim:
+      clean_up_dlimit:
        DLIMIT_FREE_BLOCK(ip, sbi->nbperpage);
-      clean_up_quota:
+
+      clean_up_dquot:
        DQUOT_FREE_BLOCK(ip, sbi->nbperpage);
+
       clean_up:
 
        jfs_ip->next_index--;
@@ -930,7 +932,7 @@ int dtInsert(tid_t tid, struct inode *ip,
  *
  * return: 0 - success;
  *        errno - failure;
- *     leaf page unpinned;
+ *     leaf page unpinned;
  */
 static int dtSplitUp(tid_t tid,
          struct inode *ip, struct dtsplit * split, struct btstack * btstack)
@@ -1011,6 +1013,9 @@ static int dtSplitUp(tid_t tid,
 
                DT_PUTPAGE(smp);
 
+               if (!DO_INDEX(ip))
+                       ip->i_size = xlen << sbi->l2bsize;
+
                goto freeKeyName;
        }
 
@@ -1067,7 +1072,9 @@ static int dtSplitUp(tid_t tid,
                                xaddr = addressPXD(pxd) + xlen;
                                dbFree(ip, xaddr, (s64) n);
                        }
-               }
+               } else if (!DO_INDEX(ip))
+                       ip->i_size = lengthPXD(pxd) << sbi->l2bsize;
+
 
              extendOut:
                DT_PUTPAGE(smp);
@@ -1110,6 +1117,9 @@ static int dtSplitUp(tid_t tid,
                goto splitOut;
        }
 
+       if (!DO_INDEX(ip))
+               ip->i_size += PSIZE;
+
        /*
         * propagate up the router entry for the leaf page just split
         *
@@ -2455,6 +2465,9 @@ static int dtDeleteUp(tid_t tid, struct inode *ip,
                break;
        }
 
+       if (!DO_INDEX(ip))
+               ip->i_size -= PSIZE;
+
        return 0;
 }
 
@@ -3029,7 +3042,7 @@ static inline struct jfs_dirent *next_jfs_dirent(struct jfs_dirent *dirent)
  */
 int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *ip = filp->f_dentry->d_inode;
+       struct inode *ip = filp->f_path.dentry->d_inode;
        struct nls_table *codepage = JFS_SBI(ip->i_sb)->nls_tab;
        int rc = 0;
        loff_t dtpos;   /* legacy OS/2 style position */
@@ -3787,7 +3800,7 @@ static int ciCompare(struct component_name * key, /* search key */
  *          across page boundary
  *
  * return: non-zero on error
- *     
+ *
  */
 static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp,
                               int ri, struct component_name * key, int flag)
@@ -3797,16 +3810,16 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp,
        struct component_name lkey;
        struct component_name rkey;
 
-       lkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
+       lkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
                                        GFP_KERNEL);
        if (lkey.name == NULL)
-               return -ENOSPC;
+               return -ENOMEM;
 
-       rkey.name = (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
+       rkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
                                        GFP_KERNEL);
        if (rkey.name == NULL) {
                kfree(lkey.name);
-               return -ENOSPC;
+               return -ENOMEM;
        }
 
        /* get left and right key */