Skip to contentSkip to conversation

xfs_repair segfaut in stage 6

DISCUSSION Bartosz Cisek 5 participants 17 messages Sep 9, 2011 – Sep 20, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

Recently we had some problems with 2TB partition using xfs.

I/O error in filesystem ("cciss/c0d5p1") meta-data dev cciss/c0d5p1
block 0x120a0 ("xfs_trans_read_buf") error 5 buf count 4096

At first I suspected failed hardware, but disk array wasn't reporting anything.

Distro (Debian 5.0) version of xfs_repair finished with segfault. Same with compiled from git. I filled bug report [1]. Can someone possibly look into it? As it's hadoop heavy replicated partition I keep it only to provide additional information to resolve this segfault. I would be happy to provide as much detailed info as required, but I need to know what :)

[1] http://oss.sgi.com/bugzilla/show_bug.cgi?id=914

Kind regards,

Bartek

Signature · 18 lines
Bartosz Cisek
Admin

email: [email protected]
tel: +48 519 300 122

Nasza Klasa Sp. z o.o.,
ul. Gen. J. Bema 2, 50-265 Wrocław

Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu,
VI Wydział Gospodarczy Krajowego Rejestru Sądowego,
nr KRS:0000289629, NIP:898-21-22-104 REGON:020586020,
Kapitał zakładowy: 67 850,00 PLN

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 6 lines · On Freitag, 9. September 2011 Bartosz Cisek wrote:

Distro (Debian 5.0) version of xfs_repair finished with segfault. Same with compiled from git. I filled bug report [1]. Can someone possibly look into it? As it's hadoop heavy replicated partition I keep it only to provide additional information to resolve this segfault. I would be happy to provide as much detailed info as required, but I need to know what :)

Can you provide a metadump of that partition? By this, the devs can reproduce the bug on their machine, and resolve issues much quicker.

Which kernel and architecture are you on?

Signature · 8 lines
mit freundlichen Grüssen,
Michael Monnerie, Ing. BSc

it-management Internet Services: Protéger
http://proteger.at [gesprochen: Prot-e-schee]
Tel: +43 660 / 415 6531

// Haus zu verkaufen: http://zmi.at/langegg/

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#16 lore raw
In reply to Bartosz Cisek
Quoted 9 lines · Bartosz Cisek

Hi,

Recently we had some problems with 2TB partition using xfs.

I/O error in filesystem ("cciss/c0d5p1") meta-data dev cciss/c0d5p1
block 0x120a0 ("xfs_trans_read_buf") error 5 buf count 4096

At first I suspected failed hardware, but disk array wasn't reporting anything.

But that error really means that we got an error from the device.

Quoted 6 lines

Distro (Debian 5.0) version of xfs_repair finished with segfault. Same with compiled from git. I filled bug report [1]. Can someone possibly look into it? As it's hadoop heavy replicated partition I keep it only to provide additional information to resolve this segfault. I would be happy to provide as much detailed info as required, but I need to know what :)

The above pretty much guarantees a hardware (or maybe driver) issue, as XFS only gets the EIO from the lower layers.

Of course that does not mean that xfs_repair should crash. I'll look into it. As already mentioned a metadump image would be very helpful.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
In reply to Michael Monnerie

W dniu 09.09.2011 14:01, Michael Monnerie pisze:

Thanks for reply :)

Quoted 2 lines

Can you provide a metadump of that partition? By this, the devs can reproduce the bug on their machine, and resolve issues much quicker.

xfs_metadump -g /dev/cciss/c0d5p1 - | bzip2 > metadump.bz2

http://bartoszcisek.pl/metadump.bz2

Quoted 1 line

Which kernel and architecture are you on?

Linux hd-slave5 2.6.30-1-amd64 #1 SMP Tue Aug 18 17:39:23 CEST 2009 x86_64 GNU/Linux

Signature · 18 lines
Bartosz Cisek
Admin

email: [email protected]
tel: +48 519 300 122

Nasza Klasa Sp. z o.o.,
ul. Gen. J. Bema 2, 50-265 Wrocław

Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu,
VI Wydział Gospodarczy Krajowego Rejestru Sądowego,
nr KRS:0000289629, NIP:898-21-22-104 REGON:020586020,
Kapitał zakładowy: 67 850,00 PLN

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#3 lore raw

W dniu 09.09.2011 17:06, Bartosz Cisek pisze:

Quoted 6 lines
Quoted 2 lines

