X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=fs%2Freiserfs%2Fnamei.c;h=c1add28dd45ec144ec946b3ddba2c06a340af405;hb=b0fc5e043401df4cd243352f1030c4d23e767347;hp=284f7852de8b00e53211e40822d935acef0d9a67;hpb=2e9abdd9bad485970b37cd53a82f92702054984c;p=linux-2.6-omap-h63xx.git diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 284f7852de8..c1add28dd45 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -11,17 +11,15 @@ * NO WARRANTY */ -#include #include #include #include #include #include -#include #include -#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 +53,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 +66,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 +78,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 +87,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 +112,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; @@ -286,7 +281,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; @@ -306,7 +301,7 @@ static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen, path_to_entry, de); if (retval == IO_ERROR) { reiserfs_warning(dir->i_sb, "zam-7001: io error in %s", - __FUNCTION__); + __func__); return IO_ERROR; } @@ -457,7 +452,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th, buflen = DEH_SIZE + ROUND_UP(namelen); if (buflen > sizeof(small_buf)) { buffer = kmalloc(buflen, GFP_NOFS); - if (buffer == 0) + if (!buffer) return -ENOMEM; } else buffer = small_buf; @@ -501,7 +496,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th, reiserfs_warning(dir->i_sb, "zam-7002:%s: \"reiserfs_find_entry\" " "has returned unexpected value (%d)", - __FUNCTION__, retval); + __func__, retval); } return -EEXIST; @@ -912,9 +907,9 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry) if (inode->i_nlink != 2 && inode->i_nlink != 1) reiserfs_warning(inode->i_sb, "%s: empty directory has nlink " - "!= 2 (%d)", __FUNCTION__, inode->i_nlink); + "!= 2 (%d)", __func__, 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); @@ -989,13 +984,13 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry) if (!inode->i_nlink) { reiserfs_warning(inode->i_sb, "%s: deleting nonexistent file " - "(%s:%lu), %d", __FUNCTION__, + "(%s:%lu), %d", __func__, reiserfs_bdevname(inode->i_sb), inode->i_ino, inode->i_nlink); inode->i_nlink = 1; } - inode->i_nlink--; + drop_nlink(inode); /* * we schedule before doing the add_save_link call, save the link @@ -1007,7 +1002,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 +1139,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 +1469,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; @@ -1529,7 +1524,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry, /* * directories can handle most operations... */ -struct inode_operations reiserfs_dir_inode_operations = { +const struct inode_operations reiserfs_dir_inode_operations = { //&reiserfs_dir_operations, /* default_file_ops */ .create = reiserfs_create, .lookup = reiserfs_lookup, @@ -1552,7 +1547,7 @@ struct inode_operations reiserfs_dir_inode_operations = { * symlink operations.. same as page_symlink_inode_operations, with xattr * stuff added */ -struct inode_operations reiserfs_symlink_inode_operations = { +const struct inode_operations reiserfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = page_follow_link_light, .put_link = page_put_link, @@ -1568,7 +1563,7 @@ struct inode_operations reiserfs_symlink_inode_operations = { /* * special file operations.. just xattr/acl stuff */ -struct inode_operations reiserfs_special_inode_operations = { +const struct inode_operations reiserfs_special_inode_operations = { .setattr = reiserfs_setattr, .setxattr = reiserfs_setxattr, .getxattr = reiserfs_getxattr,