]> git.baikalelectronics.ru Git - kernel.git/commitdiff
udf: Do not bother looking for prealloc extents if i_lenExtents matches i_size
authorJan Kara <jack@suse.cz>
Wed, 7 Dec 2022 16:34:33 +0000 (17:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:40:47 +0000 (11:40 +0100)
commit 6ad53f0f71c52871202a7bf096feb2c59db33fc5 upstream.

If rounded block-rounded i_lenExtents matches block rounded i_size,
there are no preallocation extents. Do not bother walking extent linked
list.

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/udf/truncate.c

index b9af8d9509d5232b9b61f6b2dfff11c24b8b8cb3..fd3e4a8671f0f17f6c36a3b8ffc91eff33ba19cb 100644 (file)
@@ -127,9 +127,10 @@ void udf_discard_prealloc(struct inode *inode)
        uint64_t lbcount = 0;
        int8_t etype = -1, netype;
        struct udf_inode_info *iinfo = UDF_I(inode);
+       int bsize = 1 << inode->i_blkbits;
 
        if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ||
-           inode->i_size == iinfo->i_lenExtents)
+           ALIGN(inode->i_size, bsize) == ALIGN(iinfo->i_lenExtents, bsize))
                return;
 
        epos.block = iinfo->i_location;