Commit 34187d9e authored by Nathan Scott's avatar Nathan Scott

[XFS] Make uses of extended inode flags consistent, remove duplicated code.

SGI Modid: xfs-linux:xfs-kern:171450a
parent 8f299acd
...@@ -1049,6 +1049,25 @@ xfs_merge_ioc_xflags( ...@@ -1049,6 +1049,25 @@ xfs_merge_ioc_xflags(
return xflags; return xflags;
} }
STATIC unsigned int
xfs_di2lxflags(
__uint16_t di_flags)
{
unsigned int flags = 0;
if (di_flags & XFS_DIFLAG_IMMUTABLE)
flags |= LINUX_XFLAG_IMMUTABLE;
if (di_flags & XFS_DIFLAG_APPEND)
flags |= LINUX_XFLAG_APPEND;
if (di_flags & XFS_DIFLAG_SYNC)
flags |= LINUX_XFLAG_SYNC;
if (di_flags & XFS_DIFLAG_NOATIME)
flags |= LINUX_XFLAG_NOATIME;
if (di_flags & XFS_DIFLAG_NODUMP)
flags |= LINUX_XFLAG_NODUMP;
return flags;
}
STATIC int STATIC int
xfs_ioc_xattr( xfs_ioc_xattr(
vnode_t *vp, vnode_t *vp,
...@@ -1113,17 +1132,7 @@ xfs_ioc_xattr( ...@@ -1113,17 +1132,7 @@ xfs_ioc_xattr(
} }
case XFS_IOC_GETXFLAGS: { case XFS_IOC_GETXFLAGS: {
flags = 0; flags = xfs_di2lxflags(ip->i_d.di_flags);
if (ip->i_d.di_flags & XFS_XFLAG_IMMUTABLE)
flags |= LINUX_XFLAG_IMMUTABLE;
if (ip->i_d.di_flags & XFS_XFLAG_APPEND)
flags |= LINUX_XFLAG_APPEND;
if (ip->i_d.di_flags & XFS_XFLAG_SYNC)
flags |= LINUX_XFLAG_SYNC;
if (ip->i_d.di_flags & XFS_XFLAG_NOATIME)
flags |= LINUX_XFLAG_NOATIME;
if (ip->i_d.di_flags & XFS_XFLAG_NODUMP)
flags |= LINUX_XFLAG_NODUMP;
if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags))) if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags)))
return -XFS_ERROR(EFAULT); return -XFS_ERROR(EFAULT);
return 0; return 0;
...@@ -1143,7 +1152,8 @@ xfs_ioc_xattr( ...@@ -1143,7 +1152,8 @@ xfs_ioc_xattr(
attr_flags |= ATTR_NONBLOCK; attr_flags |= ATTR_NONBLOCK;
va.va_mask = XFS_AT_XFLAGS; va.va_mask = XFS_AT_XFLAGS;
va.va_xflags = xfs_merge_ioc_xflags(flags, ip->i_d.di_flags); va.va_xflags = xfs_merge_ioc_xflags(flags,
xfs_dic2xflags(&ip->i_d, ARCH_NOCONVERT));
VOP_SETATTR(vp, &va, attr_flags, NULL, error); VOP_SETATTR(vp, &va, attr_flags, NULL, error);
if (!error) if (!error)
......
...@@ -854,6 +854,34 @@ xfs_xlate_dinode_core( ...@@ -854,6 +854,34 @@ xfs_xlate_dinode_core(
INT_XLATE(buf_core->di_gen, mem_core->di_gen, dir, arch); INT_XLATE(buf_core->di_gen, mem_core->di_gen, dir, arch);
} }
uint
xfs_dic2xflags(
xfs_dinode_core_t *dic,
xfs_arch_t arch)
{
__uint16_t di_flags;
uint flags = 0;
di_flags = INT_GET(dic->di_flags, arch);
if (di_flags & XFS_DIFLAG_REALTIME)
flags |= XFS_XFLAG_REALTIME;
if (di_flags & XFS_DIFLAG_PREALLOC)
flags |= XFS_XFLAG_PREALLOC;
if (di_flags & XFS_DIFLAG_IMMUTABLE)
flags |= XFS_XFLAG_IMMUTABLE;
if (di_flags & XFS_DIFLAG_APPEND)
flags |= XFS_XFLAG_APPEND;
if (di_flags & XFS_DIFLAG_SYNC)
flags |= XFS_XFLAG_SYNC;
if (di_flags & XFS_DIFLAG_NOATIME)
flags |= XFS_XFLAG_NOATIME;
if (di_flags & XFS_DIFLAG_NODUMP)
flags |= XFS_XFLAG_NODUMP;
if (XFS_CFORK_Q_ARCH(dic, arch))
flags |= XFS_XFLAG_HASATTR;
return flags;
}
/* /*
* Given a mount structure and an inode number, return a pointer * Given a mount structure and an inode number, return a pointer
* to a newly allocated in-core inode coresponding to the given * to a newly allocated in-core inode coresponding to the given
......
...@@ -503,8 +503,9 @@ int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); ...@@ -503,8 +503,9 @@ int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, nlink_t, int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, nlink_t,
xfs_dev_t, struct cred *, xfs_prid_t, int, xfs_dev_t, struct cred *, xfs_prid_t, int,
struct xfs_buf **, boolean_t *, xfs_inode_t **); struct xfs_buf **, boolean_t *, xfs_inode_t **);
void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, int, void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *,
xfs_arch_t); int, xfs_arch_t);
uint xfs_dic2xflags(struct xfs_dinode_core *, xfs_arch_t);
int xfs_ifree(struct xfs_trans *, xfs_inode_t *, int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
struct xfs_bmap_free *); struct xfs_bmap_free *);
int xfs_atruncate_start(xfs_inode_t *); int xfs_atruncate_start(xfs_inode_t *);
......
...@@ -82,7 +82,6 @@ xfs_bulkstat_one( ...@@ -82,7 +82,6 @@ xfs_bulkstat_one(
xfs_dinode_core_t *dic; /* dinode core info pointer */ xfs_dinode_core_t *dic; /* dinode core info pointer */
xfs_inode_t *ip = NULL; /* incore inode pointer */ xfs_inode_t *ip = NULL; /* incore inode pointer */
xfs_arch_t arch; /* these are set according to */ xfs_arch_t arch; /* these are set according to */
__uint16_t di_flags; /* temp */
dip = (xfs_dinode_t *)dibuff; dip = (xfs_dinode_t *)dibuff;
...@@ -166,29 +165,7 @@ xfs_bulkstat_one( ...@@ -166,29 +165,7 @@ xfs_bulkstat_one(
buf->bs_mtime.tv_nsec = INT_GET(dic->di_mtime.t_nsec, arch); buf->bs_mtime.tv_nsec = INT_GET(dic->di_mtime.t_nsec, arch);
buf->bs_ctime.tv_sec = INT_GET(dic->di_ctime.t_sec, arch); buf->bs_ctime.tv_sec = INT_GET(dic->di_ctime.t_sec, arch);
buf->bs_ctime.tv_nsec = INT_GET(dic->di_ctime.t_nsec, arch); buf->bs_ctime.tv_nsec = INT_GET(dic->di_ctime.t_nsec, arch);
/* buf->bs_xflags = xfs_dic2xflags(dic, arch);
* convert di_flags to bs_xflags.
*/
di_flags = INT_GET(dic->di_flags, arch);
buf->bs_xflags =
((di_flags & XFS_DIFLAG_REALTIME) ?
XFS_XFLAG_REALTIME : 0) |
((di_flags & XFS_DIFLAG_PREALLOC) ?
XFS_XFLAG_PREALLOC : 0) |
((di_flags & XFS_DIFLAG_IMMUTABLE) ?
XFS_XFLAG_IMMUTABLE : 0) |
((di_flags & XFS_DIFLAG_APPEND) ?
XFS_XFLAG_APPEND : 0) |
((di_flags & XFS_DIFLAG_SYNC) ?
XFS_XFLAG_SYNC : 0) |
((di_flags & XFS_DIFLAG_NOATIME) ?
XFS_XFLAG_NOATIME : 0) |
((di_flags & XFS_DIFLAG_NODUMP) ?
XFS_XFLAG_NODUMP : 0) |
(XFS_CFORK_Q_ARCH(dic, arch) ?
XFS_XFLAG_HASATTR : 0);
buf->bs_extsize = INT_GET(dic->di_extsize, arch) << mp->m_sb.sb_blocklog; buf->bs_extsize = INT_GET(dic->di_extsize, arch) << mp->m_sb.sb_blocklog;
buf->bs_extents = INT_GET(dic->di_nextents, arch); buf->bs_extents = INT_GET(dic->di_nextents, arch);
buf->bs_gen = INT_GET(dic->di_gen, arch); buf->bs_gen = INT_GET(dic->di_gen, arch);
......
...@@ -246,25 +246,10 @@ xfs_getattr( ...@@ -246,25 +246,10 @@ xfs_getattr(
goto all_done; goto all_done;
/* /*
* convert di_flags to xflags * Convert di_flags to xflags.
*/ */
vap->va_xflags = 0; vap->va_xflags = xfs_dic2xflags(&ip->i_d, ARCH_NOCONVERT);
if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
vap->va_xflags |= XFS_XFLAG_REALTIME;
if (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC)
vap->va_xflags |= XFS_XFLAG_PREALLOC;
if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
vap->va_xflags |= XFS_XFLAG_IMMUTABLE;
if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
vap->va_xflags |= XFS_XFLAG_APPEND;
if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
vap->va_xflags |= XFS_XFLAG_SYNC;
if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
vap->va_xflags |= XFS_XFLAG_NOATIME;
if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
vap->va_xflags |= XFS_XFLAG_NODUMP;
if (XFS_IFORK_Q(ip))
vap->va_xflags |= XFS_XFLAG_HASATTR;
/* /*
* Exit for inode revalidate. See if any of the rest of * Exit for inode revalidate. See if any of the rest of
* the fields to be filled in are needed. * the fields to be filled in are needed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment