diff mbox

[RFC,8/8] xfs: skip local format inode for reflinking

Message ID 1530846750-6686-9-git-send-email-shan.hai@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shan Hai July 6, 2018, 3:12 a.m. UTC
The local format inode holds the data inline in its data fork and
has no extents at all, so skip the inode for reflinking.

Signed-off-by: Shan Hai <shan.hai@oracle.com>
---
 fs/xfs/xfs_reflink.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Darrick J. Wong July 6, 2018, 3:26 a.m. UTC | #1
On Fri, Jul 06, 2018 at 11:12:29AM +0800, Shan Hai wrote:
> The local format inode holds the data inline in its data fork and
> has no extents at all, so skip the inode for reflinking.
> 
> Signed-off-by: Shan Hai <shan.hai@oracle.com>
> ---
>  fs/xfs/xfs_reflink.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 592fb2071a03..dfb3a85ec0e6 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -1507,6 +1507,12 @@ xfs_reflink_inode_has_shared_extents(
>  	int				error;
>  
>  	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> +
> +	if (ifp->if_flags & XFS_IFINLINE) {
> +		*has_shared = false;
> +		return 0;
> +	}

What happens if someone tries to reflink and either src or dest are an
inline file?

--D

> +
>  	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
>  		error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
>  		if (error)
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shan Hai July 6, 2018, 3:54 a.m. UTC | #2
On 2018年07月06日 11:26, Darrick J. Wong wrote:
> On Fri, Jul 06, 2018 at 11:12:29AM +0800, Shan Hai wrote:
>> The local format inode holds the data inline in its data fork and
>> has no extents at all, so skip the inode for reflinking.
>>
>> Signed-off-by: Shan Hai <shan.hai@oracle.com>
>> ---
>>   fs/xfs/xfs_reflink.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
>> index 592fb2071a03..dfb3a85ec0e6 100644
>> --- a/fs/xfs/xfs_reflink.c
>> +++ b/fs/xfs/xfs_reflink.c
>> @@ -1507,6 +1507,12 @@ xfs_reflink_inode_has_shared_extents(
>>   	int				error;
>>   
>>   	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
>> +
>> +	if (ifp->if_flags & XFS_IFINLINE) {
>> +		*has_shared = false;
>> +		return 0;
>> +	}
> What happens if someone tries to reflink and either src or dest are an
> inline file?

I have to re-check this, thanks for the suggestion.

Thanks
Shan Hai
> --D
>
>> +
>>   	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
>>   		error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
>>   		if (error)
>> -- 
>> 2.11.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoph Hellwig July 8, 2018, 4 p.m. UTC | #3
On Thu, Jul 05, 2018 at 08:26:53PM -0700, Darrick J. Wong wrote:
> What happens if someone tries to reflink and either src or dest are an
> inline file?

Very good question.  I'd also like to see how btrfs and gfs2
handle that case, as it would be good if all Linux file systems
behave the same way.
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 592fb2071a03..dfb3a85ec0e6 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -1507,6 +1507,12 @@  xfs_reflink_inode_has_shared_extents(
 	int				error;
 
 	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+
+	if (ifp->if_flags & XFS_IFINLINE) {
+		*has_shared = false;
+		return 0;
+	}
+
 	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
 		error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
 		if (error)