linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.com>
To: linux-ext4@vger.kernel.org
Cc: Ted Tso <tytso@mit.edu>,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	Jan Kara <jack@suse.com>
Subject: [PATCH 19/21] resize2fs: Remove extent mapping code
Date: Wed, 26 Aug 2015 18:22:34 +0200	[thread overview]
Message-ID: <1440606156-5754-20-git-send-email-jack@suse.com> (raw)
In-Reply-To: <1440606156-5754-1-git-send-email-jack@suse.com>

Extent mapping code is now in libext2fs. Remove a special version from
resize2fs.

Signed-off-by: Jan Kara <jack@suse.com>
---
 resize/Makefile.in |   8 +-
 resize/extent.c    | 241 -----------------------------------------------------
 resize/resize2fs.h |  11 ---
 3 files changed, 3 insertions(+), 257 deletions(-)
 delete mode 100644 resize/extent.c

diff --git a/resize/Makefile.in b/resize/Makefile.in
index ecd8619e55a5..82ae57adc4c5 100644
--- a/resize/Makefile.in
+++ b/resize/Makefile.in
@@ -16,13 +16,11 @@ PROGS=		resize2fs
 TEST_PROGS=	test_extent
 MANPAGES=	resize2fs.8
 
-RESIZE_OBJS= extent.o resize2fs.o main.o online.o resource_track.o \
-		sim_progress.o
+RESIZE_OBJS= resize2fs.o main.o online.o resource_track.o sim_progress.o
 
-TEST_EXTENT_OBJS= extent.o test_extent.o
+TEST_EXTENT_OBJS= test_extent.o
 
-SRCS= $(srcdir)/extent.c \
-	$(srcdir)/resize2fs.c \
+SRCS= $(srcdir)/resize2fs.c \
 	$(srcdir)/main.c \
 	$(srcdir)/online.c \
 	$(srcdir)/resource_track.c \
