]> git.baikalelectronics.ru Git - kernel.git/commitdiff
xfs: use new extent lookup helpers in xfs_reflink_trim_irec_to_next_cow
authorChristoph Hellwig <hch@lst.de>
Thu, 24 Nov 2016 00:39:50 +0000 (11:39 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 24 Nov 2016 00:39:50 +0000 (11:39 +1100)
And remove the unused return value.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_reflink.c
fs/xfs/xfs_reflink.h

index e92355a39304c965b3300386b32c54f63bd3415b..d3cfae842237a0e62358e006d63ffa769ba20741 100644 (file)
@@ -451,43 +451,34 @@ xfs_reflink_find_cow_mapping(
 /*
  * Trim an extent to end at the next CoW reservation past offset_fsb.
  */
-int
+void
 xfs_reflink_trim_irec_to_next_cow(
        struct xfs_inode                *ip,
        xfs_fileoff_t                   offset_fsb,
        struct xfs_bmbt_irec            *imap)
 {
-       struct xfs_bmbt_irec            irec;
-       struct xfs_ifork                *ifp;
-       struct xfs_bmbt_rec_host        *gotp;
+       struct xfs_ifork                *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
+       struct xfs_bmbt_irec            got;
        xfs_extnum_t                    idx;
 
        if (!xfs_is_reflink_inode(ip))
-               return 0;
+               return;
 
        /* Find the extent in the CoW fork. */
-       ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
-       gotp = xfs_iext_bno_to_ext(ifp, offset_fsb, &idx);
-       if (!gotp)
-               return 0;
-       xfs_bmbt_get_all(gotp, &irec);
+       if (!xfs_iext_lookup_extent(ip, ifp, offset_fsb, &idx, &got))
+               return;
 
        /* This is the extent before; try sliding up one. */
-       if (irec.br_startoff < offset_fsb) {
-               idx++;
-               if (idx >= xfs_iext_count(ifp))
-                       return 0;
-               gotp = xfs_iext_get_ext(ifp, idx);
-               xfs_bmbt_get_all(gotp, &irec);
+       if (got.br_startoff < offset_fsb) {
+               if (!xfs_iext_get_extent(ifp, idx + 1, &got))
+                       return;
        }
 
-       if (irec.br_startoff >= imap->br_startoff + imap->br_blockcount)
-               return 0;
+       if (got.br_startoff >= imap->br_startoff + imap->br_blockcount)
+               return;
 
-       imap->br_blockcount = irec.br_startoff - imap->br_startoff;
+       imap->br_blockcount = got.br_startoff - imap->br_startoff;
        trace_xfs_reflink_trim_irec(ip, imap);
-
-       return 0;
 }
 
 /*
index cff5fc329359e2384fdb525071bd4f69b4c55b71..aa6a4d64bd35d94c2d564ff712f18ad240c34745 100644 (file)
@@ -32,7 +32,7 @@ extern int xfs_reflink_allocate_cow_range(struct xfs_inode *ip,
                xfs_off_t offset, xfs_off_t count);
 extern bool xfs_reflink_find_cow_mapping(struct xfs_inode *ip, xfs_off_t offset,
                struct xfs_bmbt_irec *imap);
-extern int xfs_reflink_trim_irec_to_next_cow(struct xfs_inode *ip,
+extern void xfs_reflink_trim_irec_to_next_cow(struct xfs_inode *ip,
                xfs_fileoff_t offset_fsb, struct xfs_bmbt_irec *imap);
 
 extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip,