aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2007-10-11 03:47:00 -0400
committerTim Shimmin <tes@chook.melbourne.sgi.com>2007-10-15 22:21:48 -0400
commitc83bfab1faec9c32297d2079c06adaaaea2650d9 (patch)
treefacee67eadcb9cee317f40a9cd421eafce376bbe /fs
parent859d718279b6e1d6bc27a701db47c1be720b5907 (diff)
[XFS] avoid xfs_getattr in XFS_IOC_FSGETXATTR ioctl
No need to call into xfs_getattr and put a big bhv_vattr_t on the stack just to get a little information from the XFS inode. Add a helper called xfs_ioc_fsgetxattr instead that deals with retrieving the information in a clean way. SGI-PV: 968563 SGI-Modid: xfs-linux-melb:xfs-kern:29780a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Tim Shimmin <tes@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index c9b0c9e68139..ffec630e7db7 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -709,6 +709,12 @@ xfs_ioc_xattr(
709 void __user *arg); 709 void __user *arg);
710 710
711STATIC int 711STATIC int
712xfs_ioc_fsgetxattr(
713 xfs_inode_t *ip,
714 int attr,
715 void __user *arg);
716
717STATIC int
712xfs_ioc_getbmap( 718xfs_ioc_getbmap(
713 struct xfs_inode *ip, 719 struct xfs_inode *ip,
714 int flags, 720 int flags,
@@ -783,11 +789,13 @@ xfs_ioctl(
783 case XFS_IOC_GETVERSION: 789 case XFS_IOC_GETVERSION:
784 return put_user(inode->i_generation, (int __user *)arg); 790 return put_user(inode->i_generation, (int __user *)arg);
785 791
792 case XFS_IOC_FSGETXATTR:
793 return xfs_ioc_fsgetxattr(ip, 0, arg);
794 case XFS_IOC_FSGETXATTRA:
795 return xfs_ioc_fsgetxattr(ip, 1, arg);
786 case XFS_IOC_GETXFLAGS: 796 case XFS_IOC_GETXFLAGS:
787 case XFS_IOC_SETXFLAGS: 797 case XFS_IOC_SETXFLAGS:
788 case XFS_IOC_FSGETXATTR:
789 case XFS_IOC_FSSETXATTR: 798 case XFS_IOC_FSSETXATTR:
790 case XFS_IOC_FSGETXATTRA:
791 return xfs_ioc_xattr(vp, ip, filp, cmd, arg); 799 return xfs_ioc_xattr(vp, ip, filp, cmd, arg);
792 800
793 case XFS_IOC_FSSETDM: { 801 case XFS_IOC_FSSETDM: {
@@ -1162,6 +1170,42 @@ xfs_di2lxflags(
1162} 1170}
1163 1171
1164STATIC int 1172STATIC int
1173xfs_ioc_fsgetxattr(
1174 xfs_inode_t *ip,
1175 int attr,
1176 void __user *arg)
1177{
1178 struct fsxattr fa;
1179
1180 xfs_ilock(ip, XFS_ILOCK_SHARED);
1181 fa.fsx_xflags = xfs_ip2xflags(ip);
1182 fa.fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
1183 fa.fsx_projid = ip->i_d.di_projid;
1184
1185 if (attr) {
1186 if (ip->i_afp) {
1187 if (ip->i_afp->if_flags & XFS_IFEXTENTS)
1188 fa.fsx_nextents = ip->i_afp->if_bytes /
1189 sizeof(xfs_bmbt_rec_t);
1190 else
1191 fa.fsx_nextents = ip->i_d.di_anextents;
1192 } else
1193 fa.fsx_nextents = 0;
1194 } else {
1195 if (ip->i_df.if_flags & XFS_IFEXTENTS)
1196 fa.fsx_nextents = ip->i_df.if_bytes /
1197 sizeof(xfs_bmbt_rec_t);
1198 else
1199 fa.fsx_nextents = ip->i_d.di_nextents;
1200 }
1201 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1202
1203 if (copy_to_user(arg, &fa, sizeof(fa)))
1204 return -EFAULT;
1205 return 0;
1206}
1207
1208STATIC int
1165xfs_ioc_xattr( 1209xfs_ioc_xattr(
1166 bhv_vnode_t *vp, 1210 bhv_vnode_t *vp,
1167 xfs_inode_t *ip, 1211 xfs_inode_t *ip,
@@ -1180,27 +1224,6 @@ xfs_ioc_xattr(
1180 return -ENOMEM; 1224 return -ENOMEM;
1181 1225
1182 switch (cmd) { 1226 switch (cmd) {
1183 case XFS_IOC_FSGETXATTR: {
1184 vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
1185 XFS_AT_NEXTENTS | XFS_AT_PROJID;
1186 error = xfs_getattr(ip, vattr, 0);
1187 if (unlikely(error)) {
1188 error = -error;
1189 break;
1190 }
1191
1192 fa.fsx_xflags = vattr->va_xflags;
1193 fa.fsx_extsize = vattr->va_extsize;
1194 fa.fsx_nextents = vattr->va_nextents;
1195 fa.fsx_projid = vattr->va_projid;
1196
1197 if (copy_to_user(arg, &fa, sizeof(fa))) {
1198 error = -EFAULT;
1199 break;
1200 }
1201 break;
1202 }
1203
1204 case XFS_IOC_FSSETXATTR: { 1227 case XFS_IOC_FSSETXATTR: {
1205 if (copy_from_user(&fa, arg, sizeof(fa))) { 1228 if (copy_from_user(&fa, arg, sizeof(fa))) {
1206 error = -EFAULT; 1229 error = -EFAULT;
@@ -1223,27 +1246,6 @@ xfs_ioc_xattr(
1223 break; 1246 break;
1224 } 1247 }
1225 1248
1226 case XFS_IOC_FSGETXATTRA: {
1227 vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
1228 XFS_AT_ANEXTENTS | XFS_AT_PROJID;
1229 error = xfs_getattr(ip, vattr, 0);
1230 if (unlikely(error)) {
1231 error = -error;
1232 break;
1233 }
1234
1235 fa.fsx_xflags = vattr->va_xflags;
1236 fa.fsx_extsize = vattr->va_extsize;
1237 fa.fsx_nextents = vattr->va_anextents;
1238 fa.fsx_projid = vattr->va_projid;
1239
1240 if (copy_to_user(arg, &fa, sizeof(fa))) {
1241 error = -EFAULT;
1242 break;
1243 }
1244 break;
1245 }
1246
1247 case XFS_IOC_GETXFLAGS: { 1249 case XFS_IOC_GETXFLAGS: {
1248 flags = xfs_di2lxflags(ip->i_d.di_flags); 1250 flags = xfs_di2lxflags(ip->i_d.di_flags);
1249 if (copy_to_user(arg, &flags, sizeof(flags))) 1251 if (copy_to_user(arg, &flags, sizeof(flags)))