Skip to contentSkip to conversation

ext2fs: don't retry discard/zeroout repeatedly

PATCH Applied Andreas Dilger 2 participants 2 messages May 10, 2023 – Dec 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext2fs: don't retry discard/zeroout repeatedly

Call safe_getenv(UNIX_IO_NOZEROOUT) once when the device is opened and set CHANNEL_FLAG_NOZEROOUT if present instead of getting uid/euid/getenv every time unix_zeroout() is called.

For unix_discard() and unix_zeroout() don't continue to call them if the block device doesn't support these operations.

---
 lib/ext2fs/ext2_io.h |  4 +++-
 lib/ext2fs/unix_io.c | 43 ++++++++++++++++++++++++++-----------------
 2 files changed, 29 insertions(+), 18 deletions(-)
lib/ext2fs/ext2_io.h +3 -1
index 679184e393f1..27eaaf1be354 100644
@@ -34,6 +34,8 @@ typedef struct struct_io_stats *io_stats;
 #define CHANNEL_FLAGS_DISCARD_ZEROES	0x02
 #define CHANNEL_FLAGS_BLOCK_DEVICE	0x04
 #define CHANNEL_FLAGS_THREADS		0x08
+#define CHANNEL_FLAGS_NODISCARD		0x10
+#define CHANNEL_FLAGS_NOZEROOUT		0x20
 
 #define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
 
@@ -57,7 +59,7 @@ struct struct_io_channel {
 				       int actual_bytes_written,
 				       errcode_t error);
 	int		refcount;
-	int		flags;
+	unsigned int	flags;
 	long		reserved[14];
 	void		*private_data;
 	void		*app_data;
lib/ext2fs/unix_io.c +26 -17

94 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 8 lines · Andreas Dilger

Call safe_getenv(UNIX_IO_NOZEROOUT) once when the device is opened and set CHANNEL_FLAG_NOZEROOUT if present instead of getting uid/euid/getenv every time unix_zeroout() is called.

For unix_discard() and unix_zeroout() don't continue to call them if the block device doesn't support these operations.

[...]

Applied, thanks!

[1/1] ext2fs: don't retry discard/zeroout repeatedly

      commit: cc20e3c4320ae34dd06ec4d6a71d07aa7d6599d7

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>