| To: | Dave Chinner <david@xxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: [PATCH 1/6] [XFS] Split inode data writeback from inode sync. |
| From: | Christoph Hellwig <hch@xxxxxxxxxxxxx> |
| Date: | Mon, 16 Mar 2009 06:10:08 -0400 |
| Cc: | xfs@xxxxxxxxxxx |
| In-reply-to: | <1237117603-26071-2-git-send-email-david@xxxxxxxxxxxxx> |
| References: | <1237117603-26071-1-git-send-email-david@xxxxxxxxxxxxx> <1237117603-26071-2-git-send-email-david@xxxxxxxxxxxxx> |
| User-agent: | Mutt/1.5.18 (2008-05-17) |
> +static int
> +xfs_sync_inode_data(
> + struct xfs_inode *ip,
> + int flags)
> +{
> + struct inode *inode = VFS_I(ip);
> + int error = 0;
> +
> + if (VN_DIRTY(inode)) {
> + int locked = 0;
> + if (flags & SYNC_TRYLOCK) {
> + if (xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
> + locked = 1;
> + } else {
> + xfs_ilock(ip, XFS_IOLOCK_SHARED);
> + locked = 1;
> + }
> + if (locked) {
> + error = xfs_flush_pages(ip, 0, -1,
> + (flags & SYNC_WAIT) ? 0 : XFS_B_ASYNC,
> + FI_NONE);
> + xfs_iunlock(ip, XFS_IOLOCK_SHARED);
> + }
> + }
> +
> + if (flags & SYNC_IOWAIT)
> + xfs_ioend_wait(ip);
> +
> + return error;
> +}
In the end this should look more like:
static int
xfs_sync_inode_data(
struct xfs_inode *ip,
int flags)
{
struct inode *inode = VFS_I(ip);
struct address_space *mapping = inode->i_mapping;
int error = 0;
if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) {
if (flags & SYNC_TRYLOCK)
goto out;
xfs_ilock(ip, XFS_IOLOCK_SHARED);
}
if (flags & SYNC_WAIT) {
error = filemap_write_and_wait(mapping);
else
error = filemap_fdatawrite(mapping);
xfs_iflags_clear(ip, XFS_ITRUNCATED);
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
}
out:
if (flags & SYNC_IOWAIT)
xfs_ioend_wait(ip);
return -error;
}
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PATCH 0/6] [XFS] introduce a AG inode tree walker, Christoph Hellwig |
|---|---|
| Next by Date: | Re: [PATCH 3/5] [XFS] Block callers of xfs_flush_inodes() correctly., Dave Chinner |
| Previous by Thread: | [PATCH 1/6] [XFS] Split inode data writeback from inode sync., Dave Chinner |
| Next by Thread: | Re: [PATCH 1/6] [XFS] Split inode data writeback from inode sync., Dave Chinner |
| Indexes: | [Date] [Thread] [Top] [All Lists] |