lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230824092619.1327976-17-yi.zhang@huaweicloud.com>
Date:   Thu, 24 Aug 2023 17:26:19 +0800
From:   Zhang Yi <yi.zhang@...weicloud.com>
To:     linux-ext4@...r.kernel.org
Cc:     tytso@....edu, adilger.kernel@...ger.ca, jack@...e.cz,
        yi.zhang@...wei.com, yi.zhang@...weicloud.com,
        chengzhihao1@...wei.com, yukuai3@...wei.com
Subject: [RFC PATCH 16/16] ext4: drop ext4_nonda_switch()

From: Zhang Yi <yi.zhang@...wei.com>

Now that we have reserve enough metadata blocks for delalloc, the
ext4_nonda_switch() could be dropped, it's safe to keep on delalloc mode
for buffer write if the dirty space is high and free space is low, we
can make sure always successfully allocate the metadata block while
mapping delalloc entries in ext4_writepages().

Signed-off-by: Zhang Yi <yi.zhang@...wei.com>
---
 fs/ext4/extents_status.c |  9 ++++-----
 fs/ext4/inode.c          | 39 ++-------------------------------------
 2 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 8e0dec27f967..954c6e49182e 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -971,11 +971,10 @@ void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
 	 * reduce the reserved cluster count and claim quota.
 	 *
 	 * Otherwise, we aren't allocating delayed allocated clusters
-	 * (from fallocate, filemap, DIO, or clusters allocated when
-	 * delalloc has been disabled by ext4_nonda_switch()), reduce the
-	 * reserved cluster count by the number of allocated clusters that
-	 * have previously been delayed allocated. Quota has been claimed
-	 * by ext4_mb_new_blocks(), so release the quota reservations made
+	 * (from fallocate, filemap, DIO), reduce the reserved cluster
+	 * count by the number of allocated clusters that have previously
+	 * been delayed allocated. Quota has been claimed by
+	 * ext4_mb_new_blocks(), so release the quota reservations made
 	 * for any previously delayed allocated clusters.
 	 */
 	ext4_da_update_reserve_space(inode, rinfo.ndelonly_clu + pending,
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d714bf2e4171..0a76c99ea8c6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2838,40 +2838,6 @@ static int ext4_dax_writepages(struct address_space *mapping,
 	return ret;
 }
 
-static int ext4_nonda_switch(struct super_block *sb)
-{
-	s64 free_clusters, dirty_clusters;
-	struct ext4_sb_info *sbi = EXT4_SB(sb);
-
-	/*
-	 * switch to non delalloc mode if we are running low
-	 * on free block. The free block accounting via percpu
-	 * counters can get slightly wrong with percpu_counter_batch getting
-	 * accumulated on each CPU without updating global counters
-	 * Delalloc need an accurate free block accounting. So switch
-	 * to non delalloc when we are near to error range.
-	 */
-	free_clusters =
-		percpu_counter_read_positive(&sbi->s_freeclusters_counter);
-	dirty_clusters =
-		percpu_counter_read_positive(&sbi->s_dirtyclusters_counter);
-	/*
-	 * Start pushing delalloc when 1/2 of free blocks are dirty.
-	 */
-	if (dirty_clusters && (free_clusters < 2 * dirty_clusters))
-		try_to_writeback_inodes_sb(sb, WB_REASON_FS_FREE_SPACE);
-
-	if (2 * free_clusters < 3 * dirty_clusters ||
-	    free_clusters < (dirty_clusters + EXT4_FREECLUSTERS_WATERMARK)) {
-		/*
-		 * free block count is less than 150% of dirty blocks
-		 * or free blocks is less than watermark
-		 */
-		return 1;
-	}
-	return 0;
-}
-
 static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
 			       loff_t pos, unsigned len,
 			       struct page **pagep, void **fsdata)
@@ -2886,7 +2852,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
 
 	index = pos >> PAGE_SHIFT;
 
-	if (ext4_nonda_switch(inode->i_sb) || ext4_verity_in_progress(inode)) {
+	if (ext4_verity_in_progress(inode)) {
 		*fsdata = (void *)FALL_BACK_TO_NONDELALLOC;
 		return ext4_write_begin(file, mapping, pos,
 					len, pagep, fsdata);
@@ -6117,8 +6083,7 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf)
 		goto retry_alloc;
 
 	/* Delalloc case is easy... */
-	if (test_opt(inode->i_sb, DELALLOC) &&
-	    !ext4_nonda_switch(inode->i_sb)) {
+	if (test_opt(inode->i_sb, DELALLOC)) {
 		do {
 			err = block_page_mkwrite(vma, vmf,
 						   ext4_da_get_block_prep);
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