[PATCH] xfs: fix sub-page blocksize data integrity writes
Dave Chinner
david at fromorbit.com
Thu May 2 02:58:36 CDT 2013
On Thu, May 02, 2013 at 05:45:09PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner at redhat.com>
>
> FSX on 512 byte block size filesystems has been failing for some
> time with corrupted data. The fault dates back to the change in
> the writeback data integrity algorithm that uses a mark-and-sweep
> approach to avoid data writeback livelocks.
.....
> + * time this will be the only page inteh file that needs writeback.
> + * Hence for more optimal IO patterns, we should always avoid partial
> + * page writeback due to multiple mappings on a page here.
> + */
> + if (!xfs_imap_valid(inode, imap, end_offset))
> + goto fail_unlock_page;
> +
> len = 1 << inode->i_blkbits;
> p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1),
> PAGE_CACHE_SIZE);
> p_offset = p_offset ? roundup(p_offset, len) : PAGE_CACHE_SIZE;
> page_dirty = p_offset / len;
>
> +
Oh, stray whitespace....
> bh = head = page_buffers(page);
> do {
> if (offset >= end_offset)
> diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
> index 1501f4f..0176bb2 100644
> --- a/fs/xfs/xfs_vnodeops.c
> +++ b/fs/xfs/xfs_vnodeops.c
> @@ -1453,7 +1453,7 @@ xfs_free_file_space(
> xfs_mount_t *mp;
> int nimap;
> uint resblks;
> - uint rounding;
> + xfs_off_t rounding;
> int rt;
> xfs_fileoff_t startoffset_fsb;
> xfs_trans_t *tp;
> @@ -1482,7 +1482,7 @@ xfs_free_file_space(
> inode_dio_wait(VFS_I(ip));
> }
>
> - rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
> + rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
> ioffset = offset & ~(rounding - 1);
> error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
> ioffset, -1);
And I forgot I had noticed a second problem while dealing with this
one (i.e. the rounding masks is wrong for offsets > 32 bits)....
I'll repost them both as separate patches.
Cheers,
Dave.
--
Dave Chinner
david at fromorbit.com
More information about the xfs
mailing list