Can you provide a metadump of that partition? By this, the devs can reproduce the bug on their machine, and resolve issues much quicker.

xfs_metadump -g /dev/cciss/c0d5p1 - | bzip2 > metadump.bz2

http://bartoszcisek.pl/metadump.bz2

Is there anything more I can get from failed partition to help solving this bug? Or it can be safely recreated?

Signature · 18 lines
Bartosz Cisek
Admin

email: [email protected]
tel: +48 519 300 122

Nasza Klasa Sp. z o.o.,
ul. Gen. J. Bema 2, 50-265 Wrocław

Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu,
VI Wydział Gospodarczy Krajowego Rejestru Sądowego,
nr KRS:0000289629, NIP:898-21-22-104 REGON:020586020,
Kapitał zakładowy: 67 850,00 PLN

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw
Quoted 11 lines · Bartosz Cisek

W dniu 09.09.2011 17:06, Bartosz Cisek pisze:

Quoted 6 lines
Quoted 2 lines

Can you provide a metadump of that partition? By this, the devs can reproduce the bug on their machine, and resolve issues much quicker.

xfs_metadump -g /dev/cciss/c0d5p1 - | bzip2 > metadump.bz2

http://bartoszcisek.pl/metadump.bz2

Is there anything more I can get from failed partition to help solving this bug? Or it can be safely recreated?

Sorry for not replying earlier Bart. I'm downloading the metadump image now and will look at it.

Do you still have the kernel logs from when the issue happened?

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
In reply to Bartosz Cisek
Quoted 7 lines · Bartosz Cisek

W dniu 09.09.2011 14:01, Michael Monnerie pisze:

Thanks for reply :)

Quoted 2 lines

Can you provide a metadump of that partition? By this, the devs can reproduce the bug on their machine, and resolve issues much quicker.

Quoted 8 lines

xfs_metadump -g /dev/cciss/c0d5p1 - | bzip2 > metadump.bz2

http://bartoszcisek.pl/metadump.bz2

Quoted 1 line

Which kernel and architecture are you on?

Linux hd-slave5 2.6.30-1-amd64 #1 SMP Tue Aug 18 17:39:23 CEST 2009 x86_64 GNU/Linux

I've repaired the image fine using xfs_repair from the Debian testing xfsprogs 3.1.5+nmu1 package. It found two invalid blocks in a directory, which look like the result from the hardware error you saw.

You should be able to just rebuild the current xfsprogs (from testing/unstable or git) on Lenny and get the same result.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw

W dniu 12.09.2011 18:12, Christoph Hellwig pisze:

Quoted 6 lines

I've repaired the image fine using xfs_repair from the Debian testing xfsprogs 3.1.5+nmu1 package. It found two invalid blocks in a directory, which look like the result from the hardware error you saw.

You should be able to just rebuild the current xfsprogs (from testing/unstable or git) on Lenny and get the same result.

I've build xfs_repair from git on lenny and got segfault before my first email to this list (please refer to first email in this thread) :)

What else I can do to find what differ our two cases?

hd-slave5 ~/devel/xfsprogs/repair # LC_ALL=en_EN ./xfs_repair -v /dev/cciss/c0d5p1
Phase 1 - find and verify superblock...
- block cache size set to 3446312 entries
Phase 2 - using internal log
- zero log...
zero_log: head block 2 tail block 2
- scan filesystem freespace and inode maps...
- found root inode chunk
Phase 3 - for each AG...
- scan and clear agi unlinked lists...
- process known inodes and perform inode discovery...
- agno = 0
xfs_repair: read failed: Input/output error
can't read block 0 for directory inode 146453
no . entry for directory 146453
no .. entry for directory 146453
- agno = 1
- agno = 2
- agno = 3
- process newly discovered inodes...
Phase 4 - check for duplicate blocks...
- setting up duplicate extent list...
- check for inodes claiming duplicate blocks...
- agno = 0
- agno = 2
- agno = 3
- agno = 1
xfs_repair: read failed: Input/output error
can't read block 0 for directory inode 146453
no . entry for directory 146453
no .. entry for directory 146453
Phase 5 - rebuild AG headers and trees...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
- reset superblock...
Phase 6 - check inode connectivity...
- resetting contents of realtime bitmap and summary inodes
- traversing filesystem ...
- agno = 0
entry "subdir49" in dir ino 437 doesn't have a .. entry, will set it in ino 146453.
xfs_repair: read failed: Input/output error
Naruszenie ochrony pamięci (segfault)
hd-slave5 ~/devel/xfsprogs/repair # LC_ALL=en_EN ./xfs_repair -V xfs_repair version 3.1.5

