Merge branch 'reiserfs-updates' from Jeff Mahoney
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 30 Mar 2009 19:29:21 +0000 (12:29 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 30 Mar 2009 19:33:01 +0000 (12:33 -0700)
* reiserfs-updates: (35 commits)
  reiserfs: rename [cn]_* variables
  reiserfs: rename p_._ variables
  reiserfs: rename p_s_tb to tb
  reiserfs: rename p_s_inode to inode
  reiserfs: rename p_s_bh to bh
  reiserfs: rename p_s_sb to sb
  reiserfs: strip trailing whitespace
  reiserfs: cleanup path functions
  reiserfs: factor out buffer_info initialization
  reiserfs: add atomic addition of selinux attributes during inode creation
  reiserfs: use generic readdir for operations across all xattrs
  reiserfs: journaled xattrs
  reiserfs: use generic xattr handlers
  reiserfs: remove i_has_xattr_dir
  reiserfs: make per-inode xattr locking more fine grained
  reiserfs: eliminate per-super xattr lock
  reiserfs: simplify xattr internal file lookups/opens
  reiserfs: Clean up xattrs when REISERFS_FS_XATTR is unset
  reiserfs: remove IS_PRIVATE helpers
  reiserfs: remove link detection code
  ...

Fixed up conflicts manually due to:
 - quota name cleanups vs variable naming changes:
fs/reiserfs/inode.c
fs/reiserfs/namei.c
fs/reiserfs/stree.c
        fs/reiserfs/xattr.c
 - exported include header cleanups
include/linux/reiserfs_fs.h

1  2 
fs/reiserfs/bitmap.c
fs/reiserfs/inode.c
fs/reiserfs/namei.c
fs/reiserfs/stree.c
fs/reiserfs/super.c
fs/reiserfs/xattr.c
include/linux/reiserfs_fs.h

diff --combined fs/reiserfs/bitmap.c
@@@ -40,8 -40,8 +40,8 @@@
  
  #define SET_OPTION(optname) \
     do { \
-         reiserfs_warning(s, "reiserfs: option \"%s\" is set", #optname); \
-         set_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s)); \
+       reiserfs_info(s, "block allocator option \"%s\" is set", #optname); \
+       set_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s)); \
      } while(0)
  #define TEST_OPTION(optname, s) \
      test_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s))
@@@ -64,9 -64,9 +64,9 @@@ int is_reusable(struct super_block *s, 
        unsigned int bmap_count = reiserfs_bmap_count(s);
  
        if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
-               reiserfs_warning(s,
-                                "vs-4010: is_reusable: block number is out of range %lu (%u)",
-                                block, SB_BLOCK_COUNT(s));
+               reiserfs_error(s, "vs-4010",
+                              "block number is out of range %lu (%u)",
+                              block, SB_BLOCK_COUNT(s));
                return 0;
        }
  
                b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1;
                if (block >= bmap1 &&
                    block <= bmap1 + bmap_count) {
-                       reiserfs_warning(s, "vs: 4019: is_reusable: "
-                                        "bitmap block %lu(%u) can't be freed or reused",
-                                        block, bmap_count);
+                       reiserfs_error(s, "vs-4019", "bitmap block %lu(%u) "
+                                      "can't be freed or reused",
+                                      block, bmap_count);
                        return 0;
                }
        } else {
                if (offset == 0) {
-                       reiserfs_warning(s, "vs: 4020: is_reusable: "
-                                        "bitmap block %lu(%u) can't be freed or reused",
-                                        block, bmap_count);
+                       reiserfs_error(s, "vs-4020", "bitmap block %lu(%u) "
+                                      "can't be freed or reused",
+                                      block, bmap_count);
                        return 0;
                }
        }
  
        if (bmap >= bmap_count) {
-               reiserfs_warning(s,
-                                "vs-4030: is_reusable: there is no so many bitmap blocks: "
-                                "block=%lu, bitmap_nr=%u", block, bmap);
+               reiserfs_error(s, "vs-4030", "bitmap for requested block "
+                              "is out of range: block=%lu, bitmap_nr=%u",
+                              block, bmap);
                return 0;
        }
  
        if (bit_value == 0 && block == SB_ROOT_BLOCK(s)) {
-               reiserfs_warning(s,
-                                "vs-4050: is_reusable: this is root block (%u), "
-                                "it must be busy", SB_ROOT_BLOCK(s));
+               reiserfs_error(s, "vs-4050", "this is root block (%u), "
+                              "it must be busy", SB_ROOT_BLOCK(s));
                return 0;
        }
  
@@@ -154,8 -153,8 +153,8 @@@ static int scan_bitmap_block(struct rei
  /* - I mean `a window of zero bits' as in description of this function - Zam. */
  
        if (!bi) {
-               reiserfs_warning(s, "NULL bitmap info pointer for bitmap %d",
-                                bmap_n);
+               reiserfs_error(s, "jdm-4055", "NULL bitmap info pointer "
+                              "for bitmap %d", bmap_n);
                return 0;
        }
  
@@@ -400,11 -399,8 +399,8 @@@ static void _reiserfs_free_block(struc
        get_bit_address(s, block, &nr, &offset);
  
        if (nr >= reiserfs_bmap_count(s)) {
-               reiserfs_warning(s, "vs-4075: reiserfs_free_block: "
-                                "block %lu is out of range on %s "
-                                "(nr=%u,max=%u)", block,
-                                reiserfs_bdevname(s), nr,
-                                reiserfs_bmap_count(s));
+               reiserfs_error(s, "vs-4075", "block %lu is out of range",
+                              block);
                return;
        }
  
  
        /* clear bit for the given block in bit map */
        if (!reiserfs_test_and_clear_le_bit(offset, bmbh->b_data)) {
-               reiserfs_warning(s, "vs-4080: reiserfs_free_block: "
-                                "free_block (%s:%lu)[dev:blocknr]: bit already cleared",
-                                reiserfs_bdevname(s), block);
+               reiserfs_error(s, "vs-4080",
+                              "block %lu: bit already cleared", block);
        }
        apbi[nr].free_count++;
        journal_mark_dirty(th, s, bmbh);
  
        journal_mark_dirty(th, s, sbh);
        if (for_unformatted)
 -              DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
 +              vfs_dq_free_block_nodirty(inode, 1);
  }
  
  void reiserfs_free_block(struct reiserfs_transaction_handle *th,
                return;
  
        if (block > sb_block_count(REISERFS_SB(s)->s_rs)) {
-               reiserfs_panic(th->t_super, "bitmap-4072",
+               reiserfs_error(th->t_super, "bitmap-4072",
                               "Trying to free block outside file system "
                               "boundaries (%lu > %lu)",
                               block, sb_block_count(REISERFS_SB(s)->s_rs));
@@@ -477,9 -472,8 +472,8 @@@ static void __discard_prealloc(struct r
        BUG_ON(!th->t_trans_id);
  #ifdef CONFIG_REISERFS_CHECK
        if (ei->i_prealloc_count < 0)
-               reiserfs_warning(th->t_super,
-                                "zam-4001:%s: inode has negative prealloc blocks count.",
-                                __func__);
+               reiserfs_error(th->t_super, "zam-4001",
+                              "inode has negative prealloc blocks count.");
  #endif
        while (ei->i_prealloc_count > 0) {
                reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
@@@ -515,9 -509,9 +509,9 @@@ void reiserfs_discard_all_prealloc(stru
                                i_prealloc_list);
  #ifdef CONFIG_REISERFS_CHECK
                if (!ei->i_prealloc_count) {
-                       reiserfs_warning(th->t_super,
-                                        "zam-4001:%s: inode is in prealloc list but has no preallocated blocks.",
-                                        __func__);
+                       reiserfs_error(th->t_super, "zam-4001",
+                                      "inode is in prealloc list but has "
+                                      "no preallocated blocks.");
                }
  #endif
                __discard_prealloc(th, ei);
@@@ -631,12 -625,12 +625,12 @@@ int reiserfs_parse_alloc_options(struc
                        continue;
                }
  
-               reiserfs_warning(s, "zam-4001: %s : unknown option - %s",
-                                __func__, this_char);
+               reiserfs_warning(s, "zam-4001", "unknown option - %s",
+                                this_char);
                return 1;
        }
  
-       reiserfs_warning(s, "allocator options = [%08x]\n", SB_ALLOC_OPTS(s));
+       reiserfs_info(s, "allocator options = [%08x]\n", SB_ALLOC_OPTS(s));
        return 0;
  }
  
@@@ -1055,7 -1049,7 +1049,7 @@@ static inline int blocknrs_and_prealloc
                               amount_needed, hint->inode->i_uid);
  #endif
                quota_ret =
 -                  DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
 +                  vfs_dq_alloc_block_nodirty(hint->inode, amount_needed);
                if (quota_ret)  /* Quota exceeded? */
                        return QUOTA_EXCEEDED;
                if (hint->preallocate && hint->prealloc_size) {
                                       "reiserquota: allocating (prealloc) %d blocks id=%u",
                                       hint->prealloc_size, hint->inode->i_uid);
  #endif
 -                      quota_ret =
 -                          DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
 +                      quota_ret = vfs_dq_prealloc_block_nodirty(hint->inode,
                                                         hint->prealloc_size);
                        if (quota_ret)
                                hint->preallocate = hint->prealloc_size = 0;
                                               nr_allocated,
                                               hint->inode->i_uid);
  #endif
 -                              DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated);      /* Free not allocated blocks */
 +                              /* Free not allocated blocks */
 +                              vfs_dq_free_block_nodirty(hint->inode,
 +                                      amount_needed + hint->prealloc_size -
 +                                      nr_allocated);
                        }
                        while (nr_allocated--)
                                reiserfs_free_block(hint->th, hint->inode,
                               REISERFS_I(hint->inode)->i_prealloc_count,
                               hint->inode->i_uid);
  #endif
 -              DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
 +              vfs_dq_free_block_nodirty(hint->inode, amount_needed +
                                         hint->prealloc_size - nr_allocated -
                                         REISERFS_I(hint->inode)->
                                         i_prealloc_count);
