]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/linux-2.6/xfs_lrw.c
ipg: balance locking in irq handler
[linux-2.6-omap-h63xx.git] / fs / xfs / linux-2.6 / xfs_lrw.c
index 558076dd07522af6566d8e9468566a31c55bdd44..d6a8dddb2268bab8a341499d0debadba041f3928 100644 (file)
@@ -48,6 +48,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_utils.h"
 #include "xfs_iomap.h"
+#include "xfs_vnodeops.h"
 
 #include <linux/capability.h>
 #include <linux/writeback.h>
@@ -134,45 +135,34 @@ xfs_iozero(
        loff_t                  pos,    /* offset in file               */
        size_t                  count)  /* size of data to zero         */
 {
-       unsigned                bytes;
        struct page             *page;
        struct address_space    *mapping;
        int                     status;
 
        mapping = ip->i_mapping;
        do {
-               unsigned long index, offset;
+               unsigned offset, bytes;
+               void *fsdata;
 
                offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */
-               index = pos >> PAGE_CACHE_SHIFT;
                bytes = PAGE_CACHE_SIZE - offset;
                if (bytes > count)
                        bytes = count;
 
-               status = -ENOMEM;
-               page = grab_cache_page(mapping, index);
-               if (!page)
-                       break;
-
-               status = mapping->a_ops->prepare_write(NULL, page, offset,
-                                                       offset + bytes);
+               status = pagecache_write_begin(NULL, mapping, pos, bytes,
+                                       AOP_FLAG_UNINTERRUPTIBLE,
+                                       &page, &fsdata);
                if (status)
-                       goto unlock;
-
-               memclear_highpage_flush(page, offset, bytes);
+                       break;
 
-               status = mapping->a_ops->commit_write(NULL, page, offset,
-                                                       offset + bytes);
-               if (!status) {
-                       pos += bytes;
-                       count -= bytes;
-               }
+               zero_user_page(page, offset, bytes, KM_USER0);
 
-unlock:
-               unlock_page(page);
-               page_cache_release(page);
-               if (status)
-                       break;
+               status = pagecache_write_end(NULL, mapping, pos, bytes, bytes,
+                                       page, fsdata);
+               WARN_ON(status <= 0); /* can't return less than zero! */
+               pos += bytes;
+               count -= bytes;
+               status = 0;
        } while (count);
 
        return (-status);
@@ -180,27 +170,22 @@ unlock:
 
 ssize_t                        /* bytes read, or (-)  error */
 xfs_read(
-       bhv_desc_t              *bdp,
+       xfs_inode_t             *ip,
        struct kiocb            *iocb,
        const struct iovec      *iovp,
        unsigned int            segs,
        loff_t                  *offset,
-       int                     ioflags,
-       cred_t                  *credp)
+       int                     ioflags)
 {
        struct file             *file = iocb->ki_filp;
        struct inode            *inode = file->f_mapping->host;
+       bhv_vnode_t             *vp = XFS_ITOV(ip);
+       xfs_mount_t             *mp = ip->i_mount;
        size_t                  size = 0;
-       ssize_t                 ret;
+       ssize_t                 ret = 0;
        xfs_fsize_t             n;
-       xfs_inode_t             *ip;
-       xfs_mount_t             *mp;
-       bhv_vnode_t             *vp;
        unsigned long           seg;
 
-       ip = XFS_BHVTOI(bdp);
-       vp = BHV_TO_VNODE(bdp);
-       mp = ip->i_mount;
 
        XFS_STATS_INC(xs_read_calls);
 
@@ -224,7 +209,7 @@ xfs_read(
                                mp->m_rtdev_targp : mp->m_ddev_targp;
                if ((*offset & target->bt_smask) ||
                    (size & target->bt_smask)) {
-                       if (*offset == ip->i_d.di_size) {
+                       if (*offset == ip->i_size) {
                                return (0);
                        }
                        return -XFS_ERROR(EINVAL);
@@ -245,13 +230,11 @@ xfs_read(
                mutex_lock(&inode->i_mutex);
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
 
-       if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
-           !(ioflags & IO_INVIS)) {
+       if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) {
                bhv_vrwlock_t locktype = VRWLOCK_READ;
                int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
 
-               ret = -XFS_SEND_DATA(mp, DM_EVENT_READ,
-                                       BHV_TO_VNODE(bdp), *offset, size,
+               ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *offset, size,
                                        dmflags, &locktype);
                if (ret) {
                        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
@@ -263,9 +246,14 @@ xfs_read(
 
        if (unlikely(ioflags & IO_ISDIRECT)) {
                if (VN_CACHED(vp))
-                       bhv_vop_flushinval_pages(vp, ctooff(offtoct(*offset)),
-                                                -1, FI_REMAPF_LOCKED);
+                       ret = xfs_flushinval_pages(ip,
+                                       ctooff(offtoct(*offset)),
+                                       -1, FI_REMAPF_LOCKED);
                mutex_unlock(&inode->i_mutex);
+               if (ret) {
+                       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
+                       return ret;
+               }
        }
 
        xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
@@ -282,62 +270,17 @@ xfs_read(
        return ret;
 }
 
-ssize_t
-xfs_sendfile(
-       bhv_desc_t              *bdp,
-       struct file             *filp,
-       loff_t                  *offset,
-       int                     ioflags,
-       size_t                  count,
-       read_actor_t            actor,
-       void                    *target,
-       cred_t                  *credp)
-{
-       xfs_inode_t             *ip = XFS_BHVTOI(bdp);
-       xfs_mount_t             *mp = ip->i_mount;
-       ssize_t                 ret;
-
-       XFS_STATS_INC(xs_read_calls);
-       if (XFS_FORCED_SHUTDOWN(mp))
-               return -EIO;
-
-       xfs_ilock(ip, XFS_IOLOCK_SHARED);
-
-       if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&
-           (!(ioflags & IO_INVIS))) {
-               bhv_vrwlock_t locktype = VRWLOCK_READ;
-               int error;
-
-               error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),
-                                     *offset, count,
-                                     FILP_DELAY_FLAG(filp), &locktype);
-               if (error) {
-                       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-                       return -error;
-               }
-       }
-       xfs_rw_enter_trace(XFS_SENDFILE_ENTER, &ip->i_iocore,
-                  (void *)(unsigned long)target, count, *offset, ioflags);
-       ret = generic_file_sendfile(filp, offset, count, actor, target);
-       if (ret > 0)
-               XFS_STATS_ADD(xs_read_bytes, ret);
-
-       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-       return ret;
-}
-
 ssize_t
 xfs_splice_read(
-       bhv_desc_t              *bdp,
+       xfs_inode_t             *ip,
        struct file             *infilp,
        loff_t                  *ppos,
        struct pipe_inode_info  *pipe,
        size_t                  count,
        int                     flags,
-       int                     ioflags,
-       cred_t                  *credp)
+       int                     ioflags)
 {
-       xfs_inode_t             *ip = XFS_BHVTOI(bdp);
+       bhv_vnode_t             *vp = XFS_ITOV(ip);
        xfs_mount_t             *mp = ip->i_mount;
        ssize_t                 ret;
 
@@ -347,13 +290,11 @@ xfs_splice_read(
 
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
 
-       if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&
-           (!(ioflags & IO_INVIS))) {
+       if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) {
                bhv_vrwlock_t locktype = VRWLOCK_READ;
                int error;
 
-               error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),
-                                       *ppos, count,
+               error = XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *ppos, count,
                                        FILP_DELAY_FLAG(infilp), &locktype);
                if (error) {
                        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
@@ -372,20 +313,20 @@ xfs_splice_read(
 
 ssize_t
 xfs_splice_write(
-       bhv_desc_t              *bdp,
+       xfs_inode_t             *ip,
        struct pipe_inode_info  *pipe,
        struct file             *outfilp,
        loff_t                  *ppos,
        size_t                  count,
        int                     flags,
-       int                     ioflags,
-       cred_t                  *credp)
+       int                     ioflags)
 {
-       xfs_inode_t             *ip = XFS_BHVTOI(bdp);
+       bhv_vnode_t             *vp = XFS_ITOV(ip);
        xfs_mount_t             *mp = ip->i_mount;
+       xfs_iocore_t            *io = &ip->i_iocore;
        ssize_t                 ret;
        struct inode            *inode = outfilp->f_mapping->host;
-       xfs_fsize_t             isize;
+       xfs_fsize_t             isize, new_size;
 
        XFS_STATS_INC(xs_write_calls);
        if (XFS_FORCED_SHUTDOWN(ip->i_mount))
@@ -393,19 +334,25 @@ xfs_splice_write(
 
        xfs_ilock(ip, XFS_IOLOCK_EXCL);
 
-       if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_WRITE) &&
-           (!(ioflags & IO_INVIS))) {
+       if (DM_EVENT_ENABLED(ip, DM_EVENT_WRITE) && !(ioflags & IO_INVIS)) {
                bhv_vrwlock_t locktype = VRWLOCK_WRITE;
                int error;
 
-               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, BHV_TO_VNODE(bdp),
-                                       *ppos, count,
+               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp, *ppos, count,
                                        FILP_DELAY_FLAG(outfilp), &locktype);
                if (error) {
                        xfs_iunlock(ip, XFS_IOLOCK_EXCL);
                        return -error;
                }
        }
+
+       new_size = *ppos + count;
+
+       xfs_ilock(ip, XFS_ILOCK_EXCL);
+       if (new_size > ip->i_size)
+               io->io_new_size = new_size;
+       xfs_iunlock(ip, XFS_ILOCK_EXCL);
+
        xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, &ip->i_iocore,
                           pipe, count, *ppos, ioflags);
        ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags);
@@ -416,14 +363,18 @@ xfs_splice_write(
        if (unlikely(ret < 0 && ret != -EFAULT && *ppos > isize))
                *ppos = isize;
 
-       if (*ppos > ip->i_d.di_size) {
+       if (*ppos > ip->i_size) {
                xfs_ilock(ip, XFS_ILOCK_EXCL);
-               if (*ppos > ip->i_d.di_size) {
-                       ip->i_d.di_size = *ppos;
-                       i_size_write(inode, *ppos);
-                       ip->i_update_core = 1;
-                       ip->i_update_size = 1;
-               }
+               if (*ppos > ip->i_size)
+                       ip->i_size = *ppos;
+               xfs_iunlock(ip, XFS_ILOCK_EXCL);
+       }
+
+       if (io->io_new_size) {
+               xfs_ilock(ip, XFS_ILOCK_EXCL);
+               io->io_new_size = 0;
+               if (ip->i_d.di_size > ip->i_size)
+                       ip->i_d.di_size = ip->i_size;
                xfs_iunlock(ip, XFS_ILOCK_EXCL);
        }
        xfs_iunlock(ip, XFS_IOLOCK_EXCL);
@@ -621,36 +572,31 @@ out_lock:
 
 ssize_t                                /* bytes written, or (-) error */
 xfs_write(
-       bhv_desc_t              *bdp,
+       struct xfs_inode        *xip,
        struct kiocb            *iocb,
        const struct iovec      *iovp,
        unsigned int            nsegs,
        loff_t                  *offset,
-       int                     ioflags,
-       cred_t                  *credp)
+       int                     ioflags)
 {
        struct file             *file = iocb->ki_filp;
        struct address_space    *mapping = file->f_mapping;
        struct inode            *inode = mapping->host;
+       bhv_vnode_t             *vp = XFS_ITOV(xip);
        unsigned long           segs = nsegs;
-       xfs_inode_t             *xip;
        xfs_mount_t             *mp;
        ssize_t                 ret = 0, error = 0;
        xfs_fsize_t             isize, new_size;
        xfs_iocore_t            *io;
-       bhv_vnode_t             *vp;
        int                     iolock;
        int                     eventsent = 0;
        bhv_vrwlock_t           locktype;
        size_t                  ocount = 0, count;
        loff_t                  pos;
-       int                     need_i_mutex = 1, need_flush = 0;
+       int                     need_i_mutex;
 
        XFS_STATS_INC(xs_write_calls);
 
-       vp = BHV_TO_VNODE(bdp);
-       xip = XFS_BHVTOI(bdp);
-
        error = generic_segment_checks(iovp, &segs, &ocount, VERIFY_READ);
        if (error)
                return error;
@@ -664,44 +610,25 @@ xfs_write(
        io = &xip->i_iocore;
        mp = io->io_mount;
 
-       vfs_wait_for_freeze(vp->v_vfsp, SB_FREEZE_WRITE);
+       xfs_wait_for_freeze(mp, SB_FREEZE_WRITE);
 
        if (XFS_FORCED_SHUTDOWN(mp))
                return -EIO;
 
-       if (ioflags & IO_ISDIRECT) {
-               xfs_buftarg_t   *target =
-                       (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
-                               mp->m_rtdev_targp : mp->m_ddev_targp;
-
-               if ((pos & target->bt_smask) || (count & target->bt_smask))
-                       return XFS_ERROR(-EINVAL);
-
-               if (!VN_CACHED(vp) && pos < i_size_read(inode))
-                       need_i_mutex = 0;
-
-               if (VN_CACHED(vp))
-                       need_flush = 1;
-       }
-
 relock:
-       if (need_i_mutex) {
+       if (ioflags & IO_ISDIRECT) {
+               iolock = XFS_IOLOCK_SHARED;
+               locktype = VRWLOCK_WRITE_DIRECT;
+               need_i_mutex = 0;
+       } else {
                iolock = XFS_IOLOCK_EXCL;
                locktype = VRWLOCK_WRITE;
-
+               need_i_mutex = 1;
                mutex_lock(&inode->i_mutex);
-       } else {
-               iolock = XFS_IOLOCK_SHARED;
-               locktype = VRWLOCK_WRITE_DIRECT;
        }
 
        xfs_ilock(xip, XFS_ILOCK_EXCL|iolock);
 
-       isize = i_size_read(inode);
-
-       if (file->f_flags & O_APPEND)
-               *offset = isize;
-
 start:
        error = -generic_write_checks(file, &pos, &count,
                                        S_ISBLK(inode->i_mode));
@@ -710,13 +637,8 @@ start:
                goto out_unlock_mutex;
        }
 
-       new_size = pos + count;
-       if (new_size > isize)
-               io->io_new_size = new_size;
-
-       if ((DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_WRITE) &&
+       if ((DM_EVENT_ENABLED(xip, DM_EVENT_WRITE) &&
            !(ioflags & IO_INVIS) && !eventsent)) {
-               loff_t          savedsize = pos;
                int             dmflags = FILP_DELAY_FLAG(file);
 
                if (need_i_mutex)
@@ -727,8 +649,7 @@ start:
                                      pos, count,
                                      dmflags, &locktype);
                if (error) {
-                       xfs_iunlock(xip, iolock);
-                       goto out_unlock_mutex;
+                       goto out_unlock_internal;
                }
                xfs_ilock(xip, XFS_ILOCK_EXCL);
                eventsent = 1;
@@ -740,12 +661,35 @@ start:
                 * event prevents another call to XFS_SEND_DATA, which is
                 * what allows the size to change in the first place.
                 */
-               if ((file->f_flags & O_APPEND) && savedsize != isize) {
-                       pos = isize = xip->i_d.di_size;
+               if ((file->f_flags & O_APPEND) && pos != xip->i_size)
+                       goto start;
+       }
+
+       if (ioflags & IO_ISDIRECT) {
+               xfs_buftarg_t   *target =
+                       (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
+                               mp->m_rtdev_targp : mp->m_ddev_targp;
+
+               if ((pos & target->bt_smask) || (count & target->bt_smask)) {
+                       xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
+                       return XFS_ERROR(-EINVAL);
+               }
+
+               if (!need_i_mutex && (VN_CACHED(vp) || pos > xip->i_size)) {
+                       xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
+                       iolock = XFS_IOLOCK_EXCL;
+                       locktype = VRWLOCK_WRITE;
+                       need_i_mutex = 1;
+                       mutex_lock(&inode->i_mutex);
+                       xfs_ilock(xip, XFS_ILOCK_EXCL|iolock);
                        goto start;
                }
        }
 
+       new_size = pos + count;
+       if (new_size > xip->i_size)
+               io->io_new_size = new_size;
+
        if (likely(!(ioflags & IO_INVIS))) {
                file_update_time(file);
                xfs_ichgtime_fast(xip, inode,
@@ -761,11 +705,11 @@ start:
         * to zero it out up to the new size.
         */
 
-       if (pos > isize) {
-               error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, pos, isize);
+       if (pos > xip->i_size) {
+               error = xfs_zero_eof(vp, io, pos, xip->i_size);
                if (error) {
-                       xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
-                       goto out_unlock_mutex;
+                       xfs_iunlock(xip, XFS_ILOCK_EXCL);
+                       goto out_unlock_internal;
                }
        }
        xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -785,8 +729,7 @@ start:
                if (likely(!error))
                        error = -remove_suid(file->f_path.dentry);
                if (unlikely(error)) {
-                       xfs_iunlock(xip, iolock);
-                       goto out_unlock_mutex;
+                       goto out_unlock_internal;
                }
        }
 
@@ -795,11 +738,15 @@ retry:
        current->backing_dev_info = mapping->backing_dev_info;
 
        if ((ioflags & IO_ISDIRECT)) {
-               if (need_flush) {
+               if (VN_CACHED(vp)) {
+                       WARN_ON(need_i_mutex == 0);
                        xfs_inval_cached_trace(io, pos, -1,
                                        ctooff(offtoct(pos)), -1);
-                       bhv_vop_flushinval_pages(vp, ctooff(offtoct(pos)),
+                       error = xfs_flushinval_pages(xip,
+                                       ctooff(offtoct(pos)),
                                        -1, FI_REMAPF_LOCKED);
+                       if (error)
+                               goto out_unlock_internal;
                }
 
                if (need_i_mutex) {
@@ -827,7 +774,6 @@ retry:
                        pos += ret;
                        count -= ret;
 
-                       need_i_mutex = 1;
                        ioflags &= ~IO_ISDIRECT;
                        xfs_iunlock(xip, iolock);
                        goto relock;
@@ -844,22 +790,20 @@ retry:
        if (ret == -EIOCBQUEUED && !(ioflags & IO_ISAIO))
                ret = wait_on_sync_kiocb(iocb);
 
-       if ((ret == -ENOSPC) &&
-           DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_NOSPACE) &&
-           !(ioflags & IO_INVIS)) {
-
-               xfs_rwunlock(bdp, locktype);
+       if (ret == -ENOSPC &&
+           DM_EVENT_ENABLED(xip, DM_EVENT_NOSPACE) && !(ioflags & IO_INVIS)) {
+               xfs_rwunlock(xip, locktype);
                if (need_i_mutex)
                        mutex_unlock(&inode->i_mutex);
                error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
                                DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
                                0, 0, 0); /* Delay flag intentionally  unused */
-               if (error)
-                       goto out_nounlocks;
                if (need_i_mutex)
                        mutex_lock(&inode->i_mutex);
-               xfs_rwlock(bdp, locktype);
-               pos = xip->i_d.di_size;
+               xfs_rwlock(xip, locktype);
+               if (error)
+                       goto out_unlock_internal;
+               pos = xip->i_size;
                ret = 0;
                goto retry;
        }
@@ -868,14 +812,10 @@ retry:
        if (unlikely(ret < 0 && ret != -EFAULT && *offset > isize))
                *offset = isize;
 
-       if (*offset > xip->i_d.di_size) {
+       if (*offset > xip->i_size) {
                xfs_ilock(xip, XFS_ILOCK_EXCL);
-               if (*offset > xip->i_d.di_size) {
-                       xip->i_d.di_size = *offset;
-                       i_size_write(inode, *offset);
-                       xip->i_update_core = 1;
-                       xip->i_update_size = 1;
-               }
+               if (*offset > xip->i_size)
+                       xip->i_size = *offset;
                xfs_iunlock(xip, XFS_ILOCK_EXCL);
        }
 
@@ -887,26 +827,40 @@ retry:
 
        /* Handle various SYNC-type writes */
        if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {
-               error = xfs_write_sync_logforce(mp, xip);
-               if (error)
-                       goto out_unlock_internal;
-
-               xfs_rwunlock(bdp, locktype);
+               int error2;
+               xfs_rwunlock(xip, locktype);
                if (need_i_mutex)
                        mutex_unlock(&inode->i_mutex);
-
-               error = sync_page_range(inode, mapping, pos, ret);
+               error2 = sync_page_range(inode, mapping, pos, ret);
                if (!error)
-                       error = ret;
-               return error;
+                       error = error2;
+               if (need_i_mutex)
+                       mutex_lock(&inode->i_mutex);
+               xfs_rwlock(xip, locktype);
+               error2 = xfs_write_sync_logforce(mp, xip);
+               if (!error)
+                       error = error2;
        }
 
  out_unlock_internal:
-       xfs_rwunlock(bdp, locktype);
+       if (io->io_new_size) {
+               xfs_ilock(xip, XFS_ILOCK_EXCL);
+               io->io_new_size = 0;
+               /*
+                * If this was a direct or synchronous I/O that failed (such
+                * as ENOSPC) then part of the I/O may have been written to
+                * disk before the error occured.  In this case the on-disk
+                * file size may have been adjusted beyond the in-memory file
+                * size and now needs to be truncated back.
+                */
+               if (xip->i_d.di_size > xip->i_size)
+                       xip->i_d.di_size = xip->i_size;
+               xfs_iunlock(xip, XFS_ILOCK_EXCL);
+       }
+       xfs_rwunlock(xip, locktype);
  out_unlock_mutex:
        if (need_i_mutex)
                mutex_unlock(&inode->i_mutex);
- out_nounlocks:
        return -error;
 }
 
@@ -942,14 +896,14 @@ xfs_bdstrat_cb(struct xfs_buf *bp)
 
 
 int
-xfs_bmap(bhv_desc_t    *bdp,
+xfs_bmap(
+       xfs_inode_t     *ip,
        xfs_off_t       offset,
        ssize_t         count,
        int             flags,
        xfs_iomap_t     *iomapp,
        int             *niomaps)
 {
-       xfs_inode_t     *ip = XFS_BHVTOI(bdp);
        xfs_iocore_t    *io = &ip->i_iocore;
 
        ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);