git: 3a60f9c605a2 - releng/13.2 - makefs: make msdos creation go fast

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 16 Mar 2023 00:12:16 UTC
The branch releng/13.2 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=3a60f9c605a26784607e2b44f4fc184dca414445

commit 3a60f9c605a26784607e2b44f4fc184dca414445
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-03-13 20:28:51 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-03-15 23:14:12 +0000

    makefs: make msdos creation go fast
    
    Add missing brelse(bp). Without it the cache grows and we have a n^2
    lookup.  I'm not entirely sure why we read the block before we write it
    back out, since the only side effect of that is to allocate memory,
    clear the memory, read it in from disk, throw it away with the contents
    of the file being written out. We likely should just do a getblk() here
    instead, but even with all that, this takes the time it takes to create
    a 150MB msdos fs image down from 5 minutes to 30 seconds.
    
    Old: 317.663u 0.685s 5:18.34 100.0%     198+360k 0+19io 1009pf+0w
    New: 7.330u 23.841s 0:31.17 100.0%      198+360k 0+250522io 4pf+0w
    
    See code review for how we got this. tl;dr: netbsd move brelse
    into bwrite and we picked up msdos code after that, but not the
    move. That change should be picked up later.
    
    Sponsored by:           Netflix
    Reviewed by:            emaste
    MFC After:              1 day (13.2 is coming fast)
    Differential Revision:  https://reviews.freebsd.org/D39025
    Approved by:            re@ (cperciva)
    
    (cherry picked from commit 370e009188ba90c3290b1479aa06ec98b66e140a)
    (cherry picked from commit aa1e6a4f4c28c7051ee9431ecb7802309cc1bf96)
---
 usr.sbin/makefs/msdos/msdosfs_vnops.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/usr.sbin/makefs/msdos/msdosfs_vnops.c b/usr.sbin/makefs/msdos/msdosfs_vnops.c
index ff470576ee79..198efae31a0e 100644
--- a/usr.sbin/makefs/msdos/msdosfs_vnops.c
+++ b/usr.sbin/makefs/msdos/msdosfs_vnops.c
@@ -501,6 +501,7 @@ msdosfs_wfile(const char *path, struct denode *dep, fsnode *node)
 		cpsize = MIN((nsize - offs), blsize - on);
 		memcpy(bp->b_data + on, dat + offs, cpsize);
 		bwrite(bp);
+		brelse(bp);
 		offs += cpsize;
 	}