@@@ -1221,7 -1213,9 +1215,9 @@@ void reiserfs_cache_bitmap_metadata(str
        unsigned long *cur = (unsigned long *)(bh->b_data + bh->b_size);
  
        /* The first bit must ALWAYS be 1 */
-       BUG_ON(!reiserfs_test_le_bit(0, (unsigned long *)bh->b_data));
+       if (!reiserfs_test_le_bit(0, (unsigned long *)bh->b_data))
+               reiserfs_error(sb, "reiserfs-2025", "bitmap block %lu is "
+                              "corrupted: first bit must be 1", bh->b_blocknr);
  
        info->free_count = 0;
  
diff --combined fs/reiserfs/inode.c
@@@ -52,8 -52,8 +52,8 @@@ void reiserfs_delete_inode(struct inod
                /* Do quota update inside a transaction for journaled quotas. We must do that
                 * after delete_object so that quota updates go into the same transaction as
                 * stat data deletion */
 -              if (!err)
 -                      DQUOT_FREE_INODE(inode);
 +              if (!err) 
 +                      vfs_dq_free_inode(inode);
  
                if (journal_end(&th, inode->i_sb, jbegin_count))
                        goto out;
@@@ -363,7 -363,7 +363,7 @@@ static int _get_block_create_0(struct i
                }
                /* make sure we don't read more bytes than actually exist in
                 ** the file.  This can happen in odd cases where i_size isn't
-                ** correct, and when direct item padding results in a few 
+                ** correct, and when direct item padding results in a few
                 ** extra bytes at the end of the direct item
                 */
                if ((le_ih_k_offset(ih) + path.pos_in_item) > inode->i_size)
@@@ -438,15 -438,15 +438,15 @@@ static int reiserfs_bmap(struct inode *
  ** -ENOENT instead of a valid buffer.  block_prepare_write expects to
  ** be able to do i/o on the buffers returned, unless an error value
  ** is also returned.
- ** 
+ **
  ** So, this allows block_prepare_write to be used for reading a single block
  ** in a page.  Where it does not produce a valid page for holes, or past the
  ** end of the file.  This turns out to be exactly what we need for reading
  ** tails for conversion.
  **
  ** The point of the wrapper is forcing a certain value for create, even
- ** though the VFS layer is calling this function with create==1.  If you 
- ** don't want to send create == GET_BLOCK_NO_HOLE to reiserfs_get_block, 
+ ** though the VFS layer is calling this function with create==1.  If you
+ ** don't want to send create == GET_BLOCK_NO_HOLE to reiserfs_get_block,
  ** don't use this function.
  */
  static int reiserfs_get_block_create_0(struct inode *inode, sector_t block,
@@@ -602,7 -602,7 +602,7 @@@ int reiserfs_get_block(struct inode *in
        int done;
        int fs_gen;
        struct reiserfs_transaction_handle *th = NULL;
-       /* space reserved in transaction batch: 
+       /* space reserved in transaction batch:
           . 3 balancings in direct->indirect conversion
           . 1 block involved into reiserfs_update_sd()
           XXX in practically impossible worst case direct2indirect()
                reiserfs_write_unlock(inode->i_sb);
  
                /* the item was found, so new blocks were not added to the file
-                ** there is no need to make sure the inode is updated with this 
+                ** there is no need to make sure the inode is updated with this
                 ** transaction
                 */
                return retval;
                                                          tail_offset);
                                if (retval) {
                                        if (retval != -ENOSPC)
-                                               reiserfs_warning(inode->i_sb,
-                                                                "clm-6004: convert tail failed inode %lu, error %d",
-                                                                inode->i_ino,
-                                                                retval);
+                                               reiserfs_error(inode->i_sb,
+                                                       "clm-6004",
+                                                       "convert tail failed "
+                                                       "inode %lu, error %d",
+                                                       inode->i_ino,
+                                                       retval);
                                        if (allocated_block_nr) {
                                                /* the bitmap, the super, and the stat data == 3 */
                                                if (!th)
  
                /* this loop could log more blocks than we had originally asked
                 ** for.  So, we have to allow the transaction to end if it is
-                ** too big or too full.  Update the inode so things are 
+                ** too big or too full.  Update the inode so things are
                 ** consistent if we crash before the function returns
                 **
                 ** release the path so that anybody waiting on the path before
                        if (retval)
                                goto failure;
                }
-               /* inserting indirect pointers for a hole can take a 
+               /* inserting indirect pointers for a hole can take a
                 ** long time.  reschedule if needed
                 */
                cond_resched();
                        goto failure;
                }
                if (retval == POSITION_FOUND) {
-                       reiserfs_warning(inode->i_sb,
-                                        "vs-825: reiserfs_get_block: "
+                       reiserfs_warning(inode->i_sb, "vs-825",
                                         "%K should not be found", &key);
                        retval = -EEXIST;
                        if (allocated_block_nr)
@@@ -1299,8 -1300,7 +1300,7 @@@ static void update_stat_data(struct tre
        ih = PATH_PITEM_HEAD(path);
  
        if (!is_statdata_le_ih(ih))
-               reiserfs_panic(inode->i_sb,
-                              "vs-13065: update_stat_data: key %k, found item %h",
+               reiserfs_panic(inode->i_sb, "vs-13065", "key %k, found item %h",
                               INODE_PKEY(inode), ih);
  
        if (stat_data_v1(ih)) {
@@@ -1332,10 -1332,9 +1332,9 @@@ void reiserfs_update_sd_size(struct rei
                /* look for the object's stat data */
                retval = search_item(inode->i_sb, &key, &path);
                if (retval == IO_ERROR) {
-                       reiserfs_warning(inode->i_sb,
-                                        "vs-13050: reiserfs_update_sd: "
-                                        "i/o failure occurred trying to update %K stat data",
-                                        &key);
+                       reiserfs_error(inode->i_sb, "vs-13050",
+                                      "i/o failure occurred trying to "
+                                      "update %K stat data", &key);
                        return;
                }
                if (retval == ITEM_NOT_FOUND) {
                                /*reiserfs_warning (inode->i_sb, "vs-13050: reiserfs_update_sd: i_nlink == 0, stat data not found"); */
                                return;
                        }
-                       reiserfs_warning(inode->i_sb,
-                                        "vs-13060: reiserfs_update_sd: "
-                                        "stat data of object %k (nlink == %d) not found (pos %d)",
+                       reiserfs_warning(inode->i_sb, "vs-13060",
+                                        "stat data of object %k (nlink == %d) "
+                                        "not found (pos %d)",
                                         INODE_PKEY(inode), inode->i_nlink,
                                         pos);
                        reiserfs_check_path(&path);
@@@ -1424,10 -1423,9 +1423,9 @@@ void reiserfs_read_locked_inode(struct 
        /* look for the object's stat data */
        retval = search_item(inode->i_sb, &key, &path_to_sd);
        if (retval == IO_ERROR) {
-               reiserfs_warning(inode->i_sb,
-                                "vs-13070: reiserfs_read_locked_inode: "
-                                "i/o failure occurred trying to find stat data of %K",
-                                &key);
+               reiserfs_error(inode->i_sb, "vs-13070",
+                              "i/o failure occurred trying to find "
+                              "stat data of %K", &key);
                reiserfs_make_bad_inode(inode);
                return;
        }
           update sd on unlink all that is required is to check for nlink
           here. This bug was first found by Sizif when debugging
           SquidNG/Butterfly, forgotten, and found again after Philippe
-          Gramoulle <philippe.gramoulle@mmania.com> reproduced it. 
+          Gramoulle <philippe.gramoulle@mmania.com> reproduced it.
  
           More logical fix would require changes in fs/inode.c:iput() to
           remove inode from hash-table _after_ fs cleaned disk stuff up and
           during mount (fs/reiserfs/super.c:finish_unfinished()). */
        if ((inode->i_nlink == 0) &&
            !REISERFS_SB(inode->i_sb)->s_is_unlinked_ok) {
-               reiserfs_warning(inode->i_sb,
-                                "vs-13075: reiserfs_read_locked_inode: "
+               reiserfs_warning(inode->i_sb, "vs-13075",
                                 "dead inode read from disk %K. "
                                 "This is likely to be race with knfsd. Ignore",
                                 &key);
@@@ -1555,7 -1552,7 +1552,7 @@@ struct dentry *reiserfs_fh_to_dentry(st
         */
        if (fh_type > fh_len) {
                if (fh_type != 6 || fh_len != 5)
-                       reiserfs_warning(sb,
+                       reiserfs_warning(sb, "reiserfs-13077",
                                "nfsd/reiserfs, fhtype=%d, len=%d - odd",
                                fh_type, fh_len);
                fh_type = 5;
@@@ -1622,7 -1619,7 +1619,7 @@@ int reiserfs_write_inode(struct inode *
        if (inode->i_sb->s_flags & MS_RDONLY)
                return -EROFS;
        /* memory pressure can sometimes initiate write_inode calls with sync == 1,
-        ** these cases are just when the system needs ram, not when the 
+        ** these cases are just when the system needs ram, not when the
         ** inode needs to reach disk for safety, and they can safely be
         ** ignored because the altered inode has already been logged.
         */
@@@ -1680,13 -1677,13 +1677,13 @@@ static int reiserfs_new_directory(struc
        /* look for place in the tree for new item */
        retval = search_item(sb, &key, path);
        if (retval == IO_ERROR) {
-               reiserfs_warning(sb, "vs-13080: reiserfs_new_directory: "
-                                "i/o failure occurred creating new directory");
+               reiserfs_error(sb, "vs-13080",
+                              "i/o failure occurred creating new directory");
                return -EIO;
        }
        if (retval == ITEM_FOUND) {
                pathrelse(path);
-               reiserfs_warning(sb, "vs-13070: reiserfs_new_directory: "
+               reiserfs_warning(sb, "vs-13070",
                                 "object with this key exists (%k)",
                                 &(ih->ih_key));
                return -EEXIST;
@@@ -1720,13 -1717,13 +1717,13 @@@ static int reiserfs_new_symlink(struct 
        /* look for place in the tree for new item */
        retval = search_item(sb, &key, path);
        if (retval == IO_ERROR) {
-               reiserfs_warning(sb, "vs-13080: reiserfs_new_symlinik: "
-                                "i/o failure occurred creating new symlink");
+               reiserfs_error(sb, "vs-13080",
+                              "i/o failure occurred creating new symlink");
                return -EIO;
        }
        if (retval == ITEM_FOUND) {
                pathrelse(path);
-               reiserfs_warning(sb, "vs-13080: reiserfs_new_symlink: "
+               reiserfs_warning(sb, "vs-13080",
                                 "object with this key exists (%k)",
                                 &(ih->ih_key));
                return -EEXIST;
  /* inserts the stat data into the tree, and then calls
     reiserfs_new_directory (to insert ".", ".." item if new object is
     directory) or reiserfs_new_symlink (to insert symlink body if new
-    object is symlink) or nothing (if new object is regular file) 
+    object is symlink) or nothing (if new object is regular file)
  
     NOTE! uid and gid must already be set in the inode.  If we return
     non-zero due to an error, we have to drop the quota previously allocated
     if we return non-zero, we also end the transaction.  */
  int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
                       struct inode *dir, int mode, const char *symname,
-                      /* 0 for regular, EMTRY_DIR_SIZE for dirs, 
+                      /* 0 for regular, EMTRY_DIR_SIZE for dirs,
                          strlen (symname) for symlinks) */
                       loff_t i_size, struct dentry *dentry,
-                      struct inode *inode)
+                      struct inode *inode,
+                      struct reiserfs_security_handle *security)
  {
        struct super_block *sb;
        struct reiserfs_iget_args args;
  
        BUG_ON(!th->t_trans_id);
  
 -      if (DQUOT_ALLOC_INODE(inode)) {
 +      if (vfs_dq_alloc_inode(inode)) {
                err = -EDQUOT;
                goto out_end_trans;
        }
                goto out_bad_inode;
        }
        if (old_format_only(sb))
-               /* not a perfect generation count, as object ids can be reused, but 
+               /* not a perfect generation count, as object ids can be reused, but
                 ** this is as good as reiserfs can do right now.
                 ** note that the private part of inode isn't filled in yet, we have
                 ** to use the directory.
                goto out_inserted_sd;
        }
  
-       /* XXX CHECK THIS */
        if (reiserfs_posixacl(inode->i_sb)) {
-               retval = reiserfs_inherit_default_acl(dir, dentry, inode);
+               retval = reiserfs_inherit_default_acl(th, dir, dentry, inode);
                if (retval) {
                        err = retval;
                        reiserfs_check_path(&path_to_key);
                        goto out_inserted_sd;
                }
        } else if (inode->i_sb->s_flags & MS_POSIXACL) {
-               reiserfs_warning(inode->i_sb, "ACLs aren't enabled in the fs, "
+               reiserfs_warning(inode->i_sb, "jdm-13090",
+                                "ACLs aren't enabled in the fs, "
                                 "but vfs thinks they are!");
-       } else if (is_reiserfs_priv_object(dir)) {
-               reiserfs_mark_inode_private(inode);
+       } else if (IS_PRIVATE(dir))
+               inode->i_flags |= S_PRIVATE;
+       if (security->name) {
+               retval = reiserfs_security_write(th, inode, security);
+               if (retval) {
+                       err = retval;
+                       reiserfs_check_path(&path_to_key);
+                       retval = journal_end(th, th->t_super,
+                                            th->t_blocks_allocated);
+                       if (retval)
+                               err = retval;
+                       goto out_inserted_sd;
+               }
        }
  
        reiserfs_update_sd(th, inode);
        INODE_PKEY(inode)->k_objectid = 0;
  
        /* Quota change must be inside a transaction for journaling */
 -      DQUOT_FREE_INODE(inode);
 +      vfs_dq_free_inode(inode);
  
        out_end_trans:
        journal_end(th, th->t_super, th->t_blocks_allocated);
        /* Drop can be outside and it needs more credits so it's better to have it outside */
 -      DQUOT_DROP(inode);
 +      vfs_dq_drop(inode);
        inode->i_flags |= S_NOQUOTA;
        make_bad_inode(inode);
  
        inode->i_nlink = 0;
        th->t_trans_id = 0;     /* so the caller can't use this handle later */
        unlock_new_inode(inode); /* OK to do even if we hadn't locked it */
-       /* If we were inheriting an ACL, we need to release the lock so that
-        * iput doesn't deadlock in reiserfs_delete_xattrs. The locking
-        * code really needs to be reworked, but this will take care of it
-        * for now. -jeffm */
- #ifdef CONFIG_REISERFS_FS_POSIX_ACL
-       if (REISERFS_I(dir)->i_acl_default && !IS_ERR(REISERFS_I(dir)->i_acl_default)) {
-               reiserfs_write_unlock_xattrs(dir->i_sb);
-               iput(inode);
-               reiserfs_write_lock_xattrs(dir->i_sb);
-       } else
- #endif
-               iput(inode);
+       iput(inode);
        return err;
  }
  
  **
  ** on failure, nonzero is returned, page_result and bh_result are untouched.
  */
- static int grab_tail_page(struct inode *p_s_inode,
+ static int grab_tail_page(struct inode *inode,
                          struct page **page_result,
                          struct buffer_head **bh_result)
  {
        /* we want the page with the last byte in the file,
         ** not the page that will hold the next byte for appending
         */
-       unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT;
+       unsigned long index = (inode->i_size - 1) >> PAGE_CACHE_SHIFT;
        unsigned long pos = 0;
        unsigned long start = 0;
-       unsigned long blocksize = p_s_inode->i_sb->s_blocksize;
-       unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1);
+       unsigned long blocksize = inode->i_sb->s_blocksize;
+       unsigned long offset = (inode->i_size) & (PAGE_CACHE_SIZE - 1);
        struct buffer_head *bh;
        struct buffer_head *head;
        struct page *page;
        if ((offset & (blocksize - 1)) == 0) {
                return -ENOENT;
        }
-       page = grab_cache_page(p_s_inode->i_mapping, index);
+       page = grab_cache_page(inode->i_mapping, index);
        error = -ENOMEM;
        if (!page) {
                goto out;
                 ** I've screwed up the code to find the buffer, or the code to
                 ** call prepare_write
                 */
-               reiserfs_warning(p_s_inode->i_sb,
-                                "clm-6000: error reading block %lu on dev %s",
-                                bh->b_blocknr,
-                                reiserfs_bdevname(p_s_inode->i_sb));
+               reiserfs_error(inode->i_sb, "clm-6000",
+                              "error reading block %lu", bh->b_blocknr);
                error = -EIO;
                goto unlock;
        }
  **
  ** some code taken from block_truncate_page
  */
- int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
+ int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
  {
        struct reiserfs_transaction_handle th;
        /* we want the offset for the first byte after the end of the file */
-       unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1);
-       unsigned blocksize = p_s_inode->i_sb->s_blocksize;
+       unsigned long offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
+       unsigned blocksize = inode->i_sb->s_blocksize;
        unsigned length;
        struct page *page = NULL;
        int error;
        struct buffer_head *bh = NULL;
        int err2;
  
-       reiserfs_write_lock(p_s_inode->i_sb);
+       reiserfs_write_lock(inode->i_sb);
  
-       if (p_s_inode->i_size > 0) {
-               if ((error = grab_tail_page(p_s_inode, &page, &bh))) {
-                       // -ENOENT means we truncated past the end of the file, 
+       if (inode->i_size > 0) {
+               error = grab_tail_page(inode, &page, &bh);
+               if (error) {
+                       // -ENOENT means we truncated past the end of the file,
                        // and get_block_create_0 could not find a block to read in,
                        // which is ok.
                        if (error != -ENOENT)
-                               reiserfs_warning(p_s_inode->i_sb,
-                                                "clm-6001: grab_tail_page failed %d",
-                                                error);
+                               reiserfs_error(inode->i_sb, "clm-6001",
+                                              "grab_tail_page failed %d",
+                                              error);
                        page = NULL;
                        bh = NULL;
                }
        }
  
-       /* so, if page != NULL, we have a buffer head for the offset at 
-        ** the end of the file. if the bh is mapped, and bh->b_blocknr != 0, 
-        ** then we have an unformatted node.  Otherwise, we have a direct item, 
-        ** and no zeroing is required on disk.  We zero after the truncate, 
-        ** because the truncate might pack the item anyway 
+       /* so, if page != NULL, we have a buffer head for the offset at
+        ** the end of the file. if the bh is mapped, and bh->b_blocknr != 0,
+        ** then we have an unformatted node.  Otherwise, we have a direct item,
+        ** and no zeroing is required on disk.  We zero after the truncate,
+        ** because the truncate might pack the item anyway
         ** (it will unmap bh if it packs).
         */
        /* it is enough to reserve space in transaction for 2 balancings:
           one for "save" link adding and another for the first
           cut_from_item. 1 is for update_sd */
-       error = journal_begin(&th, p_s_inode->i_sb,
+       error = journal_begin(&th, inode->i_sb,
                              JOURNAL_PER_BALANCE_CNT * 2 + 1);
        if (error)
                goto out;
-       reiserfs_update_inode_transaction(p_s_inode);
+       reiserfs_update_inode_transaction(inode);
        if (update_timestamps)
                /* we are doing real truncate: if the system crashes before the last
                   transaction of truncating gets committed - on reboot the file
                   either appears truncated properly or not truncated at all */
-               add_save_link(&th, p_s_inode, 1);
-       err2 = reiserfs_do_truncate(&th, p_s_inode, page, update_timestamps);
+               add_save_link(&th, inode, 1);
+       err2 = reiserfs_do_truncate(&th, inode, page, update_timestamps);
        error =
-           journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
+           journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
        if (error)
                goto out;
  
        }
        
        if (update_timestamps) {
-               error = remove_save_link(p_s_inode, 1 /* truncate */ );
+               error = remove_save_link(inode, 1 /* truncate */);
                if (error)
                        goto out;
        }
                page_cache_release(page);
        }
  
-       reiserfs_write_unlock(p_s_inode->i_sb);
+       reiserfs_write_unlock(inode->i_sb);
        return 0;
        out:
        if (page) {
                unlock_page(page);
                page_cache_release(page);
        }
-       reiserfs_write_unlock(p_s_inode->i_sb);
+       reiserfs_write_unlock(inode->i_sb);
        return error;
  }
  
@@@ -2208,9 -2205,8 +2205,8 @@@ static int map_block_for_writepage(stru
        /* we've found an unformatted node */
        if (indirect_item_found(retval, ih)) {
                if (bytes_copied > 0) {
-                       reiserfs_warning(inode->i_sb,
-                                        "clm-6002: bytes_copied %d",
-                                        bytes_copied);
+                       reiserfs_warning(inode->i_sb, "clm-6002",
+                                        "bytes_copied %d", bytes_copied);
                }
                if (!get_block_num(item, pos_in_item)) {
                        /* crap, we are writing to a hole */
                        goto research;
                }
        } else {
-               reiserfs_warning(inode->i_sb,
-                                "clm-6003: bad item inode %lu, device %s",
-                                inode->i_ino, reiserfs_bdevname(inode->i_sb));
+               reiserfs_warning(inode->i_sb, "clm-6003",
+                                "bad item inode %lu", inode->i_ino);
                retval = -EIO;
                goto out;
        }
        return retval;
  }
  
- /* 
-  * mason@suse.com: updated in 2.5.54 to follow the same general io 
+ /*
+  * mason@suse.com: updated in 2.5.54 to follow the same general io
   * start/recovery path as __block_write_full_page, along with special
   * code to handle reiserfs tails.
   */
@@@ -2453,7 -2448,7 +2448,7 @@@ static int reiserfs_write_full_page(str
        unlock_page(page);
  
        /*
-        * since any buffer might be the only dirty buffer on the page, 
+        * since any buffer might be the only dirty buffer on the page,
         * the first submit_bh can bring the page out of writeback.
         * be careful with the buffers.
         */
        if (nr == 0) {
                /*
                 * if this page only had a direct item, it is very possible for
-                * no io to be required without there being an error.  Or, 
-                * someone else could have locked them and sent them down the 
+                * no io to be required without there being an error.  Or,
+                * someone else could have locked them and sent them down the
                 * pipe without locking the page
                 */
                bh = head;
  
        fail:
        /* catches various errors, we need to make sure any valid dirty blocks
-        * get to the media.  The page is currently locked and not marked for 
+        * get to the media.  The page is currently locked and not marked for
         * writeback
         */
        ClearPageUptodate(page);
@@@ -3119,7 -3114,7 +3114,7 @@@ int reiserfs_setattr(struct dentry *den
                                if (error)
                                        goto out;
                                error =
 -                                  DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
 +                                  vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
                                if (error) {
                                        journal_end(&th, inode->i_sb,
                                                    jbegin_count);
diff --combined fs/reiserfs/namei.c
@@@ -106,7 -106,7 +106,7 @@@ 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 
+ entry position in the item
  
  */
  
@@@ -120,8 -120,8 +120,8 @@@ int search_by_entry_key(struct super_bl
        switch (retval) {
        case ITEM_NOT_FOUND:
                if (!PATH_LAST_POSITION(path)) {
-                       reiserfs_warning(sb,
-                                        "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
+                       reiserfs_error(sb, "vs-7000", "search_by_key "
+                                      "returned item position == 0");
                        pathrelse(path);
                        return IO_ERROR;
                }
  
        default:
                pathrelse(path);
-               reiserfs_warning(sb,
-                                "vs-7002: search_by_entry_key: no path to here");
+               reiserfs_error(sb, "vs-7002", "no path to here");
                return IO_ERROR;
        }
  
        if (!is_direntry_le_ih(de->de_ih) ||
            COMP_SHORT_KEYS(&(de->de_ih->ih_key), key)) {
                print_block(de->de_bh, 0, -1, -1);
-               reiserfs_panic(sb,
-                              "vs-7005: search_by_entry_key: found item %h is not directory item or "
-                              "does not belong to the same directory as key %K",
-                              de->de_ih, key);
+               reiserfs_panic(sb, "vs-7005", "found item %h is not directory "
+                              "item or does not belong to the same directory "
+                              "as key %K", de->de_ih, key);
        }
  #endif                                /* CONFIG_REISERFS_CHECK */
  
@@@ -300,8 -298,7 +298,7 @@@ static int reiserfs_find_entry(struct i
                    search_by_entry_key(dir->i_sb, &key_to_search,
                                        path_to_entry, de);
                if (retval == IO_ERROR) {
-                       reiserfs_warning(dir->i_sb, "zam-7001: io error in %s",
-                                        __func__);
+                       reiserfs_error(dir->i_sb, "zam-7001", "io error");
                        return IO_ERROR;
                }
  
@@@ -361,9 -358,10 +358,10 @@@ static struct dentry *reiserfs_lookup(s
                        return ERR_PTR(-EACCES);
                }
  
-               /* Propogate the priv_object flag so we know we're in the priv tree */
-               if (is_reiserfs_priv_object(dir))
-                       reiserfs_mark_inode_private(inode);
+               /* Propagate the private flag so we know we're
+                * in the priv tree */
+               if (IS_PRIVATE(dir))
+                       inode->i_flags |= S_PRIVATE;
        }
        reiserfs_write_unlock(dir->i_sb);
        if (retval == IO_ERROR) {
        return d_splice_alias(inode, dentry);
  }
  
- /* 
+ /*
  ** looks up the dentry of the parent directory for child.
  ** taken from ext2_get_parent
  */
@@@ -403,7 -401,7 +401,7 @@@ struct dentry *reiserfs_get_parent(stru
        return d_obtain_alias(inode);
  }
  
- /* add entry to the directory (entry can be hidden). 
+ /* add entry to the directory (entry can be hidden).
  
  insert definition of when hidden directories are used here -Hans
  
@@@ -484,10 -482,9 +482,9 @@@ static int reiserfs_add_entry(struct re
                }
  
                if (retval != NAME_FOUND) {
-                       reiserfs_warning(dir->i_sb,
-                                        "zam-7002:%s: \"reiserfs_find_entry\" "
-                                        "has returned unexpected value (%d)",
-                                        __func__, retval);
+                       reiserfs_error(dir->i_sb, "zam-7002",
+                                      "reiserfs_find_entry() returned "
+                                      "unexpected value (%d)", retval);
                }
  
                return -EEXIST;
                                MAX_GENERATION_NUMBER + 1);
        if (gen_number > MAX_GENERATION_NUMBER) {
                /* there is no free generation number */
-               reiserfs_warning(dir->i_sb,
-                                "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
+               reiserfs_warning(dir->i_sb, "reiserfs-7010",
+                                "Congratulations! we have got hash function "
+                                "screwed up");
                if (buffer != small_buf)
                        kfree(buffer);
                pathrelse(&path);
        if (gen_number != 0) {  /* we need to re-search for the insertion point */
                if (search_by_entry_key(dir->i_sb, &entry_key, &path, &de) !=
                    NAME_NOT_FOUND) {
-                       reiserfs_warning(dir->i_sb,
-                                        "vs-7032: reiserfs_add_entry: "
-                                        "entry with this key (%K) already exists",
-                                        &entry_key);
+                       reiserfs_warning(dir->i_sb, "vs-7032",
+                                        "entry with this key (%K) already "
+                                        "exists", &entry_key);
  
                        if (buffer != small_buf)
                                kfree(buffer);
  */
  static int drop_new_inode(struct inode *inode)
  {
 -      DQUOT_DROP(inode);
 +      vfs_dq_drop(inode);
        make_bad_inode(inode);
        inode->i_flags |= S_NOQUOTA;
        iput(inode);
        return 0;
  }
  
- /* utility function that does setup for reiserfs_new_inode.  
+ /* utility function that does setup for reiserfs_new_inode.
 -** DQUOT_INIT needs lots of credits so it's better to have it
 +** vfs_dq_init 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.
  */
@@@ -586,7 -583,7 +583,7 @@@ static int new_inode_init(struct inode 
        } else {
                inode->i_gid = current_fsgid();
        }
 -      DQUOT_INIT(inode);
 +      vfs_dq_init(inode);
        return 0;
  }
  
@@@ -601,20 -598,22 +598,22 @@@ static int reiserfs_create(struct inod
            2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
                 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
        struct reiserfs_transaction_handle th;
-       int locked;
+       struct reiserfs_security_handle security;
  
        if (!(inode = new_inode(dir->i_sb))) {
                return -ENOMEM;
        }
        new_inode_init(inode, dir, mode);
  
-       locked = reiserfs_cache_default_acl(dir);
+       jbegin_count += reiserfs_cache_default_acl(dir);
+       retval = reiserfs_security_init(dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
        reiserfs_write_lock(dir->i_sb);
  
-       if (locked)
-               reiserfs_write_lock_xattrs(dir->i_sb);
        retval = journal_begin(&th, dir->i_sb, jbegin_count);
        if (retval) {
                drop_new_inode(inode);
  
        retval =
            reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
-                              inode);
+                              inode, &security);
        if (retval)
                goto out_failed;
  
-       if (locked) {
-               reiserfs_write_unlock_xattrs(dir->i_sb);
-               locked = 0;
-       }
        inode->i_op = &reiserfs_file_inode_operations;
        inode->i_fop = &reiserfs_file_operations;
        inode->i_mapping->a_ops = &reiserfs_address_space_operations;
        retval = journal_end(&th, dir->i_sb, jbegin_count);
  
        out_failed:
-       if (locked)
-               reiserfs_write_unlock_xattrs(dir->i_sb);
        reiserfs_write_unlock(dir->i_sb);
        return retval;
  }
@@@ -670,12 -662,12 +662,12 @@@ static int reiserfs_mknod(struct inode 
        int retval;
        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) */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
            2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
                 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
-       int locked;
  
        if (!new_valid_dev(rdev))
                return -EINVAL;
        }
        new_inode_init(inode, dir, mode);
  
-       locked = reiserfs_cache_default_acl(dir);
+       jbegin_count += reiserfs_cache_default_acl(dir);
+       retval = reiserfs_security_init(dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
        reiserfs_write_lock(dir->i_sb);
  
-       if (locked)
-               reiserfs_write_lock_xattrs(dir->i_sb);
        retval = journal_begin(&th, dir->i_sb, jbegin_count);
        if (retval) {
                drop_new_inode(inode);
  
        retval =
            reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
-                              inode);
+                              inode, &security);
        if (retval) {
                goto out_failed;
        }
  
-       if (locked) {
-               reiserfs_write_unlock_xattrs(dir->i_sb);
-               locked = 0;
-       }
        inode->i_op = &reiserfs_special_inode_operations;
        init_special_inode(inode, inode->i_mode, rdev);
  
        retval = journal_end(&th, dir->i_sb, jbegin_count);
  
        out_failed:
-       if (locked)
-               reiserfs_write_unlock_xattrs(dir->i_sb);
        reiserfs_write_unlock(dir->i_sb);
        return retval;
  }
@@@ -750,12 -737,12 +737,12 @@@ static int reiserfs_mkdir(struct inode 
        int retval;
        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) */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
            2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
                 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
-       int locked;
  
  #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 */
        }
        new_inode_init(inode, dir, mode);
  
-       locked = reiserfs_cache_default_acl(dir);
+       jbegin_count += reiserfs_cache_default_acl(dir);
+       retval = reiserfs_security_init(dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
        reiserfs_write_lock(dir->i_sb);
-       if (locked)
-               reiserfs_write_lock_xattrs(dir->i_sb);
  
        retval = journal_begin(&th, dir->i_sb, jbegin_count);
        if (retval) {
            retval = reiserfs_new_inode(&th, dir, mode, NULL /*symlink */ ,
                                        old_format_only(dir->i_sb) ?
                                        EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
-                                       dentry, inode);
+                                       dentry, inode, &security);
        if (retval) {
                dir->i_nlink--;
                goto out_failed;
        }
  
-       if (locked) {
-               reiserfs_write_unlock_xattrs(dir->i_sb);
-               locked = 0;
-       }
        reiserfs_update_inode_transaction(inode);
        reiserfs_update_inode_transaction(dir);
  
        unlock_new_inode(inode);
        retval = journal_end(&th, dir->i_sb, jbegin_count);
        out_failed:
-       if (locked)
-               reiserfs_write_unlock_xattrs(dir->i_sb);
        reiserfs_write_unlock(dir->i_sb);
        return retval;
  }
@@@ -837,7 -820,7 +820,7 @@@ static inline int reiserfs_empty_dir(st
  {
        /* 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, 
+        ** 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 &&
@@@ -903,8 -886,9 +886,9 @@@ static int reiserfs_rmdir(struct inode 
                goto end_rmdir;
  
        if (inode->i_nlink != 2 && inode->i_nlink != 1)
-               reiserfs_warning(inode->i_sb, "%s: empty directory has nlink "
-                                "!= 2 (%d)", __func__, inode->i_nlink);
+               reiserfs_error(inode->i_sb, "reiserfs-7040",
+                              "empty directory has nlink != 2 (%d)",
+                              inode->i_nlink);
  
        clear_nlink(inode);
        inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
@@@ -980,10 -964,9 +964,9 @@@ static int reiserfs_unlink(struct inod
        }
  
        if (!inode->i_nlink) {
-               reiserfs_warning(inode->i_sb, "%s: deleting nonexistent file "
-                                "(%s:%lu), %d", __func__,
-                                reiserfs_bdevname(inode->i_sb), inode->i_ino,
-                                inode->i_nlink);
+               reiserfs_warning(inode->i_sb, "reiserfs-7042",
+                                "deleting nonexistent file (%lu), %d",
+                                inode->i_ino, inode->i_nlink);
                inode->i_nlink = 1;
        }
  
@@@ -1037,6 -1020,7 +1020,7 @@@ static int reiserfs_symlink(struct inod
        char *name;
        int item_len;
        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) */
        int jbegin_count =
        }
        new_inode_init(inode, parent_dir, mode);
  
+       retval = reiserfs_security_init(parent_dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
        reiserfs_write_lock(parent_dir->i_sb);
        item_len = ROUND_UP(strlen(symname));
        if (item_len > MAX_DIRECT_ITEM_LEN(parent_dir->i_sb->s_blocksize)) {
        memcpy(name, symname, strlen(symname));
        padd_item(name, item_len, strlen(symname));
  
-       /* We would inherit the default ACL here, but symlinks don't get ACLs */
        retval = journal_begin(&th, parent_dir->i_sb, jbegin_count);
        if (retval) {
                drop_new_inode(inode);
  
        retval =
            reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
-                              dentry, inode);
+                              dentry, inode, &security);
        kfree(name);
        if (retval) {           /* reiserfs_new_inode iputs for us */
                goto out_failed;
@@@ -1173,7 -1162,7 +1162,7 @@@ static int reiserfs_link(struct dentry 
        return retval;
  }
  
- // de contains information pointing to an entry which 
+ /* de contains information pointing to an entry which */
  static int de_still_valid(const char *name, int len,
                          struct reiserfs_dir_entry *de)
  {
@@@ -1196,15 -1185,14 +1185,14 @@@ static int entry_points_to_object(cons
  
        if (inode) {
                if (!de_visible(de->de_deh + de->de_entry_num))
-                       reiserfs_panic(NULL,
-                                      "vs-7042: entry_points_to_object: entry must be visible");
+                       reiserfs_panic(inode->i_sb, "vs-7042",
+                                      "entry must be visible");
                return (de->de_objectid == inode->i_ino) ? 1 : 0;
        }
  
        /* this must be added hidden entry */
        if (de_visible(de->de_deh + de->de_entry_num))
-               reiserfs_panic(NULL,
-                              "vs-7043: entry_points_to_object: entry must be visible");
+               reiserfs_panic(NULL, "vs-7043", "entry must be visible");
  
        return 1;
  }
@@@ -1218,10 -1206,10 +1206,10 @@@ static void set_ino_in_dir_entry(struc
        de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
  }
  
- /* 
+ /*
   * process, that is going to call fix_nodes/do_balance must hold only
   * one path. If it holds 2 or more, it can get into endless waiting in
-  * get_empty_nodes or its clones 
+  * get_empty_nodes or its clones
   */
  static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                           struct inode *new_dir, struct dentry *new_dentry)
  
        old_inode_mode = old_inode->i_mode;
        if (S_ISDIR(old_inode_mode)) {
-               // make sure, that directory being renamed has correct ".." 
+               // make sure, that directory being renamed has correct ".."
                // and that its new parent directory has not too many links
                // already
  
                        }
                }
  
-               /* 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 =
                               new_dentry->d_name.len, old_inode, 0);
        if (retval == -EEXIST) {
                if (!new_dentry_inode) {
-                       reiserfs_panic(old_dir->i_sb,
-                                      "vs-7050: new entry is found, new inode == 0\n");
+                       reiserfs_panic(old_dir->i_sb, "vs-7050",
+                                      "new entry is found, new inode == 0");
                }
        } else if (retval) {
                int err = journal_end(&th, old_dir->i_sb, jbegin_count);
                   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 
+               /* 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
        }
  
        if (S_ISDIR(old_inode_mode)) {
-               // adjust ".." of renamed directory 
+               /* 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);
  
        if (reiserfs_cut_from_item
            (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL,
             0) < 0)
-               reiserfs_warning(old_dir->i_sb,
-                                "vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
+               reiserfs_error(old_dir->i_sb, "vs-7060",
+                              "couldn't not cut old name. Fsck later?");
  
        old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
  
diff --combined fs/reiserfs/stree.c
@@@ -23,7 -23,6 +23,6 @@@
   * get_rkey
   * key_in_buffer
   * decrement_bcount
-  * decrement_counters_in_path
   * reiserfs_check_path
   * pathrelse_and_restore
   * pathrelse
  #include <linux/quotaops.h>
  
  /* Does the buffer contain a disk block which is in the tree. */
- inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
+ inline int B_IS_IN_TREE(const struct buffer_head *bh)
  {
  
-       RFALSE(B_LEVEL(p_s_bh) > MAX_HEIGHT,
-              "PAP-1010: block (%b) has too big level (%z)", p_s_bh, p_s_bh);
+       RFALSE(B_LEVEL(bh) > MAX_HEIGHT,
+              "PAP-1010: block (%b) has too big level (%z)", bh, bh);
  
-       return (B_LEVEL(p_s_bh) != FREE_LEVEL);
+       return (B_LEVEL(bh) != FREE_LEVEL);
  }
  
  //
  // to gets item head in le form
  //
- inline void copy_item_head(struct item_head *p_v_to,
-                          const struct item_head *p_v_from)
+ inline void copy_item_head(struct item_head *to,
+                          const struct item_head *from)
  {
-       memcpy(p_v_to, p_v_from, IH_SIZE);
+       memcpy(to, from, IH_SIZE);
  }
  
  /* k1 is pointer to on-disk structure which is stored in little-endian
     form. k2 is pointer to cpu variable. For key of items of the same
     object this returns 0.
-    Returns: -1 if key1 < key2 
+    Returns: -1 if key1 < key2
     0 if key1 == key2
     1 if key1 > key2 */
  inline int comp_short_keys(const struct reiserfs_key *le_key,
@@@ -136,15 -135,15 +135,15 @@@ static inline int comp_keys(const struc
  inline int comp_short_le_keys(const struct reiserfs_key *key1,
                              const struct reiserfs_key *key2)
  {
-       __u32 *p_s_1_u32, *p_s_2_u32;
-       int n_key_length = REISERFS_SHORT_KEY_LEN;
+       __u32 *k1_u32, *k2_u32;
+       int key_length = REISERFS_SHORT_KEY_LEN;
  
-       p_s_1_u32 = (__u32 *) key1;
-       p_s_2_u32 = (__u32 *) key2;
-       for (; n_key_length--; ++p_s_1_u32, ++p_s_2_u32) {
-               if (le32_to_cpu(*p_s_1_u32) < le32_to_cpu(*p_s_2_u32))
+       k1_u32 = (__u32 *) key1;
+       k2_u32 = (__u32 *) key2;
+       for (; key_length--; ++k1_u32, ++k2_u32) {
+               if (le32_to_cpu(*k1_u32) < le32_to_cpu(*k2_u32))
                        return -1;
-               if (le32_to_cpu(*p_s_1_u32) > le32_to_cpu(*p_s_2_u32))
+               if (le32_to_cpu(*k1_u32) > le32_to_cpu(*k2_u32))
                        return 1;
        }
        return 0;
@@@ -175,52 -174,51 +174,51 @@@ inline int comp_le_keys(const struct re
   *  Binary search toolkit function                                        *
   *  Search for an item in the array by the item key                       *
   *  Returns:    1 if found,  0 if not found;                              *
-  *        *p_n_pos = number of the searched element if found, else the    *
-  *        number of the first element that is larger than p_v_key.        *
+  *        *pos = number of the searched element if found, else the        *
+  *        number of the first element that is larger than key.            *
   **************************************************************************/
- /* For those not familiar with binary search: n_lbound is the leftmost item that it
-  could be, n_rbound the rightmost item that it could be.  We examine the item
-  halfway between n_lbound and n_rbound, and that tells us either that we can increase
-  n_lbound, or decrease n_rbound, or that we have found it, or if n_lbound <= n_rbound that
+ /* For those not familiar with binary search: lbound is the leftmost item that it
+  could be, rbound the rightmost item that it could be.  We examine the item
+  halfway between lbound and rbound, and that tells us either that we can increase
+  lbound, or decrease rbound, or that we have found it, or if lbound <= rbound that
   there are no possible items, and we have not found it. With each examination we
   cut the number of possible items it could be by one more than half rounded down,
   or we find it. */
- static inline int bin_search(const void *p_v_key,     /* Key to search for.                   */
-                            const void *p_v_base,      /* First item in the array.             */
-                            int p_n_num,       /* Number of items in the array.        */
-                            int p_n_width,     /* Item size in the array.
-                                                  searched. Lest the reader be
-                                                  confused, note that this is crafted
-                                                  as a general function, and when it
-                                                  is applied specifically to the array
-                                                  of item headers in a node, p_n_width
-                                                  is actually the item header size not
-                                                  the item size.                      */
-                            int *p_n_pos       /* Number of the searched for element. */
+ static inline int bin_search(const void *key, /* Key to search for. */
+                            const void *base,  /* First item in the array. */
+                            int num,   /* Number of items in the array. */
+                            int width, /* Item size in the array.
+                                          searched. Lest the reader be
+                                          confused, note that this is crafted
+                                          as a general function, and when it
+                                          is applied specifically to the array
+                                          of item headers in a node, width
+                                          is actually the item header size not
+                                          the item size. */
+                            int *pos /* Number of the searched for element. */
      )
  {
-       int n_rbound, n_lbound, n_j;
+       int rbound, lbound, 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)
+       for (j = ((rbound = num - 1) + (lbound = 0)) / 2;
+            lbound <= rbound; j = (rbound + lbound) / 2)
                switch (comp_keys
-                       ((struct reiserfs_key *)((char *)p_v_base +
-                                                n_j * p_n_width),
-                        (struct cpu_key *)p_v_key)) {
+                       ((struct reiserfs_key *)((char *)base + j * width),
+                        (struct cpu_key *)key)) {
                case -1:
-                       n_lbound = n_j + 1;
+                       lbound = j + 1;
                        continue;
                case 1:
-                       n_rbound = n_j - 1;
+                       rbound = j - 1;
                        continue;
                case 0:
-                       *p_n_pos = n_j;
+                       *pos = j;
                        return ITEM_FOUND;      /* Key found in the array.  */
                }
  
        /* bin_search did not find given key, it returns position of key,
           that is minimal and greater than the given one. */
-       *p_n_pos = n_lbound;
+       *pos = lbound;
        return ITEM_NOT_FOUND;
  }
  
@@@ -243,90 -241,88 +241,88 @@@ static const struct reiserfs_key MAX_KE
     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. */
- static inline const struct reiserfs_key *get_lkey(const struct treepath
-                                                 *p_s_chk_path,
-                                                 const struct super_block
-                                                 *p_s_sb)
+ static inline const struct reiserfs_key *get_lkey(const struct treepath *chk_path,
+                                                 const struct super_block *sb)
  {
-       int n_position, n_path_offset = p_s_chk_path->path_length;
-       struct buffer_head *p_s_parent;
+       int position, path_offset = chk_path->path_length;
+       struct buffer_head *parent;
  
-       RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+       RFALSE(path_offset < FIRST_PATH_ELEMENT_OFFSET,
               "PAP-5010: invalid offset in the path");
  
        /* While not higher in path than first element. */
-       while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
+       while (path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
  
                RFALSE(!buffer_uptodate
-                      (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+                      (PATH_OFFSET_PBUFFER(chk_path, path_offset)),
                       "PAP-5020: parent is not uptodate");
  
                /* Parent at the path is not in the tree now. */
                if (!B_IS_IN_TREE
-                   (p_s_parent =
-                    PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)))
+                   (parent =
+                    PATH_OFFSET_PBUFFER(chk_path, path_offset)))
                        return &MAX_KEY;
                /* Check whether position in the parent is correct. */
-               if ((n_position =
-                    PATH_OFFSET_POSITION(p_s_chk_path,
-                                         n_path_offset)) >
-                   B_NR_ITEMS(p_s_parent))
+               if ((position =
+                    PATH_OFFSET_POSITION(chk_path,
+                                         path_offset)) >
+                   B_NR_ITEMS(parent))
                        return &MAX_KEY;
                /* Check whether parent at the path really points to the child. */
-               if (B_N_CHILD_NUM(p_s_parent, n_position) !=
-                   PATH_OFFSET_PBUFFER(p_s_chk_path,
-                                       n_path_offset + 1)->b_blocknr)
+               if (B_N_CHILD_NUM(parent, position) !=
+                   PATH_OFFSET_PBUFFER(chk_path,
+                                       path_offset + 1)->b_blocknr)
                        return &MAX_KEY;
                /* Return delimiting key if position in the parent is not equal to zero. */
-               if (n_position)
-                       return B_N_PDELIM_KEY(p_s_parent, n_position - 1);
+               if (position)
+                       return B_N_PDELIM_KEY(parent, position - 1);
        }
        /* Return MIN_KEY if we are in the root of the buffer tree. */
-       if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
-           b_blocknr == SB_ROOT_BLOCK(p_s_sb))
+       if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)->
+           b_blocknr == SB_ROOT_BLOCK(sb))
                return &MIN_KEY;
        return &MAX_KEY;
  }
  
  /* Get delimiting key of the buffer at the path and its right neighbor. */
- inline const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path,
-                                          const struct super_block *p_s_sb)
+ inline const struct reiserfs_key *get_rkey(const struct treepath *chk_path,
+                                          const struct super_block *sb)
  {
-       int n_position, n_path_offset = p_s_chk_path->path_length;
-       struct buffer_head *p_s_parent;
+       int position, path_offset = chk_path->path_length;
+       struct buffer_head *parent;
  
-       RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+       RFALSE(path_offset < FIRST_PATH_ELEMENT_OFFSET,
               "PAP-5030: invalid offset in the path");
  
-       while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
+       while (path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
  
                RFALSE(!buffer_uptodate
-                      (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+                      (PATH_OFFSET_PBUFFER(chk_path, path_offset)),
                       "PAP-5040: parent is not uptodate");
  
                /* Parent at the path is not in the tree now. */
                if (!B_IS_IN_TREE
-                   (p_s_parent =
-                    PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)))
+                   (parent =
+                    PATH_OFFSET_PBUFFER(chk_path, path_offset)))
                        return &MIN_KEY;
                /* Check whether position in the parent is correct. */
-               if ((n_position =
-                    PATH_OFFSET_POSITION(p_s_chk_path,
-                                         n_path_offset)) >
-                   B_NR_ITEMS(p_s_parent))
+               if ((position =
+                    PATH_OFFSET_POSITION(chk_path,
+                                         path_offset)) >
+                   B_NR_ITEMS(parent))
                        return &MIN_KEY;
                /* Check whether parent at the path really points to the child. */
-               if (B_N_CHILD_NUM(p_s_parent, n_position) !=
-                   PATH_OFFSET_PBUFFER(p_s_chk_path,
-                                       n_path_offset + 1)->b_blocknr)
+               if (B_N_CHILD_NUM(parent, position) !=
+                   PATH_OFFSET_PBUFFER(chk_path,
+                                       path_offset + 1)->b_blocknr)
                        return &MIN_KEY;
                /* Return delimiting key if position in the parent is not the last one. */
-               if (n_position != B_NR_ITEMS(p_s_parent))
-                       return B_N_PDELIM_KEY(p_s_parent, n_position);
+               if (position != B_NR_ITEMS(parent))
+                       return B_N_PDELIM_KEY(parent, position);
        }
        /* Return MAX_KEY if we are in the root of the buffer tree. */
-       if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
-           b_blocknr == SB_ROOT_BLOCK(p_s_sb))
+       if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)->
+           b_blocknr == SB_ROOT_BLOCK(sb))
                return &MAX_KEY;
        return &MIN_KEY;
  }
     the path.  These delimiting keys are stored at least one level above that buffer in the tree. If the
     buffer is the first or last node in the tree order then one of the delimiting keys may be absent, and in
     this case get_lkey and get_rkey return a special key which is MIN_KEY or MAX_KEY. */
- static inline int key_in_buffer(struct treepath *p_s_chk_path,        /* Path which should be checked.  */
-                               const struct cpu_key *p_s_key,  /* Key which should be checked.   */
-                               struct super_block *p_s_sb      /* Super block pointer.           */
+ static inline int key_in_buffer(struct treepath *chk_path,    /* Path which should be checked.  */
+                               const struct cpu_key *key,      /* Key which should be checked.   */
+                               struct super_block *sb
      )
  {
  
-       RFALSE(!p_s_key || p_s_chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET
-              || p_s_chk_path->path_length > MAX_HEIGHT,
+       RFALSE(!key || chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET
+              || chk_path->path_length > MAX_HEIGHT,
               "PAP-5050: pointer to the key(%p) is NULL or invalid path length(%d)",
-              p_s_key, p_s_chk_path->path_length);
-       RFALSE(!PATH_PLAST_BUFFER(p_s_chk_path)->b_bdev,
+              key, chk_path->path_length);
+       RFALSE(!PATH_PLAST_BUFFER(chk_path)->b_bdev,
               "PAP-5060: device must not be NODEV");
  
-       if (comp_keys(get_lkey(p_s_chk_path, p_s_sb), p_s_key) == 1)
+       if (comp_keys(get_lkey(chk_path, sb), key) == 1)
                /* left delimiting key is bigger, that the key we look for */
                return 0;
-       //  if ( comp_keys(p_s_key, get_rkey(p_s_chk_path, p_s_sb)) != -1 )
-       if (comp_keys(get_rkey(p_s_chk_path, p_s_sb), p_s_key) != 1)
-               /* p_s_key must be less than right delimitiing key */
+       /*  if ( comp_keys(key, get_rkey(chk_path, sb)) != -1 ) */
+       if (comp_keys(get_rkey(chk_path, sb), key) != 1)
+               /* key must be less than right delimitiing key */
                return 0;
        return 1;
  }
  
- inline void decrement_bcount(struct buffer_head *p_s_bh)
- {
-       if (p_s_bh) {
-               if (atomic_read(&(p_s_bh->b_count))) {
-                       put_bh(p_s_bh);
-                       return;
-               }
-               reiserfs_panic(NULL,
-                              "PAP-5070: decrement_bcount: trying to free free buffer %b",
-                              p_s_bh);
-       }
- }
- /* Decrement b_count field of the all buffers in the path. */
- void decrement_counters_in_path(struct treepath *p_s_search_path)
- {
-       int n_path_offset = p_s_search_path->path_length;
-       RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET ||
-              n_path_offset > EXTENDED_MAX_HEIGHT - 1,
-              "PAP-5080: invalid path offset of %d", n_path_offset);
-       while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
-               struct buffer_head *bh;
-               bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
-               decrement_bcount(bh);
-       }
-       p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
- }
  int reiserfs_check_path(struct treepath *p)
  {
        RFALSE(p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET,
        return 0;
  }
  
- /* Release all buffers in the path. Restore dirty bits clean
- ** when preparing the buffer for the log
- **
- ** only called from fix_nodes()
- */
- void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_path)
+ /* Drop the reference to each buffer in a path and restore
+  * dirty bits clean when preparing the buffer for the log.
+  * This version should only be called from fix_nodes() */
+ void pathrelse_and_restore(struct super_block *sb,
+                          struct treepath *search_path)
  {
-       int n_path_offset = p_s_search_path->path_length;
+       int path_offset = search_path->path_length;
  
-       RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+       RFALSE(path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
               "clm-4000: invalid path offset");
  
-       while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
-               reiserfs_restore_prepared_buffer(s,
-                                                PATH_OFFSET_PBUFFER
-                                                (p_s_search_path,
-                                                 n_path_offset));
-               brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
+       while (path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
+               struct buffer_head *bh;
+               bh = PATH_OFFSET_PBUFFER(search_path, path_offset--);
+               reiserfs_restore_prepared_buffer(sb, bh);
+               brelse(bh);
        }
-       p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
+       search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
  }
  
- /* Release all buffers in the path. */
- void pathrelse(struct treepath *p_s_search_path)
+ /* Drop the reference to each buffer in a path */
+ void pathrelse(struct treepath *search_path)
  {
-       int n_path_offset = p_s_search_path->path_length;
+       int path_offset = search_path->path_length;
  
-       RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+       RFALSE(path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
               "PAP-5090: invalid path offset");
  
-       while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET)
-               brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
+       while (path_offset > ILLEGAL_PATH_ELEMENT_OFFSET)
+               brelse(PATH_OFFSET_PBUFFER(search_path, path_offset--));
  
-       p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
+       search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
  }
  
  static int is_leaf(char *buf, int blocksize, struct buffer_head *bh)
  
        blkh = (struct block_head *)buf;
        if (blkh_level(blkh) != DISK_LEAF_NODE_LEVEL) {
-               reiserfs_warning(NULL,
-                                "is_leaf: this should be caught earlier");
+               reiserfs_warning(NULL, "reiserfs-5080",
+                                "this should be caught earlier");
                return 0;
        }
  
        nr = blkh_nr_item(blkh);
        if (nr < 1 || nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN))) {
                /* item number is too big or too small */
-               reiserfs_warning(NULL, "is_leaf: nr_item seems wrong: %z", bh);
+               reiserfs_warning(NULL, "reiserfs-5081",
+                                "nr_item seems wrong: %z", bh);
                return 0;
        }
        ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1;
        used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - ih_location(ih));
        if (used_space != blocksize - blkh_free_space(blkh)) {
                /* free space does not match to calculated amount of use space */
-               reiserfs_warning(NULL, "is_leaf: free space seems wrong: %z",
-                                bh);
+               reiserfs_warning(NULL, "reiserfs-5082",
+                                "free space seems wrong: %z", bh);
                return 0;
        }
        // FIXME: it is_leaf will hit performance too much - we may have
        prev_location = blocksize;
        for (i = 0; i < nr; i++, ih++) {
                if (le_ih_k_type(ih) == TYPE_ANY) {
-                       reiserfs_warning(NULL,
-                                        "is_leaf: wrong item type for item %h",
+                       reiserfs_warning(NULL, "reiserfs-5083",
+                                        "wrong item type for item %h",
                                         ih);
                        return 0;
                }
                if (ih_location(ih) >= blocksize
                    || ih_location(ih) < IH_SIZE * nr) {
-                       reiserfs_warning(NULL,
-                                        "is_leaf: item location seems wrong: %h",
+                       reiserfs_warning(NULL, "reiserfs-5084",
+                                        "item location seems wrong: %h",
                                         ih);
                        return 0;
                }
                if (ih_item_len(ih) < 1
                    || ih_item_len(ih) > MAX_ITEM_LEN(blocksize)) {
-                       reiserfs_warning(NULL,
-                                        "is_leaf: item length seems wrong: %h",
+                       reiserfs_warning(NULL, "reiserfs-5085",
+                                        "item length seems wrong: %h",
                                         ih);
                        return 0;
                }
                if (prev_location - ih_location(ih) != ih_item_len(ih)) {
-                       reiserfs_warning(NULL,
-                                        "is_leaf: item location seems wrong (second one): %h",
-                                        ih);
+                       reiserfs_warning(NULL, "reiserfs-5086",
+                                        "item location seems wrong "
+                                        "(second one): %h", ih);
                        return 0;
                }
                prev_location = ih_location(ih);
@@@ -514,24 -478,23 +478,23 @@@ static int is_internal(char *buf, int b
        nr = blkh_level(blkh);
        if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) {
                /* this level is not possible for internal nodes */
-               reiserfs_warning(NULL,
-                                "is_internal: this should be caught earlier");
+               reiserfs_warning(NULL, "reiserfs-5087",
+                                "this should be caught earlier");
                return 0;
        }
  
        nr = blkh_nr_item(blkh);
        if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) {
                /* for internal which is not root we might check min number of keys */
-               reiserfs_warning(NULL,
-                                "is_internal: number of key seems wrong: %z",
-                                bh);
+               reiserfs_warning(NULL, "reiserfs-5088",
+                                "number of key seems wrong: %z", bh);
                return 0;
        }
  
        used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1);
        if (used_space != blocksize - blkh_free_space(blkh)) {
-               reiserfs_warning(NULL,
-                                "is_internal: free space seems wrong: %z", bh);
+               reiserfs_warning(NULL, "reiserfs-5089",
+                                "free space seems wrong: %z", bh);
                return 0;
        }
        // one may imagine much more checks
  static int is_tree_node(struct buffer_head *bh, int level)
  {
        if (B_LEVEL(bh) != level) {
-               reiserfs_warning(NULL,
-                                "is_tree_node: node level %d does not match to the expected one %d",
+               reiserfs_warning(NULL, "reiserfs-5090", "node level %d does "
+                                "not match to the expected one %d",
                                 B_LEVEL(bh), level);
                return 0;
        }
@@@ -580,10 -543,10 +543,10 @@@ static void search_by_key_reada(struct 
  /**************************************************************************
   * Algorithm   SearchByKey                                                *
   *             look for item in the Disk S+Tree by its key                *
-  * Input:  p_s_sb   -  super block                                        *
-  *         p_s_key  - pointer to the key to search                        *
+  * Input:  sb   -  super block                                            *
+  *         key  - pointer to the key to search                            *
   * Output: ITEM_FOUND, ITEM_NOT_FOUND or IO_ERROR                         *
-  *         p_s_search_path - path from the root to the needed leaf        *
+  *         search_path - path from the root to the needed leaf            *
   **************************************************************************/
  
  /* This function fills up the path from the root to the leaf as it
     correctness of the top of the path but need not be checked for the
     correctness of the bottom of the path */
  /* The function is NOT SCHEDULE-SAFE! */
- int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key,  /* Key to search. */
-                 struct treepath *p_s_search_path,/* This structure was
+ int search_by_key(struct super_block *sb, const struct cpu_key *key,  /* Key to search. */
+                 struct treepath *search_path,/* This structure was
                                                   allocated and initialized
                                                   by the calling
                                                   function. It is filled up
                                                   by this function.  */
-                 int n_stop_level      /* How far down the tree to search. To
+                 int stop_level        /* How far down the tree to search. To
                                           stop at leaf level - set to
                                           DISK_LEAF_NODE_LEVEL */
      )
  {
-       b_blocknr_t n_block_number;
+       b_blocknr_t block_number;
        int expected_level;
-       struct buffer_head *p_s_bh;
-       struct path_element *p_s_last_element;
-       int n_node_level, n_retval;
+       struct buffer_head *bh;
+       struct path_element *last_element;
+       int node_level, retval;
        int right_neighbor_of_leaf_node;
        int fs_gen;
        struct buffer_head *reada_bh[SEARCH_BY_KEY_READA];
        int reada_count = 0;
  
  #ifdef CONFIG_REISERFS_CHECK
-       int n_repeat_counter = 0;
+       int repeat_counter = 0;
  #endif
  
-       PROC_INFO_INC(p_s_sb, search_by_key);
+       PROC_INFO_INC(sb, search_by_key);
  
        /* As we add each node to a path we increase its count.  This means that
           we must be careful to release all nodes in a path before we either
           discard the path struct or re-use the path struct, as we do here. */
  
-       decrement_counters_in_path(p_s_search_path);
+       pathrelse(search_path);
  
        right_neighbor_of_leaf_node = 0;
  
        /* With each iteration of this loop we search through the items in the
           current node, and calculate the next current node(next path element)
           for the next iteration of this loop.. */
-       n_block_number = SB_ROOT_BLOCK(p_s_sb);
+       block_number = SB_ROOT_BLOCK(sb);
        expected_level = -1;
        while (1) {
  
  #ifdef CONFIG_REISERFS_CHECK
-               if (!(++n_repeat_counter % 50000))
-                       reiserfs_warning(p_s_sb, "PAP-5100: search_by_key: %s:"
-                                        "there were %d iterations of while loop "
-                                        "looking for key %K",
-                                        current->comm, n_repeat_counter,
-                                        p_s_key);
+               if (!(++repeat_counter % 50000))
+                       reiserfs_warning(sb, "PAP-5100",
+                                        "%s: there were %d iterations of "
+                                        "while loop looking for key %K",
+                                        current->comm, repeat_counter,
+                                        key);
  #endif
  
                /* prep path to have another element added to it. */
-               p_s_last_element =
-                   PATH_OFFSET_PELEMENT(p_s_search_path,
-                                        ++p_s_search_path->path_length);
-               fs_gen = get_generation(p_s_sb);
+               last_element =
+                   PATH_OFFSET_PELEMENT(search_path,
+                                        ++search_path->path_length);
+               fs_gen = get_generation(sb);
  
                /* Read the next tree node, and set the last element in the path to
                   have a pointer to it. */
-               if ((p_s_bh = p_s_last_element->pe_buffer =
-                    sb_getblk(p_s_sb, n_block_number))) {
-                       if (!buffer_uptodate(p_s_bh) && reada_count > 1) {
-                               search_by_key_reada(p_s_sb, reada_bh,
+               if ((bh = last_element->pe_buffer =
+                    sb_getblk(sb, block_number))) {
+                       if (!buffer_uptodate(bh) && reada_count > 1)
+                               search_by_key_reada(sb, reada_bh,
                                                    reada_blocks, reada_count);
-                       }
-                       ll_rw_block(READ, 1, &p_s_bh);
-                       wait_on_buffer(p_s_bh);
-                       if (!buffer_uptodate(p_s_bh))
+                       ll_rw_block(READ, 1, &bh);
+                       wait_on_buffer(bh);
+                       if (!buffer_uptodate(bh))
                                goto io_error;
                } else {
                      io_error:
-                       p_s_search_path->path_length--;
-                       pathrelse(p_s_search_path);
+                       search_path->path_length--;
+                       pathrelse(search_path);
                        return IO_ERROR;
                }
                reada_count = 0;
                if (expected_level == -1)
-                       expected_level = SB_TREE_HEIGHT(p_s_sb);
+                       expected_level = SB_TREE_HEIGHT(sb);
                expected_level--;
  
                /* It is possible that schedule occurred. We must check whether the key
                   to search is still in the tree rooted from the current buffer. If
                   not then repeat search from the root. */
-               if (fs_changed(fs_gen, p_s_sb) &&
-                   (!B_IS_IN_TREE(p_s_bh) ||
-                    B_LEVEL(p_s_bh) != expected_level ||
-                    !key_in_buffer(p_s_search_path, p_s_key, p_s_sb))) {
-                       PROC_INFO_INC(p_s_sb, search_by_key_fs_changed);
-                       PROC_INFO_INC(p_s_sb, search_by_key_restarted);
-                       PROC_INFO_INC(p_s_sb,
+               if (fs_changed(fs_gen, sb) &&
+                   (!B_IS_IN_TREE(bh) ||
+                    B_LEVEL(bh) != expected_level ||
+                    !key_in_buffer(search_path, key, sb))) {
+                       PROC_INFO_INC(sb, search_by_key_fs_changed);
+                       PROC_INFO_INC(sb, search_by_key_restarted);
+                       PROC_INFO_INC(sb,
                                      sbk_restarted[expected_level - 1]);
-                       decrement_counters_in_path(p_s_search_path);
+                       pathrelse(search_path);
  
                        /* Get the root block number so that we can repeat the search
                           starting from the root. */
-                       n_block_number = SB_ROOT_BLOCK(p_s_sb);
+                       block_number = SB_ROOT_BLOCK(sb);
                        expected_level = -1;
                        right_neighbor_of_leaf_node = 0;
  
                        continue;
                }
  
-               /* only check that the key is in the buffer if p_s_key is not
+               /* only check that the key is in the buffer if key is not
                   equal to the MAX_KEY. Latter case is only possible in
                   "finish_unfinished()" processing during mount. */
-               RFALSE(comp_keys(&MAX_KEY, p_s_key) &&
-                      !key_in_buffer(p_s_search_path, p_s_key, p_s_sb),
+               RFALSE(comp_keys(&MAX_KEY, key) &&
+                      !key_in_buffer(search_path, key, sb),
                       "PAP-5130: key is not in the buffer");
  #ifdef CONFIG_REISERFS_CHECK
                if (cur_tb) {
                        print_cur_tb("5140");
-                       reiserfs_panic(p_s_sb,
-                                      "PAP-5140: search_by_key: schedule occurred in do_balance!");
+                       reiserfs_panic(sb, "PAP-5140",
+                                      "schedule occurred in do_balance!");
                }
  #endif
  
                // make sure, that the node contents look like a node of
                // certain level
-               if (!is_tree_node(p_s_bh, expected_level)) {
-                       reiserfs_warning(p_s_sb, "vs-5150: search_by_key: "
-                                        "invalid format found in block %ld. Fsck?",
-                                        p_s_bh->b_blocknr);
-                       pathrelse(p_s_search_path);
+               if (!is_tree_node(bh, expected_level)) {
+                       reiserfs_error(sb, "vs-5150",
+                                      "invalid format found in block %ld. "
+                                      "Fsck?", bh->b_blocknr);
+                       pathrelse(search_path);
                        return IO_ERROR;
                }
  
                /* ok, we have acquired next formatted node in the tree */
-               n_node_level = B_LEVEL(p_s_bh);
+               node_level = B_LEVEL(bh);
  
-               PROC_INFO_BH_STAT(p_s_sb, p_s_bh, n_node_level - 1);
+               PROC_INFO_BH_STAT(sb, bh, node_level - 1);
  
-               RFALSE(n_node_level < n_stop_level,
+               RFALSE(node_level < stop_level,
                       "vs-5152: tree level (%d) is less than stop level (%d)",
-                      n_node_level, n_stop_level);
+                      node_level, stop_level);
  
-               n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(p_s_bh, 0),
-                                     B_NR_ITEMS(p_s_bh),
-                                     (n_node_level ==
+               retval = bin_search(key, B_N_PITEM_HEAD(bh, 0),
+                                     B_NR_ITEMS(bh),
+                                     (node_level ==
                                       DISK_LEAF_NODE_LEVEL) ? IH_SIZE :
                                      KEY_SIZE,
-                                     &(p_s_last_element->pe_position));
-               if (n_node_level == n_stop_level) {
-                       return n_retval;
+                                     &(last_element->pe_position));
+               if (node_level == stop_level) {
+                       return retval;
                }
  
                /* we are not in the stop level */
-               if (n_retval == ITEM_FOUND)
+               if (retval == ITEM_FOUND)
                        /* item has been found, so we choose the pointer which is to the right of the found one */
-                       p_s_last_element->pe_position++;
+                       last_element->pe_position++;
  
                /* if item was not found we choose the position which is to
                   the left of the found item. This requires no code,
                /* So we have chosen a position in the current node which is
                   an internal node.  Now we calculate child block number by
                   position in the node. */
-               n_block_number =
-                   B_N_CHILD_NUM(p_s_bh, p_s_last_element->pe_position);
+               block_number =
+                   B_N_CHILD_NUM(bh, last_element->pe_position);
  
                /* if we are going to read leaf nodes, try for read ahead as well */
-               if ((p_s_search_path->reada & PATH_READA) &&
-                   n_node_level == DISK_LEAF_NODE_LEVEL + 1) {
-                       int pos = p_s_last_element->pe_position;
-                       int limit = B_NR_ITEMS(p_s_bh);
+               if ((search_path->reada & PATH_READA) &&
+                   node_level == DISK_LEAF_NODE_LEVEL + 1) {
+                       int pos = last_element->pe_position;
+                       int limit = B_NR_ITEMS(bh);
                        struct reiserfs_key *le_key;
  
-                       if (p_s_search_path->reada & PATH_READA_BACK)
+                       if (search_path->reada & PATH_READA_BACK)
                                limit = 0;
                        while (reada_count < SEARCH_BY_KEY_READA) {
                                if (pos == limit)
                                        break;
                                reada_blocks[reada_count++] =
-                                   B_N_CHILD_NUM(p_s_bh, pos);
-                               if (p_s_search_path->reada & PATH_READA_BACK)
+                                   B_N_CHILD_NUM(bh, pos);
+                               if (search_path->reada & PATH_READA_BACK)
                                        pos--;
                                else
                                        pos++;
                                /*
                                 * check to make sure we're in the same object
                                 */
-                               le_key = B_N_PDELIM_KEY(p_s_bh, pos);
+                               le_key = B_N_PDELIM_KEY(bh, pos);
                                if (le32_to_cpu(le_key->k_objectid) !=
-                                   p_s_key->on_disk_key.k_objectid) {
+                                   key->on_disk_key.k_objectid) {
                                        break;
                                }
                        }
  }
  
  /* Form the path to an item and position in this item which contains
-    file byte defined by p_s_key. If there is no such item
+    file byte defined by key. If there is no such item
     corresponding to the key, we point the path to the item with
-    maximal key less than p_s_key, and *p_n_pos_in_item is set to one
+    maximal key less than key, and *pos_in_item is set to one
     past the last entry/byte in the item.  If searching for entry in a
-    directory item, and it is not found, *p_n_pos_in_item is set to one
+    directory item, and it is not found, *pos_in_item is set to one
     entry more than the entry with maximal key which is less than the
     sought key.
  
     units of directory entries.  */
  
  /* The function is NOT SCHEDULE-SAFE! */
- int search_for_position_by_key(struct super_block *p_s_sb,    /* Pointer to the super block.          */
+ int search_for_position_by_key(struct super_block *sb,        /* Pointer to the super block.          */
                               const struct cpu_key *p_cpu_key, /* Key to search (cpu variable)         */
-                              struct treepath *p_s_search_path /* Filled up by this function.          */
+                              struct treepath *search_path     /* Filled up by this function.          */
      )
  {
        struct item_head *p_le_ih;      /* pointer to on-disk structure */
-       int n_blk_size;
+       int blk_size;
        loff_t item_offset, offset;
        struct reiserfs_dir_entry de;
        int retval;
  
        /* If searching for directory entry. */
        if (is_direntry_cpu_key(p_cpu_key))
-               return search_by_entry_key(p_s_sb, p_cpu_key, p_s_search_path,
+               return search_by_entry_key(sb, p_cpu_key, search_path,
                                           &de);
  
        /* If not searching for directory entry. */
  
        /* If item is found. */
-       retval = search_item(p_s_sb, p_cpu_key, p_s_search_path);
+       retval = search_item(sb, p_cpu_key, search_path);
        if (retval == IO_ERROR)
                return retval;
        if (retval == ITEM_FOUND) {
  
                RFALSE(!ih_item_len
                       (B_N_PITEM_HEAD
-                       (PATH_PLAST_BUFFER(p_s_search_path),
-                        PATH_LAST_POSITION(p_s_search_path))),
+                       (PATH_PLAST_BUFFER(search_path),
+                        PATH_LAST_POSITION(search_path))),
                       "PAP-5165: item length equals zero");
  
-               pos_in_item(p_s_search_path) = 0;
+               pos_in_item(search_path) = 0;
                return POSITION_FOUND;
        }
  
-       RFALSE(!PATH_LAST_POSITION(p_s_search_path),
+       RFALSE(!PATH_LAST_POSITION(search_path),
               "PAP-5170: position equals zero");
  
        /* Item is not found. Set path to the previous item. */
        p_le_ih =
-           B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path),
-                          --PATH_LAST_POSITION(p_s_search_path));
-       n_blk_size = p_s_sb->s_blocksize;
+           B_N_PITEM_HEAD(PATH_PLAST_BUFFER(search_path),
+                          --PATH_LAST_POSITION(search_path));
+       blk_size = sb->s_blocksize;
  
        if (comp_short_keys(&(p_le_ih->ih_key), p_cpu_key)) {
                return FILE_NOT_FOUND;
  
        /* Needed byte is contained in the item pointed to by the path. */
        if (item_offset <= offset &&
-           item_offset + op_bytes_number(p_le_ih, n_blk_size) > offset) {
-               pos_in_item(p_s_search_path) = offset - item_offset;
+           item_offset + op_bytes_number(p_le_ih, blk_size) > offset) {
+               pos_in_item(search_path) = offset - item_offset;
                if (is_indirect_le_ih(p_le_ih)) {
-                       pos_in_item(p_s_search_path) /= n_blk_size;
+                       pos_in_item(search_path) /= blk_size;
                }
                return POSITION_FOUND;
        }
        /* Needed byte is not contained in the item pointed to by the
           path. Set pos_in_item out of the item. */
        if (is_indirect_le_ih(p_le_ih))
-               pos_in_item(p_s_search_path) =
+               pos_in_item(search_path) =
                    ih_item_len(p_le_ih) / UNFM_P_SIZE;
        else
-               pos_in_item(p_s_search_path) = ih_item_len(p_le_ih);
+               pos_in_item(search_path) = ih_item_len(p_le_ih);
  
        return POSITION_NOT_FOUND;
  }
  
  /* Compare given item and item pointed to by the path. */
- int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path)
+ int comp_items(const struct item_head *stored_ih, const struct treepath *path)
  {
-       struct buffer_head *p_s_bh;
+       struct buffer_head *bh = PATH_PLAST_BUFFER(path);
        struct item_head *ih;
  
        /* Last buffer at the path is not in the tree. */
-       if (!B_IS_IN_TREE(p_s_bh = PATH_PLAST_BUFFER(p_s_path)))
+       if (!B_IS_IN_TREE(bh))
                return 1;
  
        /* Last path position is invalid. */
-       if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(p_s_bh))
+       if (PATH_LAST_POSITION(path) >= B_NR_ITEMS(bh))
                return 1;
  
        /* we need only to know, whether it is the same item */
-       ih = get_ih(p_s_path);
+       ih = get_ih(path);
        return memcmp(stored_ih, ih, IH_SIZE);
  }
  
@@@ -924,9 -886,9 +886,9 @@@ static inline int prepare_for_direct_it
        }
        // new file gets truncated
        if (get_inode_item_key_version(inode) == KEY_FORMAT_3_6) {
-               // 
+               //
                round_len = ROUND_UP(new_file_length);
-               /* this was n_new_file_length < le_ih ... */
+               /* this was new_file_length < le_ih ... */
                if (round_len < le_ih_k_offset(le_ih)) {
                        *cut_size = -(IH_SIZE + ih_item_len(le_ih));
                        return M_DELETE;        /* Delete this item. */
@@@ -986,96 -948,95 +948,95 @@@ static inline int prepare_for_direntry_
      In case of file truncate calculate whether this item must be deleted/truncated or last
      unformatted node of this item will be converted to a direct item.
      This function returns a determination of what balance mode the calling function should employ. */
- static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *p_s_path, const struct cpu_key *p_s_item_key, int *p_n_removed,   /* Number of unformatted nodes which were removed
+ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *path, const struct cpu_key *item_key, int *removed,       /* Number of unformatted nodes which were removed
                                                                                                                                                                                   from end of the file. */
-                                     int *p_n_cut_size, unsigned long long n_new_file_length   /* MAX_KEY_OFFSET in case of delete. */
+                                     int *cut_size, unsigned long long new_file_length /* MAX_KEY_OFFSET in case of delete. */
      )
  {
-       struct super_block *p_s_sb = inode->i_sb;
-       struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_path);
-       struct buffer_head *p_s_bh = PATH_PLAST_BUFFER(p_s_path);
+       struct super_block *sb = inode->i_sb;
+       struct item_head *p_le_ih = PATH_PITEM_HEAD(path);
+       struct buffer_head *bh = PATH_PLAST_BUFFER(path);
  
        BUG_ON(!th->t_trans_id);
  
        /* Stat_data item. */
        if (is_statdata_le_ih(p_le_ih)) {
  
-               RFALSE(n_new_file_length != max_reiserfs_offset(inode),
+               RFALSE(new_file_length != max_reiserfs_offset(inode),
                       "PAP-5210: mode must be M_DELETE");
  
-               *p_n_cut_size = -(IH_SIZE + ih_item_len(p_le_ih));
+               *cut_size = -(IH_SIZE + ih_item_len(p_le_ih));
                return M_DELETE;
        }
  
        /* Directory item. */
        if (is_direntry_le_ih(p_le_ih))
-               return prepare_for_direntry_item(p_s_path, p_le_ih, inode,
-                                                n_new_file_length,
-                                                p_n_cut_size);
+               return prepare_for_direntry_item(path, p_le_ih, inode,
+                                                new_file_length,
+                                                cut_size);
  
        /* Direct item. */
        if (is_direct_le_ih(p_le_ih))
-               return prepare_for_direct_item(p_s_path, p_le_ih, inode,
-                                              n_new_file_length, p_n_cut_size);
+               return prepare_for_direct_item(path, p_le_ih, inode,
+                                              new_file_length, cut_size);
  
        /* Case of an indirect item. */
        {
-           int blk_size = p_s_sb->s_blocksize;
+           int blk_size = sb->s_blocksize;
            struct item_head s_ih;
            int need_re_search;
            int delete = 0;
            int result = M_CUT;
            int pos = 0;
  
-           if ( n_new_file_length == max_reiserfs_offset (inode) ) {
+           if ( new_file_length == max_reiserfs_offset (inode) ) {
                /* prepare_for_delete_or_cut() is called by
                 * reiserfs_delete_item() */
-               n_new_file_length = 0;
+               new_file_length = 0;
                delete = 1;
            }
  
            do {
                need_re_search = 0;
-               *p_n_cut_size = 0;
-               p_s_bh = PATH_PLAST_BUFFER(p_s_path);
-               copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+               *cut_size = 0;
+               bh = PATH_PLAST_BUFFER(path);
+               copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
                pos = I_UNFM_NUM(&s_ih);
  
-               while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) {
+               while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > new_file_length) {
                    __le32 *unfm;
                    __u32 block;
  
                    /* Each unformatted block deletion may involve one additional
                     * bitmap block into the transaction, thereby the initial
                     * journal space reservation might not be enough. */
-                   if (!delete && (*p_n_cut_size) != 0 &&
-                       reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
+                   if (!delete && (*cut_size) != 0 &&
+                       reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD)
                        break;
-                   }
  
-                   unfm = (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1;
+                   unfm = (__le32 *)B_I_PITEM(bh, &s_ih) + pos - 1;
                    block = get_block_num(unfm, 0);
  
                    if (block != 0) {
-                       reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1);
+                       reiserfs_prepare_for_journal(sb, bh, 1);
                        put_block_num(unfm, 0, 0);
-                       journal_mark_dirty (th, p_s_sb, p_s_bh);
+                       journal_mark_dirty(th, sb, bh);
                        reiserfs_free_block(th, inode, block, 1);
                    }
  
                    cond_resched();
  
-                   if (item_moved (&s_ih, p_s_path))  {
+                   if (item_moved (&s_ih, path))  {
                        need_re_search = 1;
                        break;
                    }
  
                    pos --;
-                   (*p_n_removed) ++;
-                   (*p_n_cut_size) -= UNFM_P_SIZE;
+                   (*removed)++;
+                   (*cut_size) -= UNFM_P_SIZE;
  
                    if (pos == 0) {
-                       (*p_n_cut_size) -= IH_SIZE;
+                       (*cut_size) -= IH_SIZE;
                        result = M_DELETE;
                        break;
                    }
                /* a trick.  If the buffer has been logged, this will do nothing.  If
                ** we've broken the loop without logging it, it will restore the
                ** buffer */
-               reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh);
+               reiserfs_restore_prepared_buffer(sb, bh);
            } while (need_re_search &&
-                    search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_FOUND);
-           pos_in_item(p_s_path) = pos * UNFM_P_SIZE;
+                    search_for_position_by_key(sb, item_key, path) == POSITION_FOUND);
+           pos_in_item(path) = pos * UNFM_P_SIZE;
  
-           if (*p_n_cut_size == 0) {
+           if (*cut_size == 0) {
                /* Nothing were cut. maybe convert last unformatted node to the
                 * direct item? */
                result = M_CONVERT;
  }
  
  /* Calculate number of bytes which will be deleted or cut during balance */
- static int calc_deleted_bytes_number(struct tree_balance *p_s_tb, char c_mode)
+ static int calc_deleted_bytes_number(struct tree_balance *tb, char mode)
  {
-       int n_del_size;
-       struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_tb->tb_path);
+       int del_size;
+       struct item_head *p_le_ih = PATH_PITEM_HEAD(tb->tb_path);
  
        if (is_statdata_le_ih(p_le_ih))
                return 0;
  
-       n_del_size =
-           (c_mode ==
-            M_DELETE) ? ih_item_len(p_le_ih) : -p_s_tb->insert_size[0];
+       del_size =
+           (mode ==
+            M_DELETE) ? ih_item_len(p_le_ih) : -tb->insert_size[0];
        if (is_direntry_le_ih(p_le_ih)) {
-               // return EMPTY_DIR_SIZE; /* We delete emty directoris only. */
-               // we can't use EMPTY_DIR_SIZE, as old format dirs have a different
-               // empty size.  ick. FIXME, is this right?
-               //
-               return n_del_size;
+               /* return EMPTY_DIR_SIZE; We delete emty directoris only.
+                * we can't use EMPTY_DIR_SIZE, as old format dirs have a different
+                * empty size.  ick. FIXME, is this right? */
+               return del_size;
        }
  
        if (is_indirect_le_ih(p_le_ih))
-               n_del_size = (n_del_size / UNFM_P_SIZE) * (PATH_PLAST_BUFFER(p_s_tb->tb_path)->b_size); // - get_ih_free_space (p_le_ih);
-       return n_del_size;
+               del_size = (del_size / UNFM_P_SIZE) *
+                               (PATH_PLAST_BUFFER(tb->tb_path)->b_size);
+       return del_size;
  }
  
  static void init_tb_struct(struct reiserfs_transaction_handle *th,
-                          struct tree_balance *p_s_tb,
-                          struct super_block *p_s_sb,
-                          struct treepath *p_s_path, int n_size)
+                          struct tree_balance *tb,
+                          struct super_block *sb,
+                          struct treepath *path, int 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;
-       p_s_tb->tb_path = p_s_path;
-       PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
-       PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
-       p_s_tb->insert_size[0] = n_size;
+       memset(tb, '\0', sizeof(struct tree_balance));
+       tb->transaction_handle = th;
+       tb->tb_sb = sb;
+       tb->tb_path = path;
+       PATH_OFFSET_PBUFFER(path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
+       PATH_OFFSET_POSITION(path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
+       tb->insert_size[0] = size;
  }
  
  void padd_item(char *item, int total_length, int length)
@@@ -1175,73 -1136,77 +1136,77 @@@ char head2type(struct item_head *ih
  }
  #endif
  
- /* Delete object item. */
- int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path,   /* Path to the deleted item. */
-                        const struct cpu_key *p_s_item_key,    /* Key to search for the deleted item.  */
-                        struct inode *p_s_inode,       /* inode is here just to update i_blocks and quotas */
-                        struct buffer_head *p_s_un_bh)
- {                             /* NULL or unformatted node pointer.    */
-       struct super_block *p_s_sb = p_s_inode->i_sb;
+ /* Delete object item.
+  * th       - active transaction handle
+  * path     - path to the deleted item
+  * item_key - key to search for the deleted item
+  * indode   - used for updating i_blocks and quotas
+  * un_bh    - NULL or unformatted node pointer
+  */
+ int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
+                        struct treepath *path, const struct cpu_key *item_key,
+                        struct inode *inode, struct buffer_head *un_bh)
+ {
+       struct super_block *sb = inode->i_sb;
        struct tree_balance s_del_balance;
        struct item_head s_ih;
        struct item_head *q_ih;
        int quota_cut_bytes;
-       int n_ret_value, n_del_size, n_removed;
+       int ret_value, del_size, removed;
  
  #ifdef CONFIG_REISERFS_CHECK
-       char c_mode;
-       int n_iter = 0;
+       char mode;
+       int iter = 0;
  #endif
  
        BUG_ON(!th->t_trans_id);
  
-       init_tb_struct(th, &s_del_balance, p_s_sb, p_s_path,
+       init_tb_struct(th, &s_del_balance, sb, path,
                       0 /*size is unknown */ );
  
        while (1) {
-               n_removed = 0;
+               removed = 0;
  
  #ifdef CONFIG_REISERFS_CHECK
-               n_iter++;
-               c_mode =
+               iter++;
+               mode =
  #endif
-                   prepare_for_delete_or_cut(th, p_s_inode, p_s_path,
-                                             p_s_item_key, &n_removed,
-                                             &n_del_size,
-                                             max_reiserfs_offset(p_s_inode));
+                   prepare_for_delete_or_cut(th, inode, path,
+                                             item_key, &removed,
+                                             &del_size,
+                                             max_reiserfs_offset(inode));
  
-               RFALSE(c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
+               RFALSE(mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
  
-               copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
-               s_del_balance.insert_size[0] = n_del_size;
+               copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
+               s_del_balance.insert_size[0] = del_size;
  
-               n_ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL);
-               if (n_ret_value != REPEAT_SEARCH)
+               ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL);
+               if (ret_value != REPEAT_SEARCH)
                        break;
  
-               PROC_INFO_INC(p_s_sb, delete_item_restarted);
+               PROC_INFO_INC(sb, delete_item_restarted);
  
                // file system changed, repeat search
-               n_ret_value =
-                   search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path);
-               if (n_ret_value == IO_ERROR)
+               ret_value =
+                   search_for_position_by_key(sb, item_key, path);
+               if (ret_value == IO_ERROR)
                        break;
-               if (n_ret_value == FILE_NOT_FOUND) {
-                       reiserfs_warning(p_s_sb,
-                                        "vs-5340: reiserfs_delete_item: "
+               if (ret_value == FILE_NOT_FOUND) {
+                       reiserfs_warning(sb, "vs-5340",
                                         "no items of the file %K found",
-                                        p_s_item_key);
+                                        item_key);
                        break;
                }
        }                       /* while (1) */
  
-       if (n_ret_value != CARRY_ON) {
+       if (ret_value != CARRY_ON) {
                unfix_nodes(&s_del_balance);
                return 0;
        }
        // reiserfs_delete_item returns item length when success
-       n_ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE);
-       q_ih = get_ih(p_s_path);
+       ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE);
+       q_ih = get_ih(path);
        quota_cut_bytes = ih_item_len(q_ih);
  
        /* hack so the quota code doesn't have to guess if the file
         ** split into multiple items, and we only want to decrement for
         ** the unfm node once
         */
-       if (!S_ISLNK(p_s_inode->i_mode) && is_direct_le_ih(q_ih)) {
-               if ((le_ih_k_offset(q_ih) & (p_s_sb->s_blocksize - 1)) == 1) {
-                       quota_cut_bytes = p_s_sb->s_blocksize + UNFM_P_SIZE;
+       if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(q_ih)) {
+               if ((le_ih_k_offset(q_ih) & (sb->s_blocksize - 1)) == 1) {
+                       quota_cut_bytes = sb->s_blocksize + UNFM_P_SIZE;
                } else {
                        quota_cut_bytes = 0;
                }
        }
  
-       if (p_s_un_bh) {
+       if (un_bh) {
                int off;
                char *data;
  
                 ** The unformatted node must be dirtied later on.  We can't be
                 ** sure here if the entire tail has been deleted yet.
                 **
-                ** p_s_un_bh is from the page cache (all unformatted nodes are
+                ** un_bh is from the page cache (all unformatted nodes are
                 ** from the page cache) and might be a highmem page.  So, we
-                ** can't use p_s_un_bh->b_data.
+                ** can't use un_bh->b_data.
                 ** -clm
                 */
  
-               data = kmap_atomic(p_s_un_bh->b_page, KM_USER0);
+               data = kmap_atomic(un_bh->b_page, KM_USER0);
                off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1));
                memcpy(data + off,
-                      B_I_PITEM(PATH_PLAST_BUFFER(p_s_path), &s_ih),
-                      n_ret_value);
+                      B_I_PITEM(PATH_PLAST_BUFFER(path), &s_ih),
+                      ret_value);
                kunmap_atomic(data, KM_USER0);
        }
        /* Perform balancing after all resources have been collected at once. */
        do_balance(&s_del_balance, NULL, NULL, M_DELETE);
  
  #ifdef REISERQUOTA_DEBUG
-       reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+       reiserfs_debug(sb, REISERFS_DEBUG_CODE,
                       "reiserquota delete_item(): freeing %u, id=%u type=%c",
-                      quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
+                      quota_cut_bytes, inode->i_uid, head2type(&s_ih));
  #endif
-       vfs_dq_free_space_nodirty(p_s_inode, quota_cut_bytes);
 -      DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes);
++      vfs_dq_free_space_nodirty(inode, quota_cut_bytes);
  
        /* Return deleted body length */
-       return n_ret_value;
+       return ret_value;
  }
  
  /* Summary Of Mechanisms For Handling Collisions Between Processes:
@@@ -1338,10 -1303,9 +1303,9 @@@ void reiserfs_delete_solid_item(struct 
        while (1) {
                retval = search_item(th->t_super, &cpu_key, &path);
                if (retval == IO_ERROR) {
-                       reiserfs_warning(th->t_super,
-                                        "vs-5350: reiserfs_delete_solid_item: "
-                                        "i/o failure occurred trying to delete %K",
-                                        &cpu_key);
+                       reiserfs_error(th->t_super, "vs-5350",
+                                      "i/o failure occurred trying "
+                                      "to delete %K", &cpu_key);
                        break;
                }
                if (retval != ITEM_FOUND) {
                             GET_GENERATION_NUMBER(le_key_k_offset
                                                   (le_key_version(key),
                                                    key)) == 1))
-                               reiserfs_warning(th->t_super,
-                                                "vs-5355: reiserfs_delete_solid_item: %k not found",
-                                                key);
+                               reiserfs_warning(th->t_super, "vs-5355",
+                                                "%k not found", key);
                        break;
                }
                if (!tb_init) {
                                               quota_cut_bytes, inode->i_uid,
                                               key2type(key));
  #endif
 -                              DQUOT_FREE_SPACE_NODIRTY(inode,
 +                              vfs_dq_free_space_nodirty(inode,
                                                         quota_cut_bytes);
                        }
                        break;
                }
                // IO_ERROR, NO_DISK_SPACE, etc
-               reiserfs_warning(th->t_super,
-                                "vs-5360: reiserfs_delete_solid_item: "
+               reiserfs_warning(th->t_super, "vs-5360",
                                 "could not delete %K due to fix_nodes failure",
                                 &cpu_key);
                unfix_nodes(&tb);
@@@ -1462,36 -1424,37 +1424,37 @@@ static void unmap_buffers(struct page *
  }
  
  static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th,
-                                   struct inode *p_s_inode,
+                                   struct inode *inode,
                                    struct page *page,
-                                   struct treepath *p_s_path,
-                                   const struct cpu_key *p_s_item_key,
-                                   loff_t n_new_file_size, char *p_c_mode)
+                                   struct treepath *path,
+                                   const struct cpu_key *item_key,
+                                   loff_t new_file_size, char *mode)
  {
-       struct super_block *p_s_sb = p_s_inode->i_sb;
-       int n_block_size = p_s_sb->s_blocksize;
+       struct super_block *sb = inode->i_sb;
+       int block_size = sb->s_blocksize;
        int cut_bytes;
        BUG_ON(!th->t_trans_id);
-       BUG_ON(n_new_file_size != p_s_inode->i_size);
+       BUG_ON(new_file_size != inode->i_size);
  
        /* the page being sent in could be NULL if there was an i/o error
         ** reading in the last block.  The user will hit problems trying to
         ** read the file, but for now we just skip the indirect2direct
         */
-       if (atomic_read(&p_s_inode->i_count) > 1 ||
-           !tail_has_to_be_packed(p_s_inode) ||
-           !page || (REISERFS_I(p_s_inode)->i_flags & i_nopack_mask)) {
-               // leave tail in an unformatted node    
-               *p_c_mode = M_SKIP_BALANCING;
+       if (atomic_read(&inode->i_count) > 1 ||
+           !tail_has_to_be_packed(inode) ||
+           !page || (REISERFS_I(inode)->i_flags & i_nopack_mask)) {
+               /* leave tail in an unformatted node */
+               *mode = M_SKIP_BALANCING;
                cut_bytes =
-                   n_block_size - (n_new_file_size & (n_block_size - 1));
-               pathrelse(p_s_path);
+                   block_size - (new_file_size & (block_size - 1));
+               pathrelse(path);
                return cut_bytes;
        }
-       /* Permorm the conversion to a direct_item. */
-       /*return indirect_to_direct (p_s_inode, p_s_path, p_s_item_key, n_new_file_size, p_c_mode); */
-       return indirect2direct(th, p_s_inode, page, p_s_path, p_s_item_key,
-                              n_new_file_size, p_c_mode);
+       /* Perform the conversion to a direct_item. */
+       /* return indirect_to_direct(inode, path, item_key,
+                                 new_file_size, mode); */
+       return indirect2direct(th, inode, page, path, item_key,
+                              new_file_size, mode);
  }
  
  /* we did indirect_to_direct conversion. And we have inserted direct
@@@ -1515,8 -1478,8 +1478,8 @@@ static void indirect_to_direct_roll_bac
                /* look for the last byte of the tail */
                if (search_for_position_by_key(inode->i_sb, &tail_key, path) ==
                    POSITION_NOT_FOUND)
-                       reiserfs_panic(inode->i_sb,
-                                      "vs-5615: indirect_to_direct_roll_back: found invalid item");
+                       reiserfs_panic(inode->i_sb, "vs-5615",
+                                      "found invalid item");
                RFALSE(path->pos_in_item !=
                       ih_item_len(PATH_PITEM_HEAD(path)) - 1,
                       "vs-5616: appended bytes found");
                set_cpu_key_k_offset(&tail_key,
                                     cpu_key_k_offset(&tail_key) - removed);
        }
-       reiserfs_warning(inode->i_sb,
-                        "indirect_to_direct_roll_back: indirect_to_direct conversion has been rolled back due to lack of disk space");
+       reiserfs_warning(inode->i_sb, "reiserfs-5091", "indirect_to_direct "
+                        "conversion has been rolled back due to "
+                        "lack of disk space");
        //mark_file_without_tail (inode);
        mark_inode_dirty(inode);
  }
  
  /* (Truncate or cut entry) or delete object item. Returns < 0 on failure */
  int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
-                          struct treepath *p_s_path,
-                          struct cpu_key *p_s_item_key,
-                          struct inode *p_s_inode,
-                          struct page *page, loff_t n_new_file_size)
+                          struct treepath *path,
+                          struct cpu_key *item_key,
+                          struct inode *inode,
+                          struct page *page, loff_t new_file_size)
  {
-       struct super_block *p_s_sb = p_s_inode->i_sb;
+       struct super_block *sb = inode->i_sb;
        /* Every function which is going to call do_balance must first
           create a tree_balance structure.  Then it must fill up this
           structure by using the init_tb_struct and fix_nodes functions.
           After that we can make tree balancing. */
        struct tree_balance s_cut_balance;
        struct item_head *p_le_ih;
-       int n_cut_size = 0,     /* Amount to be cut. */
-           n_ret_value = CARRY_ON, n_removed = 0,      /* Number of the removed unformatted nodes. */
-           n_is_inode_locked = 0;
-       char c_mode;            /* Mode of the balance. */
+       int cut_size = 0,       /* Amount to be cut. */
+           ret_value = CARRY_ON, removed = 0,  /* Number of the removed unformatted nodes. */
+           is_inode_locked = 0;
+       char mode;              /* Mode of the balance. */
        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);
+       init_tb_struct(th, &s_cut_balance, inode->i_sb, path,
+                      cut_size);
  
        /* Repeat this loop until we either cut the item without needing
           to balance, or we fix_nodes without schedule occurring */
                   free unformatted nodes which are pointed to by the cut
                   pointers. */
  
-               c_mode =
-                   prepare_for_delete_or_cut(th, p_s_inode, p_s_path,
-                                             p_s_item_key, &n_removed,
-                                             &n_cut_size, n_new_file_size);
-               if (c_mode == M_CONVERT) {
+               mode =
+                   prepare_for_delete_or_cut(th, inode, path,
+                                             item_key, &removed,
+                                             &cut_size, new_file_size);
+               if (mode == M_CONVERT) {
                        /* convert last unformatted node to direct item or leave
                           tail in the unformatted node */
-                       RFALSE(n_ret_value != CARRY_ON,
+                       RFALSE(ret_value != CARRY_ON,
                               "PAP-5570: can not convert twice");
  
-                       n_ret_value =
-                           maybe_indirect_to_direct(th, p_s_inode, page,
-                                                    p_s_path, p_s_item_key,
-                                                    n_new_file_size, &c_mode);
-                       if (c_mode == M_SKIP_BALANCING)
+                       ret_value =
+                           maybe_indirect_to_direct(th, inode, page,
+                                                    path, item_key,
+                                                    new_file_size, &mode);
+                       if (mode == M_SKIP_BALANCING)
                                /* tail has been left in the unformatted node */
-                               return n_ret_value;
+                               return ret_value;
  
-                       n_is_inode_locked = 1;
+                       is_inode_locked = 1;
  
                        /* removing of last unformatted node will change value we
                           have to return to truncate. Save it */
-                       retval2 = n_ret_value;
-                       /*retval2 = p_s_sb->s_blocksize - (n_new_file_size & (p_s_sb->s_blocksize - 1)); */
+                       retval2 = ret_value;
+                       /*retval2 = sb->s_blocksize - (new_file_size & (sb->s_blocksize - 1)); */
  
                        /* So, we have performed the first part of the conversion:
                           inserting the new direct item.  Now we are removing the
                           last unformatted node pointer. Set key to search for
                           it. */
-                       set_cpu_key_k_type(p_s_item_key, TYPE_INDIRECT);
-                       p_s_item_key->key_length = 4;
-                       n_new_file_size -=
-                           (n_new_file_size & (p_s_sb->s_blocksize - 1));
-                       tail_pos = n_new_file_size;
-                       set_cpu_key_k_offset(p_s_item_key, n_new_file_size + 1);
+                       set_cpu_key_k_type(item_key, TYPE_INDIRECT);
+                       item_key->key_length = 4;
+                       new_file_size -=
+                           (new_file_size & (sb->s_blocksize - 1));
+                       tail_pos = new_file_size;
+                       set_cpu_key_k_offset(item_key, new_file_size + 1);
                        if (search_for_position_by_key
-                           (p_s_sb, p_s_item_key,
-                            p_s_path) == POSITION_NOT_FOUND) {
-                               print_block(PATH_PLAST_BUFFER(p_s_path), 3,
-                                           PATH_LAST_POSITION(p_s_path) - 1,
-                                           PATH_LAST_POSITION(p_s_path) + 1);
-                               reiserfs_panic(p_s_sb,
-                                              "PAP-5580: reiserfs_cut_from_item: item to convert does not exist (%K)",
-                                              p_s_item_key);
+                           (sb, item_key,
+                            path) == POSITION_NOT_FOUND) {
+                               print_block(PATH_PLAST_BUFFER(path), 3,
+                                           PATH_LAST_POSITION(path) - 1,
+                                           PATH_LAST_POSITION(path) + 1);
+                               reiserfs_panic(sb, "PAP-5580", "item to "
+                                              "convert does not exist (%K)",
+                                              item_key);
                        }
                        continue;
                }
-               if (n_cut_size == 0) {
-                       pathrelse(p_s_path);
+               if (cut_size == 0) {
+                       pathrelse(path);
                        return 0;
                }
  
-               s_cut_balance.insert_size[0] = n_cut_size;
+               s_cut_balance.insert_size[0] = cut_size;
  
-               n_ret_value = fix_nodes(c_mode, &s_cut_balance, NULL, NULL);
-               if (n_ret_value != REPEAT_SEARCH)
+               ret_value = fix_nodes(mode, &s_cut_balance, NULL, NULL);
+               if (ret_value != REPEAT_SEARCH)
                        break;
  
-               PROC_INFO_INC(p_s_sb, cut_from_item_restarted);
+               PROC_INFO_INC(sb, cut_from_item_restarted);
  
-               n_ret_value =
-                   search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path);
-               if (n_ret_value == POSITION_FOUND)
+               ret_value =
+                   search_for_position_by_key(sb, item_key, path);
+               if (ret_value == POSITION_FOUND)
                        continue;
  
-               reiserfs_warning(p_s_sb,
-                                "PAP-5610: reiserfs_cut_from_item: item %K not found",
-                                p_s_item_key);
+               reiserfs_warning(sb, "PAP-5610", "item %K not found",
+                                item_key);
                unfix_nodes(&s_cut_balance);
-               return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT;
+               return (ret_value == IO_ERROR) ? -EIO : -ENOENT;
        }                       /* while */
  
        // check fix_nodes results (IO_ERROR or NO_DISK_SPACE)
-       if (n_ret_value != CARRY_ON) {
-               if (n_is_inode_locked) {
+       if (ret_value != CARRY_ON) {
+               if (is_inode_locked) {
                        // FIXME: this seems to be not needed: we are always able
                        // to cut item
-                       indirect_to_direct_roll_back(th, p_s_inode, p_s_path);
+                       indirect_to_direct_roll_back(th, inode, path);
                }
-               if (n_ret_value == NO_DISK_SPACE)
-                       reiserfs_warning(p_s_sb, "NO_DISK_SPACE");
+               if (ret_value == NO_DISK_SPACE)
+                       reiserfs_warning(sb, "reiserfs-5092",
+                                        "NO_DISK_SPACE");
                unfix_nodes(&s_cut_balance);
                return -EIO;
        }
  
        /* go ahead and perform balancing */
  
-       RFALSE(c_mode == M_PASTE || c_mode == M_INSERT, "invalid mode");
+       RFALSE(mode == M_PASTE || mode == M_INSERT, "invalid mode");
  
        /* Calculate number of bytes that need to be cut from the item. */
        quota_cut_bytes =
-           (c_mode ==
-            M_DELETE) ? ih_item_len(get_ih(p_s_path)) : -s_cut_balance.
+           (mode ==
+            M_DELETE) ? ih_item_len(get_ih(path)) : -s_cut_balance.
            insert_size[0];
        if (retval2 == -1)
-               n_ret_value = calc_deleted_bytes_number(&s_cut_balance, c_mode);
+               ret_value = calc_deleted_bytes_number(&s_cut_balance, mode);
        else
-               n_ret_value = retval2;
+               ret_value = retval2;
  
        /* For direct items, we only change the quota when deleting the last
         ** item.
         */
        p_le_ih = PATH_PITEM_HEAD(s_cut_balance.tb_path);
-       if (!S_ISLNK(p_s_inode->i_mode) && is_direct_le_ih(p_le_ih)) {
-               if (c_mode == M_DELETE &&
-                   (le_ih_k_offset(p_le_ih) & (p_s_sb->s_blocksize - 1)) ==
+       if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_le_ih)) {
+               if (mode == M_DELETE &&
+                   (le_ih_k_offset(p_le_ih) & (sb->s_blocksize - 1)) ==
                    1) {
                        // FIXME: this is to keep 3.5 happy
-                       REISERFS_I(p_s_inode)->i_first_direct_byte = U32_MAX;
-                       quota_cut_bytes = p_s_sb->s_blocksize + UNFM_P_SIZE;
+                       REISERFS_I(inode)->i_first_direct_byte = U32_MAX;
+                       quota_cut_bytes = sb->s_blocksize + UNFM_P_SIZE;
                } else {
                        quota_cut_bytes = 0;
                }
        }
  #ifdef CONFIG_REISERFS_CHECK
-       if (n_is_inode_locked) {
+       if (is_inode_locked) {
                struct item_head *le_ih =
                    PATH_PITEM_HEAD(s_cut_balance.tb_path);
                /* we are going to complete indirect2direct conversion. Make
                   sure, that we exactly remove last unformatted node pointer
                   of the item */
                if (!is_indirect_le_ih(le_ih))
-                       reiserfs_panic(p_s_sb,
-                                      "vs-5652: reiserfs_cut_from_item: "
+                       reiserfs_panic(sb, "vs-5652",
                                       "item must be indirect %h", le_ih);
  
-               if (c_mode == M_DELETE && ih_item_len(le_ih) != UNFM_P_SIZE)
-                       reiserfs_panic(p_s_sb,
-                                      "vs-5653: reiserfs_cut_from_item: "
-                                      "completing indirect2direct conversion indirect item %h "
-                                      "being deleted must be of 4 byte long",
-                                      le_ih);
+               if (mode == M_DELETE && ih_item_len(le_ih) != UNFM_P_SIZE)
+                       reiserfs_panic(sb, "vs-5653", "completing "
+                                      "indirect2direct conversion indirect "
+                                      "item %h being deleted must be of "
+                                      "4 byte long", le_ih);
  
-               if (c_mode == M_CUT
+               if (mode == M_CUT
                    && s_cut_balance.insert_size[0] != -UNFM_P_SIZE) {
-                       reiserfs_panic(p_s_sb,
-                                      "vs-5654: reiserfs_cut_from_item: "
-                                      "can not complete indirect2direct conversion of %h (CUT, insert_size==%d)",
+                       reiserfs_panic(sb, "vs-5654", "can not complete "
+                                      "indirect2direct conversion of %h "
+                                      "(CUT, insert_size==%d)",
                                       le_ih, s_cut_balance.insert_size[0]);
                }
                /* it would be useful to make sure, that right neighboring
        }
  #endif
  
-       do_balance(&s_cut_balance, NULL, NULL, c_mode);
-       if (n_is_inode_locked) {
+       do_balance(&s_cut_balance, NULL, NULL, mode);
+       if (is_inode_locked) {
                /* we've done an indirect->direct conversion.  when the data block
                 ** was freed, it was removed from the list of blocks that must
                 ** be flushed before the transaction commits, make sure to
                 ** unmap and invalidate it
                 */
                unmap_buffers(page, tail_pos);
-               REISERFS_I(p_s_inode)->i_flags &= ~i_pack_on_close_mask;
+               REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
        }
  #ifdef REISERQUOTA_DEBUG
-       reiserfs_debug(p_s_inode->i_sb, REISERFS_DEBUG_CODE,
+       reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
                       "reiserquota cut_from_item(): freeing %u id=%u type=%c",
-                      quota_cut_bytes, p_s_inode->i_uid, '?');
+                      quota_cut_bytes, inode->i_uid, '?');
  #endif
-       vfs_dq_free_space_nodirty(p_s_inode, quota_cut_bytes);
-       return n_ret_value;
 -      DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes);
++      vfs_dq_free_space_nodirty(inode, quota_cut_bytes);
+       return ret_value;
  }
  
  static void truncate_directory(struct reiserfs_transaction_handle *th,
  {
        BUG_ON(!th->t_trans_id);
        if (inode->i_nlink)
-               reiserfs_warning(inode->i_sb,
-                                "vs-5655: truncate_directory: link count != 0");
+               reiserfs_error(inode->i_sb, "vs-5655", "link count != 0");
  
        set_le_key_k_offset(KEY_FORMAT_3_5, INODE_PKEY(inode), DOT_OFFSET);
        set_le_key_k_type(KEY_FORMAT_3_5, INODE_PKEY(inode), TYPE_DIRENTRY);
  
  /* 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, struct inode *p_s_inode,     /* ->i_size contains new
-                                                                                                  size */
+ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
+                         struct inode *inode,  /* ->i_size contains new size */
                         struct page *page,     /* up to date for last block */
                         int update_timestamps  /* when it is called by
                                                   file_release to convert
        INITIALIZE_PATH(s_search_path); /* Path to the current object item. */
        struct item_head *p_le_ih;      /* Pointer to an item header. */
        struct cpu_key s_item_key;      /* Key to search for a previous file item. */
-       loff_t n_file_size,     /* Old file size. */
-        n_new_file_size;       /* New file size. */
-       int n_deleted;          /* Number of deleted or truncated bytes. */
+       loff_t file_size,       /* Old file size. */
+        new_file_size; /* New file size. */
+       int 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)))
+           (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
+            || S_ISLNK(inode->i_mode)))
                return 0;
  
-       if (S_ISDIR(p_s_inode->i_mode)) {
+       if (S_ISDIR(inode->i_mode)) {
                // deletion of directory - no need to update timestamps
-               truncate_directory(th, p_s_inode);
+               truncate_directory(th, inode);
                return 0;
        }
  
        /* Get new file size. */
-       n_new_file_size = p_s_inode->i_size;
+       new_file_size = inode->i_size;
  
        // FIXME: note, that key type is unimportant here
-       make_cpu_key(&s_item_key, p_s_inode, max_reiserfs_offset(p_s_inode),
+       make_cpu_key(&s_item_key, inode, max_reiserfs_offset(inode),
                     TYPE_DIRECT, 3);
  
        retval =
-           search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
+           search_for_position_by_key(inode->i_sb, &s_item_key,
                                       &s_search_path);
        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);
+               reiserfs_error(inode->i_sb, "vs-5657",
+                              "i/o failure occurred trying to truncate %K",
+                              &s_item_key);
                err = -EIO;
                goto out;
        }
        if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
-               reiserfs_warning(p_s_inode->i_sb,
-                                "PAP-5660: reiserfs_do_truncate: "
-                                "wrong result %d of search for %K", retval,
-                                &s_item_key);
+               reiserfs_error(inode->i_sb, "PAP-5660",
+                              "wrong result %d of search for %K", retval,
+                              &s_item_key);
  
                err = -EIO;
                goto out;
        /* Get real file size (total length of all file items) */
        p_le_ih = PATH_PITEM_HEAD(&s_search_path);
        if (is_statdata_le_ih(p_le_ih))
-               n_file_size = 0;
+               file_size = 0;
        else {
                loff_t offset = le_ih_k_offset(p_le_ih);
                int bytes =
-                   op_bytes_number(p_le_ih, p_s_inode->i_sb->s_blocksize);
+                   op_bytes_number(p_le_ih, inode->i_sb->s_blocksize);
  
                /* this may mismatch with real file size: if last direct item
                   had no padding zeros and last unformatted node had no free
                   space, this file would have this file size */
-               n_file_size = offset + bytes - 1;
+               file_size = offset + bytes - 1;
        }
        /*
         * are we doing a full truncate or delete, if so
         * kick in the reada code
         */
-       if (n_new_file_size == 0)
+       if (new_file_size == 0)
                s_search_path.reada = PATH_READA | PATH_READA_BACK;
  
-       if (n_file_size == 0 || n_file_size < n_new_file_size) {
+       if (file_size == 0 || file_size < new_file_size) {
                goto update_and_out;
        }
  
        /* Update key to search for the last file item. */
-       set_cpu_key_k_offset(&s_item_key, n_file_size);
+       set_cpu_key_k_offset(&s_item_key, file_size);
  
        do {
                /* Cut or delete file item. */
-               n_deleted =
+               deleted =
                    reiserfs_cut_from_item(th, &s_search_path, &s_item_key,
-                                          p_s_inode, page, n_new_file_size);
-               if (n_deleted < 0) {
-                       reiserfs_warning(p_s_inode->i_sb,
-                                        "vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed");
+                                          inode, page, new_file_size);
+               if (deleted < 0) {
+                       reiserfs_warning(inode->i_sb, "vs-5665",
+                                        "reiserfs_cut_from_item failed");
                        reiserfs_check_path(&s_search_path);
                        return 0;
                }
  
-               RFALSE(n_deleted > n_file_size,
+               RFALSE(deleted > file_size,
                       "PAP-5670: reiserfs_cut_from_item: too many bytes deleted: deleted %d, file_size %lu, item_key %K",
-                      n_deleted, n_file_size, &s_item_key);
+                      deleted, file_size, &s_item_key);
  
                /* Change key to search the last file item. */
-               n_file_size -= n_deleted;
+               file_size -= deleted;
  
-               set_cpu_key_k_offset(&s_item_key, n_file_size);
+               set_cpu_key_k_offset(&s_item_key, file_size);
  
                /* While there are bytes to truncate and previous file item is presented in the tree. */
  
                /*
-                ** This loop could take a really long time, and could log 
+                ** This loop could take a really long time, and could log
                 ** many more blocks than a transaction can hold.  So, we do a polite
                 ** journal end here, and if the transaction needs ending, we make
                 ** sure the file is consistent before ending the current trans
                if (journal_transaction_should_end(th, 0) ||
                    reiserfs_transaction_free_space(th) <= JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
                        int orig_len_alloc = th->t_blocks_allocated;
-                       decrement_counters_in_path(&s_search_path);
+                       pathrelse(&s_search_path);
  
                        if (update_timestamps) {
-                               p_s_inode->i_mtime = p_s_inode->i_ctime =
-                                   CURRENT_TIME_SEC;
+                               inode->i_mtime = CURRENT_TIME_SEC;
+                               inode->i_ctime = CURRENT_TIME_SEC;
                        }
-                       reiserfs_update_sd(th, p_s_inode);
+                       reiserfs_update_sd(th, inode);
  
-                       err = journal_end(th, p_s_inode->i_sb, orig_len_alloc);
+                       err = journal_end(th, inode->i_sb, orig_len_alloc);
                        if (err)
                                goto out;
-                       err = journal_begin(th, p_s_inode->i_sb,
+                       err = journal_begin(th, inode->i_sb,
                                            JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD + JOURNAL_PER_BALANCE_CNT * 4) ;
                        if (err)
                                goto out;
-                       reiserfs_update_inode_transaction(p_s_inode);
+                       reiserfs_update_inode_transaction(inode);
                }
-       } while (n_file_size > ROUND_UP(n_new_file_size) &&
-                search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
+       } while (file_size > ROUND_UP(new_file_size) &&
+                search_for_position_by_key(inode->i_sb, &s_item_key,
                                            &s_search_path) == POSITION_FOUND);
  
-       RFALSE(n_file_size > ROUND_UP(n_new_file_size),
+       RFALSE(file_size > ROUND_UP(new_file_size),
               "PAP-5680: truncate did not finish: new_file_size %Ld, current %Ld, oid %d",
-              n_new_file_size, n_file_size, s_item_key.on_disk_key.k_objectid);
+              new_file_size, file_size, s_item_key.on_disk_key.k_objectid);
  
        update_and_out:
        if (update_timestamps) {
                // this is truncate, not file closing
-               p_s_inode->i_mtime = p_s_inode->i_ctime = CURRENT_TIME_SEC;
+               inode->i_mtime = CURRENT_TIME_SEC;
+               inode->i_ctime = CURRENT_TIME_SEC;
        }
-       reiserfs_update_sd(th, p_s_inode);
+       reiserfs_update_sd(th, inode);
  
        out:
        pathrelse(&s_search_path);
  #ifdef CONFIG_REISERFS_CHECK
  // this makes sure, that we __append__, not overwrite or add holes
  static void check_research_for_paste(struct treepath *path,
-                                    const struct cpu_key *p_s_key)
+                                    const struct cpu_key *key)
  {
        struct item_head *found_ih = get_ih(path);
  
                if (le_ih_k_offset(found_ih) +
                    op_bytes_number(found_ih,
                                    get_last_bh(path)->b_size) !=
-                   cpu_key_k_offset(p_s_key)
+                   cpu_key_k_offset(key)
                    || op_bytes_number(found_ih,
                                       get_last_bh(path)->b_size) !=
                    pos_in_item(path))
-                       reiserfs_panic(NULL,
-                                      "PAP-5720: check_research_for_paste: "
-                                      "found direct item %h or position (%d) does not match to key %K",
-                                      found_ih, pos_in_item(path), p_s_key);
+                       reiserfs_panic(NULL, "PAP-5720", "found direct item "
+                                      "%h or position (%d) does not match "
+                                      "to key %K", found_ih,
+                                      pos_in_item(path), key);
        }
        if (is_indirect_le_ih(found_ih)) {
                if (le_ih_k_offset(found_ih) +
                    op_bytes_number(found_ih,
                                    get_last_bh(path)->b_size) !=
-                   cpu_key_k_offset(p_s_key)
+                   cpu_key_k_offset(key)
                    || I_UNFM_NUM(found_ih) != pos_in_item(path)
                    || get_ih_free_space(found_ih) != 0)
-                       reiserfs_panic(NULL,
-                                      "PAP-5730: check_research_for_paste: "
-                                      "found indirect item (%h) or position (%d) does not match to key (%K)",
-                                      found_ih, pos_in_item(path), p_s_key);
+                       reiserfs_panic(NULL, "PAP-5730", "found indirect "
+                                      "item (%h) or position (%d) does not "
+                                      "match to key (%K)",
+                                      found_ih, pos_in_item(path), key);
        }
  }
  #endif                                /* config reiserfs check */
  
  /* Paste bytes to the existing item. Returns bytes number pasted into the item. */
- int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_search_path,        /* Path to the pasted item.          */
-                            const struct cpu_key *p_s_key,     /* Key to search for the needed item. */
+ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct treepath *search_path,    /* Path to the pasted item.       */
+                            const struct cpu_key *key, /* Key to search for the needed item. */
                             struct inode *inode,       /* Inode item belongs to */
-                            const char *p_c_body,      /* Pointer to the bytes to paste.    */
-                            int n_pasted_size)
+                            const char *body,  /* Pointer to the bytes to paste.    */
+                            int pasted_size)
  {                             /* Size of pasted bytes.             */
        struct tree_balance s_paste_balance;
        int retval;
  #ifdef REISERQUOTA_DEBUG
        reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
                       "reiserquota paste_into_item(): allocating %u id=%u type=%c",
-                      n_pasted_size, inode->i_uid,
-                      key2type(&(p_s_key->on_disk_key)));
+                      pasted_size, inode->i_uid,
+                      key2type(&(key->on_disk_key)));
  #endif
  
-       if (vfs_dq_alloc_space_nodirty(inode, n_pasted_size)) {
-               pathrelse(p_s_search_path);
 -      if (DQUOT_ALLOC_SPACE_NODIRTY(inode, pasted_size)) {
++      if (vfs_dq_alloc_space_nodirty(inode, pasted_size)) {
+               pathrelse(search_path);
                return -EDQUOT;
        }
-       init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
-                      n_pasted_size);
+       init_tb_struct(th, &s_paste_balance, th->t_super, search_path,
+                      pasted_size);
  #ifdef DISPLACE_NEW_PACKING_LOCALITIES
-       s_paste_balance.key = p_s_key->on_disk_key;
+       s_paste_balance.key = key->on_disk_key;
  #endif
  
        /* DQUOT_* can schedule, must check before the fix_nodes */
  
        while ((retval =
                fix_nodes(M_PASTE, &s_paste_balance, NULL,
-                         p_c_body)) == REPEAT_SEARCH) {
+                         body)) == REPEAT_SEARCH) {
              search_again:
                /* file system changed while we were in the fix_nodes */
                PROC_INFO_INC(th->t_super, paste_into_item_restarted);
                retval =
-                   search_for_position_by_key(th->t_super, p_s_key,
-                                              p_s_search_path);
+                   search_for_position_by_key(th->t_super, key,
+                                              search_path);
                if (retval == IO_ERROR) {
                        retval = -EIO;
                        goto error_out;
                }
                if (retval == POSITION_FOUND) {
-                       reiserfs_warning(inode->i_sb,
-                                        "PAP-5710: reiserfs_paste_into_item: entry or pasted byte (%K) exists",
-                                        p_s_key);
+                       reiserfs_warning(inode->i_sb, "PAP-5710",
+                                        "entry or pasted byte (%K) exists",
+                                        key);
                        retval = -EEXIST;
                        goto error_out;
                }
  #ifdef CONFIG_REISERFS_CHECK
-               check_research_for_paste(p_s_search_path, p_s_key);
+               check_research_for_paste(search_path, key);
  #endif
        }
  
        /* Perform balancing after all resources are collected by fix_nodes, and
           accessing them will not risk triggering schedule. */
        if (retval == CARRY_ON) {
-               do_balance(&s_paste_balance, NULL /*ih */ , p_c_body, M_PASTE);
+               do_balance(&s_paste_balance, NULL /*ih */ , body, M_PASTE);
                return 0;
        }
        retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO;
  #ifdef REISERQUOTA_DEBUG
        reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
                       "reiserquota paste_into_item(): freeing %u id=%u type=%c",
-                      n_pasted_size, inode->i_uid,
-                      key2type(&(p_s_key->on_disk_key)));
+                      pasted_size, inode->i_uid,
+                      key2type(&(key->on_disk_key)));
  #endif
-       vfs_dq_free_space_nodirty(inode, n_pasted_size);
 -      DQUOT_FREE_SPACE_NODIRTY(inode, pasted_size);
++      vfs_dq_free_space_nodirty(inode, pasted_size);
        return retval;
  }
  
- /* Insert new item into the buffer at the path. */
- int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path,   /* Path to the inserteded item.         */
-                        const struct cpu_key *key, struct item_head *p_s_ih,   /* Pointer to the item header to insert. */
-                        struct inode *inode, const char *p_c_body)
- {                             /* Pointer to the bytes to insert.      */
+ /* Insert new item into the buffer at the path.
+  * th   - active transaction handle
+  * path - path to the inserted item
+  * ih   - pointer to the item header to insert
+  * body - pointer to the bytes to insert
+  */
+ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
+                        struct treepath *path, const struct cpu_key *key,
+                        struct item_head *ih, struct inode *inode,
+                        const char *body)
+ {
        struct tree_balance s_ins_balance;
        int retval;
        int fs_gen = 0;
  
        if (inode) {            /* Do we count quotas for item? */
                fs_gen = get_generation(inode->i_sb);
-               quota_bytes = ih_item_len(p_s_ih);
+               quota_bytes = ih_item_len(ih);
  
                /* hack so the quota code doesn't have to guess if the file has
                 ** a tail, links are always tails, so there's no guessing needed
                 */
-               if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_s_ih)) {
+               if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(ih))
                        quota_bytes = inode->i_sb->s_blocksize + UNFM_P_SIZE;
-               }
  #ifdef REISERQUOTA_DEBUG
                reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
                               "reiserquota insert_item(): allocating %u id=%u type=%c",
-                              quota_bytes, inode->i_uid, head2type(p_s_ih));
+                              quota_bytes, inode->i_uid, head2type(ih));
  #endif
                /* We can't dirty inode here. It would be immediately written but
                 * appropriate stat item isn't inserted yet... */
 -              if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) {
 +              if (vfs_dq_alloc_space_nodirty(inode, quota_bytes)) {
-                       pathrelse(p_s_path);
+                       pathrelse(path);
                        return -EDQUOT;
                }
        }
-       init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
-                      IH_SIZE + ih_item_len(p_s_ih));
+       init_tb_struct(th, &s_ins_balance, th->t_super, path,
+                      IH_SIZE + ih_item_len(ih));
  #ifdef DISPLACE_NEW_PACKING_LOCALITIES
        s_ins_balance.key = key->on_disk_key;
  #endif
        }
  
        while ((retval =
-               fix_nodes(M_INSERT, &s_ins_balance, p_s_ih,
-                         p_c_body)) == REPEAT_SEARCH) {
+               fix_nodes(M_INSERT, &s_ins_balance, ih,
+                         body)) == REPEAT_SEARCH) {
              search_again:
                /* file system changed while we were in the fix_nodes */
                PROC_INFO_INC(th->t_super, insert_item_restarted);
-               retval = search_item(th->t_super, key, p_s_path);
+               retval = search_item(th->t_super, key, path);
                if (retval == IO_ERROR) {
                        retval = -EIO;
                        goto error_out;
                }
                if (retval == ITEM_FOUND) {
-                       reiserfs_warning(th->t_super,
-                                        "PAP-5760: reiserfs_insert_item: "
+                       reiserfs_warning(th->t_super, "PAP-5760",
                                         "key %K already exists in the tree",
                                         key);
                        retval = -EEXIST;
  
        /* make balancing after all resources will be collected at a time */
        if (retval == CARRY_ON) {
-               do_balance(&s_ins_balance, p_s_ih, p_c_body, M_INSERT);
+               do_balance(&s_ins_balance, ih, body, M_INSERT);
                return 0;
        }
  
  #ifdef REISERQUOTA_DEBUG
        reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE,
                       "reiserquota insert_item(): freeing %u id=%u type=%c",
-                      quota_bytes, inode->i_uid, head2type(p_s_ih));
+                      quota_bytes, inode->i_uid, head2type(ih));
  #endif
        if (inode)
 -              DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
 +              vfs_dq_free_space_nodirty(inode, quota_bytes);
        return retval;
  }
diff --combined fs/reiserfs/super.c
@@@ -183,9 -183,9 +183,9 @@@ static int finish_unfinished(struct sup
                if (REISERFS_SB(s)->s_qf_names[i]) {
                        int ret = reiserfs_quota_on_mount(s, i);
                        if (ret < 0)
-                               reiserfs_warning(s,
-                                                "reiserfs: cannot turn on journaled quota: error %d",
-                                                ret);
+                               reiserfs_warning(s, "reiserfs-2500",
+                                                "cannot turn on journaled "
+                                                "quota: error %d", ret);
                }
        }
  #endif
        while (!retval) {
                retval = search_item(s, &max_cpu_key, &path);
                if (retval != ITEM_NOT_FOUND) {
-                       reiserfs_warning(s,
-                                        "vs-2140: finish_unfinished: search_by_key returned %d",
-                                        retval);
+                       reiserfs_error(s, "vs-2140",
+                                      "search_by_key returned %d", retval);
                        break;
                }
  
                bh = get_last_bh(&path);
                item_pos = get_item_pos(&path);
                if (item_pos != B_NR_ITEMS(bh)) {
-                       reiserfs_warning(s,
-                                        "vs-2060: finish_unfinished: wrong position found");
+                       reiserfs_warning(s, "vs-2060",
+                                        "wrong position found");
                        break;
                }
                item_pos--;
                if (!inode) {
                        /* the unlink almost completed, it just did not manage to remove
                           "save" link and release objectid */
-                       reiserfs_warning(s,
-                                        "vs-2180: finish_unfinished: iget failed for %K",
+                       reiserfs_warning(s, "vs-2180", "iget failed for %K",
                                         &obj_key);
                        retval = remove_save_link_only(s, &save_link_key, 1);
                        continue;
  
                if (!truncate && inode->i_nlink) {
                        /* file is not unlinked */
-                       reiserfs_warning(s,
-                                        "vs-2185: finish_unfinished: file %K is not unlinked",
+                       reiserfs_warning(s, "vs-2185",
+                                        "file %K is not unlinked",
                                         &obj_key);
                        retval = remove_save_link_only(s, &save_link_key, 0);
                        continue;
                }
 -              DQUOT_INIT(inode);
 +              vfs_dq_init(inode);
  
                if (truncate && S_ISDIR(inode->i_mode)) {
                        /* We got a truncate request for a dir which is impossible.
                           The only imaginable way is to execute unfinished truncate request
                           then boot into old kernel, remove the file and create dir with
                           the same key. */
-                       reiserfs_warning(s,
-                                        "green-2101: impossible truncate on a directory %k. Please report",
+                       reiserfs_warning(s, "green-2101",
+                                        "impossible truncate on a "
+                                        "directory %k. Please report",
                                         INODE_PKEY(inode));
                        retval = remove_save_link_only(s, &save_link_key, 0);
                        truncate = 0;
                                /* removal gets completed in iput */
                                retval = 0;
                        } else {
-                               reiserfs_warning(s, "Dead loop in "
-                                               "finish_unfinished detected, "
-                                               "just remove save link\n");
+                               reiserfs_warning(s, "super-2189", "Dead loop "
+                                                "in finish_unfinished "
+                                                "detected, just remove "
+                                                "save link\n");
                                retval = remove_save_link_only(s,
                                                        &save_link_key, 0);
                        }
@@@ -360,8 -360,9 +360,9 @@@ void add_save_link(struct reiserfs_tran
        } else {
                /* truncate */
                if (S_ISDIR(inode->i_mode))
-                       reiserfs_warning(inode->i_sb,
-                                        "green-2102: Adding a truncate savelink for a directory %k! Please report",
+                       reiserfs_warning(inode->i_sb, "green-2102",
+                                        "Adding a truncate savelink for "
+                                        "a directory %k! Please report",
                                         INODE_PKEY(inode));
                set_cpu_key_k_offset(&key, 1);
                set_cpu_key_k_type(&key, TYPE_INDIRECT);
        retval = search_item(inode->i_sb, &key, &path);
        if (retval != ITEM_NOT_FOUND) {
                if (retval != -ENOSPC)
-                       reiserfs_warning(inode->i_sb, "vs-2100: add_save_link:"
-                                        "search_by_key (%K) returned %d", &key,
-                                        retval);
+                       reiserfs_error(inode->i_sb, "vs-2100",
+                                      "search_by_key (%K) returned %d", &key,
+                                      retval);
                pathrelse(&path);
                return;
        }
            reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
        if (retval) {
                if (retval != -ENOSPC)
-                       reiserfs_warning(inode->i_sb,
-                                        "vs-2120: add_save_link: insert_item returned %d",
-                                        retval);
+                       reiserfs_error(inode->i_sb, "vs-2120",
+                                      "insert_item returned %d", retval);
        } else {
                if (truncate)
                        REISERFS_I(inode)->i_flags |=
@@@ -492,8 -492,7 +492,7 @@@ static void reiserfs_put_super(struct s
        print_statistics(s);
  
        if (REISERFS_SB(s)->reserved_blocks != 0) {
-               reiserfs_warning(s,
-                                "green-2005: reiserfs_put_super: reserved blocks left %d",
+               reiserfs_warning(s, "green-2005", "reserved blocks left %d",
                                 REISERFS_SB(s)->reserved_blocks);
        }
  
@@@ -559,8 -558,8 +558,8 @@@ static void reiserfs_dirty_inode(struc
  
        int err = 0;
        if (inode->i_sb->s_flags & MS_RDONLY) {
-               reiserfs_warning(inode->i_sb,
-                                "clm-6006: writing inode %lu on readonly FS",
+               reiserfs_warning(inode->i_sb, "clm-6006",
+                                "writing inode %lu on readonly FS",
                                 inode->i_ino);
                return;
        }
@@@ -629,6 -628,8 +628,6 @@@ static const struct super_operations re
  #ifdef CONFIG_QUOTA
  #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
  
 -static int reiserfs_dquot_initialize(struct inode *, int);
 -static int reiserfs_dquot_drop(struct inode *);
  static int reiserfs_write_dquot(struct dquot *);
  static int reiserfs_acquire_dquot(struct dquot *);
  static int reiserfs_release_dquot(struct dquot *);
@@@ -637,8 -638,8 +636,8 @@@ static int reiserfs_write_info(struct s
  static int reiserfs_quota_on(struct super_block *, int, int, char *, int);
  
  static struct dquot_operations reiserfs_quota_operations = {
 -      .initialize = reiserfs_dquot_initialize,
 -      .drop = reiserfs_dquot_drop,
 +      .initialize = dquot_initialize,
 +      .drop = dquot_drop,
        .alloc_space = dquot_alloc_space,
        .alloc_inode = dquot_alloc_inode,
        .free_space = dquot_free_space,
@@@ -757,7 -758,7 +756,7 @@@ static int reiserfs_getopt(struct super
                           char **opt_arg, unsigned long *bit_flags)
  {
        char *p;
-       /* foo=bar, 
+       /* foo=bar,
           ^   ^  ^
           |   |  +-- option_end
           |   +-- arg_start
                        if (bit_flags) {
                                if (opt->clrmask ==
                                    (1 << REISERFS_UNSUPPORTED_OPT))
-                                       reiserfs_warning(s, "%s not supported.",
+                                       reiserfs_warning(s, "super-6500",
+                                                        "%s not supported.\n",
                                                         p);
                                else
                                        *bit_flags &= ~opt->clrmask;
                                if (opt->setmask ==
                                    (1 << REISERFS_UNSUPPORTED_OPT))
-                                       reiserfs_warning(s, "%s not supported.",
+                                       reiserfs_warning(s, "super-6501",
+                                                        "%s not supported.\n",
                                                         p);
                                else
                                        *bit_flags |= opt->setmask;
                }
        }
        if (!opt->option_name) {
-               reiserfs_warning(s, "unknown mount option \"%s\"", p);
+               reiserfs_warning(s, "super-6502",
+                                "unknown mount option \"%s\"", p);
                return -1;
        }
  
        switch (*p) {
        case '=':
                if (!opt->arg_required) {
-                       reiserfs_warning(s,
-                                        "the option \"%s\" does not require an argument",
+                       reiserfs_warning(s, "super-6503",
+                                        "the option \"%s\" does not "
+                                        "require an argument\n",
                                         opt->option_name);
                        return -1;
                }
  
        case 0:
                if (opt->arg_required) {
-                       reiserfs_warning(s,
-                                        "the option \"%s\" requires an argument",
-                                        opt->option_name);
+                       reiserfs_warning(s, "super-6504",
+                                        "the option \"%s\" requires an "
+                                        "argument\n", opt->option_name);
                        return -1;
                }
                break;
        default:
-               reiserfs_warning(s, "head of option \"%s\" is only correct",
+               reiserfs_warning(s, "super-6505",
+                                "head of option \"%s\" is only correct\n",
                                 opt->option_name);
                return -1;
        }
            && !(opt->arg_required & (1 << REISERFS_OPT_ALLOWEMPTY))
            && !strlen(p)) {
                /* this catches "option=," if not allowed */
-               reiserfs_warning(s, "empty argument for \"%s\"",
+               reiserfs_warning(s, "super-6506",
+                                "empty argument for \"%s\"\n",
                                 opt->option_name);
                return -1;
        }
                }
        }
  
-       reiserfs_warning(s, "bad value \"%s\" for option \"%s\"", p,
+       reiserfs_warning(s, "super-6506",
+                        "bad value \"%s\" for option \"%s\"\n", p,
                         opt->option_name);
        return -1;
  }
@@@ -955,9 -963,9 +961,9 @@@ static int reiserfs_parse_options(struc
                                *blocks = simple_strtoul(arg, &p, 0);
                                if (*p != '\0') {
                                        /* NNN does not look like a number */
-                                       reiserfs_warning(s,
-                                                        "reiserfs_parse_options: bad value %s",
-                                                        arg);
+                                       reiserfs_warning(s, "super-6507",
+                                                        "bad value %s for "
+                                                        "-oresize\n", arg);
                                        return 0;
                                }
                        }
                        unsigned long val = simple_strtoul(arg, &p, 0);
                        /* commit=NNN (time in seconds) */
                        if (*p != '\0' || val >= (unsigned int)-1) {
-                               reiserfs_warning(s,
-                                                "reiserfs_parse_options: bad value %s",
+                               reiserfs_warning(s, "super-6508",
+                                                "bad value %s for -ocommit\n",
                                                 arg);
                                return 0;
                        }
                }
  
                if (c == 'w') {
-                       reiserfs_warning(s, "reiserfs: nolargeio option is no longer supported");
+                       reiserfs_warning(s, "super-6509", "nolargeio option "
+                                        "is no longer supported");
                        return 0;
                }
  
                if (c == 'j') {
                        if (arg && *arg && jdev_name) {
                                if (*jdev_name) {       //Hm, already assigned?
-                                       reiserfs_warning(s,
-                                                        "reiserfs_parse_options: journal device was already  specified to be %s",
-                                                        *jdev_name);
+                                       reiserfs_warning(s, "super-6510",
+                                                        "journal device was "
+                                                        "already specified to "
+                                                        "be %s", *jdev_name);
                                        return 0;
                                }
                                *jdev_name = arg;
  
                        if (sb_any_quota_loaded(s) &&
                            (!*arg != !REISERFS_SB(s)->s_qf_names[qtype])) {
-                               reiserfs_warning(s,
-                                                "reiserfs_parse_options: cannot change journaled quota options when quota turned on.");
+                               reiserfs_warning(s, "super-6511",
+                                                "cannot change journaled "
+                                                "quota options when quota "
+                                                "turned on.");
                                return 0;
                        }
                        if (*arg) {     /* Some filename specified? */
                                if (REISERFS_SB(s)->s_qf_names[qtype]
                                    && strcmp(REISERFS_SB(s)->s_qf_names[qtype],
                                              arg)) {
-                                       reiserfs_warning(s,
-                                                        "reiserfs_parse_options: %s quota file already specified.",
+                                       reiserfs_warning(s, "super-6512",
+                                                        "%s quota file "
+                                                        "already specified.",
                                                         QTYPE2NAME(qtype));
                                        return 0;
                                }
                                if (strchr(arg, '/')) {
-                                       reiserfs_warning(s,
-                                                        "reiserfs_parse_options: quotafile must be on filesystem root.");
+                                       reiserfs_warning(s, "super-6513",
+                                                        "quotafile must be "
+                                                        "on filesystem root.");
                                        return 0;
                                }
                                qf_names[qtype] =
                                    kmalloc(strlen(arg) + 1, GFP_KERNEL);
                                if (!qf_names[qtype]) {
-                                       reiserfs_warning(s,
-                                                        "reiserfs_parse_options: not enough memory for storing quotafile name.");
+                                       reiserfs_warning(s, "reiserfs-2502",
+                                                        "not enough memory "
+                                                        "for storing "
+                                                        "quotafile name.");
                                        return 0;
                                }
                                strcpy(qf_names[qtype], arg);
                        else if (!strcmp(arg, "vfsv0"))
                                *qfmt = QFMT_VFS_V0;
                        else {
-                               reiserfs_warning(s,
-                                                "reiserfs_parse_options: unknown quota format specified.");
+                               reiserfs_warning(s, "super-6514",
+                                                "unknown quota format "
+                                                "specified.");
                                return 0;
                        }
                        if (sb_any_quota_loaded(s) &&
                            *qfmt != REISERFS_SB(s)->s_jquota_fmt) {
-                               reiserfs_warning(s,
-                                                "reiserfs_parse_options: cannot change journaled quota options when quota turned on.");
+                               reiserfs_warning(s, "super-6515",
+                                                "cannot change journaled "
+                                                "quota options when quota "
+                                                "turned on.");
                                return 0;
                        }
                }
  #else
                if (c == 'u' || c == 'g' || c == 'f') {
-                       reiserfs_warning(s,
-                                        "reiserfs_parse_options: journaled quota options not supported.");
+                       reiserfs_warning(s, "reiserfs-2503", "journaled "
+                                        "quota options not supported.");
                        return 0;
                }
  #endif
  #ifdef CONFIG_QUOTA
        if (!REISERFS_SB(s)->s_jquota_fmt && !*qfmt
            && (qf_names[USRQUOTA] || qf_names[GRPQUOTA])) {
-               reiserfs_warning(s,
-                                "reiserfs_parse_options: journaled quota format not specified.");
+               reiserfs_warning(s, "super-6515",
+                                "journaled quota format not specified.");
                return 0;
        }
        /* This checking is not precise wrt the quota type but for our purposes it is sufficient */
        if (!(*mount_options & (1 << REISERFS_QUOTA))
            && sb_any_quota_loaded(s)) {
-               reiserfs_warning(s,
-                                "reiserfs_parse_options: quota options must be present when quota is turned on.");
+               reiserfs_warning(s, "super-6516", "quota options must "
+                                "be present when quota is turned on.");
                return 0;
        }
  #endif
@@@ -1129,14 -1148,15 +1146,15 @@@ static void handle_attrs(struct super_b
  
        if (reiserfs_attrs(s)) {
                if (old_format_only(s)) {
-                       reiserfs_warning(s,
-                                        "reiserfs: cannot support attributes on 3.5.x disk format");
+                       reiserfs_warning(s, "super-6517", "cannot support "
+                                        "attributes on 3.5.x disk format");
                        REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
                        return;
                }
                if (!(le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared)) {
-                       reiserfs_warning(s,
-                                        "reiserfs: cannot support attributes until flag is set in super-block");
+                       reiserfs_warning(s, "super-6518", "cannot support "
+                                        "attributes until flag is set in "
+                                        "super-block");
                        REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
                }
        }
@@@ -1278,6 -1298,8 +1296,8 @@@ static int reiserfs_remount(struct supe
                REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
                s->s_flags &= ~MS_RDONLY;
                set_sb_umount_state(rs, REISERFS_ERROR_FS);
+               if (!old_format_only(s))
+                       set_sb_mnt_count(rs, sb_mnt_count(rs) + 1);
                /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
                journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
                REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS;
@@@ -1312,7 -1334,7 +1332,7 @@@ static int read_super_block(struct supe
  
        bh = sb_bread(s, offset / s->s_blocksize);
        if (!bh) {
-               reiserfs_warning(s, "sh-2006: read_super_block: "
+               reiserfs_warning(s, "sh-2006",
                                 "bread failed (dev %s, block %lu, size %lu)",
                                 reiserfs_bdevname(s), offset / s->s_blocksize,
                                 s->s_blocksize);
        }
        //
        // ok, reiserfs signature (old or new) found in at the given offset
-       //    
+       //
        fs_blocksize = sb_blocksize(rs);
        brelse(bh);
        sb_set_blocksize(s, fs_blocksize);
  
        bh = sb_bread(s, offset / s->s_blocksize);
        if (!bh) {
-               reiserfs_warning(s, "sh-2007: read_super_block: "
-                                "bread failed (dev %s, block %lu, size %lu)\n",
+               reiserfs_warning(s, "sh-2007",
+                                "bread failed (dev %s, block %lu, size %lu)",
                                 reiserfs_bdevname(s), offset / s->s_blocksize,
                                 s->s_blocksize);
                return 1;
  
        rs = (struct reiserfs_super_block *)bh->b_data;
        if (sb_blocksize(rs) != s->s_blocksize) {
-               reiserfs_warning(s, "sh-2011: read_super_block: "
-                                "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
+               reiserfs_warning(s, "sh-2011", "can't find a reiserfs "
+                                "filesystem on (dev %s, block %Lu, size %lu)",
                                 reiserfs_bdevname(s),
                                 (unsigned long long)bh->b_blocknr,
                                 s->s_blocksize);
  
        if (rs->s_v1.s_root_block == cpu_to_le32(-1)) {
                brelse(bh);
-               reiserfs_warning(s,
-                                "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
-                                "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
+               reiserfs_warning(s, "super-6519", "Unfinished reiserfsck "
+                                "--rebuild-tree run detected. Please run\n"
+                                "reiserfsck --rebuild-tree and wait for a "
+                                "completion. If that fails\n"
                                 "get newer reiserfsprogs package");
                return 1;
        }
                /* magic is of non-standard journal filesystem, look at s_version to
                   find which format is in use */
                if (sb_version(rs) == REISERFS_VERSION_2)
-                       reiserfs_warning(s,
-                                        "read_super_block: found reiserfs format \"3.6\""
-                                        " with non-standard journal");
+                       reiserfs_info(s, "found reiserfs format \"3.6\""
+                                     " with non-standard journal\n");
                else if (sb_version(rs) == REISERFS_VERSION_1)
-                       reiserfs_warning(s,
-                                        "read_super_block: found reiserfs format \"3.5\""
-                                        " with non-standard journal");
+                       reiserfs_info(s, "found reiserfs format \"3.5\""
+                                     " with non-standard journal\n");
                else {
-                       reiserfs_warning(s,
-                                        "sh-2012: read_super_block: found unknown "
-                                        "format \"%u\" of reiserfs with non-standard magic",
-                                        sb_version(rs));
+                       reiserfs_warning(s, "sh-2012", "found unknown "
+                                        "format \"%u\" of reiserfs with "
+                                        "non-standard magic", sb_version(rs));
                        return 1;
                }
        } else
@@@ -1408,8 -1428,7 +1426,7 @@@ static int reread_meta_blocks(struct su
        ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s)));
        wait_on_buffer(SB_BUFFER_WITH_SB(s));
        if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
-               reiserfs_warning(s,
-                                "reread_meta_blocks, error reading the super");
+               reiserfs_warning(s, "reiserfs-2504", "error reading the super");
                return 1;
        }
  
@@@ -1452,8 -1471,8 +1469,8 @@@ static __u32 find_hash_out(struct super
                        if (reiserfs_rupasov_hash(s)) {
                                hash = YURA_HASH;
                        }
-                       reiserfs_warning(s, "FS seems to be empty, autodetect "
-                                        "is using the default hash");
+                       reiserfs_info(s, "FS seems to be empty, autodetect "
+                                        "is using the default hash\n");
                        break;
                }
                r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen));
                        && (yurahash ==
                            GET_HASH_VALUE(deh_offset
                                           (&(de.de_deh[de.de_entry_num])))))) {
-                       reiserfs_warning(s,
-                                        "Unable to automatically detect hash function. "
-                                        "Please mount with -o hash={tea,rupasov,r5}",
-                                        reiserfs_bdevname(s));
+                       reiserfs_warning(s, "reiserfs-2506", "Unable to "
+                                        "automatically detect hash function. "
+                                        "Please mount with -o "
+                                        "hash={tea,rupasov,r5}");
                        hash = UNSET_HASH;
                        break;
                }
                         (deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash)
                        hash = R5_HASH;
                else {
-                       reiserfs_warning(s, "Unrecognised hash function");
+                       reiserfs_warning(s, "reiserfs-2506",
+                                        "Unrecognised hash function");
                        hash = UNSET_HASH;
                }
        } while (0);
@@@ -1514,21 -1534,24 +1532,24 @@@ static int what_hash(struct super_bloc
                code = find_hash_out(s);
  
        if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
-               /* detection has found the hash, and we must check against the 
-                ** mount options 
+               /* detection has found the hash, and we must check against the
+                ** mount options
                 */
                if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
-                       reiserfs_warning(s, "Error, %s hash detected, "
+                       reiserfs_warning(s, "reiserfs-2507",
+                                        "Error, %s hash detected, "
                                         "unable to force rupasov hash",
                                         reiserfs_hashname(code));
                        code = UNSET_HASH;
                } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
-                       reiserfs_warning(s, "Error, %s hash detected, "
+                       reiserfs_warning(s, "reiserfs-2508",
+                                        "Error, %s hash detected, "
                                         "unable to force tea hash",
                                         reiserfs_hashname(code));
                        code = UNSET_HASH;
                } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
-                       reiserfs_warning(s, "Error, %s hash detected, "
+                       reiserfs_warning(s, "reiserfs-2509",
+                                        "Error, %s hash detected, "
                                         "unable to force r5 hash",
                                         reiserfs_hashname(code));
                        code = UNSET_HASH;
                }
        }
  
-       /* if we are mounted RW, and we have a new valid hash code, update 
+       /* if we are mounted RW, and we have a new valid hash code, update
         ** the super
         */
        if (code != UNSET_HASH &&
@@@ -1587,9 -1610,9 +1608,9 @@@ static int function2code(hashf_t func
        return 0;
  }
  
- #define SWARN(silent, s, ...)                 \
+ #define SWARN(silent, s, id, ...)                     \
        if (!(silent))                          \
-               reiserfs_warning (s, __VA_ARGS__)
+               reiserfs_warning(s, id, __VA_ARGS__)
  
  static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
  {
        REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
        /* Preallocate by 16 blocks (17-1) at once */
        REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
- #ifdef CONFIG_REISERFS_FS_XATTR
-       /* Initialize the rwsem for xattr dir */
-       init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
- #endif
        /* setup default block allocator options */
        reiserfs_init_alloc_options(s);
  
  #endif
  
        if (blocks) {
-               SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option "
-                     "for remount only");
+               SWARN(silent, s, "jmacd-7", "resize option for remount only");
                goto error;
        }
  
                old_format = 1;
        /* try new format (64-th 1k block), which can contain reiserfs super block */
        else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
-               SWARN(silent, s,
-                     "sh-2021: reiserfs_fill_super: can not find reiserfs on %s",
+               SWARN(silent, s, "sh-2021", "can not find reiserfs on %s",
                      reiserfs_bdevname(s));
                goto error;
        }
        if (s->s_bdev && s->s_bdev->bd_inode
            && i_size_read(s->s_bdev->bd_inode) <
            sb_block_count(rs) * sb_blocksize(rs)) {
-               SWARN(silent, s,
-                     "Filesystem on %s cannot be mounted because it is bigger than the device",
-                     reiserfs_bdevname(s));
-               SWARN(silent, s,
-                     "You may need to run fsck or increase size of your LVM partition");
-               SWARN(silent, s,
-                     "Or may be you forgot to reboot after fdisk when it told you to");
+               SWARN(silent, s, "", "Filesystem cannot be "
+                     "mounted because it is bigger than the device");
+               SWARN(silent, s, "", "You may need to run fsck "
+                     "or increase size of your LVM partition");
+               SWARN(silent, s, "", "Or may be you forgot to "
+                     "reboot after fdisk when it told you to");
                goto error;
        }
  
        sbi->s_mount_state = REISERFS_VALID_FS;
  
        if ((errval = reiserfs_init_bitmap_cache(s))) {
-               SWARN(silent, s,
-                     "jmacd-8: reiserfs_fill_super: unable to read bitmap");
+               SWARN(silent, s, "jmacd-8", "unable to read bitmap");
                goto error;
        }
        errval = -EINVAL;
  #ifdef CONFIG_REISERFS_CHECK
-       SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON");
-       SWARN(silent, s, "- it is slow mode for debugging.");
+       SWARN(silent, s, "", "CONFIG_REISERFS_CHECK is set ON");
+       SWARN(silent, s, "", "- it is slow mode for debugging.");
  #endif
  
        /* make data=ordered the default */
        }
        // set_device_ro(s->s_dev, 1) ;
        if (journal_init(s, jdev_name, old_format, commit_max_age)) {
-               SWARN(silent, s,
-                     "sh-2022: reiserfs_fill_super: unable to initialize journal space");
+               SWARN(silent, s, "sh-2022",
+                     "unable to initialize journal space");
                goto error;
        } else {
                jinit_done = 1; /* once this is set, journal_release must be called
                                 */
        }
        if (reread_meta_blocks(s)) {
-               SWARN(silent, s,
-                     "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init");
+               SWARN(silent, s, "jmacd-9",
+                     "unable to reread meta blocks after journal init");
                goto error;
        }
  
                goto error;
  
        if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
-               SWARN(silent, s,
-                     "clm-7000: Detected readonly device, marking FS readonly");
+               SWARN(silent, s, "clm-7000",
+                     "Detected readonly device, marking FS readonly");
                s->s_flags |= MS_RDONLY;
        }
        args.objectid = REISERFS_ROOT_OBJECTID;
            iget5_locked(s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor,
                         reiserfs_init_locked_inode, (void *)(&args));
        if (!root_inode) {
-               SWARN(silent, s,
-                     "jmacd-10: reiserfs_fill_super: get root inode failed");
+               SWARN(silent, s, "jmacd-10", "get root inode failed");
                goto error;
        }
  
                 * avoiding corruption. -jeffm */
                if (bmap_would_wrap(reiserfs_bmap_count(s)) &&
                    sb_bmap_nr(rs) != 0) {
-                       reiserfs_warning(s, "super-2030This file system "
+                       reiserfs_warning(s, "super-2030", "This file system "
                                        "claims to use %u bitmap blocks in "
                                        "its super block, but requires %u. "
                                        "Clearing to zero.", sb_bmap_nr(rs),
                        } else if (!silent) {
                                reiserfs_info(s, "using 3.5.x disk format\n");
                        }
-               }
+               } else
+                       set_sb_mnt_count(rs, sb_mnt_count(rs) + 1);
  
                journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
                errval = journal_end(&th, s, 1);
@@@ -1894,6 -1910,58 +1908,6 @@@ static int reiserfs_statfs(struct dentr
  }
  
  #ifdef CONFIG_QUOTA
 -static int reiserfs_dquot_initialize(struct inode *inode, int type)
 -{
 -      struct reiserfs_transaction_handle th;
 -      int ret, err;
 -
 -      /* We may create quota structure so we need to reserve enough blocks */
 -      reiserfs_write_lock(inode->i_sb);
 -      ret =
 -          journal_begin(&th, inode->i_sb,
 -                        2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
 -      if (ret)
 -              goto out;
 -      ret = dquot_initialize(inode, type);
 -      err =
 -          journal_end(&th, inode->i_sb,
 -                      2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
 -      if (!ret && err)
 -              ret = err;
 -      out:
 -      reiserfs_write_unlock(inode->i_sb);
 -      return ret;
 -}
 -
 -static int reiserfs_dquot_drop(struct inode *inode)
 -{
 -      struct reiserfs_transaction_handle th;
 -      int ret, err;
 -
 -      /* We may delete quota structure so we need to reserve enough blocks */
 -      reiserfs_write_lock(inode->i_sb);
 -      ret =
 -          journal_begin(&th, inode->i_sb,
 -                        2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
 -      if (ret) {
 -              /*
 -               * We call dquot_drop() anyway to at least release references
 -               * to quota structures so that umount does not hang.
 -               */
 -              dquot_drop(inode);
 -              goto out;
 -      }
 -      ret = dquot_drop(inode);
 -      err =
 -          journal_end(&th, inode->i_sb,
 -                      2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
 -      if (!ret && err)
 -              ret = err;
 -      out:
 -      reiserfs_write_unlock(inode->i_sb);
 -      return ret;
 -}
 -
  static int reiserfs_write_dquot(struct dquot *dquot)
  {
        struct reiserfs_transaction_handle th;
@@@ -2031,8 -2099,8 +2045,8 @@@ static int reiserfs_quota_on(struct sup
        if (!(REISERFS_I(inode)->i_flags & i_nopack_mask)) {
                err = reiserfs_unpack(inode, NULL);
                if (err) {
-                       reiserfs_warning(sb,
-                               "reiserfs: Unpacking tail of quota file failed"
+                       reiserfs_warning(sb, "super-6520",
+                               "Unpacking tail of quota file failed"
                                " (%d). Cannot turn on quotas.", err);
                        err = -EINVAL;
                        goto out;
        if (REISERFS_SB(sb)->s_qf_names[type]) {
                /* Quotafile not of fs root? */
                if (path.dentry->d_parent != sb->s_root)
-                       reiserfs_warning(sb,
-                                "reiserfs: Quota file not on filesystem root. "
+                       reiserfs_warning(sb, "super-6521",
+                                "Quota file not on filesystem root. "
                                 "Journalled quota will not work.");
        }
  
@@@ -2195,9 -2263,6 +2209,6 @@@ static int __init init_reiserfs_fs(void
                return ret;
        }
  
-       if ((ret = reiserfs_xattr_register_handlers()))
-               goto failed_reiserfs_xattr_register_handlers;
        reiserfs_proc_info_global_init();
        reiserfs_proc_register_global("version",
                                      reiserfs_global_version_in_proc);
                return 0;
        }
  
-       reiserfs_xattr_unregister_handlers();
-       failed_reiserfs_xattr_register_handlers:
        reiserfs_proc_unregister_global("version");
        reiserfs_proc_info_global_done();
        destroy_inodecache();
  
  static void __exit exit_reiserfs_fs(void)
  {
-       reiserfs_xattr_unregister_handlers();
        reiserfs_proc_unregister_global("version");
        reiserfs_proc_info_global_done();
        unregister_filesystem(&reiserfs_fs_type);
diff --combined fs/reiserfs/xattr.c
   * these are special cases for filesystem ACLs, they are interpreted by the
   * kernel, in addition, they are negatively and positively cached and attached
   * to the inode so that unnecessary lookups are avoided.
+  *
+  * Locking works like so:
+  * Directory components (xattr root, xattr dir) are protectd by their i_mutex.
+  * The xattrs themselves are protected by the xattr_sem.
   */
  
  #include <linux/reiserfs_fs.h>
  #include <net/checksum.h>
  #include <linux/smp_lock.h>
  #include <linux/stat.h>
+ #include <linux/quotaops.h>
  
- #define FL_READONLY 128
- #define FL_DIR_SEM_HELD 256
  #define PRIVROOT_NAME ".reiserfs_priv"
  #define XAROOT_NAME   "xattrs"
  
- static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
-                                                               *prefix);
  
- /* Returns the dentry referring to the root of the extended attribute
-  * directory tree. If it has already been retrieved, it is used. If it
-  * hasn't been created and the flags indicate creation is allowed, we
-  * attempt to create it. On error, we return a pointer-encoded error.
-  */
- static struct dentry *get_xa_root(struct super_block *sb, int flags)
+ /* Helpers for inode ops. We do this so that we don't have all the VFS
+  * overhead and also for proper i_mutex annotation.
+  * dir->i_mutex must be held for all of them. */
+ static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
  {
-       struct dentry *privroot = dget(REISERFS_SB(sb)->priv_root);
-       struct dentry *xaroot;
+       BUG_ON(!mutex_is_locked(&dir->i_mutex));
 -      DQUOT_INIT(dir);
++      vfs_dq_init(dir);
+       return dir->i_op->create(dir, dentry, mode, NULL);
+ }
  
-       /* This needs to be created at mount-time */
-       if (!privroot)
-               return ERR_PTR(-ENODATA);
+ static int xattr_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+ {
+       BUG_ON(!mutex_is_locked(&dir->i_mutex));
 -      DQUOT_INIT(dir);
++      vfs_dq_init(dir);
+       return dir->i_op->mkdir(dir, dentry, mode);
+ }
  
-       mutex_lock_nested(&privroot->d_inode->i_mutex, I_MUTEX_XATTR);
-       if (REISERFS_SB(sb)->xattr_root) {
-               xaroot = dget(REISERFS_SB(sb)->xattr_root);
-               goto out;
-       }
+ /* We use I_MUTEX_CHILD here to silence lockdep. It's safe because xattr
+  * mutation ops aren't called during rename or splace, which are the
+  * only other users of I_MUTEX_CHILD. It violates the ordering, but that's
+  * better than allocating another subclass just for this code. */
+ static int xattr_unlink(struct inode *dir, struct dentry *dentry)
+ {
+       int error;
+       BUG_ON(!mutex_is_locked(&dir->i_mutex));
 -      DQUOT_INIT(dir);
++      vfs_dq_init(dir);
  
-       xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME));
-       if (IS_ERR(xaroot)) {
-               goto out;
-       } else if (!xaroot->d_inode) {
+       mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD);
+       error = dir->i_op->unlink(dir, dentry);
+       mutex_unlock(&dentry->d_inode->i_mutex);
+       if (!error)
+               d_delete(dentry);
+       return error;
+ }
+ static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
+ {
+       int error;
+       BUG_ON(!mutex_is_locked(&dir->i_mutex));
 -      DQUOT_INIT(dir);
++      vfs_dq_init(dir);
+       mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD);
+       dentry_unhash(dentry);
+       error = dir->i_op->rmdir(dir, dentry);
+       if (!error)
+               dentry->d_inode->i_flags |= S_DEAD;
+       mutex_unlock(&dentry->d_inode->i_mutex);
+       if (!error)
+               d_delete(dentry);
+       dput(dentry);
+       return error;
+ }
+ #define xattr_may_create(flags)       (!flags || flags & XATTR_CREATE)
+ /* Returns and possibly creates the xattr dir. */
+ static struct dentry *lookup_or_create_dir(struct dentry *parent,
+                                           const char *name, int flags)
+ {
+       struct dentry *dentry;
+       BUG_ON(!parent);
+       dentry = lookup_one_len(name, parent, strlen(name));
+       if (IS_ERR(dentry))
+               return dentry;
+       else if (!dentry->d_inode) {
                int err = -ENODATA;
-               if (flags == 0 || flags & XATTR_CREATE)
-                       err = privroot->d_inode->i_op->mkdir(privroot->d_inode,
-                                                            xaroot, 0700);
+               if (xattr_may_create(flags)) {
+                       mutex_lock_nested(&parent->d_inode->i_mutex,
+                                         I_MUTEX_XATTR);
+                       err = xattr_mkdir(parent->d_inode, dentry, 0700);
+                       mutex_unlock(&parent->d_inode->i_mutex);
+               }
                if (err) {
-                       dput(xaroot);
-                       xaroot = ERR_PTR(err);
-                       goto out;
+                       dput(dentry);
+                       dentry = ERR_PTR(err);
                }
        }
-       REISERFS_SB(sb)->xattr_root = dget(xaroot);
  
-       out:
-       mutex_unlock(&privroot->d_inode->i_mutex);
-       dput(privroot);
-       return xaroot;
+       return dentry;
+ }
+ static struct dentry *open_xa_root(struct super_block *sb, int flags)
+ {
+       struct dentry *privroot = REISERFS_SB(sb)->priv_root;
+       if (!privroot)
+               return ERR_PTR(-ENODATA);
+       return lookup_or_create_dir(privroot, XAROOT_NAME, flags);
  }
  
- /* Opens the directory corresponding to the inode's extended attribute store.
-  * If flags allow, the tree to the directory may be created. If creation is
-  * prohibited, -ENODATA is returned. */
  static struct dentry *open_xa_dir(const struct inode *inode, int flags)
  {
        struct dentry *xaroot, *xadir;
        char namebuf[17];
  
-       xaroot = get_xa_root(inode->i_sb, flags);
+       xaroot = open_xa_root(inode->i_sb, flags);
        if (IS_ERR(xaroot))
                return xaroot;
  
-       /* ok, we have xaroot open */
        snprintf(namebuf, sizeof(namebuf), "%X.%X",
                 le32_to_cpu(INODE_PKEY(inode)->k_objectid),
                 inode->i_generation);
-       xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf));
-       if (IS_ERR(xadir)) {
-               dput(xaroot);
-               return xadir;
-       }
-       if (!xadir->d_inode) {
-               int err;
-               if (flags == 0 || flags & XATTR_CREATE) {
-                       /* Although there is nothing else trying to create this directory,
-                        * another directory with the same hash may be created, so we need
-                        * to protect against that */
-                       err =
-                           xaroot->d_inode->i_op->mkdir(xaroot->d_inode, xadir,
-                                                        0700);
-                       if (err) {
-                               dput(xaroot);
-                               dput(xadir);
-                               return ERR_PTR(err);
-                       }
-               }
-               if (!xadir->d_inode) {
-                       dput(xaroot);
-                       dput(xadir);
-                       return ERR_PTR(-ENODATA);
-               }
-       }
  
+       xadir = lookup_or_create_dir(xaroot, namebuf, flags);
        dput(xaroot);
        return xadir;
  }
  
- /* Returns a dentry corresponding to a specific extended attribute file
-  * for the inode. If flags allow, the file is created. Otherwise, a
-  * valid or negative dentry, or an error is returned. */
- static struct dentry *get_xa_file_dentry(const struct inode *inode,
-                                        const char *name, int flags)
- {
-       struct dentry *xadir, *xafile;
      int err = 0;
+ /* The following are side effects of other operations that aren't explicitly
+  * modifying extended attributes. This includes operations such as permissions
+  * or ownership changes, object deletions, etc. */
+ struct reiserfs_dentry_buf {
+       struct dentry *xadir;
+       int count;
+       struct dentry *dentries[8];
};
  
-       xadir = open_xa_dir(inode, flags);
-       if (IS_ERR(xadir)) {
-               return ERR_CAST(xadir);
-       } else if (!xadir->d_inode) {
-               dput(xadir);
-               return ERR_PTR(-ENODATA);
-       }
+ static int
+ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
+                   u64 ino, unsigned int d_type)
+ {
+       struct reiserfs_dentry_buf *dbuf = buf;
+       struct dentry *dentry;
  
-       xafile = lookup_one_len(name, xadir, strlen(name));
-       if (IS_ERR(xafile)) {
-               dput(xadir);
-               return ERR_CAST(xafile);
-       }
+       if (dbuf->count == ARRAY_SIZE(dbuf->dentries))
+               return -ENOSPC;
  
-       if (xafile->d_inode) {  /* file exists */
-               if (flags & XATTR_CREATE) {
-                       err = -EEXIST;
-                       dput(xafile);
-                       goto out;
-               }
-       } else if (flags & XATTR_REPLACE || flags & FL_READONLY) {
-               goto out;
-       } else {
-               /* inode->i_mutex is down, so nothing else can try to create
-                * the same xattr */
-               err = xadir->d_inode->i_op->create(xadir->d_inode, xafile,
-                                                  0700 | S_IFREG, NULL);
+       if (name[0] == '.' && (name[1] == '\0' ||
+                              (name[1] == '.' && name[2] == '\0')))
+               return 0;
  
-               if (err) {
-                       dput(xafile);
-                       goto out;
-               }
+       dentry = lookup_one_len(name, dbuf->xadir, namelen);
+       if (IS_ERR(dentry)) {
+               return PTR_ERR(dentry);
+       } else if (!dentry->d_inode) {
+               /* A directory entry exists, but no file? */
+               reiserfs_error(dentry->d_sb, "xattr-20003",
+                              "Corrupted directory: xattr %s listed but "
+                              "not found for file %s.\n",
+                              dentry->d_name.name, dbuf->xadir->d_name.name);
+               dput(dentry);
+               return -EIO;
        }
  
-       out:
-       dput(xadir);
-       if (err)
-               xafile = ERR_PTR(err);
-       else if (!xafile->d_inode) {
-               dput(xafile);
-               xafile = ERR_PTR(-ENODATA);
-       }
-       return xafile;
+       dbuf->dentries[dbuf->count++] = dentry;
+       return 0;
  }
  
- /*
-  * this is very similar to fs/reiserfs/dir.c:reiserfs_readdir, but
-  * we need to drop the path before calling the filldir struct.  That
-  * would be a big performance hit to the non-xattr case, so I've copied
-  * the whole thing for now. --clm
-  *
-  * the big difference is that I go backwards through the directory,
-  * and don't mess with f->f_pos, but the idea is the same.  Do some
-  * action on each and every entry in the directory.
-  *
-  * we're called with i_mutex held, so there are no worries about the directory
-  * changing underneath us.
-  */
- static int __xattr_readdir(struct inode *inode, void *dirent, filldir_t filldir)
+ static void
+ cleanup_dentry_buf(struct reiserfs_dentry_buf *buf)
  {
-       struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
-       INITIALIZE_PATH(path_to_entry);
-       struct buffer_head *bh;
-       int entry_num;
-       struct item_head *ih, tmp_ih;
-       int search_res;
-       char *local_buf;
-       loff_t next_pos;
-       char small_buf[32];     /* avoid kmalloc if we can */
-       struct reiserfs_de_head *deh;
-       int d_reclen;
-       char *d_name;
-       off_t d_off;
-       ino_t d_ino;
-       struct reiserfs_dir_entry de;
-       /* form key for search the next directory entry using f_pos field of
-          file structure */
-       next_pos = max_reiserfs_offset(inode);
-       while (1) {
-             research:
-               if (next_pos <= DOT_DOT_OFFSET)
-                       break;
-               make_cpu_key(&pos_key, inode, next_pos, TYPE_DIRENTRY, 3);
-               search_res =
-                   search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
-                                       &de);
-               if (search_res == IO_ERROR) {
-                       // FIXME: we could just skip part of directory which could
-                       // not be read
-                       pathrelse(&path_to_entry);
-                       return -EIO;
-               }
+       int i;
+       for (i = 0; i < buf->count; i++)
+               if (buf->dentries[i])
+                       dput(buf->dentries[i]);
+ }
+ static int reiserfs_for_each_xattr(struct inode *inode,
+                                  int (*action)(struct dentry *, void *),
+                                  void *data)
+ {
+       struct dentry *dir;
+       int i, err = 0;
+       loff_t pos = 0;
+       struct reiserfs_dentry_buf buf = {
+               .count = 0,
+       };
  
-               if (search_res == NAME_NOT_FOUND)
-                       de.de_entry_num--;
+       /* Skip out, an xattr has no xattrs associated with it */
+       if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1)
+               return 0;
  
-               set_de_name_and_namelen(&de);
-               entry_num = de.de_entry_num;
-               deh = &(de.de_deh[entry_num]);
+       dir = open_xa_dir(inode, XATTR_REPLACE);
+       if (IS_ERR(dir)) {
+               err = PTR_ERR(dir);
+               goto out;
+       } else if (!dir->d_inode) {
+               err = 0;
+               goto out_dir;
+       }
  
-               bh = de.de_bh;
-               ih = de.de_ih;
+       mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
+       buf.xadir = dir;
+       err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos);
+       while ((err == 0 || err == -ENOSPC) && buf.count) {
+               err = 0;
  
-               if (!is_direntry_le_ih(ih)) {
-                       reiserfs_warning(inode->i_sb, "not direntry %h", ih);
-                       break;
-               }
-               copy_item_head(&tmp_ih, ih);
+               for (i = 0; i < buf.count && buf.dentries[i]; i++) {
+                       int lerr = 0;
+                       struct dentry *dentry = buf.dentries[i];
  
-               /* we must have found item, that is item of this directory, */
-               RFALSE(COMP_SHORT_KEYS(&(ih->ih_key), &pos_key),
-                      "vs-9000: found item %h does not match to dir we readdir %K",
-                      ih, &pos_key);
+                       if (err == 0 && !S_ISDIR(dentry->d_inode->i_mode))
+                               lerr = action(dentry, data);
  
-               if (deh_offset(deh) <= DOT_DOT_OFFSET) {
-                       break;
+                       dput(dentry);
+                       buf.dentries[i] = NULL;
+                       err = lerr ?: err;
                }
+               buf.count = 0;
+               if (!err)
+                       err = reiserfs_readdir_dentry(dir, &buf,
+                                                     fill_with_dentries, &pos);
+       }
+       mutex_unlock(&dir->d_inode->i_mutex);
  
-               /* look for the previous entry in the directory */
-               next_pos = deh_offset(deh) - 1;
-               if (!de_visible(deh))
-                       /* it is hidden entry */
-                       continue;
+       /* Clean up after a failed readdir */
+       cleanup_dentry_buf(&buf);
  
-               d_reclen = entry_length(bh, ih, entry_num);
-               d_name = B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh);
-               d_off = deh_offset(deh);
-               d_ino = deh_objectid(deh);
+       if (!err) {
+               /* We start a transaction here to avoid a ABBA situation
+                * between the xattr root's i_mutex and the journal lock.
+                * This doesn't incur much additional overhead since the
+                * new transaction will just nest inside the
+                * outer transaction. */
+               int blocks = JOURNAL_PER_BALANCE_CNT * 2 + 2 +
+                            4 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
+               struct reiserfs_transaction_handle th;
+               err = journal_begin(&th, inode->i_sb, blocks);
+               if (!err) {
+                       int jerror;
+                       mutex_lock_nested(&dir->d_parent->d_inode->i_mutex,
+                                         I_MUTEX_XATTR);
+                       err = action(dir, data);
+                       jerror = journal_end(&th, inode->i_sb, blocks);
+                       mutex_unlock(&dir->d_parent->d_inode->i_mutex);
+                       err = jerror ?: err;
+               }
+       }
+ out_dir:
+       dput(dir);
+ out:
+       /* -ENODATA isn't an error */
+       if (err == -ENODATA)
+               err = 0;
+       return err;
+ }
  
-               if (!d_name[d_reclen - 1])
-                       d_reclen = strlen(d_name);
+ static int delete_one_xattr(struct dentry *dentry, void *data)
+ {
+       struct inode *dir = dentry->d_parent->d_inode;
  
-               if (d_reclen > REISERFS_MAX_NAME(inode->i_sb->s_blocksize)) {
-                       /* too big to send back to VFS */
-                       continue;
-               }
+       /* This is the xattr dir, handle specially. */
+       if (S_ISDIR(dentry->d_inode->i_mode))
+               return xattr_rmdir(dir, dentry);
  
-               /* Ignore the .reiserfs_priv entry */
-               if (reiserfs_xattrs(inode->i_sb) &&
-                   !old_format_only(inode->i_sb) &&
-                   deh_objectid(deh) ==
-                   le32_to_cpu(INODE_PKEY
-                               (REISERFS_SB(inode->i_sb)->priv_root->d_inode)->
-                               k_objectid))
-                       continue;
-               if (d_reclen <= 32) {
-                       local_buf = small_buf;
-               } else {
-                       local_buf = kmalloc(d_reclen, GFP_NOFS);
-                       if (!local_buf) {
-                               pathrelse(&path_to_entry);
-                               return -ENOMEM;
-                       }
-                       if (item_moved(&tmp_ih, &path_to_entry)) {
-                               kfree(local_buf);
+       return xattr_unlink(dir, dentry);
+ }
  
-                               /* sigh, must retry.  Do this same offset again */
-                               next_pos = d_off;
-                               goto research;
-                       }
              }
+ static int chown_one_xattr(struct dentry *dentry, void *data)
+ {
+       struct iattr *attrs = data;
+       return reiserfs_setattr(dentry, attrs);
+ }
  
-               // Note, that we copy name to user space via temporary
-               // buffer (local_buf) because filldir will block if
-               // user space buffer is swapped out. At that time
-               // entry can move to somewhere else
-               memcpy(local_buf, d_name, d_reclen);
-               /* the filldir function might need to start transactions,
-                * or do who knows what.  Release the path now that we've
-                * copied all the important stuff out of the deh
-                */
-               pathrelse(&path_to_entry);
-               if (filldir(dirent, local_buf, d_reclen, d_off, d_ino,
-                           DT_UNKNOWN) < 0) {
-                       if (local_buf != small_buf) {
-                               kfree(local_buf);
-                       }
-                       goto end;
-               }
-               if (local_buf != small_buf) {
-                       kfree(local_buf);
-               }
-       }                       /* while */
+ /* No i_mutex, but the inode is unconnected. */
+ int reiserfs_delete_xattrs(struct inode *inode)
+ {
+       int err = reiserfs_for_each_xattr(inode, delete_one_xattr, NULL);
+       if (err)
+               reiserfs_warning(inode->i_sb, "jdm-20004",
+                                "Couldn't delete all xattrs (%d)\n", err);
+       return err;
+ }
  
-       end:
-       pathrelse(&path_to_entry);
-       return 0;
+ /* inode->i_mutex: down */
+ int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
+ {
+       int err = reiserfs_for_each_xattr(inode, chown_one_xattr, attrs);
+       if (err)
+               reiserfs_warning(inode->i_sb, "jdm-20007",
+                                "Couldn't chown all xattrs (%d)\n", err);
+       return err;
  }
  
- /*
-  * this could be done with dedicated readdir ops for the xattr files,
-  * but I want to get something working asap
-  * this is stolen from vfs_readdir
-  *
-  */
- static
- int xattr_readdir(struct inode *inode, filldir_t filler, void *buf)
+ #ifdef CONFIG_REISERFS_FS_XATTR
+ /* Returns a dentry corresponding to a specific extended attribute file
+  * for the inode. If flags allow, the file is created. Otherwise, a
+  * valid or negative dentry, or an error is returned. */
+ static struct dentry *xattr_lookup(struct inode *inode, const char *name,
+                                   int flags)
  {
-       int res = -ENOENT;
-       mutex_lock_nested(&inode->i_mutex, I_MUTEX_XATTR);
-       if (!IS_DEADDIR(inode)) {
-               lock_kernel();
-               res = __xattr_readdir(inode, buf, filler);
-               unlock_kernel();
+       struct dentry *xadir, *xafile;
+       int err = 0;
+       xadir = open_xa_dir(inode, flags);
+       if (IS_ERR(xadir))
+               return ERR_CAST(xadir);
+       xafile = lookup_one_len(name, xadir, strlen(name));
+       if (IS_ERR(xafile)) {
+               err = PTR_ERR(xafile);
+               goto out;
        }
-       mutex_unlock(&inode->i_mutex);
-       return res;
+       if (xafile->d_inode && (flags & XATTR_CREATE))
+               err = -EEXIST;
+       if (!xafile->d_inode) {
+               err = -ENODATA;
+               if (xattr_may_create(flags)) {
+                       mutex_lock_nested(&xadir->d_inode->i_mutex,
+                                         I_MUTEX_XATTR);
+                       err = xattr_create(xadir->d_inode, xafile,
+                                             0700|S_IFREG);
+                       mutex_unlock(&xadir->d_inode->i_mutex);
+               }
+       }
+       if (err)
+               dput(xafile);
+ out:
+       dput(xadir);
+       if (err)
+               return ERR_PTR(err);
+       return xafile;
  }
  
  /* Internal operations on file data */
@@@ -375,14 -383,14 +383,14 @@@ static inline void reiserfs_put_page(st
        page_cache_release(page);
  }
  
- static struct page *reiserfs_get_page(struct inode *dir, unsigned long n)
+ static struct page *reiserfs_get_page(struct inode *dir, size_t n)
  {
        struct address_space *mapping = dir->i_mapping;
        struct page *page;
        /* We can deadlock if we try to free dentries,
           and an unlink/rmdir has just occured - GFP_NOFS avoids this */
        mapping_set_gfp_mask(mapping, GFP_NOFS);
-       page = read_mapping_page(mapping, n, NULL);
+       page = read_mapping_page(mapping, n >> PAGE_CACHE_SHIFT, NULL);
        if (!IS_ERR(page)) {
                kmap(page);
                if (PageError(page))
@@@ -405,6 -413,45 +413,45 @@@ int reiserfs_commit_write(struct file *
  int reiserfs_prepare_write(struct file *f, struct page *page,
                           unsigned from, unsigned to);
  
+ static void update_ctime(struct inode *inode)
+ {
+       struct timespec now = current_fs_time(inode->i_sb);
+       if (hlist_unhashed(&inode->i_hash) || !inode->i_nlink ||
+           timespec_equal(&inode->i_ctime, &now))
+               return;
+       inode->i_ctime = CURRENT_TIME_SEC;
+       mark_inode_dirty(inode);
+ }
+ static int lookup_and_delete_xattr(struct inode *inode, const char *name)
+ {
+       int err = 0;
+       struct dentry *dentry, *xadir;
+       xadir = open_xa_dir(inode, XATTR_REPLACE);
+       if (IS_ERR(xadir))
+               return PTR_ERR(xadir);
+       dentry = lookup_one_len(name, xadir, strlen(name));
+       if (IS_ERR(dentry)) {
+               err = PTR_ERR(dentry);
+               goto out_dput;
+       }
+       if (dentry->d_inode) {
+               mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR);
+               err = xattr_unlink(xadir->d_inode, dentry);
+               mutex_unlock(&xadir->d_inode->i_mutex);
+               update_ctime(inode);
+       }
+       dput(dentry);
+ out_dput:
+       dput(xadir);
+       return err;
+ }
  
  /* Generic extended attribute operations that can be used by xa plugins */
  
   * inode->i_mutex: down
   */
  int
- reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
-                  size_t buffer_size, int flags)
+ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
+                         struct inode *inode, const char *name,
+                         const void *buffer, size_t buffer_size, int flags)
  {
        int err = 0;
        struct dentry *dentry;
        struct page *page;
        char *data;
-       struct address_space *mapping;
        size_t file_pos = 0;
        size_t buffer_pos = 0;
-       struct inode *xinode;
-       struct iattr newattrs;
+       size_t new_size;
        __u32 xahash = 0;
  
        if (get_inode_sd_version(inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
  
-       /* Empty xattrs are ok, they're just empty files, no hash */
-       if (buffer && buffer_size)
-               xahash = xattr_hash(buffer, buffer_size);
+       if (!buffer)
+               return lookup_and_delete_xattr(inode, name);
  
-       open_file:
-       dentry = get_xa_file_dentry(inode, name, flags);
-       if (IS_ERR(dentry)) {
-               err = PTR_ERR(dentry);
-               goto out;
-       }
-       xinode = dentry->d_inode;
-       REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
+       dentry = xattr_lookup(inode, name, flags);
+       if (IS_ERR(dentry))
+               return PTR_ERR(dentry);
  
-       /* we need to copy it off.. */
-       if (xinode->i_nlink > 1) {
-               dput(dentry);
-               err = reiserfs_xattr_del(inode, name);
-               if (err < 0)
-                       goto out;
-               /* We just killed the old one, we're not replacing anymore */
-               if (flags & XATTR_REPLACE)
-                       flags &= ~XATTR_REPLACE;
-               goto open_file;
-       }
+       down_write(&REISERFS_I(inode)->i_xattr_sem);
  
-       /* Resize it so we're ok to write there */
-       newattrs.ia_size = buffer_size;
-       newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-       mutex_lock_nested(&xinode->i_mutex, I_MUTEX_XATTR);
-       err = notify_change(dentry, &newattrs);
-       if (err)
-               goto out_filp;
-       mapping = xinode->i_mapping;
+       xahash = xattr_hash(buffer, buffer_size);
        while (buffer_pos < buffer_size || buffer_pos == 0) {
                size_t chunk;
                size_t skip = 0;
                else
                        chunk = buffer_size - buffer_pos;
  
-               page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+               page = reiserfs_get_page(dentry->d_inode, file_pos);
                if (IS_ERR(page)) {
                        err = PTR_ERR(page);
-                       goto out_filp;
+                       goto out_unlock;
                }
  
                lock_page(page);
                        break;
        }
  
-       /* We can't mark the inode dirty if it's not hashed. This is the case
-        * when we're inheriting the default ACL. If we dirty it, the inode
-        * gets marked dirty, but won't (ever) make it onto the dirty list until
-        * it's synced explicitly to clear I_DIRTY. This is bad. */
-       if (!hlist_unhashed(&inode->i_hash)) {
-               inode->i_ctime = CURRENT_TIME_SEC;
-               mark_inode_dirty(inode);
+       new_size = buffer_size + sizeof(struct reiserfs_xattr_header);
+       if (!err && new_size < i_size_read(dentry->d_inode)) {
+               struct iattr newattrs = {
+                       .ia_ctime = current_fs_time(inode->i_sb),
+                       .ia_size = buffer_size,
+                       .ia_valid = ATTR_SIZE | ATTR_CTIME,
+               };
+               mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_XATTR);
+               down_write(&dentry->d_inode->i_alloc_sem);
+               err = reiserfs_setattr(dentry, &newattrs);
+               up_write(&dentry->d_inode->i_alloc_sem);
+               mutex_unlock(&dentry->d_inode->i_mutex);
+       } else
+               update_ctime(inode);
+ out_unlock:
+       up_write(&REISERFS_I(inode)->i_xattr_sem);
+       dput(dentry);
+       return err;
+ }
+ /* We need to start a transaction to maintain lock ordering */
+ int reiserfs_xattr_set(struct inode *inode, const char *name,
+                      const void *buffer, size_t buffer_size, int flags)
+ {
+       struct reiserfs_transaction_handle th;
+       int error, error2;
+       size_t jbegin_count = reiserfs_xattr_nblocks(inode, buffer_size);
+       if (!(flags & XATTR_REPLACE))
+               jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
+       reiserfs_write_lock(inode->i_sb);
+       error = journal_begin(&th, inode->i_sb, jbegin_count);
+       if (error) {
+               reiserfs_write_unlock(inode->i_sb);
+               return error;
        }
  
-       out_filp:
-       mutex_unlock(&xinode->i_mutex);
-       dput(dentry);
+       error = reiserfs_xattr_set_handle(&th, inode, name,
+                                         buffer, buffer_size, flags);
  
-       out:
-       return err;
+       error2 = journal_end(&th, inode->i_sb, jbegin_count);
+       if (error == 0)
+               error = error2;
+       reiserfs_write_unlock(inode->i_sb);
+       return error;
  }
  
  /*
   * inode->i_mutex: down
   */
  int
- reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer,
+ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer,
                   size_t buffer_size)
  {
        ssize_t err = 0;
        size_t file_pos = 0;
        size_t buffer_pos = 0;
        struct page *page;
-       struct inode *xinode;
        __u32 hash = 0;
  
        if (name == NULL)
        if (get_inode_sd_version(inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
  
-       dentry = get_xa_file_dentry(inode, name, FL_READONLY);
+       dentry = xattr_lookup(inode, name, XATTR_REPLACE);
        if (IS_ERR(dentry)) {
                err = PTR_ERR(dentry);
                goto out;
        }
  
-       xinode = dentry->d_inode;
-       isize = xinode->i_size;
-       REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
+       down_read(&REISERFS_I(inode)->i_xattr_sem);
+       isize = i_size_read(dentry->d_inode);
  
        /* Just return the size needed */
        if (buffer == NULL) {
                err = isize - sizeof(struct reiserfs_xattr_header);
-               goto out_dput;
+               goto out_unlock;
        }
  
        if (buffer_size < isize - sizeof(struct reiserfs_xattr_header)) {
                err = -ERANGE;
-               goto out_dput;
+               goto out_unlock;
        }
  
        while (file_pos < isize) {
                else
                        chunk = isize - file_pos;
  
-               page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+               page = reiserfs_get_page(dentry->d_inode, file_pos);
                if (IS_ERR(page)) {
                        err = PTR_ERR(page);
-                       goto out_dput;
+                       goto out_unlock;
                }
  
                lock_page(page);
                        if (rxh->h_magic != cpu_to_le32(REISERFS_XATTR_MAGIC)) {
                                unlock_page(page);
                                reiserfs_put_page(page);
-                               reiserfs_warning(inode->i_sb,
+                               reiserfs_warning(inode->i_sb, "jdm-20001",
                                                 "Invalid magic for xattr (%s) "
                                                 "associated with %k", name,
                                                 INODE_PKEY(inode));
                                err = -EIO;
-                               goto out_dput;
+                               goto out_unlock;
                        }
                        hash = le32_to_cpu(rxh->h_hash);
                }
  
        if (xattr_hash(buffer, isize - sizeof(struct reiserfs_xattr_header)) !=
            hash) {
-               reiserfs_warning(inode->i_sb,
+               reiserfs_warning(inode->i_sb, "jdm-20002",
                                 "Invalid hash for xattr (%s) associated "
                                 "with %k", name, INODE_PKEY(inode));
                err = -EIO;
        }
  
-       out_dput:
+ out_unlock:
+       up_read(&REISERFS_I(inode)->i_xattr_sem);
        dput(dentry);
  
-       out:
-       return err;
- }
- static int
- __reiserfs_xattr_del(struct dentry *xadir, const char *name, int namelen)
- {
-       struct dentry *dentry;
-       struct inode *dir = xadir->d_inode;
-       int err = 0;
-       dentry = lookup_one_len(name, xadir, namelen);
-       if (IS_ERR(dentry)) {
-               err = PTR_ERR(dentry);
-               goto out;
-       } else if (!dentry->d_inode) {
-               err = -ENODATA;
-               goto out_file;
-       }
-       /* Skip directories.. */
-       if (S_ISDIR(dentry->d_inode->i_mode))
-               goto out_file;
-       if (!is_reiserfs_priv_object(dentry->d_inode)) {
-               reiserfs_warning(dir->i_sb, "OID %08x [%.*s/%.*s] doesn't have "
-                                "priv flag set [parent is %sset].",
-                                le32_to_cpu(INODE_PKEY(dentry->d_inode)->
-                                            k_objectid), xadir->d_name.len,
-                                xadir->d_name.name, namelen, name,
-                                is_reiserfs_priv_object(xadir->
-                                                        d_inode) ? "" :
-                                "not ");
-               dput(dentry);
-               return -EIO;
-       }
-       err = dir->i_op->unlink(dir, dentry);
-       if (!err)
-               d_delete(dentry);
-       out_file:
-       dput(dentry);
-       out:
-       return err;
- }
- int reiserfs_xattr_del(struct inode *inode, const char *name)
- {
-       struct dentry *dir;
-       int err;
-       dir = open_xa_dir(inode, FL_READONLY);
-       if (IS_ERR(dir)) {
-               err = PTR_ERR(dir);
-               goto out;
-       }
-       err = __reiserfs_xattr_del(dir, name, strlen(name));
-       dput(dir);
-       if (!err) {
-               inode->i_ctime = CURRENT_TIME_SEC;
-               mark_inode_dirty(inode);
-       }
-       out:
+ out:
        return err;
  }
  
- /* The following are side effects of other operations that aren't explicitly
-  * modifying extended attributes. This includes operations such as permissions
-  * or ownership changes, object deletions, etc. */
- static int
- reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
-                             loff_t offset, u64 ino, unsigned int d_type)
- {
-       struct dentry *xadir = (struct dentry *)buf;
-       return __reiserfs_xattr_del(xadir, name, namelen);
- }
- /* This is called w/ inode->i_mutex downed */
- int reiserfs_delete_xattrs(struct inode *inode)
- {
-       struct dentry *dir, *root;
-       int err = 0;
-       /* Skip out, an xattr has no xattrs associated with it */
-       if (is_reiserfs_priv_object(inode) ||
-           get_inode_sd_version(inode) == STAT_DATA_V1 ||
-           !reiserfs_xattrs(inode->i_sb)) {
-               return 0;
-       }
-       reiserfs_read_lock_xattrs(inode->i_sb);
-       dir = open_xa_dir(inode, FL_READONLY);
-       reiserfs_read_unlock_xattrs(inode->i_sb);
-       if (IS_ERR(dir)) {
-               err = PTR_ERR(dir);
-               goto out;
-       } else if (!dir->d_inode) {
-               dput(dir);
-               return 0;
-       }
-       lock_kernel();
-       err = xattr_readdir(dir->d_inode, reiserfs_delete_xattrs_filler, dir);
-       if (err) {
-               unlock_kernel();
-               goto out_dir;
-       }
-       /* Leftovers besides . and .. -- that's not good. */
-       if (dir->d_inode->i_nlink <= 2) {
-               root = get_xa_root(inode->i_sb, XATTR_REPLACE);
-               reiserfs_write_lock_xattrs(inode->i_sb);
-               err = vfs_rmdir(root->d_inode, dir);
-               reiserfs_write_unlock_xattrs(inode->i_sb);
-               dput(root);
-       } else {
-               reiserfs_warning(inode->i_sb,
-                                "Couldn't remove all entries in directory");
-       }
-       unlock_kernel();
-       out_dir:
-       dput(dir);
-       out:
-       if (!err)
-               REISERFS_I(inode)->i_flags =
-                   REISERFS_I(inode)->i_flags & ~i_has_xattr_dir;
-       return err;
- }
- struct reiserfs_chown_buf {
-       struct inode *inode;
-       struct dentry *xadir;
-       struct iattr *attrs;
+ /* Actual operations that are exported to VFS-land */
+ struct xattr_handler *reiserfs_xattr_handlers[] = {
+       &reiserfs_xattr_user_handler,
+       &reiserfs_xattr_trusted_handler,
+ #ifdef CONFIG_REISERFS_FS_SECURITY
+       &reiserfs_xattr_security_handler,
+ #endif
+ #ifdef CONFIG_REISERFS_FS_POSIX_ACL
+       &reiserfs_posix_acl_access_handler,
+       &reiserfs_posix_acl_default_handler,
+ #endif
+       NULL
  };
  
- /* XXX: If there is a better way to do this, I'd love to hear about it */
- static int
- reiserfs_chown_xattrs_filler(void *buf, const char *name, int namelen,
-                            loff_t offset, u64 ino, unsigned int d_type)
- {
-       struct reiserfs_chown_buf *chown_buf = (struct reiserfs_chown_buf *)buf;
-       struct dentry *xafile, *xadir = chown_buf->xadir;
-       struct iattr *attrs = chown_buf->attrs;
-       int err = 0;
-       xafile = lookup_one_len(name, xadir, namelen);
-       if (IS_ERR(xafile))
-               return PTR_ERR(xafile);
-       else if (!xafile->d_inode) {
-               dput(xafile);
-               return -ENODATA;
-       }
-       if (!S_ISDIR(xafile->d_inode->i_mode))
-               err = notify_change(xafile, attrs);
-       dput(xafile);
-       return err;
- }
+ /*
+  * In order to implement different sets of xattr operations for each xattr
+  * prefix with the generic xattr API, a filesystem should create a
+  * null-terminated array of struct xattr_handler (one for each prefix) and
+  * hang a pointer to it off of the s_xattr field of the superblock.
+  *
+  * The generic_fooxattr() functions will use this list to dispatch xattr
+  * operations to the correct xattr_handler.
+  */
+ #define for_each_xattr_handler(handlers, handler)             \
+               for ((handler) = *(handlers)++;                 \
+                       (handler) != NULL;                      \
+                       (handler) = *(handlers)++)
  
- int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
+ /* This is the implementation for the xattr plugin infrastructure */
+ static inline struct xattr_handler *
+ find_xattr_handler_prefix(struct xattr_handler **handlers,
+                          const char *name)
  {
-       struct dentry *dir;
-       int err = 0;
-       struct reiserfs_chown_buf buf;
-       unsigned int ia_valid = attrs->ia_valid;
+       struct xattr_handler *xah;
  
-       /* Skip out, an xattr has no xattrs associated with it */
-       if (is_reiserfs_priv_object(inode) ||
-           get_inode_sd_version(inode) == STAT_DATA_V1 ||
-           !reiserfs_xattrs(inode->i_sb)) {
-               return 0;
-       }
-       reiserfs_read_lock_xattrs(inode->i_sb);
-       dir = open_xa_dir(inode, FL_READONLY);
-       reiserfs_read_unlock_xattrs(inode->i_sb);
-       if (IS_ERR(dir)) {
-               if (PTR_ERR(dir) != -ENODATA)
-                       err = PTR_ERR(dir);
-               goto out;
-       } else if (!dir->d_inode) {
-               dput(dir);
-               goto out;
-       }
+       if (!handlers)
+               return NULL;
  
-       lock_kernel();
-       attrs->ia_valid &= (ATTR_UID | ATTR_GID | ATTR_CTIME);
-       buf.xadir = dir;
-       buf.attrs = attrs;
-       buf.inode = inode;
-       err = xattr_readdir(dir->d_inode, reiserfs_chown_xattrs_filler, &buf);
-       if (err) {
-               unlock_kernel();
-               goto out_dir;
+       for_each_xattr_handler(handlers, xah) {
+               if (strncmp(xah->prefix, name, strlen(xah->prefix)) == 0)
+                       break;
        }
  
-       err = notify_change(dir, attrs);
-       unlock_kernel();
-       out_dir:
-       dput(dir);
-       out:
-       attrs->ia_valid = ia_valid;
-       return err;
+       return xah;
  }
  
- /* Actual operations that are exported to VFS-land */
  
  /*
   * Inode operation getxattr()
-  * Preliminary locking: we down dentry->d_inode->i_mutex
   */
  ssize_t
  reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
                  size_t size)
  {
-       struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
-       int err;
+       struct inode *inode = dentry->d_inode;
+       struct xattr_handler *handler;
  
-       if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
-           get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+       handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+       if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
  
-       reiserfs_read_lock_xattr_i(dentry->d_inode);
-       reiserfs_read_lock_xattrs(dentry->d_sb);
-       err = xah->get(dentry->d_inode, name, buffer, size);
-       reiserfs_read_unlock_xattrs(dentry->d_sb);
-       reiserfs_read_unlock_xattr_i(dentry->d_inode);
-       return err;
+       return handler->get(inode, name, buffer, size);
  }
  
  /*
@@@ -879,27 -759,15 +759,15 @@@ in
  reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
                  size_t size, int flags)
  {
-       struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
-       int err;
-       int lock;
+       struct inode *inode = dentry->d_inode;
+       struct xattr_handler *handler;
  
-       if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
-           get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+       handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+       if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
  
-       reiserfs_write_lock_xattr_i(dentry->d_inode);
-       lock = !has_xattr_dir(dentry->d_inode);
-       if (lock)
-               reiserfs_write_lock_xattrs(dentry->d_sb);
-       else
-               reiserfs_read_lock_xattrs(dentry->d_sb);
-       err = xah->set(dentry->d_inode, name, value, size, flags);
-       if (lock)
-               reiserfs_write_unlock_xattrs(dentry->d_sb);
-       else
-               reiserfs_read_unlock_xattrs(dentry->d_sb);
-       reiserfs_write_unlock_xattr_i(dentry->d_inode);
-       return err;
+       return handler->set(inode, name, value, size, flags);
  }
  
  /*
   */
  int reiserfs_removexattr(struct dentry *dentry, const char *name)
  {
-       int err;
-       struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
+       struct inode *inode = dentry->d_inode;
+       struct xattr_handler *handler;
+       handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
  
-       if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
-           get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+       if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
  
-       reiserfs_write_lock_xattr_i(dentry->d_inode);
-       reiserfs_read_lock_xattrs(dentry->d_sb);
-       /* Deletion pre-operation */
-       if (xah->del) {
-               err = xah->del(dentry->d_inode, name);
-               if (err)
-                       goto out;
-       }
-       err = reiserfs_xattr_del(dentry->d_inode, name);
-       dentry->d_inode->i_ctime = CURRENT_TIME_SEC;
-       mark_inode_dirty(dentry->d_inode);
-       out:
-       reiserfs_read_unlock_xattrs(dentry->d_sb);
-       reiserfs_write_unlock_xattr_i(dentry->d_inode);
-       return err;
+       return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
  }
  
- /* This is what filldir will use:
-  * r_pos will always contain the amount of space required for the entire
-  * list. If r_pos becomes larger than r_size, we need more space and we
-  * return an error indicating this. If r_pos is less than r_size, then we've
-  * filled the buffer successfully and we return success */
- struct reiserfs_listxattr_buf {
-       int r_pos;
-       int r_size;
-       char *r_buf;
-       struct inode *r_inode;
+ struct listxattr_buf {
+       size_t size;
+       size_t pos;
+       char *buf;
+       struct inode *inode;
  };
  
- static int
- reiserfs_listxattr_filler(void *buf, const char *name, int namelen,
-                         loff_t offset, u64 ino, unsigned int d_type)
+ static int listxattr_filler(void *buf, const char *name, int namelen,
+                           loff_t offset, u64 ino, unsigned int d_type)
  {
-       struct reiserfs_listxattr_buf *b = (struct reiserfs_listxattr_buf *)buf;
-       int len = 0;
-       if (name[0] != '.'
-           || (namelen != 1 && (name[1] != '.' || namelen != 2))) {
-               struct reiserfs_xattr_handler *xah =
-                   find_xattr_handler_prefix(name);
-               if (!xah)
-                       return 0;       /* Unsupported xattr name, skip it */
-               /* We call ->list() twice because the operation isn't required to just
-                * return the name back - we want to make sure we have enough space */
-               len += xah->list(b->r_inode, name, namelen, NULL);
-               if (len) {
-                       if (b->r_pos + len + 1 <= b->r_size) {
-                               char *p = b->r_buf + b->r_pos;
-                               p += xah->list(b->r_inode, name, namelen, p);
-                               *p++ = '\0';
-                       }
-                       b->r_pos += len + 1;
+       struct listxattr_buf *b = (struct listxattr_buf *)buf;
+       size_t size;
+       if (name[0] != '.' ||
+           (namelen != 1 && (name[1] != '.' || namelen != 2))) {
+               struct xattr_handler *handler;
+               handler = find_xattr_handler_prefix(b->inode->i_sb->s_xattr,
+                                                   name);
+               if (!handler)   /* Unsupported xattr name */
+                       return 0;
+               if (b->buf) {
+                       size = handler->list(b->inode, b->buf + b->pos,
+                                        b->size, name, namelen);
+                       if (size > b->size)
+                               return -ERANGE;
+               } else {
+                       size = handler->list(b->inode, NULL, 0, name, namelen);
                }
-       }
  
+               b->pos += size;
+       }
        return 0;
  }
  
  /*
   * Inode operation listxattr()
   *
-  * Preliminary locking: we down dentry->d_inode->i_mutex
+  * We totally ignore the generic listxattr here because it would be stupid
+  * not to. Since the xattrs are organized in a directory, we can just
+  * readdir to find them.
   */
  ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
  {
        struct dentry *dir;
        int err = 0;
-       struct reiserfs_listxattr_buf buf;
+       loff_t pos = 0;
+       struct listxattr_buf buf = {
+               .inode = dentry->d_inode,
+               .buf = buffer,
+               .size = buffer ? size : 0,
+       };
  
        if (!dentry->d_inode)
                return -EINVAL;
            get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
  
-       reiserfs_read_lock_xattr_i(dentry->d_inode);
-       reiserfs_read_lock_xattrs(dentry->d_sb);
-       dir = open_xa_dir(dentry->d_inode, FL_READONLY);
-       reiserfs_read_unlock_xattrs(dentry->d_sb);
+       dir = open_xa_dir(dentry->d_inode, XATTR_REPLACE);
        if (IS_ERR(dir)) {
                err = PTR_ERR(dir);
                if (err == -ENODATA)
-                       err = 0;        /* Not an error if there aren't any xattrs */
+                       err = 0;  /* Not an error if there aren't any xattrs */
                goto out;
        }
  
-       buf.r_buf = buffer;
-       buf.r_size = buffer ? size : 0;
-       buf.r_pos = 0;
-       buf.r_inode = dentry->d_inode;
+       mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
+       err = reiserfs_readdir_dentry(dir, &buf, listxattr_filler, &pos);
+       mutex_unlock(&dir->d_inode->i_mutex);
  
-       REISERFS_I(dentry->d_inode)->i_flags |= i_has_xattr_dir;
-       err = xattr_readdir(dir->d_inode, reiserfs_listxattr_filler, &buf);
-       if (err)
-               goto out_dir;
-       if (buf.r_pos > buf.r_size && buffer != NULL)
-               err = -ERANGE;
-       else
-               err = buf.r_pos;
+       if (!err)
+               err = buf.pos;
  
-       out_dir:
        dput(dir);
-       out:
-       reiserfs_read_unlock_xattr_i(dentry->d_inode);
+ out:
        return err;
  }
  
- /* This is the implementation for the xattr plugin infrastructure */
- static LIST_HEAD(xattr_handlers);
- static DEFINE_RWLOCK(handler_lock);
- static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
-                                                               *prefix)
+ static int reiserfs_check_acl(struct inode *inode, int mask)
  {
-       struct reiserfs_xattr_handler *xah = NULL;
-       struct list_head *p;
+       struct posix_acl *acl;
+       int error = -EAGAIN; /* do regular unix permission checks by default */
  
-       read_lock(&handler_lock);
-       list_for_each(p, &xattr_handlers) {
-               xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
-               if (strncmp(xah->prefix, prefix, strlen(xah->prefix)) == 0)
-                       break;
-               xah = NULL;
+       acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
+       if (acl) {
+               if (!IS_ERR(acl)) {
+                       error = posix_acl_permission(inode, acl, mask);
+                       posix_acl_release(acl);
+               } else if (PTR_ERR(acl) != -ENODATA)
+                       error = PTR_ERR(acl);
        }
  
-       read_unlock(&handler_lock);
-       return xah;
+       return error;
  }
  
static void __unregister_handlers(void)
int reiserfs_permission(struct inode *inode, int mask)
  {
-       struct reiserfs_xattr_handler *xah;
-       struct list_head *p, *tmp;
-       list_for_each_safe(p, tmp, &xattr_handlers) {
-               xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
-               if (xah->exit)
-                       xah->exit();
-               list_del_init(p);
-       }
-       INIT_LIST_HEAD(&xattr_handlers);
+       /*
+        * We don't do permission checks on the internal objects.
+        * Permissions are determined by the "owning" object.
+        */
+       if (IS_PRIVATE(inode))
+               return 0;
+       /*
+        * Stat data v1 doesn't support ACLs.
+        */
+       if (get_inode_sd_version(inode) == STAT_DATA_V1)
+               return generic_permission(inode, mask, NULL);
+       else
+               return generic_permission(inode, mask, reiserfs_check_acl);
  }
  
int __init reiserfs_xattr_register_handlers(void)
static int create_privroot(struct dentry *dentry)
  {
-       int err = 0;
-       struct reiserfs_xattr_handler *xah;
-       struct list_head *p;
-       write_lock(&handler_lock);
-       /* If we're already initialized, nothing to do */
-       if (!list_empty(&xattr_handlers)) {
-               write_unlock(&handler_lock);
-               return 0;
-       }
-       /* Add the handlers */
-       list_add_tail(&user_handler.handlers, &xattr_handlers);
-       list_add_tail(&trusted_handler.handlers, &xattr_handlers);
- #ifdef CONFIG_REISERFS_FS_SECURITY
-       list_add_tail(&security_handler.handlers, &xattr_handlers);
- #endif
- #ifdef CONFIG_REISERFS_FS_POSIX_ACL
-       list_add_tail(&posix_acl_access_handler.handlers, &xattr_handlers);
-       list_add_tail(&posix_acl_default_handler.handlers, &xattr_handlers);
- #endif
-       /* Run initializers, if available */
-       list_for_each(p, &xattr_handlers) {
-               xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
-               if (xah->init) {
-                       err = xah->init();
-                       if (err) {
-                               list_del_init(p);
-                               break;
-                       }
-               }
+       int err;
+       struct inode *inode = dentry->d_parent->d_inode;
+       mutex_lock_nested(&inode->i_mutex, I_MUTEX_XATTR);
+       err = xattr_mkdir(inode, dentry, 0700);
+       mutex_unlock(&inode->i_mutex);
+       if (err) {
+               dput(dentry);
+               dentry = NULL;
        }
  
-       /* Clean up other handlers, if any failed */
-       if (err)
-               __unregister_handlers();
+       if (dentry && dentry->d_inode)
+               reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
+                             "storage.\n", PRIVROOT_NAME);
  
-       write_unlock(&handler_lock);
        return err;
  }
  
void reiserfs_xattr_unregister_handlers(void)
static int xattr_mount_check(struct super_block *s)
  {
-       write_lock(&handler_lock);
-       __unregister_handlers();
-       write_unlock(&handler_lock);
+       /* We need generation numbers to ensure that the oid mapping is correct
+        * v3.5 filesystems don't have them. */
+       if (old_format_only(s)) {
+               if (reiserfs_xattrs_optional(s)) {
+                       /* Old format filesystem, but optional xattrs have
+                        * been enabled. Error out. */
+                       reiserfs_warning(s, "jdm-2005",
+                                        "xattrs/ACLs not supported "
+                                        "on pre-v3.6 format filesystems. "
+                                        "Failing mount.");
+                       return -EOPNOTSUPP;
+               }
+       }
+       return 0;
  }
  
+ #else
+ int __init reiserfs_xattr_register_handlers(void) { return 0; }
+ void reiserfs_xattr_unregister_handlers(void) {}
+ #endif
  /* This will catch lookups from the fs root to .reiserfs_priv */
  static int
  xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name)
        return 1;
  }
  
 -static struct dentry_operations xattr_lookup_poison_ops = {
 +static const struct dentry_operations xattr_lookup_poison_ops = {
        .d_compare = xattr_lookup_poison,
  };
  
@@@ -1147,48 -969,23 +969,23 @@@ int reiserfs_xattr_init(struct super_bl
  {
        int err = 0;
  
-       /* We need generation numbers to ensure that the oid mapping is correct
-        * v3.5 filesystems don't have them. */
-       if (!old_format_only(s)) {
-               set_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
-       } else if (reiserfs_xattrs_optional(s)) {
-               /* Old format filesystem, but optional xattrs have been enabled
-                * at mount time. Error out. */
-               reiserfs_warning(s, "xattrs/ACLs not supported on pre v3.6 "
-                                "format filesystem. Failing mount.");
-               err = -EOPNOTSUPP;
+ #ifdef CONFIG_REISERFS_FS_XATTR
+       err = xattr_mount_check(s);
+       if (err)
                goto error;
-       } else {
-               /* Old format filesystem, but no optional xattrs have been enabled. This
-                * means we silently disable xattrs on the filesystem. */
-               clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
-       }
+ #endif
  
        /* If we don't have the privroot located yet - go find it */
-       if (reiserfs_xattrs(s) && !REISERFS_SB(s)->priv_root) {
+       if (!REISERFS_SB(s)->priv_root) {
                struct dentry *dentry;
                dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
                                        strlen(PRIVROOT_NAME));
                if (!IS_ERR(dentry)) {
-                       if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) {
-                               struct inode *inode = dentry->d_parent->d_inode;
-                               mutex_lock_nested(&inode->i_mutex,
-                                                 I_MUTEX_XATTR);
-                               err = inode->i_op->mkdir(inode, dentry, 0700);
-                               mutex_unlock(&inode->i_mutex);
-                               if (err) {
-                                       dput(dentry);
-                                       dentry = NULL;
-                               }
-                               if (dentry && dentry->d_inode)
-                                       reiserfs_warning(s,
-                                                        "Created %s on %s - reserved for "
-                                                        "xattr storage.",
-                                                        PRIVROOT_NAME,
-                                                        reiserfs_bdevname
-                                                        (inode->i_sb));
-                       } else if (!dentry->d_inode) {
+ #ifdef CONFIG_REISERFS_FS_XATTR
+                       if (!(mount_flags & MS_RDONLY) && !dentry->d_inode)
+                               err = create_privroot(dentry);
+ #endif
+                       if (!dentry->d_inode) {
                                dput(dentry);
                                dentry = NULL;
                        }
  
                if (!err && dentry) {
                        s->s_root->d_op = &xattr_lookup_poison_ops;
-                       reiserfs_mark_inode_private(dentry->d_inode);
+                       dentry->d_inode->i_flags |= S_PRIVATE;
                        REISERFS_SB(s)->priv_root = dentry;
-               } else if (!(mount_flags & MS_RDONLY)) {        /* xattrs are unavailable */
-                       /* If we're read-only it just means that the dir hasn't been
-                        * created. Not an error -- just no xattrs on the fs. We'll
-                        * check again if we go read-write */
-                       reiserfs_warning(s, "xattrs/ACLs enabled and couldn't "
-                                        "find/create .reiserfs_priv. Failing mount.");
+ #ifdef CONFIG_REISERFS_FS_XATTR
+               /* xattrs are unavailable */
+               } else if (!(mount_flags & MS_RDONLY)) {
+                       /* If we're read-only it just means that the dir
+                        * hasn't been created. Not an error -- just no
+                        * xattrs on the fs. We'll check again if we
+                        * go read-write */
+                       reiserfs_warning(s, "jdm-20006",
+                                        "xattrs/ACLs enabled and couldn't "
+                                        "find/create .reiserfs_priv. "
+                                        "Failing mount.");
                        err = -EOPNOTSUPP;
+ #endif
                }
        }
  
-       error:
-       /* This is only nonzero if there was an error initializing the xattr
-        * directory or if there is a condition where we don't support them. */
+ #ifdef CONFIG_REISERFS_FS_XATTR
+       if (!err)
+               s->s_xattr = reiserfs_xattr_handlers;
+ error:
        if (err) {
-               clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
                clear_bit(REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt));
                clear_bit(REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt));
        }
+ #endif
  
        /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */
        s->s_flags = s->s_flags & ~MS_POSIXACL;
+ #ifdef CONFIG_REISERFS_FS_POSIX_ACL
        if (reiserfs_posixacl(s))
                s->s_flags |= MS_POSIXACL;
+ #endif
  
        return err;
  }
- static int reiserfs_check_acl(struct inode *inode, int mask)
- {
-       struct posix_acl *acl;
-       int error = -EAGAIN; /* do regular unix permission checks by default */
-       reiserfs_read_lock_xattr_i(inode);
-       reiserfs_read_lock_xattrs(inode->i_sb);
-       acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
-       reiserfs_read_unlock_xattrs(inode->i_sb);
-       reiserfs_read_unlock_xattr_i(inode);
-       if (acl) {
-               if (!IS_ERR(acl)) {
-                       error = posix_acl_permission(inode, acl, mask);
-                       posix_acl_release(acl);
-               } else if (PTR_ERR(acl) != -ENODATA)
-                       error = PTR_ERR(acl);
-       }
-       return error;
- }
- int reiserfs_permission(struct inode *inode, int mask)
- {
-       /*
-        * We don't do permission checks on the internal objects.
-        * Permissions are determined by the "owning" object.
-        */
-       if (is_reiserfs_priv_object(inode))
-               return 0;
-       /*
-        * Stat data v1 doesn't support ACLs.
-        */
-       if (get_inode_sd_version(inode) == STAT_DATA_V1)
-               return generic_permission(inode, mask, NULL);
-       else
-               return generic_permission(inode, mask, reiserfs_check_acl);
- }
@@@ -28,6 -28,8 +28,6 @@@
  #include <linux/reiserfs_fs_sb.h>
  #endif
  
 -struct fid;
 -
  /*
   *  include/linux/reiser_fs.h
   *
   *
   */
  
- /* xattr stuff */
- #define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem)
 +/* ioctl's command */
 +#define REISERFS_IOC_UNPACK           _IOW(0xCD,1,long)
 +/* define following flags to be the same as in ext2, so that chattr(1),
 +   lsattr(1) will work with us. */
 +#define REISERFS_IOC_GETFLAGS         FS_IOC_GETFLAGS
 +#define REISERFS_IOC_SETFLAGS         FS_IOC_SETFLAGS
 +#define REISERFS_IOC_GETVERSION               FS_IOC_GETVERSION
 +#define REISERFS_IOC_SETVERSION               FS_IOC_SETVERSION
 +
 +#ifdef __KERNEL__
 +/* the 32 bit compat definitions with int argument */
 +#define REISERFS_IOC32_UNPACK         _IOW(0xCD, 1, int)
 +#define REISERFS_IOC32_GETFLAGS               FS_IOC32_GETFLAGS
 +#define REISERFS_IOC32_SETFLAGS               FS_IOC32_SETFLAGS
 +#define REISERFS_IOC32_GETVERSION     FS_IOC32_GETVERSION
 +#define REISERFS_IOC32_SETVERSION     FS_IOC32_SETVERSION
 +
 +/* Locking primitives */
 +/* Right now we are still falling back to (un)lock_kernel, but eventually that
 +   would evolve into real per-fs locks */
 +#define reiserfs_write_lock( sb ) lock_kernel()
 +#define reiserfs_write_unlock( sb ) unlock_kernel()
 +
 +struct fid;
 +
  /* in reading the #defines, it may help to understand that they employ
     the following abbreviations:
  
  */
  #define REISERFS_DEBUG_CODE 5 /* extra messages to help find/debug errors */
  
- void reiserfs_warning(struct super_block *s, const char *fmt, ...);
+ void __reiserfs_warning(struct super_block *s, const char *id,
+                        const char *func, const char *fmt, ...);
+ #define reiserfs_warning(s, id, fmt, args...) \
+        __reiserfs_warning(s, id, __func__, fmt, ##args)
  /* assertions handling */
  
  /** always check a condition and panic if it's false. */
- #define __RASSERT( cond, scond, format, args... )                                     \
- if( !( cond ) )                                                               \
-   reiserfs_panic( NULL, "reiserfs[%i]: assertion " scond " failed at "        \
-                 __FILE__ ":%i:%s: " format "\n",              \
-                 in_interrupt() ? -1 : task_pid_nr(current), __LINE__ , __func__ , ##args )
+ #define __RASSERT(cond, scond, format, args...)                       \
+ do {                                                                  \
+       if (!(cond))                                                    \
+               reiserfs_panic(NULL, "assertion failure", "(" #cond ") at " \
+                              __FILE__ ":%i:%s: " format "\n",         \
+                              in_interrupt() ? -1 : task_pid_nr(current), \
+                              __LINE__, __func__ , ##args);            \
+ } while (0)
  
  #define RASSERT(cond, format, args...) __RASSERT(cond, #cond, format, ##args)
  
@@@ -196,7 -177,11 +200,11 @@@ struct reiserfs_super_block 
        __le32 s_flags;         /* Right now used only by inode-attributes, if enabled */
        unsigned char s_uuid[16];       /* filesystem unique identifier */
        unsigned char s_label[16];      /* filesystem volume label */
-       char s_unused[88];      /* zero filled by mkreiserfs and
+       __le16 s_mnt_count;             /* Count of mounts since last fsck */
+       __le16 s_max_mnt_count;         /* Maximum mounts before check */
+       __le32 s_lastcheck;             /* Timestamp of last fsck */
+       __le32 s_check_interval;        /* Interval between checks */
+       char s_unused[76];      /* zero filled by mkreiserfs and
                                 * reiserfs_convert_objectid_map_v1()
                                 * so any additions must be updated
                                 * there as well. */
@@@ -578,10 -563,8 +586,8 @@@ static inline int uniqueness2type(__u3
                return TYPE_DIRECT;
        case V1_DIRENTRY_UNIQUENESS:
                return TYPE_DIRENTRY;
-       default:
-               reiserfs_warning(NULL, "vs-500: unknown uniqueness %d",
-                                uniqueness);
        case V1_ANY_UNIQUENESS:
+       default:
                return TYPE_ANY;
        }
  }
@@@ -598,9 -581,8 +604,8 @@@ static inline __u32 type2uniqueness(in
                return V1_DIRECT_UNIQUENESS;
        case TYPE_DIRENTRY:
                return V1_DIRENTRY_UNIQUENESS;
-       default:
-               reiserfs_warning(NULL, "vs-501: unknown type %d", type);
        case TYPE_ANY:
+       default:
                return V1_ANY_UNIQUENESS;
        }
  }
@@@ -712,9 -694,9 +717,9 @@@ static inline void cpu_key_k_offset_dec
  #define is_indirect_cpu_ih(ih) (is_indirect_cpu_key (&((ih)->ih_key)))
  #define is_statdata_cpu_ih(ih) (is_statdata_cpu_key (&((ih)->ih_key)))
  
- #define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \
-     ( ! COMP_SHORT_KEYS(p_s_ih, p_s_key) && \
-           I_OFF_BYTE_IN_ITEM(p_s_ih, k_offset (p_s_key), n_blocksize) )
+ #define I_K_KEY_IN_ITEM(ih, key, n_blocksize) \
+     (!COMP_SHORT_KEYS(ih, key) && \
+         I_OFF_BYTE_IN_ITEM(ih, k_offset(key), n_blocksize))
  
  /* maximal length of item */
  #define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)
  /* object identifier for root dir */
  #define REISERFS_ROOT_OBJECTID 2
  #define REISERFS_ROOT_PARENT_OBJECTID 1
 +
  extern struct reiserfs_key root_key;
  
  /* 
@@@ -770,25 -751,25 +775,25 @@@ struct block_head 
  #define DISK_LEAF_NODE_LEVEL  1       /* Leaf node level. */
  
  /* Given the buffer head of a formatted node, resolve to the block head of that node. */
- #define B_BLK_HEAD(p_s_bh)            ((struct block_head *)((p_s_bh)->b_data))
+ #define B_BLK_HEAD(bh)                        ((struct block_head *)((bh)->b_data))
  /* Number of items that are in buffer. */
- #define B_NR_ITEMS(p_s_bh)            (blkh_nr_item(B_BLK_HEAD(p_s_bh)))
- #define B_LEVEL(p_s_bh)               (blkh_level(B_BLK_HEAD(p_s_bh)))
- #define B_FREE_SPACE(p_s_bh)          (blkh_free_space(B_BLK_HEAD(p_s_bh)))
+ #define B_NR_ITEMS(bh)                        (blkh_nr_item(B_BLK_HEAD(bh)))
+ #define B_LEVEL(bh)                   (blkh_level(B_BLK_HEAD(bh)))
+ #define B_FREE_SPACE(bh)              (blkh_free_space(B_BLK_HEAD(bh)))
  
- #define PUT_B_NR_ITEMS(p_s_bh,val)    do { set_blkh_nr_item(B_BLK_HEAD(p_s_bh),val); } while (0)
- #define PUT_B_LEVEL(p_s_bh,val)       do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0)
- #define PUT_B_FREE_SPACE(p_s_bh,val)  do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
+ #define PUT_B_NR_ITEMS(bh, val)               do { set_blkh_nr_item(B_BLK_HEAD(bh), val); } while (0)
+ #define PUT_B_LEVEL(bh, val)          do { set_blkh_level(B_BLK_HEAD(bh), val); } while (0)
+ #define PUT_B_FREE_SPACE(bh, val)     do { set_blkh_free_space(B_BLK_HEAD(bh), val); } while (0)
  
  /* Get right delimiting key. -- little endian */
- #define B_PRIGHT_DELIM_KEY(p_s_bh)   (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))))
+ #define B_PRIGHT_DELIM_KEY(bh)                (&(blk_right_delim_key(B_BLK_HEAD(bh))))
  
  /* Does the buffer contain a disk leaf. */
- #define B_IS_ITEMS_LEVEL(p_s_bh)     (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL)
+ #define B_IS_ITEMS_LEVEL(bh)          (B_LEVEL(bh) == DISK_LEAF_NODE_LEVEL)
  
  /* Does the buffer contain a disk internal node */
- #define B_IS_KEYS_LEVEL(p_s_bh)      (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \
-                                             && B_LEVEL(p_s_bh) <= MAX_HEIGHT)
+ #define B_IS_KEYS_LEVEL(bh)      (B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL \
+                                           && B_LEVEL(bh) <= MAX_HEIGHT)
  
  /***************************************************************************/
  /*                             STAT DATA                                   */
@@@ -1138,12 -1119,13 +1143,13 @@@ struct disk_child 
  #define put_dc_size(dc_p, val)   do { (dc_p)->dc_size = cpu_to_le16(val); } while(0)
  
  /* Get disk child by buffer header and position in the tree node. */
- #define B_N_CHILD(p_s_bh,n_pos)  ((struct disk_child *)\
- ((p_s_bh)->b_data+BLKH_SIZE+B_NR_ITEMS(p_s_bh)*KEY_SIZE+DC_SIZE*(n_pos)))
+ #define B_N_CHILD(bh, n_pos)  ((struct disk_child *)\
+ ((bh)->b_data + BLKH_SIZE + B_NR_ITEMS(bh) * KEY_SIZE + DC_SIZE * (n_pos)))
  
  /* Get disk child number by buffer header and position in the tree node. */
- #define B_N_CHILD_NUM(p_s_bh,n_pos) (dc_block_number(B_N_CHILD(p_s_bh,n_pos)))
- #define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) (put_dc_block_number(B_N_CHILD(p_s_bh,n_pos), val ))
+ #define B_N_CHILD_NUM(bh, n_pos) (dc_block_number(B_N_CHILD(bh, n_pos)))
+ #define PUT_B_N_CHILD_NUM(bh, n_pos, val) \
+                               (put_dc_block_number(B_N_CHILD(bh, n_pos), val))
  
   /* maximal value of field child_size in structure disk_child */
   /* child size is the combined size of all items and their headers */
@@@ -1214,33 -1196,33 +1220,33 @@@ struct treepath 
  struct treepath var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
  
  /* Get path element by path and path position. */
- #define PATH_OFFSET_PELEMENT(p_s_path,n_offset)  ((p_s_path)->path_elements +(n_offset))
+ #define PATH_OFFSET_PELEMENT(path, n_offset)  ((path)->path_elements + (n_offset))
  
  /* Get buffer header at the path by path and path position. */
- #define PATH_OFFSET_PBUFFER(p_s_path,n_offset)   (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_buffer)
+ #define PATH_OFFSET_PBUFFER(path, n_offset)   (PATH_OFFSET_PELEMENT(path, n_offset)->pe_buffer)
  
  /* Get position in the element at the path by path and path position. */
- #define PATH_OFFSET_POSITION(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_position)
+ #define PATH_OFFSET_POSITION(path, n_offset) (PATH_OFFSET_PELEMENT(path, n_offset)->pe_position)
  
- #define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
+ #define PATH_PLAST_BUFFER(path) (PATH_OFFSET_PBUFFER((path), (path)->path_length))
                                /* you know, to the person who didn't
                                   write this the macro name does not
                                   at first suggest what it does.
                                   Maybe POSITION_FROM_PATH_END? Or
                                   maybe we should just focus on
                                   dumping paths... -Hans */
- #define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
+ #define PATH_LAST_POSITION(path) (PATH_OFFSET_POSITION((path), (path)->path_length))
  
- #define PATH_PITEM_HEAD(p_s_path)    B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
+ #define PATH_PITEM_HEAD(path)    B_N_PITEM_HEAD(PATH_PLAST_BUFFER(path), PATH_LAST_POSITION(path))
  
  /* in do_balance leaf has h == 0 in contrast with path structure,
     where root has level == 0. That is why we need these defines */
- #define PATH_H_PBUFFER(p_s_path, h) PATH_OFFSET_PBUFFER (p_s_path, p_s_path->path_length - (h))       /* tb->S[h] */
+ #define PATH_H_PBUFFER(path, h) PATH_OFFSET_PBUFFER (path, path->path_length - (h))   /* tb->S[h] */
  #define PATH_H_PPARENT(path, h) PATH_H_PBUFFER (path, (h) + 1)        /* tb->F[h] or tb->S[0]->b_parent */
  #define PATH_H_POSITION(path, h) PATH_OFFSET_POSITION (path, path->path_length - (h))
  #define PATH_H_B_ITEM_ORDER(path, h) PATH_H_POSITION(path, h + 1)     /* tb->S[h]->b_item_order */
  
- #define PATH_H_PATH_OFFSET(p_s_path, n_h) ((p_s_path)->path_length - (n_h))
+ #define PATH_H_PATH_OFFSET(path, n_h) ((path)->path_length - (n_h))
  
  #define get_last_bh(path) PATH_PLAST_BUFFER(path)
  #define get_ih(path) PATH_PITEM_HEAD(path)
@@@ -1470,6 -1452,16 +1476,16 @@@ struct buffer_info 
        int bi_position;
  };
  
+ static inline struct super_block *sb_from_tb(struct tree_balance *tb)
+ {
+       return tb ? tb->tb_sb : NULL;
+ }
+ static inline struct super_block *sb_from_bi(struct buffer_info *bi)
+ {
+       return bi ? sb_from_tb(bi->tb) : NULL;
+ }
  /* there are 4 types of items: stat data, directory item, indirect, direct.
  +-------------------+------------+--------------+------------+
  |                 |  k_offset  | k_uniqueness | mergeable? |
@@@ -1520,7 -1512,7 +1536,7 @@@ extern struct item_operations *item_ops
  #define COMP_SHORT_KEYS comp_short_keys
  
  /* number of blocks pointed to by the indirect item */
- #define I_UNFM_NUM(p_s_ih)    ( ih_item_len(p_s_ih) / UNFM_P_SIZE )
+ #define I_UNFM_NUM(ih)        (ih_item_len(ih) / UNFM_P_SIZE)
  
  /* the used space within the unformatted node corresponding to pos within the item pointed to by ih */
  #define I_POS_UNFM_SIZE(ih,pos,size) (((pos) == I_UNFM_NUM(ih) - 1 ) ? (size) - ih_free_space(ih) : (size))
@@@ -1566,6 -1558,7 +1582,6 @@@ struct reiserfs_iget_args 
  /*                    FUNCTION DECLARATIONS                                */
  /***************************************************************************/
  
 -/*#ifdef __KERNEL__*/
  #define get_journal_desc_magic(bh) (bh->b_data + bh->b_size - 12)
  
  #define journal_trans_half(blocksize) \
@@@ -1623,6 -1616,10 +1639,10 @@@ struct reiserfs_journal_header 
  #define JOURNAL_MAX_COMMIT_AGE 30
  #define JOURNAL_MAX_TRANS_AGE 30
  #define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9)
+ #define JOURNAL_BLOCKS_PER_OBJECT(sb)  (JOURNAL_PER_BALANCE_CNT * 3 + \
+                                        2 * (REISERFS_QUOTA_INIT_BLOCKS(sb) + \
+                                             REISERFS_QUOTA_TRANS_BLOCKS(sb)))
  #ifdef CONFIG_QUOTA
  /* We need to update data and inode (atime) */
  #define REISERFS_QUOTA_TRANS_BLOCKS(s) (REISERFS_SB(s)->s_mount_opt & (1<<REISERFS_QUOTA) ? 2 : 0)
@@@ -1697,7 -1694,7 +1717,7 @@@ struct reiserfs_transaction_handle 
        int t_refcount;
        int t_blocks_logged;    /* number of blocks this writer has logged */
        int t_blocks_allocated; /* number of blocks this writer allocated */
-       unsigned long t_trans_id;       /* sanity check, equals the current trans id */
+       unsigned int t_trans_id;        /* sanity check, equals the current trans id */
        void *t_handle_save;    /* save existing current->journal_info */
        unsigned displace_new_blocks:1; /* if new block allocation occurres, that block
                                           should be displaced from others */
@@@ -1773,13 -1770,13 +1793,13 @@@ int journal_end_sync(struct reiserfs_tr
  int journal_mark_freed(struct reiserfs_transaction_handle *,
                       struct super_block *, b_blocknr_t blocknr);
  int journal_transaction_should_end(struct reiserfs_transaction_handle *, int);
- int reiserfs_in_journal(struct super_block *p_s_sb, unsigned int bmap_nr,
-                       int bit_nr, int searchall, b_blocknr_t *next);
+ int reiserfs_in_journal(struct super_block *sb, unsigned int bmap_nr,
+                        int bit_nr, int searchall, b_blocknr_t *next);
  int journal_begin(struct reiserfs_transaction_handle *,
-                 struct super_block *p_s_sb, unsigned long);
+                 struct super_block *sb, unsigned long);
  int journal_join_abort(struct reiserfs_transaction_handle *,
-                      struct super_block *p_s_sb, unsigned long);
- void reiserfs_journal_abort(struct super_block *sb, int errno);
+                      struct super_block *sb, unsigned long);
+ void reiserfs_abort_journal(struct super_block *sb, int errno);
  void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...);
  int reiserfs_allocate_list_bitmaps(struct super_block *s,
                                   struct reiserfs_list_bitmap *, unsigned int);
@@@ -1796,8 -1793,8 +1816,8 @@@ int reiserfs_convert_objectid_map_v1(st
  
  /* stree.c */
  int B_IS_IN_TREE(const struct buffer_head *);
- extern void copy_item_head(struct item_head *p_v_to,
-                          const struct item_head *p_v_from);
+ extern void copy_item_head(struct item_head *to,
+                          const struct item_head *from);
  
  // first key is in cpu form, second - le
  extern int comp_short_keys(const struct reiserfs_key *le_key,
@@@ -1832,20 -1829,20 +1852,20 @@@ static inline void copy_key(struct reis
        memcpy(to, from, KEY_SIZE);
  }
  
- int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path);
- const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path,
-                                   const struct super_block *p_s_sb);
+ int comp_items(const struct item_head *stored_ih, const struct treepath *path);
+ const struct reiserfs_key *get_rkey(const struct treepath *chk_path,
+                                   const struct super_block *sb);
  int search_by_key(struct super_block *, const struct cpu_key *,
                  struct treepath *, int);
  #define search_item(s,key,path) search_by_key (s, key, path, DISK_LEAF_NODE_LEVEL)
- int search_for_position_by_key(struct super_block *p_s_sb,
-                              const struct cpu_key *p_s_cpu_key,
-                              struct treepath *p_s_search_path);
- extern void decrement_bcount(struct buffer_head *p_s_bh);
- void decrement_counters_in_path(struct treepath *p_s_search_path);
- void pathrelse(struct treepath *p_s_search_path);
+ int search_for_position_by_key(struct super_block *sb,
+                              const struct cpu_key *cpu_key,
+                              struct treepath *search_path);
+ extern void decrement_bcount(struct buffer_head *bh);
+ void decrement_counters_in_path(struct treepath *search_path);
+ void pathrelse(struct treepath *search_path);
  int reiserfs_check_path(struct treepath *p);
- void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_path);
+ void pathrelse_and_restore(struct super_block *s, struct treepath *search_path);
  
  int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
                         struct treepath *path,
@@@ -1868,14 -1865,14 +1888,14 @@@ int reiserfs_cut_from_item(struct reise
  int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
                         struct treepath *path,
                         const struct cpu_key *key,
-                        struct inode *inode, struct buffer_head *p_s_un_bh);
+                        struct inode *inode, struct buffer_head *un_bh);
  
  void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
                                struct inode *inode, struct reiserfs_key *key);
  int reiserfs_delete_object(struct reiserfs_transaction_handle *th,
-                          struct inode *p_s_inode);
+                          struct inode *inode);
  int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
-                        struct inode *p_s_inode, struct page *,
+                        struct inode *inode, struct page *,
                         int update_timestamps);
  
  #define i_block_size(inode) ((inode)->i_sb->s_blocksize)
@@@ -1919,10 -1916,12 +1939,12 @@@ void make_le_item_head(struct item_hea
                       loff_t offset, int type, int length, int entry_count);
  struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key);
  
+ struct reiserfs_security_handle;
  int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
                       struct inode *dir, int mode,
                       const char *symname, loff_t i_size,
-                      struct dentry *dentry, struct inode *inode);
+                      struct dentry *dentry, struct inode *inode,
+                      struct reiserfs_security_handle *security);
  
  void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
                             struct inode *inode, loff_t size);
@@@ -1980,7 -1979,7 +2002,7 @@@ int reiserfs_global_version_in_proc(cha
  #define PROC_INFO_MAX( sb, field, value ) VOID_V
  #define PROC_INFO_INC( sb, field ) VOID_V
  #define PROC_INFO_ADD( sb, field, val ) VOID_V
- #define PROC_INFO_BH_STAT( p_s_sb, p_s_bh, n_node_level ) VOID_V
+ #define PROC_INFO_BH_STAT(sb, bh, n_node_level) VOID_V
  #endif
  
  /* dir.c */
@@@ -1988,6 -1987,7 +2010,7 @@@ extern const struct inode_operations re
  extern const struct inode_operations reiserfs_symlink_inode_operations;
  extern const struct inode_operations reiserfs_special_inode_operations;
  extern const struct file_operations reiserfs_dir_operations;
+ int reiserfs_readdir_dentry(struct dentry *, void *, filldir_t, loff_t *);
  
  /* tail_conversion.c */
  int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
@@@ -2004,13 -2004,20 +2027,20 @@@ extern const struct address_space_opera
  
  /* fix_nodes.c */
  
- int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb,
-             struct item_head *p_s_ins_ih, const void *);
+ int fix_nodes(int n_op_mode, struct tree_balance *tb,
+             struct item_head *ins_ih, const void *);
  void unfix_nodes(struct tree_balance *);
  
  /* prints.c */
- void reiserfs_panic(struct super_block *s, const char *fmt, ...)
+ void __reiserfs_panic(struct super_block *s, const char *id,
+                     const char *function, const char *fmt, ...)
      __attribute__ ((noreturn));
+ #define reiserfs_panic(s, id, fmt, args...) \
+       __reiserfs_panic(s, id, __func__, fmt, ##args)
+ void __reiserfs_error(struct super_block *s, const char *id,
+                     const char *function, const char *fmt, ...);
+ #define reiserfs_error(s, id, fmt, args...) \
+        __reiserfs_error(s, id, __func__, fmt, ##args)
  void reiserfs_info(struct super_block *s, const char *fmt, ...);
  void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...);
  void print_indirect_item(struct buffer_head *bh, int item_num);
@@@ -2047,7 -2054,7 +2077,7 @@@ void leaf_paste_in_buffer(struct buffer
                          int zeros_number);
  void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num,
                          int pos_in_item, int cut_size);
- void leaf_paste_entries(struct buffer_head *bh, int item_num, int before,
+ void leaf_paste_entries(struct buffer_info *bi, int item_num, int before,
                        int new_entry_count, struct reiserfs_de_head *new_dehs,
                        const char *records, int paste_size);
  /* ibalance.c */
@@@ -2203,6 -2210,26 +2233,6 @@@ long reiserfs_compat_ioctl(struct file 
                   unsigned int cmd, unsigned long arg);
  int reiserfs_unpack(struct inode *inode, struct file *filp);
  
 -/* ioctl's command */
 -#define REISERFS_IOC_UNPACK           _IOW(0xCD,1,long)
 -/* define following flags to be the same as in ext2, so that chattr(1),
 -   lsattr(1) will work with us. */
 -#define REISERFS_IOC_GETFLAGS         FS_IOC_GETFLAGS
 -#define REISERFS_IOC_SETFLAGS         FS_IOC_SETFLAGS
 -#define REISERFS_IOC_GETVERSION               FS_IOC_GETVERSION
 -#define REISERFS_IOC_SETVERSION               FS_IOC_SETVERSION
 -
 -/* the 32 bit compat definitions with int argument */
 -#define REISERFS_IOC32_UNPACK         _IOW(0xCD, 1, int)
 -#define REISERFS_IOC32_GETFLAGS               FS_IOC32_GETFLAGS
 -#define REISERFS_IOC32_SETFLAGS               FS_IOC32_SETFLAGS
 -#define REISERFS_IOC32_GETVERSION     FS_IOC32_GETVERSION
 -#define REISERFS_IOC32_SETVERSION     FS_IOC32_SETVERSION
--
 -/* Locking primitives */
 -/* Right now we are still falling back to (un)lock_kernel, but eventually that
 -   would evolve into real per-fs locks */
 -#define reiserfs_write_lock( sb ) lock_kernel()
 -#define reiserfs_write_unlock( sb ) unlock_kernel()
 +#endif /* __KERNEL__ */
  #endif                                /* _LINUX_REISER_FS_H */