Signature · 18 lines
Bartosz Cisek
Admin

email: [email protected]
tel: +48 519 300 122

Nasza Klasa Sp. z o.o.,
ul. Gen. J. Bema 2, 50-265 Wrocław

Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu,
VI Wydział Gospodarczy Krajowego Rejestru Sądowego,
nr KRS:0000289629, NIP:898-21-22-104 REGON:020586020,
Kapitał zakładowy: 67 850,00 PLN

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#7 lore raw
Quoted 10 lines · Bartosz Cisek

W dniu 12.09.2011 18:12, Christoph Hellwig pisze:

Quoted 6 lines

I've repaired the image fine using xfs_repair from the Debian testing xfsprogs 3.1.5+nmu1 package. It found two invalid blocks in a directory, which look like the result from the hardware error you saw.

You should be able to just rebuild the current xfsprogs (from testing/unstable or git) on Lenny and get the same result.

I've build xfs_repair from git on lenny and got segfault before my first email to this list (please refer to first email in this thread) :)

Ooops.

Quoted 1 line

What else I can do to find what differ our two cases?

The hardware? Given that you were getting read I/O errors from the hardware when shutting the fs down you probably got those as well when
running repair and that caused the segfault. Can you run xfs_repair
under gdb for me, that is:

gdb /path/to.xfs_repair

(gdb) set args /dev/cciss/c0d5p1
(gdb) run

and see what backtrace it gives you?

Please make sure to build xfs_repair in the git tree manually using make and not the Debian packaging, as that removes the debug symbols.

You can run gdb on the xfs_repair binary just built in the tree, no need to install it first.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#8 lore raw
Quoted 26 lines · Christoph Hellwig
Quoted 10 lines · Bartosz Cisek

W dniu 12.09.2011 18:12, Christoph Hellwig pisze:

Quoted 6 lines

I've repaired the image fine using xfs_repair from the Debian testing xfsprogs 3.1.5+nmu1 package. It found two invalid blocks in a directory, which look like the result from the hardware error you saw.

You should be able to just rebuild the current xfsprogs (from testing/unstable or git) on Lenny and get the same result.

I've build xfs_repair from git on lenny and got segfault before my first email to this list (please refer to first email in this thread) :)

Ooops.

Quoted 1 line

What else I can do to find what differ our two cases?

The hardware? Given that you were getting read I/O errors from the hardware when shutting the fs down you probably got those as well when
running repair and that caused the segfault. Can you run xfs_repair
under gdb for me, that is:

gdb /path/to.xfs_repair

(gdb) set args /dev/cciss/c0d5p1
(gdb) run

Quoted 7 lines

and see what backtrace it gives you?

Please make sure to build xfs_repair in the git tree manually using make and not the Debian packaging, as that removes the debug symbols.

You can run gdb on the xfs_repair binary just built in the tree, no need to install it first.

If it worked for Christoph and not for Bartosz ....

Is the -DDEBUG / -DNDEBUG type setting the same in both cases? Maybe Fedora is the only one doing -DNDEBUG :( but maybe worth checking.

-Eric

Quoted 5 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#11 lore raw
In reply to Christoph Hellwig

W dniu 14.09.2011 16:24, Christoph Hellwig pisze:

Quoted 10 lines

The hardware? Given that you were getting read I/O errors from the hardware when shutting the fs down you probably got those as well when
running repair and that caused the segfault. Can you run xfs_repair
under gdb for me, that is:

gdb /path/to.xfs_repair

(gdb) set args /dev/cciss/c0d5p1
(gdb) run

Quoted 7 lines

and see what backtrace it gives you?

Please make sure to build xfs_repair in the git tree manually using make and not the Debian packaging, as that removes the debug symbols.

You can run gdb on the xfs_repair binary just built in the tree, no need to install it first.

Stack trace is pasted in bug issue [1] that is linked in first mail ;) Compiled by hand from git: "DEBUG=-DDEBUG make". I don't know why some of values are 'optimized out'.

[1] http://oss.sgi.com/bugzilla/show_bug.cgi?id=914

Signature · 18 lines
Bartosz Cisek
Admin

email: [email protected]
tel: +48 519 300 122

