diff mbox

e2fsprogs: add 64bit-online-resize support

Message ID 1313046601-2795-1-git-send-email-xiaoqiangnk@gmail.com
State Superseded, archived
Headers show

Commit Message

Yongqiang Yang Aug. 11, 2011, 7:10 a.m. UTC
This patch adds 64bit-resize support to e2fsprogs.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
 lib/ext2fs/ext2_fs.h |    1 +
 resize/online.c      |   22 +++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)

Comments

Andreas Dilger Aug. 11, 2011, 7:42 a.m. UTC | #1
On 2011-08-11, at 1:10 AM, Yongqiang Yang wrote:
> This patch adds 64bit-resize support to e2fsprogs.
> 
> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
> ---
> lib/ext2fs/ext2_fs.h |    1 +
> resize/online.c      |   22 +++++++++++++++++++++-
> 2 files changed, 22 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
> index 54cb3d4..4fec5db 100644
> --- a/lib/ext2fs/ext2_fs.h
> +++ b/lib/ext2fs/ext2_fs.h
> @@ -327,6 +327,7 @@ struct ext4_new_group_input {
> #define EXT2_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
> #define EXT2_IOC_GROUP_ADD		_IOW('f', 8,struct ext2_new_group_input)
> #define EXT4_IOC_GROUP_ADD		_IOW('f', 8,struct ext4_new_group_input)
> +#define EXT4_IOC_RESIZE_FS		_IOW('f', 16, __u64)
> 
> /*
>  * Structure of an inode on the disk
> diff --git a/resize/online.c b/resize/online.c
> index 1d8d4ec..53ad852 100644
> --- a/resize/online.c
> +++ b/resize/online.c
> @@ -51,7 +51,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
> 				  fs->super->s_first_data_block,
> 				  EXT2_BLOCKS_PER_GROUP(fs->super)),
> 		EXT2_DESC_PER_BLOCK(fs->super));
> -	printf("old desc_blocks = %lu, new_desc_blocks = %lu\n",
> +	printf("old_desc_blocks = %lu, new_desc_blocks = %lu\n",
> 	       fs->desc_blocks, new_desc_blocks);
> 	if (!(fs->super->s_feature_compat &
> 	      EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
> @@ -69,6 +69,26 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
> 	}
> 
> 	size=ext2fs_blocks_count(sb);
> +
> +	if (ioctl(fd, EXT4_IOC_RESIZE_FS, new_size)) {
> +		if (errno == ENOTTY) {
> +			printf("Kernel does not support 64bit-online resizing, "
> +			       "tring the old style online resizing\n");

s/tring/trying/

In any case, I don't think users care about which ioctl is in use, just
that it works correctly on the kernel they are using.  IMHO it should just
silently try both ioctls() without any extra warnings.

> +		} else {
> +			if (errno == EPERM)
> +				com_err(program_name, 0,
> +				_("Permission denied to resize filesystem"));
> +			else
> +				com_err(program_name, errno,
> +				_("While checking for on-line resizing "
> +				  "support"));
> +			exit(1);
> +		}
> +	} else {
> +		close(fd);
> +		return 0;
> +	}
> +
> 	if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) {
> 		if (errno == EPERM)
> 			com_err(program_name, 0,
> -- 
> 1.7.5.1
> 
> --
> 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


Cheers, Andreas





--
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
Yongqiang Yang Aug. 12, 2011, 8:43 a.m. UTC | #2
On Thu, Aug 11, 2011 at 3:42 PM, Andreas Dilger <adilger@dilger.ca> wrote:
> On 2011-08-11, at 1:10 AM, Yongqiang Yang wrote:
>> This patch adds 64bit-resize support to e2fsprogs.
>>
>> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
>> ---
>> lib/ext2fs/ext2_fs.h |    1 +
>> resize/online.c      |   22 +++++++++++++++++++++-
>> 2 files changed, 22 insertions(+), 1 deletions(-)
>>
>> diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
>> index 54cb3d4..4fec5db 100644
>> --- a/lib/ext2fs/ext2_fs.h
>> +++ b/lib/ext2fs/ext2_fs.h
>> @@ -327,6 +327,7 @@ struct ext4_new_group_input {
>> #define EXT2_IOC_GROUP_EXTEND         _IOW('f', 7, unsigned long)
>> #define EXT2_IOC_GROUP_ADD            _IOW('f', 8,struct ext2_new_group_input)
>> #define EXT4_IOC_GROUP_ADD            _IOW('f', 8,struct ext4_new_group_input)
>> +#define EXT4_IOC_RESIZE_FS           _IOW('f', 16, __u64)
>>
>> /*
>>  * Structure of an inode on the disk
>> diff --git a/resize/online.c b/resize/online.c
>> index 1d8d4ec..53ad852 100644
>> --- a/resize/online.c
>> +++ b/resize/online.c
>> @@ -51,7 +51,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
>>                                 fs->super->s_first_data_block,
>>                                 EXT2_BLOCKS_PER_GROUP(fs->super)),
>>               EXT2_DESC_PER_BLOCK(fs->super));
>> -     printf("old desc_blocks = %lu, new_desc_blocks = %lu\n",
>> +     printf("old_desc_blocks = %lu, new_desc_blocks = %lu\n",
>>              fs->desc_blocks, new_desc_blocks);
>>       if (!(fs->super->s_feature_compat &
>>             EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
>> @@ -69,6 +69,26 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
>>       }
>>
>>       size=ext2fs_blocks_count(sb);
>> +
>> +     if (ioctl(fd, EXT4_IOC_RESIZE_FS, new_size)) {
>> +             if (errno == ENOTTY) {
>> +                     printf("Kernel does not support 64bit-online resizing, "
>> +                            "tring the old style online resizing\n");
>
> s/tring/trying/
>
> In any case, I don't think users care about which ioctl is in use, just
> that it works correctly on the kernel they are using.  IMHO it should just
> silently try both ioctls() without any extra warnings.
Thanks, it will be fixed.

Yongqiang.
>
>> +             } else {
>> +                     if (errno == EPERM)
>> +                             com_err(program_name, 0,
>> +                             _("Permission denied to resize filesystem"));
>> +                     else
>> +                             com_err(program_name, errno,
>> +                             _("While checking for on-line resizing "
>> +                               "support"));
>> +                     exit(1);
>> +             }
>> +     } else {
>> +             close(fd);
>> +             return 0;
>> +     }
>> +
>>       if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) {
>>               if (errno == EPERM)
>>                       com_err(program_name, 0,
>> --
>> 1.7.5.1
>>
>> --
>> 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
>
>
> Cheers, Andreas
>
>
>
>
>
>
diff mbox

Patch

diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index 54cb3d4..4fec5db 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -327,6 +327,7 @@  struct ext4_new_group_input {
 #define EXT2_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
 #define EXT2_IOC_GROUP_ADD		_IOW('f', 8,struct ext2_new_group_input)
 #define EXT4_IOC_GROUP_ADD		_IOW('f', 8,struct ext4_new_group_input)
+#define EXT4_IOC_RESIZE_FS		_IOW('f', 16, __u64)
 
 /*
  * Structure of an inode on the disk
diff --git a/resize/online.c b/resize/online.c
index 1d8d4ec..53ad852 100644
--- a/resize/online.c
+++ b/resize/online.c
@@ -51,7 +51,7 @@  errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 				  fs->super->s_first_data_block,
 				  EXT2_BLOCKS_PER_GROUP(fs->super)),
 		EXT2_DESC_PER_BLOCK(fs->super));
-	printf("old desc_blocks = %lu, new_desc_blocks = %lu\n",
+	printf("old_desc_blocks = %lu, new_desc_blocks = %lu\n",
 	       fs->desc_blocks, new_desc_blocks);
 	if (!(fs->super->s_feature_compat &
 	      EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
@@ -69,6 +69,26 @@  errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 	}
 
 	size=ext2fs_blocks_count(sb);
+
+	if (ioctl(fd, EXT4_IOC_RESIZE_FS, new_size)) {
+		if (errno == ENOTTY) {
+			printf("Kernel does not support 64bit-online resizing, "
+			       "tring the old style online resizing\n");
+		} else {
+			if (errno == EPERM)
+				com_err(program_name, 0,
+				_("Permission denied to resize filesystem"));
+			else
+				com_err(program_name, errno,
+				_("While checking for on-line resizing "
+				  "support"));
+			exit(1);
+		}
+	} else {
+		close(fd);
+		return 0;
+	}
+
 	if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) {
 		if (errno == EPERM)
 			com_err(program_name, 0,