Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / fs / reiserfs / namei.c
index e825f8b..cd11358 100644 (file)
 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) set_nlink(i, 1); }
 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
 
-// directory item contains array of entry headers. This performs
-// binary search through that array
+/*
+ * directory item contains array of entry headers. This performs
+ * binary search through that array
+ */
 static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
 {
        struct item_head *ih = de->de_ih;
@@ -31,7 +33,7 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
        int rbound, lbound, j;
 
        lbound = 0;
-       rbound = I_ENTRY_COUNT(ih) - 1;
+       rbound = ih_entry_count(ih) - 1;
 
        for (j = (rbound + lbound) / 2; lbound <= rbound;
             j = (rbound + lbound) / 2) {
@@ -43,7 +45,7 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
                        lbound = j + 1;
                        continue;
                }
-               // this is not name found, but matched third key component
+               /* this is not name found, but matched third key component */
                de->de_entry_num = j;
                return NAME_FOUND;
        }
@@ -52,17 +54,21 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
        return NAME_NOT_FOUND;
 }
 
-// comment?  maybe something like set de to point to what the path points to?
+/*
+ * comment?  maybe something like set de to point to what the path points to?
+ */
 static inline void set_de_item_location(struct reiserfs_dir_entry *de,
                                        struct treepath *path)
 {
        de->de_bh = get_last_bh(path);
-       de->de_ih = get_ih(path);
+       de->de_ih = tp_item_head(path);
        de->de_deh = B_I_DEH(de->de_bh, de->de_ih);
        de->de_item_num = PATH_LAST_POSITION(path);
 }
 
-// de_bh, de_ih, de_deh (points to first element of array), de_item_num is set
+/*
+ * de_bh, de_ih, de_deh (points to first element of array), de_item_num is set
+ */
 inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
 {
        struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
@@ -71,17 +77,17 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
 
        de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num);
        de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0);
-       de->de_name = B_I_PITEM(de->de_bh, de->de_ih) + deh_location(deh);
+       de->de_name = ih_item_body(de->de_bh, de->de_ih) + deh_location(deh);
        if (de->de_name[de->de_namelen - 1] == 0)
                de->de_namelen = strlen(de->de_name);
 }
 
-// what entry points to
+/* what entry points to */
 static inline void set_de_object_key(struct reiserfs_dir_entry *de)
 {
        BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih));
-       de->de_dir_id = deh_dir_id(&(de->de_deh[de->de_entry_num]));
-       de->de_objectid = deh_objectid(&(de->de_deh[de->de_entry_num]));
+       de->de_dir_id = deh_dir_id(&de->de_deh[de->de_entry_num]);
+       de->de_objectid = deh_objectid(&de->de_deh[de->de_entry_num]);
 }
 
 static inline void store_de_entry_key(struct reiserfs_dir_entry *de)
@@ -96,21 +102,20 @@ static inline void store_de_entry_key(struct reiserfs_dir_entry *de)
            le32_to_cpu(de->de_ih->ih_key.k_dir_id);
        de->de_entry_key.on_disk_key.k_objectid =
            le32_to_cpu(de->de_ih->ih_key.k_objectid);
-       set_cpu_key_k_offset(&(de->de_entry_key), deh_offset(deh));
-       set_cpu_key_k_type(&(de->de_entry_key), TYPE_DIRENTRY);
+       set_cpu_key_k_offset(&de->de_entry_key, deh_offset(deh));
+       set_cpu_key_k_type(&de->de_entry_key, TYPE_DIRENTRY);
 }
 
-/* We assign a key to each directory item, and place multiple entries
-in a single directory item.  A directory item has a key equal to the
-key of the first directory entry in it.
-
-This function first calls search_by_key, then, if item whose first
-entry matches is not found it looks for the entry inside directory
-item found by search_by_key. Fills the path to the entry, and to the
-entry position in the item
-
-*/
-
+/*
+ * We assign a key to each directory item, and place multiple entries in a
+ * single directory item.  A directory item has a key equal to the key of
+ * the first directory entry in it.
+
+ * This function first calls search_by_key, then, if item whose first entry
+ * matches is not found it looks for the entry inside directory item found
+ * by search_by_key. Fills the path to the entry, and to the entry position
+ * in the item
+ */
 /* The function is NOT SCHEDULE-SAFE! */
 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
                        struct treepath *path, struct reiserfs_dir_entry *de)
