From 41fb2ba1cd2e84f28cd9f5b91d670fef7d982409 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 8 May 2024 06:17:45 +0200 Subject: Merging upstream version 4.19.289. Signed-off-by: Daniel Baumann --- fs/nilfs2/sufile.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'fs/nilfs2/sufile.c') diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index 150845a43..d85d3c758 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c @@ -782,6 +782,15 @@ int nilfs_sufile_resize(struct inode *sufile, __u64 newnsegs) goto out_header; sui->ncleansegs -= nsegs - newnsegs; + + /* + * If the sufile is successfully truncated, immediately adjust + * the segment allocation space while locking the semaphore + * "mi_sem" so that nilfs_sufile_alloc() never allocates + * segments in the truncated space. + */ + sui->allocmax = newnsegs - 1; + sui->allocmin = 0; } kaddr = kmap_atomic(header_bh->b_page); -- cgit v1.2.3