Patchwork resize2fs: add debug switch to use old online interface

login
register
mail settings
Submitter Eric Sandeen
Date Jan. 11, 2013, 5:52 p.m.
Message ID <50F05175.8060502@redhat.com>
Download mbox | patch
Permalink /patch/211390/
State Superseded
Headers show

Comments

Eric Sandeen - Jan. 11, 2013, 5:52 p.m.
The old online resize ioctl interfaces are still present
in the kernel; add a debug switch to resize2fs to be able
to test them.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---



--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o - Jan. 12, 2013, 12:30 a.m.
On Fri, Jan 11, 2013 at 11:52:53AM -0600, Eric Sandeen wrote:
> --- a/resize/resize2fs.h
> +++ b/resize/resize2fs.h
> @@ -76,6 +76,8 @@ typedef struct ext2_sim_progress *ext2_sim_progmeter;
>  #define RESIZE_DEBUG_BMOVE		0x0002
>  #define RESIZE_DEBUG_INODEMAP		0x0004
>  #define RESIZE_DEBUG_ITABLEMOVE		0x0008
> +/* old online resize interface */
> +#define RESIZE_DEBUG_OLD		0x0010

0x0010 is already used for

#define RESIZE_DEBUG_RTRACK		0x0010

(which is very useful for performance tuning resize2fs).

I wonder if we would be better off using a environment variable for
this?  Mainly because currently, the current resize flags don't
actually change the behavior of resize2fs, but just add different
levels of debugging messages. 

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Sandeen - Jan. 12, 2013, 12:33 a.m.
On 1/11/13 6:30 PM, Theodore Ts'o wrote:
> On Fri, Jan 11, 2013 at 11:52:53AM -0600, Eric Sandeen wrote:
>> --- a/resize/resize2fs.h
>> +++ b/resize/resize2fs.h
>> @@ -76,6 +76,8 @@ typedef struct ext2_sim_progress *ext2_sim_progmeter;
>>  #define RESIZE_DEBUG_BMOVE		0x0002
>>  #define RESIZE_DEBUG_INODEMAP		0x0004
>>  #define RESIZE_DEBUG_ITABLEMOVE		0x0008
>> +/* old online resize interface */
>> +#define RESIZE_DEBUG_OLD		0x0010
> 
> 0x0010 is already used for
> 
> #define RESIZE_DEBUG_RTRACK		0x0010
> 
> (which is very useful for performance tuning resize2fs).

Ugh, how did I miss that.  Sorry.

> I wonder if we would be better off using a environment variable for
> this?  Mainly because currently, the current resize flags don't
> actually change the behavior of resize2fs, but just add different
> levels of debugging messages. 

The mechanism doesn't matter to me, we just need to be able to test
it if the interface is in the kernel.  I had originally had an "-o"
option for "old interface" but that didn't seem great.

-Eric

> 
> 						- Ted
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/resize/online.c b/resize/online.c
index d3d3546..9b38ac8 100644
--- a/resize/online.c
+++ b/resize/online.c
@@ -22,7 +22,7 @@  extern char *program_name;
 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
 
 errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
-			   blk64_t *new_size, int flags EXT2FS_ATTR((unused)))
+			   blk64_t *new_size, int flags)
 {
 #ifdef __linux__
 	struct ext2_new_group_input input;
@@ -94,9 +94,11 @@  errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 		exit(1);
 	}
 
-	if (ioctl(fd, EXT4_IOC_RESIZE_FS, new_size)) {
+	if (flags & RESIZE_DEBUG_OLD ||
+	    ioctl(fd, EXT4_IOC_RESIZE_FS, new_size)) {
 		/*
-		 * If kernel does not support EXT4_IOC_RESIZE_FS, use the
+		 * If kernel does not support EXT4_IOC_RESIZE_FS, or -d 16
+		 * is specified on the resize2fs command line, use the
 		 * old online resize. Note that the old approach does not
 		 * handle >32 bit file systems
 		 *
@@ -109,7 +111,9 @@  errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 		 * in the kernel sources.  This is probably a kernel
 		 * bug, but work around it here.
 		 */
-		if ((errno != ENOTTY) && (errno != EINVAL)) {
+		if (flags & RESIZE_DEBUG_OLD) {
+			printf("Old resize interface requested.\n");
+		} else if ((errno != ENOTTY) && (errno != EINVAL)) {
 			if (errno == EPERM)
 				com_err(program_name, 0,
 				_("Permission denied to resize filesystem"));
diff --git a/resize/resize2fs.8.in b/resize/resize2fs.8.in
index 9ff6e0a..766c4d8 100644
--- a/resize/resize2fs.8.in
+++ b/resize/resize2fs.8.in
@@ -99,6 +99,8 @@  from the following list:
 	4	\-\ Debug inode relocations
 .br
 	8	\-\ Debug moving the inode table
+.br
+	16	\-\ Debug old online resize interface
 .TP 
 .B \-f
 Forces resize2fs to proceed with the filesystem resize operation, overriding
diff --git a/resize/resize2fs.h b/resize/resize2fs.h
index 2184759..58fc04d 100644
--- a/resize/resize2fs.h
+++ b/resize/resize2fs.h
@@ -76,6 +76,8 @@  typedef struct ext2_sim_progress *ext2_sim_progmeter;
 #define RESIZE_DEBUG_BMOVE		0x0002
 #define RESIZE_DEBUG_INODEMAP		0x0004
 #define RESIZE_DEBUG_ITABLEMOVE		0x0008
+/* old online resize interface */
+#define RESIZE_DEBUG_OLD		0x0010
 
 #define RESIZE_PERCENT_COMPLETE		0x0100
 #define RESIZE_VERBOSE			0x0200