[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174786677566.1383760.15330012260577982100.stgit@frogsfrogsfrogs>
Date: Wed, 21 May 2025 15:35:10 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 01/29] libext2fs: fix unix io manager invalidation
From: Darrick J. Wong <djwong@...nel.org>
flush_cached_blocks does not invalidate clean blocks from the block
cache. From reading all the call sites, it looks like they all actually
want the cache to be empty on successful return, so adjust the
implementation to do this.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
lib/ext2fs/unix_io.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index dbe748d9c43583..b98c44a84bb0af 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -670,20 +670,24 @@ static errcode_t flush_cached_blocks(io_channel channel,
if ((flags & FLUSH_NOLOCK) == 0)
mutex_lock(data, CACHE_MTX);
for (i=0, cache = data->cache; i < data->cache_size; i++, cache++) {
- if (!cache->in_use || !cache->dirty)
+ if (!cache->in_use)
continue;
- retval = raw_write_blk(channel, data,
- cache->block, 1, cache->buf,
- RAW_WRITE_NO_HANDLER);
- if (retval) {
- cache->write_err = 1;
- errors_found = 1;
- retval2 = retval;
- } else {
- cache->dirty = 0;
- cache->write_err = 0;
- if (flags & FLUSH_INVALIDATE)
- cache->in_use = 0;
+ if (cache->dirty) {
+ retval = raw_write_blk(channel, data,
+ cache->block, 1, cache->buf,
+ RAW_WRITE_NO_HANDLER);
+ if (retval) {
+ cache->write_err = 1;
+ errors_found = 1;
+ retval2 = retval;
+ } else {
+ cache->dirty = 0;
+ cache->write_err = 0;
+ if (flags & FLUSH_INVALIDATE)
+ cache->in_use = 0;
+ }
+ } else if (flags & FLUSH_INVALIDATE) {
+ cache->in_use = 0;
}
}
if ((flags & FLUSH_NOLOCK) == 0)
Powered by blists - more mailing lists