Linux-ext4 Archive mirror
 help / color / mirror / Atom feed
* [PATCH] resize2fs: trim resize to cluster boundary
@ 2022-05-14  4:17 Kiselev, Oleg
  2022-08-11 14:32 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Kiselev, Oleg @ 2022-05-14  4:17 UTC (permalink / raw
  To: linux-ext4@vger.kernel.org; +Cc: Theodore Ts'o


This patch rounds down the size provided to resize2fs to the nearest
cluster boundary for bigalloc filesystems.  This is similar to the
trimming already done for page boundary alignment.  Aligning the size in
the user space provides the right value feedback from the resize2fs
command, which is a better user experience than trimming the size
in the kernel.

Signed-off-by: Oleg Kiselev <okiselev@amazon.com>
---
 resize/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/resize/main.c b/resize/main.c
index bceaa1677e21..93a1d5a260e1 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -537,6 +537,12 @@ int main (int argc, char ** argv)
 			goto errout;
 		}
 	}
+
+	/* If using cluster allocations, trim down to a cluster boundary */
+	if (ext2fs_has_feature_bigalloc(fs->super)) {
+		new_size &= ~((blk64_t)(1 << fs->cluster_ratio_bits) - 1);
+	}
+
 	new_group_desc_count = ext2fs_div64_ceil(new_size -
 				fs->super->s_first_data_block,
 						 EXT2_BLOCKS_PER_GROUP(fs->super));
--
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] resize2fs: trim resize to cluster boundary
  2022-05-14  4:17 [PATCH] resize2fs: trim resize to cluster boundary Kiselev, Oleg
@ 2022-08-11 14:32 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2022-08-11 14:32 UTC (permalink / raw
  To: linux-ext4, okiselev; +Cc: Theodore Ts'o

On Sat, 14 May 2022 04:17:09 +0000, Kiselev, Oleg wrote:
> This patch rounds down the size provided to resize2fs to the nearest
> cluster boundary for bigalloc filesystems.  This is similar to the
> trimming already done for page boundary alignment.  Aligning the size in
> the user space provides the right value feedback from the resize2fs
> command, which is a better user experience than trimming the size
> in the kernel.
> 
> [...]

Applied, thanks!

[1/1] resize2fs: trim resize to cluster boundary
      commit: b609d01e6d200638aad42adee922f91d91e3e642

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-11 14:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-14  4:17 [PATCH] resize2fs: trim resize to cluster boundary Kiselev, Oleg
2022-08-11 14:32 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).