Skip to contentSkip to conversation

BUG REPORT: XFS LOG FORWARD COMPATIBILITY PROBLEM

DISCUSSION Lachlan McIlroy 3 participants 11 messages Jul 27, 2009 – Jul 30, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 362522677.1010811248671789619.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com

#1 lore raw
Quoted 9 lines · ----- "Eddy Zhao
Quoted 2 lines

I don't recommend you pull the usb disk out while the filesystem is

still

Quoted 2 lines

mounted (if you can avoid it).

Doing that to emulate power loss scenario our device might experience.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

I would start by looking through the change history for

fs/xfs/xfs_log_recover.c

Quoted 1 line

and paying particular attention to anything to do with inode

transactions.

Quoted 1 line

Not quite familiar with XFS code :(

We all start somewhere!

Quoted 15 lines
Quoted 3 lines

Or try some intermediate kernels and see if you can narrow the fix

down to a set of

Quoted 2 lines

changes.

I'll try to bisect (It will take some time...)

Quoted 6 lines
# mount /dev/sda1 /mnt/
UDF-fs: No VRS found
XFS mounting filesystem sda1
Starting XFS recovery on filesystem: sda1 (dev: sda1)
Filesystem "sda1": xfs_inode_recover: Bad inode magic number, dino
Quoted 7 lines

ptr

Quoted 1 line

= 0xc8266700, dino bp = 0xc8281b40, ino = 0

Because XFS log is OK to 2.6.28 system, which means the log is correct in itself.
Would it be easy for you to debug the problem by compare 2.6.10 log recovery code fail point and the corresponding 2.6.28 log record?

Easy? Not exactly. Diff'ing 2.6.10 version of fs/xfs/xfs_log_recover.c with mainline shows over 300 differences. If you really want to be able to replay the log on a different system it really has to be running the same version of XFS for there to be any chance of it working properly.

It should also be the same architecture too - is it possible you have a 32 bit kernel on the 2.6.10 system and a 64 bit kernel on the 2.6.28 system? If so then this fix might help

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6d192a9b82212abf1e0e89da6e3a952afba7e4d6

I think it went into 2.6.18.

Quoted 7 lines

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

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

#2 lore raw

Hello Lachlan:

Quoted 3 lines

We all start somewhere!

Yes. I'll start from this problem :)

Quoted 5 lines

It should also be the same architecture too - is it possible you have a 32 bit kernel on the 2.6.10 system and a 64 bit kernel on the 2.6.28 system? If so then this fix might help

The two systems are all 32bit.

Enlightened by your suggestion, I find problem lies in the two systems are different architecture. One is arm, on is x86. Use 2.6.10 on both system, XFS created on arm can't mount on x86, vice versa (dump stack at xlog_recover_process_data).

Use xfs_logprint to inspect log, tool exit with assertion failed:
"item->ri_buf[0].i_len == sizeof(xfs_inode_log_format_t)". Debug the assertion and find xfs_inode_log_format_t on arm is 56 byte, on x86 is 52 byte. Then find on 2.6.10 xfs_inode_log_format is not packed!! Fix this, fix the mount failed problem.

Grep the code and find a lot other log/metadata needs pack on 2.6.10. I find these
xfs_fid64
xfs_extent_32_t
xfs_efi_log_format_32_t
xfs_efd_log_format_32_t
xfs_inode_log_format_32_t
xfs_flock64_32
compat_xfs_fsop_geom_v1_t
compat_xfs_inogrp_t
xfs_dir2_sf_off_t
xfs_dir2_sf_hdr_t
xfs_dir2_sf_entry_t

Is there any other log/metadata needs pack on 2.6.10? Any other problem/caveat I need pay attention to while/besides fix pack bug?

Thanks
Eddy

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

#3 lore raw
Quoted 14 lines · Eddy Zhao

Hello Lachlan:

Quoted 3 lines

We all start somewhere!

Yes. I'll start from this problem :)

Quoted 5 lines

It should also be the same architecture too - is it possible you have a 32 bit kernel on the 2.6.10 system and a 64 bit kernel on the 2.6.28 system? If so then this fix might help

Quoted 6 lines

The two systems are all 32bit.

Enlightened by your suggestion, I find problem lies in the two systems are different architecture. One is arm, on is x86. Use 2.6.10 on both system, XFS created on arm can't mount on x86, vice versa (dump stack at xlog_recover_process_data).

Well, the fact that you have 2 arches would have been highly relevant in your first email. ;) Is this the old abi or the new? Guessing old, based on the alignment issues.

Quoted 20 lines

