xfs
[Top] [All Lists]

[PATCH] xfs: fix the extent count when allocating an new indirection arr

To: "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfs: fix the extent count when allocating an new indirection array entry
From: Jeff Liu <jeff.liu@xxxxxxxxxx>
Date: Sat, 21 Sep 2013 22:38:31 +0800
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1
From: Jie Liu <jeff.liu@xxxxxxxxxx>

At xfs_iext_add(), if extent(s) are being appended to the last
page in the indirection array and the new extent(s) don't fit
in the page, the number of extents(erp->er_extcount) in a new
allocated entry should be the minimum value between count and
XFS_LINEAR_EXTS, instead of count.

Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
---
 fs/xfs/xfs_inode_fork.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_inode_fork.c b/fs/xfs/xfs_inode_fork.c
index 02f1083..dfb4226 100644
--- a/fs/xfs/xfs_inode_fork.c
+++ b/fs/xfs/xfs_inode_fork.c
@@ -1035,11 +1035,11 @@ xfs_iext_add(
 
                        while (count) {
                                erp = xfs_iext_irec_new(ifp, erp_idx);
-                               erp->er_extcount = count;
-                               count -= MIN(count, (int)XFS_LINEAR_EXTS);
-                               if (count) {
+                               erp->er_extcount = MIN(count,
+                                                      (int)XFS_LINEAR_EXTS);
+                               count -= erp->er_extcount;
+                               if (count)
                                        erp_idx++;
-                               }
                        }
                }
        }
-- 
1.7.9.5

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