xfs: convert to new aops
[firefly-linux-kernel-4.4.55.git] / fs / xfs / linux-2.6 / xfs_lrw.c
index ed90403f0ee71dcfaefc4ae03d84990d59155f3e..7e7aeb4c8a082decef5d1f9f59baff627ec1ab55 100644 (file)
@@ -134,45 +134,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;
+                       break;
 
                zero_user_page(page, offset, bytes, KM_USER0);
 
-               status = mapping->a_ops->commit_write(NULL, page, offset,
-                                                       offset + bytes);
-               if (!status) {
-                       pos += bytes;
-                       count -= bytes;
-               }
-
-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);
@@ -286,50 +275,6 @@ 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,