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>] [day] [month] [year] [list]
Message-ID: <20210512090930epcms2p2227112d22c961ca129462861108c03b6@epcms2p2>
Date:   Wed, 12 May 2021 18:09:30 +0900
From:   Daejun Park <daejun7.park@...sung.com>
To:     "jaegeuk@...nel.org" <jaegeuk@...nel.org>,
        "chao@...nel.org" <chao@...nel.org>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-f2fs-devel@...ts.sourceforge.net" 
        <linux-f2fs-devel@...ts.sourceforge.net>,
        Daejun Park <daejun7.park@...sung.com>
Subject: [PATCH] f2fs: support cold file defragementation

F2FS_IOC_DEFRAGMENT performs defragmentation of a file. In
f2fs_defragment_range(), it checks whether in-place update policy is
applied, for avoiding unnecessary write operations.
The cold file may be fragmented according to the write order. However,
in the case of a cold file, the in-place update policy is applied, so it
is can not be defragmented.
This patch temporarily clears the cold bit so that the file can be
defragmented.

Signed-off-by: Daejun Park <daejun7.park@...sung.com>
---
 fs/f2fs/file.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ceb575f99048..c38e9727ce25 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2536,11 +2536,23 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
 	unsigned int total = 0, sec_num;
 	block_t blk_end = 0;
 	bool fragmented = false;
+	bool is_cold = file_is_cold(inode);
 	int err;
 
+	/*
+	 * Cold file can be fragmented by write order. So we clear cold bit from
+	 * the file temporarily.
+	 */
+	if (is_cold)
+		file_clear_cold(inode);
+
 	/* if in-place-update policy is enabled, don't waste time here */
-	if (f2fs_should_update_inplace(inode, NULL))
+	if (f2fs_should_update_inplace(inode, NULL)) {
+		/* restore file temperature */
+		if (is_cold)
+			file_set_cold(inode);
 		return -EINVAL;
+	}
 
 	pg_start = range->start >> PAGE_SHIFT;
 	pg_end = (range->start + range->len) >> PAGE_SHIFT;
@@ -2665,6 +2677,9 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
 	clear_inode_flag(inode, FI_DO_DEFRAG);
 out:
 	inode_unlock(inode);
+	/* restore file temperature */
+	if (is_cold)
+		file_set_cold(inode);
 	if (!err)
 		range->len = (u64)total << PAGE_SHIFT;
 	return err;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