xfs
[Top] [All Lists]

[PATCH 6/9] xfs: do not use unchecked extent indices in xfs_bunmapi

To: xfs@xxxxxxxxxxx
Subject: [PATCH 6/9] xfs: do not use unchecked extent indices in xfs_bunmapi
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Wed, 11 May 2011 11:04:08 -0400
References: <20110511150402.258164661@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: quilt/0.48-1
Make sure to only call xfs_iext_get_ext after we've validate the extent index
when moving on to the next index in xfs_bunmapi.  Also remove the old
workaround for too large indices that has been superceeded by the proper
fix in xfs_bmap_del_extent.

Based on an earlier patch from Lachlan McIlroy.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: xfs/fs/xfs/xfs_bmap.c
===================================================================
--- xfs.orig/fs/xfs/xfs_bmap.c  2011-05-11 10:17:04.803235692 +0200
+++ xfs/fs/xfs/xfs_bmap.c       2011-05-11 10:17:06.432734169 +0200
@@ -5247,17 +5247,17 @@ xfs_bunmapi(
 nodelete:
                /*
                 * If not done go on to the next (previous) record.
-                * Reset ep in case the extents array was re-alloced.
                 */
-               ep = xfs_iext_get_ext(ifp, lastx);
                if (bno != (xfs_fileoff_t)-1 && bno >= start) {
-                       if (lastx >= XFS_IFORK_NEXTENTS(ip, whichfork) ||
-                           xfs_bmbt_get_startoff(ep) > bno) {
-                               if (--lastx >= 0)
-                                       ep = xfs_iext_get_ext(ifp, lastx);
-                       }
-                       if (lastx >= 0)
+                       if (lastx >= 0) {
+                               ep = xfs_iext_get_ext(ifp, lastx);
+                               if (xfs_bmbt_get_startoff(ep) > bno) {
+                                       if (--lastx >= 0)
+                                               ep = xfs_iext_get_ext(ifp,
+                                                                     lastx);
+                               }
                                xfs_bmbt_get_all(ep, &got);
+                       }
                        extno++;
                }
        }

<Prev in Thread] Current Thread [Next in Thread>