aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c56
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h73
-rw-r--r--fs/xfs/xfs_acl.c18
-rw-r--r--fs/xfs/xfs_dmapi.h2
-rw-r--r--fs/xfs/xfs_vnodeops.c172
-rw-r--r--fs/xfs/xfs_vnodeops.h8
7 files changed, 102 insertions, 231 deletions
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index d2bbb0532ef6..d1b0da6bcdca 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -688,9 +688,9 @@ xfs_ioc_space(
688 return -XFS_ERROR(EFAULT); 688 return -XFS_ERROR(EFAULT);
689 689
690 if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) 690 if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
691 attr_flags |= ATTR_NONBLOCK; 691 attr_flags |= XFS_ATTR_NONBLOCK;
692 if (ioflags & IO_INVIS) 692 if (ioflags & IO_INVIS)
693 attr_flags |= ATTR_DMI; 693 attr_flags |= XFS_ATTR_DMI;
694 694
695 error = xfs_change_file_space(ip, cmd, &bf, filp->f_pos, 695 error = xfs_change_file_space(ip, cmd, &bf, filp->f_pos,
696 NULL, attr_flags); 696 NULL, attr_flags);
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 7b42569968fe..669bbdc20857 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -648,54 +648,20 @@ xfs_vn_getattr(
648STATIC int 648STATIC int
649xfs_vn_setattr( 649xfs_vn_setattr(
650 struct dentry *dentry, 650 struct dentry *dentry,
651 struct iattr *attr) 651 struct iattr *iattr)
652{ 652{
653 struct inode *inode = dentry->d_inode; 653 struct inode *inode = dentry->d_inode;
654 unsigned int ia_valid = attr->ia_valid;
655 bhv_vattr_t vattr = { 0 };
656 int flags = 0;
657 int error; 654 int error;
658 655
659 if (ia_valid & ATTR_UID) { 656 if (iattr->ia_valid & ATTR_ATIME)
660 vattr.va_mask |= XFS_AT_UID; 657 inode->i_atime = iattr->ia_atime;
661 vattr.va_uid = attr->ia_uid; 658
662 } 659 if (iattr->ia_valid & ATTR_MODE) {
663 if (ia_valid & ATTR_GID) {
664 vattr.va_mask |= XFS_AT_GID;
665 vattr.va_gid = attr->ia_gid;
666 }
667 if (ia_valid & ATTR_SIZE) {
668 vattr.va_mask |= XFS_AT_SIZE;
669 vattr.va_size = attr->ia_size;
670 }
671 if (ia_valid & ATTR_ATIME) {
672 vattr.va_mask |= XFS_AT_ATIME;
673 vattr.va_atime = attr->ia_atime;
674 inode->i_atime = attr->ia_atime;
675 }
676 if (ia_valid & ATTR_MTIME) {
677 vattr.va_mask |= XFS_AT_MTIME;
678 vattr.va_mtime = attr->ia_mtime;
679 }
680 if (ia_valid & ATTR_CTIME) {
681 vattr.va_mask |= XFS_AT_CTIME;
682 vattr.va_ctime = attr->ia_ctime;
683 }
684 if (ia_valid & ATTR_MODE) {
685 vattr.va_mask |= XFS_AT_MODE;
686 vattr.va_mode = attr->ia_mode;
687 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) 660 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
688 inode->i_mode &= ~S_ISGID; 661 inode->i_mode &= ~S_ISGID;
689 } 662 }
690 663
691 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) 664 error = xfs_setattr(XFS_I(inode), iattr, 0, NULL);
692 flags |= ATTR_UTIME;
693#ifdef ATTR_NO_BLOCK
694 if ((ia_valid & ATTR_NO_BLOCK))
695 flags |= ATTR_NONBLOCK;
696#endif
697
698 error = xfs_setattr(XFS_I(inode), &vattr, flags, NULL);
699 if (likely(!error)) 665 if (likely(!error))
700 vn_revalidate(vn_from_inode(inode)); 666 vn_revalidate(vn_from_inode(inode));
701 return -error; 667 return -error;
@@ -739,18 +705,18 @@ xfs_vn_fallocate(
739 705
740 xfs_ilock(ip, XFS_IOLOCK_EXCL); 706 xfs_ilock(ip, XFS_IOLOCK_EXCL);
741 error = xfs_change_file_space(ip, XFS_IOC_RESVSP, &bf, 707 error = xfs_change_file_space(ip, XFS_IOC_RESVSP, &bf,
742 0, NULL, ATTR_NOLOCK); 708 0, NULL, XFS_ATTR_NOLOCK);
743 if (!error && !(mode & FALLOC_FL_KEEP_SIZE) && 709 if (!error && !(mode & FALLOC_FL_KEEP_SIZE) &&
744 offset + len > i_size_read(inode)) 710 offset + len > i_size_read(inode))
745 new_size = offset + len; 711 new_size = offset + len;
746 712
747 /* Change file size if needed */ 713 /* Change file size if needed */
748 if (new_size) { 714 if (new_size) {
749 bhv_vattr_t va; 715 struct iattr iattr;
750 716
751 va.va_mask = XFS_AT_SIZE; 717 iattr.ia_valid = ATTR_SIZE;
752 va.va_size = new_size; 718 iattr.ia_size = new_size;
753 error = xfs_setattr(ip, &va, ATTR_NOLOCK, NULL); 719 error = xfs_setattr(ip, &iattr, XFS_ATTR_NOLOCK, NULL);
754 } 720 }
755 721
756 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 722 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 7797c9cdb591..96e4a7b5391c 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -19,7 +19,6 @@
19#define __XFS_VNODE_H__ 19#define __XFS_VNODE_H__
20 20
21struct file; 21struct file;
22struct bhv_vattr;
23struct xfs_iomap; 22struct xfs_iomap;
24struct attrlist_cursor_kern; 23struct attrlist_cursor_kern;
25 24
@@ -66,69 +65,6 @@ static inline struct inode *vn_to_inode(bhv_vnode_t *vnode)
66 Prevent VM access to the pages until 65 Prevent VM access to the pages until
67 the operation completes. */ 66 the operation completes. */
68 67
69/*
70 * Vnode attributes. va_mask indicates those attributes the caller
71 * wants to set or extract.
72 */
73typedef struct bhv_vattr {
74 int va_mask; /* bit-mask of attributes present */
75 mode_t va_mode; /* file access mode and type */
76 xfs_nlink_t va_nlink; /* number of references to file */
77 uid_t va_uid; /* owner user id */
78 gid_t va_gid; /* owner group id */
79 xfs_ino_t va_nodeid; /* file id */
80 xfs_off_t va_size; /* file size in bytes */
81 u_long va_blocksize; /* blocksize preferred for i/o */
82 struct timespec va_atime; /* time of last access */
83 struct timespec va_mtime; /* time of last modification */
84 struct timespec va_ctime; /* time file changed */
85 u_int va_gen; /* generation number of file */
86 xfs_dev_t va_rdev; /* device the special file represents */
87 __int64_t va_nblocks; /* number of blocks allocated */
88 u_long va_xflags; /* random extended file flags */
89 u_long va_extsize; /* file extent size */
90 u_long va_nextents; /* number of extents in file */
91 u_long va_anextents; /* number of attr extents in file */
92 prid_t va_projid; /* project id */
93} bhv_vattr_t;
94
95/*
96 * setattr or getattr attributes
97 */
98#define XFS_AT_TYPE 0x00000001
99#define XFS_AT_MODE 0x00000002
100#define XFS_AT_UID 0x00000004
101#define XFS_AT_GID 0x00000008
102#define XFS_AT_FSID 0x00000010
103#define XFS_AT_NODEID 0x00000020
104#define XFS_AT_NLINK 0x00000040
105#define XFS_AT_SIZE 0x00000080
106#define XFS_AT_ATIME 0x00000100
107#define XFS_AT_MTIME 0x00000200
108#define XFS_AT_CTIME 0x00000400
109#define XFS_AT_RDEV 0x00000800
110#define XFS_AT_BLKSIZE 0x00001000
111#define XFS_AT_NBLOCKS 0x00002000
112#define XFS_AT_VCODE 0x00004000
113#define XFS_AT_MAC 0x00008000
114#define XFS_AT_UPDATIME 0x00010000
115#define XFS_AT_UPDMTIME 0x00020000
116#define XFS_AT_UPDCTIME 0x00040000
117#define XFS_AT_ACL 0x00080000
118#define XFS_AT_CAP 0x00100000
119#define XFS_AT_INF 0x00200000
120#define XFS_AT_NEXTENTS 0x01000000
121#define XFS_AT_ANEXTENTS 0x02000000
122#define XFS_AT_SIZE_NOPERM 0x08000000
123#define XFS_AT_GENCOUNT 0x10000000
124
125#define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME)
126
127#define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME)
128
129#define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\
130 XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
131 XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
132 68
133extern void vn_init(void); 69extern void vn_init(void);
134extern int vn_revalidate(bhv_vnode_t *); 70extern int vn_revalidate(bhv_vnode_t *);
@@ -204,15 +140,6 @@ static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt)
204#define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \ 140#define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \
205 PAGECACHE_TAG_DIRTY) 141 PAGECACHE_TAG_DIRTY)
206 142
207/*
208 * Flags to vop_setattr/getattr.
209 */
210#define ATTR_UTIME 0x01 /* non-default utime(2) request */
211#define ATTR_DMI 0x08 /* invocation from a DMI function */
212#define ATTR_LAZY 0x80 /* set/get attributes lazily */
213#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
214#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
215#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */
216 143
217/* 144/*
218 * Tracking vnode activity. 145 * Tracking vnode activity.
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 93057af2fe3d..3e4648ad9cfc 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -719,7 +719,7 @@ xfs_acl_setmode(
719 xfs_acl_t *acl, 719 xfs_acl_t *acl,
720 int *basicperms) 720 int *basicperms)
721{ 721{
722 bhv_vattr_t va; 722 struct iattr iattr;
723 xfs_acl_entry_t *ap; 723 xfs_acl_entry_t *ap;
724 xfs_acl_entry_t *gap = NULL; 724 xfs_acl_entry_t *gap = NULL;
725 int i, nomask = 1; 725 int i, nomask = 1;
@@ -733,25 +733,25 @@ xfs_acl_setmode(
733 * Copy the u::, g::, o::, and m:: bits from the ACL into the 733 * Copy the u::, g::, o::, and m:: bits from the ACL into the
734 * mode. The m:: bits take precedence over the g:: bits. 734 * mode. The m:: bits take precedence over the g:: bits.
735 */ 735 */
736 va.va_mask = XFS_AT_MODE; 736 iattr.ia_valid = ATTR_MODE;
737 va.va_mode = xfs_vtoi(vp)->i_d.di_mode; 737 iattr.ia_mode = xfs_vtoi(vp)->i_d.di_mode;
738 va.va_mode &= ~(S_IRWXU|S_IRWXG|S_IRWXO); 738 iattr.ia_mode &= ~(S_IRWXU|S_IRWXG|S_IRWXO);
739 ap = acl->acl_entry; 739 ap = acl->acl_entry;
740 for (i = 0; i < acl->acl_cnt; ++i) { 740 for (i = 0; i < acl->acl_cnt; ++i) {
741 switch (ap->ae_tag) { 741 switch (ap->ae_tag) {
742 case ACL_USER_OBJ: 742 case ACL_USER_OBJ:
743 va.va_mode |= ap->ae_perm << 6; 743 iattr.ia_mode |= ap->ae_perm << 6;
744 break; 744 break;
745 case ACL_GROUP_OBJ: 745 case ACL_GROUP_OBJ:
746 gap = ap; 746 gap = ap;
747 break; 747 break;
748 case ACL_MASK: /* more than just standard modes */ 748 case ACL_MASK: /* more than just standard modes */
749 nomask = 0; 749 nomask = 0;
750 va.va_mode |= ap->ae_perm << 3; 750 iattr.ia_mode |= ap->ae_perm << 3;
751 *basicperms = 0; 751 *basicperms = 0;
752 break; 752 break;
753 case ACL_OTHER: 753 case ACL_OTHER:
754 va.va_mode |= ap->ae_perm; 754 iattr.ia_mode |= ap->ae_perm;
755 break; 755 break;
756 default: /* more than just standard modes */ 756 default: /* more than just standard modes */
757 *basicperms = 0; 757 *basicperms = 0;
@@ -762,9 +762,9 @@ xfs_acl_setmode(
762 762
763 /* Set the group bits from ACL_GROUP_OBJ if there's no ACL_MASK */ 763 /* Set the group bits from ACL_GROUP_OBJ if there's no ACL_MASK */
764 if (gap && nomask) 764 if (gap && nomask)
765 va.va_mode |= gap->ae_perm << 3; 765 iattr.ia_mode |= gap->ae_perm << 3;
766 766
767 return xfs_setattr(xfs_vtoi(vp), &va, 0, sys_cred); 767 return xfs_setattr(xfs_vtoi(vp), &iattr, 0, sys_cred);
768} 768}
769 769
770/* 770/*
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h
index f71784ab6a60..cdc2d3464a1a 100644
--- a/fs/xfs/xfs_dmapi.h
+++ b/fs/xfs/xfs_dmapi.h
@@ -166,6 +166,6 @@ typedef enum {
166 166
167#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \ 167#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
168 DM_FLAGS_NDELAY : 0) 168 DM_FLAGS_NDELAY : 0)
169#define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0) 169#define AT_DELAY_FLAG(f) ((f & XFS_ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
170 170
171#endif /* __XFS_DMAPI_H__ */ 171#endif /* __XFS_DMAPI_H__ */
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index ed399523b782..b792a121b1a7 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -75,19 +75,16 @@ xfs_open(
75 return 0; 75 return 0;
76} 76}
77 77
78/*
79 * xfs_setattr
80 */
81int 78int
82xfs_setattr( 79xfs_setattr(
83 xfs_inode_t *ip, 80 struct xfs_inode *ip,
84 bhv_vattr_t *vap, 81 struct iattr *iattr,
85 int flags, 82 int flags,
86 cred_t *credp) 83 cred_t *credp)
87{ 84{
88 xfs_mount_t *mp = ip->i_mount; 85 xfs_mount_t *mp = ip->i_mount;
86 int mask = iattr->ia_valid;
89 xfs_trans_t *tp; 87 xfs_trans_t *tp;
90 int mask;
91 int code; 88 int code;
92 uint lock_flags; 89 uint lock_flags;
93 uint commit_flags=0; 90 uint commit_flags=0;
@@ -103,30 +100,9 @@ xfs_setattr(
103 if (mp->m_flags & XFS_MOUNT_RDONLY) 100 if (mp->m_flags & XFS_MOUNT_RDONLY)
104 return XFS_ERROR(EROFS); 101 return XFS_ERROR(EROFS);
105 102
106 /*
107 * Cannot set certain attributes.
108 */
109 mask = vap->va_mask;
110 if (mask & XFS_AT_NOSET) {
111 return XFS_ERROR(EINVAL);
112 }
113
114 if (XFS_FORCED_SHUTDOWN(mp)) 103 if (XFS_FORCED_SHUTDOWN(mp))
115 return XFS_ERROR(EIO); 104 return XFS_ERROR(EIO);
116 105
117 /*
118 * Timestamps do not need to be logged and hence do not
119 * need to be done within a transaction.
120 */
121 if (mask & XFS_AT_UPDTIMES) {
122 ASSERT((mask & ~XFS_AT_UPDTIMES) == 0);
123 timeflags = ((mask & XFS_AT_UPDATIME) ? XFS_ICHGTIME_ACC : 0) |
124 ((mask & XFS_AT_UPDCTIME) ? XFS_ICHGTIME_CHG : 0) |
125 ((mask & XFS_AT_UPDMTIME) ? XFS_ICHGTIME_MOD : 0);
126 xfs_ichgtime(ip, timeflags);
127 return 0;
128 }
129
130 olddquot1 = olddquot2 = NULL; 106 olddquot1 = olddquot2 = NULL;
131 udqp = gdqp = NULL; 107 udqp = gdqp = NULL;
132 108
@@ -138,17 +114,17 @@ xfs_setattr(
138 * If the IDs do change before we take the ilock, we're covered 114 * If the IDs do change before we take the ilock, we're covered
139 * because the i_*dquot fields will get updated anyway. 115 * because the i_*dquot fields will get updated anyway.
140 */ 116 */
141 if (XFS_IS_QUOTA_ON(mp) && (mask & (XFS_AT_UID|XFS_AT_GID))) { 117 if (XFS_IS_QUOTA_ON(mp) && (mask & (ATTR_UID|ATTR_GID))) {
142 uint qflags = 0; 118 uint qflags = 0;
143 119
144 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) { 120 if ((mask & ATTR_UID) && XFS_IS_UQUOTA_ON(mp)) {
145 uid = vap->va_uid; 121 uid = iattr->ia_uid;
146 qflags |= XFS_QMOPT_UQUOTA; 122 qflags |= XFS_QMOPT_UQUOTA;
147 } else { 123 } else {
148 uid = ip->i_d.di_uid; 124 uid = ip->i_d.di_uid;
149 } 125 }
150 if ((mask & XFS_AT_GID) && XFS_IS_GQUOTA_ON(mp)) { 126 if ((mask & ATTR_GID) && XFS_IS_GQUOTA_ON(mp)) {
151 gid = vap->va_gid; 127 gid = iattr->ia_gid;
152 qflags |= XFS_QMOPT_GQUOTA; 128 qflags |= XFS_QMOPT_GQUOTA;
153 } else { 129 } else {
154 gid = ip->i_d.di_gid; 130 gid = ip->i_d.di_gid;
@@ -173,10 +149,10 @@ xfs_setattr(
173 */ 149 */
174 tp = NULL; 150 tp = NULL;
175 lock_flags = XFS_ILOCK_EXCL; 151 lock_flags = XFS_ILOCK_EXCL;
176 if (flags & ATTR_NOLOCK) 152 if (flags & XFS_ATTR_NOLOCK)
177 need_iolock = 0; 153 need_iolock = 0;
178 if (!(mask & XFS_AT_SIZE)) { 154 if (!(mask & ATTR_SIZE)) {
179 if ((mask != (XFS_AT_CTIME|XFS_AT_ATIME|XFS_AT_MTIME)) || 155 if ((mask != (ATTR_CTIME|ATTR_ATIME|ATTR_MTIME)) ||
180 (mp->m_flags & XFS_MOUNT_WSYNC)) { 156 (mp->m_flags & XFS_MOUNT_WSYNC)) {
181 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); 157 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
182 commit_flags = 0; 158 commit_flags = 0;
@@ -189,10 +165,10 @@ xfs_setattr(
189 } 165 }
190 } else { 166 } else {
191 if (DM_EVENT_ENABLED(ip, DM_EVENT_TRUNCATE) && 167 if (DM_EVENT_ENABLED(ip, DM_EVENT_TRUNCATE) &&
192 !(flags & ATTR_DMI)) { 168 !(flags & XFS_ATTR_DMI)) {
193 int dmflags = AT_DELAY_FLAG(flags) | DM_SEM_FLAG_WR; 169 int dmflags = AT_DELAY_FLAG(flags) | DM_SEM_FLAG_WR;
194 code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, ip, 170 code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, ip,
195 vap->va_size, 0, dmflags, NULL); 171 iattr->ia_size, 0, dmflags, NULL);
196 if (code) { 172 if (code) {
197 lock_flags = 0; 173 lock_flags = 0;
198 goto error_return; 174 goto error_return;
@@ -212,7 +188,7 @@ xfs_setattr(
212 * Only the owner or users with CAP_FOWNER 188 * Only the owner or users with CAP_FOWNER
213 * capability may do these things. 189 * capability may do these things.
214 */ 190 */
215 if (mask & (XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID)) { 191 if (mask & (ATTR_MODE|ATTR_UID|ATTR_GID)) {
216 /* 192 /*
217 * CAP_FOWNER overrides the following restrictions: 193 * CAP_FOWNER overrides the following restrictions:
218 * 194 *
@@ -236,21 +212,21 @@ xfs_setattr(
236 * IDs of the calling process shall match the group owner of 212 * IDs of the calling process shall match the group owner of
237 * the file when setting the set-group-ID bit on that file 213 * the file when setting the set-group-ID bit on that file
238 */ 214 */
239 if (mask & XFS_AT_MODE) { 215 if (mask & ATTR_MODE) {
240 mode_t m = 0; 216 mode_t m = 0;
241 217
242 if ((vap->va_mode & S_ISUID) && !file_owner) 218 if ((iattr->ia_mode & S_ISUID) && !file_owner)
243 m |= S_ISUID; 219 m |= S_ISUID;
244 if ((vap->va_mode & S_ISGID) && 220 if ((iattr->ia_mode & S_ISGID) &&
245 !in_group_p((gid_t)ip->i_d.di_gid)) 221 !in_group_p((gid_t)ip->i_d.di_gid))
246 m |= S_ISGID; 222 m |= S_ISGID;
247#if 0 223#if 0
248 /* Linux allows this, Irix doesn't. */ 224 /* Linux allows this, Irix doesn't. */
249 if ((vap->va_mode & S_ISVTX) && !S_ISDIR(ip->i_d.di_mode)) 225 if ((iattr->ia_mode & S_ISVTX) && !S_ISDIR(ip->i_d.di_mode))
250 m |= S_ISVTX; 226 m |= S_ISVTX;
251#endif 227#endif
252 if (m && !capable(CAP_FSETID)) 228 if (m && !capable(CAP_FSETID))
253 vap->va_mode &= ~m; 229 iattr->ia_mode &= ~m;
254 } 230 }
255 } 231 }
256 232
@@ -261,7 +237,7 @@ xfs_setattr(
261 * and can change the group id only to a group of which he 237 * and can change the group id only to a group of which he
262 * or she is a member. 238 * or she is a member.
263 */ 239 */
264 if (mask & (XFS_AT_UID|XFS_AT_GID)) { 240 if (mask & (ATTR_UID|ATTR_GID)) {
265 /* 241 /*
266 * These IDs could have changed since we last looked at them. 242 * These IDs could have changed since we last looked at them.
267 * But, we're assured that if the ownership did change 243 * But, we're assured that if the ownership did change
@@ -270,8 +246,8 @@ xfs_setattr(
270 */ 246 */
271 iuid = ip->i_d.di_uid; 247 iuid = ip->i_d.di_uid;
272 igid = ip->i_d.di_gid; 248 igid = ip->i_d.di_gid;
273 gid = (mask & XFS_AT_GID) ? vap->va_gid : igid; 249 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
274 uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid; 250 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
275 251
276 /* 252 /*
277 * CAP_CHOWN overrides the following restrictions: 253 * CAP_CHOWN overrides the following restrictions:
@@ -308,13 +284,13 @@ xfs_setattr(
308 /* 284 /*
309 * Truncate file. Must have write permission and not be a directory. 285 * Truncate file. Must have write permission and not be a directory.
310 */ 286 */
311 if (mask & XFS_AT_SIZE) { 287 if (mask & ATTR_SIZE) {
312 /* Short circuit the truncate case for zero length files */ 288 /* Short circuit the truncate case for zero length files */
313 if ((vap->va_size == 0) && 289 if (iattr->ia_size == 0 &&
314 (ip->i_size == 0) && (ip->i_d.di_nextents == 0)) { 290 ip->i_size == 0 && ip->i_d.di_nextents == 0) {
315 xfs_iunlock(ip, XFS_ILOCK_EXCL); 291 xfs_iunlock(ip, XFS_ILOCK_EXCL);
316 lock_flags &= ~XFS_ILOCK_EXCL; 292 lock_flags &= ~XFS_ILOCK_EXCL;
317 if (mask & XFS_AT_CTIME) 293 if (mask & ATTR_CTIME)
318 xfs_ichgtime(ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); 294 xfs_ichgtime(ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
319 code = 0; 295 code = 0;
320 goto error_return; 296 goto error_return;
@@ -337,9 +313,9 @@ xfs_setattr(
337 /* 313 /*
338 * Change file access or modified times. 314 * Change file access or modified times.
339 */ 315 */
340 if (mask & (XFS_AT_ATIME|XFS_AT_MTIME)) { 316 if (mask & (ATTR_ATIME|ATTR_MTIME)) {
341 if (!file_owner) { 317 if (!file_owner) {
342 if ((flags & ATTR_UTIME) && 318 if ((mask & (ATTR_MTIME_SET|ATTR_ATIME_SET)) &&
343 !capable(CAP_FOWNER)) { 319 !capable(CAP_FOWNER)) {
344 code = XFS_ERROR(EPERM); 320 code = XFS_ERROR(EPERM);
345 goto error_return; 321 goto error_return;
@@ -349,23 +325,22 @@ xfs_setattr(
349 325
350 /* 326 /*
351 * Now we can make the changes. Before we join the inode 327 * Now we can make the changes. Before we join the inode
352 * to the transaction, if XFS_AT_SIZE is set then take care of 328 * to the transaction, if ATTR_SIZE is set then take care of
353 * the part of the truncation that must be done without the 329 * the part of the truncation that must be done without the
354 * inode lock. This needs to be done before joining the inode 330 * inode lock. This needs to be done before joining the inode
355 * to the transaction, because the inode cannot be unlocked 331 * to the transaction, because the inode cannot be unlocked
356 * once it is a part of the transaction. 332 * once it is a part of the transaction.
357 */ 333 */
358 if (mask & XFS_AT_SIZE) { 334 if (mask & ATTR_SIZE) {
359 code = 0; 335 code = 0;
360 if ((vap->va_size > ip->i_size) && 336 if (iattr->ia_size > ip->i_size) {
361 (flags & ATTR_NOSIZETOK) == 0) {
362 /* 337 /*
363 * Do the first part of growing a file: zero any data 338 * Do the first part of growing a file: zero any data
364 * in the last block that is beyond the old EOF. We 339 * in the last block that is beyond the old EOF. We
365 * need to do this before the inode is joined to the 340 * need to do this before the inode is joined to the
366 * transaction to modify the i_size. 341 * transaction to modify the i_size.
367 */ 342 */
368 code = xfs_zero_eof(ip, vap->va_size, ip->i_size); 343 code = xfs_zero_eof(ip, iattr->ia_size, ip->i_size);
369 } 344 }
370 xfs_iunlock(ip, XFS_ILOCK_EXCL); 345 xfs_iunlock(ip, XFS_ILOCK_EXCL);
371 346
@@ -382,10 +357,10 @@ xfs_setattr(
382 * not within the range we care about here. 357 * not within the range we care about here.
383 */ 358 */
384 if (!code && 359 if (!code &&
385 (ip->i_size != ip->i_d.di_size) && 360 ip->i_size != ip->i_d.di_size &&
386 (vap->va_size > ip->i_d.di_size)) { 361 iattr->ia_size > ip->i_d.di_size) {
387 code = xfs_flush_pages(ip, 362 code = xfs_flush_pages(ip,
388 ip->i_d.di_size, vap->va_size, 363 ip->i_d.di_size, iattr->ia_size,
389 XFS_B_ASYNC, FI_NONE); 364 XFS_B_ASYNC, FI_NONE);
390 } 365 }
391 366
@@ -393,7 +368,7 @@ xfs_setattr(
393 vn_iowait(ip); 368 vn_iowait(ip);
394 369
395 if (!code) 370 if (!code)
396 code = xfs_itruncate_data(ip, vap->va_size); 371 code = xfs_itruncate_data(ip, iattr->ia_size);
397 if (code) { 372 if (code) {
398 ASSERT(tp == NULL); 373 ASSERT(tp == NULL);
399 lock_flags &= ~XFS_ILOCK_EXCL; 374 lock_flags &= ~XFS_ILOCK_EXCL;
@@ -422,31 +397,30 @@ xfs_setattr(
422 /* 397 /*
423 * Truncate file. Must have write permission and not be a directory. 398 * Truncate file. Must have write permission and not be a directory.
424 */ 399 */
425 if (mask & XFS_AT_SIZE) { 400 if (mask & ATTR_SIZE) {
426 /* 401 /*
427 * Only change the c/mtime if we are changing the size 402 * Only change the c/mtime if we are changing the size
428 * or we are explicitly asked to change it. This handles 403 * or we are explicitly asked to change it. This handles
429 * the semantic difference between truncate() and ftruncate() 404 * the semantic difference between truncate() and ftruncate()
430 * as implemented in the VFS. 405 * as implemented in the VFS.
431 */ 406 */
432 if (vap->va_size != ip->i_size || (mask & XFS_AT_CTIME)) 407 if (iattr->ia_size != ip->i_size || (mask & ATTR_CTIME))
433 timeflags |= XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG; 408 timeflags |= XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG;
434 409
435 if (vap->va_size > ip->i_size) { 410 if (iattr->ia_size > ip->i_size) {
436 ip->i_d.di_size = vap->va_size; 411 ip->i_d.di_size = iattr->ia_size;
437 ip->i_size = vap->va_size; 412 ip->i_size = iattr->ia_size;
438 if (!(flags & ATTR_DMI)) 413 if (!(flags & XFS_ATTR_DMI))
439 xfs_ichgtime(ip, XFS_ICHGTIME_CHG); 414 xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
440 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 415 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
441 } else if ((vap->va_size <= ip->i_size) || 416 } else if (iattr->ia_size <= ip->i_size ||
442 ((vap->va_size == 0) && ip->i_d.di_nextents)) { 417 (iattr->ia_size == 0 && ip->i_d.di_nextents)) {
443 /* 418 /*
444 * signal a sync transaction unless 419 * signal a sync transaction unless
445 * we're truncating an already unlinked 420 * we're truncating an already unlinked
446 * file on a wsync filesystem 421 * file on a wsync filesystem
447 */ 422 */
448 code = xfs_itruncate_finish(&tp, ip, 423 code = xfs_itruncate_finish(&tp, ip, iattr->ia_size,
449 (xfs_fsize_t)vap->va_size,
450 XFS_DATA_FORK, 424 XFS_DATA_FORK,
451 ((ip->i_d.di_nlink != 0 || 425 ((ip->i_d.di_nlink != 0 ||
452 !(mp->m_flags & XFS_MOUNT_WSYNC)) 426 !(mp->m_flags & XFS_MOUNT_WSYNC))
@@ -468,9 +442,9 @@ xfs_setattr(
468 /* 442 /*
469 * Change file access modes. 443 * Change file access modes.
470 */ 444 */
471 if (mask & XFS_AT_MODE) { 445 if (mask & ATTR_MODE) {
472 ip->i_d.di_mode &= S_IFMT; 446 ip->i_d.di_mode &= S_IFMT;
473 ip->i_d.di_mode |= vap->va_mode & ~S_IFMT; 447 ip->i_d.di_mode |= iattr->ia_mode & ~S_IFMT;
474 448
475 xfs_trans_log_inode (tp, ip, XFS_ILOG_CORE); 449 xfs_trans_log_inode (tp, ip, XFS_ILOG_CORE);
476 timeflags |= XFS_ICHGTIME_CHG; 450 timeflags |= XFS_ICHGTIME_CHG;
@@ -483,7 +457,7 @@ xfs_setattr(
483 * and can change the group id only to a group of which he 457 * and can change the group id only to a group of which he
484 * or she is a member. 458 * or she is a member.
485 */ 459 */
486 if (mask & (XFS_AT_UID|XFS_AT_GID)) { 460 if (mask & (ATTR_UID|ATTR_GID)) {
487 /* 461 /*
488 * CAP_FSETID overrides the following restrictions: 462 * CAP_FSETID overrides the following restrictions:
489 * 463 *
@@ -501,7 +475,7 @@ xfs_setattr(
501 */ 475 */
502 if (iuid != uid) { 476 if (iuid != uid) {
503 if (XFS_IS_UQUOTA_ON(mp)) { 477 if (XFS_IS_UQUOTA_ON(mp)) {
504 ASSERT(mask & XFS_AT_UID); 478 ASSERT(mask & ATTR_UID);
505 ASSERT(udqp); 479 ASSERT(udqp);
506 olddquot1 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 480 olddquot1 = XFS_QM_DQVOPCHOWN(mp, tp, ip,
507 &ip->i_udquot, udqp); 481 &ip->i_udquot, udqp);
@@ -511,7 +485,7 @@ xfs_setattr(
511 if (igid != gid) { 485 if (igid != gid) {
512 if (XFS_IS_GQUOTA_ON(mp)) { 486 if (XFS_IS_GQUOTA_ON(mp)) {
513 ASSERT(!XFS_IS_PQUOTA_ON(mp)); 487 ASSERT(!XFS_IS_PQUOTA_ON(mp));
514 ASSERT(mask & XFS_AT_GID); 488 ASSERT(mask & ATTR_GID);
515 ASSERT(gdqp); 489 ASSERT(gdqp);
516 olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 490 olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip,
517 &ip->i_gdquot, gdqp); 491 &ip->i_gdquot, gdqp);
@@ -527,31 +501,31 @@ xfs_setattr(
527 /* 501 /*
528 * Change file access or modified times. 502 * Change file access or modified times.
529 */ 503 */
530 if (mask & (XFS_AT_ATIME|XFS_AT_MTIME)) { 504 if (mask & (ATTR_ATIME|ATTR_MTIME)) {
531 if (mask & XFS_AT_ATIME) { 505 if (mask & ATTR_ATIME) {
532 ip->i_d.di_atime.t_sec = vap->va_atime.tv_sec; 506 ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec;
533 ip->i_d.di_atime.t_nsec = vap->va_atime.tv_nsec; 507 ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec;
534 ip->i_update_core = 1; 508 ip->i_update_core = 1;
535 timeflags &= ~XFS_ICHGTIME_ACC; 509 timeflags &= ~XFS_ICHGTIME_ACC;
536 } 510 }
537 if (mask & XFS_AT_MTIME) { 511 if (mask & ATTR_MTIME) {
538 ip->i_d.di_mtime.t_sec = vap->va_mtime.tv_sec; 512 ip->i_d.di_mtime.t_sec = iattr->ia_mtime.tv_sec;
539 ip->i_d.di_mtime.t_nsec = vap->va_mtime.tv_nsec; 513 ip->i_d.di_mtime.t_nsec = iattr->ia_mtime.tv_nsec;
540 timeflags &= ~XFS_ICHGTIME_MOD; 514 timeflags &= ~XFS_ICHGTIME_MOD;
541 timeflags |= XFS_ICHGTIME_CHG; 515 timeflags |= XFS_ICHGTIME_CHG;
542 } 516 }
543 if (tp && (flags & ATTR_UTIME)) 517 if (tp && (mask & (ATTR_MTIME_SET|ATTR_ATIME_SET)))
544 xfs_trans_log_inode (tp, ip, XFS_ILOG_CORE); 518 xfs_trans_log_inode (tp, ip, XFS_ILOG_CORE);
545 } 519 }
546 520
547 /* 521 /*
548 * Change file inode change time only if XFS_AT_CTIME set 522 * Change file inode change time only if ATTR_CTIME set
549 * AND we have been called by a DMI function. 523 * AND we have been called by a DMI function.
550 */ 524 */
551 525
552 if ( (flags & ATTR_DMI) && (mask & XFS_AT_CTIME) ) { 526 if ((flags & XFS_ATTR_DMI) && (mask & ATTR_CTIME)) {
553 ip->i_d.di_ctime.t_sec = vap->va_ctime.tv_sec; 527 ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec;
554 ip->i_d.di_ctime.t_nsec = vap->va_ctime.tv_nsec; 528 ip->i_d.di_ctime.t_nsec = iattr->ia_ctime.tv_nsec;
555 ip->i_update_core = 1; 529 ip->i_update_core = 1;
556 timeflags &= ~XFS_ICHGTIME_CHG; 530 timeflags &= ~XFS_ICHGTIME_CHG;
557 } 531 }
@@ -560,7 +534,7 @@ xfs_setattr(
560 * Send out timestamp changes that need to be set to the 534 * Send out timestamp changes that need to be set to the
561 * current time. Not done when called by a DMI function. 535 * current time. Not done when called by a DMI function.
562 */ 536 */
563 if (timeflags && !(flags & ATTR_DMI)) 537 if (timeflags && !(flags & XFS_ATTR_DMI))
564 xfs_ichgtime(ip, timeflags); 538 xfs_ichgtime(ip, timeflags);
565 539
566 XFS_STATS_INC(xs_ig_attrchg); 540 XFS_STATS_INC(xs_ig_attrchg);
@@ -598,7 +572,7 @@ xfs_setattr(
598 } 572 }
599 573
600 if (DM_EVENT_ENABLED(ip, DM_EVENT_ATTRIBUTE) && 574 if (DM_EVENT_ENABLED(ip, DM_EVENT_ATTRIBUTE) &&
601 !(flags & ATTR_DMI)) { 575 !(flags & XFS_ATTR_DMI)) {
602 (void) XFS_SEND_NAMESP(mp, DM_EVENT_ATTRIBUTE, ip, DM_RIGHT_NULL, 576 (void) XFS_SEND_NAMESP(mp, DM_EVENT_ATTRIBUTE, ip, DM_RIGHT_NULL,
603 NULL, DM_RIGHT_NULL, NULL, NULL, 577 NULL, DM_RIGHT_NULL, NULL, NULL,
604 0, 0, AT_DELAY_FLAG(flags)); 578 0, 0, AT_DELAY_FLAG(flags));
@@ -3113,7 +3087,7 @@ xfs_alloc_file_space(
3113 3087
3114 /* Generate a DMAPI event if needed. */ 3088 /* Generate a DMAPI event if needed. */
3115 if (alloc_type != 0 && offset < ip->i_size && 3089 if (alloc_type != 0 && offset < ip->i_size &&
3116 (attr_flags&ATTR_DMI) == 0 && 3090 (attr_flags & XFS_ATTR_DMI) == 0 &&
3117 DM_EVENT_ENABLED(ip, DM_EVENT_WRITE)) { 3091 DM_EVENT_ENABLED(ip, DM_EVENT_WRITE)) {
3118 xfs_off_t end_dmi_offset; 3092 xfs_off_t end_dmi_offset;
3119 3093
@@ -3227,7 +3201,7 @@ retry:
3227 allocatesize_fsb -= allocated_fsb; 3201 allocatesize_fsb -= allocated_fsb;
3228 } 3202 }
3229dmapi_enospc_check: 3203dmapi_enospc_check:
3230 if (error == ENOSPC && (attr_flags & ATTR_DMI) == 0 && 3204 if (error == ENOSPC && (attr_flags & XFS_ATTR_DMI) == 0 &&
3231 DM_EVENT_ENABLED(ip, DM_EVENT_NOSPACE)) { 3205 DM_EVENT_ENABLED(ip, DM_EVENT_NOSPACE)) {
3232 error = XFS_SEND_NAMESP(mp, DM_EVENT_NOSPACE, 3206 error = XFS_SEND_NAMESP(mp, DM_EVENT_NOSPACE,
3233 ip, DM_RIGHT_NULL, 3207 ip, DM_RIGHT_NULL,
@@ -3374,7 +3348,7 @@ xfs_free_file_space(
3374 end_dmi_offset = offset + len; 3348 end_dmi_offset = offset + len;
3375 endoffset_fsb = XFS_B_TO_FSBT(mp, end_dmi_offset); 3349 endoffset_fsb = XFS_B_TO_FSBT(mp, end_dmi_offset);
3376 3350
3377 if (offset < ip->i_size && (attr_flags & ATTR_DMI) == 0 && 3351 if (offset < ip->i_size && (attr_flags & XFS_ATTR_DMI) == 0 &&
3378 DM_EVENT_ENABLED(ip, DM_EVENT_WRITE)) { 3352 DM_EVENT_ENABLED(ip, DM_EVENT_WRITE)) {
3379 if (end_dmi_offset > ip->i_size) 3353 if (end_dmi_offset > ip->i_size)
3380 end_dmi_offset = ip->i_size; 3354 end_dmi_offset = ip->i_size;
@@ -3385,7 +3359,7 @@ xfs_free_file_space(
3385 return error; 3359 return error;
3386 } 3360 }
3387 3361
3388 if (attr_flags & ATTR_NOLOCK) 3362 if (attr_flags & XFS_ATTR_NOLOCK)
3389 need_iolock = 0; 3363 need_iolock = 0;
3390 if (need_iolock) { 3364 if (need_iolock) {
3391 xfs_ilock(ip, XFS_IOLOCK_EXCL); 3365 xfs_ilock(ip, XFS_IOLOCK_EXCL);
@@ -3562,7 +3536,7 @@ xfs_change_file_space(
3562 xfs_off_t startoffset; 3536 xfs_off_t startoffset;
3563 xfs_off_t llen; 3537 xfs_off_t llen;
3564 xfs_trans_t *tp; 3538 xfs_trans_t *tp;
3565 bhv_vattr_t va; 3539 struct iattr iattr;
3566 3540
3567 xfs_itrace_entry(ip); 3541 xfs_itrace_entry(ip);
3568 3542
@@ -3636,10 +3610,10 @@ xfs_change_file_space(
3636 break; 3610 break;
3637 } 3611 }
3638 3612
3639 va.va_mask = XFS_AT_SIZE; 3613 iattr.ia_valid = ATTR_SIZE;
3640 va.va_size = startoffset; 3614 iattr.ia_size = startoffset;
3641 3615
3642 error = xfs_setattr(ip, &va, attr_flags, credp); 3616 error = xfs_setattr(ip, &iattr, attr_flags, credp);
3643 3617
3644 if (error) 3618 if (error)
3645 return error; 3619 return error;
@@ -3669,7 +3643,7 @@ xfs_change_file_space(
3669 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 3643 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
3670 xfs_trans_ihold(tp, ip); 3644 xfs_trans_ihold(tp, ip);
3671 3645
3672 if ((attr_flags & ATTR_DMI) == 0) { 3646 if ((attr_flags & XFS_ATTR_DMI) == 0) {
3673 ip->i_d.di_mode &= ~S_ISUID; 3647 ip->i_d.di_mode &= ~S_ISUID;
3674 3648
3675 /* 3649 /*
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h
index 454fa9a3e526..e932a96bec54 100644
--- a/fs/xfs/xfs_vnodeops.h
+++ b/fs/xfs/xfs_vnodeops.h
@@ -2,9 +2,9 @@
2#define _XFS_VNODEOPS_H 1 2#define _XFS_VNODEOPS_H 1
3 3
4struct attrlist_cursor_kern; 4struct attrlist_cursor_kern;
5struct bhv_vattr;
6struct cred; 5struct cred;
7struct file; 6struct file;
7struct iattr;
8struct inode; 8struct inode;
9struct iovec; 9struct iovec;
10struct kiocb; 10struct kiocb;
@@ -15,8 +15,12 @@ struct xfs_iomap;
15 15
16 16
17int xfs_open(struct xfs_inode *ip); 17int xfs_open(struct xfs_inode *ip);
18int xfs_setattr(struct xfs_inode *ip, struct bhv_vattr *vap, int flags, 18int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags,
19 struct cred *credp); 19 struct cred *credp);
20#define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
21#define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
22#define XFS_ATTR_NOLOCK 0x04 /* Don't grab any conflicting locks */
23
20int xfs_readlink(struct xfs_inode *ip, char *link); 24int xfs_readlink(struct xfs_inode *ip, char *link);
21int xfs_fsync(struct xfs_inode *ip); 25int xfs_fsync(struct xfs_inode *ip);
22int xfs_release(struct xfs_inode *ip); 26int xfs_release(struct xfs_inode *ip);