mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
xfs: hoist inode flag conversion functions to libxfs
Hoist the inode flag conversion functions into libxfs so that we can keep them in sync. Do this by creating a new xfs_inode_util.c file in libxfs. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
acdddbe168
commit
b7c477be39
@ -40,6 +40,7 @@ xfs-y += $(addprefix libxfs/, \
|
||||
xfs_iext_tree.o \
|
||||
xfs_inode_fork.o \
|
||||
xfs_inode_buf.o \
|
||||
xfs_inode_util.o \
|
||||
xfs_log_rlimit.o \
|
||||
xfs_ag_resv.o \
|
||||
xfs_parent.o \
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "xfs_health.h"
|
||||
#include "xfs_bmap_item.h"
|
||||
#include "xfs_symlink_remote.h"
|
||||
#include "xfs_inode_util.h"
|
||||
|
||||
struct kmem_cache *xfs_bmap_intent_cache;
|
||||
|
||||
|
124
fs/xfs/libxfs/xfs_inode_util.c
Normal file
124
fs/xfs/libxfs/xfs_inode_util.c
Normal file
@ -0,0 +1,124 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (c) 2000-2006 Silicon Graphics, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
#include "xfs.h"
|
||||
#include "xfs_fs.h"
|
||||
#include "xfs_shared.h"
|
||||
#include "xfs_format.h"
|
||||
#include "xfs_log_format.h"
|
||||
#include "xfs_trans_resv.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_inode_util.h"
|
||||
|
||||
uint16_t
|
||||
xfs_flags2diflags(
|
||||
struct xfs_inode *ip,
|
||||
unsigned int xflags)
|
||||
{
|
||||
/* can't set PREALLOC this way, just preserve it */
|
||||
uint16_t di_flags =
|
||||
(ip->i_diflags & XFS_DIFLAG_PREALLOC);
|
||||
|
||||
if (xflags & FS_XFLAG_IMMUTABLE)
|
||||
di_flags |= XFS_DIFLAG_IMMUTABLE;
|
||||
if (xflags & FS_XFLAG_APPEND)
|
||||
di_flags |= XFS_DIFLAG_APPEND;
|
||||
if (xflags & FS_XFLAG_SYNC)
|
||||
di_flags |= XFS_DIFLAG_SYNC;
|
||||
if (xflags & FS_XFLAG_NOATIME)
|
||||
di_flags |= XFS_DIFLAG_NOATIME;
|
||||
if (xflags & FS_XFLAG_NODUMP)
|
||||
di_flags |= XFS_DIFLAG_NODUMP;
|
||||
if (xflags & FS_XFLAG_NODEFRAG)
|
||||
di_flags |= XFS_DIFLAG_NODEFRAG;
|
||||
if (xflags & FS_XFLAG_FILESTREAM)
|
||||
di_flags |= XFS_DIFLAG_FILESTREAM;
|
||||
if (S_ISDIR(VFS_I(ip)->i_mode)) {
|
||||
if (xflags & FS_XFLAG_RTINHERIT)
|
||||
di_flags |= XFS_DIFLAG_RTINHERIT;
|
||||
if (xflags & FS_XFLAG_NOSYMLINKS)
|
||||
di_flags |= XFS_DIFLAG_NOSYMLINKS;
|
||||
if (xflags & FS_XFLAG_EXTSZINHERIT)
|
||||
di_flags |= XFS_DIFLAG_EXTSZINHERIT;
|
||||
if (xflags & FS_XFLAG_PROJINHERIT)
|
||||
di_flags |= XFS_DIFLAG_PROJINHERIT;
|
||||
} else if (S_ISREG(VFS_I(ip)->i_mode)) {
|
||||
if (xflags & FS_XFLAG_REALTIME)
|
||||
di_flags |= XFS_DIFLAG_REALTIME;
|
||||
if (xflags & FS_XFLAG_EXTSIZE)
|
||||
di_flags |= XFS_DIFLAG_EXTSIZE;
|
||||
}
|
||||
|
||||
return di_flags;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
xfs_flags2diflags2(
|
||||
struct xfs_inode *ip,
|
||||
unsigned int xflags)
|
||||
{
|
||||
uint64_t di_flags2 =
|
||||
(ip->i_diflags2 & (XFS_DIFLAG2_REFLINK |
|
||||
XFS_DIFLAG2_BIGTIME |
|
||||
XFS_DIFLAG2_NREXT64));
|
||||
|
||||
if (xflags & FS_XFLAG_DAX)
|
||||
di_flags2 |= XFS_DIFLAG2_DAX;
|
||||
if (xflags & FS_XFLAG_COWEXTSIZE)
|
||||
di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
|
||||
|
||||
return di_flags2;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
xfs_ip2xflags(
|
||||
struct xfs_inode *ip)
|
||||
{
|
||||
uint32_t flags = 0;
|
||||
|
||||
if (ip->i_diflags & XFS_DIFLAG_ANY) {
|
||||
if (ip->i_diflags & XFS_DIFLAG_REALTIME)
|
||||
flags |= FS_XFLAG_REALTIME;
|
||||
if (ip->i_diflags & XFS_DIFLAG_PREALLOC)
|
||||
flags |= FS_XFLAG_PREALLOC;
|
||||
if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE)
|
||||
flags |= FS_XFLAG_IMMUTABLE;
|
||||
if (ip->i_diflags & XFS_DIFLAG_APPEND)
|
||||
flags |= FS_XFLAG_APPEND;
|
||||
if (ip->i_diflags & XFS_DIFLAG_SYNC)
|
||||
flags |= FS_XFLAG_SYNC;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NOATIME)
|
||||
flags |= FS_XFLAG_NOATIME;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NODUMP)
|
||||
flags |= FS_XFLAG_NODUMP;
|
||||
if (ip->i_diflags & XFS_DIFLAG_RTINHERIT)
|
||||
flags |= FS_XFLAG_RTINHERIT;
|
||||
if (ip->i_diflags & XFS_DIFLAG_PROJINHERIT)
|
||||
flags |= FS_XFLAG_PROJINHERIT;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NOSYMLINKS)
|
||||
flags |= FS_XFLAG_NOSYMLINKS;
|
||||
if (ip->i_diflags & XFS_DIFLAG_EXTSIZE)
|
||||
flags |= FS_XFLAG_EXTSIZE;
|
||||
if (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT)
|
||||
flags |= FS_XFLAG_EXTSZINHERIT;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NODEFRAG)
|
||||
flags |= FS_XFLAG_NODEFRAG;
|
||||
if (ip->i_diflags & XFS_DIFLAG_FILESTREAM)
|
||||
flags |= FS_XFLAG_FILESTREAM;
|
||||
}
|
||||
|
||||
if (ip->i_diflags2 & XFS_DIFLAG2_ANY) {
|
||||
if (ip->i_diflags2 & XFS_DIFLAG2_DAX)
|
||||
flags |= FS_XFLAG_DAX;
|
||||
if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
|
||||
flags |= FS_XFLAG_COWEXTSIZE;
|
||||
}
|
||||
|
||||
if (xfs_inode_has_attr_fork(ip))
|
||||
flags |= FS_XFLAG_HASATTR;
|
||||
return flags;
|
||||
}
|
14
fs/xfs/libxfs/xfs_inode_util.h
Normal file
14
fs/xfs/libxfs/xfs_inode_util.h
Normal file
@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
#ifndef __XFS_INODE_UTIL_H__
|
||||
#define __XFS_INODE_UTIL_H__
|
||||
|
||||
uint16_t xfs_flags2diflags(struct xfs_inode *ip, unsigned int xflags);
|
||||
uint64_t xfs_flags2diflags2(struct xfs_inode *ip, unsigned int xflags);
|
||||
uint32_t xfs_dic2xflags(struct xfs_inode *ip);
|
||||
uint32_t xfs_ip2xflags(struct xfs_inode *ip);
|
||||
|
||||
#endif /* __XFS_INODE_UTIL_H__ */
|
@ -523,55 +523,6 @@ xfs_lock_two_inodes(
|
||||
}
|
||||
}
|
||||
|
||||
uint
|
||||
xfs_ip2xflags(
|
||||
struct xfs_inode *ip)
|
||||
{
|
||||
uint flags = 0;
|
||||
|
||||
if (ip->i_diflags & XFS_DIFLAG_ANY) {
|
||||
if (ip->i_diflags & XFS_DIFLAG_REALTIME)
|
||||
flags |= FS_XFLAG_REALTIME;
|
||||
if (ip->i_diflags & XFS_DIFLAG_PREALLOC)
|
||||
flags |= FS_XFLAG_PREALLOC;
|
||||
if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE)
|
||||
flags |= FS_XFLAG_IMMUTABLE;
|
||||
if (ip->i_diflags & XFS_DIFLAG_APPEND)
|
||||
flags |= FS_XFLAG_APPEND;
|
||||
if (ip->i_diflags & XFS_DIFLAG_SYNC)
|
||||
flags |= FS_XFLAG_SYNC;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NOATIME)
|
||||
flags |= FS_XFLAG_NOATIME;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NODUMP)
|
||||
flags |= FS_XFLAG_NODUMP;
|
||||
if (ip->i_diflags & XFS_DIFLAG_RTINHERIT)
|
||||
flags |= FS_XFLAG_RTINHERIT;
|
||||
if (ip->i_diflags & XFS_DIFLAG_PROJINHERIT)
|
||||
flags |= FS_XFLAG_PROJINHERIT;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NOSYMLINKS)
|
||||
flags |= FS_XFLAG_NOSYMLINKS;
|
||||
if (ip->i_diflags & XFS_DIFLAG_EXTSIZE)
|
||||
flags |= FS_XFLAG_EXTSIZE;
|
||||
if (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT)
|
||||
flags |= FS_XFLAG_EXTSZINHERIT;
|
||||
if (ip->i_diflags & XFS_DIFLAG_NODEFRAG)
|
||||
flags |= FS_XFLAG_NODEFRAG;
|
||||
if (ip->i_diflags & XFS_DIFLAG_FILESTREAM)
|
||||
flags |= FS_XFLAG_FILESTREAM;
|
||||
}
|
||||
|
||||
if (ip->i_diflags2 & XFS_DIFLAG2_ANY) {
|
||||
if (ip->i_diflags2 & XFS_DIFLAG2_DAX)
|
||||
flags |= FS_XFLAG_DAX;
|
||||
if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
|
||||
flags |= FS_XFLAG_COWEXTSIZE;
|
||||
}
|
||||
|
||||
if (xfs_inode_has_attr_fork(ip))
|
||||
flags |= FS_XFLAG_HASATTR;
|
||||
return flags;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookups up an inode from "name". If ci_name is not NULL, then a CI match
|
||||
* is allowed, otherwise it has to be an exact match. If a CI match is found,
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "xfs_inode_buf.h"
|
||||
#include "xfs_inode_fork.h"
|
||||
#include "xfs_inode_util.h"
|
||||
|
||||
/*
|
||||
* Kernel only inode definitions
|
||||
@ -549,7 +550,6 @@ void xfs_assert_ilocked(struct xfs_inode *, uint);
|
||||
uint xfs_ilock_data_map_shared(struct xfs_inode *);
|
||||
uint xfs_ilock_attr_map_shared(struct xfs_inode *);
|
||||
|
||||
uint xfs_ip2xflags(struct xfs_inode *);
|
||||
int xfs_ifree(struct xfs_trans *, struct xfs_inode *);
|
||||
int xfs_itruncate_extents_flags(struct xfs_trans **,
|
||||
struct xfs_inode *, int, xfs_fsize_t, int);
|
||||
|
@ -469,66 +469,6 @@ xfs_fileattr_get(
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC uint16_t
|
||||
xfs_flags2diflags(
|
||||
struct xfs_inode *ip,
|
||||
unsigned int xflags)
|
||||
{
|
||||
/* can't set PREALLOC this way, just preserve it */
|
||||
uint16_t di_flags =
|
||||
(ip->i_diflags & XFS_DIFLAG_PREALLOC);
|
||||
|
||||
if (xflags & FS_XFLAG_IMMUTABLE)
|
||||
di_flags |= XFS_DIFLAG_IMMUTABLE;
|
||||
if (xflags & FS_XFLAG_APPEND)
|
||||
di_flags |= XFS_DIFLAG_APPEND;
|
||||
if (xflags & FS_XFLAG_SYNC)
|
||||
di_flags |= XFS_DIFLAG_SYNC;
|
||||
if (xflags & FS_XFLAG_NOATIME)
|
||||
di_flags |= XFS_DIFLAG_NOATIME;
|
||||
if (xflags & FS_XFLAG_NODUMP)
|
||||
di_flags |= XFS_DIFLAG_NODUMP;
|
||||
if (xflags & FS_XFLAG_NODEFRAG)
|
||||
di_flags |= XFS_DIFLAG_NODEFRAG;
|
||||
if (xflags & FS_XFLAG_FILESTREAM)
|
||||
di_flags |= XFS_DIFLAG_FILESTREAM;
|
||||
if (S_ISDIR(VFS_I(ip)->i_mode)) {
|
||||
if (xflags & FS_XFLAG_RTINHERIT)
|
||||
di_flags |= XFS_DIFLAG_RTINHERIT;
|
||||
if (xflags & FS_XFLAG_NOSYMLINKS)
|
||||
di_flags |= XFS_DIFLAG_NOSYMLINKS;
|
||||
if (xflags & FS_XFLAG_EXTSZINHERIT)
|
||||
di_flags |= XFS_DIFLAG_EXTSZINHERIT;
|
||||
if (xflags & FS_XFLAG_PROJINHERIT)
|
||||
di_flags |= XFS_DIFLAG_PROJINHERIT;
|
||||
} else if (S_ISREG(VFS_I(ip)->i_mode)) {
|
||||
if (xflags & FS_XFLAG_REALTIME)
|
||||
di_flags |= XFS_DIFLAG_REALTIME;
|
||||
if (xflags & FS_XFLAG_EXTSIZE)
|
||||
di_flags |= XFS_DIFLAG_EXTSIZE;
|
||||
}
|
||||
|
||||
return di_flags;
|
||||
}
|
||||
|
||||
STATIC uint64_t
|
||||
xfs_flags2diflags2(
|
||||
struct xfs_inode *ip,
|
||||
unsigned int xflags)
|
||||
{
|
||||
uint64_t di_flags2 =
|
||||
(ip->i_diflags2 & (XFS_DIFLAG2_REFLINK |
|
||||
XFS_DIFLAG2_BIGTIME |
|
||||
XFS_DIFLAG2_NREXT64));
|
||||
|
||||
if (xflags & FS_XFLAG_DAX)
|
||||
di_flags2 |= XFS_DIFLAG2_DAX;
|
||||
if (xflags & FS_XFLAG_COWEXTSIZE)
|
||||
di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
|
||||
|
||||
return di_flags2;
|
||||
}
|
||||
|
||||
static int
|
||||
xfs_ioctl_setattr_xflags(
|
||||
struct xfs_trans *tp,
|
||||
|
Loading…
Reference in New Issue
Block a user