@@ -144,7 +149,7 @@ int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
 
 #ifdef CONFIG_REISERFS_CHECK
        if (!is_direntry_le_ih(de->de_ih) ||
-           COMP_SHORT_KEYS(&(de->de_ih->ih_key), key)) {
+           COMP_SHORT_KEYS(&de->de_ih->ih_key, key)) {
                print_block(de->de_bh, 0, -1, -1);
                reiserfs_panic(sb, "vs-7005", "found item %h is not directory "
                               "item or does not belong to the same directory "
@@ -152,12 +157,17 @@ int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
        }
 #endif                         /* CONFIG_REISERFS_CHECK */
 
-       /* binary search in directory item by third componen t of the
-          key. sets de->de_entry_num of de */
+       /*
+        * binary search in directory item by third component of the
+        * key. sets de->de_entry_num of de
+        */
        retval = bin_search_in_dir_item(de, cpu_key_k_offset(key));
        path->pos_in_item = de->de_entry_num;
        if (retval != NAME_NOT_FOUND) {
-               // ugly, but rename needs de_bh, de_deh, de_name, de_namelen, de_objectid set
+               /*
+                * ugly, but rename needs de_bh, de_deh, de_name,
+                * de_namelen, de_objectid set
+                */
                set_de_name_and_namelen(de);
                set_de_object_key(de);
        }
@@ -166,11 +176,12 @@ int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
 
 /* Keyed 32-bit hash function using TEA in a Davis-Meyer function */
 
-/* The third component is hashed, and you can choose from more than
-   one hash function.  Per directory hashes are not yet implemented
-   but are thought about. This function should be moved to hashes.c
-   Jedi, please do so.  -Hans */
-
+/*
+ * The third component is hashed, and you can choose from more than
+ * one hash function.  Per directory hashes are not yet implemented
+ * but are thought about. This function should be moved to hashes.c
+ * Jedi, please do so.  -Hans
+ */
 static __u32 get_third_component(struct super_block *s,
                                 const char *name, int len)
 {
@@ -183,11 +194,13 @@ static __u32 get_third_component(struct super_block *s,
 
        res = REISERFS_SB(s)->s_hash_function(name, len);
 
-       // take bits from 7-th to 30-th including both bounds
+       /* take bits from 7-th to 30-th including both bounds */
        res = GET_HASH_VALUE(res);
        if (res == 0)
-               // needed to have no names before "." and ".." those have hash
-               // value == 0 and generation conters 1 and 2 accordingly
+               /*
+                * needed to have no names before "." and ".." those have hash
+                * value == 0 and generation conters 1 and 2 accordingly
+                */
                res = 128;
        return res + MAX_GENERATION_NUMBER;
 }
@@ -208,7 +221,7 @@ static int reiserfs_match(struct reiserfs_dir_entry *de,
 
 /* de's de_bh, de_ih, de_deh, de_item_num, de_entry_num are set already */
 
-                               /* used when hash collisions exist */
+/* used when hash collisions exist */
 
 static int linear_search_in_dir_item(struct cpu_key *key,
                                     struct reiserfs_dir_entry *de,
@@ -220,7 +233,7 @@ static int linear_search_in_dir_item(struct cpu_key *key,
 
        i = de->de_entry_num;
 
-       if (i == I_ENTRY_COUNT(de->de_ih) ||
+       if (i == ih_entry_count(de->de_ih) ||
            GET_HASH_VALUE(deh_offset(deh + i)) !=
            GET_HASH_VALUE(cpu_key_k_offset(key))) {
                i--;
@@ -232,43 +245,50 @@ static int linear_search_in_dir_item(struct cpu_key *key,
        deh += i;
 
        for (; i >= 0; i--, deh--) {
+               /* hash value does not match, no need to check whole name */
                if (GET_HASH_VALUE(deh_offset(deh)) !=
                    GET_HASH_VALUE(cpu_key_k_offset(key))) {
-                       // hash value does not match, no need to check whole name
                        return NAME_NOT_FOUND;
                }
 
-               /* mark, that this generation number is used */
+               /* mark that this generation number is used */
                if (de->de_gen_number_bit_string)
                        set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
                                de->de_gen_number_bit_string);
 
-               // calculate pointer to name and namelen
+               /* calculate pointer to name and namelen */
                de->de_entry_num = i;
                set_de_name_and_namelen(de);
 
+               /*
+                * de's de_name, de_namelen, de_recordlen are set.
+                * Fill the rest.
+                */
                if ((retval =
                     reiserfs_match(de, name, namelen)) != NAME_NOT_FOUND) {
-                       // de's de_name, de_namelen, de_recordlen are set. Fill the rest:
 
-                       // key of pointed object
+                       /* key of pointed object */
                        set_de_object_key(de);
 
                        store_de_entry_key(de);
 
-                       // retval can be NAME_FOUND or NAME_FOUND_INVISIBLE
+                       /* retval can be NAME_FOUND or NAME_FOUND_INVISIBLE */
                        return retval;
                }
        }
 
        if (GET_GENERATION_NUMBER(le_ih_k_offset(de->de_ih)) == 0)
-               /* we have reached left most entry in the node. In common we
-                  have to go to the left neighbor, but if generation counter
-                  is 0 already, we know for sure, that there is no name with
-                  the same hash value */
-               // FIXME: this work correctly only because hash value can not
-               // be 0. Btw, in case of Yura's hash it is probably possible,
-               // so, this is a bug
+               /*
+                * we have reached left most entry in the node. In common we
+                * have to go to the left neighbor, but if generation counter
+                * is 0 already, we know for sure, that there is no name with
+                * the same hash value
+                */
+               /*
+                * FIXME: this work correctly only because hash value can not
+                *  be 0. Btw, in case of Yura's hash it is probably possible,
+                * so, this is a bug
+                */
                return NAME_NOT_FOUND;
 
        RFALSE(de->de_item_num,
@@ -277,8 +297,10 @@ static int linear_search_in_dir_item(struct cpu_key *key,
        return GOTO_PREVIOUS_ITEM;
 }
 
-// may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
-// FIXME: should add something like IOERROR
+/*
+ * may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
+ * FIXME: should add something like IOERROR
+ */
 static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
                               struct treepath *path_to_entry,
                               struct reiserfs_dir_entry *de)
@@ -307,13 +329,19 @@ static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
                retval =
                    linear_search_in_dir_item(&key_to_search, de, name,
                                              namelen);
+               /*
+                * there is no need to scan directory anymore.
+                * Given entry found or does not exist
+                */
                if (retval != GOTO_PREVIOUS_ITEM) {
-                       /* there is no need to scan directory anymore. Given entry found or does not exist */
                        path_to_entry->pos_in_item = de->de_entry_num;
                        return retval;
                }
 
-               /* there is left neighboring item of this directory and given entry can be there */
+               /*
+                * there is left neighboring item of this directory
+                * and given entry can be there
+                */
                set_cpu_key_k_offset(&key_to_search,
                                     le_ih_k_offset(de->de_ih) - 1);
                pathrelse(path_to_entry);
@@ -341,14 +369,16 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
        pathrelse(&path_to_entry);
        if (retval == NAME_FOUND) {
                inode = reiserfs_iget(dir->i_sb,
-                                     (struct cpu_key *)&(de.de_dir_id));
+                                     (struct cpu_key *)&de.de_dir_id);
                if (!inode || IS_ERR(inode)) {
                        reiserfs_write_unlock(dir->i_sb);
                        return ERR_PTR(-EACCES);
                }
 
-               /* Propagate the private flag so we know we're
-                * in the priv tree */
+               /*
+                * Propagate the private flag so we know we're
+                * in the priv tree
+                */
                if (IS_PRIVATE(dir))
                        inode->i_flags |= S_PRIVATE;
        }
@@ -361,9 +391,9 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
 }
 
 /*
-** looks up the dentry of the parent directory for child.
-** taken from ext2_get_parent
-*/
+ * looks up the dentry of the parent directory for child.
+ * taken from ext2_get_parent
+ */
 struct dentry *reiserfs_get_parent(struct dentry *child)
 {
        int retval;
@@ -384,7 +414,7 @@ struct dentry *reiserfs_get_parent(struct dentry *child)
                reiserfs_write_unlock(dir->i_sb);
                return ERR_PTR(-ENOENT);
        }
-       inode = reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
+       inode = reiserfs_iget(dir->i_sb, (struct cpu_key *)&de.de_dir_id);
        reiserfs_write_unlock(dir->i_sb);
 
        return d_obtain_alias(inode);
@@ -406,8 +436,13 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
        struct reiserfs_dir_entry de;
        DECLARE_BITMAP(bit_string, MAX_GENERATION_NUMBER + 1);
        int gen_number;
-       char small_buf[32 + DEH_SIZE];  /* 48 bytes now and we avoid kmalloc
-                                          if we create file with short name */
+
+       /*
+        * 48 bytes now and we avoid kmalloc if we
+        * create file with short name
+        */
+       char small_buf[32 + DEH_SIZE];
+
        char *buffer;
        int buflen, paste_size;
        int retval;
@@ -439,21 +474,30 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
            (get_inode_sd_version(dir) ==
             STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
 
-       /* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
+       /*
+        * fill buffer : directory entry head, name[, dir objectid | ,
+        * stat data | ,stat data, dir objectid ]
+        */
        deh = (struct reiserfs_de_head *)buffer;
        deh->deh_location = 0;  /* JDM Endian safe if 0 */
        put_deh_offset(deh, cpu_key_k_offset(&entry_key));
        deh->deh_state = 0;     /* JDM Endian safe if 0 */
        /* put key (ino analog) to de */
-       deh->deh_dir_id = INODE_PKEY(inode)->k_dir_id;  /* safe: k_dir_id is le */
-       deh->deh_objectid = INODE_PKEY(inode)->k_objectid;      /* safe: k_objectid is le */
+
+       /* safe: k_dir_id is le */
+       deh->deh_dir_id = INODE_PKEY(inode)->k_dir_id;
+       /* safe: k_objectid is le */
+       deh->deh_objectid = INODE_PKEY(inode)->k_objectid;
 
        /* copy name */
        memcpy((char *)(deh + 1), name, namelen);
        /* padd by 0s to the 4 byte boundary */
        padd_item((char *)(deh + 1), ROUND_UP(namelen), namelen);
 
-       /* entry is ready to be pasted into tree, set 'visibility' and 'stat data in entry' attributes */
+       /*
+        * entry is ready to be pasted into tree, set 'visibility'
+        * and 'stat data in entry' attributes
+        */
        mark_de_without_sd(deh);
        visible ? mark_de_visible(deh) : mark_de_hidden(deh);
 
@@ -499,7 +543,8 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
        /* update max-hash-collisions counter in reiserfs_sb_info */
        PROC_INFO_MAX(th->t_super, max_hash_collisions, gen_number);
 
-       if (gen_number != 0) {  /* we need to re-search for the insertion point */
+       /* we need to re-search for the insertion point */
+       if (gen_number != 0) {
                if (search_by_entry_key(dir->i_sb, &entry_key, &path, &de) !=
                    NAME_NOT_FOUND) {
                        reiserfs_warning(dir->i_sb, "vs-7032",
@@ -527,18 +572,19 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
        dir->i_size += paste_size;
        dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
        if (!S_ISDIR(inode->i_mode) && visible)
-               // reiserfs_mkdir or reiserfs_rename will do that by itself
+               /* reiserfs_mkdir or reiserfs_rename will do that by itself */
                reiserfs_update_sd(th, dir);
 
        reiserfs_check_path(&path);
        return 0;
 }
 
-/* quota utility function, call if you've had to abort after calling
-** new_inode_init, and have not called reiserfs_new_inode yet.
-** This should only be called on inodes that do not have stat data
-** inserted into the tree yet.
-*/
+/*
+ * quota utility function, call if you've had to abort after calling
+ * new_inode_init, and have not called reiserfs_new_inode yet.
+ * This should only be called on inodes that do not have stat data
+ * inserted into the tree yet.
+ */
 static int drop_new_inode(struct inode *inode)
 {
        dquot_drop(inode);
@@ -548,18 +594,23 @@ static int drop_new_inode(struct inode *inode)
        return 0;
 }
 
-/* utility function that does setup for reiserfs_new_inode.
-** dquot_initialize needs lots of credits so it's better to have it
-** outside of a transaction, so we had to pull some bits of
-** reiserfs_new_inode out into this func.
-*/
+/*
+ * utility function that does setup for reiserfs_new_inode.
+ * dquot_initialize needs lots of credits so it's better to have it
+ * outside of a transaction, so we had to pull some bits of
+ * reiserfs_new_inode out into this func.
+ */
 static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode)
 {
-       /* Make inode invalid - just in case we are going to drop it before
-        * the initialization happens */
+       /*
+        * Make inode invalid - just in case we are going to drop it before
+        * the initialization happens
+        */
        INODE_PKEY(inode)->k_objectid = 0;
-       /* the quota init calls have to know who to charge the quota to, so
-        ** we have to set uid and gid here
+
+       /*
+        * the quota init calls have to know who to charge the quota to, so
+        * we have to set uid and gid here
         */
        inode_init_owner(inode, dir, mode);
        dquot_initialize(inode);
@@ -571,7 +622,10 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mod
 {
        int retval;
        struct inode *inode;
-       /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+       /*
+        * We need blocks for transaction + (user+group)*(quotas
+        * for new inode + update of quota for directory owner)
+        */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 2 +
            2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
@@ -618,7 +672,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mod
                int err;
                drop_nlink(inode);
                reiserfs_update_sd(&th, inode);
-               err = journal_end(&th, dir->i_sb, jbegin_count);
+               err = journal_end(&th);
                if (err)
                        retval = err;
                unlock_new_inode(inode);
@@ -630,9 +684,9 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mod
 
        unlock_new_inode(inode);
        d_instantiate(dentry, inode);
-       retval = journal_end(&th, dir->i_sb, jbegin_count);
+       retval = journal_end(&th);
 
-      out_failed:
+out_failed:
        reiserfs_write_unlock(dir->i_sb);
        return retval;
 }
@@ -644,7 +698,10 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode
        struct inode *inode;
        struct reiserfs_transaction_handle th;
        struct reiserfs_security_handle security;
-       /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+       /*
+        * We need blocks for transaction + (user+group)*(quotas
+        * for new inode + update of quota for directory owner)
+        */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
            2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
@@ -685,7 +742,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode
        inode->i_op = &reiserfs_special_inode_operations;
        init_special_inode(inode, inode->i_mode, rdev);
 
-       //FIXME: needed for block and char devices only
+       /* FIXME: needed for block and char devices only */
        reiserfs_update_sd(&th, inode);
 
        reiserfs_update_inode_transaction(inode);
@@ -698,7 +755,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode
                int err;
                drop_nlink(inode);
                reiserfs_update_sd(&th, inode);
-               err = journal_end(&th, dir->i_sb, jbegin_count);
+               err = journal_end(&th);
                if (err)
                        retval = err;
                unlock_new_inode(inode);
@@ -708,9 +765,9 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode
 
        unlock_new_inode(inode);
        d_instantiate(dentry, inode);
-       retval = journal_end(&th, dir->i_sb, jbegin_count);
+       retval = journal_end(&th);
 
-      out_failed:
+out_failed:
        reiserfs_write_unlock(dir->i_sb);
        return retval;
 }
@@ -721,7 +778,10 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
        struct inode *inode;
        struct reiserfs_transaction_handle th;
        struct reiserfs_security_handle security;
-       /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+       /*
+        * We need blocks for transaction + (user+group)*(quotas
+        * for new inode + update of quota for directory owner)
+        */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
            2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
@@ -730,7 +790,10 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
        dquot_initialize(dir);
 
 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
-       /* set flag that new packing locality created and new blocks for the content     * of that directory are not displaced yet */
+       /*
+        * set flag that new packing locality created and new blocks
+        * for the content of that directory are not displaced yet
+        */
        REISERFS_I(dir)->new_packing_locality = 1;
 #endif
        mode = S_IFDIR | mode;
@@ -754,8 +817,9 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
                goto out_failed;
        }
 
-       /* inc the link count now, so another writer doesn't overflow it while
-        ** we sleep later on.
+       /*
+        * inc the link count now, so another writer doesn't overflow
+        * it while we sleep later on.
         */
        INC_DIR_INODE_NLINK(dir)
 
@@ -774,7 +838,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
        inode->i_op = &reiserfs_dir_inode_operations;
        inode->i_fop = &reiserfs_dir_operations;
 
-       // note, _this_ add_entry will not update dir's stat data
+       /* note, _this_ add_entry will not update dir's stat data */
        retval =
            reiserfs_add_entry(&th, dir, dentry->d_name.name,
                               dentry->d_name.len, inode, 1 /*visible */ );
@@ -783,19 +847,19 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
                clear_nlink(inode);
                DEC_DIR_INODE_NLINK(dir);
                reiserfs_update_sd(&th, inode);
-               err = journal_end(&th, dir->i_sb, jbegin_count);
+               err = journal_end(&th);
                if (err)
                        retval = err;
                unlock_new_inode(inode);
                iput(inode);
                goto out_failed;
        }
-       // the above add_entry did not update dir's stat data
+       /* the above add_entry did not update dir's stat data */
        reiserfs_update_sd(&th, dir);
 
        unlock_new_inode(inode);
        d_instantiate(dentry, inode);
-       retval = journal_end(&th, dir->i_sb, jbegin_count);
+       retval = journal_end(&th);
 out_failed:
        reiserfs_write_unlock(dir->i_sb);
        return retval;
@@ -803,10 +867,11 @@ out_failed:
 
 static inline int reiserfs_empty_dir(struct inode *inode)
 {
-       /* we can cheat because an old format dir cannot have
-        ** EMPTY_DIR_SIZE, and a new format dir cannot have
-        ** EMPTY_DIR_SIZE_V1.  So, if the inode is either size,
-        ** regardless of disk format version, the directory is empty.
+       /*
+        * we can cheat because an old format dir cannot have
+        * EMPTY_DIR_SIZE, and a new format dir cannot have
+        * EMPTY_DIR_SIZE_V1.  So, if the inode is either size,
+        * regardless of disk format version, the directory is empty.
         */
        if (inode->i_size != EMPTY_DIR_SIZE &&
            inode->i_size != EMPTY_DIR_SIZE_V1) {
@@ -824,10 +889,12 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
        INITIALIZE_PATH(path);
        struct reiserfs_dir_entry de;
 
-       /* we will be doing 2 balancings and update 2 stat data, we change quotas
-        * of the owner of the directory and of the owner of the parent directory.
-        * The quota structure is possibly deleted only on last iput => outside
-        * of this transaction */
+       /*
+        * we will be doing 2 balancings and update 2 stat data, we
+        * change quotas of the owner of the directory and of the owner
+        * of the parent directory.  The quota structure is possibly
+        * deleted only on last iput => outside of this transaction
+        */
        jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 2 + 2 +
            4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
@@ -856,8 +923,9 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
        reiserfs_update_inode_transaction(dir);
 
        if (de.de_objectid != inode->i_ino) {
-               // FIXME: compare key of an object and a key found in the
-               // entry
+               /*
+                * FIXME: compare key of an object and a key found in the entry
+                */
                retval = -EIO;
                goto end_rmdir;
        }
@@ -867,7 +935,8 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
        }
 
        /* cut entry from dir directory */
-       retval = reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL,      /* page */
+       retval = reiserfs_cut_from_item(&th, &path, &de.de_entry_key,
+                                       dir, NULL,      /* page */
                                        0 /*new file size - not used here */ );
        if (retval < 0)
                goto end_rmdir;
@@ -888,18 +957,20 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
        /* prevent empty directory from getting lost */
        add_save_link(&th, inode, 0 /* not truncate */ );
 
-       retval = journal_end(&th, dir->i_sb, jbegin_count);
+       retval = journal_end(&th);
        reiserfs_check_path(&path);
-      out_rmdir:
+out_rmdir:
        reiserfs_write_unlock(dir->i_sb);
        return retval;
 
-      end_rmdir:
-       /* we must release path, because we did not call
-          reiserfs_cut_from_item, or reiserfs_cut_from_item does not
-          release path if operation was not complete */
+end_rmdir:
+       /*
+        * we must release path, because we did not call
+        * reiserfs_cut_from_item, or reiserfs_cut_from_item does not
+        * release path if operation was not complete
+        */
        pathrelse(&path);
-       err = journal_end(&th, dir->i_sb, jbegin_count);
+       err = journal_end(&th);
        reiserfs_write_unlock(dir->i_sb);
        return err ? err : retval;
 }
@@ -918,10 +989,13 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
 
        inode = dentry->d_inode;
 
-       /* in this transaction we can be doing at max two balancings and update
-        * two stat datas, we change quotas of the owner of the directory and of
-        * the owner of the parent directory. The quota structure is possibly
-        * deleted only on iput => outside of this transaction */
+       /*
+        * in this transaction we can be doing at max two balancings and
+        * update two stat datas, we change quotas of the owner of the
+        * directory and of the owner of the parent directory. The quota
+        * structure is possibly deleted only on iput => outside of
+        * this transaction
+        */
        jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 2 + 2 +
            4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
@@ -946,8 +1020,9 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
        reiserfs_update_inode_transaction(dir);
 
        if (de.de_objectid != inode->i_ino) {
-               // FIXME: compare key of an object and a key found in the
-               // entry
+               /*
+                * FIXME: compare key of an object and a key found in the entry
+                */
                retval = -EIO;
                goto end_unlink;
        }
@@ -968,7 +1043,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
        savelink = inode->i_nlink;
 
        retval =
-           reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL,
+           reiserfs_cut_from_item(&th, &path, &de.de_entry_key, dir, NULL,
                                   0);
        if (retval < 0) {
                inc_nlink(inode);
@@ -985,18 +1060,18 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
                /* prevent file from getting lost */
                add_save_link(&th, inode, 0 /* not truncate */ );
 
-       retval = journal_end(&th, dir->i_sb, jbegin_count);
+       retval = journal_end(&th);
        reiserfs_check_path(&path);
        reiserfs_write_unlock(dir->i_sb);
        return retval;
 
-      end_unlink:
+end_unlink:
        pathrelse(&path);
-       err = journal_end(&th, dir->i_sb, jbegin_count);
+       err = journal_end(&th);
        reiserfs_check_path(&path);
        if (err)
                retval = err;
-      out_unlink:
+out_unlink:
        reiserfs_write_unlock(dir->i_sb);
        return retval;
 }
@@ -1011,7 +1086,10 @@ static int reiserfs_symlink(struct inode *parent_dir,
        struct reiserfs_transaction_handle th;
        struct reiserfs_security_handle security;
        int mode = S_IFLNK | S_IRWXUGO;
-       /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+       /*
+        * We need blocks for transaction + (user+group)*(quotas for
+        * new inode + update of quota for directory owner)
+        */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
            2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
@@ -1070,17 +1148,13 @@ static int reiserfs_symlink(struct inode *parent_dir,
        inode->i_op = &reiserfs_symlink_inode_operations;
        inode->i_mapping->a_ops = &reiserfs_address_space_operations;
 
-       // must be sure this inode is written with this transaction
-       //
-       //reiserfs_update_sd (&th, inode, READ_BLOCKS);
-
        retval = reiserfs_add_entry(&th, parent_dir, dentry->d_name.name,
                                    dentry->d_name.len, inode, 1 /*visible */ );
        if (retval) {
                int err;
                drop_nlink(inode);
                reiserfs_update_sd(&th, inode);
-               err = journal_end(&th, parent_dir->i_sb, jbegin_count);
+               err = journal_end(&th);
                if (err)
                        retval = err;
                unlock_new_inode(inode);
@@ -1090,8 +1164,8 @@ static int reiserfs_symlink(struct inode *parent_dir,
 
        unlock_new_inode(inode);
        d_instantiate(dentry, inode);
-       retval = journal_end(&th, parent_dir->i_sb, jbegin_count);
-      out_failed:
+       retval = journal_end(&th);
+out_failed:
        reiserfs_write_unlock(parent_dir->i_sb);
        return retval;
 }
@@ -1102,7 +1176,10 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
        int retval;
        struct inode *inode = old_dentry->d_inode;
        struct reiserfs_transaction_handle th;
-       /* We need blocks for transaction + update of quotas for the owners of the directory */
+       /*
+        * We need blocks for transaction + update of quotas for
+        * the owners of the directory
+        */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
            2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
@@ -1111,7 +1188,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
 
        reiserfs_write_lock(dir->i_sb);
        if (inode->i_nlink >= REISERFS_LINK_MAX) {
-               //FIXME: sd_nlink is 32 bit for new files
+               /* FIXME: sd_nlink is 32 bit for new files */
                reiserfs_write_unlock(dir->i_sb);
                return -EMLINK;
        }
@@ -1137,7 +1214,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
        if (retval) {
                int err;
                drop_nlink(inode);
-               err = journal_end(&th, dir->i_sb, jbegin_count);
+               err = journal_end(&th);
                reiserfs_write_unlock(dir->i_sb);
                return err ? err : retval;
        }
@@ -1147,7 +1224,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
 
        ihold(inode);
        d_instantiate(dentry, inode);
-       retval = journal_end(&th, dir->i_sb, jbegin_count);
+       retval = journal_end(&th);
        reiserfs_write_unlock(dir->i_sb);
        return retval;
 }
@@ -1158,9 +1235,9 @@ static int de_still_valid(const char *name, int len,
 {
        struct reiserfs_dir_entry tmp = *de;
 
-       // recalculate pointer to name and name length
+       /* recalculate pointer to name and name length */
        set_de_name_and_namelen(&tmp);
-       // FIXME: could check more
+       /* FIXME: could check more */
        if (tmp.de_namelen != len || memcmp(name, de->de_name, len))
                return 0;
        return 1;
@@ -1217,14 +1294,16 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        unsigned long savelink = 1;
        struct timespec ctime;
 
-       /* three balancings: (1) old name removal, (2) new name insertion
-          and (3) maybe "save" link insertion
-          stat data updates: (1) old directory,
-          (2) new directory and (3) maybe old object stat data (when it is
-          directory) and (4) maybe stat data of object to which new entry
-          pointed initially and (5) maybe block containing ".." of
-          renamed directory
-          quota updates: two parent directories */
+       /*
+        * three balancings: (1) old name removal, (2) new name insertion
+        * and (3) maybe "save" link insertion
+        * stat data updates: (1) old directory,
+        * (2) new directory and (3) maybe old object stat data (when it is
+        * directory) and (4) maybe stat data of object to which new entry
+        * pointed initially and (5) maybe block containing ".." of
+        * renamed directory
+        * quota updates: two parent directories
+        */
        jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 + 5 +
            4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
@@ -1235,8 +1314,10 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        old_inode = old_dentry->d_inode;
        new_dentry_inode = new_dentry->d_inode;
 
-       // make sure, that oldname still exists and points to an object we
-       // are going to rename
+       /*
+        * make sure that oldname still exists and points to an object we
+        * are going to rename
+        */
        old_de.de_gen_number_bit_string = NULL;
        reiserfs_write_lock(old_dir->i_sb);
        retval =
@@ -1256,10 +1337,11 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
        old_inode_mode = old_inode->i_mode;
        if (S_ISDIR(old_inode_mode)) {
-               // make sure, that directory being renamed has correct ".."
-               // and that its new parent directory has not too many links
-               // already
-
+               /*
+                * make sure that directory being renamed has correct ".."
+                * and that its new parent directory has not too many links
+                * already
+                */
                if (new_dentry_inode) {
                        if (!reiserfs_empty_dir(new_dentry_inode)) {
                                reiserfs_write_unlock(old_dir->i_sb);
@@ -1267,8 +1349,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        }
                }
 
-               /* directory is renamed, its parent directory will be changed,
-                ** so find ".." entry
+               /*
+                * directory is renamed, its parent directory will be changed,
+                * so find ".." entry
                 */
                dot_dot_de.de_gen_number_bit_string = NULL;
                retval =
@@ -1303,7 +1386,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                                       "new entry is found, new inode == 0");
                }
        } else if (retval) {
-               int err = journal_end(&th, old_dir->i_sb, jbegin_count);
+               int err = journal_end(&th);
                reiserfs_write_unlock(old_dir->i_sb);
                return err ? err : retval;
        }
@@ -1311,8 +1394,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        reiserfs_update_inode_transaction(old_dir);
        reiserfs_update_inode_transaction(new_dir);
 
-       /* this makes it so an fsync on an open fd for the old name will
-        ** commit the rename operation
+       /*
+        * this makes it so an fsync on an open fd for the old name will
+        * commit the rename operation
         */
        reiserfs_update_inode_transaction(old_inode);
 
@@ -1320,38 +1404,45 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                reiserfs_update_inode_transaction(new_dentry_inode);
 
        while (1) {
-               // look for old name using corresponding entry key (found by reiserfs_find_entry)
+               /*
+                * look for old name using corresponding entry key
+                * (found by reiserfs_find_entry)
+                */
                if ((retval =
                     search_by_entry_key(new_dir->i_sb, &old_de.de_entry_key,
                                         &old_entry_path,
                                         &old_de)) != NAME_FOUND) {
                        pathrelse(&old_entry_path);
-                       journal_end(&th, old_dir->i_sb, jbegin_count);
+                       journal_end(&th);
                        reiserfs_write_unlock(old_dir->i_sb);
                        return -EIO;
                }
 
-               copy_item_head(&old_entry_ih, get_ih(&old_entry_path));
+               copy_item_head(&old_entry_ih, tp_item_head(&old_entry_path));
 
                reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1);
 
-               // look for new name by reiserfs_find_entry
+               /* look for new name by reiserfs_find_entry */
                new_de.de_gen_number_bit_string = NULL;
                retval =
                    reiserfs_find_entry(new_dir, new_dentry->d_name.name,
                                        new_dentry->d_name.len, &new_entry_path,
                                        &new_de);
-               // reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from
-               // reiserfs_add_entry above, and we'll catch any i/o errors before we get here.
+               /*
+                * reiserfs_add_entry should not return IO_ERROR,
+                * because it is called with essentially same parameters from
+                * reiserfs_add_entry above, and we'll catch any i/o errors
+                * before we get here.
+                */
                if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {
                        pathrelse(&new_entry_path);
                        pathrelse(&old_entry_path);
-                       journal_end(&th, old_dir->i_sb, jbegin_count);
+                       journal_end(&th);
                        reiserfs_write_unlock(old_dir->i_sb);
                        return -EIO;
                }
 
-               copy_item_head(&new_entry_ih, get_ih(&new_entry_path));
+               copy_item_head(&new_entry_ih, tp_item_head(&new_entry_path));
 
                reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1);
 
@@ -1364,28 +1455,32 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                                pathrelse(&dot_dot_entry_path);
                                pathrelse(&new_entry_path);
                                pathrelse(&old_entry_path);
-                               journal_end(&th, old_dir->i_sb, jbegin_count);
+                               journal_end(&th);
                                reiserfs_write_unlock(old_dir->i_sb);
                                return -EIO;
                        }
                        copy_item_head(&dot_dot_ih,
-                                      get_ih(&dot_dot_entry_path));
-                       // node containing ".." gets into transaction
+                                      tp_item_head(&dot_dot_entry_path));
+                       /* node containing ".." gets into transaction */
                        reiserfs_prepare_for_journal(old_inode->i_sb,
                                                     dot_dot_de.de_bh, 1);
                }
-               /* we should check seals here, not do
-                  this stuff, yes? Then, having
-                  gathered everything into RAM we
-                  should lock the buffers, yes?  -Hans */
-               /* probably.  our rename needs to hold more
-                ** than one path at once.  The seals would
-                ** have to be written to deal with multi-path
-                ** issues -chris
+               /*
+                * we should check seals here, not do
+                * this stuff, yes? Then, having
+                * gathered everything into RAM we
+                * should lock the buffers, yes?  -Hans
+                */
+               /*
+                * probably.  our rename needs to hold more
+                * than one path at once.  The seals would
+                * have to be written to deal with multi-path
+                * issues -chris
                 */
-               /* sanity checking before doing the rename - avoid races many
-                ** of the above checks could have scheduled.  We have to be
-                ** sure our items haven't been shifted by another process.
+               /*
+                * sanity checking before doing the rename - avoid races many
+                * of the above checks could have scheduled.  We have to be
+                * sure our items haven't been shifted by another process.
                 */
                if (item_moved(&new_entry_ih, &new_entry_path) ||
                    !entry_points_to_object(new_dentry->d_name.name,
@@ -1430,24 +1525,28 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                break;
        }
 
-       /* ok, all the changes can be done in one fell swoop when we
-          have claimed all the buffers needed. */
+       /*
+        * ok, all the changes can be done in one fell swoop when we
+        * have claimed all the buffers needed.
+        */
 
        mark_de_visible(new_de.de_deh + new_de.de_entry_num);
        set_ino_in_dir_entry(&new_de, INODE_PKEY(old_inode));
-       journal_mark_dirty(&th, old_dir->i_sb, new_de.de_bh);
+       journal_mark_dirty(&th, new_de.de_bh);
 
        mark_de_hidden(old_de.de_deh + old_de.de_entry_num);
-       journal_mark_dirty(&th, old_dir->i_sb, old_de.de_bh);
+       journal_mark_dirty(&th, old_de.de_bh);
        ctime = CURRENT_TIME_SEC;
        old_dir->i_ctime = old_dir->i_mtime = ctime;
        new_dir->i_ctime = new_dir->i_mtime = ctime;
-       /* thanks to Alex Adriaanse <alex_a@caltech.edu> for patch which adds ctime update of
-          renamed object */
+       /*
+        * thanks to Alex Adriaanse <alex_a@caltech.edu> for patch
+        * which adds ctime update of renamed object
+        */
        old_inode->i_ctime = ctime;
 
        if (new_dentry_inode) {
-               // adjust link number of the victim
+               /* adjust link number of the victim */
                if (S_ISDIR(new_dentry_inode->i_mode)) {
                        clear_nlink(new_dentry_inode);
                } else {
@@ -1460,25 +1559,32 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        if (S_ISDIR(old_inode_mode)) {
                /* adjust ".." of renamed directory */
                set_ino_in_dir_entry(&dot_dot_de, INODE_PKEY(new_dir));
-               journal_mark_dirty(&th, new_dir->i_sb, dot_dot_de.de_bh);
+               journal_mark_dirty(&th, dot_dot_de.de_bh);
 
+               /*
+                * there (in new_dir) was no directory, so it got new link
+                * (".."  of renamed directory)
+                */
                if (!new_dentry_inode)
-                       /* there (in new_dir) was no directory, so it got new link
-                          (".."  of renamed directory) */
                        INC_DIR_INODE_NLINK(new_dir);
 
                /* old directory lost one link - ".. " of renamed directory */
                DEC_DIR_INODE_NLINK(old_dir);
        }
-       // looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse
+       /*
+        * looks like in 2.3.99pre3 brelse is atomic.
+        * so we can use pathrelse
+        */
        pathrelse(&new_entry_path);
        pathrelse(&dot_dot_entry_path);
 
-       // FIXME: this reiserfs_cut_from_item's return value may screw up
-       // anybody, but it will panic if will not be able to find the
-       // entry. This needs one more clean up
+       /*
+        * FIXME: this reiserfs_cut_from_item's return value may screw up
+        * anybody, but it will panic if will not be able to find the
+        * entry. This needs one more clean up
+        */
        if (reiserfs_cut_from_item
-           (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL,
+           (&th, &old_entry_path, &old_de.de_entry_key, old_dir, NULL,
             0) < 0)
                reiserfs_error(old_dir->i_sb, "vs-7060",
                               "couldn't not cut old name. Fsck later?");
@@ -1496,16 +1602,13 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                reiserfs_update_sd(&th, new_dentry_inode);
        }
 
-       retval = journal_end(&th, old_dir->i_sb, jbegin_count);
+       retval = journal_end(&th);
        reiserfs_write_unlock(old_dir->i_sb);
        return retval;
 }
 
-/*
- * directories can handle most operations...
- */
+/* directories can handle most operations...  */
 const struct inode_operations reiserfs_dir_inode_operations = {
-       //&reiserfs_dir_operations,   /* default_file_ops */
        .create = reiserfs_create,
        .lookup = reiserfs_lookup,
        .link = reiserfs_link,