Use xfs_logprint to inspect log, tool exit with assertion failed:
"item->ri_buf[0].i_len == sizeof(xfs_inode_log_format_t)". Debug the assertion and find xfs_inode_log_format_t on arm is 56 byte, on x86 is 52 byte. Then find on 2.6.10 xfs_inode_log_format is not packed!! Fix this, fix the mount failed problem.

Grep the code and find a lot other log/metadata needs pack on 2.6.10. I find these
xfs_fid64
xfs_extent_32_t
xfs_efi_log_format_32_t
xfs_efd_log_format_32_t
xfs_inode_log_format_32_t
xfs_flock64_32
compat_xfs_fsop_geom_v1_t
compat_xfs_inogrp_t
xfs_dir2_sf_off_t
xfs_dir2_sf_hdr_t
xfs_dir2_sf_entry_t

Quoted 2 lines

Is there any other log/metadata needs pack on 2.6.10? Any other problem/caveat I need pay attention to while/besides fix pack bug?

Well, packing structures like mad is not a great solution[1] - it needs to be done carefully & judiciously. We don't want to pack structures that are already aligned on most arches, because this will cause performance issues.

But I see above you've found a few that were, for various reasons. Note that the dir2 types above use a funky "__arch_pack" to conditionally pack only on arm old abi:

/* ARM old ABI has some weird alignment/padding */ #if defined(__arm__) && !defined(__ARM_EABI__) #define __arch_pack __attribute__((packed)) #else
#define __arch_pack
#endif

When I looked around for structure size mismatches on arm old abi, I was only looking at on-disk structures for which were big-endian. Because the log is native-endian, I did not think to check the log structures.

To be honest, I am not certain that this is "worth fixing" - we already have the requirement that log replay can only be done on an architecture of the same endianness, and a further requirement that it can only be done on architectures with similar alignment rules doesn't seem so bad.
The problem is, if you go off and "fix" this on arm now, you'll find
that logs created under older arm kernels can't be replayed on newer arm kernels and vice versa...

-Eric

[1]
http://digitalvampire.org/blog/index.php/2006/07/31/why-you-shouldnt-use-__attribute__packed/

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

#4 lore raw

Hello Eric:

Quoted 5 lines

Well, the fact that you have 2 arches would have been highly relevant in your first email. ;) Is this the old abi or the new? Guessing old, based on the alignment issues.

ARM compiler is producing eabi. The problem lies in: "long long" on arm is 8 bytes aligned, on x86 is 4 bytes aligned. So 4 more bytes are padded before xfs_inode_log_format::ilf_ino on arm.

Quoted 6 lines

Well, packing structures like mad is not a great solution[1] - it needs to be done carefully & judiciously. We don't want to pack structures that are already aligned on most arches, because this will cause performance issues.

Interesting. Nice tip.

Quoted 5 lines

But I see above you've found a few that were, for various reasons. Note that the dir2 types above use a funky "__arch_pack" to conditionally pack only on arm old abi:

Get it. Thanks for the reminder.

Quoted 6 lines

To be honest, I am not certain that this is "worth fixing" - we already have the requirement that log replay can only be done on an architecture of the same endianness, and a further requirement that it can only be done on architectures with similar alignment rules doesn't seem so bad.

Where is the official description of such requirment? The requirment is not obvious to new XFS users, and they should be warned :)

Why is such requirment? For backward compatibility?

I think the requirment is bad. It inhibit user from exchanging data freely between systems, which is an obvious requirment for file system design.

Quoted 5 lines

The problem is, if you go off and "fix" this on arm now, you'll find that logs created under older arm kernels can't be replayed on newer arm kernels and vice versa...

Compared with the above restriction("requirment"), we can afford this :)

Do I miss any other log/metadata needs pack on 2.6.10?

Thanks
Eddy

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

#5 lore raw
Quoted 11 lines · Eddy Zhao

Hello Eric:

Quoted 5 lines

Well, the fact that you have 2 arches would have been highly relevant in your first email. ;) Is this the old abi or the new? Guessing old, based on the alignment issues.

ARM compiler is producing eabi. The problem lies in: "long long" on arm is 8 bytes aligned, on x86 is 4 bytes aligned. So 4 more bytes are padded before xfs_inode_log_format::ilf_ino on arm.

A tool that can be very helpful here is "pahole" found in the dwarves package:

# pahole -C xfs_inode_log_format xfs-arm-eabi.ko
struct xfs_inode_log_format {
	__uint16_t                 ilf_type;          /*     0     2 */
	__uint16_t                 ilf_size;          /*     2     2 */
	__uint32_t                 ilf_fields;        /*     4     4 */
	__uint16_t                 ilf_asize;         /*     8     2 */
	__uint16_t                 ilf_dsize;         /*    10     2 */
	/* XXX 4 bytes hole, try to pack */

