xfs
[Top] [All Lists]

[PATCH RFC] xfs: use invalidate_inode_pages2_range for DIO writes

To: <xfs@xxxxxxxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx>, Eric Sandeen <sandeen@xxxxxxxxxx>
Subject: [PATCH RFC] xfs: use invalidate_inode_pages2_range for DIO writes
From: Chris Mason <clm@xxxxxx>
Date: Fri, 8 Aug 2014 12:04:40 -0400
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=message-id : date : from : mime-version : to : subject : references : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=hkfURDh/IGyzlHrhjsWVmtZq9IcA67p9amu+5Y7ZtiU=; b=S0GrJ4uaeEngGlIhFpZvgEFiJPSieD78u4SiffEIG/XTLdNE3X9gmtVk+fONLfTYfiwx c2k1x8HUERI3CWM/ou3BGcl0jPN6q5MNpn4UI6efzTxQD2fW3nx2PVQGPHnab6wMN1RB FE/CMCW5IOO41v0+yj3spr2tYMi6K6bMvpY=
In-reply-to: <53E4E03A.7050101@xxxxxx>
References: <53E4E03A.7050101@xxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
xfs is using truncate_pagecache_range to invalidate the page cache
during DIO writes.  The other filesystems are calling
invalidate_inode_pages2_range
 
truncate_pagecache_range is meant to be used when we are freeing the
underlying data structs from disk, so it will zero any partial ranges
in the page.  This means a DIO write can zero out part of the page cache
page, and it is possible the page will stay in cache.

This one is an RFC because it is untested and because I don't understand
how XFS is dealing with pages the truncate was unable to clear away.
I'm not able to actually trigger zeros by mixing DIO writes with
buffered reads.

Signed-off-by: Chris Mason <clm@xxxxxx>

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 8d25d98..c30c112 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -638,7 +638,10 @@ xfs_file_dio_aio_write(
                                                    pos, -1);
                if (ret)
                        goto out;
-               truncate_pagecache_range(VFS_I(ip), pos, -1);
+
+               /* what do we do if we can't invalidate the pages? */
+               invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
+                                             pos >> PAGE_CACHE_SHIFT, -1);
        }
 
        /*

<Prev in Thread] Current Thread [Next in Thread>