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: <b469bd6ecbb015b02b7a89b4f8110cf2c09f4275.1725334811.git.bo.wu@vivo.com>
Date: Tue,  3 Sep 2024 02:54:51 -0600
From: Wu Bo <bo.wu@...o.com>
To: linux-kernel@...r.kernel.org
Cc: Jaegeuk Kim <jaegeuk@...nel.org>,
	Chao Yu <chao@...nel.org>,
	linux-f2fs-devel@...ts.sourceforge.net,
	Wu Bo <wubo.oduw@...il.com>,
	Wu Bo <bo.wu@...o.com>
Subject: [PATCH 07/13] f2fs: support seek for inline tail

Fix to support seek for inline tail files

Signed-off-by: Wu Bo <bo.wu@...o.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 957d1ff55350..dda4cf6d7325 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -400,6 +400,7 @@ static bool __found_offset(struct address_space *mapping,
 	block_t blkaddr = f2fs_data_blkaddr(dn);
 	struct inode *inode = mapping->host;
 	bool compressed_cluster = false;
+	bool inline_tail = false;
 
 	if (f2fs_compressed_file(inode)) {
 		block_t first_blkaddr = data_blkaddr(dn->inode, dn->node_page,
@@ -408,6 +409,14 @@ static bool __found_offset(struct address_space *mapping,
 		compressed_cluster = first_blkaddr == COMPRESS_ADDR;
 	}
 
+	if (f2fs_has_inline_tail(inode)) {
+		loff_t isize = i_size_read(inode);
+		if ((isize >> PAGE_SHIFT == index) &&
+		    (f2fs_exist_data(inode) ||
+		     xa_get_mark(&mapping->i_pages, index, PAGECACHE_TAG_DIRTY)))
+			inline_tail = true;
+	}
+
 	switch (whence) {
 	case SEEK_DATA:
 		if (__is_valid_data_blkaddr(blkaddr))
@@ -417,11 +426,13 @@ static bool __found_offset(struct address_space *mapping,
 			return true;
 		if (compressed_cluster)
 			return true;
+		if (inline_tail)
+			return true;
 		break;
 	case SEEK_HOLE:
 		if (compressed_cluster)
 			return false;
-		if (blkaddr == NULL_ADDR)
+		if (blkaddr == NULL_ADDR && !inline_tail)
 			return true;
 		break;
 	}
@@ -473,6 +484,8 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 		}
 
 		end_offset = ADDRS_PER_PAGE(dn.node_page, inode);
+		if (f2fs_has_inline_tail(inode))
+			end_offset = COMPACT_ADDRS_PER_INODE + 1;
 
 		/* find data/hole in dnode block */
 		for (; dn.ofs_in_node < end_offset;
@@ -496,6 +509,8 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 			}
 		}
 		f2fs_put_dnode(&dn);
+		if (f2fs_has_inline_tail(inode) && dn.ofs_in_node == end_offset)
+			goto fail;
 	}
 
 	if (whence == SEEK_DATA)
-- 
2.35.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