Received: with ECARTIS (v1.0.0; list linux-xfs); Thu, 16 Feb 2006 10:59:49 -0800 (PST) Received: from pentafluge.infradead.org (pentafluge.infradead.org [213.146.154.40]) by oss.sgi.com (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id k1GIxSm2031622 for ; Thu, 16 Feb 2006 10:59:41 -0800 Received: from hch by pentafluge.infradead.org with local (Exim 4.54 #1 (Red Hat Linux)) id 1F9oMY-0004eB-GS; Thu, 16 Feb 2006 19:00:22 +0000 Date: Thu, 16 Feb 2006 19:00:22 +0000 From: Christoph Hellwig To: Eric Sandeen Cc: Christoph Hellwig , linux-xfs@oss.sgi.com Subject: Re: fs/xfs/xfs_dmapi.c vanished from CVS? Message-ID: <20060216190022.GA17824@infradead.org> References: <20060216144537.GA12409@infradead.org> <43F4C979.3080802@sgi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43F4C979.3080802@sgi.com> User-Agent: Mutt/1.4.2.1i X-SRS-Rewrite: SMTP reverse-path rewritten from by pentafluge.infradead.org See http://www.infradead.org/rpr.html X-archive-position: 7348 X-ecartis-version: Ecartis v1.0.0 Sender: linux-xfs-bounce@oss.sgi.com Errors-to: linux-xfs-bounce@oss.sgi.com X-original-sender: hch@infradead.org Precedence: bulk X-list: linux-xfs Content-Length: 11991 Lines: 504 On Thu, Feb 16, 2006 at 12:50:33PM -0600, Eric Sandeen wrote: > Christoph Hellwig wrote: > >I tried to rediff and send an older patch, but fs/xfs/xfs_dmapi.c in the > >CVS tree vanished. It's still in the SuSE kernel, though including the > >related hacks. What's the story here? > > > > http://oss.sgi.com/cgi-bin/cvsweb.cgi/xfs-linux/xfs_rw.h.diff?r1=text&tr1=1.78&r2=text&tr2=1.77&f=h > xfs_dmapi.c - 1.142 - renamed to dmapi/xfs_dm.c 1.1 > > from nathan's most recent change... A thanks, must be the 1^16th location of the dmapi code in the Linux tree :) And here's the patch: -- Use xfs_vtoi and xfs_vfstom in the dmapi code instead of opencoding behaviour lookups. Signed-off-by: Christoph Hellwig Index: xfs-2.6.x/fs/xfs/dmapi/xfs_dm.c =================================================================== --- xfs-2.6.x.orig/fs/xfs/dmapi/xfs_dm.c 2006-02-16 03:47:52.000000000 +0100 +++ xfs-2.6.x/fs/xfs/dmapi/xfs_dm.c 2006-02-16 19:58:24.000000000 +0100 @@ -182,7 +182,7 @@ /* Returns positive errors to XFS */ XFS_BHV_LOOKUP(vp, bdp); - ip = XFS_BHVTOI(bdp); + ip = xfs_vtoi(vp); do { dmstate = ip->i_iocore.io_dmstate; if (locktype) @@ -254,20 +254,17 @@ #ifdef DEBUG_RIGHTS STATIC int -xfs_bdp_to_hexhandle( - bhv_desc_t *bdp, +xfs_vp_to_hexhandle( + vnode_t *vp, u_int type, char *buffer) { dm_handle_t handle; - vnode_t *vp; u_char *ip; int length; int error; int i; - vp = BHV_TO_VNODE(bdp); - if ((error = dm_vp_to_handle(vp, &handle))) return(error); @@ -825,14 +822,13 @@ STATIC int xfs_dm_f_get_eventlist( - bhv_desc_t *bdp, + xfs_inode_t *ip, dm_right_t right, u_int nelem, dm_eventset_t *eventsetp, /* in kernel space! */ u_int *nelemp) /* in kernel space! */ { dm_eventset_t eventset; - xfs_inode_t *ip; if (right < DM_RIGHT_SHARED) return(EACCES); @@ -844,7 +840,6 @@ all other object types, the bits will already be zero. Handy, huh? */ - ip = XFS_BHVTOI(bdp); eventset = ip->i_d.di_dmevmask; /* Now copy the event mask and event count back to the caller. We @@ -867,7 +862,8 @@ STATIC int xfs_dm_f_set_eventlist( - bhv_desc_t *bdp, + vnode_t *vp, + xfs_inode_t *ip, dm_right_t right, dm_eventset_t *eventsetp, /* in kernel space! */ u_int maxevent) @@ -875,8 +871,6 @@ dm_eventset_t eventset; dm_eventset_t max_mask; dm_eventset_t valid_events; - vnode_t *vp; - xfs_inode_t *ip; xfs_trans_t *tp; xfs_mount_t *mp; int error; @@ -889,7 +883,6 @@ return(EINVAL); max_mask = (1 << maxevent) - 1; - vp = BHV_TO_VNODE(bdp); if (VN_ISDIR(vp)) { valid_events = DM_XFS_VALID_DIRECTORY_EVENTS; } else { /* file or symlink */ @@ -906,7 +899,6 @@ max_mask &= ~(1 <i_mount; tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS); error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0); @@ -932,19 +924,17 @@ STATIC int xfs_dm_fs_get_eventlist( - bhv_desc_t *bdp, + xfs_mount_t *mp, dm_right_t right, u_int nelem, dm_eventset_t *eventsetp, /* in kernel space! */ u_int *nelemp) /* in kernel space! */ { dm_eventset_t eventset; - xfs_mount_t *mp; if (right < DM_RIGHT_SHARED) return(EACCES); - mp = XFS_BHVTOI(bdp)->i_mount; eventset = mp->m_dmevmask; /* Now copy the event mask and event count back to the caller. We @@ -968,21 +958,19 @@ STATIC int xfs_dm_fs_set_eventlist( - bhv_desc_t *bdp, + xfs_mount_t *mp, dm_right_t right, dm_eventset_t *eventsetp, /* in kernel space! */ u_int maxevent) { dm_eventset_t eventset; dm_eventset_t max_mask; - xfs_mount_t *mp; if (right < DM_RIGHT_EXCL) return(EACCES); eventset = *eventsetp; - mp = XFS_BHVTOI(bdp)->i_mount; if (maxevent >= sizeof(mp->m_dmevmask) * NBBY) return(EINVAL); max_mask = (1 << maxevent) - 1; @@ -1001,15 +989,13 @@ STATIC int xfs_dm_direct_ok( - bhv_desc_t *bdp, + xfs_inode_t *ip, dm_off_t off, dm_size_t len, void __user *bufp) { xfs_mount_t *mp; - xfs_inode_t *ip; - ip = XFS_BHVTOI(bdp); mp = ip->i_mount; /* Realtime files can ONLY do direct I/O. */ @@ -1068,7 +1054,7 @@ struct file *file; struct inode *inode = LINVFS_GET_IP(vp); struct dentry *dentry; - bhv_desc_t *xbdp; + xfs_inode_t *ip; if ((off < 0) || (off > i_size_read(inode)) || !S_ISREG(inode->i_mode)) return EINVAL; @@ -1085,8 +1071,8 @@ */ oflags |= O_LARGEFILE | O_NONBLOCK; - XFS_BHV_LOOKUP(vp, xbdp); - if (xfs_dm_direct_ok(xbdp, off, len, bufp)) + ip = xfs_vtoi(vp); + if (xfs_dm_direct_ok(ip, off, len, bufp)) oflags |= O_DIRECT; if (fflag & O_SYNC) @@ -1162,12 +1148,9 @@ { #ifdef DEBUG_RIGHTS char buffer[sizeof(dm_handle_t) * 2 + 1]; - bhv_desc_t *bdp; vnode_t *vp = LINVFS_GET_VP(inode); - XFS_BHV_LOOKUP(vp, bdp); - - if (!xfs_bdp_to_hexhandle(bdp, type, buffer)) { + if (!xfs_vp_to_hexhandle(vp, type, buffer)) { printf("dm_downgrade_right: old %d new %d type %d handle %s\n", right, DM_RIGHT_SHARED, type, buffer); } else { @@ -1205,7 +1188,6 @@ xfs_filblks_t fsb_length; dm_off_t startoff; int elem; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); xfs_bmbt_irec_t *bmp = NULL; u_int bmpcnt = 50; @@ -1223,9 +1205,7 @@ if (copy_from_user( &startoff, offp, sizeof(startoff))) return(-EFAULT); - XFS_BHV_LOOKUP(vp, xbdp); - - ip = XFS_BHVTOI(xbdp); + ip = xfs_vtoi(vp); mp = ip->i_mount; ASSERT(mp); @@ -1342,7 +1322,6 @@ int nelems; u_int statstruct_sz; dm_attrloc_t loc; - bhv_desc_t *mp_bdp; xfs_mount_t *mp; vnode_t *vp = LINVFS_GET_VP(inode); vfs_t *vfsp = vp->v_vfsp; @@ -1384,9 +1363,8 @@ return(-E2BIG); } - mp_bdp = bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops); - ASSERT(mp_bdp); - mp = XFS_BHVTOM(mp_bdp); + mp = xfs_vfstom(vfsp); + ASSERT(mp); /* Build the on-disk version of the attribute name. */ @@ -1456,7 +1434,6 @@ int nelems; u_int statstruct_sz; dm_attrloc_t loc; - bhv_desc_t *mp_bdp; xfs_mount_t *mp; vnode_t *vp = LINVFS_GET_VP(inode); vfs_t *vfsp = vp->v_vfsp; @@ -1490,9 +1467,8 @@ return(-E2BIG); } - mp_bdp = bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops); - ASSERT(mp_bdp); - mp = XFS_BHVTOM(mp_bdp); + mp = xfs_vfstom(vfsp); + ASSERT(mp); /* @@ -1753,7 +1729,6 @@ dm_dioinfo_t dio; xfs_mount_t *mp; xfs_inode_t *ip; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); /* Returns negative errors to DMAPI */ @@ -1761,9 +1736,7 @@ if (right < DM_RIGHT_SHARED) return(-EACCES); - XFS_BHV_LOOKUP(vp, xbdp); - - ip = XFS_BHVTOI(xbdp); + ip = xfs_vtoi(vp); mp = ip->i_mount; dio.d_miniosz = dio.d_mem = MIN_DIO_SIZE(mp); @@ -1799,7 +1772,6 @@ int error = 0; dm_attrloc_t loc; dm_attrloc_t prev_loc; - bhv_desc_t *mp_bdp; vnode_t *vp = LINVFS_GET_VP(inode); vfs_t *vfsp = vp->v_vfsp; uint dir_gen = 0; @@ -1820,12 +1792,11 @@ if ((inode->i_mode & S_IFMT) != S_IFDIR) return(-EINVAL); - mp_bdp = bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops); - ASSERT(mp_bdp); dp = xfs_vtoi(vp); ASSERT(dp); - mp = XFS_BHVTOM(mp_bdp); + mp = xfs_vfstom(vfsp); + ASSERT(mp); if (buflen < DM_STAT_SIZE(dm_stat_t, 0)) { *rvp = 1; /* tell caller to try again */ @@ -2011,18 +1982,16 @@ u_int *nelemp) { int error; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); + xfs_inode_t *ip = xfs_vtoi(vp); /* Returns negative errors to DMAPI */ - XFS_BHV_LOOKUP(vp, xbdp); - if (type == DM_FSYS_OBJ) { - error = xfs_dm_fs_get_eventlist(xbdp, right, nelem, + error = xfs_dm_fs_get_eventlist(ip->i_mount, right, nelem, eventsetp, nelemp); } else { - error = xfs_dm_f_get_eventlist(xbdp, right, nelem, + error = xfs_dm_f_get_eventlist(ip, right, nelem, eventsetp, nelemp); } return(-error); /* Returns negative error to DMAPI */ @@ -2040,7 +2009,6 @@ dm_stat_t stat; xfs_inode_t *ip; xfs_mount_t *mp; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); /* Returns negative errors to DMAPI */ @@ -2048,11 +2016,9 @@ if (right < DM_RIGHT_SHARED) return(-EACCES); - XFS_BHV_LOOKUP(vp, xbdp); - /* Find the mount point. */ - ip = XFS_BHVTOI(xbdp); + ip = xfs_vtoi(vp); mp = ip->i_mount; xfs_ilock(ip, XFS_ILOCK_SHARED); @@ -2083,7 +2049,6 @@ dm_region_t region; xfs_inode_t *ip; u_int elem; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); /* Returns negative errors to DMAPI */ @@ -2091,9 +2056,7 @@ if (right < DM_RIGHT_SHARED) return(-EACCES); - XFS_BHV_LOOKUP(vp, xbdp); - - ip = XFS_BHVTOI(xbdp); + ip = xfs_vtoi(vp); evmask = ip->i_d.di_dmevmask; /* read the mask "atomically" */ /* Get the file's current managed region flags out of the @@ -2340,7 +2303,6 @@ uint lock_flags; xfs_fsize_t realsize; u_int bsize; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); /* Returns negative errors to DMAPI */ @@ -2348,9 +2310,7 @@ if (right < DM_RIGHT_SHARED) return(-EACCES); - XFS_BHV_LOOKUP(vp, xbdp); - - ip = XFS_BHVTOI(xbdp); + ip = xfs_vtoi(vp); if ((ip->i_d.di_mode & S_IFMT) != S_IFREG) return(-EINVAL); @@ -2406,7 +2366,7 @@ return -EBUSY; XFS_BHV_LOOKUP(vp, xbdp); - xip = XFS_BHVTOI(xbdp); + xip = xfs_vtoi(vp); mp = xip->i_mount; bsize = mp->m_sb.sb_blocksize; if (off & (bsize-1)) { @@ -2494,12 +2454,9 @@ { #ifdef DEBUG_RIGHTS char buffer[sizeof(dm_handle_t) * 2 + 1]; - bhv_desc_t *bdp; vnode_t *vp = LINVFS_GET_VP(inode); - XFS_BHV_LOOKUP(vp, bdp); - - if (!xfs_bdp_to_hexhandle(bdp, type, buffer)) { + if (!xfs_vp_to_hexhandle(vp, type, buffer)) { printf("dm_release_right: old %d type %d handle %s\n", right, type, buffer); } else { @@ -2554,12 +2511,9 @@ { #ifdef DEBUG_RIGHTS char buffer[sizeof(dm_handle_t) * 2 + 1]; - bhv_desc_t *bdp; vnode_t *vp = LINVFS_GET_VP(inode); - XFS_BHV_LOOKUP(vp, bdp); - - if (!xfs_bdp_to_hexhandle(bdp, type, buffer)) { + if (!xfs_vp_to_hexhandle(vp, type, buffer)) { printf("dm_request_right: old %d new %d type %d flags 0x%x " "handle %s\n", right, newright, type, flags, buffer); } else { @@ -2625,17 +2579,15 @@ u_int maxevent) { int error; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); + xfs_inode_t *ip = xfs_vtoi(vp); /* Returns negative errors to DMAPI */ - XFS_BHV_LOOKUP(vp, xbdp); - if (type == DM_FSYS_OBJ) { - error = xfs_dm_fs_set_eventlist(xbdp, right, eventsetp, maxevent); + error = xfs_dm_fs_set_eventlist(ip->i_mount, right, eventsetp, maxevent); } else { - error = xfs_dm_f_set_eventlist(xbdp, right, eventsetp, maxevent); + error = xfs_dm_f_set_eventlist(vp, ip, right, eventsetp, maxevent); } return(-error); /* Return negative error to DMAPI */ } @@ -2744,7 +2696,6 @@ dm_eventset_t mr_mask; int error; u_int exactflag; - bhv_desc_t *xbdp; vnode_t *vp = LINVFS_GET_VP(inode); /* Returns negative errors to DMAPI */ @@ -2785,8 +2736,7 @@ bits, add in the new ones, and update the file's mask. */ - XFS_BHV_LOOKUP(vp, xbdp); - ip = XFS_BHVTOI(xbdp); + ip = xfs_vtoi(vp); if (new_mask & prohibited_mr_events(vp)) { /* If the change is simply to remove the READ @@ -2874,12 +2824,9 @@ { #ifdef DEBUG_RIGHTS char buffer[sizeof(dm_handle_t) * 2 + 1]; - bhv_desc_t *bdp; vnode_t *vp = LINVFS_GET_VP(inode); - XFS_BHV_LOOKUP(vp, bdp); - - if (!xfs_bdp_to_hexhandle(bdp, type, buffer)) { + if (!xfs_vp_to_hexhandle(vp, type, buffer)) { printf("dm_upgrade_right: old %d new %d type %d handle %s\n", right, DM_RIGHT_EXCL, type, buffer); } else { @@ -3040,7 +2987,6 @@ { vnode_t *vp; xfs_inode_t *ip; - bhv_desc_t *bdp; int error = 0; dm_eventtype_t max_event = DM_EVENT_READ; vrwlock_t locktype; @@ -3075,8 +3021,7 @@ return -EACCES; } - XFS_BHV_LOOKUP(vp, bdp); - ip = XFS_BHVTOI(bdp); + ip = xfs_vtoi(vp); /* Figure out how much of the file is being requested by the user. */ offset = 0; /* beginning of file, for now */