diff mbox

Segmentation fault in e4defrag -c

Message ID 4A485929.7010403@rs.jp.nec.com
State Accepted, archived
Headers show

Commit Message

Akira Fujita June 29, 2009, 6:03 a.m. UTC
Hi,

Steinar H. Gunderson wrote:
>> 3. stat "/home/sesse/Mika - Life In Cartoon Motion/11 - Ring Ring (Bonus Track).mp3"
> 
> pannekake:~# stat "/home/sesse/Mika - Life In Cartoon Motion/11 - Ring Ring (Bonus Track).mp3" 
>   File: `/home/sesse/Mika - Life In Cartoon Motion/11 - Ring Ring (Bonus Track).mp3'
>   Size: 4050385   	Blocks: 0          IO Block: 4096   regular file
> Device: fd12h/64786d	Inode: 688755      Links: 1
> Access: (0644/-rw-r--r--)  Uid: ( 1000/   sesse)   Gid: ( 1000/   sesse)
> Access: 2009-05-30 03:08:38.724454316 +0200
> Modify: 2008-09-01 20:38:26.135589449 +0200
> Change: 2008-09-01 20:38:26.135589449 +0200

Thank you for information.

File size is "4050385" but Blocks is "0"
probably means blocks are not allocated yet or file is *corrupted*.
Is your mp3 file available?

Anyway, with this patch, 0 blocks file is skipped,
therefore the segmentation fault you had will not happen.

Thanks and Regards,
Akira Fujita

Signed-off-by Akira Fujita <a-fujita@rs.jp.nec.com>
---
 online-defrag-cmd |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
--
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

Comments

Andreas Dilger June 29, 2009, 9:49 p.m. UTC | #1
On Jun 29, 2009  15:03 +0900, Akira Fujita wrote:
> >   Size: 4050385   	Blocks: 0          IO Block: 4096   regular file
> > Device: fd12h/64786d	Inode: 688755      Links: 1
> > Access: (0644/-rw-r--r--)  Uid: ( 1000/   sesse)   Gid: ( 1000/   sesse)
> > Access: 2009-05-30 03:08:38.724454316 +0200
> > Modify: 2008-09-01 20:38:26.135589449 +0200
> > Change: 2008-09-01 20:38:26.135589449 +0200
> 
> File size is "4050385" but Blocks is "0"
> probably means blocks are not allocated yet or file is *corrupted*.
> Is your mp3 file available?

Well, this is a sparse file for some reason (e.g. failed mp3 p2p download).

> Anyway, with this patch, 0 blocks file is skipped,
> therefore the segmentation fault you had will not happen.

Is it possible that the code has not been tested with sparse files?
In that case, the check for size == 0 is only going to catch a single
case of problem, and not handle general sparse files.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
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
Akira Fujita June 30, 2009, 11:43 p.m. UTC | #2
Hi,
Andreas Dilger wrote:
> On Jun 29, 2009  15:03 +0900, Akira Fujita wrote:
>>>   Size: 4050385   	Blocks: 0          IO Block: 4096   regular file
>>> Device: fd12h/64786d	Inode: 688755      Links: 1
>>> Access: (0644/-rw-r--r--)  Uid: ( 1000/   sesse)   Gid: ( 1000/   sesse)
>>> Access: 2009-05-30 03:08:38.724454316 +0200
>>> Modify: 2008-09-01 20:38:26.135589449 +0200
>>> Change: 2008-09-01 20:38:26.135589449 +0200
>> File size is "4050385" but Blocks is "0"
>> probably means blocks are not allocated yet or file is *corrupted*.
>> Is your mp3 file available?
> 
> Well, this is a sparse file for some reason (e.g. failed mp3 p2p download).
> 

Ah, may be so.

>> Anyway, with this patch, 0 blocks file is skipped,
>> therefore the segmentation fault you had will not happen.
> 
> Is it possible that the code has not been tested with sparse files?
> In that case, the check for size == 0 is only going to catch a single
> case of problem, and not handle general sparse files.
> 

I have tested files that have sparse blocks
(e.g. files that have sparse blocks in its beginning,
middle and those combinations) and got fine results.
Unfortunately, like this case, only 0 blocks file (all sparse blocks)
has not been tested yet.

But the kernel space (EXT4_IOC_MOVE_EXTENT) does not have this kind of issue.
Because there is a check of whether the extents of orig_inode
that ext4_ext_find_extent() gets is NULL.
If extents is NULL or ext4_ext_find_extent() fails,
ext4_move_extents() returns an error value (e.g. EINVAL) to the user space.

Regards,
Akira Fujita


--
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
diff mbox

Patch

--- online-defrag-cmd	2009-06-29 13:07:16.000000000 +0900
+++ online-defrag-cmd-20090629	2009-06-29 13:07:41.000000000 +0900
@@ -1303,6 +1303,15 @@  int file_statistic(const char *file, con
 		return 0;
 	}

+	/* Has no blocks */
+	if (buf->st_blocks == 0) {
+		if (mode_flag & DETAIL) {
+			PRINT_FILE_NAME(file);
+			STATISTIC_ERR_MSG("File has no blocks");
+		}
+		return 0;
+	}
+
 	fd = open64(file, O_RDONLY);
 	if (fd < 0) {
 		if (mode_flag & DETAIL) {
@@ -1624,6 +1633,15 @@  int file_defrag(const char *file, const
 		return 0;
 	}

+	/* Has no blocks */
+	if (buf->st_blocks == 0) {
+		if (mode_flag & DETAIL) {
+			PRINT_FILE_NAME(file);
+			STATISTIC_ERR_MSG("File has no blocks");
+		}
+		return 0;
+	}
+
 	fd = open64(file, O_RDONLY);
 	if (fd < 0) {
 		if (mode_flag & DETAIL) {