diff --git a/resize/extent.c b/resize/extent.c
deleted file mode 100644
index ec81b944e94a..000000000000
--- a/resize/extent.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * extent.c --- ext2 extent abstraction
- *
- * This abstraction is used to provide a compact way of representing a
- * translation table, for moving multiple contiguous ranges (extents)
- * of blocks or inodes.
- *
- * Copyright (C) 1997, 1998 by Theodore Ts'o and
- * 	PowerQuest, Inc.
- *
- * Copyright (C) 1999, 2000 by Theosore Ts'o
- *
- * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
- * %End-Header%
- */
-
-#include "config.h"
-#include "resize2fs.h"
-
-struct ext2_extent_entry {
-	__u64	old_loc, new_loc;
-	__u64	size;
-};
-
-struct _ext2_extent {
-	struct ext2_extent_entry *list;
-	__u64	cursor;
-	__u64	size;
-	__u64	num;
-	__u64	sorted;
-};
-
-/*
- * Create an extent table
- */
-errcode_t ext2fs_create_extent_table(ext2_extent *ret_extent, __u64 size)
-{
-	ext2_extent	extent;
-	errcode_t	retval;
-
-	retval = ext2fs_get_mem(sizeof(struct _ext2_extent), &extent);
-	if (retval)
-		return retval;
-	memset(extent, 0, sizeof(struct _ext2_extent));
-
-	extent->size = size ? size : 50;
-	extent->cursor = 0;
-	extent->num = 0;
-	extent->sorted = 1;
-
-	retval = ext2fs_get_array(sizeof(struct ext2_extent_entry),
-				extent->size, &extent->list);
-	if (retval) {
-		ext2fs_free_mem(&extent);
-		return retval;
-	}
-	memset(extent->list, 0,
-	       sizeof(struct ext2_extent_entry) * extent->size);
-	*ret_extent = extent;
-	return 0;
-}
-
-/*
- * Free an extent table
- */
-void ext2fs_free_extent_table(ext2_extent extent)
-{
-	if (extent->list)
-		ext2fs_free_mem(&extent->list);
-	extent->list = 0;
-	extent->size = 0;
-	extent->num = 0;
-	ext2fs_free_mem(&extent);
-}
-
-/*
- * Add an entry to the extent table
- */
-errcode_t ext2fs_add_extent_entry(ext2_extent extent, __u64 old_loc, __u64 new_loc)
-{
-	struct	ext2_extent_entry	*ent;
-	errcode_t			retval;
-	__u64				newsize;
-	__u64				curr;
-
-	if (extent->num >= extent->size) {
-		newsize = extent->size + 100;
-		retval = ext2fs_resize_mem(sizeof(struct ext2_extent_entry) *
-					   extent->size,
-					   sizeof(struct ext2_extent_entry) *
-					   newsize, &extent->list);
-		if (retval)
-			return retval;
-		extent->size = newsize;
-	}
-	curr = extent->num;
-	ent = extent->list + curr;
-	if (curr) {
-		/*
-		 * Check to see if this can be coalesced with the last
-		 * extent
-		 */
-		ent--;
-		if ((ent->old_loc + ent->size == old_loc) &&
-		    (ent->new_loc + ent->size == new_loc)) {
-			ent->size++;
-			return 0;
-		}
-		/*
-		 * Now see if we're going to ruin the sorting
-		 */
-		if (ent->old_loc + ent->size > old_loc)
-			extent->sorted = 0;
-		ent++;
-	}
-	ent->old_loc = old_loc;
-	ent->new_loc = new_loc;
-	ent->size = 1;
-	extent->num++;
-	return 0;
-}
-
-/*
- * Helper function for qsort
- */
-static EXT2_QSORT_TYPE extent_cmp(const void *a, const void *b)
-{
-	const struct ext2_extent_entry *db_a;
-	const struct ext2_extent_entry *db_b;
-
-	db_a = (const struct ext2_extent_entry *) a;
-	db_b = (const struct ext2_extent_entry *) b;
-
-	return (db_a->old_loc - db_b->old_loc);
-}
-
-/*
- * Given an inode map and inode number, look up the old inode number
- * and return the new inode number.
- */
-__u64 ext2fs_extent_translate(ext2_extent extent, __u64 old_loc)
-{
-	__s64	low, high, mid;
-	__u64	lowval, highval;
-	float	range;
-
-	if (!extent->sorted) {
-		qsort(extent->list, extent->num,
-		      sizeof(struct ext2_extent_entry), extent_cmp);
-		extent->sorted = 1;
-	}
-	low = 0;
-	high = extent->num-1;
-	while (low <= high) {
-#if 0
-		mid = (low+high)/2;
-#else
-		if (low == high)
-			mid = low;
-		else {
-			/* Interpolate for efficiency */
-			lowval = extent->list[low].old_loc;
-			highval = extent->list[high].old_loc;
-
-			if (old_loc < lowval)
-				range = 0;
-			else if (old_loc > highval)
-				range = 1;
-			else {
-				range = ((float) (old_loc - lowval)) /
-					(highval - lowval);
-				if (range > 0.9)
-					range = 0.9;
-				if (range < 0.1)
-					range = 0.1;
-			}
-			mid = low + ((__u64) (range * (high-low)));
-		}
-#endif
-		if ((old_loc >= extent->list[mid].old_loc) &&
-		    (old_loc < extent->list[mid].old_loc + extent->list[mid].size))
-			return (extent->list[mid].new_loc +
-				(old_loc - extent->list[mid].old_loc));
-		if (old_loc < extent->list[mid].old_loc)
-			high = mid-1;
-		else
-			low = mid+1;
-	}
-	return 0;
-}
-
-/*
- * For debugging only
- */
-void ext2fs_extent_dump(ext2_extent extent, FILE *out)
-{
-	__u64	i;
-	struct ext2_extent_entry *ent;
-
-	fputs(_("# Extent dump:\n"), out);
-	fprintf(out, _("#\tNum=%llu, Size=%llu, Cursor=%llu, Sorted=%llu\n"),
-	       extent->num, extent->size, extent->cursor, extent->sorted);
-	for (i=0, ent=extent->list; i < extent->num; i++, ent++) {
-		fprintf(out, "#\t\t %llu -> %llu (%llu)\n", ent->old_loc,
-			ent->new_loc, ent->size);
-	}
-}
-
-/*
- * Iterate over the contents of the extent table
- */
-errcode_t ext2fs_iterate_extent(ext2_extent extent, __u64 *old_loc,
-				__u64 *new_loc, __u64 *size)
-{
-	struct ext2_extent_entry *ent;
-
-	if (!old_loc) {
-		extent->cursor = 0;
-		return 0;
-	}
-
-	if (extent->cursor >= extent->num) {
-		*old_loc = 0;
-		*new_loc = 0;
-		*size = 0;
-		return 0;
-	}
-
-	ent = extent->list + extent->cursor++;
-
-	*old_loc = ent->old_loc;
-	*new_loc = ent->new_loc;
-	*size = ent->size;
-	return 0;
-}
-
-
-
-
diff --git a/resize/resize2fs.h b/resize/resize2fs.h
index 829fcd8ea8e1..c53b3bee8c8d 100644
--- a/resize/resize2fs.h
+++ b/resize/resize2fs.h
@@ -152,17 +152,6 @@ extern errcode_t adjust_fs_info(ext2_filsys fs, ext2_filsys old_fs,
 extern blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags);
 
 
