aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2016-10-03 12:11:50 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2016-10-05 19:26:31 -0400
commitc8e156ac336d82f67d7adc014404a2251e9dad09 (patch)
treead4439160ac5088574fa6984270ee2221438abb2
parente153aa7990a09a8a12860fc1f79304b02a6bc03f (diff)
xfs: check for invalid inode reflink flags
We don't support sharing blocks on the realtime device. Flag inodes with the reflink or cowextsize flags set when the reflink feature is disabled. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c16
-rw-r--r--fs/xfs/xfs_ioctl.c4
2 files changed, 20 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index a3e803823a19..f1b9d97c540f 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -375,6 +375,9 @@ xfs_dinode_verify(
375 struct xfs_inode *ip, 375 struct xfs_inode *ip,
376 struct xfs_dinode *dip) 376 struct xfs_dinode *dip)
377{ 377{
378 uint16_t flags;
379 uint64_t flags2;
380
378 if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) 381 if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
379 return false; 382 return false;
380 383
@@ -391,6 +394,19 @@ xfs_dinode_verify(
391 return false; 394 return false;
392 if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid)) 395 if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
393 return false; 396 return false;
397
398 flags = be16_to_cpu(dip->di_flags);
399 flags2 = be64_to_cpu(dip->di_flags2);
400
401 /* don't allow reflink/cowextsize if we don't have reflink */
402 if ((flags2 & (XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE)) &&
403 !xfs_sb_version_hasreflink(&mp->m_sb))
404 return false;
405
406 /* don't let reflink and realtime mix */
407 if ((flags2 & XFS_DIFLAG2_REFLINK) && (flags & XFS_DIFLAG_REALTIME))
408 return false;
409
394 return true; 410 return true;
395} 411}
396 412
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1388a1275dc8..c65d9eacf54d 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1034,6 +1034,10 @@ xfs_ioctl_setattr_xflags(
1034 return -EINVAL; 1034 return -EINVAL;
1035 } 1035 }
1036 1036
1037 /* Don't allow us to set realtime mode for a reflinked file. */
1038 if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip))
1039 return -EINVAL;
1040
1037 /* 1041 /*
1038 * Can't modify an immutable/append-only file unless 1042 * Can't modify an immutable/append-only file unless
1039 * we have appropriate permission. 1043 * we have appropriate permission.