sanitize xfs_initialize_vnode
PATCH 1/1 sanitize xfs_initialize_vnode
Sanitize setting up the Linux indode.
Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core now because that's the only place it needs to be done, xfs_initialize_vnode is renamed to xfs_setup_inode and loses all superflous paramaters. The check for I_NEW is removed because it always is true and the di_mode check moves into xfs_iget_core because it's only needed there.
xfs_set_inodeops and xfs_revalidate_inode are merged into xfs_setup_inode and the whole things is moved into xfs_iops.c where it belongs.
fs/xfs/linux-2.6/xfs_iops.c +95 -3
@@ -777,7 +777,7 @@ out_error:return error; } -const struct inode_operations xfs_inode_operations = { +static const struct inode_operations xfs_inode_operations = { .permission = xfs_vn_permission, .truncate = xfs_vn_truncate, .getattr = xfs_vn_getattr,
@@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_ .fallocate = xfs_vn_fallocate, }; -const struct inode_operations xfs_dir_inode_operations = { +static const struct inode_operations xfs_dir_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_lookup, .link = xfs_vn_link,
@@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_symlink_inode_operations = { +static const struct inode_operations xfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = xfs_vn_follow_link, .put_link = xfs_vn_put_link,
@@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin .removexattr = generic_removexattr, .listxattr = xfs_vn_listxattr, }; + +STATIC void +xfs_diflags_to_iflags ( +struct inode *inode, +struct xfs_inode *ip) +{ +if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +} + +/* +* Initialize the Linux inode, set up the operation vectors and +* unlock the inode. +* +* When reading existing inodes from disk this is called directly +* from xfs_iget, when creating a new inode it is called from +* xfs_ialloc after setting up the inode. +*/ +void +xfs_setup_inode ( +struct xfs_inode *ip) +{ +struct inode *inode = ip->i_vnode; + + inode->i_mode = ip->i_d.di_mode; + inode->i_nlink = ip->i_d.di_nlink; + inode->i_uid = ip->i_d.di_uid; + inode->i_gid = ip->i_d.di_gid; + +switch (inode->i_mode &S_IFMT ) { +case S_IFBLK : +case S_IFCHR : + inode->i_rdev = +MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , +sysv_minor (ip->i_df.if_u2.if_rdev)); +break ; +default : + inode->i_rdev =0 ; +break ; + } + + inode->i_generation = ip->i_d.di_gen; +i_size_write (inode, ip->i_d.di_size); + inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; + inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; + 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; +xfs_diflags_to_iflags (inode, ip); +xfs_iflags_clear (ip,XFS_IMODIFIED ); + +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &xfs_inode_operations; + inode->i_fop = &xfs_file_operations; + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +case S_IFDIR : + inode->i_op = &xfs_dir_inode_operations; + inode->i_fop = &xfs_dir_file_operations; +break ; +case S_IFLNK : + inode->i_op = &xfs_symlink_inode_operations; +if (!(ip->i_df.if_flags &XFS_IFINLINE )) + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +default : + inode->i_op = &xfs_inode_operations; +init_special_inode (inode, inode->i_mode, inode->i_rdev); +break ; + } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}
fs/xfs/linux-2.6/xfs_iops.h +3 -4
@@ -18,9 +18,7 @@#ifndef __XFS_IOPS_H__#define __XFS_IOPS_H__ -extern const struct inode_operations xfs_inode_operations; -extern const struct inode_operations xfs_dir_inode_operations; -extern const struct inode_operations xfs_symlink_inode_operations; +struct xfs_inode ;extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations;
@@ -28,10 +26,11 @@ extern const struct file_operations xfs_extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); -struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );extern void xfs_ichgtime_fast (struct xfs_inode *,struct inode *,int ); +extern void xfs_setup_inode (struct xfs_inode *); +#define xfs_vtoi (vp) \ ((struct xfs_inode *)vn_to_inode(vp)->i_private)
fs/xfs/linux-2.6/xfs_ksyms.c +0 -3
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);EXPORT_SYMBOL (kmem_zone_init);EXPORT_SYMBOL (kmem_zone_zalloc);EXPORT_SYMBOL (xfs_address_space_operations); -EXPORT_SYMBOL (xfs_dir_inode_operations);EXPORT_SYMBOL (xfs_dir_file_operations); -EXPORT_SYMBOL (xfs_inode_operations);EXPORT_SYMBOL (xfs_file_operations);EXPORT_SYMBOL (xfs_invis_file_operations); -EXPORT_SYMBOL (xfs_symlink_inode_operations);EXPORT_SYMBOL (xfs_buf_delwri_dequeue);EXPORT_SYMBOL (_xfs_buf_find);EXPORT_SYMBOL (xfs_buf_iostart);
fs/xfs/linux-2.6/xfs_super.c +0 -109
115 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_super.h +0 -3
@@ -72,9 +72,6 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_initialize_vnode (struct xfs_mount *mp,bhv_vnode_t *vp, -struct xfs_inode *ip); -extern void xfs_flush_inode (struct xfs_inode *);extern void xfs_flush_device (struct xfs_inode *);
fs/xfs/xfs_iget.c +8 -1
@@ -288,10 +288,17 @@ finish_inode: *ipp = ip;/* +* Set up the Linux with the Linux inode. +*/ + ip->i_vnode = inode; + inode->i_private = ip; + +/* * If we have a real type for an on-disk inode, we can set ops(&unlock) * now. If it's a new inode being created, xfs_ialloc will handle it. */ -xfs_initialize_vnode (mp, inode, ip); +if (ip->i_d.di_mode !=0 ) +xfs_setup_inode (ip);return 0 ; }
fs/xfs/xfs_inode.c +1 -3
@@ -1046,7 +1046,6 @@ xfs_ialloc( {xfs_ino_t ino;xfs_inode_t *ip; -bhv_vnode_t *vp;uint flags;int error;
@@ -1077,7 +1076,6 @@ xfs_ialloc( }ASSERT (ip !=NULL ); - vp =XFS_ITOV (ip); ip->i_d.di_mode = (__uint16_t )mode; ip->i_d.di_onlink =0 ; ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(xfs_trans_log_inode (tp, ip, flags);/* now that we have an i_mode we can setup inode ops and unlock */ -xfs_initialize_vnode (tp->t_mountp, vp, ip); +xfs_setup_inode (ip); *ipp = ip;return 0 ;
ping?
Quoted 366 lines · Christoph Hellwig
Sanitize setting up the Linux indode.
Setting up the
xfs_inode<-> inode link is opencoded inxfs_iget_corenow because that's the only place it needs to be done,xfs_initialize_vnodeis renamed toxfs_setup_inodeand loses all superflous paramaters. The check forI_NEWis removed because it always is true and thedi_modecheck moves intoxfs_iget_corebecause it's only needed there.
xfs_set_inodeopsandxfs_revalidate_inodeare merged intoxfs_setup_inodeand the whole things is moved intoxfs_iops.cwhere it belongs.Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================fs/xfs/linux-2.6/xfs_iops.c +95
-3@@ -777,7 +777,7 @@ out_error:return error; } -const struct inode_operations xfs_inode_operations = { +static const struct inode_operations xfs_inode_operations = { .permission = xfs_vn_permission, .truncate = xfs_vn_truncate, .getattr = xfs_vn_getattr,@@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_ .fallocate = xfs_vn_fallocate, }; -const struct inode_operations xfs_dir_inode_operations = { +static const struct inode_operations xfs_dir_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_lookup, .link = xfs_vn_link,@@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_symlink_inode_operations = { +static const struct inode_operations xfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = xfs_vn_follow_link, .put_link = xfs_vn_put_link,@@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin .removexattr = generic_removexattr, .listxattr = xfs_vn_listxattr, }; + +STATIC void +xfs_diflags_to_iflags ( +struct inode *inode, +struct xfs_inode *ip) +{ +if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +} + +/* +* Initialize the Linux inode, set up the operation vectors and +* unlock the inode. +* +* When reading existing inodes from disk this is called directly +* from xfs_iget, when creating a new inode it is called from +* xfs_ialloc after setting up the inode. +*/ +void +xfs_setup_inode ( +struct xfs_inode *ip) +{ +struct inode *inode = ip->i_vnode; + + inode->i_mode = ip->i_d.di_mode; + inode->i_nlink = ip->i_d.di_nlink; + inode->i_uid = ip->i_d.di_uid; + inode->i_gid = ip->i_d.di_gid; + +switch (inode->i_mode &S_IFMT ) { +case S_IFBLK : +case S_IFCHR : + inode->i_rdev = +MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , +sysv_minor (ip->i_df.if_u2.if_rdev)); +break ; +default : + inode->i_rdev =0 ; +break ; + } + + inode->i_generation = ip->i_d.di_gen; +i_size_write (inode, ip->i_d.di_size); + inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; + inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; + 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; +xfs_diflags_to_iflags (inode, ip); +xfs_iflags_clear (ip,XFS_IMODIFIED ); + +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &xfs_inode_operations; + inode->i_fop = &xfs_file_operations; + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +case S_IFDIR : + inode->i_op = &xfs_dir_inode_operations; + inode->i_fop = &xfs_dir_file_operations; +break ; +case S_IFLNK : + inode->i_op = &xfs_symlink_inode_operations; +if (!(ip->i_df.if_flags &XFS_IFINLINE )) + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +default : + inode->i_op = &xfs_inode_operations; +init_special_inode (inode, inode->i_mode, inode->i_rdev); +break ; + } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
===================================================================fs/xfs/linux-2.6/xfs_iops.h +3
-4@@ -18,9 +18,7 @@#ifndef __XFS_IOPS_H__#define __XFS_IOPS_H__ -extern const struct inode_operations xfs_inode_operations; -extern const struct inode_operations xfs_dir_inode_operations; -extern const struct inode_operations xfs_symlink_inode_operations; +struct xfs_inode ;extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations;@@ -28,10 +26,11 @@ extern const struct file_operations xfs_extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); -struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );extern void xfs_ichgtime_fast (struct xfs_inode *,struct inode *,int ); +extern void xfs_setup_inode (struct xfs_inode *); +#define xfs_vtoi (vp) \ ((struct xfs_inode *)vn_to_inode(vp)->i_private)Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================fs/xfs/linux-2.6/xfs_ksyms.c +0
-3@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);EXPORT_SYMBOL (kmem_zone_init);EXPORT_SYMBOL (kmem_zone_zalloc);EXPORT_SYMBOL (xfs_address_space_operations); -EXPORT_SYMBOL (xfs_dir_inode_operations);EXPORT_SYMBOL (xfs_dir_file_operations); -EXPORT_SYMBOL (xfs_inode_operations);EXPORT_SYMBOL (xfs_file_operations);EXPORT_SYMBOL (xfs_invis_file_operations); -EXPORT_SYMBOL (xfs_symlink_inode_operations);EXPORT_SYMBOL (xfs_buf_delwri_dequeue);EXPORT_SYMBOL (_xfs_buf_find);EXPORT_SYMBOL (xfs_buf_iostart);Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================fs/xfs/linux-2.6/xfs_super.c +0
-109@@ -558,115 +558,6 @@ xfs_max_file_offset(return (((__uint64_t )pagefactor) << bitshift) -1 ; } -STATIC_INLINE void -xfs_set_inodeops ( -struct inode *inode) -{ -switch (inode->i_mode &S_IFMT ) { -case S_IFREG : - inode->i_op = &xfs_inode_operations; - inode->i_fop = &xfs_file_operations; - inode->i_mapping->a_ops = &xfs_address_space_operations; -break ; -case S_IFDIR : - inode->i_op = &xfs_dir_inode_operations; - inode->i_fop = &xfs_dir_file_operations; -break ; -case S_IFLNK : - inode->i_op = &xfs_symlink_inode_operations; -if (!(XFS_I (inode)->i_df.if_flags &XFS_IFINLINE )) - inode->i_mapping->a_ops = &xfs_address_space_operations; -break ; -default : - inode->i_op = &xfs_inode_operations; -init_special_inode (inode, inode->i_mode, inode->i_rdev); -break ; - } -} - -STATIC_INLINE void -xfs_revalidate_inode ( -xfs_mount_t *mp, -bhv_vnode_t *vp, -xfs_inode_t *ip) -{ -struct inode *inode =vn_to_inode (vp); - - inode->i_mode = ip->i_d.di_mode; - inode->i_nlink = ip->i_d.di_nlink; - inode->i_uid = ip->i_d.di_uid; - inode->i_gid = ip->i_d.di_gid; - -switch (inode->i_mode &S_IFMT ) { -case S_IFBLK : -case S_IFCHR : - inode->i_rdev = -MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , -sysv_minor (ip->i_df.if_u2.if_rdev)); -break ; -default : - inode->i_rdev =0 ; -break ; - } - - inode->i_generation = ip->i_d.di_gen; -i_size_write (inode, ip->i_d.di_size); - inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; - inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; - 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; -if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) - inode->i_flags |=S_IMMUTABLE ; -else - inode->i_flags &= ~S_IMMUTABLE ; -if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) - inode->i_flags |=S_APPEND ; -else - inode->i_flags &= ~S_APPEND ; -if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) - inode->i_flags |=S_SYNC ; -else - inode->i_flags &= ~S_SYNC ; -if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) - inode->i_flags |=S_NOATIME ; -else - inode->i_flags &= ~S_NOATIME ; -xfs_iflags_clear (ip,XFS_IMODIFIED ); -} - -void -xfs_initialize_vnode ( -struct xfs_mount *mp, -bhv_vnode_t *vp, -struct xfs_inode *ip) -{ -struct inode *inode =vn_to_inode (vp); - -if (!ip->i_vnode) { - ip->i_vnode = vp; - inode->i_private = ip; - } - -/* -* We need to set the ops vectors, and unlock the inode, but if -* we have been called during the new inode create process, it is -* too early to fill in the Linux inode. We will get called a -* second time once the inode is properly set up, and then we can -* finish our work. -*/ -if (ip->i_d.di_mode !=0 && (inode->i_state &I_NEW )) { -xfs_revalidate_inode (mp, vp, ip); -xfs_set_inodeops (inode); - -xfs_iflags_clear (ip,XFS_INEW ); -barrier (); - -unlock_new_inode (inode); - } -} - int xfs_blkdev_get( xfs_mount_t *mp,Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
===================================================================fs/xfs/linux-2.6/xfs_super.h +0
-3@@ -72,9 +72,6 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_initialize_vnode (struct xfs_mount *mp,bhv_vnode_t *vp, -struct xfs_inode *ip); -extern void xfs_flush_inode (struct xfs_inode *);extern void xfs_flush_device (struct xfs_inode *);Index:
linux-2.6-xfs/fs/xfs/xfs_iget.c
===================================================================fs/xfs/xfs_iget.c +8
-1@@ -288,10 +288,17 @@ finish_inode: *ipp = ip;/* +* Set up the Linux with the Linux inode. +*/ + ip->i_vnode = inode; + inode->i_private = ip; + +/* * If we have a real type for an on-disk inode, we can set ops(&unlock) * now. If it's a new inode being created, xfs_ialloc will handle it. */ -xfs_initialize_vnode (mp, inode, ip); +if (ip->i_d.di_mode !=0 ) +xfs_setup_inode (ip);return 0 ; }Index:
linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================fs/xfs/xfs_inode.c +0
-2@@ -1046,7 +1046,6 @@ xfs_ialloc( {xfs_ino_t ino;xfs_inode_t *ip; -bhv_vnode_t *vp;uint flags;int error;@@ -1077,7 +1076,6 @@ xfs_ialloc( }ASSERT (ip !=NULL ); - vp =XFS_ITOV (ip); ip->i_d.di_mode = (__uint16_t )mode; ip->i_d.di_onlink =0 ; ip->i_d.di_nlink = nlink;
fs/xfs/xfs_inode.c xfs_ialloc( · line 1224
Quoted 8 lines
fs/xfs/xfs_inode.c +1
-1@@ -1220,7 +1218,7 @@ xfs_ialloc(xfs_trans_log_inode (tp, ip, flags);/* now that we have an i_mode we can setup inode ops and unlock */ -xfs_initialize_vnode (tp->t_mountp, vp, ip); +xfs_setup_inode (ip); *ipp = ip;return 0 ;
---end quoted text---
ping^2
Quoted 371 lines · Christoph Hellwig
ping?
Quoted 368 lines · Christoph Hellwig
Sanitize setting up the Linux indode.
Setting up the
xfs_inode<-> inode link is opencoded inxfs_iget_corenow because that's the only place it needs to be done,xfs_initialize_vnodeis renamed toxfs_setup_inodeand loses all superflous paramaters. The check forI_NEWis removed because it always is true and thedi_modecheck moves intoxfs_iget_corebecause it's only needed there.
xfs_set_inodeopsandxfs_revalidate_inodeare merged intoxfs_setup_inodeand the whole things is moved intoxfs_iops.cwhere it belongs.Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================fs/xfs/linux-2.6/xfs_iops.c +95
-3@@ -777,7 +777,7 @@ out_error:return error; } -const struct inode_operations xfs_inode_operations = { +static const struct inode_operations xfs_inode_operations = { .permission = xfs_vn_permission, .truncate = xfs_vn_truncate, .getattr = xfs_vn_getattr,@@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_ .fallocate = xfs_vn_fallocate, }; -const struct inode_operations xfs_dir_inode_operations = { +static const struct inode_operations xfs_dir_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_lookup, .link = xfs_vn_link,@@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_symlink_inode_operations = { +static const struct inode_operations xfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = xfs_vn_follow_link, .put_link = xfs_vn_put_link,@@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin .removexattr = generic_removexattr, .listxattr = xfs_vn_listxattr, }; + +STATIC void +xfs_diflags_to_iflags ( +struct inode *inode, +struct xfs_inode *ip) +{ +if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +} + +/* +* Initialize the Linux inode, set up the operation vectors and +* unlock the inode. +* +* When reading existing inodes from disk this is called directly +* from xfs_iget, when creating a new inode it is called from +* xfs_ialloc after setting up the inode. +*/ +void +xfs_setup_inode ( +struct xfs_inode *ip) +{ +struct inode *inode = ip->i_vnode; + + inode->i_mode = ip->i_d.di_mode; + inode->i_nlink = ip->i_d.di_nlink; + inode->i_uid = ip->i_d.di_uid; + inode->i_gid = ip->i_d.di_gid; + +switch (inode->i_mode &S_IFMT ) { +case S_IFBLK : +case S_IFCHR : + inode->i_rdev = +MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , +sysv_minor (ip->i_df.if_u2.if_rdev)); +break ; +default : + inode->i_rdev =0 ; +break ; + } + + inode->i_generation = ip->i_d.di_gen; +i_size_write (inode, ip->i_d.di_size); + inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; + inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; + 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; +xfs_diflags_to_iflags (inode, ip); +xfs_iflags_clear (ip,XFS_IMODIFIED ); + +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &xfs_inode_operations; + inode->i_fop = &xfs_file_operations; + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +case S_IFDIR : + inode->i_op = &xfs_dir_inode_operations; + inode->i_fop = &xfs_dir_file_operations; +break ; +case S_IFLNK : + inode->i_op = &xfs_symlink_inode_operations; +if (!(ip->i_df.if_flags &XFS_IFINLINE )) + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +default : + inode->i_op = &xfs_inode_operations; +init_special_inode (inode, inode->i_mode, inode->i_rdev); +break ; + } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
===================================================================fs/xfs/linux-2.6/xfs_iops.h +3
-4@@ -18,9 +18,7 @@#ifndef __XFS_IOPS_H__#define __XFS_IOPS_H__ -extern const struct inode_operations xfs_inode_operations; -extern const struct inode_operations xfs_dir_inode_operations; -extern const struct inode_operations xfs_symlink_inode_operations; +struct xfs_inode ;extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations;@@ -28,10 +26,11 @@ extern const struct file_operations xfs_extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); -struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );extern void xfs_ichgtime_fast (struct xfs_inode *,struct inode *,int ); +extern void xfs_setup_inode (struct xfs_inode *); +#define xfs_vtoi (vp) \ ((struct xfs_inode *)vn_to_inode(vp)->i_private)Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================fs/xfs/linux-2.6/xfs_ksyms.c +0
-3@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);EXPORT_SYMBOL (kmem_zone_init);EXPORT_SYMBOL (kmem_zone_zalloc);EXPORT_SYMBOL (xfs_address_space_operations); -EXPORT_SYMBOL (xfs_dir_inode_operations);EXPORT_SYMBOL (xfs_dir_file_operations); -EXPORT_SYMBOL (xfs_inode_operations);EXPORT_SYMBOL (xfs_file_operations);EXPORT_SYMBOL (xfs_invis_file_operations); -EXPORT_SYMBOL (xfs_symlink_inode_operations);EXPORT_SYMBOL (xfs_buf_delwri_dequeue);EXPORT_SYMBOL (_xfs_buf_find);EXPORT_SYMBOL (xfs_buf_iostart);Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================fs/xfs/linux-2.6/xfs_super.c +0
-109@@ -558,115 +558,6 @@ xfs_max_file_offset(return (((__uint64_t )pagefactor) << bitshift) -1 ; } -STATIC_INLINE void -xfs_set_inodeops ( -struct inode *inode) -{ -switch (inode->i_mode &S_IFMT ) { -case S_IFREG : - inode->i_op = &xfs_inode_operations; - inode->i_fop = &xfs_file_operations; - inode->i_mapping->a_ops = &xfs_address_space_operations; -break ; -case S_IFDIR : - inode->i_op = &xfs_dir_inode_operations; - inode->i_fop = &xfs_dir_file_operations; -break ; -case S_IFLNK : - inode->i_op = &xfs_symlink_inode_operations; -if (!(XFS_I (inode)->i_df.if_flags &XFS_IFINLINE )) - inode->i_mapping->a_ops = &xfs_address_space_operations; -break ; -default : - inode->i_op = &xfs_inode_operations; -init_special_inode (inode, inode->i_mode, inode->i_rdev); -break ; - } -} - -STATIC_INLINE void -xfs_revalidate_inode ( -xfs_mount_t *mp, -bhv_vnode_t *vp, -xfs_inode_t *ip) -{ -struct inode *inode =vn_to_inode (vp); - - inode->i_mode = ip->i_d.di_mode; - inode->i_nlink = ip->i_d.di_nlink; - inode->i_uid = ip->i_d.di_uid; - inode->i_gid = ip->i_d.di_gid; - -switch (inode->i_mode &S_IFMT ) { -case S_IFBLK : -case S_IFCHR : - inode->i_rdev = -MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , -sysv_minor (ip->i_df.if_u2.if_rdev)); -break ; -default : - inode->i_rdev =0 ; -break ; - } - - inode->i_generation = ip->i_d.di_gen; -i_size_write (inode, ip->i_d.di_size); - inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; - inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; - 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; -if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) - inode->i_flags |=S_IMMUTABLE ; -else - inode->i_flags &= ~S_IMMUTABLE ; -if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) - inode->i_flags |=S_APPEND ; -else - inode->i_flags &= ~S_APPEND ; -if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) - inode->i_flags |=S_SYNC ; -else - inode->i_flags &= ~S_SYNC ; -if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) - inode->i_flags |=S_NOATIME ; -else - inode->i_flags &= ~S_NOATIME ; -xfs_iflags_clear (ip,XFS_IMODIFIED ); -} - -void -xfs_initialize_vnode ( -struct xfs_mount *mp, -bhv_vnode_t *vp, -struct xfs_inode *ip) -{ -struct inode *inode =vn_to_inode (vp); - -if (!ip->i_vnode) { - ip->i_vnode = vp; - inode->i_private = ip; - } - -/* -* We need to set the ops vectors, and unlock the inode, but if -* we have been called during the new inode create process, it is -* too early to fill in the Linux inode. We will get called a -* second time once the inode is properly set up, and then we can -* finish our work. -*/ -if (ip->i_d.di_mode !=0 && (inode->i_state &I_NEW )) { -xfs_revalidate_inode (mp, vp, ip); -xfs_set_inodeops (inode); - -xfs_iflags_clear (ip,XFS_INEW ); -barrier (); - -unlock_new_inode (inode); - } -} - int xfs_blkdev_get( xfs_mount_t *mp,Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
===================================================================fs/xfs/linux-2.6/xfs_super.h +0
-3@@ -72,9 +72,6 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_initialize_vnode (struct xfs_mount *mp,bhv_vnode_t *vp, -struct xfs_inode *ip); -extern void xfs_flush_inode (struct xfs_inode *);extern void xfs_flush_device (struct xfs_inode *);Index:
linux-2.6-xfs/fs/xfs/xfs_iget.c
===================================================================fs/xfs/xfs_iget.c +8
-1@@ -288,10 +288,17 @@ finish_inode: *ipp = ip;/* +* Set up the Linux with the Linux inode. +*/ + ip->i_vnode = inode; + inode->i_private = ip; + +/* * If we have a real type for an on-disk inode, we can set ops(&unlock) * now. If it's a new inode being created, xfs_ialloc will handle it. */ -xfs_initialize_vnode (mp, inode, ip); +if (ip->i_d.di_mode !=0 ) +xfs_setup_inode (ip);return 0 ; }Index:
linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================fs/xfs/xfs_inode.c +0
-2@@ -1046,7 +1046,6 @@ xfs_ialloc( {xfs_ino_t ino;xfs_inode_t *ip; -bhv_vnode_t *vp;uint flags;int error;@@ -1077,7 +1076,6 @@ xfs_ialloc( }ASSERT (ip !=NULL ); - vp =XFS_ITOV (ip); ip->i_d.di_mode = (__uint16_t )mode; ip->i_d.di_onlink =0 ; ip->i_d.di_nlink = nlink;@@ -1220,7 +1218,7 @@ xfs_ialloc(xfs_trans_log_inode (tp, ip, flags);
Quoted 7 lines
fs/xfs/xfs_inode.c xfs_ialloc( · line 1224
Quoted 6 lines
fs/xfs/xfs_inode.c +1
-1/* now that we have an i_mode we can setup inode ops and unlock */ -xfs_initialize_vnode (tp->t_mountp, vp, ip); +xfs_setup_inode (ip); *ipp = ip;return 0 ;---end quoted text---
---end quoted text---
ping^3
Quoted 374 lines · Christoph Hellwig
ping^2
Quoted 371 lines · Christoph Hellwig
ping?
Quoted 368 lines · Christoph Hellwig
Sanitize setting up the Linux indode.
Setting up the
xfs_inode<-> inode link is opencoded inxfs_iget_corenow because that's the only place it needs to be done,xfs_initialize_vnodeis renamed toxfs_setup_inodeand loses all superflous paramaters. The check forI_NEWis removed because it always is true and thedi_modecheck moves intoxfs_iget_corebecause it's only needed there.
xfs_set_inodeopsandxfs_revalidate_inodeare merged intoxfs_setup_inodeand the whole things is moved intoxfs_iops.cwhere it belongs.Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================fs/xfs/linux-2.6/xfs_iops.c +95
-3@@ -777,7 +777,7 @@ out_error:return error; } -const struct inode_operations xfs_inode_operations = { +static const struct inode_operations xfs_inode_operations = { .permission = xfs_vn_permission, .truncate = xfs_vn_truncate, .getattr = xfs_vn_getattr,@@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_ .fallocate = xfs_vn_fallocate, }; -const struct inode_operations xfs_dir_inode_operations = { +static const struct inode_operations xfs_dir_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_lookup, .link = xfs_vn_link,@@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_symlink_inode_operations = { +static const struct inode_operations xfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = xfs_vn_follow_link, .put_link = xfs_vn_put_link,@@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin .removexattr = generic_removexattr, .listxattr = xfs_vn_listxattr, }; + +STATIC void +xfs_diflags_to_iflags ( +struct inode *inode, +struct xfs_inode *ip) +{ +if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +} + +/* +* Initialize the Linux inode, set up the operation vectors and +* unlock the inode. +* +* When reading existing inodes from disk this is called directly +* from xfs_iget, when creating a new inode it is called from +* xfs_ialloc after setting up the inode. +*/ +void +xfs_setup_inode ( +struct xfs_inode *ip) +{ +struct inode *inode = ip->i_vnode; + + inode->i_mode = ip->i_d.di_mode; + inode->i_nlink = ip->i_d.di_nlink; + inode->i_uid = ip->i_d.di_uid; + inode->i_gid = ip->i_d.di_gid; + +switch (inode->i_mode &S_IFMT ) { +case S_IFBLK : +case S_IFCHR : + inode->i_rdev = +MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , +sysv_minor (ip->i_df.if_u2.if_rdev)); +break ; +default : + inode->i_rdev =0 ; +break ; + } + + inode->i_generation = ip->i_d.di_gen; +i_size_write (inode, ip->i_d.di_size); + inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; + inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; + 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; +xfs_diflags_to_iflags (inode, ip); +xfs_iflags_clear (ip,XFS_IMODIFIED ); + +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &xfs_inode_operations; + inode->i_fop = &xfs_file_operations; + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +case S_IFDIR : + inode->i_op = &xfs_dir_inode_operations; + inode->i_fop = &xfs_dir_file_operations; +break ; +case S_IFLNK : + inode->i_op = &xfs_symlink_inode_operations; +if (!(ip->i_df.if_flags &XFS_IFINLINE )) + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +default : + inode->i_op = &xfs_inode_operations; +init_special_inode (inode, inode->i_mode, inode->i_rdev); +break ; + } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
===================================================================fs/xfs/linux-2.6/xfs_iops.h +3
-4@@ -18,9 +18,7 @@#ifndef __XFS_IOPS_H__#define __XFS_IOPS_H__ -extern const struct inode_operations xfs_inode_operations; -extern const struct inode_operations xfs_dir_inode_operations; -extern const struct inode_operations xfs_symlink_inode_operations; +struct xfs_inode ;extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations;@@ -28,10 +26,11 @@ extern const struct file_operations xfs_extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); -struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );extern void xfs_ichgtime_fast (struct xfs_inode *,struct inode *,int ); +extern void xfs_setup_inode (struct xfs_inode *); +#define xfs_vtoi (vp) \ ((struct xfs_inode *)vn_to_inode(vp)->i_private)Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================fs/xfs/linux-2.6/xfs_ksyms.c +0
-3@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);EXPORT_SYMBOL (kmem_zone_init);EXPORT_SYMBOL (kmem_zone_zalloc);EXPORT_SYMBOL (xfs_address_space_operations); -EXPORT_SYMBOL (xfs_dir_inode_operations);EXPORT_SYMBOL (xfs_dir_file_operations); -EXPORT_SYMBOL (xfs_inode_operations);EXPORT_SYMBOL (xfs_file_operations);EXPORT_SYMBOL (xfs_invis_file_operations); -EXPORT_SYMBOL (xfs_symlink_inode_operations);EXPORT_SYMBOL (xfs_buf_delwri_dequeue);EXPORT_SYMBOL (_xfs_buf_find);EXPORT_SYMBOL (xfs_buf_iostart);Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================fs/xfs/linux-2.6/xfs_super.c +0
-109@@ -558,115 +558,6 @@ xfs_max_file_offset(return (((__uint64_t )pagefactor) << bitshift) -1 ; } -STATIC_INLINE void -xfs_set_inodeops ( -struct inode *inode) -{ -switch (inode->i_mode &S_IFMT ) { -case S_IFREG : - inode->i_op = &xfs_inode_operations; - inode->i_fop = &xfs_file_operations; - inode->i_mapping->a_ops = &xfs_address_space_operations; -break ; -case S_IFDIR : - inode->i_op = &xfs_dir_inode_operations; - inode->i_fop = &xfs_dir_file_operations; -break ; -case S_IFLNK : - inode->i_op = &xfs_symlink_inode_operations; -if (!(XFS_I (inode)->i_df.if_flags &XFS_IFINLINE )) - inode->i_mapping->a_ops = &xfs_address_space_operations; -break ; -default : - inode->i_op = &xfs_inode_operations; -init_special_inode (inode, inode->i_mode, inode->i_rdev); -break ; - } -} - -STATIC_INLINE void -xfs_revalidate_inode ( -xfs_mount_t *mp, -bhv_vnode_t *vp, -xfs_inode_t *ip) -{ -struct inode *inode =vn_to_inode (vp); - - inode->i_mode = ip->i_d.di_mode; - inode->i_nlink = ip->i_d.di_nlink; - inode->i_uid = ip->i_d.di_uid; - inode->i_gid = ip->i_d.di_gid; - -switch (inode->i_mode &S_IFMT ) { -case S_IFBLK : -case S_IFCHR : - inode->i_rdev = -MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , -sysv_minor (ip->i_df.if_u2.if_rdev)); -break ; -default : - inode->i_rdev =0 ; -break ; - } - - inode->i_generation = ip->i_d.di_gen; -i_size_write (inode, ip->i_d.di_size); - inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; - inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; - 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; -if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) - inode->i_flags |=S_IMMUTABLE ; -else - inode->i_flags &= ~S_IMMUTABLE ; -if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) - inode->i_flags |=S_APPEND ; -else - inode->i_flags &= ~S_APPEND ; -if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) - inode->i_flags |=S_SYNC ; -else - inode->i_flags &= ~S_SYNC ; -if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) - inode->i_flags |=S_NOATIME ; -else - inode->i_flags &= ~S_NOATIME ; -xfs_iflags_clear (ip,XFS_IMODIFIED ); -} - -void -xfs_initialize_vnode ( -struct xfs_mount *mp, -bhv_vnode_t *vp, -struct xfs_inode *ip) -{ -struct inode *inode =vn_to_inode (vp); - -if (!ip->i_vnode) { - ip->i_vnode = vp; - inode->i_private = ip; - } - -/* -* We need to set the ops vectors, and unlock the inode, but if -* we have been called during the new inode create process, it is -* too early to fill in the Linux inode. We will get called a -* second time once the inode is properly set up, and then we can -* finish our work. -*/ -if (ip->i_d.di_mode !=0 && (inode->i_state &I_NEW )) { -xfs_revalidate_inode (mp, vp, ip); -xfs_set_inodeops (inode); - -xfs_iflags_clear (ip,XFS_INEW ); -barrier (); - -unlock_new_inode (inode); - } -} - int xfs_blkdev_get( xfs_mount_t *mp,Index:
linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
===================================================================fs/xfs/linux-2.6/xfs_super.h +0
-3@@ -72,9 +72,6 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_initialize_vnode (struct xfs_mount *mp,bhv_vnode_t *vp, -struct xfs_inode *ip); -extern void xfs_flush_inode (struct xfs_inode *);extern void xfs_flush_device (struct xfs_inode *);Index:
linux-2.6-xfs/fs/xfs/xfs_iget.c
===================================================================fs/xfs/xfs_iget.c +8
-1@@ -288,10 +288,17 @@ finish_inode: *ipp = ip;/* +* Set up the Linux with the Linux inode. +*/ + ip->i_vnode = inode; + inode->i_private = ip; + +/* * If we have a real type for an on-disk inode, we can set ops(&unlock) * now. If it's a new inode being created, xfs_ialloc will handle it. */ -xfs_initialize_vnode (mp, inode, ip); +if (ip->i_d.di_mode !=0 ) +xfs_setup_inode (ip);return 0 ; }Index:
linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================fs/xfs/xfs_inode.c +0
-2@@ -1046,7 +1046,6 @@ xfs_ialloc( {xfs_ino_t ino;xfs_inode_t *ip; -bhv_vnode_t *vp;uint flags;int error;@@ -1077,7 +1076,6 @@ xfs_ialloc( }ASSERT (ip !=NULL ); - vp =XFS_ITOV (ip); ip->i_d.di_mode = (__uint16_t )mode; ip->i_d.di_onlink =0 ; ip->i_d.di_nlink = nlink;@@ -1220,7 +1218,7 @@ xfs_ialloc(xfs_trans_log_inode (tp, ip, flags);
Quoted 8 lines
Quoted 7 lines
fs/xfs/xfs_inode.c xfs_ialloc( · line 1224
Quoted 6 lines
fs/xfs/xfs_inode.c +1
-1/* now that we have an i_mode we can setup inode ops and unlock */ -xfs_initialize_vnode (tp->t_mountp, vp, ip); +xfs_setup_inode (ip); *ipp = ip;return 0 ;---end quoted text---
---end quoted text---
---end quoted text---
Quoted 9 lines · Christoph Hellwig
Sanitize setting up the Linux indode.
Setting up the
xfs_inode<-> inode link is opencoded inxfs_iget_corenow because that's the only place it needs to be done,xfs_initialize_vnodeis renamed toxfs_setup_inodeand loses all superflous paramaters. The check forI_NEWis removed because it always is true and thedi_modecheck moves intoxfs_iget_corebecause it's only needed there.
Quoted 3 lines
xfs_set_inodeopsandxfs_revalidate_inodeare merged intoxfs_setup_inodeand the whole things is moved intoxfs_iops.cwhere it belongs.
Updated to apply ontop of the case-insensitive filename changes.
fs/xfs/linux-2.6/xfs_iops.c +99 -4
@@ -813,7 +813,7 @@ out_error:return error; } -const struct inode_operations xfs_inode_operations = { +static const struct inode_operations xfs_inode_operations = { .permission = xfs_vn_permission, .truncate = xfs_vn_truncate, .getattr = xfs_vn_getattr,
@@ -825,7 +825,7 @@ const struct inode_operations xfs_inode_ .fallocate = xfs_vn_fallocate, }; -const struct inode_operations xfs_dir_inode_operations = { +static const struct inode_operations xfs_dir_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_lookup, .link = xfs_vn_link,
@@ -844,7 +844,7 @@ const struct inode_operations xfs_dir_in .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_dir_ci_inode_operations = { +static const struct inode_operations xfs_dir_ci_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_ci_lookup, .link = xfs_vn_link,
@@ -863,7 +863,7 @@ const struct inode_operations xfs_dir_ci .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_symlink_inode_operations = { +static const struct inode_operations xfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = xfs_vn_follow_link, .put_link = xfs_vn_put_link,
@@ -875,3 +875,98 @@ const struct inode_operations xfs_symlin .removexattr = generic_removexattr, .listxattr = xfs_vn_listxattr, }; + +STATIC void +xfs_diflags_to_iflags ( +struct inode *inode, +struct xfs_inode *ip) +{ +if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +} + +/* +* Initialize the Linux inode, set up the operation vectors and +* unlock the inode. +* +* When reading existing inodes from disk this is called directly +* from xfs_iget, when creating a new inode it is called from +* xfs_ialloc after setting up the inode. +*/ +void +xfs_setup_inode ( +struct xfs_inode *ip) +{ +struct inode *inode = ip->i_vnode; + + inode->i_mode = ip->i_d.di_mode; + inode->i_nlink = ip->i_d.di_nlink; + inode->i_uid = ip->i_d.di_uid; + inode->i_gid = ip->i_d.di_gid; + +switch (inode->i_mode &S_IFMT ) { +case S_IFBLK : +case S_IFCHR : + inode->i_rdev = +MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , +sysv_minor (ip->i_df.if_u2.if_rdev)); +break ; +default : + inode->i_rdev =0 ; +break ; + } + + inode->i_generation = ip->i_d.di_gen; +i_size_write (inode, ip->i_d.di_size); + inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; + inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; + 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; +xfs_diflags_to_iflags (inode, ip); +xfs_iflags_clear (ip,XFS_IMODIFIED ); + +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &xfs_inode_operations; + inode->i_fop = &xfs_file_operations; + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +case S_IFDIR : +if (xfs_sb_version_hasasciici (&XFS_M (inode->i_sb)->m_sb)) + inode->i_op = &xfs_dir_ci_inode_operations; +else + inode->i_op = &xfs_dir_inode_operations; + inode->i_fop = &xfs_dir_file_operations; +break ; +case S_IFLNK : + inode->i_op = &xfs_symlink_inode_operations; +if (!(ip->i_df.if_flags &XFS_IFINLINE )) + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +default : + inode->i_op = &xfs_inode_operations; +init_special_inode (inode, inode->i_mode, inode->i_rdev); +break ; + } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}
fs/xfs/linux-2.6/xfs_iops.h +2 -6
@@ -18,21 +18,17 @@#ifndef __XFS_IOPS_H__#define __XFS_IOPS_H__ -extern const struct inode_operations xfs_inode_operations; -extern const struct inode_operations xfs_dir_inode_operations; -extern const struct inode_operations xfs_dir_ci_inode_operations; -extern const struct inode_operations xfs_symlink_inode_operations; -extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations;extern const struct file_operations xfs_invis_file_operations;extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); -struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );extern void xfs_ichgtime_fast (struct xfs_inode *,struct inode *,int ); +extern void xfs_setup_inode (struct xfs_inode *); +#define xfs_vtoi (vp) \ ((struct xfs_inode *)vn_to_inode(vp)->i_private)
fs/xfs/linux-2.6/xfs_ksyms.c +0 -3
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);EXPORT_SYMBOL (kmem_zone_init);EXPORT_SYMBOL (kmem_zone_zalloc);EXPORT_SYMBOL (xfs_address_space_operations); -EXPORT_SYMBOL (xfs_dir_inode_operations);EXPORT_SYMBOL (xfs_dir_file_operations); -EXPORT_SYMBOL (xfs_inode_operations);EXPORT_SYMBOL (xfs_file_operations);EXPORT_SYMBOL (xfs_invis_file_operations); -EXPORT_SYMBOL (xfs_symlink_inode_operations);EXPORT_SYMBOL (xfs_buf_delwri_dequeue);EXPORT_SYMBOL (_xfs_buf_find);EXPORT_SYMBOL (xfs_buf_iostart);
fs/xfs/linux-2.6/xfs_super.c +0 -112
118 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_super.h +0 -3
@@ -72,9 +72,6 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_initialize_vnode (struct xfs_mount *mp,bhv_vnode_t *vp, -struct xfs_inode *ip); -extern void xfs_flush_inode (struct xfs_inode *);extern void xfs_flush_device (struct xfs_inode *);
fs/xfs/xfs_iget.c +8 -1
@@ -288,10 +288,17 @@ finish_inode: *ipp = ip;/* +* Set up the Linux with the Linux inode. +*/ + ip->i_vnode = inode; + inode->i_private = ip; + +/* * If we have a real type for an on-disk inode, we can set ops(&unlock) * now. If it's a new inode being created, xfs_ialloc will handle it. */ -xfs_initialize_vnode (mp, inode, ip); +if (ip->i_d.di_mode !=0 ) +xfs_setup_inode (ip);return 0 ; }
fs/xfs/xfs_inode.c +1 -3
@@ -1046,7 +1046,6 @@ xfs_ialloc( {xfs_ino_t ino;xfs_inode_t *ip; -bhv_vnode_t *vp;uint flags;int error;
@@ -1077,7 +1076,6 @@ xfs_ialloc( }ASSERT (ip !=NULL ); - vp =XFS_ITOV (ip); ip->i_d.di_mode = (__uint16_t )mode; ip->i_d.di_onlink =0 ; ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(xfs_trans_log_inode (tp, ip, flags);/* now that we have an i_mode we can setup inode ops and unlock */ -xfs_initialize_vnode (tp->t_mountp, vp, ip); +xfs_setup_inode (ip); *ipp = ip;return 0 ;
Quoted 9 lines · Christoph Hellwig
Sanitize setting up the Linux indode.
Setting up the
xfs_inode<-> inode link is opencoded inxfs_iget_corenow because that's the only place it needs to be done,xfs_initialize_vnodeis renamed toxfs_setup_inodeand loses all superflous paramaters. The check forI_NEWis removed because it always is true and thedi_modecheck moves intoxfs_iget_corebecause it's only needed there.
Quoted 3 lines
xfs_set_inodeopsandxfs_revalidate_inodeare merged intoxfs_setup_inodeand the whole things is moved intoxfs_iops.cwhere it belongs.
Rediffed to apply ontop of Dave's and my vnode helper cleanups:
fs/xfs/linux-2.6/xfs_iops.c +99 -4
@@ -718,7 +718,7 @@ out_error:return error; } -const struct inode_operations xfs_inode_operations = { +static const struct inode_operations xfs_inode_operations = { .permission = xfs_vn_permission, .truncate = xfs_vn_truncate, .getattr = xfs_vn_getattr,
@@ -730,7 +730,7 @@ const struct inode_operations xfs_inode_ .fallocate = xfs_vn_fallocate, }; -const struct inode_operations xfs_dir_inode_operations = { +static const struct inode_operations xfs_dir_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_lookup, .link = xfs_vn_link,
@@ -755,7 +755,7 @@ const struct inode_operations xfs_dir_in .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_dir_ci_inode_operations = { +static const struct inode_operations xfs_dir_ci_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_ci_lookup, .link = xfs_vn_link,
@@ -780,7 +780,7 @@ const struct inode_operations xfs_dir_ci .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_symlink_inode_operations = { +static const struct inode_operations xfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = xfs_vn_follow_link, .put_link = xfs_vn_put_link,
@@ -792,3 +792,98 @@ const struct inode_operations xfs_symlin .removexattr = generic_removexattr, .listxattr = xfs_vn_listxattr, }; + +STATIC void +xfs_diflags_to_iflags ( +struct inode *inode, +struct xfs_inode *ip) +{ +if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +} + +/* +* Initialize the Linux inode, set up the operation vectors and +* unlock the inode. +* +* When reading existing inodes from disk this is called directly +* from xfs_iget, when creating a new inode it is called from +* xfs_ialloc after setting up the inode. +*/ +void +xfs_setup_inode ( +struct xfs_inode *ip) +{ +struct inode *inode = ip->i_vnode; + + inode->i_mode = ip->i_d.di_mode; + inode->i_nlink = ip->i_d.di_nlink; + inode->i_uid = ip->i_d.di_uid; + inode->i_gid = ip->i_d.di_gid; + +switch (inode->i_mode &S_IFMT ) { +case S_IFBLK : +case S_IFCHR : + inode->i_rdev = +MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , +sysv_minor (ip->i_df.if_u2.if_rdev)); +break ; +default : + inode->i_rdev =0 ; +break ; + } + + inode->i_generation = ip->i_d.di_gen; +i_size_write (inode, ip->i_d.di_size); + inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; + inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; + 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; +xfs_diflags_to_iflags (inode, ip); +xfs_iflags_clear (ip,XFS_IMODIFIED ); + +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &xfs_inode_operations; + inode->i_fop = &xfs_file_operations; + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +case S_IFDIR : +if (xfs_sb_version_hasasciici (&XFS_M (inode->i_sb)->m_sb)) + inode->i_op = &xfs_dir_ci_inode_operations; +else + inode->i_op = &xfs_dir_inode_operations; + inode->i_fop = &xfs_dir_file_operations; +break ; +case S_IFLNK : + inode->i_op = &xfs_symlink_inode_operations; +if (!(ip->i_df.if_flags &XFS_IFINLINE )) + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +default : + inode->i_op = &xfs_inode_operations; +init_special_inode (inode, inode->i_mode, inode->i_rdev); +break ; + } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}
fs/xfs/linux-2.6/xfs_iops.h +3 -5
@@ -18,10 +18,7 @@#ifndef __XFS_IOPS_H__#define __XFS_IOPS_H__ -extern const struct inode_operations xfs_inode_operations; -extern const struct inode_operations xfs_dir_inode_operations; -extern const struct inode_operations xfs_dir_ci_inode_operations; -extern const struct inode_operations xfs_symlink_inode_operations; +struct xfs_inode ;extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations;
@@ -29,8 +26,9 @@ extern const struct file_operations xfs_extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); -struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );extern void xfs_ichgtime_fast (struct xfs_inode *,struct inode *,int ); +extern void xfs_setup_inode (struct xfs_inode *); +#endif /* __XFS_IOPS_H__ */
fs/xfs/linux-2.6/xfs_ksyms.c +0 -3
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);EXPORT_SYMBOL (kmem_zone_init);EXPORT_SYMBOL (kmem_zone_zalloc);EXPORT_SYMBOL (xfs_address_space_operations); -EXPORT_SYMBOL (xfs_dir_inode_operations);EXPORT_SYMBOL (xfs_dir_file_operations); -EXPORT_SYMBOL (xfs_inode_operations);EXPORT_SYMBOL (xfs_file_operations);EXPORT_SYMBOL (xfs_invis_file_operations); -EXPORT_SYMBOL (xfs_symlink_inode_operations);EXPORT_SYMBOL (xfs_buf_delwri_dequeue);EXPORT_SYMBOL (_xfs_buf_find);EXPORT_SYMBOL (xfs_buf_iostart);
fs/xfs/linux-2.6/xfs_super.h +0 -3
@@ -72,9 +72,6 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_initialize_vnode (struct xfs_mount *mp,bhv_vnode_t *vp, -struct xfs_inode *ip); -extern void xfs_flush_inode (struct xfs_inode *);extern void xfs_flush_device (struct xfs_inode *);
fs/xfs/xfs_iget.c +8 -1
@@ -288,10 +288,17 @@ finish_inode: *ipp = ip;/* +* Set up the Linux with the Linux inode. +*/ + ip->i_vnode = inode; + inode->i_private = ip; + +/* * If we have a real type for an on-disk inode, we can set ops(&unlock) * now. If it's a new inode being created, xfs_ialloc will handle it. */ -xfs_initialize_vnode (mp, inode, ip); +if (ip->i_d.di_mode !=0 ) +xfs_setup_inode (ip);return 0 ; }
fs/xfs/xfs_inode.c +1 -3
@@ -1046,7 +1046,6 @@ xfs_ialloc( {xfs_ino_t ino;xfs_inode_t *ip; -bhv_vnode_t *vp;uint flags;int error;
@@ -1077,7 +1076,6 @@ xfs_ialloc( }ASSERT (ip !=NULL ); - vp =VFS_I (ip); ip->i_d.di_mode = (__uint16_t )mode; ip->i_d.di_onlink =0 ; ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(xfs_trans_log_inode (tp, ip, flags);/* now that we have an i_mode we can setup inode ops and unlock */ -xfs_initialize_vnode (tp->t_mountp, vp, ip); +xfs_setup_inode (ip); *ipp = ip;return 0 ;
fs/xfs/linux-2.6/xfs_super.c +0 -110
116 lines not on this page · raw message
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Christoph Hellwig
Sanitize setting up the Linux indode.
Setting up the
xfs_inode<-> inode link is opencoded inxfs_iget_corenow because that's the only place it needs to be done,xfs_initialize_vnodeis renamed toxfs_setup_inodeand loses all superflous paramaters. The check forI_NEWis removed because it always is true and thedi_modecheck moves intoxfs_iget_corebecause it's only needed there.
Quoted 5 lines
Quoted 3 lines
xfs_set_inodeopsandxfs_revalidate_inodeare merged intoxfs_setup_inodeand the whole things is moved intoxfs_iops.cwhere it belongs.Rediffed to apply ontop of Dave's and my vnode helper cleanups:
Looks good and has been passing testing here for the past week...
One question, though:
fs/xfs/linux-2.6/xfs_iops.c const struct inode_operations xfs_symlin · line 889
Quoted 7 lines
fs/xfs/linux-2.6/xfs_iops.c +7
-0+ } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}
Do we still need that barrier()? Or has the reason for it existing been lost in the mists of time? Regardless, it was there before so this is not a reason to stop the patch from going in...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 4 lines · Dave Chinner
Quoted 4 lines
fs/xfs/linux-2.6/xfs_iops.c +4
-0+ } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier ();
Quoted 8 lines
fs/xfs/linux-2.6/xfs_iops.c const struct inode_operations xfs_symlin · line 889
Quoted 3 lines
fs/xfs/linux-2.6/xfs_iops.c +3
-0+ +unlock_new_inode (inode); +}Do we still need that
barrier()? Or has the reason for it existing been lost in the mists of time? Regardless, it was there before so this is not a reason to stop the patch from going in...
Good question. I wonder why it's there in the first place.
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Christoph Hellwig
Sanitize setting up the Linux indode.
Setting up the
xfs_inode<-> inode link is opencoded inxfs_iget_corenow because that's the only place it needs to be done,xfs_initialize_vnodeis renamed toxfs_setup_inodeand loses all superflous paramaters. The check forI_NEWis removed because it always is true and thedi_modecheck moves intoxfs_iget_corebecause it's only needed there.
Quoted 5 lines
Quoted 3 lines
xfs_set_inodeopsandxfs_revalidate_inodeare merged intoxfs_setup_inodeand the whole things is moved intoxfs_iops.cwhere it belongs.Rediffed to apply ontop of Dave's and my vnode helper cleanups:
And another rediff after the vnode removal which was supposed to apply after this patch. Any chance to get in before it gets three month old?
fs/xfs/linux-2.6/xfs_iops.c +99 -4
@@ -718,7 +718,7 @@ out_error:return error; } -const struct inode_operations xfs_inode_operations = { +static const struct inode_operations xfs_inode_operations = { .permission = xfs_vn_permission, .truncate = xfs_vn_truncate, .getattr = xfs_vn_getattr,
@@ -730,7 +730,7 @@ const struct inode_operations xfs_inode_ .fallocate = xfs_vn_fallocate, }; -const struct inode_operations xfs_dir_inode_operations = { +static const struct inode_operations xfs_dir_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_lookup, .link = xfs_vn_link,
@@ -755,7 +755,7 @@ const struct inode_operations xfs_dir_in .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_dir_ci_inode_operations = { +static const struct inode_operations xfs_dir_ci_inode_operations = { .create = xfs_vn_create, .lookup = xfs_vn_ci_lookup, .link = xfs_vn_link,
@@ -780,7 +780,7 @@ const struct inode_operations xfs_dir_ci .listxattr = xfs_vn_listxattr, }; -const struct inode_operations xfs_symlink_inode_operations = { +static const struct inode_operations xfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = xfs_vn_follow_link, .put_link = xfs_vn_put_link,
@@ -792,3 +792,98 @@ const struct inode_operations xfs_symlin .removexattr = generic_removexattr, .listxattr = xfs_vn_listxattr, }; + +STATIC void +xfs_diflags_to_iflags ( +struct inode *inode, +struct xfs_inode *ip) +{ +if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &= ~S_IMMUTABLE ; +if (ip->i_d.di_flags &XFS_DIFLAG_APPEND ) + inode->i_flags |=S_APPEND ; +else + inode->i_flags &= ~S_APPEND ; +if (ip->i_d.di_flags &XFS_DIFLAG_SYNC ) + inode->i_flags |=S_SYNC ; +else + inode->i_flags &= ~S_SYNC ; +if (ip->i_d.di_flags &XFS_DIFLAG_NOATIME ) + inode->i_flags |=S_NOATIME ; +else + inode->i_flags &= ~S_NOATIME ; +} + +/* +* Initialize the Linux inode, set up the operation vectors and +* unlock the inode. +* +* When reading existing inodes from disk this is called directly +* from xfs_iget, when creating a new inode it is called from +* xfs_ialloc after setting up the inode. +*/ +void +xfs_setup_inode ( +struct xfs_inode *ip) +{ +struct inode *inode = ip->i_vnode; + + inode->i_mode = ip->i_d.di_mode; + inode->i_nlink = ip->i_d.di_nlink; + inode->i_uid = ip->i_d.di_uid; + inode->i_gid = ip->i_d.di_gid; + +switch (inode->i_mode &S_IFMT ) { +case S_IFBLK : +case S_IFCHR : + inode->i_rdev = +MKDEV (sysv_major (ip->i_df.if_u2.if_rdev) &0x1ff , +sysv_minor (ip->i_df.if_u2.if_rdev)); +break ; +default : + inode->i_rdev =0 ; +break ; + } + + inode->i_generation = ip->i_d.di_gen; +i_size_write (inode, ip->i_d.di_size); + inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; + inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec; + 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; +xfs_diflags_to_iflags (inode, ip); +xfs_iflags_clear (ip,XFS_IMODIFIED ); + +switch (inode->i_mode &S_IFMT ) { +case S_IFREG : + inode->i_op = &xfs_inode_operations; + inode->i_fop = &xfs_file_operations; + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +case S_IFDIR : +if (xfs_sb_version_hasasciici (&XFS_M (inode->i_sb)->m_sb)) + inode->i_op = &xfs_dir_ci_inode_operations; +else + inode->i_op = &xfs_dir_inode_operations; + inode->i_fop = &xfs_dir_file_operations; +break ; +case S_IFLNK : + inode->i_op = &xfs_symlink_inode_operations; +if (!(ip->i_df.if_flags &XFS_IFINLINE )) + inode->i_mapping->a_ops = &xfs_address_space_operations; +break ; +default : + inode->i_op = &xfs_inode_operations; +init_special_inode (inode, inode->i_mode, inode->i_rdev); +break ; + } + +xfs_iflags_clear (ip,XFS_INEW ); +barrier (); + +unlock_new_inode (inode); +}
fs/xfs/linux-2.6/xfs_iops.h +3 -5
@@ -18,10 +18,7 @@#ifndef __XFS_IOPS_H__#define __XFS_IOPS_H__ -extern const struct inode_operations xfs_inode_operations; -extern const struct inode_operations xfs_dir_inode_operations; -extern const struct inode_operations xfs_dir_ci_inode_operations; -extern const struct inode_operations xfs_symlink_inode_operations; +struct xfs_inode ;extern const struct file_operations xfs_file_operations;extern const struct file_operations xfs_dir_file_operations;
@@ -29,8 +26,9 @@ extern const struct file_operations xfs_extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size); -struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );extern void xfs_ichgtime_fast (struct xfs_inode *,struct inode *,int ); +extern void xfs_setup_inode (struct xfs_inode *); +#endif /* __XFS_IOPS_H__ */
fs/xfs/linux-2.6/xfs_ksyms.c +0 -3
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);EXPORT_SYMBOL (kmem_zone_init);EXPORT_SYMBOL (kmem_zone_zalloc);EXPORT_SYMBOL (xfs_address_space_operations); -EXPORT_SYMBOL (xfs_dir_inode_operations);EXPORT_SYMBOL (xfs_dir_file_operations); -EXPORT_SYMBOL (xfs_inode_operations);EXPORT_SYMBOL (xfs_file_operations);EXPORT_SYMBOL (xfs_invis_file_operations); -EXPORT_SYMBOL (xfs_symlink_inode_operations);EXPORT_SYMBOL (xfs_buf_delwri_dequeue);EXPORT_SYMBOL (_xfs_buf_find);EXPORT_SYMBOL (xfs_buf_iostart);
fs/xfs/linux-2.6/xfs_super.h +0 -3
@@ -72,9 +72,6 @@ struct block_device;extern __uint64_t xfs_max_file_offset (unsigned int ); -extern void xfs_initialize_vnode (struct xfs_mount *mp,struct inode *vp, -struct xfs_inode *ip); -extern void xfs_flush_inode (struct xfs_inode *);extern void xfs_flush_device (struct xfs_inode *);
fs/xfs/xfs_iget.c +8 -1
@@ -288,10 +288,17 @@ finish_inode: *ipp = ip;/* +* Set up the Linux with the Linux inode. +*/ + ip->i_vnode = inode; + inode->i_private = ip; + +/* * If we have a real type for an on-disk inode, we can set ops(&unlock) * now. If it's a new inode being created, xfs_ialloc will handle it. */ -xfs_initialize_vnode (mp, inode, ip); +if (ip->i_d.di_mode !=0 ) +xfs_setup_inode (ip);return 0 ; }
fs/xfs/xfs_inode.c +1 -3
@@ -1046,7 +1046,6 @@ xfs_ialloc( {xfs_ino_t ino;xfs_inode_t *ip; -struct inode *vp;uint flags;int error;
@@ -1077,7 +1076,6 @@ xfs_ialloc( }ASSERT (ip !=NULL ); - vp =VFS_I (ip); ip->i_d.di_mode = (__uint16_t )mode; ip->i_d.di_onlink =0 ; ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(xfs_trans_log_inode (tp, ip, flags);/* now that we have an i_mode we can setup inode ops and unlock */ -xfs_initialize_vnode (tp->t_mountp, vp, ip); +xfs_setup_inode (ip); *ipp = ip;return 0 ;
fs/xfs/linux-2.6/xfs_super.c +0 -110
116 lines not on this page · raw message
I thought I got this one in already, apparently not, going in now.
Cheers,
Signature · 1 line
Niv Sardi