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: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
Родитель
42b67dc6ff
Коммит
66f364649d
|
@ -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_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
|
||||
* on-disk inode to the in-core inode. For fifos, devs, and sockets
|
||||
* this means set if_rdev to the proper value. For files, 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
|
||||
* brought in-core. The rest will be in-lined in if_extents when it
|
||||
* is first referenced (see xfs_iread_extents()).
|
||||
* Copy inode type and data and attr format specific information from the
|
||||
* on-disk inode to the in-core inode and fork structures. For fifos, devices,
|
||||
* and sockets this means set i_rdev to the proper value. For files,
|
||||
* directories, and symlinks this means to bring in the in-line data or extent
|
||||
* pointers as well as the attribute fork. For a fork in B-tree format, only
|
||||
* the root is immediately brought in-core. The rest will be read in later when
|
||||
* first referenced (see xfs_iread_extents()).
|
||||
*/
|
||||
int
|
||||
xfs_iformat_fork(
|
||||
xfs_inode_t *ip,
|
||||
xfs_dinode_t *dip)
|
||||
struct xfs_inode *ip,
|
||||
struct xfs_dinode *dip)
|
||||
{
|
||||
xfs_attr_shortform_t *atp;
|
||||
struct inode *inode = VFS_I(ip);
|
||||
struct xfs_attr_shortform *atp;
|
||||
int size;
|
||||
int error = 0;
|
||||
xfs_fsize_t di_size;
|
||||
|
@ -95,8 +101,7 @@ xfs_iformat_fork(
|
|||
return -EFSCORRUPTED;
|
||||
}
|
||||
|
||||
if (unlikely(xfs_is_reflink_inode(ip) &&
|
||||
(VFS_I(ip)->i_mode & S_IFMT) != S_IFREG)) {
|
||||
if (unlikely(xfs_is_reflink_inode(ip) && !S_ISREG(inode->i_mode))) {
|
||||
xfs_warn(ip->i_mount,
|
||||
"corrupt dinode %llu, wrong file type for reflink.",
|
||||
ip->i_ino);
|
||||
|
@ -115,7 +120,7 @@ xfs_iformat_fork(
|
|||
return -EFSCORRUPTED;
|
||||
}
|
||||
|
||||
switch (VFS_I(ip)->i_mode & S_IFMT) {
|
||||
switch (inode->i_mode & S_IFMT) {
|
||||
case S_IFIFO:
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
|
@ -126,7 +131,7 @@ xfs_iformat_fork(
|
|||
return -EFSCORRUPTED;
|
||||
}
|
||||
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;
|
||||
|
||||
case S_IFREG:
|
||||
|
@ -184,8 +189,7 @@ xfs_iformat_fork(
|
|||
return error;
|
||||
|
||||
/* Check inline dir contents. */
|
||||
if (S_ISDIR(VFS_I(ip)->i_mode) &&
|
||||
dip->di_format == XFS_DINODE_FMT_LOCAL) {
|
||||
if (S_ISDIR(inode->i_mode) && dip->di_format == XFS_DINODE_FMT_LOCAL) {
|
||||
error = xfs_dir2_sf_verify(ip);
|
||||
if (error) {
|
||||
xfs_idestroy_fork(ip, XFS_DATA_FORK);
|
||||
|
@ -898,7 +902,7 @@ xfs_iflush_fork(
|
|||
case XFS_DINODE_FMT_DEV:
|
||||
if (iip->ili_fields & XFS_ILOG_DEV) {
|
||||
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;
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ typedef struct xfs_ifork {
|
|||
/* very small file extents */
|
||||
char if_inline_data[XFS_INLINE_DATA];
|
||||
/* very small file data */
|
||||
xfs_dev_t if_rdev; /* dev number if special */
|
||||
} if_u2;
|
||||
} xfs_ifork_t;
|
||||
|
||||
|
|
|
@ -767,7 +767,7 @@ xfs_ialloc(
|
|||
xfs_inode_t *pip,
|
||||
umode_t mode,
|
||||
xfs_nlink_t nlink,
|
||||
xfs_dev_t rdev,
|
||||
dev_t rdev,
|
||||
prid_t prid,
|
||||
int okalloc,
|
||||
xfs_buf_t **ialloc_context,
|
||||
|
@ -819,6 +819,7 @@ xfs_ialloc(
|
|||
set_nlink(inode, nlink);
|
||||
ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid());
|
||||
ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid());
|
||||
inode->i_rdev = rdev;
|
||||
xfs_set_projid(ip, prid);
|
||||
|
||||
if (pip && XFS_INHERIT_GID(pip)) {
|
||||
|
@ -867,7 +868,6 @@ xfs_ialloc(
|
|||
case S_IFBLK:
|
||||
case S_IFSOCK:
|
||||
ip->i_d.di_format = XFS_DINODE_FMT_DEV;
|
||||
ip->i_df.if_u2.if_rdev = rdev;
|
||||
ip->i_df.if_flags = 0;
|
||||
flags |= XFS_ILOG_DEV;
|
||||
break;
|
||||
|
@ -975,7 +975,7 @@ xfs_dir_ialloc(
|
|||
the inode. */
|
||||
umode_t mode,
|
||||
xfs_nlink_t nlink,
|
||||
xfs_dev_t rdev,
|
||||
dev_t rdev,
|
||||
prid_t prid, /* project id */
|
||||
int okalloc, /* ok to allocate new space */
|
||||
xfs_inode_t **ipp, /* pointer to inode; it will be
|
||||
|
@ -1147,7 +1147,7 @@ xfs_create(
|
|||
xfs_inode_t *dp,
|
||||
struct xfs_name *name,
|
||||
umode_t mode,
|
||||
xfs_dev_t rdev,
|
||||
dev_t rdev,
|
||||
xfs_inode_t **ipp)
|
||||
{
|
||||
int is_dir = S_ISDIR(mode);
|
||||
|
@ -1183,7 +1183,6 @@ xfs_create(
|
|||
return error;
|
||||
|
||||
if (is_dir) {
|
||||
rdev = 0;
|
||||
resblks = XFS_MKDIR_SPACE_RES(mp, name->len);
|
||||
tres = &M_RES(mp)->tr_mkdir;
|
||||
} else {
|
||||
|
|
|
@ -391,7 +391,7 @@ void xfs_inactive(struct xfs_inode *ip);
|
|||
int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,
|
||||
struct xfs_inode **ipp, struct xfs_name *ci_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,
|
||||
umode_t mode, struct xfs_inode **ipp);
|
||||
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);
|
|||
xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip);
|
||||
|
||||
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 *);
|
||||
|
||||
/* from xfs_file.c */
|
||||
|
|
|
@ -222,7 +222,7 @@ xfs_inode_item_format_data_fork(
|
|||
iip->ili_fields &=
|
||||
~(XFS_ILOG_DDATA | XFS_ILOG_DBROOT | XFS_ILOG_DEXT);
|
||||
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;
|
||||
default:
|
||||
ASSERT(0);
|
||||
|
|
|
@ -160,7 +160,6 @@ xfs_generic_create(
|
|||
if (S_ISCHR(mode) || S_ISBLK(mode)) {
|
||||
if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
|
||||
return -EINVAL;
|
||||
rdev = sysv_encode_dev(rdev);
|
||||
} else {
|
||||
rdev = 0;
|
||||
}
|
||||
|
@ -535,8 +534,7 @@ xfs_vn_getattr(
|
|||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
stat->blksize = BLKDEV_IOSIZE;
|
||||
stat->rdev = MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
|
||||
sysv_minor(ip->i_df.if_u2.if_rdev));
|
||||
stat->rdev = inode->i_rdev;
|
||||
break;
|
||||
default:
|
||||
if (XFS_IS_REALTIME_INODE(ip)) {
|
||||
|
@ -1231,18 +1229,6 @@ xfs_setup_inode(
|
|||
inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid);
|
||||
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);
|
||||
xfs_diflags_to_iflags(inode, ip);
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ xfs_bulkstat_one_int(
|
|||
|
||||
switch (dic->di_format) {
|
||||
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_blocks = 0;
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче