loff_t byte_offset = (block << inode->i_sb->s_blocksize_bits) + 1; 
loff_t byte_offset = ((loff_t)block << inode->i_sb->s_blocksize_bits)+1; 
static int map_block_for_writepage(struct inode *inode,				   struct buffer_head *bh_result,				   unsigned long block){	struct reiserfs_transaction_handle th;	int fs_gen;	struct item_head tmp_ih;	struct item_head *ih;	struct buffer_head *bh;	__le32 *item;	struct cpu_key key;	INITIALIZE_PATH(path);	int pos_in_item;	int jbegin_count = JOURNAL_PER_BALANCE_CNT;	loff_t byte_offset = (block << inode->i_sb->s_blocksize_bits) + 1;	int retval;	int use_get_block = 0;	int bytes_copied = 0;	int copy_size;	int trans_running = 0;	/* catch places below that try to log something without starting a trans */	th.t_trans_id = 0;	if (!buffer_uptodate(bh_result)) {		return -EIO;	}	kmap(bh_result->b_page);      start_over:	reiserfs_write_lock(inode->i_sb);	make_cpu_key(&key, inode, byte_offset, TYPE_ANY, 3);      research:	retval = search_for_position_by_key(inode->i_sb, &key, &path);	if (retval != POSITION_FOUND) {		use_get_block = 1;		goto out;	}	bh = get_last_bh(&path);	ih = get_ih(&path);	item = get_item(&path);	pos_in_item = path.pos_in_item;	/* 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);		}		if (!get_block_num(item, pos_in_item)) {			/* crap, we are writing to a hole */			use_get_block = 1;			goto out;		}		set_block_dev_mapped(bh_result,				     get_block_num(item, pos_in_item), inode);	} else if (is_direct_le_ih(ih)) {		char *p;		p = page_address(bh_result->b_page);		p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1);		copy_size = ih_item_len(ih) - pos_in_item;		fs_gen = get_generation(inode->i_sb);		copy_item_head(&tmp_ih, ih);		if (!trans_running) {			/* vs-3050 is gone, no need to drop the path */			retval = journal_begin(&th, inode->i_sb, jbegin_count);			if (retval)				goto out;			reiserfs_update_inode_transaction(inode);			trans_running = 1;			if (fs_changed(fs_gen, inode->i_sb)			    && item_moved(&tmp_ih, &path)) {				reiserfs_restore_prepared_buffer(inode->i_sb,								 bh);				goto research;			}		}		reiserfs_prepare_for_journal(inode->i_sb, bh, 1);		if (fs_changed(fs_gen, inode->i_sb)		    && item_moved(&tmp_ih, &path)) {			reiserfs_restore_prepared_buffer(inode->i_sb, bh);			goto research;		}		memcpy(B_I_PITEM(bh, ih) + pos_in_item, p + bytes_copied,		       copy_size);		journal_mark_dirty(&th, inode->i_sb, bh);		bytes_copied += copy_size;		set_block_dev_mapped(bh_result, 0, inode);		/* are there still bytes left? */		if (bytes_copied < bh_result->b_size &&		    (byte_offset + bytes_copied) < inode->i_size) {			set_cpu_key_k_offset(&key,					     cpu_key_k_offset(&key) +					     copy_size);			goto research;		}	} else {		reiserfs_warning(inode->i_sb,				 "clm-6003: bad item inode %lu, device %s",				 inode->i_ino, reiserfs_bdevname(inode->i_sb));		retval = -EIO;		goto out;	}	retval = 0;      out:	pathrelse(&path);	if (trans_running) {		int err = journal_end(&th, inode->i_sb, jbegin_count);		if (err)			retval = err;		trans_running = 0;	}	reiserfs_write_unlock(inode->i_sb);	/* this is where we fill in holes in the file. */	if (use_get_block) {		retval = reiserfs_get_block(inode, block, bh_result,					    GET_BLOCK_CREATE | GET_BLOCK_NO_ISEM					    | GET_BLOCK_NO_DANGLE);		if (!retval) {			if (!buffer_mapped(bh_result)			    || bh_result->b_blocknr == 0) {				/* get_block failed to find a mapped unformatted node. */				use_get_block = 0;				goto start_over;			}		}	}	kunmap(bh_result->b_page);	if (!retval && buffer_mapped(bh_result) && bh_result->b_blocknr == 0) {		/* we've copied data from the page into the direct item, so the		 * buffer in the page is now clean, mark it to reflect that.		 */		lock_buffer(bh_result);		clear_buffer_dirty(bh_result);		unlock_buffer(bh_result);	}	return retval;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7729ac5efe156129d172784fedeaddb2167a1914/inode.c/clean/fs/reiserfs/inode.c