linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] e4defrag : Open the source file for e4defrag in read write mode to avoid failures from EXT4_IOC_EXT_MOVE
@ 2010-01-19  4:21 Manish Katiyar
  2010-01-19  4:37 ` Akira Fujita
  0 siblings, 1 reply; 3+ messages in thread
From: Manish Katiyar @ 2010-01-19  4:21 UTC (permalink / raw)
  To: Akira Fujita; +Cc: ext4

Hi Akira,

I am consistently getting -EBADF while trying out e4defrag and it
fails with below error.

/home/mkatiyar/e2fs-git/e2fsprogs/misc> ./e4defrag -v /tmp/ohsm/mntdir/f1
ext4 defragmentation for /tmp/ohsm/mntdir/f1
[1/1]/tmp/ohsm/mntdir/f1:	  0%
	Failed to defrag:Bad file descriptor	[ NG ]
 Success:			[0/1]

Below patch fixes the issue for me, though I am not sure if this is
the right fix to open the source file in readwrite mode or fix the
ext4 ioctl part.


Open the source file in read write mode to avoid failures from EXT4_IOC_EXT_MOVE

Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>
---
 misc/e4defrag.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 82e3868..424e0ca 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -1605,7 +1605,7 @@ static int file_defrag(const char *file, const
struct stat64 *buf,
 		return 0;
 	}

-	fd = open64(file, O_RDONLY);
+	fd = open64(file, O_RDWR);
 	if (fd < 0) {
 		if (mode_flag & DETAIL) {
 			PRINT_FILE_NAME(file);
-- 
1.6.3.3


-- 
Thanks -
Manish
==================================
[$\*.^ -- I miss being one of them
==================================

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

* Re: [PATCH] e4defrag : Open the source file for e4defrag in read write  mode to avoid failures from EXT4_IOC_EXT_MOVE
  2010-01-19  4:21 [PATCH] e4defrag : Open the source file for e4defrag in read write mode to avoid failures from EXT4_IOC_EXT_MOVE Manish Katiyar
@ 2010-01-19  4:37 ` Akira Fujita
  2010-01-19  4:40   ` Manish Katiyar
  0 siblings, 1 reply; 3+ messages in thread
From: Akira Fujita @ 2010-01-19  4:37 UTC (permalink / raw)
  To: Manish Katiyar; +Cc: ext4


Hi Manish,

(2010/01/19 13:21), Manish Katiyar wrote:
> Hi Akira,
> 
> I am consistently getting -EBADF while trying out e4defrag and it
> fails with below error.
> 
> /home/mkatiyar/e2fs-git/e2fsprogs/misc>  ./e4defrag -v /tmp/ohsm/mntdir/f1
> ext4 defragmentation for /tmp/ohsm/mntdir/f1
> [1/1]/tmp/ohsm/mntdir/f1:	  0%
> 	Failed to defrag:Bad file descriptor	[ NG ]
>   Success:			[0/1]
> 
> Below patch fixes the issue for me, though I am not sure if this is
> the right fix to open the source file in readwrite mode or fix the
> ext4 ioctl part.
> 

Patch looks good to me.
# I send same patch to Ted last month, but it is not on linux-ext4, sorry.

By commit 4a58579b9e4e2a35d57e6c9c8483e52f6f1b7fd6 of Linus' kernel tree,
rw mode check was added to EXT4_IOC_MOVE_EXTENT.
But command patch which corresponds to this change
has not been merged into e2fsprogs.
So this change is needed to run e4defrag command on current Linux kernel.

Regards,
Akira Fujita


> Open the source file in read write mode to avoid failures from EXT4_IOC_EXT_MOVE
> 
> Signed-off-by: Manish Katiyar<mkatiyar@gmail.com>
> ---
>   misc/e4defrag.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/misc/e4defrag.c b/misc/e4defrag.c
> index 82e3868..424e0ca 100644
> --- a/misc/e4defrag.c
> +++ b/misc/e4defrag.c
> @@ -1605,7 +1605,7 @@ static int file_defrag(const char *file, const
> struct stat64 *buf,
>   		return 0;
>   	}
> 
> -	fd = open64(file, O_RDONLY);
> +	fd = open64(file, O_RDWR);
>   	if (fd<  0) {
>   		if (mode_flag&  DETAIL) {
>   			PRINT_FILE_NAME(file);



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

* Re: [PATCH] e4defrag : Open the source file for e4defrag in read write mode to avoid failures from EXT4_IOC_EXT_MOVE
  2010-01-19  4:37 ` Akira Fujita
@ 2010-01-19  4:40   ` Manish Katiyar
  0 siblings, 0 replies; 3+ messages in thread
From: Manish Katiyar @ 2010-01-19  4:40 UTC (permalink / raw)
  To: Akira Fujita; +Cc: ext4

2010/1/19 Akira Fujita <a-fujita@rs.jp.nec.com>:
>
> Hi Manish,
>
> (2010/01/19 13:21), Manish Katiyar wrote:
>> Hi Akira,
>>
>> I am consistently getting -EBADF while trying out e4defrag and it
>> fails with below error.
>>
>> /home/mkatiyar/e2fs-git/e2fsprogs/misc>  ./e4defrag -v /tmp/ohsm/mntdir/f1
>> ext4 defragmentation for /tmp/ohsm/mntdir/f1
>> [1/1]/tmp/ohsm/mntdir/f1:       0%
>>       Failed to defrag:Bad file descriptor    [ NG ]
>>   Success:                    [0/1]
>>
>> Below patch fixes the issue for me, though I am not sure if this is
>> the right fix to open the source file in readwrite mode or fix the
>> ext4 ioctl part.
>>
>
> Patch looks good to me.
> # I send same patch to Ted last month, but it is not on linux-ext4, sorry.
>
> By commit 4a58579b9e4e2a35d57e6c9c8483e52f6f1b7fd6 of Linus' kernel tree,
> rw mode check was added to EXT4_IOC_MOVE_EXTENT.
> But command patch which corresponds to this change
> has not been merged into e2fsprogs.
> So this change is needed to run e4defrag command on current Linux kernel.

Ohh okie... Thanks a lot for the prompt response :-)

Thanks -
Manish

>
> Regards,
> Akira Fujita
>
>
>> Open the source file in read write mode to avoid failures from EXT4_IOC_EXT_MOVE
>>
>> Signed-off-by: Manish Katiyar<mkatiyar@gmail.com>
>> ---
>>   misc/e4defrag.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/misc/e4defrag.c b/misc/e4defrag.c
>> index 82e3868..424e0ca 100644
>> --- a/misc/e4defrag.c
>> +++ b/misc/e4defrag.c
>> @@ -1605,7 +1605,7 @@ static int file_defrag(const char *file, const
>> struct stat64 *buf,
>>               return 0;
>>       }
>>
>> -     fd = open64(file, O_RDONLY);
>> +     fd = open64(file, O_RDWR);
>>       if (fd<  0) {
>>               if (mode_flag&  DETAIL) {
>>                       PRINT_FILE_NAME(file);
>
>
>



-- 
Thanks -
Manish
==================================
[$\*.^ -- I miss being one of them
==================================
--
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

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

end of thread, other threads:[~2010-01-19  4:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-19  4:21 [PATCH] e4defrag : Open the source file for e4defrag in read write mode to avoid failures from EXT4_IOC_EXT_MOVE Manish Katiyar
2010-01-19  4:37 ` Akira Fujita
2010-01-19  4:40   ` Manish Katiyar

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).