xfs: fix the same_inode check in xfs_file_share_range
authorChristoph Hellwig <hch@lst.de>
Thu, 20 Oct 2016 04:49:03 +0000 (15:49 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 20 Oct 2016 04:49:03 +0000 (15:49 +1100)
The VFS i_ino is an unsigned long, while XFS inode numbers are 64-bit
wide, so checking i_ino for equality could lead to rate false positives
on 32-bit architectures.  Just compare the inode pointers themselves
to be safe.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_file.c

index 194f8f396e4d0432f4e021284220c0a50930a0d3..d5b835e82b2d4b3dd1d0b03afb3a1e0637e1909f 100644 (file)
@@ -965,7 +965,7 @@ xfs_file_share_range(
            IS_SWAPFILE(inode_out))
                return -ETXTBSY;
 
-       same_inode = (inode_in->i_ino == inode_out->i_ino);
+       same_inode = (inode_in == inode_out);
 
        /* Don't reflink dirs, pipes, sockets... */
        if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))