提交 cbe4dab1 编写于 作者: D Dave Chinner 提交者: Dave Chinner

xfs: add initial DAX support

Add initial DAX support to XFS. To do this we need a new mount
option to turn DAX on filesystem, and we need to propagate this into
the inode flags whenever an inode is instantiated so that the
per-inode checks throughout the code Do The Right Thing.
Signed-off-by: NDave Chinner <dchinner@redhat.com>
Reviewed-by: NBrian Foster <bfoster@redhat.com>
Signed-off-by: NDave Chinner <david@fromorbit.com>
上级 6e1ba0bc
...@@ -1195,22 +1195,22 @@ xfs_diflags_to_iflags( ...@@ -1195,22 +1195,22 @@ xfs_diflags_to_iflags(
struct inode *inode, struct inode *inode,
struct xfs_inode *ip) struct xfs_inode *ip)
{ {
if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE) uint16_t flags = ip->i_d.di_flags;
inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | S_SYNC |
S_NOATIME | S_DAX);
if (flags & XFS_DIFLAG_IMMUTABLE)
inode->i_flags |= S_IMMUTABLE; inode->i_flags |= S_IMMUTABLE;
else if (flags & XFS_DIFLAG_APPEND)
inode->i_flags &= ~S_IMMUTABLE;
if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
inode->i_flags |= S_APPEND; inode->i_flags |= S_APPEND;
else if (flags & XFS_DIFLAG_SYNC)
inode->i_flags &= ~S_APPEND;
if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
inode->i_flags |= S_SYNC; inode->i_flags |= S_SYNC;
else if (flags & XFS_DIFLAG_NOATIME)
inode->i_flags &= ~S_SYNC;
if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
inode->i_flags |= S_NOATIME; inode->i_flags |= S_NOATIME;
else /* XXX: Also needs an on-disk per inode flag! */
inode->i_flags &= ~S_NOATIME; if (ip->i_mount->m_flags & XFS_MOUNT_DAX)
inode->i_flags |= S_DAX;
} }
/* /*
......
...@@ -179,6 +179,8 @@ typedef struct xfs_mount { ...@@ -179,6 +179,8 @@ typedef struct xfs_mount {
allocator */ allocator */
#define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */ #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
#define XFS_MOUNT_DAX (1ULL << 62) /* TEST ONLY! */
/* /*
* Default minimum read and write sizes. * Default minimum read and write sizes.
......
...@@ -112,6 +112,8 @@ static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */ ...@@ -112,6 +112,8 @@ static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
#define MNTOPT_DISCARD "discard" /* Discard unused blocks */ #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
#define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */ #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
#define MNTOPT_DAX "dax" /* Enable direct access to bdev pages */
/* /*
* Table driven mount option parser. * Table driven mount option parser.
* *
...@@ -363,6 +365,10 @@ xfs_parseargs( ...@@ -363,6 +365,10 @@ xfs_parseargs(
mp->m_flags |= XFS_MOUNT_DISCARD; mp->m_flags |= XFS_MOUNT_DISCARD;
} else if (!strcmp(this_char, MNTOPT_NODISCARD)) { } else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
mp->m_flags &= ~XFS_MOUNT_DISCARD; mp->m_flags &= ~XFS_MOUNT_DISCARD;
#ifdef CONFIG_FS_DAX
} else if (!strcmp(this_char, MNTOPT_DAX)) {
mp->m_flags |= XFS_MOUNT_DAX;
#endif
} else { } else {
xfs_warn(mp, "unknown mount option [%s].", this_char); xfs_warn(mp, "unknown mount option [%s].", this_char);
return -EINVAL; return -EINVAL;
...@@ -452,8 +458,8 @@ xfs_parseargs( ...@@ -452,8 +458,8 @@ xfs_parseargs(
} }
struct proc_xfs_info { struct proc_xfs_info {
int flag; uint64_t flag;
char *str; char *str;
}; };
STATIC int STATIC int
...@@ -474,6 +480,7 @@ xfs_showargs( ...@@ -474,6 +480,7 @@ xfs_showargs(
{ XFS_MOUNT_GRPID, "," MNTOPT_GRPID }, { XFS_MOUNT_GRPID, "," MNTOPT_GRPID },
{ XFS_MOUNT_DISCARD, "," MNTOPT_DISCARD }, { XFS_MOUNT_DISCARD, "," MNTOPT_DISCARD },
{ XFS_MOUNT_SMALL_INUMS, "," MNTOPT_32BITINODE }, { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_32BITINODE },
{ XFS_MOUNT_DAX, "," MNTOPT_DAX },
{ 0, NULL } { 0, NULL }
}; };
static struct proc_xfs_info xfs_info_unset[] = { static struct proc_xfs_info xfs_info_unset[] = {
...@@ -1507,6 +1514,20 @@ xfs_fs_fill_super( ...@@ -1507,6 +1514,20 @@ xfs_fs_fill_super(
if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5) if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5)
sb->s_flags |= MS_I_VERSION; sb->s_flags |= MS_I_VERSION;
if (mp->m_flags & XFS_MOUNT_DAX) {
xfs_warn(mp,
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
if (sb->s_blocksize != PAGE_SIZE) {
xfs_alert(mp,
"Filesystem block size invalid for DAX Turning DAX off.");
mp->m_flags &= ~XFS_MOUNT_DAX;
} else if (!sb->s_bdev->bd_disk->fops->direct_access) {
xfs_alert(mp,
"Block device does not support DAX Turning DAX off.");
mp->m_flags &= ~XFS_MOUNT_DAX;
}
}
error = xfs_mountfs(mp); error = xfs_mountfs(mp);
if (error) if (error)
goto out_filestream_unmount; goto out_filestream_unmount;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册