-/* extent.c */
-extern errcode_t ext2fs_create_extent_table(ext2_extent *ret_extent,
-					    __u64 size);
-extern void ext2fs_free_extent_table(ext2_extent extent);
-extern errcode_t ext2fs_add_extent_entry(ext2_extent extent,
-					 __u64 old_loc, __u64 new_loc);
-extern __u64 ext2fs_extent_translate(ext2_extent extent, __u64 old_loc);
-extern void ext2fs_extent_dump(ext2_extent extent, FILE *out);
-extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u64 *old_loc,
-				       __u64 *new_loc, __u64 *size);

  parent reply	other threads:[~2015-08-26 16:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-26 16:22 [PATCH 00/21 v2] e2fsprogs: Resizing rewrite Jan Kara
2015-08-26 16:22 ` [PATCH 01/21] ext2fs: Add pointer to allocator private data into ext2_filsys Jan Kara
2015-08-26 16:22 ` [PATCH 02/21] ext2fs: Implement ext2fs_allocate_group_table2() Jan Kara
2015-08-26 16:22 ` [PATCH 03/21] resize2fs: Use ext2fs_allocate_group_table2() Jan Kara
2015-08-26 16:22 ` [PATCH 04/21] ext2fs: Provide helper for wiping resize inode Jan Kara
2015-08-26 16:22 ` [PATCH 05/21] ext2fs: Implement block moving in libext2fs Jan Kara
2015-08-26 16:22 ` [PATCH 06/21] ext2fs: Implement inode " Jan Kara
2015-08-26 16:22 ` [PATCH 07/21] tune2fs: Implement setting and disabling of 64-bit feature Jan Kara
2015-08-26 16:22 ` [PATCH 08/21] tests: Convert tests for 64bit feature to use tune2fs Jan Kara
2015-08-26 16:22 ` [PATCH 09/21] mke2fs: Allow specifying number of reserved inodes Jan Kara
2015-08-26 16:22 ` [PATCH 10/21] ext2fs: Fixup inline directory test Jan Kara
2015-08-26 16:22 ` [PATCH 11/21] tests: Specify number of reserved inodes for tests where it matters Jan Kara
2015-08-26 16:22 ` [PATCH 12/21] libext2fs: Bump default number of reserved inodes to 64 Jan Kara
2015-08-26 16:22 ` [PATCH 13/21] tune2fs: Add support for changing number of reserved inodes Jan Kara
2015-08-26 16:22 ` [PATCH 14/21] mke2fs, tune2fs: Tests for handling reserved_inodes option Jan Kara
2015-08-26 16:22 ` [PATCH 15/21] resize2fs: Rip out 64-bit feature handling from resize2fs Jan Kara
2015-08-26 16:22 ` [PATCH 16/21] ext2fs: Remove old block mapping function Jan Kara
2015-08-26 16:22 ` [PATCH 17/21] resize2fs: Remove duplicate condition Jan Kara
2015-08-26 16:22 ` [PATCH 18/21] ext2fs: Add extent dumping function to extent mapping code Jan Kara
2015-08-26 16:22 ` Jan Kara [this message]
2015-08-26 16:22 ` [PATCH 20/21] ext2fs: Move extent mapping test Jan Kara
2015-08-26 16:22 ` [PATCH 21/21] resize2fs: Use libextfs2 helpers for resizing Jan Kara

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=1440606156-5754-20-git-send-email-jack@suse.com \
    --to=jack@suse.com \
    --cc=darrick.wong@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).