Nasza Klasa Sp. z o.o.,
ul. Gen. J. Bema 2, 50-265 Wrocław

Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu,
VI Wydział Gospodarczy Krajowego Rejestru Sądowego,
nr KRS:0000289629, NIP:898-21-22-104 REGON:020586020,
Kapitał zakładowy: 67 850,00 PLN

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#9 lore raw
In reply to Eric Sandeen

W dniu 14.09.2011 16:57, Eric Sandeen pisze:

Quoted 5 lines

If it worked for Christoph and not for Bartosz ....

Is the -DDEBUG / -DNDEBUG type setting the same in both cases? Maybe Fedora is the only one doing -DNDEBUG :( but maybe worth checking.

Tested both. I was wodering why I got 'value optimized out' in gdb, so compiled with DEBUG=-DNDBEUG and DEBUG=-DDEBUG. Both crashed, both had 'optimized out' values in gdb backtrace.

I found two placed where DEBUG may be overwritten:

hd-slave5 ~/devel/xfsprogs # ack-grep NDEBUG
libxfs/Makefile
39:DEBUG = -DNDEBUG

libxlog/Makefile
16:DEBUG = -DNDEBUG

When I changed -DNDEBUG to -DDEBUG/ compilation failed.

xfs_ialloc.c: In function ‘xfs_imap’:
xfs_ialloc.c:1122: warning: implicit declaration of function ‘xfs_stack_trace’
[CC] xfs_inode.lo
xfs_inode.c: In function ‘xfs_validate_extents’:
xfs_inode.c:45: warning: implicit declaration of function ‘get_unaligned’ xfs_inode.c: In function ‘xfs_imap_to_bp’:
xfs_inode.c:149: warning: implicit declaration of function ‘XFS_BUFTARG_NAME’
xfs_inode.c: In function ‘xfs_iextents_copy’:
xfs_inode.c:1012: warning: implicit declaration of function ‘xfs_isilocked’ xfs_inode.c:1012: error: ‘XFS_ILOCK_SHARED’ undeclared (first use in this function)
xfs_inode.c:1012: error: (Each undeclared identifier is reported only once xfs_inode.c:1012: error: for each function it appears in.)

Signature · 18 lines
Bartosz Cisek
Admin

email: [email protected]
tel: +48 519 300 122

Nasza Klasa Sp. z o.o.,
ul. Gen. J. Bema 2, 50-265 Wrocław

Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu,
VI Wydział Gospodarczy Krajowego Rejestru Sądowego,
nr KRS:0000289629, NIP:898-21-22-104 REGON:020586020,
Kapitał zakładowy: 67 850,00 PLN

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#10 lore raw
Quoted 13 lines · Bartosz Cisek

W dniu 14.09.2011 16:57, Eric Sandeen pisze:

Quoted 5 lines

If it worked for Christoph and not for Bartosz ....

Is the -DDEBUG / -DNDEBUG type setting the same in both cases? Maybe Fedora is the only one doing -DNDEBUG :( but maybe worth checking.

Tested both. I was wodering why I got 'value optimized out' in gdb, so compiled with DEBUG=-DNDBEUG and DEBUG=-DDEBUG. Both crashed, both had 'optimized out' values in gdb backtrace.

I found two placed where DEBUG may be overwritten:

Quoted 8 lines

hd-slave5 ~/devel/xfsprogs # ack-grep NDEBUG
libxfs/Makefile
39:DEBUG = -DNDEBUG

libxlog/Makefile
16:DEBUG = -DNDEBUG

When I changed -DNDEBUG to -DDEBUG/ compilation failed.

yeah, that's why it's overridden in those places. :)

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#12 lore raw
In reply to Bartosz Cisek
Quoted 5 lines · Bartosz Cisek

Stack trace is pasted in bug issue [1] that is linked in first mail ;) Compiled by hand from git: "DEBUG=-DDEBUG make". I don't know why some of values are 'optimized out'.

[1] http://oss.sgi.com/bugzilla/show_bug.cgi?id=914

Looks like we do not handle read I/O errors very well (to say at all) in phase6. Can you see if the patch below makes a difference?

---
From: Christoph Hellwig <[email protected]>
Subject: repair: fix I/O error handling

