From: Andrew Deason Date: Wed, 22 Feb 2012 21:36:37 +0000 (-0600) Subject: LINUX: move afs_notify_change to osi_vnodeops.c X-Git-Tag: upstream/1.6.1^2~7 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=81f8951118f135857eaf4429fec10ce0fcdb5d24;p=packages%2Fo%2Fopenafs.git LINUX: move afs_notify_change to osi_vnodeops.c afs_notify_change is almost always used solely in inode_operations structs, and is more similar to the other per-vnode functions. Put it with the other per-vnode functions for better organization, and so they can use the same static functions. Move the helper functions iattr2vattr and vattr2inode along with it. Reviewed-on: http://gerrit.openafs.org/6775 Reviewed-by: Derrick Brashear Tested-by: BuildBot (cherry picked from commit 620d4169b73088579e691aec2cfdafc7f44e2fee) Reviewed-on: http://gerrit.openafs.org/6917 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit b44bb369dedd979b22d3cdbcc49208620c17daaf) Change-Id: I64c6e9a8bc15e05de9152d2ff7cca1240074d7a7 Reviewed-on: http://gerrit.openafs.org/6934 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index 0aa9d2fbb..a6be1b3ef 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -39,7 +39,6 @@ extern struct afs_q VLRU; extern struct dentry_operations afs_dentry_operations; /* Forward declarations */ -static void iattr2vattr(struct vattr *vattrp, struct iattr *iattrp); static int afs_root(struct super_block *afsp); int afs_fill_super(struct super_block *sb, void *data, int silent); @@ -207,33 +206,6 @@ afs_root(struct super_block *afsp) /* super_operations */ -/* afs_notify_change - * Linux version of setattr call. What to change is in the iattr struct. - * We need to set bits in both the Linux inode as well as the vcache. - */ -int -afs_notify_change(struct dentry *dp, struct iattr *iattrp) -{ - struct vattr vattr; - cred_t *credp = crref(); - struct inode *ip = dp->d_inode; - int code; - - VATTR_NULL(&vattr); - iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ - - AFS_GLOCK(); - code = afs_setattr(VTOAFS(ip), &vattr, credp); - if (!code) { - afs_getattr(VTOAFS(ip), &vattr, credp); - vattr2inode(ip, &vattr); - } - AFS_GUNLOCK(); - crfree(credp); - return -code; -} - - #if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE) static afs_kmem_cache_t *afs_inode_cachep; @@ -405,70 +377,3 @@ struct super_operations afs_sops = { .put_super = afs_put_super, .statfs = afs_statfs, }; - -/************** Support routines ************************/ - -/* vattr_setattr - * Set iattr data into vattr. Assume vattr cleared before call. - */ -static void -iattr2vattr(struct vattr *vattrp, struct iattr *iattrp) -{ - vattrp->va_mask = iattrp->ia_valid; - if (iattrp->ia_valid & ATTR_MODE) - vattrp->va_mode = iattrp->ia_mode; - if (iattrp->ia_valid & ATTR_UID) - vattrp->va_uid = iattrp->ia_uid; - if (iattrp->ia_valid & ATTR_GID) - vattrp->va_gid = iattrp->ia_gid; - if (iattrp->ia_valid & ATTR_SIZE) - vattrp->va_size = iattrp->ia_size; - if (iattrp->ia_valid & ATTR_ATIME) { - vattrp->va_atime.tv_sec = iattrp->ia_atime.tv_sec; - vattrp->va_atime.tv_usec = 0; - } - if (iattrp->ia_valid & ATTR_MTIME) { - vattrp->va_mtime.tv_sec = iattrp->ia_mtime.tv_sec; - vattrp->va_mtime.tv_usec = 0; - } - if (iattrp->ia_valid & ATTR_CTIME) { - vattrp->va_ctime.tv_sec = iattrp->ia_ctime.tv_sec; - vattrp->va_ctime.tv_usec = 0; - } -} - -/* vattr2inode - * Rewrite the inode cache from the attr. Assumes all vattr fields are valid. - */ -void -vattr2inode(struct inode *ip, struct vattr *vp) -{ - ip->i_ino = vp->va_nodeid; -#ifdef HAVE_LINUX_SET_NLINK - set_nlink(ip, vp->va_nlink); -#else - ip->i_nlink = vp->va_nlink; -#endif - ip->i_blocks = vp->va_blocks; -#ifdef STRUCT_INODE_HAS_I_BLKBITS - ip->i_blkbits = AFS_BLKBITS; -#endif -#ifdef STRUCT_INODE_HAS_I_BLKSIZE - ip->i_blksize = vp->va_blocksize; -#endif - ip->i_rdev = vp->va_rdev; - ip->i_mode = vp->va_mode; - ip->i_uid = vp->va_uid; - ip->i_gid = vp->va_gid; - i_size_write(ip, vp->va_size); - ip->i_atime.tv_sec = vp->va_atime.tv_sec; - ip->i_atime.tv_nsec = 0; - ip->i_mtime.tv_sec = vp->va_mtime.tv_sec; - /* Set the mtime nanoseconds to the sysname generation number. - * This convinces NFS clients that all directories have changed - * any time the sysname list changes. - */ - ip->i_mtime.tv_nsec = afs_sysnamegen; - ip->i_ctime.tv_sec = vp->va_ctime.tv_sec; - ip->i_ctime.tv_nsec = 0; -} diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 2d9eb8e11..93ea124c0 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -49,7 +49,6 @@ extern struct backing_dev_info *afs_backing_dev_info; extern struct vcache *afs_globalVp; -extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp); /* This function converts a positive error code from AFS into a negative * code suitable for passing into the Linux VFS layer. It checks that the @@ -798,6 +797,97 @@ afs_linux_revalidate(struct dentry *dp) return afs_convert_code(code); } +/* vattr_setattr + * Set iattr data into vattr. Assume vattr cleared before call. + */ +static void +iattr2vattr(struct vattr *vattrp, struct iattr *iattrp) +{ + vattrp->va_mask = iattrp->ia_valid; + if (iattrp->ia_valid & ATTR_MODE) + vattrp->va_mode = iattrp->ia_mode; + if (iattrp->ia_valid & ATTR_UID) + vattrp->va_uid = iattrp->ia_uid; + if (iattrp->ia_valid & ATTR_GID) + vattrp->va_gid = iattrp->ia_gid; + if (iattrp->ia_valid & ATTR_SIZE) + vattrp->va_size = iattrp->ia_size; + if (iattrp->ia_valid & ATTR_ATIME) { + vattrp->va_atime.tv_sec = iattrp->ia_atime.tv_sec; + vattrp->va_atime.tv_usec = 0; + } + if (iattrp->ia_valid & ATTR_MTIME) { + vattrp->va_mtime.tv_sec = iattrp->ia_mtime.tv_sec; + vattrp->va_mtime.tv_usec = 0; + } + if (iattrp->ia_valid & ATTR_CTIME) { + vattrp->va_ctime.tv_sec = iattrp->ia_ctime.tv_sec; + vattrp->va_ctime.tv_usec = 0; + } +} + +/* vattr2inode + * Rewrite the inode cache from the attr. Assumes all vattr fields are valid. + */ +void +vattr2inode(struct inode *ip, struct vattr *vp) +{ + ip->i_ino = vp->va_nodeid; +#ifdef HAVE_LINUX_SET_NLINK + set_nlink(ip, vp->va_nlink); +#else + ip->i_nlink = vp->va_nlink; +#endif + ip->i_blocks = vp->va_blocks; +#ifdef STRUCT_INODE_HAS_I_BLKBITS + ip->i_blkbits = AFS_BLKBITS; +#endif +#ifdef STRUCT_INODE_HAS_I_BLKSIZE + ip->i_blksize = vp->va_blocksize; +#endif + ip->i_rdev = vp->va_rdev; + ip->i_mode = vp->va_mode; + ip->i_uid = vp->va_uid; + ip->i_gid = vp->va_gid; + i_size_write(ip, vp->va_size); + ip->i_atime.tv_sec = vp->va_atime.tv_sec; + ip->i_atime.tv_nsec = 0; + ip->i_mtime.tv_sec = vp->va_mtime.tv_sec; + /* Set the mtime nanoseconds to the sysname generation number. + * This convinces NFS clients that all directories have changed + * any time the sysname list changes. + */ + ip->i_mtime.tv_nsec = afs_sysnamegen; + ip->i_ctime.tv_sec = vp->va_ctime.tv_sec; + ip->i_ctime.tv_nsec = 0; +} + +/* afs_notify_change + * Linux version of setattr call. What to change is in the iattr struct. + * We need to set bits in both the Linux inode as well as the vcache. + */ +static int +afs_notify_change(struct dentry *dp, struct iattr *iattrp) +{ + struct vattr vattr; + cred_t *credp = crref(); + struct inode *ip = dp->d_inode; + int code; + + VATTR_NULL(&vattr); + iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ + + AFS_GLOCK(); + code = afs_setattr(VTOAFS(ip), &vattr, credp); + if (!code) { + afs_getattr(VTOAFS(ip), &vattr, credp); + vattr2inode(ip, &vattr); + } + AFS_GUNLOCK(); + crfree(credp); + return -code; +} + static int afs_linux_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { diff --git a/src/afs/LINUX24/osi_vfsops.c b/src/afs/LINUX24/osi_vfsops.c index 8b9cdea3d..77b821bb2 100644 --- a/src/afs/LINUX24/osi_vfsops.c +++ b/src/afs/LINUX24/osi_vfsops.c @@ -39,9 +39,9 @@ extern afs_rwlock_t afs_xvcache; extern struct afs_q VLRU; extern struct dentry_operations afs_dentry_operations; +extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp); /* Forward declarations */ -static void iattr2vattr(struct vattr *vattrp, struct iattr *iattrp); static int afs_root(struct super_block *afsp); struct super_block *afs_read_super(struct super_block *sb, void *data, int silent); int afs_fill_super(struct super_block *sb, void *data, int silent); @@ -175,33 +175,6 @@ afs_root(struct super_block *afsp) /* super_operations */ -/* afs_notify_change - * Linux version of setattr call. What to change is in the iattr struct. - * We need to set bits in both the Linux inode as well as the vcache. - */ -int -afs_notify_change(struct dentry *dp, struct iattr *iattrp) -{ - struct vattr vattr; - cred_t *credp = crref(); - struct inode *ip = dp->d_inode; - int code; - - VATTR_NULL(&vattr); - iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ - - AFS_GLOCK(); - code = afs_setattr(VTOAFS(ip), &vattr, credp); - if (!code) { - afs_getattr(VTOAFS(ip), &vattr, credp); - vattr2inode(ip, &vattr); - } - AFS_GUNLOCK(); - crfree(credp); - return -code; -} - - #if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE) #if defined(HAVE_KMEM_CACHE_T) static kmem_cache_t *afs_inode_cachep; @@ -395,59 +368,3 @@ struct super_operations afs_sops = { .notify_change = afs_notify_change, #endif }; - -/************** Support routines ************************/ - -/* vattr_setattr - * Set iattr data into vattr. Assume vattr cleared before call. - */ -static void -iattr2vattr(struct vattr *vattrp, struct iattr *iattrp) -{ - vattrp->va_mask = iattrp->ia_valid; - if (iattrp->ia_valid & ATTR_MODE) - vattrp->va_mode = iattrp->ia_mode; - if (iattrp->ia_valid & ATTR_UID) - vattrp->va_uid = iattrp->ia_uid; - if (iattrp->ia_valid & ATTR_GID) - vattrp->va_gid = iattrp->ia_gid; - if (iattrp->ia_valid & ATTR_SIZE) - vattrp->va_size = iattrp->ia_size; - if (iattrp->ia_valid & ATTR_ATIME) { - vattrp->va_atime.tv_sec = iattrp->ia_atime; - vattrp->va_atime.tv_usec = 0; - } - if (iattrp->ia_valid & ATTR_MTIME) { - vattrp->va_mtime.tv_sec = iattrp->ia_mtime; - vattrp->va_mtime.tv_usec = 0; - } - if (iattrp->ia_valid & ATTR_CTIME) { - vattrp->va_ctime.tv_sec = iattrp->ia_ctime; - vattrp->va_ctime.tv_usec = 0; - } -} - -/* vattr2inode - * Rewrite the inode cache from the attr. Assumes all vattr fields are valid. - */ -void -vattr2inode(struct inode *ip, struct vattr *vp) -{ - ip->i_ino = vp->va_nodeid; - ip->i_nlink = vp->va_nlink; - ip->i_blocks = vp->va_blocks; -#ifdef STRUCT_INODE_HAS_I_BLKBITS - ip->i_blkbits = AFS_BLKBITS; -#endif -#ifdef STRUCT_INODE_HAS_I_BLKSIZE - ip->i_blksize = vp->va_blocksize; -#endif - ip->i_rdev = vp->va_rdev; - ip->i_mode = vp->va_mode; - ip->i_uid = vp->va_uid; - ip->i_gid = vp->va_gid; - i_size_write(ip, vp->va_size); - ip->i_atime = vp->va_atime.tv_sec; - ip->i_mtime = vp->va_mtime.tv_sec; - ip->i_ctime = vp->va_ctime.tv_sec; -} diff --git a/src/afs/LINUX24/osi_vnodeops.c b/src/afs/LINUX24/osi_vnodeops.c index b5b025633..b4c938d06 100644 --- a/src/afs/LINUX24/osi_vnodeops.c +++ b/src/afs/LINUX24/osi_vnodeops.c @@ -47,7 +47,6 @@ #endif extern struct vcache *afs_globalVp; -extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp); #if defined(AFS_LINUX24_ENV) /* Some uses of BKL are perhaps not needed for bypass or memcache-- * why don't we try it out? */ @@ -886,6 +885,86 @@ afs_linux_revalidate(struct dentry *dp) return afs_convert_code(code); } +/* vattr_setattr + * Set iattr data into vattr. Assume vattr cleared before call. + */ +static void +iattr2vattr(struct vattr *vattrp, struct iattr *iattrp) +{ + vattrp->va_mask = iattrp->ia_valid; + if (iattrp->ia_valid & ATTR_MODE) + vattrp->va_mode = iattrp->ia_mode; + if (iattrp->ia_valid & ATTR_UID) + vattrp->va_uid = iattrp->ia_uid; + if (iattrp->ia_valid & ATTR_GID) + vattrp->va_gid = iattrp->ia_gid; + if (iattrp->ia_valid & ATTR_SIZE) + vattrp->va_size = iattrp->ia_size; + if (iattrp->ia_valid & ATTR_ATIME) { + vattrp->va_atime.tv_sec = iattrp->ia_atime; + vattrp->va_atime.tv_usec = 0; + } + if (iattrp->ia_valid & ATTR_MTIME) { + vattrp->va_mtime.tv_sec = iattrp->ia_mtime; + vattrp->va_mtime.tv_usec = 0; + } + if (iattrp->ia_valid & ATTR_CTIME) { + vattrp->va_ctime.tv_sec = iattrp->ia_ctime; + vattrp->va_ctime.tv_usec = 0; + } +} + +/* vattr2inode + * Rewrite the inode cache from the attr. Assumes all vattr fields are valid. + */ +void +vattr2inode(struct inode *ip, struct vattr *vp) +{ + ip->i_ino = vp->va_nodeid; + ip->i_nlink = vp->va_nlink; + ip->i_blocks = vp->va_blocks; +#ifdef STRUCT_INODE_HAS_I_BLKBITS + ip->i_blkbits = AFS_BLKBITS; +#endif +#ifdef STRUCT_INODE_HAS_I_BLKSIZE + ip->i_blksize = vp->va_blocksize; +#endif + ip->i_rdev = vp->va_rdev; + ip->i_mode = vp->va_mode; + ip->i_uid = vp->va_uid; + ip->i_gid = vp->va_gid; + i_size_write(ip, vp->va_size); + ip->i_atime = vp->va_atime.tv_sec; + ip->i_mtime = vp->va_mtime.tv_sec; + ip->i_ctime = vp->va_ctime.tv_sec; +} + +/* afs_notify_change + * Linux version of setattr call. What to change is in the iattr struct. + * We need to set bits in both the Linux inode as well as the vcache. + */ +int +afs_notify_change(struct dentry *dp, struct iattr *iattrp) +{ + struct vattr vattr; + cred_t *credp = crref(); + struct inode *ip = dp->d_inode; + int code; + + VATTR_NULL(&vattr); + iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ + + AFS_GLOCK(); + code = afs_setattr(VTOAFS(ip), &vattr, credp); + if (!code) { + afs_getattr(VTOAFS(ip), &vattr, credp); + vattr2inode(ip, &vattr); + } + AFS_GUNLOCK(); + crfree(credp); + return -code; +} + /* Validate a dentry. Return 1 if unchanged, 0 if VFS layer should re-evaluate. * In kernels 2.2.10 and above, we are passed an additional flags var which * may have either the LOOKUP_FOLLOW OR LOOKUP_DIRECTORY set in which case