This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / reiserfs / stree.c
index caea037..497b2f3 100644 (file)
@@ -93,7 +93,7 @@ inline void copy_item_head(struct item_head * p_v_to,
    Returns: -1 if key1 < key2 
    0 if key1 == key2
    1 if key1 > key2 */
-inline int  comp_short_keys (const struct reiserfs_key * le_key,
+inline int  comp_short_keys (const struct key * le_key, 
                             const struct cpu_key * cpu_key)
 {
   __u32 * p_s_le_u32, * p_s_cpu_u32;
@@ -117,7 +117,7 @@ inline int  comp_short_keys (const struct reiserfs_key * le_key,
    Compare keys using all 4 key fields.
    Returns: -1 if key1 < key2 0
    if key1 = key2 1 if key1 > key2 */
-inline int  comp_keys (const struct reiserfs_key * le_key, const struct cpu_key * cpu_key)
+inline int  comp_keys (const struct key * le_key, const struct cpu_key * cpu_key)
 {
   int retval;
 
@@ -174,7 +174,7 @@ inline int comp_cpu_keys (const struct cpu_key * key1,
     return 0;
 }
 
-inline int comp_short_le_keys (const struct reiserfs_key * key1, const struct reiserfs_key * key2)
+inline int comp_short_le_keys (const struct key * key1, const struct key * key2)
 {
   __u32 * p_s_1_u32, * p_s_2_u32;
   int n_key_length = REISERFS_SHORT_KEY_LEN;
@@ -216,7 +216,7 @@ inline void cpu_key2cpu_key (struct cpu_key * to, const struct cpu_key * from)
 }
 
 
-inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from)
+inline void le_key2cpu_key (struct cpu_key * to, const struct key * from)
 {
     to->on_disk_key.k_dir_id = le32_to_cpu (from->k_dir_id);
     to->on_disk_key.k_objectid = le32_to_cpu (from->k_objectid);
@@ -236,9 +236,9 @@ inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * fro
 
 // this does not say which one is bigger, it only returns 1 if keys
 // are not equal, 0 otherwise
-inline int comp_le_keys (const struct reiserfs_key * k1, const struct reiserfs_key * k2)
+inline int comp_le_keys (const struct key * k1, const struct key * k2)
 {
-    return memcmp (k1, k2, sizeof (struct reiserfs_key));
+    return memcmp (k1, k2, sizeof (struct key));
 }
 
 /**************************************************************************
@@ -272,7 +272,7 @@ inline      int bin_search (
     int   n_rbound, n_lbound, n_j;
 
    for ( n_j = ((n_rbound = p_n_num - 1) + (n_lbound = 0))/2; n_lbound <= n_rbound; n_j = (n_rbound + n_lbound)/2 )
-     switch( COMP_KEYS((struct reiserfs_key *)((char * )p_v_base + n_j * p_n_width), (struct cpu_key *)p_v_key) )  {
+     switch( COMP_KEYS((struct key *)((char * )p_v_base + n_j * p_n_width), (struct cpu_key *)p_v_key) )  {
      case -1: n_lbound = n_j + 1; continue;
      case  1: n_rbound = n_j - 1; continue;
      case  0: *p_n_pos = n_j;     return ITEM_FOUND; /* Key found in the array.  */
@@ -291,17 +291,17 @@ extern struct tree_balance * cur_tb;
 
 
 /* Minimal possible key. It is never in the tree. */
-const struct reiserfs_key  MIN_KEY = {0, 0, {{0, 0},}};
+const struct key  MIN_KEY = {0, 0, {{0, 0},}};
 
 /* Maximal possible key. It is never in the tree. */
-const struct reiserfs_key  MAX_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}};
+const struct key  MAX_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}};
 
 
 /* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom
    of the path, and going upwards.  We must check the path's validity at each step.  If the key is not in
    the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this
    case we return a special key, either MIN_KEY or MAX_KEY. */
-inline const struct  reiserfs_key * get_lkey  (
+inline const struct  key * get_lkey  (
                        const struct path         * p_s_chk_path,
                         const struct super_block  * p_s_sb
                       ) {
@@ -340,7 +340,7 @@ inline      const struct  reiserfs_key * get_lkey  (
 
 
 /* Get delimiting key of the buffer at the path and its right neighbor. */
-inline const struct  reiserfs_key * get_rkey  (
+inline const struct  key * get_rkey  (
                        const struct path         * p_s_chk_path,
                         const struct super_block  * p_s_sb
                       ) {
@@ -802,7 +802,7 @@ io_error:
        {
            int pos = p_s_last_element->pe_position;
            int limit = B_NR_ITEMS(p_s_bh);
-           struct reiserfs_key *le_key;
+           struct key *le_key;
 
            if (p_s_search_path->reada & PATH_READA_BACK)
                limit = 0;
@@ -1036,8 +1036,6 @@ static char  prepare_for_delete_or_cut(
     struct item_head    * p_le_ih = PATH_PITEM_HEAD(p_s_path);
     struct buffer_head  * p_s_bh = PATH_PLAST_BUFFER(p_s_path);
 
-    BUG_ON (!th->t_trans_id);
-
     /* Stat_data item. */
     if ( is_statdata_le_ih (p_le_ih) ) {
 
@@ -1224,9 +1222,6 @@ static void init_tb_struct(
     struct path         * p_s_path,
     int                   n_size
     ) {
-
-    BUG_ON (!th->t_trans_id);
-
     memset (p_s_tb,'\0',sizeof(struct tree_balance));
     p_s_tb->transaction_handle = th ;
     p_s_tb->tb_sb = p_s_sb;
@@ -1247,7 +1242,7 @@ void padd_item (char * item, int total_length, int length)
 }
 
 #ifdef REISERQUOTA_DEBUG
-char key2type(struct reiserfs_key *ih)
+char key2type(struct key *ih)
 {
   if (is_direntry_le_key(2, ih))
     return 'd';
@@ -1295,8 +1290,6 @@ int reiserfs_delete_item (struct reiserfs_transaction_handle *th,
     int                        n_iter = 0;
 #endif
 
-    BUG_ON (!th->t_trans_id);
-
     init_tb_struct(th, &s_del_balance, p_s_sb, p_s_path, 0/*size is unknown*/);
 
     while ( 1 ) {
@@ -1417,7 +1410,7 @@ int reiserfs_delete_item (struct reiserfs_transaction_handle *th,
 /* this deletes item which never gets split */
 void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
                                 struct inode *inode,
-                                struct reiserfs_key * key)
+                                struct key * key)
 {
     struct tree_balance tb;
     INITIALIZE_PATH (path);
@@ -1426,8 +1419,6 @@ void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
     struct cpu_key cpu_key;
     int retval;
     int quota_cut_bytes = 0;
-
-    BUG_ON (!th->t_trans_id);
     
     le_key2cpu_key (&cpu_key, key);
     
@@ -1483,16 +1474,12 @@ void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
 }
 
 
-int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * inode)
+void reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * inode)
 {
-    int err;
     inode->i_size = 0;
-    BUG_ON (!th->t_trans_id);
 
     /* for directory this deletes item containing "." and ".." */
-    err = reiserfs_do_truncate (th, inode, NULL, 0/*no timestamp updates*/);
-    if (err)
-        return err;
+    reiserfs_do_truncate (th, inode, NULL, 0/*no timestamp updates*/);
     
 #if defined( USE_INODE_GENERATION_COUNTER )
     if( !old_format_only ( th -> t_super ) )
@@ -1506,8 +1493,6 @@ int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode
 /* USE_INODE_GENERATION_COUNTER */
 #endif
     reiserfs_delete_solid_item (th, inode, INODE_PKEY (inode));
-
-    return err;
 }
 
 static void
@@ -1557,7 +1542,6 @@ static int maybe_indirect_to_direct (struct reiserfs_transaction_handle *th,
     struct super_block * p_s_sb = p_s_inode->i_sb;
     int n_block_size = p_s_sb->s_blocksize;
     int cut_bytes;
-    BUG_ON (!th->t_trans_id);
 
     if (n_new_file_size != p_s_inode->i_size)
        BUG ();
@@ -1590,7 +1574,6 @@ static void indirect_to_direct_roll_back (struct reiserfs_transaction_handle *th
     struct cpu_key tail_key;
     int tail_len;
     int removed;
-    BUG_ON (!th->t_trans_id);
 
     make_cpu_key (&tail_key, inode, inode->i_size + 1, TYPE_DIRECT, 4);// !!!!
     tail_key.key_length = 4;
@@ -1640,8 +1623,6 @@ int reiserfs_cut_from_item (struct reiserfs_transaction_handle *th,
     int retval2 = -1;
     int quota_cut_bytes;
     loff_t tail_pos = 0;
-
-    BUG_ON (!th->t_trans_id);
     
     init_tb_struct(th, &s_cut_balance, p_s_inode->i_sb, p_s_path, n_cut_size);
 
@@ -1794,7 +1775,6 @@ int reiserfs_cut_from_item (struct reiserfs_transaction_handle *th,
 
 static void truncate_directory (struct reiserfs_transaction_handle *th, struct inode * inode)
 {
-    BUG_ON (!th->t_trans_id);
     if (inode->i_nlink)
        reiserfs_warning (inode->i_sb,
                          "vs-5655: truncate_directory: link count != 0");
@@ -1812,7 +1792,7 @@ static void truncate_directory (struct reiserfs_transaction_handle *th, struct i
 
 /* Truncate file to the new size. Note, this must be called with a transaction
    already started */
-int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
+void reiserfs_do_truncate (struct reiserfs_transaction_handle *th, 
                           struct  inode * p_s_inode, /* ->i_size contains new
                                                          size */
                           struct page *page, /* up to date for last block */
@@ -1828,16 +1808,14 @@ int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
        n_new_file_size;/* New file size. */
     int                   n_deleted;      /* Number of deleted or truncated bytes. */
     int retval;
-    int err = 0;
 
-    BUG_ON (!th->t_trans_id);
     if ( ! (S_ISREG(p_s_inode->i_mode) || S_ISDIR(p_s_inode->i_mode) || S_ISLNK(p_s_inode->i_mode)) )
-       return 0;
+       return;
 
     if (S_ISDIR(p_s_inode->i_mode)) {
        // deletion of directory - no need to update timestamps
        truncate_directory (th, p_s_inode);
-       return 0;
+       return;
     }
 
     /* Get new file size. */
@@ -1850,15 +1828,13 @@ int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
     if (retval == IO_ERROR) {
        reiserfs_warning (p_s_inode->i_sb, "vs-5657: reiserfs_do_truncate: "
                          "i/o failure occurred trying to truncate %K", &s_item_key);
-        err = -EIO;
-        goto out;
+       return;
     }
     if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
+       pathrelse (&s_search_path);
        reiserfs_warning (p_s_inode->i_sb, "PAP-5660: reiserfs_do_truncate: "
                          "wrong result %d of search for %K", retval, &s_item_key);
-
-        err = -EIO;
-        goto out;
+       return;
     }
 
     s_search_path.pos_in_item --;
@@ -1896,7 +1872,7 @@ int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
        if (n_deleted < 0) {
            reiserfs_warning (p_s_inode->i_sb, "vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed");
            reiserfs_check_path(&s_search_path) ;
-           return 0;
+           return;
        }
 
        RFALSE( n_deleted > n_file_size,
@@ -1926,13 +1902,8 @@ int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
          } 
          reiserfs_update_sd(th, p_s_inode) ;
 
-         err = journal_end(th, p_s_inode->i_sb, orig_len_alloc) ;
-         if (err)
-           goto out;
-         err = journal_begin (th, p_s_inode->i_sb,
-                               JOURNAL_PER_BALANCE_CNT * 6);
-         if (err)
-           goto out;
+         journal_end(th, p_s_inode->i_sb, orig_len_alloc) ;
+         journal_begin(th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 6) ;
          reiserfs_update_inode_transaction(p_s_inode) ;
        }
     } while ( n_file_size > ROUND_UP (n_new_file_size) &&
@@ -1949,9 +1920,7 @@ update_and_out:
     }
     reiserfs_update_sd (th, p_s_inode);
 
-out:
     pathrelse(&s_search_path) ;
-    return err;
 }
 
 
@@ -1994,8 +1963,6 @@ int reiserfs_paste_into_item (struct reiserfs_transaction_handle *th,
     int                 retval;
     int                        fs_gen;
 
-    BUG_ON (!th->t_trans_id);
-
     fs_gen = get_generation(inode->i_sb) ;
 
 #ifdef REISERQUOTA_DEBUG
@@ -2068,8 +2035,6 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
     int fs_gen = 0 ;
     int quota_bytes = 0 ;
 
-    BUG_ON (!th->t_trans_id);
-
     if (inode) {      /* Do we count quotas for item? */
        fs_gen = get_generation(inode->i_sb);
        quota_bytes = ih_item_len(p_s_ih);