Currently libxfs_trans_read_buf never returns an error, even if libxfs_readbuf did not manage to complete the I/O. This is different from the kernel behaviour and can lead to segfaults in code that doesn't expect it. Add a new b_error member to xfs_buf (mirroring the kernel version) and use that to propagate proper error codes to the caller. Also fix libxfs_readbufr to handle short reads properly, and to not override errno values e.g. by a fprintf.

include/libxfs.h +1 -0
Index: xfsprogs-dev/include/libxfs.h
===================================================================
@@ -230,6 +230,7 @@ typedef struct xfs_buf {
 	void			*b_fsprivate2;
 	void			*b_fsprivate3;
 	char			*b_addr;
+	int			b_error;
 #ifdef XFS_BUF_TRACING
 	struct list_head	b_lock_list;
 	const char		*b_func;
libxfs/rdwr.c +8 -7
Index: xfsprogs-dev/libxfs/rdwr.c
===================================================================
@@ -314,6 +314,7 @@ libxfs_initbuf(xfs_buf_t *bp, dev_t devi
 	bp->b_blkno = bno;
 	bp->b_bcount = bytes;
 	bp->b_dev = device;
+	bp->b_error = 0;
 	if (!bp->b_addr)
 		bp->b_addr = memalign(libxfs_device_alignment(), bytes);
 	if (!bp->b_addr) {
@@ -454,15 +455,17 @@ libxfs_readbufr(dev_t dev, xfs_daddr_t b
 {
 	int	fd = libxfs_device_to_fd(dev);
 	int	bytes = BBTOB(len);
+	int	error;
 
 	ASSERT(BBTOB(len) <= bp->b_bcount);
 
-	if (pread64(fd, bp->b_addr, bytes, LIBXFS_BBTOOFF64(blkno)) < 0) {
+	if (pread64(fd, bp->b_addr, bytes, LIBXFS_BBTOOFF64(blkno)) != bytes) {
+		error = errno;
 		fprintf(stderr, _("%s: read failed: %s\n"),
-			progname, strerror(errno));
+			progname, strerror(error));
 		if (flags & LIBXFS_EXIT_ON_FAILURE)
 			exit(1);
-		return errno;
+		return error;
 	}
 #ifdef IO_DEBUG
 	printf("%lx: %s: read %u bytes, blkno=%llu(%llu), %p\n",
@@ -485,10 +488,8 @@ libxfs_readbuf(dev_t dev, xfs_daddr_t bl
 	bp = libxfs_getbuf(dev, blkno, len);
 	if (bp && !(bp->b_flags & (LIBXFS_B_UPTODATE|LIBXFS_B_DIRTY))) {
 		error = libxfs_readbufr(dev, blkno, bp, len, flags);
-		if (error) {
-			libxfs_putbuf(bp);
-			return NULL;
-		}
+		if (error)
+			bp->b_error = error;
 	}
 	return bp;
 }
libxfs/trans.c +26 -8
Index: xfsprogs-dev/libxfs/trans.c
===================================================================
@@ -478,9 +478,20 @@ libxfs_trans_read_buf(
 	xfs_buf_log_item_t	*bip;
 	xfs_buftarg_t		bdev;
 
+	*bpp = NULL;
+
 	if (tp == NULL) {
-		*bpp = libxfs_readbuf(dev, blkno, len, flags);
-		return 0;
+		bp = libxfs_readbuf(dev, blkno, len, flags);
+		if (!bp) {
+			return (flags & XBF_TRYLOCK) ?
+				EAGAIN : XFS_ERROR(ENOMEM);
+		}
+		if (bp->b_error) {
+			int error = bp->b_error;
+			xfs_buf_relse(bp);
+			return error;
+		}
+		goto done;
 	}
 
 	bdev.dev = dev;
@@ -490,15 +501,20 @@ libxfs_trans_read_buf(
 		ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
 		bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
 		bip->bli_recur++;
-		*bpp = bp;
-		return 0;
+		goto done;
 	}
 
 	bp = libxfs_readbuf(dev, blkno, len, flags);
-       if (!bp){
-               *bpp = NULL;
-               return errno;
-       }
+	if (!bp) {
+		return (flags & XBF_TRYLOCK) ?
+			EAGAIN : XFS_ERROR(ENOMEM);
+	}
+	if (bp->b_error) {
+		int error = bp->b_error;
+		xfs_buf_relse(bp);
+		return error;
+	}
+
 #ifdef XACT_DEBUG
 	fprintf(stderr, "trans_read_buf buffer %p, transaction %p\n", bp, tp);
 #endif
@@ -510,6 +526,8 @@ libxfs_trans_read_buf(
 
 	/* initialise b_fsprivate2 so we can find it incore */
 	XFS_BUF_SET_FSPRIVATE2(bp, tp);
+
+done:
 	*bpp = bp;
 	return 0;
 }

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#13 lore raw

W dniu 14.09.2011 17:38, Christoph Hellwig pisze:

Quoted 9 lines · Bartosz Cisek
Quoted 5 lines

Stack trace is pasted in bug issue [1] that is linked in first mail ;) Compiled by hand from git: "DEBUG=-DDEBUG make". I don't know why some of values are 'optimized out'.

[1] http://oss.sgi.com/bugzilla/show_bug.cgi?id=914

Looks like we do not handle read I/O errors very well (to say at all) in phase6. Can you see if the patch below makes a difference?

It handled IO error and went on. Thanks ;)

Signature · 18 lines
Bartosz Cisek
Admin

email: [email protected]
tel: +48 519 300 122

Nasza Klasa Sp. z o.o.,
ul. Gen. J. Bema 2, 50-265 Wrocław

Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu,
VI Wydział Gospodarczy Krajowego Rejestru Sądowego,
nr KRS:0000289629, NIP:898-21-22-104 REGON:020586020,
Kapitał zakładowy: 67 850,00 PLN

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by
#14 lore raw
In reply to Christoph Hellwig
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Bartosz Cisek

Stack trace is pasted in bug issue [1] that is linked in first mail ;) Compiled by hand from git: "DEBUG=-DDEBUG make". I don't know why some of values are 'optimized out'.

[1] http://oss.sgi.com/bugzilla/show_bug.cgi?id=914

Looks like we do not handle read I/O errors very well (to say at all) in phase6. Can you see if the patch below makes a difference?

Christoph, I'm assuming you want this reviewed as a submitted patch.

Quoted 39 lines

---
From: Christoph Hellwig <[email protected]>
Subject: repair: fix I/O error handling

Currently libxfs_trans_read_buf never returns an error, even if libxfs_readbuf did not manage to complete the I/O. This is different from the kernel behaviour and can lead to segfaults in code that doesn't expect it. Add a new b_error member to xfs_buf (mirroring the kernel version) and use that to propagate proper error codes to the caller. Also fix libxfs_readbufr to handle short reads properly, and to not override errno values e.g. by a fprintf.

Index: xfsprogs-dev/include/libxfs.h
===================================================================

include/libxfs.h +1 -0
@@ -230,6 +230,7 @@ typedef struct xfs_buf {
 	void			*b_fsprivate2;
 	void			*b_fsprivate3;
 	char			*b_addr;
+	int			b_error;
 #ifdef XFS_BUF_TRACING
 	struct list_head	b_lock_list;
 	const char		*b_func;

Index: xfsprogs-dev/libxfs/rdwr.c
===================================================================

libxfs/rdwr.c +1 -0
@@ -314,6 +314,7 @@ libxfs_initbuf(xfs_buf_t *bp, dev_t devi
 	bp->b_blkno = bno;
 	bp->b_bcount = bytes;
 	bp->b_dev = device;
+	bp->b_error = 0;
 	if (!bp->b_addr)
 		bp->b_addr = memalign(libxfs_device_alignment(), bytes);
 	if (!bp->b_addr) {

libxfs/rdwr.c libxfs_readbufr(dev_t dev, xfs_daddr_t b · line 462

Quoted 9 lines
libxfs/rdwr.c +2 -1
@@ -454,15 +455,17 @@ libxfs_readbufr(dev_t dev, xfs_daddr_t b
 {
 	int	fd = libxfs_device_to_fd(dev);
 	int	bytes = BBTOB(len);
+	int	error;
 
 	ASSERT(BBTOB(len) <= bp->b_bcount);
 
-	if (pread64(fd, bp->b_addr, bytes, LIBXFS_BBTOOFF64(blkno)) < 0) {
+	if (pread64(fd, bp->b_addr, bytes, LIBXFS_BBTOOFF64(blkno)) != bytes) {

If we reach EOF this returns 0, but errno is I think going to be 0. Do we want to print a "read failed" message in that case? Is EOF a failure, or just a somewhat normal condition?

Also, it may not matter in the calling code (I did only a quick check) but maybe it would be better to set bp->b_error here, where the error really occurred, rather than in libxfs_readbuf().

Other than that, this change looks good to me.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs