Commit 66f36464 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: remove if_rdev

We can simply use the i_rdev field in the Linux inode and just convert
to and from the XFS dev_t when reading or logging/writing the inode.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 42b67dc6
...@@ -42,21 +42,27 @@ STATIC int xfs_iformat_local(xfs_inode_t *, xfs_dinode_t *, int, int); ...@@ -42,21 +42,27 @@ STATIC int xfs_iformat_local(xfs_inode_t *, xfs_dinode_t *, int, int);
STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int);
STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int);
static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev)
{
return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev));
}
/* /*
* Move inode type and inode format specific information from the * Copy inode type and data and attr format specific information from the
* on-disk inode to the in-core inode. For fifos, devs, and sockets * on-disk inode to the in-core inode and fork structures. For fifos, devices,
* this means set if_rdev to the proper value. For files, directories, * and sockets this means set i_rdev to the proper value. For files,
* and symlinks this means to bring in the in-line data or extent * directories, and symlinks this means to bring in the in-line data or extent
* pointers. For a file in B-tree format, only the root is immediately * pointers as well as the attribute fork. For a fork in B-tree format, only
* brought in-core. The rest will be in-lined in if_extents when it * the root is immediately brought in-core. The rest will be read in later when
* is first referenced (see xfs_iread_extents()). * first referenced (see xfs_iread_extents()).
*/ */
int int
xfs_iformat_fork( xfs_iformat_fork(
xfs_inode_t *ip, struct xfs_inode *ip,
xfs_dinode_t *dip) struct xfs_dinode *dip)
{ {
xfs_attr_shortform_t *atp; struct inode *inode = VFS_I(ip);
struct xfs_attr_shortform *atp;
int size; int size;
int error = 0; int error = 0;
xfs_fsize_t di_size; xfs_fsize_t di_size;
...@@ -95,8 +101,7 @@ xfs_iformat_fork( ...@@ -95,8 +101,7 @@ xfs_iformat_fork(
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
if (unlikely(xfs_is_reflink_inode(ip) && if (unlikely(xfs_is_reflink_inode(ip) && !S_ISREG(inode->i_mode))) {
(VFS_I(ip)->i_mode & S_IFMT) != S_IFREG)) {
xfs_warn(ip->i_mount, xfs_warn(ip->i_mount,
"corrupt dinode %llu, wrong file type for reflink.", "corrupt dinode %llu, wrong file type for reflink.",
ip->i_ino); ip->i_ino);
...@@ -115,7 +120,7 @@ xfs_iformat_fork( ...@@ -115,7 +120,7 @@ xfs_iformat_fork(
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
switch (VFS_I(ip)->i_mode & S_IFMT) { switch (inode->i_mode & S_IFMT) {
case S_IFIFO: case S_IFIFO:
case S_IFCHR: case S_IFCHR:
case S_IFBLK: case S_IFBLK:
...@@ -126,7 +131,7 @@ xfs_iformat_fork( ...@@ -126,7 +131,7 @@ xfs_iformat_fork(
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
ip->i_d.di_size = 0; ip->i_d.di_size = 0;
ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip); inode->i_rdev = xfs_to_linux_dev_t(xfs_dinode_get_rdev(dip));
break; break;
case S_IFREG: case S_IFREG:
...@@ -184,8 +189,7 @@ xfs_iformat_fork( ...@@ -184,8 +189,7 @@ xfs_iformat_fork(
return error; return error;
/* Check inline dir contents. */ /* Check inline dir contents. */
if (S_ISDIR(VFS_I(ip)->i_mode) && if (S_ISDIR(inode->i_mode) && dip->di_format == XFS_DINODE_FMT_LOCAL) {
dip->di_format == XFS_DINODE_FMT_LOCAL) {
error = xfs_dir2_sf_verify(ip); error = xfs_dir2_sf_verify(ip);
if (error) { if (error) {
xfs_idestroy_fork(ip, XFS_DATA_FORK); xfs_idestroy_fork(ip, XFS_DATA_FORK);
...@@ -898,7 +902,7 @@ xfs_iflush_fork( ...@@ -898,7 +902,7 @@ xfs_iflush_fork(
case XFS_DINODE_FMT_DEV: case XFS_DINODE_FMT_DEV:
if (iip->ili_fields & XFS_ILOG_DEV) { if (iip->ili_fields & XFS_ILOG_DEV) {
ASSERT(whichfork == XFS_DATA_FORK); ASSERT(whichfork == XFS_DATA_FORK);
xfs_dinode_put_rdev(dip, ip->i_df.if_u2.if_rdev); xfs_dinode_put_rdev(dip, sysv_encode_dev(VFS_I(ip)->i_rdev));
} }
break; break;
......
...@@ -69,7 +69,6 @@ typedef struct xfs_ifork { ...@@ -69,7 +69,6 @@ typedef struct xfs_ifork {
/* very small file extents */ /* very small file extents */
char if_inline_data[XFS_INLINE_DATA]; char if_inline_data[XFS_INLINE_DATA];
/* very small file data */ /* very small file data */
xfs_dev_t if_rdev; /* dev number if special */
} if_u2; } if_u2;
} xfs_ifork_t; } xfs_ifork_t;
......
...@@ -767,7 +767,7 @@ xfs_ialloc( ...@@ -767,7 +767,7 @@ xfs_ialloc(
xfs_inode_t *pip, xfs_inode_t *pip,
umode_t mode, umode_t mode,
xfs_nlink_t nlink, xfs_nlink_t nlink,
xfs_dev_t rdev, dev_t rdev,
prid_t prid, prid_t prid,
int okalloc, int okalloc,
xfs_buf_t **ialloc_context, xfs_buf_t **ialloc_context,
...@@ -819,6 +819,7 @@ xfs_ialloc( ...@@ -819,6 +819,7 @@ xfs_ialloc(
set_nlink(inode, nlink); set_nlink(inode, nlink);
ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid()); ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid());
ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid()); ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid());
inode->i_rdev = rdev;
xfs_set_projid(ip, prid); xfs_set_projid(ip, prid);
if (pip && XFS_INHERIT_GID(pip)) { if (pip && XFS_INHERIT_GID(pip)) {
...@@ -867,7 +868,6 @@ xfs_ialloc( ...@@ -867,7 +868,6 @@ xfs_ialloc(
case S_IFBLK: case S_IFBLK:
case S_IFSOCK: case S_IFSOCK:
ip->i_d.di_format = XFS_DINODE_FMT_DEV; ip->i_d.di_format = XFS_DINODE_FMT_DEV;
ip->i_df.if_u2.if_rdev = rdev;
ip->i_df.if_flags = 0; ip->i_df.if_flags = 0;
flags |= XFS_ILOG_DEV; flags |= XFS_ILOG_DEV;
break; break;
...@@ -975,7 +975,7 @@ xfs_dir_ialloc( ...@@ -975,7 +975,7 @@ xfs_dir_ialloc(
the inode. */ the inode. */
umode_t mode, umode_t mode,
xfs_nlink_t nlink, xfs_nlink_t nlink,
xfs_dev_t rdev, dev_t rdev,
prid_t prid, /* project id */ prid_t prid, /* project id */
int okalloc, /* ok to allocate new space */ int okalloc, /* ok to allocate new space */
xfs_inode_t **ipp, /* pointer to inode; it will be xfs_inode_t **ipp, /* pointer to inode; it will be
...@@ -1147,7 +1147,7 @@ xfs_create( ...@@ -1147,7 +1147,7 @@ xfs_create(
xfs_inode_t *dp, xfs_inode_t *dp,
struct xfs_name *name, struct xfs_name *name,
umode_t mode, umode_t mode,
xfs_dev_t rdev, dev_t rdev,
xfs_inode_t **ipp) xfs_inode_t **ipp)
{ {
int is_dir = S_ISDIR(mode); int is_dir = S_ISDIR(mode);
...@@ -1183,7 +1183,6 @@ xfs_create( ...@@ -1183,7 +1183,6 @@ xfs_create(
return error; return error;
if (is_dir) { if (is_dir) {
rdev = 0;
resblks = XFS_MKDIR_SPACE_RES(mp, name->len); resblks = XFS_MKDIR_SPACE_RES(mp, name->len);
tres = &M_RES(mp)->tr_mkdir; tres = &M_RES(mp)->tr_mkdir;
} else { } else {
......
...@@ -391,7 +391,7 @@ void xfs_inactive(struct xfs_inode *ip); ...@@ -391,7 +391,7 @@ void xfs_inactive(struct xfs_inode *ip);
int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,
struct xfs_inode **ipp, struct xfs_name *ci_name); struct xfs_inode **ipp, struct xfs_name *ci_name);
int xfs_create(struct xfs_inode *dp, struct xfs_name *name, int xfs_create(struct xfs_inode *dp, struct xfs_name *name,
umode_t mode, xfs_dev_t rdev, struct xfs_inode **ipp); umode_t mode, dev_t rdev, struct xfs_inode **ipp);
int xfs_create_tmpfile(struct xfs_inode *dp, struct dentry *dentry, int xfs_create_tmpfile(struct xfs_inode *dp, struct dentry *dentry,
umode_t mode, struct xfs_inode **ipp); umode_t mode, struct xfs_inode **ipp);
int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
...@@ -428,7 +428,7 @@ xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip); ...@@ -428,7 +428,7 @@ xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip);
xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip); xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip);
int xfs_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t, int xfs_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t,
xfs_nlink_t, xfs_dev_t, prid_t, int, xfs_nlink_t, dev_t, prid_t, int,
struct xfs_inode **, int *); struct xfs_inode **, int *);
/* from xfs_file.c */ /* from xfs_file.c */
......
...@@ -222,7 +222,7 @@ xfs_inode_item_format_data_fork( ...@@ -222,7 +222,7 @@ xfs_inode_item_format_data_fork(
iip->ili_fields &= iip->ili_fields &=
~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT | XFS_ILOG_DEXT); ~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT | XFS_ILOG_DEXT);
if (iip->ili_fields & XFS_ILOG_DEV) if (iip->ili_fields & XFS_ILOG_DEV)
ilf->ilf_u.ilfu_rdev = ip->i_df.if_u2.if_rdev; ilf->ilf_u.ilfu_rdev = sysv_encode_dev(VFS_I(ip)->i_rdev);
break; break;
default: default:
ASSERT(0); ASSERT(0);
......
...@@ -160,7 +160,6 @@ xfs_generic_create( ...@@ -160,7 +160,6 @@ xfs_generic_create(
if (S_ISCHR(mode) || S_ISBLK(mode)) { if (S_ISCHR(mode) || S_ISBLK(mode)) {
if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
return -EINVAL; return -EINVAL;
rdev = sysv_encode_dev(rdev);
} else { } else {
rdev = 0; rdev = 0;
} }
...@@ -535,8 +534,7 @@ xfs_vn_getattr( ...@@ -535,8 +534,7 @@ xfs_vn_getattr(
case S_IFBLK: case S_IFBLK:
case S_IFCHR: case S_IFCHR:
stat->blksize = BLKDEV_IOSIZE; stat->blksize = BLKDEV_IOSIZE;
stat->rdev = MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff, stat->rdev = inode->i_rdev;
sysv_minor(ip->i_df.if_u2.if_rdev));
break; break;
default: default:
if (XFS_IS_REALTIME_INODE(ip)) { if (XFS_IS_REALTIME_INODE(ip)) {
...@@ -1231,18 +1229,6 @@ xfs_setup_inode( ...@@ -1231,18 +1229,6 @@ xfs_setup_inode(
inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid); inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid);
inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid); inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid);
switch (inode->i_mode & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
inode->i_rdev =
MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
sysv_minor(ip->i_df.if_u2.if_rdev));
break;
default:
inode->i_rdev = 0;
break;
}
i_size_write(inode, ip->i_d.di_size); i_size_write(inode, ip->i_d.di_size);
xfs_diflags_to_iflags(inode, ip); xfs_diflags_to_iflags(inode, ip);
......
...@@ -109,7 +109,7 @@ xfs_bulkstat_one_int( ...@@ -109,7 +109,7 @@ xfs_bulkstat_one_int(
switch (dic->di_format) { switch (dic->di_format) {
case XFS_DINODE_FMT_DEV: case XFS_DINODE_FMT_DEV:
buf->bs_rdev = ip->i_df.if_u2.if_rdev; buf->bs_rdev = sysv_encode_dev(inode->i_rdev);
buf->bs_blksize = BLKDEV_IOSIZE; buf->bs_blksize = BLKDEV_IOSIZE;
buf->bs_blocks = 0; buf->bs_blocks = 0;
break; break;
......
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