jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 5 + 4 * REISERFS_QUOTA_TRANS_BLOCKS; 
jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 5 + 4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb); 
static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,			    struct inode * new_dir, struct dentry *new_dentry){    int retval;    INITIALIZE_PATH (old_entry_path);    INITIALIZE_PATH (new_entry_path);    INITIALIZE_PATH (dot_dot_entry_path);    struct item_head new_entry_ih, old_entry_ih, dot_dot_ih ;    struct reiserfs_dir_entry old_de, new_de, dot_dot_de;    struct inode * old_inode, * new_dentry_inode;    struct reiserfs_transaction_handle th ;    int jbegin_count ;     umode_t old_inode_mode;    unsigned long savelink = 1;    struct timespec ctime;    /* three balancings: (1) old name removal, (2) new name insertion       and (3) maybe "save" link insertion       stat data updates: (1) old directory,       (2) new directory and (3) maybe old object stat data (when it is       directory) and (4) maybe stat data of object to which new entry       pointed initially and (5) maybe block containing ".." of       renamed directory       quota updates: two parent directories */    jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 5 + 4 * REISERFS_QUOTA_TRANS_BLOCKS;    old_inode = old_dentry->d_inode;    new_dentry_inode = new_dentry->d_inode;    // make sure, that oldname still exists and points to an object we    // are going to rename    old_de.de_gen_number_bit_string = NULL;    reiserfs_write_lock(old_dir->i_sb);    retval = reiserfs_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len,				  &old_entry_path, &old_de);    pathrelse (&old_entry_path);    if (retval == IO_ERROR) {	reiserfs_write_unlock(old_dir->i_sb);	return -EIO;    }    if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {	reiserfs_write_unlock(old_dir->i_sb);	return -ENOENT;    }    old_inode_mode = old_inode->i_mode;    if (S_ISDIR(old_inode_mode)) {	// make sure, that directory being renamed has correct ".." 	// and that its new parent directory has not too many links	// already	if (new_dentry_inode) {	    if (!reiserfs_empty_dir(new_dentry_inode)) {		reiserfs_write_unlock(old_dir->i_sb);		return -ENOTEMPTY;	    }	}		/* directory is renamed, its parent directory will be changed, 	** so find ".." entry 	*/	dot_dot_de.de_gen_number_bit_string = NULL;	retval = reiserfs_find_entry (old_inode, "..", 2, &dot_dot_entry_path, &dot_dot_de);	pathrelse (&dot_dot_entry_path);	if (retval != NAME_FOUND) {	    reiserfs_write_unlock(old_dir->i_sb);	    return -EIO;	}	/* inode number of .. must equal old_dir->i_ino */	if (dot_dot_de.de_objectid != old_dir->i_ino) {	    reiserfs_write_unlock(old_dir->i_sb);	    return -EIO;	}    }    retval = journal_begin(&th, old_dir->i_sb, jbegin_count) ;    if (retval) {        reiserfs_write_unlock (old_dir->i_sb);        return retval;    }    /* add new entry (or find the existing one) */    retval = reiserfs_add_entry (&th, new_dir, new_dentry->d_name.name, 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");	}    } else if (retval) {	int err = journal_end(&th, old_dir->i_sb, jbegin_count) ;	reiserfs_write_unlock(old_dir->i_sb);	return err ? err : retval;    }    reiserfs_update_inode_transaction(old_dir) ;    reiserfs_update_inode_transaction(new_dir) ;    /* this makes it so an fsync on an open fd for the old name will    ** commit the rename operation    */    reiserfs_update_inode_transaction(old_inode) ;    if (new_dentry_inode) 	reiserfs_update_inode_transaction(new_dentry_inode) ;    while (1) {	// look for old name using corresponding entry key (found by reiserfs_find_entry)	if ((retval = search_by_entry_key (new_dir->i_sb, &old_de.de_entry_key,					   &old_entry_path, &old_de)) != NAME_FOUND) {	    pathrelse(&old_entry_path);	    journal_end(&th, old_dir->i_sb, jbegin_count);	    reiserfs_write_unlock(old_dir->i_sb);	    return -EIO;	}	copy_item_head(&old_entry_ih, get_ih(&old_entry_path)) ;	reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1) ;	// look for new name by reiserfs_find_entry	new_de.de_gen_number_bit_string = NULL;	retval = reiserfs_find_entry (new_dir, new_dentry->d_name.name, new_dentry->d_name.len, 				      &new_entry_path, &new_de);	// reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from        // reiserfs_add_entry above, and we'll catch any i/o errors before we get here.	if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {	    pathrelse(&new_entry_path);	    pathrelse(&old_entry_path);	    journal_end(&th, old_dir->i_sb, jbegin_count);	    reiserfs_write_unlock(old_dir->i_sb);	    return -EIO;	}	copy_item_head(&new_entry_ih, get_ih(&new_entry_path)) ;	reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1) ;	if (S_ISDIR(old_inode->i_mode)) {	    if ((retval = search_by_entry_key (new_dir->i_sb, &dot_dot_de.de_entry_key,					       &dot_dot_entry_path, &dot_dot_de)) != NAME_FOUND) {		pathrelse(&dot_dot_entry_path);		pathrelse(&new_entry_path);		pathrelse(&old_entry_path);		journal_end(&th, old_dir->i_sb, jbegin_count);		reiserfs_write_unlock(old_dir->i_sb);		return -EIO;	    }	    copy_item_head(&dot_dot_ih, get_ih(&dot_dot_entry_path)) ;	    // node containing ".." gets into transaction	    reiserfs_prepare_for_journal(old_inode->i_sb, dot_dot_de.de_bh, 1) ;	}				/* we should check seals here, not do                                   this stuff, yes? Then, having                                   gathered everything into RAM we                                   should lock the buffers, yes?  -Hans */				/* probably.  our rename needs to hold more 				** than one path at once.  The seals would 				** have to be written to deal with multi-path 				** issues -chris				*/	/* sanity checking before doing the rename - avoid races many	** of the above checks could have scheduled.  We have to be	** sure our items haven't been shifted by another process.	*/	if (item_moved(&new_entry_ih, &new_entry_path) ||	    !entry_points_to_object(new_dentry->d_name.name, 	                            new_dentry->d_name.len,				    &new_de, new_dentry_inode) ||	    item_moved(&old_entry_ih, &old_entry_path) || 	    !entry_points_to_object (old_dentry->d_name.name, 	                             old_dentry->d_name.len,				     &old_de, old_inode)) {	    reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);	    reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);	    if (S_ISDIR(old_inode_mode))		reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);	    continue;	}	if (S_ISDIR(old_inode_mode)) {	    if ( item_moved(&dot_dot_ih, &dot_dot_entry_path) ||		!entry_points_to_object ( "..", 2, &dot_dot_de, old_dir) ) {		reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);		reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);		reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);		continue;	    }	}	RFALSE( S_ISDIR(old_inode_mode) && 		 !buffer_journal_prepared(dot_dot_de.de_bh), "" );	break;    }    /* ok, all the changes can be done in one fell swoop when we       have claimed all the buffers needed.*/        mark_de_visible (new_de.de_deh + new_de.de_entry_num);    set_ino_in_dir_entry (&new_de, INODE_PKEY (old_inode));    journal_mark_dirty (&th, old_dir->i_sb, new_de.de_bh);    mark_de_hidden (old_de.de_deh + old_de.de_entry_num);    journal_mark_dirty (&th, old_dir->i_sb, old_de.de_bh);    ctime = CURRENT_TIME_SEC;    old_dir->i_ctime = old_dir->i_mtime = ctime;    new_dir->i_ctime = new_dir->i_mtime = ctime;    /* thanks to Alex Adriaanse <alex_a@caltech.edu> for patch which adds ctime update of       renamed object */    old_inode->i_ctime = ctime;    if (new_dentry_inode) {	// adjust link number of the victim	if (S_ISDIR(new_dentry_inode->i_mode)) {	    new_dentry_inode->i_nlink  = 0;	} else {	    new_dentry_inode->i_nlink--;	}	new_dentry_inode->i_ctime = ctime;	savelink = new_dentry_inode->i_nlink;    }    if (S_ISDIR(old_inode_mode)) {	// adjust ".." of renamed directory 	set_ino_in_dir_entry (&dot_dot_de, INODE_PKEY (new_dir));	journal_mark_dirty (&th, new_dir->i_sb, dot_dot_de.de_bh);	        if (!new_dentry_inode)	    /* there (in new_dir) was no directory, so it got new link	       (".."  of renamed directory) */	    INC_DIR_INODE_NLINK(new_dir);			/* old directory lost one link - ".. " of renamed directory */	DEC_DIR_INODE_NLINK(old_dir);    }    // looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse    pathrelse (&new_entry_path);    pathrelse (&dot_dot_entry_path);    // FIXME: this reiserfs_cut_from_item's return value may screw up    // anybody, but it will panic if will not be able to find the    // entry. This needs one more clean up    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?");    old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;    reiserfs_update_sd (&th, old_dir);    reiserfs_update_sd (&th, new_dir);    reiserfs_update_sd (&th, old_inode);    if (new_dentry_inode) {	if (savelink == 0)	    add_save_link (&th, new_dentry_inode, 0/* not truncate */);	reiserfs_update_sd (&th, new_dentry_inode);    }    retval = journal_end(&th, old_dir->i_sb, jbegin_count) ;    reiserfs_write_unlock(old_dir->i_sb);    return retval;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/556a2a45bce1740f035befaa7201e4ad836c7257/namei.c/clean/fs/reiserfs/namei.c