From: Steven J. Magnani <magn...@ieee.org>

Adjust bookkeeping during creation of an end-of-file hole to ensure that
any File Tail (preallocated extent) is reclaimed when the file is
released.

This also ensures that the file's Extended File Entry is populated with
the proper count of recorded blocks.

Fixes: fa33cdbf3ece ("udf: Fix incorrect final NOT_ALLOCATED (hole) extent 
length")
Signed-off-by: Steven J. Magnani <magn...@ieee.org>
---
--- a/fs/udf/inode.c    2020-12-28 20:51:29.000000000 -0600
+++ b/fs/udf/inode.c    2021-01-03 07:04:05.759911829 -0600
@@ -535,6 +535,7 @@ static int udf_do_extend_file(struct ino
                        add = new_block_bytes;
                new_block_bytes -= add;
                last_ext->extLength += add;
+               iinfo->i_lenExtents += add;
        }
 
        if (fake) {
@@ -571,6 +572,7 @@ static int udf_do_extend_file(struct ino
                                   last_ext->extLength, 1);
                if (err)
                        return err;
+               iinfo->i_lenExtents += add;
                count++;
        }
        if (new_block_bytes) {
@@ -580,6 +582,7 @@ static int udf_do_extend_file(struct ino
                                   last_ext->extLength, 1);
                if (err)
                        return err;
+               iinfo->i_lenExtents += new_block_bytes;
                count++;
        }
 
@@ -682,7 +685,6 @@ static int udf_extend_file(struct inode
        if (err < 0)
                goto out;
        err = 0;
-       iinfo->i_lenExtents = newsize;
 out:
        brelse(epos.bh);
        return err;

Reply via email to