Skip to contentSkip to conversation

kernel BUG at /usr/src/sources/linux-2.6.16-rc5/fs/reiser4/plugin/file/tail_conversion.c:29

DISCUSSION Christian Trefzer 2 participants 10 messages Mar 15, 2006 – Mar 30, 2006

lore
Share & tools
lore
#0 lore raw

Hi everyone,

I got this half an hour ago, with some processes left in D state, namely ooffice.bin and two instances of procmail, as this happened on my /home LV:

kernel BUG at /usr/src/sources/linux-2.6.16-rc5/fs/reiser4/plugin/file/tail_conversion.c:29! invalid opcode: 0000 [#1]
PREEMPT

Modules linked in: mga drm w83781d hwmon_vid hwmon i2c_isa snd_seq_midi snd_pcm_oss snd_mixer_oss snd_seq_oss snd_seq_midi_event snd_seq snd_cmipci snd_opl3_lib snd_hwdep snd_mpu401_uart ohci_hcd floppy sr_mod cdrom pata_via i2c_viapro aic7xxx scsi_transport_spi ehci_hcd uhci_hcd 3c59x mii snd_ens1370 gameport snd_rawmidi snd_seq_device snd_pcm snd_timer snd_ak4531_codec snd soundcore snd_page_alloc via_agp agpgart usbcore xfs exportfs reiser4 ext2 loop lp parport_pc parport rtc psmouse reiserfs dm_mod raid5 raid1 xor md_mod pata_pdc2027x libata sd_mod scsi_mod unix
CPU:    0
EIP:    0060:[<f2daa02d>]    Not tainted VLI
EFLAGS: 00010286   (2.6.16-rc5 #10) 

EIP is at get_exclusive_access+0x31/0x44 [reiser4]
eax: b26d6c04 ebx: 00000000 ecx: ec54bbf4 edx: b736fdc0
esi: 3dbf3000 edi: 00006c85 ebp: 00006c85 esp: ded36f0c
ds: 007b es: 007b ss: 0068
Process soffice.bin (pid: 12533, threadinfo=ded36000 task=b3b7b070)

Stack: <0>f2da83da 00000000 c52ca544 e52935a8 00007000 b014c75f c52ca544 e7b3cc80 
b0151cd1 b6b54354 b6b5434c 3dbf3000 ed113360 e6a02160 b26d6bc0 ec54bc4c 
ec54bbf4 00000000 00006c85 00000001 00000000 ec54bc00 00000000 00006c85 
Call Trace:
[<f2da83da>] write_unix_file+0x1ba/0x60c [reiser4]
[<f2da8220>] write_unix_file+0x0/0x60c [reiser4]
[<b0101135>] syscall_call+0x7/0xb
Code: ff 21 e0 8b 00 8b 80 b0 04 00 00 8b 40 40 8b 50 08 85 d2 75 16 ba 01 00 ff ff 89 c8 0f c1 10 85 d2 75 12 c7 41 24 01 00 00 00 c3 <0f> 0b 1d 00 04 8c dc f2 eb e0 51 e8 13 ac 35 bd 59 eb e5 55 89 

I had another occurrence of something looking similar at first glance, repeatedly grinding my laptop to halt when I was on a trip. The only way to make it go away was to wipe the device by dd'ing /dev/zero to it. Not even tar-backup and mkfs did the job - otherwise I could have left out the word "repeatedly"...

The only thing I could imagine other than a serious problem wrt. reiser4 code is a "soft" bad block relocated by the drive upon write, but there was nothing like a read error in the logs. Furthermore I wanted the gurus to know since it occured to me more than once.

Thanks for your time!
Chris

FYI, here comes something about the disk, including SMART error log:

/dev/sda:

ATA device, with non-removable media

	Model Number:       SAMSUNG SV1203N                         
	Serial Number:      S01CJ10Y410901      
	Firmware Revision:  TQ100-30
Standards:
	Supported: 7 6 5 4 
	Likely used: 7
Configuration:
	Logical		max	current
	cylinders	16383	16383
	heads		16	16
	sectors/track	63	63
	--
	CHS current addressable sectors:   16514064
	LBA    user addressable sectors:  234493056
	LBA48  user addressable sectors:  234493056
	device size with M = 1024*1024:      114498 MBytes
	device size with M = 1000*1000:      120060 MBytes (120 GB)

Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 1
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
Recommended acoustic management value: 254, current value: 254
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=240ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* READ BUFFER cmd
* WRITE BUFFER cmd
* Host Protected Area feature set
* Look-ahead
* Write cache
* Power Management feature set
Security Mode feature set
* SMART feature set
* FLUSH CACHE EXT command
* Mandatory FLUSH CACHE command
* Device Configuration Overlay feature set
* 48-bit Address feature set
* Automatic Acoustic Management feature set
SET MAX security extension
* DOWNLOAD MICROCODE cmd
* SMART self-test
* SMART error logging
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
56min for SECURITY ERASE UNIT. 56min for ENHANCED SECURITY ERASE UNIT.
HW reset results:
CBLID- above Vih
Device num = 0 determined by the jumper
Checksum: correct

smartctl version 5.33 [i386-pc-linux-gnu] Copyright (C) 2002-4 Bruce Allen Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
ATA Error Count: 8 (device log contains only the most recent five errors)
CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 8 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
04 51 00 00 00 00 a0 Error: ABRT

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  b1 c0 00 00 00 00 a0 00      16:23:07.813  DEVICE CONFIGURATION RESTORE
  b1 c2 00 00 00 00 a0 00      16:23:07.813  DEVICE CONFIGURATION IDENTIFY
  9a 23 04 00 02 00 a0 00      16:23:07.813  [VENDOR SPECIFIC]
  9a 23 04 00 02 00 a0 00      16:23:07.750  [VENDOR SPECIFIC]
  9a 23 01 00 02 00 a0 00      16:23:07.750  [VENDOR SPECIFIC]

Error 7 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
02 51 3f 00 00 00 e0 Error: TK0NF

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  10 00 3f 00 00 00 e0 00      16:10:46.563  RECALIBRATE [OBS-4]
  91 00 3f 3f ff 3f e0 00      16:10:46.563  INITIALIZE DEVICE PARAMETERS [OBS-6]
  ef 03 45 01 00 00 a0 00      16:10:46.563  SET FEATURES [Set transfer mode]
  ef 03 0c 01 00 00 a0 00      16:10:46.563  SET FEATURES [Set transfer mode]
  ec 00 00 01 00 00 a0 00      16:10:45.813  IDENTIFY DEVICE

Error 6 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
02 51 00 00 00 00 e0 Error: TK0NF

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  10 00 00 00 00 00 e0 00      16:10:32.625  RECALIBRATE [OBS-4]
  00 00 01 01 00 00 a0 00      16:10:32.625  NOP [Abort queued commands]

Error 5 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
02 51 00 00 00 00 e0 Error: TK0NF

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  10 00 00 00 00 00 e0 00      16:10:32.063  RECALIBRATE [OBS-4]
  00 da 01 01 00 00 a0 00      16:10:32.063  NOP [Reserved subcommand]
  b0 da 10 01 4f c2 a0 00      16:10:25.688  SMART RETURN STATUS
  b0 d8 10 01 4f c2 a0 00      16:10:25.625  SMART ENABLE OPERATIONS
  c6 03 10 01 00 00 a0 00      16:10:25.625  SET MULTIPLE MODE

Error 4 occurred at disk power-on lifetime: 483 hours (20 days + 3 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
04 51 00 00 4f c2 e0 Error: ABRT

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  b0 da 00 00 4f c2 e0 00  21d+14:59:16.250  SMART RETURN STATUS
  ec 00 00 ac 87 e4 e0 00  21d+14:59:16.188  IDENTIFY DEVICE
  ef 82 00 00 00 00 e0 00  21d+14:47:39.438  SET FEATURES [Disable write cache]
  ef 02 00 00 00 00 e0 00  21d+14:44:35.625  SET FEATURES [Enable write cache]
  ef 42 fe 00 00 00 e0 00  21d+09:37:08.125  SET FEATURES [Enable AAM]
#1 lore raw

Hello,

please try the attached patch.

Quoted 234 lines · Christian Trefzer

Hi everyone,

I got this half an hour ago, with some processes left in D state, namely ooffice.bin and two instances of procmail, as this happened on my /home LV:

kernel BUG at /usr/src/sources/linux-2.6.16-rc5/fs/reiser4/plugin/file/tail_convers ion.c:29! invalid opcode: 0000 [#1]
PREEMPT

Modules linked in: mga drm w83781d hwmon_vid hwmon i2c_isa

snd_seq_midi snd_pcm_oss snd_mixer_oss snd_seq_oss snd_seq_midi_event snd_seq snd_cmipci snd_opl3_lib snd_hwdep snd_mpu401_uart ohci_hcd floppy sr_mod cdrom pata_via i2c_viapro aic7xxx scsi_transport_spi ehci_hcd uhci_hcd 3c59x mii snd_ens1370 gameport snd_rawmidi snd_seq_device snd_pcm snd_timer snd_ak4531_codec snd soundcore snd_page_alloc via_agp agpgart usbcore xfs exportfs reiser4 ext2 loop lp parport_pc parport rtc psmouse reiserfs dm_mod raid5 raid1 xor
md_mod pata_pdc2027x libata sd_mod scsi_mod unix CPU: 0

EIP:    0060:[<f2daa02d>]    Not tainted VLI
EFLAGS: 00010286   (2.6.16-rc5 #10)

EIP is at get_exclusive_access+0x31/0x44 [reiser4]
eax: b26d6c04 ebx: 00000000 ecx: ec54bbf4 edx: b736fdc0
esi: 3dbf3000 edi: 00006c85 ebp: 00006c85 esp: ded36f0c
ds: 007b es: 007b ss: 0068
Process soffice.bin (pid: 12533, threadinfo=ded36000 task=b3b7b070)

Stack: <0>f2da83da 00000000 c52ca544 e52935a8 00007000 b014c75f
c52ca544 e7b3cc80 b0151cd1 b6b54354 b6b5434c 3dbf3000 ed113360
e6a02160 b26d6bc0 ec54bc4c ec54bbf4 00000000 00006c85 00000001
00000000 ec54bc00 00000000 00006c85 Call Trace:
[<f2da83da>] write_unix_file+0x1ba/0x60c [reiser4]
[<f2da8220>] write_unix_file+0x0/0x60c [reiser4]
[<b0101135>] syscall_call+0x7/0xb
Code: ff 21 e0 8b 00 8b 80 b0 04 00 00 8b 40 40 8b 50 08 85 d2 75 16

ba 01 00 ff ff 89 c8 0f c1 10 85 d2 75 12 c7 41 24 01 00 00 00 c3 <0f> 0b 1d 00 04 8c dc f2 eb e0 51 e8 13 ac 35 bd 59 eb e5 55 89

I had another occurrence of something looking similar at first glance, repeatedly grinding my laptop to halt when I was on a trip. The only way to make it go away was to wipe the device by dd'ing /dev/zero to it. Not even tar-backup and mkfs did the job - otherwise I could have left out the word "repeatedly"...

The only thing I could imagine other than a serious problem wrt. reiser4 code is a "soft" bad block relocated by the drive upon write, but there was nothing like a read error in the logs. Furthermore I wanted the gurus to know since it occured to me more than once.

Thanks for your time!
Chris

FYI, here comes something about the disk, including SMART error log:

/dev/sda:

ATA device, with non-removable media

	Model Number:       SAMSUNG SV1203N
	Serial Number:      S01CJ10Y410901
	Firmware Revision:  TQ100-30
Standards:
	Supported: 7 6 5 4
	Likely used: 7
Configuration:
	Logical		max	current
	cylinders	16383	16383
	heads		16	16
	sectors/track	63	63
	--
	CHS current addressable sectors:   16514064
	LBA    user addressable sectors:  234493056
	LBA48  user addressable sectors:  234493056
	device size with M = 1024*1024:      114498 MBytes
	device size with M = 1000*1000:      120060 MBytes (120 GB)

Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 1
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
Recommended acoustic management value: 254, current value: 254
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=240ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* READ BUFFER cmd
* WRITE BUFFER cmd
* Host Protected Area feature set
* Look-ahead
* Write cache
* Power Management feature set
Security Mode feature set
* SMART feature set
* FLUSH CACHE EXT command
* Mandatory FLUSH CACHE command
* Device Configuration Overlay feature set
* 48-bit Address feature set
* Automatic Acoustic Management feature set
SET MAX security extension
* DOWNLOAD MICROCODE cmd
* SMART self-test
* SMART error logging
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
56min for SECURITY ERASE UNIT. 56min for ENHANCED SECURITY ERASE
UNIT. HW reset results:
CBLID- above Vih
Device num = 0 determined by the jumper
Checksum: correct

smartctl version 5.33 [i386-pc-linux-gnu] Copyright (C) 2002-4 Bruce Allen Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
ATA Error Count: 8 (device log contains only the most recent five errors) CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes, SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 8 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours) When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
04 51 00 00 00 00 a0 Error: ABRT

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  b1 c0 00 00 00 00 a0 00      16:23:07.813  DEVICE CONFIGURATION

RESTORE b1 c2 00 00 00 00 a0 00 16:23:07.813 DEVICE
CONFIGURATION IDENTIFY 9a 23 04 00 02 00 a0 00 16:23:07.813
[VENDOR SPECIFIC] 9a 23 04 00 02 00 a0 00 16:23:07.750 [VENDOR
SPECIFIC] 9a 23 01 00 02 00 a0 00 16:23:07.750 [VENDOR
SPECIFIC]

Error 7 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours) When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
02 51 3f 00 00 00 e0 Error: TK0NF

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  10 00 3f 00 00 00 e0 00      16:10:46.563  RECALIBRATE [OBS-4]
  91 00 3f 3f ff 3f e0 00      16:10:46.563  INITIALIZE DEVICE

PARAMETERS [OBS-6] ef 03 45 01 00 00 a0 00 16:10:46.563 SET
FEATURES [Set transfer mode] ef 03 0c 01 00 00 a0 00 16:10:46.563 SET FEATURES [Set transfer mode] ec 00 00 01 00 00 a0
00 16:10:45.813 IDENTIFY DEVICE

Error 6 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours) When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
02 51 00 00 00 00 e0 Error: TK0NF

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  10 00 00 00 00 00 e0 00      16:10:32.625  RECALIBRATE [OBS-4]
  00 00 01 01 00 00 a0 00      16:10:32.625  NOP [Abort queued

commands]

Error 5 occurred at disk power-on lifetime: 1595 hours (66 days + 11 hours) When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
02 51 00 00 00 00 e0 Error: TK0NF

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  10 00 00 00 00 00 e0 00      16:10:32.063  RECALIBRATE [OBS-4]
  00 da 01 01 00 00 a0 00      16:10:32.063  NOP [Reserved

subcommand] b0 da 10 01 4f c2 a0 00 16:10:25.688 SMART RETURN
STATUS b0 d8 10 01 4f c2 a0 00 16:10:25.625 SMART ENABLE
OPERATIONS c6 03 10 01 00 00 a0 00 16:10:25.625 SET MULTIPLE
MODE

Error 4 occurred at disk power-on lifetime: 483 hours (20 days + 3 hours) When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
04 51 00 00 4f c2 e0 Error: ABRT

Commands leading to the command that caused the error were:

  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  b0 da 00 00 4f c2 e0 00  21d+14:59:16.250  SMART RETURN STATUS
  ec 00 00 ac 87 e4 e0 00  21d+14:59:16.188  IDENTIFY DEVICE
  ef 82 00 00 00 00 e0 00  21d+14:47:39.438  SET FEATURES [Disable

write cache] ef 02 00 00 00 00 e0 00 21d+14:44:35.625 SET FEATURES [Enable write cache] ef 42 fe 00 00 00 e0 00 21d+09:37:08.125 SET FEATURES [Enable AAM]

Signature · 1 line
Alex.

From: Alexander Zarochentsev <[email protected]>

Have get_exclusive_access() restart transaction before taking r/w semaphore.

There are several places in write_unix_file and extent_balance_dirty_pages where transaction may be open before calling get_exclusive_access. It triggers the "deadlock detection" BUG_ON inside get_exclusive_access().

This patch fixes the bug by embedding txn_restart into the get_exclusive_access() code and cleanes up other places where txn_restart() was called right before get_eclusive_access().

Signed-off-by [email protected]
 fs/reiser4/plugin/file/file.c            |   13 -------------
 fs/reiser4/plugin/file/tail_conversion.c |    5 ++---
 2 files changed, 2 insertions(+), 16 deletions(-)
fs/reiser4/plugin/file/file.c +0 -13
Index: linux-2.6.16-rc4-mm2/fs/reiser4/plugin/file/file.c
===================================================================
@@ -1451,9 +1451,6 @@ static int commit_file_atoms(struct inod
 	int result;
 	unix_file_info_t *uf_info;
 
-	/* close current transaction */
-	txn_restart_current();
-
 	uf_info = unix_file_inode_data(inode);
 
 	/*
@@ -2174,7 +2171,6 @@ append_and_or_overwrite(hint_t * hint, s
 				done_lh(&hint->lh);
 				if (!exclusive) {
 					drop_nonexclusive_access(uf_info);
-					txn_restart_current();
 					get_exclusive_access(uf_info);
 				}
 				result = tail2extent(uf_info);
@@ -2964,15 +2960,6 @@ int delete_object_unix_file(struct inode
 	unix_file_info_t *uf_info;
 	int result;
 
-	/*
-	 * transaction can be open already. For example:
-	 * writeback_inodes->sync_sb_inodes->reiser4_sync_inodes->
-	 * generic_sync_sb_inodes->iput->generic_drop_inode->
-	 * generic_delete_inode->reiser4_delete_inode->delete_object_unix_file.
-	 * So, restart transaction to avoid deadlock with file rw semaphore.
-	 */
-	txn_restart_current();
-
 	if (inode_get_flag(inode, REISER4_NO_SD))
 		return 0;
 
fs/reiser4/plugin/file/tail_conversion.c +2 -3
Index: linux-2.6.16-rc4-mm2/fs/reiser4/plugin/file/tail_conversion.c
===================================================================
@@ -20,13 +20,12 @@ void get_exclusive_access(unix_file_info
 	assert("nikita-3047", LOCK_CNT_NIL(inode_sem_w));
 	assert("nikita-3048", LOCK_CNT_NIL(inode_sem_r));
 	/*
-	 * "deadlock detection": sometimes we commit a transaction under
+	 * "deadlock avoidance": sometimes we commit a transaction under
 	 * rw-semaphore on a file. Such commit can deadlock with another
 	 * thread that captured some block (hence preventing atom from being
 	 * committed) and waits on rw-semaphore.
 	 */
-	assert("nikita-3361", get_current_context()->trans->atom == NULL);
-	BUG_ON(get_current_context()->trans->atom != NULL);
+	txn_restart_current();
 	LOCK_CNT_INC(inode_sem_w);
 	down_write(&uf_info->latch);
 	uf_info->exclusive_use = 1;
#9 lore raw
In reply to Christian Trefzer

Hi again,

small update and clarification: I wiped the laptop's volume on which the problem occured, but my workstation's has _not yet_ been wiped. But:

kernel BUG at /usr/src/sources/linux-2.6.16-rc5/fs/reiser4/plugin/file/tail_conversion.c:29! invalid opcode: 0000 [#1]
PREEMPT

Modules linked in: mga drm usb_storage libusual w83781d hwmon_vid hwmon i2c_isa snd_seq_midi snd_pcm_oss snd_mixer_oss snd_seq_oss snd_seq_midi_event snd_seq snd_cmipci snd_opl3_lib snd_hwdep snd_mpu401_uart ohci_hcd floppy sr_mod cdrom pata_via i2c_viapro aic7xxx scsi_transport_spi ehci_hcd uhci_hcd 3c59x mii snd_ens1370 gameport snd_rawmidi snd_seq_device snd_pcm snd_timer snd_ak4531_codec snd soundcore snd_page_alloc via_agp agpgart usbcore xfs exportfs reiser4 ext2 loop lp parport_pc parport rtc psmouse reiserfs dm_mod raid5 raid1 xor md_mod pata_pdc2027x libata sd_mod scsi_mod unix
CPU:    0
EIP:    0060:[<f2daa02d>]    Not tainted VLI
EFLAGS: 00010282   (2.6.16-rc5 #10) 

EIP is at get_exclusive_access+0x31/0x44 [reiser4]
eax: bdb66604 ebx: 00000000 ecx: d44cd294 edx: d09041e0
esi: 3d762000 edi: 00006c85 ebp: 00006c85 esp: c33c9f0c
ds: 007b es: 007b ss: 0068
Process soffice.bin (pid: 687, threadinfo=c33c9000 task=cfc0da90)

Stack: <0>f2da83da 00000000 e6578e8c d2f12ee8 00007000 b014c75f e6578e8c b19e8900 
       b0151cd1 d025fda8 d025fd9c 3d762000 c1465440 b7c775c0 bdb665c0 d44cd2ec 
       d44cd294 00000000 00006c85 00000001 00000000 d44cd2a0 00000000 00006c85 
Call Trace:
 [<f2da83da>] write_unix_file+0x1ba/0x60c [reiser4]
 [<f2da8220>] write_unix_file+0x0/0x60c [reiser4]
 [<b0101135>] syscall_call+0x7/0xb
Code: ff 21 e0 8b 00 8b 80 b0 04 00 00 8b 40 40 8b 50 08 85 d2 75 16 ba 01 00 ff ff 89 c8 0f c1 10 85 d2 75 12 c7 41 24 01 00 00 00 c3 <0f> 0b 1d 00 04 8c dc f2 eb e0 51 e8 13 ac 35 bd 59 eb e5 55 89 
 <6>lp0: ECP mode

This is what I got with the laptop's disk in a USB case and the home volume from there mounted as /home. Processes stuck in D state were all trying to write to /home. I have to mention that the volume on the laptop disk which had problems before was _not_ home, so this is not a repetition of something I've seen before. Basically, I have now reset my sysctl values regarding the vm subsystem to the default values and will try to reproduce.

Workstation has 1GB of RAM and is trying to build OOo2 from source at the time, but writing the build tree to a totally different volume. The build process also is not interrupted by this BUG.

Thanks,

Chris

#2 lore raw
In reply to Alexander Zarochentsev

Hi Alexander,

Quoted 1 line · Alexander Zarochentsev

please try the attached patch.

Wow, that was FAST!

Will do ASAP, but for now I'll have to _hurry_ to work. I'll build a kernel with your patch right when I come back.

Thanks a bunch!

Chris

#3 lore raw
In reply to Alexander Zarochentsev

Hi zam,

after the first build of OOo has finished (as "gift" for my laptop) the machine is working on it's own copy, after a reboot with the exact same setup yielding my BUG problems plus your patch applied. I'll keep an eye on my syslog. Sorry for taking so long!

Regards,
Chris

#4 lore raw

Hello,

Quoted 6 lines · Christian Trefzer

Hi zam,

after the first build of OOo has finished (as "gift" for my laptop) the machine is working on it's own copy, after a reboot with the exact same setup yielding my BUG problems plus your patch applied. I'll keep an eye on my syslog. Sorry for taking so long!

I guess it was in release_unix_file where get_exclusive_access is called outside reiser4_context.

can you please replace the old patch by the attached one?

Quoted 3 lines

Regards,
Chris

Signature · 1 line
Alex.

From: Alexander Zarochentsev <[email protected]>

Have get_exclusive_access() restart transaction before taking r/w semaphore.

There are several places in write_unix_file and extent_balance_dirty_pages where transaction may be open before calling get_exclusive_access. It triggers the "deadlock detection" BUG_ON inside get_exclusive_access().

This patch fixes the bug by embedding txn_restart into the get_exclusive_access() code and cleanes up other places where txn_restart() was called right before get_eclusive_access().

Signed-off-by [email protected]
 fs/reiser4/plugin/file/file.c            |   13 -------------
 fs/reiser4/plugin/file/tail_conversion.c |    8 +++++---
 2 files changed, 5 insertions(+), 16 deletions(-)
fs/reiser4/plugin/file/file.c +0 -13
Index: linux-2.6.16-rc5-mm2/fs/reiser4/plugin/file/file.c
===================================================================
@@ -1451,9 +1451,6 @@ static int commit_file_atoms(struct inod
 	int result;
 	unix_file_info_t *uf_info;
 
-	/* close current transaction */
-	txn_restart_current();
-
 	uf_info = unix_file_inode_data(inode);
 
 	/*
@@ -2174,7 +2171,6 @@ append_and_or_overwrite(hint_t * hint, s
 				done_lh(&hint->lh);
 				if (!exclusive) {
 					drop_nonexclusive_access(uf_info);
-					txn_restart_current();
 					get_exclusive_access(uf_info);
 				}
 				result = tail2extent(uf_info);
@@ -2964,15 +2960,6 @@ int delete_object_unix_file(struct inode
 	unix_file_info_t *uf_info;
 	int result;
 
-	/*
-	 * transaction can be open already. For example:
-	 * writeback_inodes->sync_sb_inodes->reiser4_sync_inodes->
-	 * generic_sync_sb_inodes->iput->generic_drop_inode->
-	 * generic_delete_inode->reiser4_delete_inode->delete_object_unix_file.
-	 * So, restart transaction to avoid deadlock with file rw semaphore.
-	 */
-	txn_restart_current();
-
 	if (inode_get_flag(inode, REISER4_NO_SD))
 		return 0;
 
fs/reiser4/plugin/file/tail_conversion.c +5 -3
Index: linux-2.6.16-rc5-mm2/fs/reiser4/plugin/file/tail_conversion.c
===================================================================
@@ -16,17 +16,19 @@
 /* exclusive access to a file is acquired when file state changes: tail2extent, empty2tail, extent2tail, etc */
 void get_exclusive_access(unix_file_info_t * uf_info)
 {
+	reiser4_context * ctx = get_current_context_check();
+
 	assert("nikita-3028", schedulable());
 	assert("nikita-3047", LOCK_CNT_NIL(inode_sem_w));
 	assert("nikita-3048", LOCK_CNT_NIL(inode_sem_r));
 	/*
-	 * "deadlock detection": sometimes we commit a transaction under
+	 * "deadlock avoidance": sometimes we commit a transaction under
 	 * rw-semaphore on a file. Such commit can deadlock with another
 	 * thread that captured some block (hence preventing atom from being
 	 * committed) and waits on rw-semaphore.
 	 */
-	assert("nikita-3361", get_current_context()->trans->atom == NULL);
-	BUG_ON(get_current_context()->trans->atom != NULL);
+	if (ctx != NULL)
+		txn_restart(ctx);
 	LOCK_CNT_INC(inode_sem_w);
 	down_write(&uf_info->latch);
 	uf_info->exclusive_use = 1;
#5 lore raw

Hi zam,

Quoted 5 lines · Alexander Zarochentsev

I guess it was in release_unix_file where get_exclusive_access is called outside reiser4_context.

can you please replace the old patch by the attached one?

Sure I can, but so far I did not have any further trouble after applying your first patch. It seems to me that exchanging the two patches won't bring the BUG back, so I will report in a few days with something along the lines of "thank you very much". You will, on the other hand, definitely hear from me if the thing BUGs on me again ; )

Thanks for your time!

Chris

#6 lore raw
Quoted 3 lines · Christian Trefzer

Hi zam,

On Thu, Mar 16, 2006 at 10:28:37AM +0300, Alexander Zarochentsev

Quoted 7 lines · wrote:
Quoted 4 lines

I guess it was in release_unix_file where get_exclusive_access is called outside reiser4_context.

can you please replace the old patch by the attached one?

Sure I can, but so far I did not have any further trouble after applying your first patch.

Thanks.

I looked one more time at my second patch and realized now that is it not needed, it solves problem which can't happen. I was thinking too much trying to invent a situation where the first patch fails :)

Quoted 8 lines

It seems to me that exchanging the two
patches won't bring the BUG back, so I will report in a few days with something along the lines of "thank you very much". You will, on the other hand, definitely hear from me if the thing BUGs on me again ; )

Thanks for your time!

Chris

Signature · 1 line
Alex.
#7 lore raw
Quoted 3 lines · Alexander Zarochentsev

I looked one more time at my second patch and realized now that is it not needed, it solves problem which can't happen. I was thinking too much trying to invent a situation where the first patch fails :)

Well, so I'll leave the first one applied instead, presuming that this is the one you will merge into "mainstream" reiser4 code?

Thanks,
Chris

#8 lore raw
In reply to Alexander Zarochentsev

Hi zam,

Quoted 8 lines · Alexander Zarochentsev

Hello,

please try the attached patch.

Signature · 3 lines
Alex.

[ skipped life-saving patch ]

I just checked my currently used reiser4 version against reiser4-for-2.6.16-1 and noticed that this patch was not in there. The diff between my copy (2.6.16-rc4-mm2 with your patch on top) and status quo follows:

fs/reiser4/as_ops.c +1 -1
diff -urN a/fs/reiser4/as_ops.c b/fs/reiser4/as_ops.c
@@ -222,7 +222,7 @@
 
 	ctx = init_context(inode->i_sb);
 	if (IS_ERR(ctx))
-		return PTR_ERR(ctx);
+		return RETERR(PTR_ERR(ctx));
 
 	node = jprivate(page);
 	spin_lock_jnode(node);
fs/reiser4/page_cache.c +0 -4
diff -urN a/fs/reiser4/page_cache.c b/fs/reiser4/page_cache.c
@@ -198,10 +198,6 @@
 {
 	assert("nikita-2168", fake->i_state & I_NEW);
 	fake->i_mapping->a_ops = &formatted_fake_as_ops;
-	fake->i_blkbits = super->s_blocksize_bits;
-	fake->i_size = ~0ull;
-	fake->i_rdev = super->s_bdev->bd_dev;
-	fake->i_bdev = super->s_bdev;
 	*pfake = fake;
 	/* NOTE-NIKITA something else? */
 	unlock_new_inode(fake);
fs/reiser4/plugin/file/file.c +13 -0
diff -urN a/fs/reiser4/plugin/file/file.c b/fs/reiser4/plugin/file/file.c
@@ -1451,6 +1451,9 @@
 	int result;
 	unix_file_info_t *uf_info;
 
+	/* close current transaction */
+	txn_restart_current();
+
 	uf_info = unix_file_inode_data(inode);
 
 	/*
@@ -2171,6 +2174,7 @@
 				done_lh(&hint->lh);
 				if (!exclusive) {
 					drop_nonexclusive_access(uf_info);
+					txn_restart_current();
 					get_exclusive_access(uf_info);
 				}
 				result = tail2extent(uf_info);
@@ -2960,6 +2964,15 @@
 	unix_file_info_t *uf_info;
 	int result;
 
+	/*
+	 * transaction can be open already. For example:
+	 * writeback_inodes->sync_sb_inodes->reiser4_sync_inodes->
+	 * generic_sync_sb_inodes->iput->generic_drop_inode->
+	 * generic_delete_inode->reiser4_delete_inode->delete_object_unix_file.
+	 * So, restart transaction to avoid deadlock with file rw semaphore.
+	 */
+	txn_restart_current();
+
 	if (inode_get_flag(inode, REISER4_NO_SD))
 		return 0;
 
fs/reiser4/plugin/file/tail_conversion.c +3 -2
diff -urN a/fs/reiser4/plugin/file/tail_conversion.c b/fs/reiser4/plugin/file/tail_conversion.c
@@ -20,12 +20,13 @@
 	assert("nikita-3047", LOCK_CNT_NIL(inode_sem_w));
 	assert("nikita-3048", LOCK_CNT_NIL(inode_sem_r));
 	/*
-	 * "deadlock avoidance": sometimes we commit a transaction under
+	 * "deadlock detection": sometimes we commit a transaction under
 	 * rw-semaphore on a file. Such commit can deadlock with another
 	 * thread that captured some block (hence preventing atom from being
 	 * committed) and waits on rw-semaphore.
 	 */
-	txn_restart_current();
+	assert("nikita-3361", get_current_context()->trans->atom == NULL);
+	BUG_ON(get_current_context()->trans->atom != NULL);
 	LOCK_CNT_INC(inode_sem_w);
 	down_write(&uf_info->latch);
 	uf_info->exclusive_use = 1;

This would basically revert your patch once applied to my local copy, and make some other tiny changes. Will those take care of the problem, or was your solution lost somehow?

The diff between reiser4-for-2.6.16-1 with your patch applied and my copy looks like this:

fs/reiser4/as_ops.c +1 -1
diff -urN a/fs/reiser4/as_ops.c b/fs/reiser4/as_ops.c
@@ -222,7 +222,7 @@
 
 	ctx = init_context(inode->i_sb);
 	if (IS_ERR(ctx))
-		return PTR_ERR(ctx);
+		return RETERR(PTR_ERR(ctx));
 
 	node = jprivate(page);
 	spin_lock_jnode(node);
fs/reiser4/page_cache.c +0 -4
diff -urN a/fs/reiser4/page_cache.c b/fs/reiser4/page_cache.c
@@ -198,10 +198,6 @@
 {
 	assert("nikita-2168", fake->i_state & I_NEW);
 	fake->i_mapping->a_ops = &formatted_fake_as_ops;
-	fake->i_blkbits = super->s_blocksize_bits;
-	fake->i_size = ~0ull;
-	fake->i_rdev = super->s_bdev->bd_dev;
-	fake->i_bdev = super->s_bdev;
 	*pfake = fake;
 	/* NOTE-NIKITA something else? */
 	unlock_new_inode(fake);

Is that supposed to do the job of avoiding the trouble I had?

Kind regards,

Chris (currently wondering which codebase to test-drive the hell out without volumes going that way)