Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6
[pandora-kernel.git] / fs / reiserfs / namei.c
index c812330..23f5cd5 100644 (file)
@@ -11,7 +11,6 @@
  * NO WARRANTY
  */
 
-#include <linux/config.h>
 #include <linux/time.h>
 #include <linux/bitops.h>
 #include <linux/reiserfs_fs.h>
@@ -20,8 +19,8 @@
 #include <linux/smp_lock.h>
 #include <linux/quotaops.h>
 
-#define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { i->i_nlink++; if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
-#define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) i->i_nlink--;
+#define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
+#define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
 
 // directory item contains array of entry headers. This performs
 // binary search through that array
@@ -55,7 +54,7 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
 
 // comment?  maybe something like set de to point to what the path points to?
 static inline void set_de_item_location(struct reiserfs_dir_entry *de,
-                                       struct path *path)
+                                       struct treepath *path)
 {
        de->de_bh = get_last_bh(path);
        de->de_ih = get_ih(path);
@@ -68,8 +67,7 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
 {
        struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
 
-       if (de->de_entry_num >= ih_entry_count(de->de_ih))
-               BUG();
+       BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih));
 
        de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num);
        de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0);
@@ -81,8 +79,7 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
 // what entry points to
 static inline void set_de_object_key(struct reiserfs_dir_entry *de)
 {
-       if (de->de_entry_num >= ih_entry_count(de->de_ih))
-               BUG();
+       BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih));
        de->de_dir_id = deh_dir_id(&(de->de_deh[de->de_entry_num]));
        de->de_objectid = deh_objectid(&(de->de_deh[de->de_entry_num]));
 }
@@ -91,8 +88,7 @@ static inline void store_de_entry_key(struct reiserfs_dir_entry *de)
 {
        struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
 
-       if (de->de_entry_num >= ih_entry_count(de->de_ih))
-               BUG();
+       BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih));
 
        /* store key of the found entry */
        de->de_entry_key.version = KEY_FORMAT_3_5;
@@ -117,7 +113,7 @@ entry position in the item
 
 /* The function is NOT SCHEDULE-SAFE! */
 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
-                       struct path *path, struct reiserfs_dir_entry *de)
+                       struct treepath *path, struct reiserfs_dir_entry *de)
 {
        int retval;
 
@@ -247,7 +243,7 @@ static int linear_search_in_dir_item(struct cpu_key *key,
                /* mark, that this generation number is used */
                if (de->de_gen_number_bit_string)
                        set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
-                               (unsigned long *)de->de_gen_number_bit_string);
+                               de->de_gen_number_bit_string);
 
                // calculate pointer to name and namelen
                de->de_entry_num = i;
@@ -286,7 +282,7 @@ static int linear_search_in_dir_item(struct cpu_key *key,
 // may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
 // FIXME: should add something like IOERROR
 static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
-                              struct path *path_to_entry,
+                              struct treepath *path_to_entry,
                               struct reiserfs_dir_entry *de)
 {
        struct cpu_key key_to_search;
@@ -431,7 +427,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
        struct reiserfs_de_head *deh;
        INITIALIZE_PATH(path);
        struct reiserfs_dir_entry de;
-       int bit_string[MAX_GENERATION_NUMBER / (sizeof(int) * 8) + 1];
+       DECLARE_BITMAP(bit_string, MAX_GENERATION_NUMBER + 1);
        int gen_number;
        char small_buf[32 + DEH_SIZE];  /* 48 bytes now and we avoid kmalloc
                                           if we create file with short name */
@@ -486,7 +482,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
 
        /* find the proper place for the new entry */
        memset(bit_string, 0, sizeof(bit_string));
-       de.de_gen_number_bit_string = (char *)bit_string;
+       de.de_gen_number_bit_string = bit_string;
        retval = reiserfs_find_entry(dir, name, namelen, &path, &de);
        if (retval != NAME_NOT_FOUND) {
                if (buffer != small_buf)
@@ -508,7 +504,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
        }
 
        gen_number =
-           find_first_zero_bit((unsigned long *)bit_string,
+           find_first_zero_bit(bit_string,
                                MAX_GENERATION_NUMBER + 1);
        if (gen_number > MAX_GENERATION_NUMBER) {
                /* there is no free generation number */
@@ -914,7 +910,7 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
                reiserfs_warning(inode->i_sb, "%s: empty directory has nlink "
                                 "!= 2 (%d)", __FUNCTION__, inode->i_nlink);
 
-       inode->i_nlink = 0;
+       clear_nlink(inode);
        inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
        reiserfs_update_sd(&th, inode);
 
@@ -995,7 +991,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
                inode->i_nlink = 1;
        }
 
-       inode->i_nlink--;
+       drop_nlink(inode);
 
        /*
         * we schedule before doing the add_save_link call, save the link
@@ -1007,7 +1003,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
            reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL,
                                   0);
        if (retval < 0) {
-               inode->i_nlink++;
+               inc_nlink(inode);
                goto end_unlink;
        }
        inode->i_ctime = CURRENT_TIME_SEC;
@@ -1144,7 +1140,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
        }
 
        /* inc before scheduling so reiserfs_unlink knows we are here */
-       inode->i_nlink++;
+       inc_nlink(inode);
 
        retval = journal_begin(&th, dir->i_sb, jbegin_count);
        if (retval) {
@@ -1474,9 +1470,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        if (new_dentry_inode) {
                // adjust link number of the victim
                if (S_ISDIR(new_dentry_inode->i_mode)) {
-                       new_dentry_inode->i_nlink = 0;
+                       clear_nlink(new_dentry_inode);
                } else {
-                       new_dentry_inode->i_nlink--;
+                       drop_nlink(new_dentry_inode);
                }
                new_dentry_inode->i_ctime = ctime;
                savelink = new_dentry_inode->i_nlink;