decontaminate vnode operations from behavior details
PATCH 1/17 decontaminate vnode operations from behavior details
All vnode ops now take struct xfs_inode pointers and the behaviour related glue is split out into methods of it's own. This required fixing xfs_create/mkdir/symlink to not mess with the inode pointer but rather use a separate boolean for error handling. Thanks to Dave Chinner for that fix.
Signed-off-by Christoph Hellwig <[email protected]>
fs/xfs/xfs_vnodeops.c +124 -306
@@ -52,15 +52,13 @@#include "xfs_trans_space.h" #include "xfs_log_priv.h" #include "xfs_filestream.h" +#include "xfs_vnodeops.h" -STATIC int +int xfs_open ( -bhv_desc_t *bdp, -cred_t *credp) +xfs_inode_t *ip) {int mode; -bhv_vnode_t *vp =BHV_TO_VNODE (bdp); -xfs_inode_t *ip =XFS_BHVTOI (bdp);if (XFS_FORCED_SHUTDOWN (ip->i_mount))return XFS_ERROR (EIO );
@@ -69,7 +67,7 @@ xfs_open(* If it's a directory with any blocks, read-ahead block 0 * as we're almost certain to have the next operation be a read there. */ -if (VN_ISDIR (vp) && ip->i_d.di_nextents >0 ) { +if (S_ISDIR (ip->i_d.di_mode) && ip->i_d.di_nextents >0 ) { mode =xfs_ilock_map_shared (ip);if (ip->i_d.di_nextents >0 ) (void )xfs_da_reada_buf (NULL , ip,0 ,XFS_DATA_FORK );
@@ -81,23 +79,17 @@ xfs_open(/* * xfs_getattr */ -STATIC int +int xfs_getattr ( -bhv_desc_t *bdp, +xfs_inode_t *ip,bhv_vattr_t *vap, -int flags, -cred_t *credp) +int flags) { -xfs_inode_t *ip; -xfs_mount_t *mp; -bhv_vnode_t *vp; +bhv_vnode_t *vp =XFS_ITOV (ip); +xfs_mount_t *mp = ip->i_mount; - vp =BHV_TO_VNODE (bdp);vn_trace_entry (vp, __FUNCTION__, (inst_t *)__return_address); - ip =XFS_BHVTOI (bdp); - mp = ip->i_mount; -if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO );
@@ -215,14 +207,14 @@ xfs_getattr(*/ int xfs_setattr ( -bhv_desc_t *bdp, +xfs_inode_t *ip,bhv_vattr_t *vap,int flags,cred_t *credp) { -xfs_inode_t *ip; +bhv_vnode_t *vp =XFS_ITOV (ip); +xfs_mount_t *mp = ip->i_mount;xfs_trans_t *tp; -xfs_mount_t *mp;int mask;int code;uint lock_flags;
@@ -230,14 +222,12 @@ xfs_setattr(uid_t uid=0 , iuid=0 ;gid_t gid=0 , igid=0 ;int timeflags =0 ; -bhv_vnode_t *vp;xfs_prid_t projid=0 , iprojid=0 ;int mandlock_before, mandlock_after;struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;int file_owner;int need_iolock =1 ; - vp =BHV_TO_VNODE (bdp);vn_trace_entry (vp, __FUNCTION__, (inst_t *)__return_address);if (vp->v_vfsp->vfs_flag &VFS_RDONLY )
@@ -251,9 +241,6 @@ xfs_setattr(return XFS_ERROR (EINVAL ); } - ip =XFS_BHVTOI (bdp); - mp = ip->i_mount; -if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO );
@@ -924,19 +911,16 @@ xfs_setattr(* xfs_access * Null conversion from vnode mode bits to inode mode bits, as in efs. */ -STATIC int +int xfs_access ( -bhv_desc_t *bdp, +xfs_inode_t *ip,int mode,cred_t *credp) { -xfs_inode_t *ip;int error; -vn_trace_entry (BHV_TO_VNODE (bdp), __FUNCTION__, - (inst_t *)__return_address); +vn_trace_entry (XFS_ITOV (ip), __FUNCTION__, (inst_t *)__return_address); - ip =XFS_BHVTOI (bdp);xfs_ilock (ip,XFS_ILOCK_SHARED ); error =xfs_iaccess (ip, mode, credp);xfs_iunlock (ip,XFS_ILOCK_SHARED );
@@ -998,16 +982,11 @@ xfs_readlink_bmap(return error; } -/* -* xfs_readlink -* -*/ -STATIC int +int xfs_readlink ( -bhv_desc_t *bdp, +xfs_inode_t *ip,char *link) { -xfs_inode_t *ip =XFS_BHVTOI (bdp);xfs_mount_t *mp = ip->i_mount;int pathlen;int error =0 ;
@@ -1047,23 +1026,18 @@ xfs_readlink(* be held while flushing the data, so acquire after we're done * with that. */ -STATIC int +int xfs_fsync ( -bhv_desc_t *bdp, +xfs_inode_t *ip,int flag, -cred_t *credp,xfs_off_t start,xfs_off_t stop) { -xfs_inode_t *ip;xfs_trans_t *tp;int error;int log_flushed =0 , changed =1 ; -vn_trace_entry (BHV_TO_VNODE (bdp), - __FUNCTION__, (inst_t *)__return_address); - - ip =XFS_BHVTOI (bdp); +vn_trace_entry (XFS_ITOV (ip), __FUNCTION__, (inst_t *)__return_address);ASSERT (start >=0 && stop >=-1 );
@@ -1530,19 +1504,14 @@ xfs_inactive_attrs(return 0 ; } -STATIC int +int xfs_release ( -bhv_desc_t *bdp) +xfs_inode_t *ip) { -xfs_inode_t *ip; -bhv_vnode_t *vp; -xfs_mount_t *mp; +bhv_vnode_t *vp =XFS_ITOV (ip); +xfs_mount_t *mp = ip->i_mount;int error; - vp =BHV_TO_VNODE (bdp); - ip =XFS_BHVTOI (bdp); - mp = ip->i_mount; -if (!VN_ISREG (vp) || (ip->i_d.di_mode ==0 ))return 0 ;
@@ -1608,13 +1577,11 @@ xfs_release(* now be truncated. Also, we clear all of the read-ahead state * kept for the inode here since the file is now closed. */ -STATIC int +int xfs_inactive ( -bhv_desc_t *bdp, -cred_t *credp) +xfs_inode_t *ip) { -xfs_inode_t *ip; -bhv_vnode_t *vp; +bhv_vnode_t *vp =XFS_ITOV (ip);xfs_bmap_free_t free_list;xfs_fsblock_t first_block;int committed;
@@ -1623,11 +1590,8 @@ xfs_inactive(int error;int truncate; - vp =BHV_TO_VNODE (bdp);vn_trace_entry (vp, __FUNCTION__, (inst_t *)__return_address); - ip =XFS_BHVTOI (bdp); -/* * If the inode is already free, then there can be nothing * to clean up here.
@@ -1828,34 +1792,24 @@ xfs_inactive( } -/* -* xfs_lookup -*/ -STATIC int +int xfs_lookup ( -bhv_desc_t *dir_bdp, +xfs_inode_t *dp,bhv_vname_t *dentry, -bhv_vnode_t **vpp, -int flags, -bhv_vnode_t *rdir, -cred_t *credp) +bhv_vnode_t **vpp) { -xfs_inode_t *dp, *ip; +xfs_inode_t *ip;xfs_ino_t e_inum;int error;uint lock_mode; -bhv_vnode_t *dir_vp; - - dir_vp =BHV_TO_VNODE (dir_bdp); -vn_trace_entry (dir_vp, __FUNCTION__, (inst_t *)__return_address); - dp =XFS_BHVTOI (dir_bdp); +vn_trace_entry (XFS_ITOV (dp), __FUNCTION__, (inst_t *)__return_address);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return XFS_ERROR (EIO ); lock_mode =xfs_ilock_map_shared (dp); - error =xfs_dir_lookup_int (dir_bdp, lock_mode, dentry, &e_inum, &ip); + error =xfs_dir_lookup_int (dp, lock_mode, dentry, &e_inum, &ip);if (!error) { *vpp =XFS_ITOV (ip);ITRACE (ip);
@@ -1864,29 +1818,25 @@ xfs_lookup(return error; } - -/* -* xfs_create (create a new file). -*/ -STATIC int +int xfs_create ( -bhv_desc_t *dir_bdp, +xfs_inode_t *dp,bhv_vname_t *dentry,bhv_vattr_t *vap,bhv_vnode_t **vpp,cred_t *credp) {char *name =VNAME (dentry); -bhv_vnode_t *dir_vp; -xfs_inode_t *dp, *ip; +xfs_mount_t *mp = dp->i_mount; +bhv_vnode_t *dir_vp =XFS_ITOV (dp); +xfs_inode_t *ip;bhv_vnode_t *vp =NULL ;xfs_trans_t *tp; -xfs_mount_t *mp;xfs_dev_t rdev;int error;xfs_bmap_free_t free_list;xfs_fsblock_t first_block; -boolean_t dp_joined_to_trans; +boolean_t unlock_dp_on_error =B_FALSE ;int dm_event_sent =0 ;uint cancel_flags;int committed;
@@ -1897,12 +1847,8 @@ xfs_create(int namelen;ASSERT (!*vpp); - dir_vp =BHV_TO_VNODE (dir_bdp);vn_trace_entry (dir_vp, __FUNCTION__, (inst_t *)__return_address); - dp =XFS_BHVTOI (dir_bdp); - mp = dp->i_mount; - dm_di_mode = vap->va_mode; namelen =VNAMELEN (dentry);
@@ -1940,7 +1886,6 @@ xfs_create( goto std_return; ip =NULL ; - dp_joined_to_trans =B_FALSE ; tp =xfs_trans_alloc (mp,XFS_TRANS_CREATE ); cancel_flags =XFS_TRANS_RELEASE_LOG_RES ;
@@ -1960,11 +1905,11 @@ xfs_create( }if (error) { cancel_flags =0 ; - dp =NULL ; goto error_return; }xfs_ilock (dp,XFS_ILOCK_EXCL |XFS_ILOCK_PARENT ); + unlock_dp_on_error =B_TRUE ;XFS_BMAP_INIT (&free_list, &first_block);
@@ -1998,15 +1943,15 @@ xfs_create(ASSERT (ismrlocked (&ip->i_lock,MR_UPDATE ));/* -* Now we join the directory inode to the transaction. -* We do not do it earlier because xfs_dir_ialloc -* might commit the previous transaction (and release -* all the locks). +* Now we join the directory inode to the transaction. We do not do it +* earlier because xfs_dir_ialloc might commit the previous transaction +* (and release all the locks). An error from here on will result in +* the transaction cancel unlocking dp so don't do it explicitly in the +* error path. */ -VN_HOLD (dir_vp);xfs_trans_ijoin (tp, dp,XFS_ILOCK_EXCL ); - dp_joined_to_trans =B_TRUE ; + unlock_dp_on_error =B_FALSE ; error = xfs_dir_createname(tp, dp, name, namelen, ip->i_ino, &first_block, &free_list, resblks ?
@@ -2072,7 +2017,7 @@ xfs_create( std_return:if ((*vpp || (error !=0 && dm_event_sent !=0 )) && -DM_EVENT_ENABLED (XFS_BHVTOI (dir_bdp),DM_EVENT_POSTCREATE )) { +DM_EVENT_ENABLED (dp,DM_EVENT_POSTCREATE )) { (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE, dir_vp, DM_RIGHT_NULL, *vpp ? vp:NULL,
@@ -2089,11 +2034,12 @@ std_return:if (tp !=NULL )xfs_trans_cancel (tp, cancel_flags); -if (!dp_joined_to_trans && (dp !=NULL )) -xfs_iunlock (dp,XFS_ILOCK_EXCL );XFS_QM_DQRELE (mp, udqp);XFS_QM_DQRELE (mp, gdqp); +if (unlock_dp_on_error) +xfs_iunlock (dp,XFS_ILOCK_EXCL ); + goto std_return; abort_rele:
@@ -2364,22 +2310,16 @@ int remove_which_error_return = 0;#define REMOVE_DEBUG_TRACE (x)#endif /* ! DEBUG */ - -/* -* xfs_remove -* -*/ -STATIC int +int xfs_remove ( -bhv_desc_t *dir_bdp, -bhv_vname_t *dentry, -cred_t *credp) +xfs_inode_t *dp, +bhv_vname_t *dentry) { -bhv_vnode_t *dir_vp; +bhv_vnode_t *dir_vp =XFS_ITOV (dp);char *name =VNAME (dentry); -xfs_inode_t *dp, *ip; +xfs_mount_t *mp = dp->i_mount; +xfs_inode_t *ip;xfs_trans_t *tp =NULL ; -xfs_mount_t *mp;int error =0 ;xfs_bmap_free_t free_list;xfs_fsblock_t first_block;
@@ -2390,12 +2330,8 @@ xfs_remove(uint resblks;int namelen; - dir_vp =BHV_TO_VNODE (dir_bdp);vn_trace_entry (dir_vp, __FUNCTION__, (inst_t *)__return_address); - dp =XFS_BHVTOI (dir_bdp); - mp = dp->i_mount; -if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO );
@@ -2620,42 +2556,32 @@ xfs_remove( goto std_return; } - -/* -* xfs_link -* -*/ -STATIC int +int xfs_link ( -bhv_desc_t *target_dir_bdp, +xfs_inode_t *tdp,bhv_vnode_t *src_vp, -bhv_vname_t *dentry, -cred_t *credp) +bhv_vname_t *dentry) { -xfs_inode_t *tdp, *sip; +bhv_vnode_t *target_dir_vp =XFS_ITOV (tdp); +xfs_mount_t *mp = tdp->i_mount; +xfs_inode_t *sip =xfs_vtoi (src_vp);xfs_trans_t *tp; -xfs_mount_t *mp;xfs_inode_t *ips[2 ];int error;xfs_bmap_free_t free_list;xfs_fsblock_t first_block;int cancel_flags;int committed; -bhv_vnode_t *target_dir_vp;int resblks;char *target_name =VNAME (dentry);int target_namelen; - target_dir_vp =BHV_TO_VNODE (target_dir_bdp);vn_trace_entry (target_dir_vp, __FUNCTION__, (inst_t *)__return_address);vn_trace_entry (src_vp, __FUNCTION__, (inst_t *)__return_address); target_namelen =VNAMELEN (dentry);ASSERT (!VN_ISDIR (src_vp)); - sip =xfs_vtoi (src_vp); - tdp =XFS_BHVTOI (target_dir_bdp); - mp = tdp->i_mount;if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO );
@@ -2788,50 +2714,38 @@ std_return: } -/* -* xfs_mkdir -* -*/ -STATIC int +int xfs_mkdir ( -bhv_desc_t *dir_bdp, +xfs_inode_t *dp,bhv_vname_t *dentry,bhv_vattr_t *vap,bhv_vnode_t **vpp,cred_t *credp) { +bhv_vnode_t *dir_vp =XFS_ITOV (dp);char *dir_name =VNAME (dentry); -xfs_inode_t *dp; +int dir_namelen =VNAMELEN (dentry); +xfs_mount_t *mp = dp->i_mount;xfs_inode_t *cdp;/* inode of created dir */ bhv_vnode_t *cvp;/* vnode of created dir */ xfs_trans_t *tp; -xfs_mount_t *mp;int cancel_flags;int error;int committed;xfs_bmap_free_t free_list;xfs_fsblock_t first_block; -bhv_vnode_t *dir_vp; -boolean_t dp_joined_to_trans; +boolean_t unlock_dp_on_error =B_FALSE ;boolean_t created =B_FALSE ;int dm_event_sent =0 ;xfs_prid_t prid;struct xfs_dquot *udqp, *gdqp;uint resblks;int dm_di_mode; -int dir_namelen; - - dir_vp =BHV_TO_VNODE (dir_bdp); - dp =XFS_BHVTOI (dir_bdp); - mp = dp->i_mount;if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO ); - dir_namelen =VNAMELEN (dentry); - tp =NULL ; - dp_joined_to_trans =B_FALSE ; dm_di_mode = vap->va_mode;if (DM_EVENT_ENABLED (dp,DM_EVENT_CREATE )) {
@@ -2879,11 +2793,11 @@ xfs_mkdir( }if (error) { cancel_flags =0 ; - dp =NULL ; goto error_return; }xfs_ilock (dp,XFS_ILOCK_EXCL |XFS_ILOCK_PARENT ); + unlock_dp_on_error =B_TRUE ;/* * Check for directory link count overflow.
@@ -2920,11 +2834,13 @@ xfs_mkdir(* Now we add the directory inode to the transaction. * We waited until now since xfs_dir_ialloc might start * a new transaction. Had we joined the transaction -* earlier, the locks might have gotten released. +* earlier, the locks might have gotten released. An error +* from here on will result in the transaction cancel +* unlocking dp so don't do it explicitly in the error path. */ VN_HOLD (dir_vp);xfs_trans_ijoin (tp, dp,XFS_ILOCK_EXCL ); - dp_joined_to_trans =B_TRUE ; + unlock_dp_on_error =B_FALSE ;XFS_BMAP_INIT (&free_list, &first_block);
@@ -2992,7 +2908,7 @@ xfs_mkdir( std_return:if ((created || (error !=0 && dm_event_sent !=0 )) && -DM_EVENT_ENABLED (XFS_BHVTOI (dir_bdp),DM_EVENT_POSTCREATE )) { +DM_EVENT_ENABLED (dp,DM_EVENT_POSTCREATE )) { (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE, dir_vp, DM_RIGHT_NULL, created ? XFS_ITOV(cdp):NULL,
@@ -3012,49 +2928,36 @@ std_return:XFS_QM_DQRELE (mp, udqp);XFS_QM_DQRELE (mp, gdqp); -if (!dp_joined_to_trans && (dp !=NULL )) { +if (unlock_dp_on_error)xfs_iunlock (dp,XFS_ILOCK_EXCL ); - } goto std_return; } - -/* -* xfs_rmdir -* -*/ -STATIC int +int xfs_rmdir ( -bhv_desc_t *dir_bdp, -bhv_vname_t *dentry, -cred_t *credp) +xfs_inode_t *dp, +bhv_vname_t *dentry) { +bhv_vnode_t *dir_vp =XFS_ITOV (dp);char *name =VNAME (dentry); -xfs_inode_t *dp; -xfs_inode_t *cdp;/* child directory */ +int namelen =VNAMELEN (dentry); +xfs_mount_t *mp = dp->i_mount; +xfs_inode_t *cdp;/* child directory */ xfs_trans_t *tp; -xfs_mount_t *mp;int error;xfs_bmap_free_t free_list;xfs_fsblock_t first_block;int cancel_flags;int committed; -bhv_vnode_t *dir_vp;int dm_di_mode =S_IFDIR ;int last_cdp_link; -int namelen;uint resblks; - dir_vp =BHV_TO_VNODE (dir_bdp); - dp =XFS_BHVTOI (dir_bdp); - mp = dp->i_mount; -vn_trace_entry (dir_vp, __FUNCTION__, (inst_t *)__return_address); -if (XFS_FORCED_SHUTDOWN (XFS_BHVTOI (dir_bdp)->i_mount)) +if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO ); - namelen =VNAMELEN (dentry);if (!xfs_get_dir_entry (dentry, &cdp)) { dm_di_mode = cdp->i_d.di_mode;
@@ -3269,25 +3172,24 @@ xfs_rmdir( goto std_return; } -STATIC int +int xfs_symlink ( -bhv_desc_t *dir_bdp, +xfs_inode_t *dp,bhv_vname_t *dentry,bhv_vattr_t *vap,char *target_path,bhv_vnode_t **vpp,cred_t *credp) { +bhv_vnode_t *dir_vp =XFS_ITOV (dp); +xfs_mount_t *mp = dp->i_mount;xfs_trans_t *tp; -xfs_mount_t *mp; -xfs_inode_t *dp;xfs_inode_t *ip;int error;int pathlen;xfs_bmap_free_t free_list;xfs_fsblock_t first_block; -boolean_t dp_joined_to_trans; -bhv_vnode_t *dir_vp; +boolean_t unlock_dp_on_error =B_FALSE ;uint cancel_flags;int committed;xfs_fileoff_t first_fsb;
@@ -3306,16 +3208,12 @@ xfs_symlink(int link_namelen; *vpp =NULL ; - dir_vp =BHV_TO_VNODE (dir_bdp); - dp =XFS_BHVTOI (dir_bdp); - dp_joined_to_trans =B_FALSE ; error =0 ; ip =NULL ; tp =NULL ;vn_trace_entry (dir_vp, __FUNCTION__, (inst_t *)__return_address); - mp = dp->i_mount;if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO );
@@ -3401,11 +3299,11 @@ xfs_symlink( }if (error) { cancel_flags =0 ; - dp =NULL ; goto error_return; }xfs_ilock (dp,XFS_ILOCK_EXCL |XFS_ILOCK_PARENT ); + unlock_dp_on_error =B_TRUE ;/* * Check whether the directory allows new symlinks or not.
@@ -3446,9 +3344,14 @@ xfs_symlink( }ITRACE (ip); +/* +* An error after we've joined dp to the transaction will result in the +* transaction cancel unlocking dp so don't do it explicitly in the +* error path. +*/ VN_HOLD (dir_vp);xfs_trans_ijoin (tp, dp,XFS_ILOCK_EXCL ); - dp_joined_to_trans =B_TRUE ; + unlock_dp_on_error =B_FALSE ;/* * Also attach the dquot(s) to it, if applicable.
@@ -3554,7 +3457,7 @@ xfs_symlink(/* Fall through to std_return with error = 0 or errno from * xfs_trans_commit */ std_return: -if (DM_EVENT_ENABLED (XFS_BHVTOI (dir_bdp),DM_EVENT_POSTSYMLINK )) { +if (DM_EVENT_ENABLED (dp,DM_EVENT_POSTSYMLINK )) { (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTSYMLINK, dir_vp, DM_RIGHT_NULL, error ? NULL : XFS_ITOV(ip),
@@ -3581,9 +3484,8 @@ std_return:XFS_QM_DQRELE (mp, udqp);XFS_QM_DQRELE (mp, gdqp); -if (!dp_joined_to_trans && (dp !=NULL )) { +if (unlock_dp_on_error)xfs_iunlock (dp,XFS_ILOCK_EXCL ); - } goto std_return; }
@@ -3595,20 +3497,16 @@ std_return:* A fid routine that takes a pointer to a previously allocated * fid structure (like xfs_fast_fid) but uses a 64 bit inode number. */ -STATIC int +int xfs_fid2 ( -bhv_desc_t *bdp, +xfs_inode_t *ip,fid_t *fidp) { -xfs_inode_t *ip; -xfs_fid2_t *xfid; +xfs_fid2_t *xfid = (xfs_fid2_t *)fidp; -vn_trace_entry (BHV_TO_VNODE (bdp), __FUNCTION__, - (inst_t *)__return_address); +vn_trace_entry (XFS_ITOV (ip), __FUNCTION__, (inst_t *)__return_address);ASSERT (sizeof (fid_t) >=sizeof (xfs_fid2_t)); - xfid = (xfs_fid2_t *)fidp; - ip =XFS_BHVTOI (bdp); xfid->fid_len =sizeof (xfs_fid2_t) -sizeof (xfid->fid_len); xfid->fid_pad =0 ;/*
@@ -3622,21 +3520,13 @@ xfs_fid2( } -/* -* xfs_rwlock -*/ int xfs_rwlock ( -bhv_desc_t *bdp, +xfs_inode_t *ip,bhv_vrwlock_t locktype) { -xfs_inode_t *ip; -bhv_vnode_t *vp; - - vp =BHV_TO_VNODE (bdp); -if (VN_ISDIR (vp)) +if (S_ISDIR (ip->i_d.di_mode))return 1 ; - ip =XFS_BHVTOI (bdp);if (locktype ==VRWLOCK_WRITE ) {xfs_ilock (ip,XFS_IOLOCK_EXCL ); }else if (locktype ==VRWLOCK_TRY_READ ) {
@@ -3653,21 +3543,13 @@ xfs_rwlock( } -/* -* xfs_rwunlock -*/ void xfs_rwunlock ( -bhv_desc_t *bdp, +xfs_inode_t *ip,bhv_vrwlock_t locktype) { -xfs_inode_t *ip; -bhv_vnode_t *vp; - - vp =BHV_TO_VNODE (bdp); -if (VN_ISDIR (vp)) -return ; - ip =XFS_BHVTOI (bdp); +if (S_ISDIR (ip->i_d.di_mode)) +return ;if (locktype ==VRWLOCK_WRITE ) {/* * In the write case, we may have added a new entry to
@@ -3685,20 +3567,16 @@ xfs_rwunlock(return ; } -STATIC int + +int xfs_inode_flush ( -bhv_desc_t *bdp, +xfs_inode_t *ip,int flags) { -xfs_inode_t *ip; -xfs_mount_t *mp; -xfs_inode_log_item_t *iip; +xfs_mount_t *mp = ip->i_mount; +xfs_inode_log_item_t *iip = ip->i_itemp;int error =0 ; - ip =XFS_BHVTOI (bdp); - mp = ip->i_mount; - iip = ip->i_itemp; -if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO );
@@ -3766,24 +3644,20 @@ xfs_inode_flush(return error; } +int -xfs_set_dmattrs ( -bhv_desc_t *bdp, +xfs_set_dmattrs ( +xfs_inode_t *ip,u_int evmask, -u_int16_t state, -cred_t *credp) +u_int16_t state) { -xfs_inode_t *ip; +xfs_mount_t *mp = ip->i_mount;xfs_trans_t *tp; -xfs_mount_t *mp;int error;if (!capable (CAP_SYS_ADMIN ))return XFS_ERROR (EPERM ); - ip =XFS_BHVTOI (bdp); - mp = ip->i_mount; -if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO );
@@ -3806,15 +3680,11 @@ xfs_set_dmattrs (return error; } -STATIC int +int xfs_reclaim ( -bhv_desc_t *bdp) +xfs_inode_t *ip) { -xfs_inode_t *ip; -bhv_vnode_t *vp; - - vp =BHV_TO_VNODE (bdp); - ip =XFS_BHVTOI (bdp); +bhv_vnode_t *vp =XFS_ITOV (ip);vn_trace_entry (vp, __FUNCTION__, (inst_t *)__return_address);
@@ -4491,35 +4361,29 @@ xfs_free_file_space(*/ int xfs_change_file_space ( -bhv_desc_t *bdp, +xfs_inode_t *ip,int cmd,xfs_flock64_t *bf,xfs_off_t offset,cred_t *credp,int attr_flags) { +xfs_mount_t *mp = ip->i_mount;int clrprealloc;int error;xfs_fsize_t fsize; -xfs_inode_t *ip; -xfs_mount_t *mp;int setprealloc;xfs_off_t startoffset;xfs_off_t llen;xfs_trans_t *tp;bhv_vattr_t va; -bhv_vnode_t *vp; - vp =BHV_TO_VNODE (bdp); -vn_trace_entry (vp, __FUNCTION__, (inst_t *)__return_address); - - ip =XFS_BHVTOI (bdp); - mp = ip->i_mount; +vn_trace_entry (XFS_ITOV (ip), __FUNCTION__, (inst_t *)__return_address);/* * must be a regular file and have write permission */ -if (!VN_ISREG (vp)) +if (!S_ISREG (ip->i_d.di_mode))return XFS_ERROR (EINVAL );xfs_ilock (ip,XFS_ILOCK_SHARED );
@@ -4601,7 +4465,7 @@ xfs_change_file_space( va.va_mask =XFS_AT_SIZE ; va.va_size = startoffset; - error =xfs_setattr (bdp, &va, attr_flags, credp); + error =xfs_setattr (ip, &va, attr_flags, credp);if (error)return error;
@@ -4660,49 +4524,3 @@ xfs_change_file_space(return error; } - -bhv_vnodeops_t xfs_vnodeops = { -BHV_IDENTITY_INIT (VN_BHV_XFS ,VNODE_POSITION_XFS ), - .vop_open = xfs_open, - .vop_read = xfs_read, -#ifdef HAVE_SENDFILE - .vop_sendfile = xfs_sendfile, -#endif -#ifdef HAVE_SPLICE - .vop_splice_read = xfs_splice_read, - .vop_splice_write = xfs_splice_write, -#endif - .vop_write = xfs_write, - .vop_ioctl = xfs_ioctl, - .vop_getattr = xfs_getattr, - .vop_setattr = xfs_setattr, - .vop_access = xfs_access, - .vop_lookup = xfs_lookup, - .vop_create = xfs_create, - .vop_remove = xfs_remove, - .vop_link = xfs_link, - .vop_rename = xfs_rename, - .vop_mkdir = xfs_mkdir, - .vop_rmdir = xfs_rmdir, - .vop_readdir = xfs_readdir, - .vop_symlink = xfs_symlink, - .vop_readlink = xfs_readlink, - .vop_fsync = xfs_fsync, - .vop_inactive = xfs_inactive, - .vop_fid2 = xfs_fid2, - .vop_rwlock = xfs_rwlock, - .vop_rwunlock = xfs_rwunlock, - .vop_bmap = xfs_bmap, - .vop_reclaim = xfs_reclaim, - .vop_attr_get = xfs_attr_get, - .vop_attr_set = xfs_attr_set, - .vop_attr_remove = xfs_attr_remove, - .vop_attr_list = xfs_attr_list, - .vop_link_removed = (vop_link_removed_t )fs_noval, - .vop_vnode_change = (vop_vnode_change_t )fs_noval, - .vop_tosspages = fs_tosspages, - .vop_flushinval_pages = fs_flushinval_pages, - .vop_flush_pages = fs_flush_pages, - .vop_release = xfs_release, - .vop_iflush = xfs_inode_flush, -};
fs/xfs/linux-2.6/xfs_ioctl.c +21 -27
152 lines not on this page · raw message
fs/xfs/xfs_rename.c +6 -12
@@ -129,8 +129,7 @@ xfs_lock_for_rename( lock_mode =xfs_ilock_map_shared (dp2); } - error =xfs_dir_lookup_int (XFS_ITOBHV (dp2), lock_mode, - vname2, &inum2, &ip2); + error =xfs_dir_lookup_int (dp2, lock_mode, vname2, &inum2, &ip2);if (error ==ENOENT ) {/* target does not need to exist. */ inum2 =0 ; }else if (error) {
@@ -222,15 +221,15 @@ xfs_lock_for_rename(*/ int xfs_rename ( -bhv_desc_t *src_dir_bdp, +xfs_inode_t *src_dp,bhv_vname_t *src_vname,bhv_vnode_t *target_dir_vp, -bhv_vname_t *target_vname, -cred_t *credp) +bhv_vname_t *target_vname) { +bhv_vnode_t *src_dir_vp =XFS_ITOV (src_dp);xfs_trans_t *tp; -xfs_inode_t *src_dp, *target_dp, *src_ip, *target_ip; -xfs_mount_t *mp; +xfs_inode_t *target_dp, *src_ip, *target_ip; +xfs_mount_t *mp = src_dp->i_mount;int new_parent;/* moving to a new dir */ int src_is_directory;/* src_name is a directory */ int error;
@@ -240,7 +239,6 @@ xfs_rename(int committed;xfs_inode_t *inodes[4 ];int target_ip_dropped =0 ;/* dropped target_ip link? */ -bhv_vnode_t *src_dir_vp;int spaceres;int target_link_zero =0 ;int num_inodes;
@@ -249,7 +247,6 @@ xfs_rename(int src_namelen =VNAMELEN (src_vname);int target_namelen =VNAMELEN (target_vname); - src_dir_vp =BHV_TO_VNODE (src_dir_bdp);vn_trace_entry (src_dir_vp,"xfs_rename" , (inst_t *)__return_address);vn_trace_entry (target_dir_vp,"xfs_rename" , (inst_t *)__return_address);
@@ -262,9 +259,6 @@ xfs_rename(return XFS_ERROR (EXDEV ); } - src_dp =XFS_BHVTOI (src_dir_bdp); - mp = src_dp->i_mount; -if (DM_EVENT_ENABLED (src_dp,DM_EVENT_RENAME ) ||DM_EVENT_ENABLED (target_dp,DM_EVENT_RENAME )) { error = XFS_SEND_NAMESP(mp, DM_EVENT_RENAME,
fs/xfs/xfs_rw.h +0 -8
@@ -90,14 +90,6 @@ extern void xfs_ioerror_alert(char *func/* * Prototypes for functions in xfs_vnodeops.c. */ -extern int xfs_rwlock (bhv_desc_t *bdp,bhv_vrwlock_t write_lock); -extern void xfs_rwunlock (bhv_desc_t *bdp,bhv_vrwlock_t write_lock); -extern int xfs_setattr (bhv_desc_t *,bhv_vattr_t *vap,int flags, -cred_t *credp); -extern int xfs_change_file_space (bhv_desc_t *bdp,int cmd,xfs_flock64_t *bf, -xfs_off_t offset,cred_t *credp,int flags); -extern int xfs_set_dmattrs (bhv_desc_t *bdp,u_int evmask,u_int16_t state, -cred_t *credp);extern int xfs_free_eofblocks (struct xfs_mount *mp,struct xfs_inode *ip,int flags);
fs/xfs/xfs_utils.c +2 -7
@@ -65,20 +65,15 @@ xfs_get_dir_entry(int xfs_dir_lookup_int ( -bhv_desc_t *dir_bdp, +xfs_inode_t *dp,uint lock_mode,bhv_vname_t *dentry,xfs_ino_t *inum,xfs_inode_t **ipp) { -bhv_vnode_t *dir_vp; -xfs_inode_t *dp;int error; - dir_vp =BHV_TO_VNODE (dir_bdp); -vn_trace_entry (dir_vp, __FUNCTION__, (inst_t *)__return_address); - - dp =XFS_BHVTOI (dir_bdp); +vn_trace_entry (XFS_ITOV (dp), __FUNCTION__, (inst_t *)__return_address); error =xfs_dir_lookup (NULL , dp,VNAME (dentry),VNAMELEN (dentry), inum);if (!error) {
fs/xfs/xfs_utils.h +1 -3
@@ -23,10 +23,8 @@#define ITRACE (ip) vn_trace_ref(XFS_ITOV(ip), __FILE__, __LINE__, \ (inst_t *)__return_address) -extern int xfs_rename (bhv_desc_t *,bhv_vname_t *,bhv_vnode_t *, -bhv_vname_t *,cred_t *);extern int xfs_get_dir_entry (bhv_vname_t *,xfs_inode_t **); -extern int xfs_dir_lookup_int (bhv_desc_t *,uint ,bhv_vname_t *,xfs_ino_t *, +extern int xfs_dir_lookup_int (xfs_inode_t *,uint ,bhv_vname_t *,xfs_ino_t *,xfs_inode_t **);extern int xfs_truncate_file (xfs_mount_t *,xfs_inode_t *); extern int xfs_dir_ialloc (xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t,
fs/xfs/Makefile-linux-2.6 +1 -0
@@ -79,6 +79,7 @@ xfs-y += xfs_alloc.o \ xfs_utils.o \ xfs_vfsops.o \ xfs_vnodeops.o \ + xfs_vnodeops_bhv.o \ xfs_rw.o \ xfs_dmops.o \ xfs_qmops.o
fs/xfs/xfs_vnodeops.h new file +86 -0
86 lines not on this page · raw message
fs/xfs/xfs_vnodeops_bhv.c new file +438 -0
438 lines not on this page · raw message
fs/xfs/xfs_attr.c +25 -15
@@ -156,10 +156,14 @@ xfs_attr_fetch(xfs_inode_t *ip, const ch }int -xfs_attr_get (bhv_desc_t *bdp,const char *name,char *value,int *valuelenp, -int flags,struct cred *cred) +xfs_attr_get ( +xfs_inode_t *ip, +const char *name, +char *value, +int *valuelenp, +int flags, +cred_t *cred) { -xfs_inode_t *ip =XFS_BHVTOI (bdp);int error, namelen;XFS_STATS_INC (xs_attr_get);
@@ -417,10 +421,13 @@ out: }int -xfs_attr_set (bhv_desc_t *bdp,const char *name,char *value,int valuelen,int flags, -struct cred *cred) +xfs_attr_set ( +xfs_inode_t *dp, +const char *name, +char *value, +int valuelen, +int flags) { -xfs_inode_t *dp;int namelen; namelen =strlen (name);
@@ -429,7 +436,6 @@ xfs_attr_set(bhv_desc_t *bdp, const charXFS_STATS_INC (xs_attr_set); - dp =XFS_BHVTOI (bdp);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return (EIO );
@@ -563,10 +569,12 @@ out: }int -xfs_attr_remove (bhv_desc_t *bdp,const char *name,int flags,struct cred *cred) +xfs_attr_remove ( +xfs_inode_t *dp, +const char *name, +int flags) { -xfs_inode_t *dp; -int namelen; +int namelen; namelen =strlen (name);if (namelen >=MAXNAMELEN )
@@ -574,7 +582,6 @@ xfs_attr_remove(bhv_desc_t *bdp, const cXFS_STATS_INC (xs_attr_remove); - dp =XFS_BHVTOI (bdp);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return (EIO );
@@ -702,11 +709,14 @@ xfs_attr_kern_list_sizes(xfs_attr_list_c* success. */ int -xfs_attr_list (bhv_desc_t *bdp,char *buffer,int bufsize,int flags, -attrlist_cursor_kern_t *cursor,struct cred *cred) +xfs_attr_list ( +xfs_inode_t *dp, +char *buffer, +int bufsize, +int flags, +attrlist_cursor_kern_t *cursor) {xfs_attr_list_context_t context; -xfs_inode_t *dp;int error;XFS_STATS_INC (xs_attr_list);
@@ -731,7 +741,7 @@ xfs_attr_list(bhv_desc_t *bdp, char *buf/* * Initialize the output buffer. */ - context.dp = dp =XFS_BHVTOI (bdp); + context.dp = dp; context.cursor = cursor; context.count =0 ; context.dupcnt =0 ;
fs/xfs/xfs_attr.h +0 -4
@@ -159,12 +159,8 @@ struct xfs_da_args;/* * Overall external interface routines. */ -int xfs_attr_get (bhv_desc_t *,const char *,char *,int *,int ,struct cred *); -int xfs_attr_set (bhv_desc_t *,const char *,char *,int ,int ,struct cred *);int xfs_attr_set_int (struct xfs_inode *,const char *,int ,char *,int ,int ); -int xfs_attr_remove (bhv_desc_t *,const char *,int ,struct cred *);int xfs_attr_remove_int (struct xfs_inode *,const char *,int ,int ); -int xfs_attr_list (bhv_desc_t *,char *,int ,int ,struct attrlist_cursor_kern *,struct cred *);int xfs_attr_list_int (struct xfs_attr_list_context *);int xfs_attr_inactive (struct xfs_inode *dp);
fs/xfs/linux-2.6/xfs_iops.h +0 -2
@@ -26,8 +26,6 @@ extern const struct file_operations xfs_extern const struct file_operations xfs_dir_file_operations;extern const struct file_operations xfs_invis_file_operations; -extern int xfs_ioctl (struct bhv_desc *,struct inode *,struct file *, -int ,unsigned int ,void __user *);struct xfs_inode ;extern void xfs_ichgtime (struct xfs_inode *,int );
fs/xfs/linux-2.6/xfs_lrw.c +29 -45
231 lines not on this page · raw message
fs/xfs/xfs_bmap.c +2 -4
@@ -5764,7 +5764,7 @@ xfs_getbmapx_fix_eof_hole(*/ int /* error code */ xfs_getbmap ( -bhv_desc_t *bdp,/* XFS behavior descriptor*/ +xfs_inode_t *ip,struct getbmap *bmv,/* user bmap structure */ void __user *ap,/* pointer to user's array */ int interface)/* interface flags */
@@ -5773,7 +5773,6 @@ xfs_getbmap(int error;/* return value */ __int64_t fixlen;/* length for -1 case */ int i;/* extent number */ -xfs_inode_t *ip;/* xfs incore inode pointer */ bhv_vnode_t *vp;/* corresponding vnode */ int lock;/* lock state */ xfs_bmbt_irec_t *map;/* buffer for user's data */
@@ -5791,8 +5790,7 @@ xfs_getbmap(int bmapi_flags;/* flags for xfs_bmapi */ __int32_t oflags;/* getbmapx bmv_oflags field */ - vp =BHV_TO_VNODE (bdp); - ip =XFS_BHVTOI (bdp); + vp =XFS_ITOV (ip); mp = ip->i_mount; whichfork = interface &BMV_IF_ATTRFORK ?XFS_ATTR_FORK :XFS_DATA_FORK ;
fs/xfs/xfs_bmap.h +1 -1
@@ -335,7 +335,7 @@ xfs_bunmapi(*/ int /* error code */ xfs_getbmap ( -bhv_desc_t *bdp,/* XFS behavior descriptor*/ +xfs_inode_t *ip,struct getbmap *bmv,/* user bmap structure */ void __user *ap,/* pointer to user's array */ int iflags);/* interface flags */
fs/xfs/linux-2.6/xfs_lrw.h +0 -17
@@ -71,28 +71,11 @@ extern void xfs_inval_cached_trace(struc#define xfs_inval_cached_trace (io, offset, len, first, last)#endif -extern int xfs_bmap (struct bhv_desc *,xfs_off_t ,ssize_t ,int , -struct xfs_iomap *,int *);extern int xfsbdstrat (struct xfs_mount *,struct xfs_buf *);extern int xfs_bdstrat_cb (struct xfs_buf *);extern int xfs_dev_is_read_only (struct xfs_mount *,char *);extern int xfs_zero_eof (struct bhv_vnode *,struct xfs_iocore *,xfs_off_t ,xfs_fsize_t ); -extern ssize_t xfs_read (struct bhv_desc *,struct kiocb *, -const struct iovec *,unsigned int , -loff_t *,int ,struct cred *); -extern ssize_t xfs_write (struct bhv_desc *,struct kiocb *, -const struct iovec *,unsigned int , -loff_t *,int ,struct cred *); -extern ssize_t xfs_sendfile (struct bhv_desc *,struct file *, -loff_t *,int ,size_t ,read_actor_t , -void *,struct cred *); -extern ssize_t xfs_splice_read (struct bhv_desc *,struct file *,loff_t *, -struct pipe_inode_info *,size_t ,int ,int , -struct cred *); -extern ssize_t xfs_splice_write (struct bhv_desc *,struct pipe_inode_info *, -struct file *,loff_t *,size_t ,int ,int , -struct cred *);#endif /* __XFS_LRW_H__ */
fs/xfs/linux-2.6/xfs_fs_subr.c +31 -17
97 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_fs_subr.h +0 -4
@@ -18,12 +18,8 @@#ifndef __XFS_FS_SUBR_H__#define __XFS_FS_SUBR_H__ -struct cred ;extern int fs_noerr (void );extern int fs_nosys (void );extern void fs_noval (void ); -extern void fs_tosspages (bhv_desc_t *,xfs_off_t ,xfs_off_t ,int ); -extern int fs_flushinval_pages (bhv_desc_t *,xfs_off_t ,xfs_off_t ,int ); -extern int fs_flush_pages (bhv_desc_t *,xfs_off_t ,xfs_off_t ,uint64_t ,int );#endif /* __XFS_FS_SUBR_H__ */
fs/xfs/dmapi/xfs_dm.c +4 -13
@@ -46,6 +46,7 @@#include "xfs_attr.h" #include "xfs_attr_leaf.h" #include "xfs_inode_item.h" +#include "xfs_vnodeops.h" #include <dmapi.h> #include <dmapi_kern.h> #include "xfs_dm.h"
@@ -178,22 +179,17 @@ xfs_dm_send_data_event( bhv_vrwlock_t *locktype) {int error; -bhv_desc_t *bdp;xfs_inode_t *ip;uint16_t dmstate;struct inode *inode =vn_to_inode (vp);/* Returns positive errors to XFS */ - bdp =bhv_lookup_range (VN_BHV_HEAD (vp), -VNODE_POSITION_XFS ,VNODE_POSITION_XFS ); -ASSERT (bdp); - ip =xfs_vtoi (vp); do { dmstate = ip->i_iocore.io_dmstate; if (locktype) - xfs_rwunlock(bdp, *locktype); + xfs_rwunlock(ip, *locktype); up_rw_sems(inode, flags);
@@ -204,7 +200,7 @@ xfs_dm_send_data_event(down_rw_sems (inode, flags);if (locktype) -xfs_rwlock (bdp, *locktype); +xfs_rwlock (ip, *locktype); }while (!error && (ip->i_iocore.io_dmstate != dmstate));return error;
@@ -2506,7 +2502,6 @@ xfs_dm_punch_hole( {xfs_flock64_t bf;int error =0 ; -bhv_desc_t *xbdp;xfs_inode_t *ip;xfs_mount_t *mp;dm_size_t align;
@@ -2529,10 +2524,6 @@ xfs_dm_punch_hole(if (error)return -EBUSY ; - xbdp =bhv_lookup_range (VN_BHV_HEAD (vp), -VNODE_POSITION_XFS ,VNODE_POSITION_XFS ); -ASSERT (xbdp); - ip =xfs_vtoi (vp); mp = ip->i_mount;
@@ -2585,7 +2576,7 @@ xfs_dm_punch_hole( off, len, align);#endif - error =xfs_change_file_space (xbdp,XFS_IOC_UNRESVSP , &bf, + error =xfs_change_file_space (ip,XFS_IOC_UNRESVSP , &bf, (xfs_off_t )off, sys_cred,ATTR_DMI |ATTR_NOLOCK );/*
fs/xfs/linux-2.6/xfs_ksyms.c +4 -3
@@ -64,6 +64,7 @@#include "xfs_utils.h" #include "xfs_iomap.h" #include "xfs_filestream.h" +#include "xfs_vnodeops.h" #include "support/ktrace.h"
@@ -150,9 +151,9 @@ EXPORT_SYMBOL(bhv_module_exit);EXPORT_SYMBOL (bhv_remove_vfsops);EXPORT_SYMBOL (bhv_remove_all_vfsops);EXPORT_SYMBOL (bhv_remove_not_first); -EXPORT_SYMBOL (fs_flush_pages); -EXPORT_SYMBOL (fs_flushinval_pages); -EXPORT_SYMBOL (fs_tosspages); +EXPORT_SYMBOL (xfs_flush_pages); +EXPORT_SYMBOL (xfs_flushinval_pages); +EXPORT_SYMBOL (xfs_tosspages);EXPORT_SYMBOL (fs_noval);EXPORT_SYMBOL (icmn_err);EXPORT_SYMBOL (kmem_alloc);
fs/xfs/xfs_dir2.c +2 -4
@@ -292,18 +292,16 @@ xfs_dir_removename(*/ int xfs_readdir ( -bhv_desc_t *dir_bdp, +xfs_inode_t *dp,void *dirent,size_t bufsize,xfs_off_t *offset,filldir_t filldir) { -xfs_inode_t *dp =XFS_BHVTOI (dir_bdp);int rval;/* return value */ int v;/* type-checking value */ -vn_trace_entry (BHV_TO_VNODE (dir_bdp), __FUNCTION__, - (inst_t *)__return_address); +vn_trace_entry (XFS_ITOV (dp), __FUNCTION__, (inst_t *)__return_address);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return XFS_ERROR (EIO );
fs/xfs/xfs_dir2.h +0 -2
@@ -84,8 +84,6 @@ extern int xfs_dir_replace(struct xfs_trextern int xfs_dir_canenter (struct xfs_trans *tp,struct xfs_inode *dp,char *name,int namelen);extern int xfs_dir_ino_validate (struct xfs_mount *mp,xfs_ino_t ino); -extern int xfs_readdir (bhv_desc_t *dir_bdp,void *dirent,size_t bufsize, -xfs_off_t *offset,filldir_t filldir);/* * Utility routines for v2 directories.