	__uint64_t                 ilf_ino;           /*    16     8 */
	union {
		__uint32_t         ilfu_rdev;         /*           4 */
		uuid_t             ilfu_uuid;         /*          16 */
	} ilf_u;                                      /*    24    16 */
	__int64_t                  ilf_blkno;         /*    40     8 */
	__int32_t                  ilf_len;           /*    48     4 */
	__int32_t                  ilf_boffset;       /*    52     4 */

	/* size: 56, cachelines: 1, members: 10 */
	/* sum members: 52, holes: 1, sum holes: 4 */
	/* last cacheline: 56 bytes */
};

That was for an arm eabi xfs.ko from 2.6.25. Don't worry about the "try to pack" message; as long as holes match everywhere it's ok ;)

...

Quoted 8 lines
Quoted 5 lines

To be honest, I am not certain that this is "worth fixing" - we already have the requirement that log replay can only be done on an architecture of the same endianness, and a further requirement that it can only be done on architectures with similar alignment rules doesn't seem so bad.

Where is the official description of such requirment? The requirment is not obvious to new XFS users, and they should be warned :)

For the endian requirement ... not sure where it's doc'd to be honest. if you don't find it in Documentation/filesystems/xfs.txt feel free to send a patch ;)

Quoted 1 line

Why is such requirment? For backward compatibility?

The xfs log was done native-endian for performance reasons, I think.

Quoted 3 lines

I think the requirment is bad. It inhibit user from exchanging data freely between systems, which is an obvious requirment for file system design.

No, it just means that you have to cleanly unmount on one filesystem before you try to mount it on another different system.

Quoted 7 lines
Quoted 3 lines

The problem is, if you go off and "fix" this on arm now, you'll find that logs created under older arm kernels can't be replayed on newer arm kernels and vice versa...

Compared with the above restriction("requirment"), we can afford this :)

Do I miss any other log/metadata needs pack on 2.6.10?

I can't really speak to 2.6.10, I don't want to go back that far ;) I'm afraid you're on your own there.

So just to be clear, on 2.6.28, arm eabi logs replay fine on x86_64?

-Eric

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

#6 lore raw

Hello Eric:

Quoted 4 lines

A tool that can be very helpful here is "pahole" found in the dwarves package:

Nice tool.

Quoted 3 lines

So just to be clear, on 2.6.28, arm eabi logs replay fine on x86_64?

I don't have x86_64 machine at hand. Replay arm eabi log on ia32 machine "seems" success (mount "successfully" returns). Actually I guess that's because 2.6.28 XFS running on ia32 misinterprets unpacked xfs_inode_log_format produced by arm as xfs_inode_log_format_64. And there must be something silently goes wrong on disk after replaying the log. During fixing the problem, I find it is difficult to change the code to commit packed log item (restricted by xfs_log_iovec_t mechanism). If we could somehow change this piece of code to use packed structure. The endianess problem could be solved by add an byte-swap option to xfs_repair (like e2fsck "-s"). Then we solve the xfs-log-cant-migrate-between-archs problem.

Thanks
Eddy

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

#8 lore raw
In reply to Eddy Zhao
Quoted 2 lines

And there must be something silently goes wrong on disk after replaying

the log.

Quoted 1 line

Forget this. Nothing on disk will goes wrong even under the misinterpretation.

#9 lore raw
In reply to Eddy Zhao
Quoted 2 lines

Replay arm eabi log on ia32 machine "seems" success (mount "successfully"

returns). Actually I guess that's because 2.6.28 XFS running on ia32 misinterprets unpacked xfs_inode_log_format produced by arm as xfs_inode_log_format_64. And there must be something silently goes wrong on disk after replaying the log.

Quoted 1 line

Forget this. There's no misinterpretation. Should be

"Replay arm eabi log on ia32 machine success (mount successfully returns). 2.6.28 XFS running on ia32 interprets unpacked xfs_inode_log_format produced by arm as xfs_inode_log_format_64"

Sorry for patch myself repeatedly : )

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

#10 lore raw
In reply to Eddy Zhao

Eddy Zhao wrote:

...

Quoted 6 lines

During fixing the problem, I find it is difficult to change the code to commit packed log item (restricted by xfs_log_iovec_t mechanism). If we could somehow change this piece of code to use packed structure. The endianess problem could be solved by add an byte-swap option to xfs_repair (like e2fsck "-s"). Then we solve the xfs-log-cant-migrate-between-archs problem.

Well, to be honest, the restriction of a clean log when migrating an xfs filesystem between systems of differing endianness was design decision.
And xfs userspace can't replay any log, native endian or not. If it
could, then perhaps doing the swapping in userspace would be a migration option. If you're signing up to make xfs_repair replay logs, I'm sure we'd welcome the patch. :)

-Eric

Quoted 2 lines

Thanks
Eddy

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