kill vn_revalidate
PATCH 3/3 kill vn_revalidate
These days most of the attributes in struct inode are properly kept in sync by XFS. This patch removes the need for vn_revalidate completely by:
- keeping inode.i_flags uptodate after any flags are updated in xfs_ioctl_setattr
- keeping i_mode, i_uid and i_gid uptodate in xfs_setattr
fs/xfs/dmapi/xfs_dm.c +1 -5
@@ -2663,7 +2663,6 @@ xfs_dm_set_fileattr( {dm_fileattr_t stat;struct iattr iattr; -int error;/* Returns negative errors to DMAPI */
@@ -2718,10 +2717,7 @@ xfs_dm_set_fileattr( iattr.ia_size = stat.fa_size; } - error =xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); -if (!error) -vn_revalidate (vn_from_inode (inode));/* update Linux inode flags */ -return (-error);/* Return negative error to DMAPI */ +return -xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); }
fs/xfs/linux-2.6/xfs_acl.c +0 -1
@@ -278,7 +278,6 @@ xfs_set_mode(struct inode *inode, mode_t iattr.ia_mode = mode; error = -xfs_setattr (XFS_I (inode), &iattr,0 , sys_cred); - inode->i_mode = mode; }return error;
fs/xfs/linux-2.6/xfs_ioctl.c +27 -2
@@ -919,6 +919,30 @@ xfs_set_diflags( ip->i_d.di_flags = di_flags; } +STATIC void +xfs_diflags_to_linux ( +struct xfs_inode *ip) +{ +struct inode *inode =XFS_ITOV (ip); +unsigned int xflags =xfs_ip2xflags (ip); + +if (xflags &XFS_XFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (xflags &XFS_XFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (xflags &XFS_XFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (xflags &XFS_XFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +}#define FSX_PROJID 1#define FSX_EXTSIZE 2
@@ -1117,8 +1141,10 @@ xfs_ioctl_setattr(if (mask &FSX_EXTSIZE ) ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog; -if (mask &FSX_XFLAGS ) +if (mask &FSX_XFLAGS ) {xfs_set_diflags (ip, fa->fsx_xflags); +xfs_diflags_to_linux (ip); + }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );xfs_ichgtime (ip,XFS_ICHGTIME_CHG );
@@ -1156,7 +1182,6 @@ xfs_ioctl_setattr( (mask & FSX_NONBLOCK) ? DM_FLAGS_NDELAY : 0); } -vn_revalidate (XFS_ITOV (ip));/* update flags */ return 0 ; error_return:
fs/xfs/linux-2.6/xfs_iops.c +0 -11
@@ -624,18 +624,7 @@ xfs_vn_setattr(struct inode *inode = dentry->d_inode;int error; -if (iattr->ia_valid &ATTR_ATIME ) - inode->i_atime = iattr->ia_atime; - -if (iattr->ia_valid &ATTR_MODE ) { -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) - inode->i_mode &= ~S_ISGID ; - } - error =xfs_setattr (XFS_I (inode), iattr,0 ,NULL ); -if (likely (!error)) -vn_revalidate (vn_from_inode (inode)); -if (!error && (iattr->ia_valid &ATTR_MODE )) error = -xfs_acl_chmod (inode);return -error;
fs/xfs/linux-2.6/xfs_ksyms.c +0 -1
@@ -175,7 +175,6 @@ EXPORT_SYMBOL(uuid_hash64);EXPORT_SYMBOL (uuid_is_nil);EXPORT_SYMBOL (uuid_table_remove);EXPORT_SYMBOL (vn_hold); -EXPORT_SYMBOL (vn_revalidate);EXPORT_SYMBOL (xfs_alloc_buftarg);EXPORT_SYMBOL (xfs_flush_buftarg);
fs/xfs/linux-2.6/xfs_vnode.c +0 -50
56 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_vnode.h +0 -1
@@ -67,7 +67,6 @@ static inline struct inode *vn_to_inode(extern void vn_init (void ); -extern int vn_revalidate (bhv_vnode_t *);/* * Yeah, these don't take vnode anymore at all, all this should be
fs/xfs/xfs_vnodeops.c +9 -0
@@ -83,6 +83,7 @@ xfs_setattr( cred_t *credp) {xfs_mount_t *mp = ip->i_mount; +struct inode *inode =XFS_ITOV (ip);int mask = iattr->ia_valid;xfs_trans_t *tp;int code;
@@ -446,6 +447,9 @@ xfs_setattr( ip->i_d.di_mode &=S_IFMT ; ip->i_d.di_mode |= iattr->ia_mode & ~S_IFMT ; + inode->i_mode &=S_IFMT ; + inode->i_mode |= iattr->ia_mode & ~S_IFMT ; +xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); timeflags |=XFS_ICHGTIME_CHG ; }
@@ -481,6 +485,7 @@ xfs_setattr( &ip->i_udquot, udqp); } ip->i_d.di_uid = uid; + inode->i_uid = uid; }if (igid != gid) {if (XFS_IS_GQUOTA_ON (mp)) {
@@ -491,6 +496,7 @@ xfs_setattr( &ip->i_gdquot, gdqp); } ip->i_d.di_gid = gid; + inode->i_gid = gid; }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );
@@ -503,12 +509,14 @@ xfs_setattr(*/ if (mask & (ATTR_ATIME |ATTR_MTIME )) {if (mask &ATTR_ATIME ) { + inode->i_atime = iattr->ia_atime; ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec; ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec; ip->i_update_core =1 ; timeflags &= ~XFS_ICHGTIME_ACC ; }if (mask &ATTR_MTIME ) { + inode->i_mtime = iattr->ia_mtime; ip->i_d.di_mtime.t_sec = iattr->ia_mtime.tv_sec; ip->i_d.di_mtime.t_nsec = iattr->ia_mtime.tv_nsec; timeflags &= ~XFS_ICHGTIME_MOD ;
@@ -524,6 +532,7 @@ xfs_setattr(*/ if ((flags &XFS_ATTR_DMI ) && (mask &ATTR_CTIME )) { + inode->i_ctime = iattr->ia_ctime; ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec; ip->i_d.di_ctime.t_nsec = iattr->ia_ctime.tv_nsec; ip->i_update_core =1 ;
Quoted 7 lines · Christoph Hellwig
These days most of the attributes in struct inode are properly kept in sync by XFS. This patch removes the need for
vn_revalidatecompletely by:- keeping inode.i_flags uptodate after any flags are updated in
xfs_ioctl_setattr
- keepingi_mode,i_uidandi_giduptodate inxfs_setattr
Version that doesn't require the generic ACL patch below:
fs/xfs/dmapi/xfs_dm.c +1 -5
@@ -2665,7 +2665,6 @@ xfs_dm_set_fileattr( {dm_fileattr_t stat;struct iattr iattr; -int error;/* Returns negative errors to DMAPI */
@@ -2720,10 +2719,7 @@ xfs_dm_set_fileattr( iattr.ia_size = stat.fa_size; } - error =xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); -if (!error) -vn_revalidate (vn_from_inode (inode));/* update Linux inode flags */ -return (-error);/* Return negative error to DMAPI */ +return -xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); }
fs/xfs/linux-2.6/xfs_ioctl.c +27 -2
@@ -920,6 +920,30 @@ xfs_set_diflags( ip->i_d.di_flags = di_flags; } +STATIC void +xfs_diflags_to_linux ( +struct xfs_inode *ip) +{ +struct inode *inode =XFS_ITOV (ip); +unsigned int xflags =xfs_ip2xflags (ip); + +if (xflags &XFS_XFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (xflags &XFS_XFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (xflags &XFS_XFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (xflags &XFS_XFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +}#define FSX_PROJID 1#define FSX_EXTSIZE 2
@@ -1118,8 +1142,10 @@ xfs_ioctl_setattr(if (mask &FSX_EXTSIZE ) ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog; -if (mask &FSX_XFLAGS ) +if (mask &FSX_XFLAGS ) {xfs_set_diflags (ip, fa->fsx_xflags); +xfs_diflags_to_linux (ip); + }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );xfs_ichgtime (ip,XFS_ICHGTIME_CHG );
@@ -1157,7 +1183,6 @@ xfs_ioctl_setattr( (mask & FSX_NONBLOCK) ? DM_FLAGS_NDELAY : 0); } -vn_revalidate (XFS_ITOV (ip));/* update flags */ return 0 ; error_return:
fs/xfs/linux-2.6/xfs_iops.c +1 -15
@@ -658,21 +658,7 @@ xfs_vn_setattr(struct dentry *dentry, struct iattr *iattr) { - struct inode *inode = dentry->d_inode; -int error; - -if (iattr->ia_valid &ATTR_ATIME ) - inode->i_atime = iattr->ia_atime; - -if (iattr->ia_valid &ATTR_MODE ) { -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) - inode->i_mode &= ~S_ISGID ; - } - - error =xfs_setattr (XFS_I (inode), iattr,0 ,NULL ); -if (likely (!error)) -vn_revalidate (vn_from_inode (inode)); -return -error; + return -xfs_setattr(XFS_I(dentry->d_inode), iattr, 0, NULL); }/*
fs/xfs/linux-2.6/xfs_ksyms.c +0 -1
@@ -177,7 +177,6 @@ EXPORT_SYMBOL(uuid_hash64);EXPORT_SYMBOL (uuid_is_nil);EXPORT_SYMBOL (uuid_table_remove);EXPORT_SYMBOL (vn_hold); -EXPORT_SYMBOL (vn_revalidate);#if defined(CONFIG_XFS_POSIX_ACL )EXPORT_SYMBOL (xfs_acl_vtoacl);
fs/xfs/linux-2.6/xfs_vnode.c +0 -50
56 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_vnode.h +0 -1
@@ -67,7 +67,6 @@ static inline struct inode *vn_to_inode(extern void vn_init (void ); -extern int vn_revalidate (bhv_vnode_t *);/* * Yeah, these don't take vnode anymore at all, all this should be
fs/xfs/xfs_vnodeops.c +9 -0
@@ -83,6 +83,7 @@ xfs_setattr( cred_t *credp) {xfs_mount_t *mp = ip->i_mount; +struct inode *inode =XFS_ITOV (ip);int mask = iattr->ia_valid;xfs_trans_t *tp;int code;
@@ -446,6 +447,9 @@ xfs_setattr( ip->i_d.di_mode &=S_IFMT ; ip->i_d.di_mode |= iattr->ia_mode & ~S_IFMT ; + inode->i_mode &=S_IFMT ; + inode->i_mode |= iattr->ia_mode & ~S_IFMT ; +xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); timeflags |=XFS_ICHGTIME_CHG ; }
@@ -481,6 +485,7 @@ xfs_setattr( &ip->i_udquot, udqp); } ip->i_d.di_uid = uid; + inode->i_uid = uid; }if (igid != gid) {if (XFS_IS_GQUOTA_ON (mp)) {
@@ -491,6 +496,7 @@ xfs_setattr( &ip->i_gdquot, gdqp); } ip->i_d.di_gid = gid; + inode->i_gid = gid; }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );
@@ -503,12 +509,14 @@ xfs_setattr(*/ if (mask & (ATTR_ATIME |ATTR_MTIME )) {if (mask &ATTR_ATIME ) { + inode->i_atime = iattr->ia_atime; ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec; ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec; ip->i_update_core =1 ; timeflags &= ~XFS_ICHGTIME_ACC ; }if (mask &ATTR_MTIME ) { + inode->i_mtime = iattr->ia_mtime; ip->i_d.di_mtime.t_sec = iattr->ia_mtime.tv_sec; ip->i_d.di_mtime.t_nsec = iattr->ia_mtime.tv_nsec; timeflags &= ~XFS_ICHGTIME_MOD ;
@@ -524,6 +532,7 @@ xfs_setattr(*/ if ((flags &XFS_ATTR_DMI ) && (mask &ATTR_CTIME )) { + inode->i_ctime = iattr->ia_ctime; ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec; ip->i_d.di_ctime.t_nsec = iattr->ia_ctime.tv_nsec; ip->i_update_core =1 ;
fs/xfs/linux-2.6/xfs_xattr.c +2 -5
@@ -64,7 +64,7 @@ static int xfs_xattr_system_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { - int error, acl; + int acl; acl =xfs_decode_acl (name);if (acl <0 )
@@ -75,10 +75,7 @@ xfs_xattr_system_set(struct inode *inodeif (!value)return xfs_acl_vremove (inode, acl); - error =xfs_acl_vset (inode, (void *)value, size, acl); -if (!error) -vn_revalidate (inode); -return error; +return xfs_acl_vset (inode, (void *)value, size, acl); }static struct xattr_handler xfs_xattr_system_handler = {
fs/xfs/xfs_acl.c +1 -1
@@ -734,7 +734,7 @@ xfs_acl_setmode(* Copy the u::, g::, o::, and m:: bits from the ACL into the * mode. The m:: bits take precedence over the g:: bits. */ - iattr.ia_mask =XFS_AT_MODE ; + iattr.ia_valid =ATTR_MODE ; iattr.ia_mode =xfs_vtoi (vp)->i_d.di_mode; iattr.ia_mode &= ~(S_IRWXU |S_IRWXG |S_IRWXO ); ap = acl->acl_entry;
Hi,
Looks reasonable.
Looking at changes...
* remove calls to vn_revalidate from:
-> xfs_ioctl_setattr (but call xfs_diflags_to_linux(ip) for FSX_XFLAGS instead
which is the relevant bit of vn_revalidate)
-> xfs_dm_set_fileattr (after call to xfs_setattr)
-> xfs_vn_setattr (after call to xfs_setattr)
-> xfs_xattr_system_set
(after call to xfs_acl_vset -> xfs_acl_setmode -> xfs_setattr)
So we now do inode field sets in xfs_setattr instead of waiting until after calling xfs_setattr (either directly or indirectly) to get vn_revalidate to set the inode fields. Okay.
* in xfs_setattr we now explicitly set for linux inode:i_mode, i_uid, i_gid, i_atime, i_mtime, i_ctime
It looks like we didn't set i_atime in vn_revalidate previously.
This change looks weird:
fs/xfs/xfs_acl.c xfs_acl_setmode( · line 738
Quoted 4 lines
fs/xfs/xfs_acl.c +1
-1*/ - iattr.ia_mask =XFS_AT_MODE ; + iattr.ia_valid =ATTR_MODE ; iattr.ia_mode =xfs_vtoi (vp)->i_d.di_mode;
I didn't think there was an ia_mask field - was this really from another patch? Confused.
--Tim
Quoted 305 lines · Christoph Hellwig
Quoted 7 lines · Christoph Hellwig
These days most of the attributes in struct inode are properly kept in sync by XFS. This patch removes the need for
vn_revalidatecompletely by:- keeping inode.i_flags uptodate after any flags are updated in
xfs_ioctl_setattr
- keepingi_mode,i_uidandi_giduptodate inxfs_setattrVersion that doesn't require the generic ACL patch below:
Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6-xfs/fs/xfs/dmapi/xfs_dm.c
===================================================================fs/xfs/dmapi/xfs_dm.c +1
-5@@ -2665,7 +2665,6 @@ xfs_dm_set_fileattr( {dm_fileattr_t stat;struct iattr iattr; -int error;/* Returns negative errors to DMAPI */ @@ -2720,10 +2719,7 @@ xfs_dm_set_fileattr( iattr.ia_size = stat.fa_size; } - error =xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); -if (!error) -vn_revalidate (vn_from_inode (inode));/* update Linux inode flags */ -return (-error);/* Return negative error to DMAPI */ +return -xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); }Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ioctl.c
===================================================================fs/xfs/linux-2.6/xfs_ioctl.c +27
-2@@ -920,6 +920,30 @@ xfs_set_diflags( ip->i_d.di_flags = di_flags; } +STATIC void +xfs_diflags_to_linux ( +struct xfs_inode *ip) +{ +struct inode *inode =XFS_ITOV (ip); +unsigned int xflags =xfs_ip2xflags (ip); + +if (xflags &XFS_XFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (xflags &XFS_XFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (xflags &XFS_XFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (xflags &XFS_XFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +}#define FSX_PROJID 1#define FSX_EXTSIZE 2@@ -1118,8 +1142,10 @@ xfs_ioctl_setattr(if (mask &FSX_EXTSIZE ) ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog; -if (mask &FSX_XFLAGS ) +if (mask &FSX_XFLAGS ) {xfs_set_diflags (ip, fa->fsx_xflags); +xfs_diflags_to_linux (ip); + }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );xfs_ichgtime (ip,XFS_ICHGTIME_CHG );@@ -1157,7 +1183,6 @@ xfs_ioctl_setattr( (mask & FSX_NONBLOCK) ? DM_FLAGS_NDELAY : 0); } -vn_revalidate (XFS_ITOV (ip));/* update flags */ return 0 ; error_return:Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================fs/xfs/linux-2.6/xfs_iops.c +1
-15@@ -658,21 +658,7 @@ xfs_vn_setattr(struct dentry *dentry, struct iattr *iattr) { - struct inode *inode = dentry->d_inode; -int error; - -if (iattr->ia_valid &ATTR_ATIME ) - inode->i_atime = iattr->ia_atime; - -if (iattr->ia_valid &ATTR_MODE ) { -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) - inode->i_mode &= ~S_ISGID ; - } - - error =xfs_setattr (XFS_I (inode), iattr,0 ,NULL ); -if (likely (!error)) -vn_revalidate (vn_from_inode (inode)); -return -error; + return -xfs_setattr(XFS_I(dentry->d_inode), iattr, 0, NULL); }/* Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================fs/xfs/linux-2.6/xfs_ksyms.c +0
-1@@ -177,7 +177,6 @@ EXPORT_SYMBOL(uuid_hash64);EXPORT_SYMBOL (uuid_is_nil);EXPORT_SYMBOL (uuid_table_remove);EXPORT_SYMBOL (vn_hold); -EXPORT_SYMBOL (vn_revalidate);#if defined(CONFIG_XFS_POSIX_ACL )EXPORT_SYMBOL (xfs_acl_vtoacl);Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.c
===================================================================fs/xfs/linux-2.6/xfs_vnode.c +0
-50@@ -82,56 +82,6 @@ vn_ioerror(xfs_do_force_shutdown (ip->i_mount,SHUTDOWN_DEVICE_REQ , f, l); } -/* -* Revalidate the Linux inode from the XFS inode. -* Note: i_size _not_ updated; we must hold the inode -* semaphore when doing that - callers responsibility. -*/ -int -vn_revalidate ( -bhv_vnode_t *vp) -{ -struct inode *inode =vn_to_inode (vp); -struct xfs_inode *ip =XFS_I (inode); -struct xfs_mount *mp = ip->i_mount; -unsigned long xflags; - -xfs_itrace_entry (ip); - -if (XFS_FORCED_SHUTDOWN (mp)) -return -EIO ; - -xfs_ilock (ip,XFS_ILOCK_SHARED ); - inode->i_mode = ip->i_d.di_mode; - inode->i_uid = ip->i_d.di_uid; - inode->i_gid = ip->i_d.di_gid; - inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec; - inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec; - inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec; - inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec; - - xflags =xfs_ip2xflags (ip); -if (xflags &XFS_XFLAG_IMMUTABLE ) - inode->i_flags |=S_IMMUTABLE ; -else - inode->i_flags &= ~S_IMMUTABLE ; -if (xflags &XFS_XFLAG_APPEND ) - inode->i_flags |=S_APPEND ; -else - inode->i_flags &= ~S_APPEND ; -if (xflags &XFS_XFLAG_SYNC ) - inode->i_flags |=S_SYNC ; -else - inode->i_flags &= ~S_SYNC ; -if (xflags &XFS_XFLAG_NOATIME ) - inode->i_flags |=S_NOATIME ; -else - inode->i_flags &= ~S_NOATIME ; -xfs_iunlock (ip,XFS_ILOCK_SHARED ); - -xfs_iflags_clear (ip,XFS_IMODIFIED ); -return 0 ; -}/* * Add a reference to a referenced vnode. Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.h
===================================================================fs/xfs/linux-2.6/xfs_vnode.h +0
-1@@ -67,7 +67,6 @@ static inline struct inode *vn_to_inode(extern void vn_init (void ); -extern int vn_revalidate (bhv_vnode_t *);/* * Yeah, these don't take vnode anymore at all, all this should be Index:
linux-2.6-xfs/fs/xfs/xfs_vnodeops.c
===================================================================fs/xfs/xfs_vnodeops.c +9
-0@@ -83,6 +83,7 @@ xfs_setattr( cred_t *credp) {xfs_mount_t *mp = ip->i_mount; +struct inode *inode =XFS_ITOV (ip);int mask = iattr->ia_valid;xfs_trans_t *tp;int code;@@ -446,6 +447,9 @@ xfs_setattr( ip->i_d.di_mode &=S_IFMT ; ip->i_d.di_mode |= iattr->ia_mode & ~S_IFMT ; + inode->i_mode &=S_IFMT ; + inode->i_mode |= iattr->ia_mode & ~S_IFMT ; +xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); timeflags |=XFS_ICHGTIME_CHG ; }@@ -481,6 +485,7 @@ xfs_setattr( &ip->i_udquot, udqp); } ip->i_d.di_uid = uid; + inode->i_uid = uid; }if (igid != gid) {if (XFS_IS_GQUOTA_ON (mp)) {@@ -491,6 +496,7 @@ xfs_setattr( &ip->i_gdquot, gdqp); } ip->i_d.di_gid = gid; + inode->i_gid = gid; }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );@@ -503,12 +509,14 @@ xfs_setattr(*/ if (mask & (ATTR_ATIME |ATTR_MTIME )) {if (mask &ATTR_ATIME ) { + inode->i_atime = iattr->ia_atime; ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec; ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec; ip->i_update_core =1 ; timeflags &= ~XFS_ICHGTIME_ACC ; }if (mask &ATTR_MTIME ) { + inode->i_mtime = iattr->ia_mtime; ip->i_d.di_mtime.t_sec = iattr->ia_mtime.tv_sec; ip->i_d.di_mtime.t_nsec = iattr->ia_mtime.tv_nsec; timeflags &= ~XFS_ICHGTIME_MOD ;@@ -524,6 +532,7 @@ xfs_setattr(*/ if ((flags &XFS_ATTR_DMI ) && (mask &ATTR_CTIME )) { + inode->i_ctime = iattr->ia_ctime; ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec; ip->i_d.di_ctime.t_nsec = iattr->ia_ctime.tv_nsec; ip->i_update_core =1 ;Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_xattr.c
===================================================================fs/xfs/linux-2.6/xfs_xattr.c +2
-5@@ -64,7 +64,7 @@ static int xfs_xattr_system_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { - int error, acl; + int acl; acl =xfs_decode_acl (name);if (acl <0 )@@ -75,10 +75,7 @@ xfs_xattr_system_set(struct inode *inodeif (!value)return xfs_acl_vremove (inode, acl); - error =xfs_acl_vset (inode, (void *)value, size, acl); -if (!error) -vn_revalidate (inode); -return error; +return xfs_acl_vset (inode, (void *)value, size, acl); }static struct xattr_handler xfs_xattr_system_handler = {Index:
linux-2.6-xfs/fs/xfs/xfs_acl.c
===================================================================fs/xfs/xfs_acl.c +1
-1@@ -734,7 +734,7 @@ xfs_acl_setmode(* Copy the u::, g::, o::, and m:: bits from the ACL into the * mode. The m:: bits take precedence over the g:: bits. */ - iattr.ia_mask =XFS_AT_MODE ; + iattr.ia_valid =ATTR_MODE ; iattr.ia_mode =xfs_vtoi (vp)->i_d.di_mode; iattr.ia_mode &= ~(S_IRWXU |S_IRWXG |S_IRWXO ); ap = acl->acl_entry;
Quoted 3 lines · Timothy Shimmin
* in
xfs_setattrwe now explicitly set for linux inode:i_mode,i_uid,i_gid,i_atime,i_mtime,i_ctime
It looks like we didn't seti_atimeinvn_revalidatepreviously.
That was intentional because the VFS updates this one directly and we already must only update it from setattr.
Quoted 8 lines
This change looks weird:
Review
Quoted 4 lines
(quoted diff) +1
-1*/ - iattr.ia_mask = XFS_AT_MODE; + iattr.ia_valid = ATTR_MODE; iattr.ia_mode = xfs_vtoi(vp)->i_d.di_mode;I didn't think there was an
ia_maskfield - was this really from another patch? Confused.
That's because the previous patch did a botched bhv_vattr to iattr conversion and I only noticed this when compiling the second patch and accidentally fixed it there.
I've updated both patches to correct this and attached them.
fs/xfs/dmapi/xfs_dm.c +29 -28
@@ -2460,7 +2460,8 @@ xfs_dm_punch_hole(#endif error =xfs_change_file_space (ip,XFS_IOC_UNRESVSP , &bf, - (xfs_off_t )off, sys_cred,ATTR_DMI |ATTR_NOLOCK ); + (xfs_off_t )off, sys_cred, +XFS_ATTR_DMI |XFS_ATTR_NOLOCK );/* * if punching to end of file, kill any blocks past EOF that
@@ -2663,7 +2664,7 @@ xfs_dm_set_fileattr( dm_fileattr_t __user *statp) {dm_fileattr_t stat; -bhv_vattr_t vat; +struct iattr iattr;int error;/* Returns negative errors to DMAPI */
@@ -2674,52 +2675,52 @@ xfs_dm_set_fileattr(if (copy_from_user ( &stat, statp,sizeof (stat)))return (-EFAULT ); - vat.va_mask =0 ; + iattr.ia_valid =0 ;if (mask &DM_AT_MODE ) { - vat.va_mask |=XFS_AT_MODE ; - vat.va_mode = stat.fa_mode; + iattr.ia_valid |=ATTR_MODE ; + iattr.ia_mode = stat.fa_mode; }if (mask &DM_AT_UID ) { - vat.va_mask |=XFS_AT_UID ; - vat.va_uid = stat.fa_uid; + iattr.ia_valid |=ATTR_UID ; + iattr.ia_uid = stat.fa_uid; }if (mask &DM_AT_GID ) { - vat.va_mask |=XFS_AT_GID ; - vat.va_gid = stat.fa_gid; + iattr.ia_valid |=ATTR_GID ; + iattr.ia_gid = stat.fa_gid; }if (mask &DM_AT_ATIME ) { - vat.va_mask |=XFS_AT_ATIME ; - vat.va_atime.tv_sec = stat.fa_atime; - vat.va_atime.tv_nsec =0 ; + iattr.ia_valid |=ATTR_ATIME ; + iattr.ia_atime.tv_sec = stat.fa_atime; + iattr.ia_atime.tv_nsec =0 ; inode->i_atime.tv_sec = stat.fa_atime; }if (mask &DM_AT_MTIME ) { - vat.va_mask |=XFS_AT_MTIME ; - vat.va_mtime.tv_sec = stat.fa_mtime; - vat.va_mtime.tv_nsec =0 ; + iattr.ia_valid |=ATTR_MTIME ; + iattr.ia_mtime.tv_sec = stat.fa_mtime; + iattr.ia_mtime.tv_nsec =0 ; }if (mask &DM_AT_CTIME ) { - vat.va_mask |=XFS_AT_CTIME ; - vat.va_ctime.tv_sec = stat.fa_ctime; - vat.va_ctime.tv_nsec =0 ; + iattr.ia_valid |=ATTR_CTIME ; + iattr.ia_ctime.tv_sec = stat.fa_ctime; + iattr.ia_ctime.tv_nsec =0 ; } -/* DM_AT_DTIME only takes effect if DM_AT_CTIME is not specified. We -overload ctime to also act as dtime, i.e. DM_CONFIG_DTIME_OVERLOAD. -*/ - +/* +* DM_AT_DTIME only takes effect if DM_AT_CTIME is not specified. We +* overload ctime to also act as dtime, i.e. DM_CONFIG_DTIME_OVERLOAD. +*/ if ((mask &DM_AT_DTIME ) && !(mask &DM_AT_CTIME )) { - vat.va_mask |=XFS_AT_CTIME ; - vat.va_ctime.tv_sec = stat.fa_dtime; - vat.va_ctime.tv_nsec =0 ; + iattr.ia_valid |=ATTR_CTIME ; + iattr.ia_ctime.tv_sec = stat.fa_dtime; + iattr.ia_ctime.tv_nsec =0 ; }if (mask &DM_AT_SIZE ) { - vat.va_mask |=XFS_AT_SIZE ; - vat.va_size = stat.fa_size; + iattr.ia_valid |=ATTR_SIZE ; + iattr.ia_size = stat.fa_size; } - error =xfs_setattr (XFS_I (inode), &vat,ATTR_DMI ,NULL ); + error =xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL );if (!error)vn_revalidate (vn_from_inode (inode));/* update Linux inode flags */ return (-error);/* Return negative error to DMAPI */
fs/xfs/linux-2.6/xfs_iops.c +11 -45
83 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_vnode.h +0 -73
91 lines not on this page · raw message
fs/xfs/xfs_vnodeops.c +73 -99
422 lines not on this page · raw message
fs/xfs/xfs_vnodeops.h +6 -2
@@ -2,9 +2,9 @@#define _XFS_VNODEOPS_H 1struct attrlist_cursor_kern ; -struct bhv_vattr ;struct cred ;struct file ; +struct iattr ;struct inode ;struct iovec ;struct kiocb ;
@@ -15,8 +15,12 @@ struct xfs_iomap;int xfs_open (struct xfs_inode *ip); -int xfs_setattr (struct xfs_inode *ip,struct bhv_vattr *vap,int flags, +int xfs_setattr (struct xfs_inode *ip,struct iattr *vap,int flags,struct cred *credp); +#define XFS_ATTR_DMI 0x01/* invocation from a DMI function */ +#define XFS_ATTR_NONBLOCK 0x02/* return EAGAIN if operation would block */ +#define XFS_ATTR_NOLOCK 0x04/* Don't grab any conflicting locks */ +int xfs_readlink (struct xfs_inode *ip,char *link);int xfs_fsync (struct xfs_inode *ip);int xfs_release (struct xfs_inode *ip);
fs/xfs/linux-2.6/xfs_ioctl.c +2 -2
@@ -685,9 +685,9 @@ xfs_ioc_space(return -XFS_ERROR (EFAULT );if (filp->f_flags & (O_NDELAY |O_NONBLOCK )) - attr_flags |=ATTR_NONBLOCK ; + attr_flags |=XFS_ATTR_NONBLOCK ;if (ioflags &IO_INVIS ) - attr_flags |=ATTR_DMI ; + attr_flags |=XFS_ATTR_DMI ; error =xfs_change_file_space (ip, cmd, &bf, filp->f_pos,NULL , attr_flags);
fs/xfs/xfs_dmapi.h +1 -1
@@ -166,6 +166,6 @@ typedef enum {#define FILP_DELAY_FLAG (filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \ DM_FLAGS_NDELAY : 0) -#define AT_DELAY_FLAG (f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0) +#define AT_DELAY_FLAG (f) ((f & XFS_ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)#endif /* __XFS_DMAPI_H__ */
fs/xfs/xfs_acl.c +9 -9
@@ -720,7 +720,7 @@ xfs_acl_setmode( xfs_acl_t *acl, int *basicperms) { -bhv_vattr_t va; +struct iattr iattr;xfs_acl_entry_t *ap;xfs_acl_entry_t *gap =NULL ;int i, nomask =1 ;
@@ -734,25 +734,25 @@ xfs_acl_setmode(* Copy the u::, g::, o::, and m:: bits from the ACL into the * mode. The m:: bits take precedence over the g:: bits. */ - va.va_mask =XFS_AT_MODE ; - va.va_mode =xfs_vtoi (vp)->i_d.di_mode; - va.va_mode &= ~(S_IRWXU |S_IRWXG |S_IRWXO ); + iattr.ia_valid =ATTR_MODE ; + iattr.ia_mode =xfs_vtoi (vp)->i_d.di_mode; + iattr.ia_mode &= ~(S_IRWXU |S_IRWXG |S_IRWXO ); ap = acl->acl_entry;for (i =0 ; i < acl->acl_cnt; ++i) {switch (ap->ae_tag) {case ACL_USER_OBJ : - va.va_mode |= ap->ae_perm <<6 ; + iattr.ia_mode |= ap->ae_perm <<6 ;break ;case ACL_GROUP_OBJ : gap = ap;break ;case ACL_MASK :/* more than just standard modes */ nomask =0 ; - va.va_mode |= ap->ae_perm <<3 ; + iattr.ia_mode |= ap->ae_perm <<3 ; *basicperms =0 ;break ;case ACL_OTHER : - va.va_mode |= ap->ae_perm; + iattr.ia_mode |= ap->ae_perm;break ;default :/* more than just standard modes */ *basicperms =0 ;
@@ -763,9 +763,9 @@ xfs_acl_setmode(/* Set the group bits from ACL_GROUP_OBJ if there's no ACL_MASK */ if (gap && nomask) - va.va_mode |= gap->ae_perm <<3 ; + iattr.ia_mode |= gap->ae_perm <<3 ; -return xfs_setattr (xfs_vtoi (vp), &va,0 , sys_cred); +return xfs_setattr (xfs_vtoi (vp), &iattr,0 , sys_cred); }/*
fs/xfs/dmapi/xfs_dm.c +1 -5
@@ -2665,7 +2665,6 @@ xfs_dm_set_fileattr( {dm_fileattr_t stat;struct iattr iattr; -int error;/* Returns negative errors to DMAPI */
@@ -2720,10 +2719,7 @@ xfs_dm_set_fileattr( iattr.ia_size = stat.fa_size; } - error =xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); -if (!error) -vn_revalidate (vn_from_inode (inode));/* update Linux inode flags */ -return (-error);/* Return negative error to DMAPI */ +return -xfs_setattr (XFS_I (inode), &iattr,XFS_ATTR_DMI ,NULL ); }
fs/xfs/linux-2.6/xfs_ioctl.c +27 -2
@@ -920,6 +920,30 @@ xfs_set_diflags( ip->i_d.di_flags = di_flags; } +STATIC void +xfs_diflags_to_linux ( +struct xfs_inode *ip) +{ +struct inode *inode =XFS_ITOV (ip); +unsigned int xflags =xfs_ip2xflags (ip); + +if (xflags &XFS_XFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (xflags &XFS_XFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (xflags &XFS_XFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (xflags &XFS_XFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +}#define FSX_PROJID 1#define FSX_EXTSIZE 2
@@ -1118,8 +1142,10 @@ xfs_ioctl_setattr(if (mask &FSX_EXTSIZE ) ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog; -if (mask &FSX_XFLAGS ) +if (mask &FSX_XFLAGS ) {xfs_set_diflags (ip, fa->fsx_xflags); +xfs_diflags_to_linux (ip); + }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );xfs_ichgtime (ip,XFS_ICHGTIME_CHG );
@@ -1157,7 +1183,6 @@ xfs_ioctl_setattr( (mask & FSX_NONBLOCK) ? DM_FLAGS_NDELAY : 0); } -vn_revalidate (XFS_ITOV (ip));/* update flags */ return 0 ; error_return:
fs/xfs/linux-2.6/xfs_iops.c +1 -15
@@ -658,21 +658,7 @@ xfs_vn_setattr(struct dentry *dentry, struct iattr *iattr) { - struct inode *inode = dentry->d_inode; -int error; - -if (iattr->ia_valid &ATTR_ATIME ) - inode->i_atime = iattr->ia_atime; - -if (iattr->ia_valid &ATTR_MODE ) { -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) - inode->i_mode &= ~S_ISGID ; - } - - error =xfs_setattr (XFS_I (inode), iattr,0 ,NULL ); -if (likely (!error)) -vn_revalidate (vn_from_inode (inode)); -return -error; + return -xfs_setattr(XFS_I(dentry->d_inode), iattr, 0, NULL); }/*
fs/xfs/linux-2.6/xfs_ksyms.c +0 -1
@@ -177,7 +177,6 @@ EXPORT_SYMBOL(uuid_hash64);EXPORT_SYMBOL (uuid_is_nil);EXPORT_SYMBOL (uuid_table_remove);EXPORT_SYMBOL (vn_hold); -EXPORT_SYMBOL (vn_revalidate);#if defined(CONFIG_XFS_POSIX_ACL )EXPORT_SYMBOL (xfs_acl_vtoacl);
fs/xfs/linux-2.6/xfs_vnode.c +0 -50
56 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_vnode.h +0 -1
@@ -67,7 +67,6 @@ static inline struct inode *vn_to_inode(extern void vn_init (void ); -extern int vn_revalidate (bhv_vnode_t *);/* * Yeah, these don't take vnode anymore at all, all this should be
fs/xfs/xfs_vnodeops.c +9 -0
@@ -83,6 +83,7 @@ xfs_setattr( cred_t *credp) {xfs_mount_t *mp = ip->i_mount; +struct inode *inode =XFS_ITOV (ip);int mask = iattr->ia_valid;xfs_trans_t *tp;int code;
@@ -446,6 +447,9 @@ xfs_setattr( ip->i_d.di_mode &=S_IFMT ; ip->i_d.di_mode |= iattr->ia_mode & ~S_IFMT ; + inode->i_mode &=S_IFMT ; + inode->i_mode |= iattr->ia_mode & ~S_IFMT ; +xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); timeflags |=XFS_ICHGTIME_CHG ; }
@@ -481,6 +485,7 @@ xfs_setattr( &ip->i_udquot, udqp); } ip->i_d.di_uid = uid; + inode->i_uid = uid; }if (igid != gid) {if (XFS_IS_GQUOTA_ON (mp)) {
@@ -491,6 +496,7 @@ xfs_setattr( &ip->i_gdquot, gdqp); } ip->i_d.di_gid = gid; + inode->i_gid = gid; }xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );
@@ -503,12 +509,14 @@ xfs_setattr(*/ if (mask & (ATTR_ATIME |ATTR_MTIME )) {if (mask &ATTR_ATIME ) { + inode->i_atime = iattr->ia_atime; ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec; ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec; ip->i_update_core =1 ; timeflags &= ~XFS_ICHGTIME_ACC ; }if (mask &ATTR_MTIME ) { + inode->i_mtime = iattr->ia_mtime; ip->i_d.di_mtime.t_sec = iattr->ia_mtime.tv_sec; ip->i_d.di_mtime.t_nsec = iattr->ia_mtime.tv_nsec; timeflags &= ~XFS_ICHGTIME_MOD ;
@@ -524,6 +532,7 @@ xfs_setattr(*/ if ((flags &XFS_ATTR_DMI ) && (mask &ATTR_CTIME )) { + inode->i_ctime = iattr->ia_ctime; ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec; ip->i_d.di_ctime.t_nsec = iattr->ia_ctime.tv_nsec; ip->i_update_core =1 ;
fs/xfs/linux-2.6/xfs_xattr.c +2 -5
@@ -64,7 +64,7 @@ static int xfs_xattr_system_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { - int error, acl; + int acl; acl =xfs_decode_acl (name);if (acl <0 )
@@ -75,10 +75,7 @@ xfs_xattr_system_set(struct inode *inodeif (!value)return xfs_acl_vremove (inode, acl); - error =xfs_acl_vset (inode, (void *)value, size, acl); -if (!error) -vn_revalidate (inode); -return error; +return xfs_acl_vset (inode, (void *)value, size, acl); }static struct xattr_handler xfs_xattr_system_handler = {