]> git.hungrycats.org Git - linux/commitdiff
XFS: merge strategy and bmap calls, they are two aspects of the same operation
authorStephen Lord <lord@sgi.com>
Tue, 15 Oct 2002 01:18:15 +0000 (03:18 +0200)
committerChristoph Hellwig <hch@sgi.com>
Tue, 15 Oct 2002 01:18:15 +0000 (03:18 +0200)
Modid: 2.5.x-xfs:slinx:129728a

fs/xfs/linux/xfs_aops.c
fs/xfs/linux/xfs_lrw.c
fs/xfs/linux/xfs_lrw.h
fs/xfs/linux/xfs_vnode.h
fs/xfs/xfs_vnodeops.c

index 2fd598c79e7f85ffd492973a837860976b610562..8364f6c3eb41b1054f9d130365e208a4dcfacb59 100644 (file)
@@ -49,17 +49,11 @@ map_blocks(
        int                     error, nmaps = 1;
 
 retry:
-       if (flags & PBF_FILE_ALLOCATE) {
-               VOP_STRATEGY(vp, offset, count, flags, NULL,
-                               pbmapp, &nmaps, error);
-       } else {
-               VOP_BMAP(vp, offset, count, flags, NULL,
-                               pbmapp, &nmaps, error);
-       }
+       VOP_BMAP(vp, offset, count, flags, pbmapp, &nmaps, error);
        if (flags & PBF_WRITE) {
                if (unlikely((flags & PBF_DIRECT) && nmaps &&
                    (pbmapp->pbm_flags & PBMF_DELAY))) {
-                       flags = PBF_WRITE | PBF_FILE_ALLOCATE;
+                       flags = PBF_FILE_ALLOCATE;
                        goto retry;
                }
                VMODIFY(vp);
@@ -404,7 +398,7 @@ delalloc_convert(
                if (buffer_delay(bh)) {
                        if (!mp) {
                                err = map_blocks(inode, offset, len, &map,
-                                               PBF_WRITE|PBF_FILE_ALLOCATE);
+                                               PBF_FILE_ALLOCATE);
                                if (err) {
                                        goto error;
                                }
@@ -517,7 +511,7 @@ linvfs_get_block_core(
        }
 
        VOP_BMAP(vp, offset, size,
-               create ? flags : PBF_READ, NULL,
+               create ? flags : PBF_READ,
                (struct page_buf_bmap_s *)&pbmap, &retpbbm, error);
        if (error)
                return -error;
index 05a4b4e84b4c5b4b217e930cfc559f99c7242c9a..9f4a37c46f32edbd0e147bb390b4fa2a70d6c4f7 100644 (file)
                                                << mp->m_writeio_log)
 #define XFS_STRAT_WRITE_IMAPS  2
 
-STATIC int xfs_iomap_read(xfs_iocore_t *, loff_t, size_t, int, pb_bmap_t *,
+STATIC int xfs_iomap_read(xfs_iocore_t *, loff_t, size_t, int, page_buf_bmap_t *,
                        int *);
-STATIC int xfs_iomap_write(xfs_iocore_t *, loff_t, size_t, pb_bmap_t *,
+STATIC int xfs_iomap_write(xfs_iocore_t *, loff_t, size_t, page_buf_bmap_t *,
                        int *, int);
-STATIC int xfs_iomap_write_delay(xfs_iocore_t *, loff_t, size_t, pb_bmap_t *,
+STATIC int xfs_iomap_write_delay(xfs_iocore_t *, loff_t, size_t, page_buf_bmap_t *,
                        int *, int, int);
-STATIC int xfs_iomap_write_direct(xfs_iocore_t *, loff_t, size_t, pb_bmap_t *,
+STATIC int xfs_iomap_write_direct(xfs_iocore_t *, loff_t, size_t, page_buf_bmap_t *,
                        int *, int, int);
 STATIC int _xfs_imap_to_bmap(xfs_iocore_t *, xfs_off_t, xfs_bmbt_irec_t *,
-                       pb_bmap_t *, int, int);
+                       page_buf_bmap_t *, int, int);
 
 
 /*
@@ -757,112 +757,15 @@ retry:
        return(ret);
 }
 
-/*
- * xfs_bmap() is the same as the irix xfs_bmap from xfs_rw.c
- * execpt for slight changes to the params
- */
-int
-xfs_bmap(bhv_desc_t    *bdp,
-       xfs_off_t       offset,
-       ssize_t         count,
-       int             flags,
-       struct cred     *cred,
-       pb_bmap_t       *pbmapp,
-       int             *npbmaps)
-{
-       xfs_inode_t     *ip;
-       int             error;
-       int             lockmode;
-       int             fsynced = 0;
-       vnode_t         *vp;
-
-       ip = XFS_BHVTOI(bdp);
-       ASSERT((ip->i_d.di_mode & IFMT) == IFREG);
-       ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
-              ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
-       ASSERT((flags & PBF_READ) || (flags & PBF_WRITE));
-
-       if (XFS_FORCED_SHUTDOWN(ip->i_iocore.io_mount))
-               return XFS_ERROR(EIO);
-
-       if (flags & PBF_READ) {
-               lockmode = xfs_ilock_map_shared(ip);
-               error = xfs_iomap_read(&ip->i_iocore, offset, count,
-                                XFS_BMAPI_ENTIRE, pbmapp, npbmaps);
-               xfs_iunlock_map_shared(ip, lockmode);
-       } else { /* PBF_WRITE */
-               ASSERT(flags & PBF_WRITE);
-               vp = BHV_TO_VNODE(bdp);
-               xfs_ilock(ip, XFS_ILOCK_EXCL);
-
-               /*
-                * Make sure that the dquots are there. This doesn't hold
-                * the ilock across a disk read.
-                */
-
-               if (XFS_IS_QUOTA_ON(ip->i_mount)) {
-                       if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) {
-                               if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_ILOCKED))) {
-                                       xfs_iunlock(ip, XFS_ILOCK_EXCL);
-                                       return XFS_ERROR(error);
-                               }
-                       }
-               }
-retry:
-               error = xfs_iomap_write(&ip->i_iocore, offset, count,
-                                       pbmapp, npbmaps, flags);
-               /* xfs_iomap_write unlocks/locks/unlocks */
-
-               if (error == ENOSPC) {
-                       switch (fsynced) {
-                       case 0:
-                               if (ip->i_delayed_blks) {
-                                       filemap_fdatawrite(LINVFS_GET_IP(vp)->i_mapping);
-                                       fsynced = 1;
-                               } else {
-                                       fsynced = 2;
-                                       flags |= PBF_SYNC;
-                               }
-                               error = 0;
-                               xfs_ilock(ip, XFS_ILOCK_EXCL);
-                               goto retry;
-                       case 1:
-                               fsynced = 2;
-                               if (!(flags & PBF_SYNC)) {
-                                       flags |= PBF_SYNC;
-                                       error = 0;
-                                       xfs_ilock(ip, XFS_ILOCK_EXCL);
-                                       goto retry;
-                               }
-                       case 2:
-                               sync_blockdev(vp->v_vfsp->vfs_super->s_bdev);
-                               xfs_log_force(ip->i_mount, (xfs_lsn_t)0,
-                                               XFS_LOG_FORCE|XFS_LOG_SYNC);
-
-                               error = 0;
-/**
-                               delay(HZ);
-**/
-                               fsynced++;
-                               xfs_ilock(ip, XFS_ILOCK_EXCL);
-                               goto retry;
-                       }
-               }
-       }
-
-       return XFS_ERROR(error);
-}
 
 int
-xfs_strategy(bhv_desc_t *bdp,
+xfs_strategy(xfs_inode_t *ip,
        xfs_off_t       offset,
        ssize_t         count,
        int             flags,
-       struct cred     *cred,
-       pb_bmap_t       *pbmapp,
+       page_buf_bmap_t *pbmapp,
        int             *npbmaps)
 {
-       xfs_inode_t     *ip;
        xfs_iocore_t    *io;
        xfs_mount_t     *mp;
        int             error;
@@ -878,22 +781,16 @@ xfs_strategy(bhv_desc_t *bdp,
        xfs_bmbt_irec_t imap[XFS_MAX_RW_NBMAPS];
        xfs_trans_t     *tp;
 
-       ip = XFS_BHVTOI(bdp);
-       vn_trace_entry(BHV_TO_VNODE(bdp), "xfs_strategy",
-                                       (inst_t *)__return_address);
        io = &ip->i_iocore;
        mp = ip->i_mount;
        /* is_xfs = IO_IS_XFS(io); */
        ASSERT((ip->i_d.di_mode & IFMT) == IFREG);
        ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
               ((io->io_flags & XFS_IOCORE_RT) != 0));
-       ASSERT((flags & PBF_READ) || (flags & PBF_WRITE));
 
        if (XFS_FORCED_SHUTDOWN(mp))
                return XFS_ERROR(EIO);
 
-       ASSERT(flags & PBF_WRITE);
-
        offset_fsb = XFS_B_TO_FSBT(mp, offset);
        nimaps = min(XFS_MAX_RW_NBMAPS, *npbmaps);
        end_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));
@@ -1086,12 +983,110 @@ xfs_strategy(bhv_desc_t *bdp,
 }
 
 
+/*
+ * xfs_bmap() is the same as the irix xfs_bmap from xfs_rw.c
+ * execpt for slight changes to the params
+ */
+int
+xfs_bmap(bhv_desc_t    *bdp,
+       xfs_off_t       offset,
+       ssize_t         count,
+       int             flags,
+       page_buf_bmap_t *pbmapp,
+       int             *npbmaps)
+{
+       xfs_inode_t     *ip;
+       int             error;
+       int             lockmode;
+       int             fsynced = 0;
+       vnode_t         *vp;
+
+       ip = XFS_BHVTOI(bdp);
+       ASSERT((ip->i_d.di_mode & IFMT) == IFREG);
+       ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
+              ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
+
+       if (XFS_FORCED_SHUTDOWN(ip->i_iocore.io_mount))
+               return XFS_ERROR(EIO);
+
+       if (flags & PBF_READ) {
+               lockmode = xfs_ilock_map_shared(ip);
+               error = xfs_iomap_read(&ip->i_iocore, offset, count,
+                                XFS_BMAPI_ENTIRE, pbmapp, npbmaps);
+               xfs_iunlock_map_shared(ip, lockmode);
+       } else if (flags & PBF_FILE_ALLOCATE) {
+               error = xfs_strategy(ip, offset, count, flags,
+                               pbmapp, npbmaps);
+       } else { /* PBF_WRITE */
+               ASSERT(flags & PBF_WRITE);
+               vp = BHV_TO_VNODE(bdp);
+               xfs_ilock(ip, XFS_ILOCK_EXCL);
+
+               /*
+                * Make sure that the dquots are there. This doesn't hold
+                * the ilock across a disk read.
+                */
+
+               if (XFS_IS_QUOTA_ON(ip->i_mount)) {
+                       if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) {
+                               if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_ILOCKED))) {
+                                       xfs_iunlock(ip, XFS_ILOCK_EXCL);
+                                       return XFS_ERROR(error);
+                               }
+                       }
+               }
+retry:
+               error = xfs_iomap_write(&ip->i_iocore, offset, count,
+                                       pbmapp, npbmaps, flags);
+               /* xfs_iomap_write unlocks/locks/unlocks */
+
+               if (error == ENOSPC) {
+                       switch (fsynced) {
+                       case 0:
+                               if (ip->i_delayed_blks) {
+                                       filemap_fdatawrite(LINVFS_GET_IP(vp)->i_mapping);
+                                       fsynced = 1;
+                               } else {
+                                       fsynced = 2;
+                                       flags |= PBF_SYNC;
+                               }
+                               error = 0;
+                               xfs_ilock(ip, XFS_ILOCK_EXCL);
+                               goto retry;
+                       case 1:
+                               fsynced = 2;
+                               if (!(flags & PBF_SYNC)) {
+                                       flags |= PBF_SYNC;
+                                       error = 0;
+                                       xfs_ilock(ip, XFS_ILOCK_EXCL);
+                                       goto retry;
+                               }
+                       case 2:
+                               sync_blockdev(vp->v_vfsp->vfs_super->s_bdev);
+                               xfs_log_force(ip->i_mount, (xfs_lsn_t)0,
+                                               XFS_LOG_FORCE|XFS_LOG_SYNC);
+
+                               error = 0;
+/**
+                               delay(HZ);
+**/
+                               fsynced++;
+                               xfs_ilock(ip, XFS_ILOCK_EXCL);
+                               goto retry;
+                       }
+               }
+       }
+
+       return XFS_ERROR(error);
+}
+
+
 STATIC int
 _xfs_imap_to_bmap(
        xfs_iocore_t    *io,
        xfs_off_t       offset,
        xfs_bmbt_irec_t *imap,
-       pb_bmap_t       *pbmapp,
+       page_buf_bmap_t *pbmapp,
        int             imaps,                  /* Number of imap entries */
        int             pbmaps)                 /* Number of pbmap entries */
 {
@@ -1142,7 +1137,7 @@ xfs_iomap_read(
        loff_t          offset,
        size_t          count,
        int             flags,
-       pb_bmap_t       *pbmapp,
+       page_buf_bmap_t *pbmapp,
        int             *npbmaps)
 {
        xfs_fileoff_t   offset_fsb;
@@ -1194,7 +1189,7 @@ xfs_iomap_write(
        xfs_iocore_t    *io,
        loff_t          offset,
        size_t          count,
-       pb_bmap_t       *pbmapp,
+       page_buf_bmap_t *pbmapp,
        int             *npbmaps,
        int             ioflag)
 {
@@ -1262,7 +1257,7 @@ xfs_write_bmap(
        xfs_mount_t     *mp,
        xfs_iocore_t    *io,
        xfs_bmbt_irec_t *imapp,
-       pb_bmap_t       *pbmapp,
+       page_buf_bmap_t *pbmapp,
        int             iosize,
        xfs_fileoff_t   ioalign,
        xfs_fsize_t     isize)
@@ -1332,7 +1327,7 @@ xfs_iomap_write_delay(
        xfs_iocore_t    *io,
        loff_t          offset,
        size_t          count,
-       pb_bmap_t       *pbmapp,
+       page_buf_bmap_t *pbmapp,
        int             *npbmaps,
        int             ioflag,
        int             found)
@@ -1530,7 +1525,7 @@ xfs_iomap_write_direct(
        xfs_iocore_t    *io,
        loff_t          offset,
        size_t          count,
-       pb_bmap_t       *pbmapp,
+       page_buf_bmap_t *pbmapp,
        int             *npbmaps,
        int             ioflag,
        int             found)
index 4d1967353a44c2bf2b414e3a4d01168757e0e368..3ac8eddedb23f26f292b4e8b8285c341983aff84 100644 (file)
@@ -39,8 +39,7 @@
  */
 #define XFS_MAX_RW_NBMAPS      4
 
-extern int xfs_bmap (bhv_desc_t *, xfs_off_t, ssize_t, int, struct cred *, pb_bmap_t *, int *);
-extern int xfs_strategy (bhv_desc_t *, xfs_off_t, ssize_t, int, struct cred *, pb_bmap_t *, int *);
+extern int xfs_bmap (bhv_desc_t *, xfs_off_t, ssize_t, int, page_buf_bmap_t *, int *);
 extern int xfsbdstrat (struct xfs_mount *, struct xfs_buf *);
 extern int xfs_bdstrat_cb (struct xfs_buf *);
 
index 0cc85e88ca5fd766ed450f2a5d75395f12b979ac..97443cb9ffa05ab7d30666141d04b089bd3a4bee 100644 (file)
@@ -211,8 +211,7 @@ typedef int (*vop_fid2_t)(bhv_desc_t *, struct fid *);
 typedef int    (*vop_release_t)(bhv_desc_t *);
 typedef int    (*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
 typedef void   (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
-typedef int    (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, struct cred *, struct page_buf_bmap_s *, int *);
-typedef int    (*vop_strategy_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, struct cred *, struct page_buf_bmap_s *, int *);
+typedef int    (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int, struct page_buf_bmap_s *, int *);
 typedef int    (*vop_reclaim_t)(bhv_desc_t *);
 typedef int    (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int,
                                struct cred *);
@@ -254,7 +253,6 @@ typedef struct vnodeops {
        vop_rwlock_t            vop_rwlock;
        vop_rwunlock_t          vop_rwunlock;
        vop_bmap_t              vop_bmap;
-       vop_strategy_t          vop_strategy;
        vop_reclaim_t           vop_reclaim;
        vop_attr_get_t          vop_attr_get;
        vop_attr_set_t          vop_attr_set;
@@ -286,16 +284,10 @@ typedef struct vnodeops {
        rv = _VOP_(vop_write, vp)((vp)->v_fbhv,file,iov,segs,offset,cr);\
        VN_BHV_READ_UNLOCK(&(vp)->v_bh);                                \
 }
-#define VOP_BMAP(vp,of,sz,rw,cr,b,n,rv)                                        \
+#define VOP_BMAP(vp,of,sz,rw,b,n,rv)                                   \
 {                                                                      \
        VN_BHV_READ_LOCK(&(vp)->v_bh);                                  \
-       rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,cr,b,n);         \
-       VN_BHV_READ_UNLOCK(&(vp)->v_bh);                                \
-}
-#define VOP_STRATEGY(vp,of,sz,rw,cr,b,n,rv)                            \
-{                                                                      \
-       VN_BHV_READ_LOCK(&(vp)->v_bh);                                  \
-       rv = _VOP_(vop_strategy, vp)((vp)->v_fbhv,of,sz,rw,cr,b,n);     \
+       rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n);            \
        VN_BHV_READ_UNLOCK(&(vp)->v_bh);                                \
 }
 #define VOP_OPEN(vp, cr, rv)                                           \
index 9b76c90bb5443176512bb936d3557901a337c342..07f1af20c10810397a53194d912e225354134dc6 100644 (file)
@@ -4937,7 +4937,6 @@ vnodeops_t xfs_vnodeops = {
        .vop_rwlock             = xfs_rwlock,
        .vop_rwunlock           = xfs_rwunlock,
        .vop_bmap               = xfs_bmap,
-       .vop_strategy           = xfs_strategy,
        .vop_reclaim            = xfs_reclaim,
        .vop_attr_get           = xfs_attr_get,
        .vop_attr_set           = xfs_attr_set,