From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/4] fs: ext4: remove unnecessarily clever file read
Date: Tue, 29 Oct 2019 10:10:27 +0100 [thread overview]
Message-ID: <20191029091029.22215-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20191029091029.22215-1-s.hauer@pengutronix.de>
ext4fs_read_file() tries to tries to bundle contiguous block reads into
longer reads from the device. In barebox we cache in the block layer
already, so this is unnecessary. Simplify the code by removing the
bundled reads.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/ext4/ext4fs.c | 59 +++++-------------------------------------------
1 file changed, 6 insertions(+), 53 deletions(-)
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index acecccd6b9..2d231d273a 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -55,12 +55,6 @@ int ext4fs_read_file(struct ext2fs_node *node, int pos,
int log2blocksize = LOG2_EXT2_BLOCK_SIZE(node->data);
int blocksize = 1 << (log2blocksize + DISK_SECTOR_BITS);
unsigned int filesize = le32_to_cpu(node->inode.size);
- int previous_block_number = -1;
- int delayed_start = 0;
- int delayed_extent = 0;
- int delayed_skipfirst = 0;
- int delayed_next = 0;
- char *delayed_buf = NULL;
short ret;
struct ext_filesystem *fs = node->data->fs;
@@ -75,6 +69,7 @@ int ext4fs_read_file(struct ext2fs_node *node, int pos,
int blockoff = pos % blocksize;
int blockend = blocksize;
int skipfirst = 0;
+
blknr = read_allocated_block(node, i);
if (blknr < 0)
return blknr;
@@ -95,59 +90,17 @@ int ext4fs_read_file(struct ext2fs_node *node, int pos,
skipfirst = blockoff;
blockend -= skipfirst;
}
+
if (blknr) {
- if (previous_block_number != -1) {
- if (delayed_next == blknr) {
- delayed_extent += blockend;
- delayed_next += blockend >> SECTOR_BITS;
- } else { /* spill */
- ret = ext4fs_devread(fs, delayed_start,
- delayed_skipfirst,
- delayed_extent,
- delayed_buf);
- if (ret)
- return ret;
- previous_block_number = blknr;
- delayed_start = blknr;
- delayed_extent = blockend;
- delayed_skipfirst = skipfirst;
- delayed_buf = buf;
- delayed_next = blknr +
- (blockend >> SECTOR_BITS);
- }
- } else {
- previous_block_number = blknr;
- delayed_start = blknr;
- delayed_extent = blockend;
- delayed_skipfirst = skipfirst;
- delayed_buf = buf;
- delayed_next = blknr +
- (blockend >> SECTOR_BITS);
- }
+ ret = ext4fs_devread(fs, blknr, skipfirst, blockend, buf);
+ if (ret)
+ return ret;
} else {
- if (previous_block_number != -1) {
- /* spill */
- ret = ext4fs_devread(fs, delayed_start,
- delayed_skipfirst,
- delayed_extent,
- delayed_buf);
- if (ret)
- return ret;
- previous_block_number = -1;
- }
memset(buf, 0, blockend);
}
+
buf += blocksize - skipfirst;
}
- if (previous_block_number != -1) {
- /* spill */
- ret = ext4fs_devread(fs, delayed_start,
- delayed_skipfirst, delayed_extent,
- delayed_buf);
- if (ret)
- return ret;
- previous_block_number = -1;
- }
return len;
}
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-10-29 9:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 9:10 [PATCH 0/4] ext4 fixes Sascha Hauer
2019-10-29 9:10 ` [PATCH 1/4] fs: ext4: Fix out of bounds memset Sascha Hauer
2019-10-29 9:10 ` Sascha Hauer [this message]
2019-10-29 9:10 ` [PATCH 3/4] fs: ext4: Fix handling of sparse files Sascha Hauer
2019-10-29 9:10 ` [PATCH 4/4] fs: ext4: return NULL instead of 0 Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191029091029.22215-3-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox