Commit c43f4087 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Lachlan McIlroy

[XFS] simplify xfs_vn_getattr

Just fill in struct kstat directly from the xfs_inode instead of doing a
detour through a bhv_vattr_t and xfs_getattr.

SGI-PV: 970980
SGI-Modid: xfs-linux-melb:xfs-kern:29770a
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent 613d7043
...@@ -560,28 +560,56 @@ xfs_vn_getattr( ...@@ -560,28 +560,56 @@ xfs_vn_getattr(
struct kstat *stat) struct kstat *stat)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
bhv_vattr_t vattr = { .va_mask = XFS_AT_STAT }; struct xfs_inode *ip = XFS_I(inode);
int error; struct xfs_mount *mp = ip->i_mount;
error = xfs_getattr(XFS_I(inode), &vattr, ATTR_LAZY); xfs_itrace_entry(ip);
if (likely(!error)) {
stat->size = i_size_read(inode); if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO);
stat->size = XFS_ISIZE(ip);
stat->dev = inode->i_sb->s_dev; stat->dev = inode->i_sb->s_dev;
stat->rdev = (vattr.va_rdev == 0) ? 0 : stat->mode = ip->i_d.di_mode;
MKDEV(sysv_major(vattr.va_rdev) & 0x1ff, stat->nlink = ip->i_d.di_nlink;
sysv_minor(vattr.va_rdev)); stat->uid = ip->i_d.di_uid;
stat->mode = vattr.va_mode; stat->gid = ip->i_d.di_gid;
stat->nlink = vattr.va_nlink; stat->ino = ip->i_ino;
stat->uid = vattr.va_uid; #if XFS_BIG_INUMS
stat->gid = vattr.va_gid; stat->ino += mp->m_inoadd;
stat->ino = vattr.va_nodeid; #endif
stat->atime = vattr.va_atime; stat->atime = inode->i_atime;
stat->mtime = vattr.va_mtime; stat->mtime.tv_sec = ip->i_d.di_mtime.t_sec;
stat->ctime = vattr.va_ctime; stat->mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
stat->blocks = vattr.va_nblocks; stat->ctime.tv_sec = ip->i_d.di_ctime.t_sec;
stat->blksize = vattr.va_blocksize; stat->ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
stat->blocks =
XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
switch (inode->i_mode & S_IFMT) {
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));
break;
default:
if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
/*
* If the file blocks are being allocated from a
* realtime volume, then return the inode's realtime
* extent size or the realtime volume's extent size.
*/
stat->blksize =
xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog;
} else
stat->blksize = xfs_preferred_iosize(mp);
stat->rdev = 0;
break;
} }
return -error;
return 0;
} }
STATIC int STATIC int
......
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