From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/15] xfs: remove if_rdev
Date: Thu, 19 Oct 2017 15:52:06 -0700 [thread overview]
Message-ID: <20171019225206.GV4755@magnolia> (raw)
In-Reply-To: <20171019065942.18813-8-hch@lst.de>
On Thu, Oct 19, 2017 at 08:59:34AM +0200, Christoph Hellwig wrote:
> 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>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/libxfs/xfs_inode_fork.c | 38 +++++++++++++++++++++-----------------
> fs/xfs/libxfs/xfs_inode_fork.h | 1 -
> fs/xfs/xfs_inode.c | 9 ++++-----
> fs/xfs/xfs_inode.h | 4 ++--
> fs/xfs/xfs_inode_item.c | 2 +-
> fs/xfs/xfs_iops.c | 16 +---------------
> fs/xfs/xfs_itable.c | 2 +-
> 7 files changed, 30 insertions(+), 42 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index 1d003ca21562..b1e69734c450 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -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;
>
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
> index 064babdc373c..e0c42ea9b8d0 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.h
> +++ b/fs/xfs/libxfs/xfs_inode_fork.h
> @@ -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;
>
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 4ec5b7f45401..a929ca72fa8e 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -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 {
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 0ee453de239a..cc13c3763721 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -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 */
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index bd60ad313173..eb6f4f7c9520 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.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);
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 17081c77ef86..8b5676d244ca 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -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);
>
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 23ba69fcc516..7595baee0c7c 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -119,7 +119,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;
> --
> 2.14.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-10-19 22:52 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 6:59 more extent mapping cleanups Christoph Hellwig
2017-10-19 6:59 ` [PATCH 01/15] xfs: add a xfs_bmap_fork_to_state helper Christoph Hellwig
2017-10-19 22:48 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 02/15] xfs: make better use of the 'state' variable in xfs_bmap_del_extent_real Christoph Hellwig
2017-10-19 22:49 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 03/15] xfs: remove post-bmap tracing in xfs_bmap_local_to_extents Christoph Hellwig
2017-10-19 22:49 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 04/15] xfs: move pre/post-bmap tracing into xfs_iext_update_extent Christoph Hellwig
2017-10-19 22:50 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 05/15] xfs: remove XFS_BMAP_TRACE_EXLIST Christoph Hellwig
2017-10-19 22:50 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 06/15] xfs: remove the never fully implemented UUID fork format Christoph Hellwig
2017-10-19 22:48 ` Darrick J. Wong
2017-10-20 7:02 ` Christoph Hellwig
2017-10-20 16:52 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 07/15] xfs: remove if_rdev Christoph Hellwig
2017-10-19 22:52 ` Darrick J. Wong [this message]
2017-10-19 6:59 ` [PATCH 08/15] xfs: inline xfs_shift_file_space into callers Christoph Hellwig
2017-10-21 0:07 ` Darrick J. Wong
2017-10-21 8:13 ` Christoph Hellwig
2017-10-21 18:06 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 09/15] xfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS Christoph Hellwig
2017-10-21 0:10 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 10/15] xfs: split xfs_bmap_shift_extents Christoph Hellwig
2017-10-21 0:22 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 11/15] xfs: remove xfs_bmse_shift_one Christoph Hellwig
2017-10-21 0:25 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 12/15] xfs: update got in xfs_bmap_shift_update_extent Christoph Hellwig
2017-10-21 0:25 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 13/15] xfs: don't rely on extent indices in xfs_bmap_collapse_extents Christoph Hellwig
2017-10-21 0:26 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 14/15] xfs: don't rely on extent indices in xfs_bmap_insert_extents Christoph Hellwig
2017-10-21 0:27 ` Darrick J. Wong
2017-10-19 6:59 ` [PATCH 15/15] xfs: rewrite xfs_bmap_first_unused to make better use of xfs_iext_get_extent Christoph Hellwig
2017-10-21 0:27 ` Darrick J. Wong
2017-10-19 20:04 ` more extent mapping cleanups Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171019225206.GV4755@magnolia \
--to=darrick.wong@oracle.com \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox