BMAPI_READ|BMAPI_IGNSTATE); 
BMAPI_WRITE|BMAPI_IGNSTATE); 
xfs_page_state_convert(	struct inode	*inode,	struct page	*page,	struct writeback_control *wbc,	int		startio,	int		unmapped) /* also implies page uptodate */{	struct buffer_head	*bh_arr[MAX_BUF_PER_PAGE], *bh, *head;	xfs_iomap_t		*iomp, iomap;	loff_t			offset;	unsigned long           p_offset = 0;	__uint64_t              end_offset;	pgoff_t                 end_index, last_index, tlast;	int			len, err, i, cnt = 0, uptodate = 1;	int			flags;	int			page_dirty;	/* wait for other IO threads? */	flags = (startio && wbc->sync_mode != WB_SYNC_NONE) ? 0 : BMAPI_TRYLOCK;	/* Is this page beyond the end of the file? */	offset = i_size_read(inode);	end_index = offset >> PAGE_CACHE_SHIFT;	last_index = (offset - 1) >> PAGE_CACHE_SHIFT;	if (page->index >= end_index) {		if ((page->index >= end_index + 1) ||		    !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {			err = -EIO;			goto error;		}	}	end_offset = min_t(unsigned long long,			(loff_t)(page->index + 1) << PAGE_CACHE_SHIFT, offset);	offset = (loff_t)page->index << PAGE_CACHE_SHIFT;	/*	 * page_dirty is initially a count of buffers on the page before	 * EOF and is decrememted as we move each into a cleanable state.	 */	len = 1 << inode->i_blkbits;	p_offset = max(p_offset, PAGE_CACHE_SIZE);	p_offset = roundup(p_offset, len);	page_dirty = p_offset / len;	iomp = NULL;	p_offset = 0;	bh = head = page_buffers(page);	do {		if (offset >= end_offset)			break;		if (!buffer_uptodate(bh))			uptodate = 0;		if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio)			continue;		if (iomp) {			iomp = xfs_offset_to_map(page, &iomap, p_offset);		}		/*		 * First case, map an unwritten extent and prepare for		 * extent state conversion transaction on completion.		 */		if (buffer_unwritten(bh)) {			if (!startio)				continue;			if (!iomp) {				err = xfs_map_blocks(inode, offset, len, &iomap,						BMAPI_READ|BMAPI_IGNSTATE);				if (err) {					goto error;				}				iomp = xfs_offset_to_map(page, &iomap,								p_offset);			}			if (iomp) {				if (!bh->b_end_io) {					err = xfs_map_unwritten(inode, page,							head, bh, p_offset,							inode->i_blkbits, iomp,							wbc, startio, unmapped);					if (err) {						goto error;					}				} else {					set_bit(BH_Lock, &bh->b_state);				}				BUG_ON(!buffer_locked(bh));				bh_arr[cnt++] = bh;				page_dirty--;			}		/*		 * Second case, allocate space for a delalloc buffer.		 * We can return EAGAIN here in the release page case.		 */		} else if (buffer_delay(bh)) {			if (!iomp) {				err = xfs_map_blocks(inode, offset, len, &iomap,						BMAPI_ALLOCATE | flags);				if (err) {					goto error;				}				iomp = xfs_offset_to_map(page, &iomap,								p_offset);			}			if (iomp) {				xfs_map_at_offset(page, bh, p_offset,						inode->i_blkbits, iomp);				if (startio) {					bh_arr[cnt++] = bh;				} else {					set_buffer_dirty(bh);					unlock_buffer(bh);					mark_buffer_dirty(bh);				}				page_dirty--;			}		} else if ((buffer_uptodate(bh) || PageUptodate(page)) &&			   (unmapped || startio)) {			if (!buffer_mapped(bh)) {				int	size;				/*				 * Getting here implies an unmapped buffer				 * was found, and we are in a path where we				 * need to write the whole page out.				 */				if (!iomp) {					size = xfs_probe_unmapped_cluster(							inode, page, bh, head);					err = xfs_map_blocks(inode, offset,							size, &iomap,							BMAPI_WRITE|BMAPI_MMAP);					if (err) {						goto error;					}					iomp = xfs_offset_to_map(page, &iomap,								     p_offset);				}				if (iomp) {					xfs_map_at_offset(page,							bh, p_offset,							inode->i_blkbits, iomp);					if (startio) {						bh_arr[cnt++] = bh;					} else {						set_buffer_dirty(bh);						unlock_buffer(bh);						mark_buffer_dirty(bh);					}					page_dirty--;				}			} else if (startio) {				if (buffer_uptodate(bh) &&				    !test_and_set_bit(BH_Lock, &bh->b_state)) {					bh_arr[cnt++] = bh;					page_dirty--;				}			}		}	} while (offset += len, p_offset += len,		((bh = bh->b_this_page) != head));	if (uptodate && bh == head)		SetPageUptodate(page);	if (startio) {		xfs_submit_page(page, wbc, bh_arr, cnt, 0, !page_dirty);	}	if (iomp) {		offset = (iomp->iomap_offset + iomp->iomap_bsize - 1) >>					PAGE_CACHE_SHIFT;		tlast = min_t(pgoff_t, offset, last_index);		xfs_cluster_write(inode, page->index + 1, iomp, wbc,					startio, unmapped, tlast);	}	return page_dirty;error:	for (i = 0; i < cnt; i++) {		unlock_buffer(bh_arr[i]);	}	/*	 * If it's delalloc and we have nowhere to put it,	 * throw it away, unless the lower layers told	 * us to try again.	 */	if (err != -EAGAIN) {		if (!unmapped) {			block_invalidatepage(page, 0);		}		ClearPageUptodate(page);	}	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/c31e887807a3eab26614ee142629ba447cbcc0dc/xfs_aops.c/clean/fs/xfs/linux-2.6/xfs_aops.c