Skip to contentSkip to conversation

Introduced btrfs file-system with btrload command

PATCH RESEND Superseded Adnan Ali 2 participants 4 messages Mar 21, 2013 – Mar 28, 2013

Subsystems (4)

v1 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Adnan Ali

author
#0 lore raw

PATCH RESEND 1/1 Introduced btrfs file-system with btrload command

Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.

v9:     patch problem reworked.
v8:     patch problem reworked.
v5:     merged with master.
v4:     btrls command added.
---
 Makefile                   |    1 +
 common/Makefile            |    1 +
 common/cmd_btr.c           |   65 +++
 fs/btrfs/Makefile          |   51 ++
 fs/btrfs/btrfs.c           | 1336 ++++++++++++++++++++++++++++++++++++++++++++
 fs/fs.c                    |   10 +
 include/btrfs.h            |  416 ++++++++++++++
 include/config_fallbacks.h |    4 +
 include/crc.h              |    8 +
 include/fs.h               |    1 +
 lib/Makefile               |    1 +
 lib/crc32_c.c              |   40 ++
 12 files changed, 1934 insertions(+)
 create mode 100644 common/cmd_btr.c
 create mode 100644 fs/btrfs/Makefile
 create mode 100644 fs/btrfs/btrfs.c
 create mode 100644 include/btrfs.h
 create mode 100644 lib/crc32_c.c
Makefile +1 -0
index 55bd55c..bd7981d 100644
@@ -257,6 +257,7 @@ endif
 LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o
 LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
 LIBS-y += fs/libfs.o \
+	fs/btrfs/libbtrfs.o \
 	fs/cbfs/libcbfs.o \
 	fs/cramfs/libcramfs.o \
 	fs/ext4/libext4fs.o \
common/Makefile +1 -0
index 719fc23..d1fae56 100644
@@ -73,6 +73,7 @@ COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
 COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
 COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
 COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o
+COBJS-$(CONFIG_CMD_BTR) += cmd_btr.o
 COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
 COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
 COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
common/cmd_btr.c new file +65 -0

65 lines not on this page · raw message

fs/btrfs/Makefile new file +51 -0

51 lines not on this page · raw message

fs/btrfs/btrfs.c new file +1336 -0

1,336 lines not on this page · raw message

fs/fs.c +10 -0
index 6f5063c..b8c3603 100644
@@ -17,6 +17,7 @@
 #include <config.h>
 #include <common.h>
 #include <part.h>
+#include <btrfs.h>
 #include <ext4fs.h>
 #include <fat.h>
 #include <fs.h>
@@ -88,6 +89,15 @@ static struct fstype_info fstypes[] = {
 		.read = fs_read_sandbox,
 	},
 #endif
+#ifdef CONFIG_FS_BTR
+	{
+		.fstype = FS_TYPE_BTR,
+		.probe = btrfs_probe,
+		.close = btrfs_close,
+		.ls = btrfs_ls,
+		.read = btrfs_read_file,
+	},
+#endif
 	{
 		.fstype = FS_TYPE_ANY,
 		.probe = fs_probe_unsupported,
include/btrfs.h new file +416 -0

416 lines not on this page · raw message

include/config_fallbacks.h +4 -0
index bfb9680..28a0a66 100644
@@ -26,4 +26,8 @@
 #define CONFIG_EXT4_WRITE
 #endif
 
+#if defined(CONFIG_CMD_BTR) && !defined(CONFIG_FS_BTR)
+#define CONFIG_FS_BTR
+#endif
+
 #endif	/* __CONFIG_FALLBACKS_H */
include/crc.h +8 -0
index 10560c9..5e5b1f0 100644
@@ -97,4 +97,12 @@ cyg_ether_crc32_accumulate(uint32_t crc, unsigned char *s, int len);
 
 extern uint16_t cyg_crc16(unsigned char *s, int len);
 
+/* CRC init for btrfs file-system*/
+
+void crc32c_init(u32 *crc32c_table, u32 pol);
+
+/* CRC calculate for btrfs file-system*/
+
+u32 crc32c_cal(u32 crc, const char *data, size_t length, u32 *crc32c_table);
+
 #endif /* _SERVICES_CRC_CRC_H_ */
include/fs.h +1 -0
index b6d69e5..a8b97ea 100644
@@ -22,6 +22,7 @@
 #define FS_TYPE_FAT	1
 #define FS_TYPE_EXT	2
 #define FS_TYPE_SANDBOX	3
+#define FS_TYPE_BTR	4
 
 /*
  * Tell the fs layer which block device an partition to use for future
lib/Makefile +1 -0
index 86ca1a6..9518b72 100644
@@ -67,6 +67,7 @@ COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
 endif
 COBJS-y += crc32.o
+COBJS-y += crc32_c.o
 COBJS-y += ctype.o
 COBJS-y += div64.o
 COBJS-y += linux_string.o
lib/crc32_c.c new file +40 -0
new file mode 100644
index 0000000..b97c98a
@@ -0,0 +1,40 @@
+/*
+ * Copied from Linux kernel crypto/crc32c.c
+ * Copyright (c) 2004 Cisco Systems, Inc.
+ * Copyright (c) 2008 Herbert Xu <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+#include <linux/stat.h>
+#include <command.h>
+#include <asm/byteorder.h>
+#include <linux/compiler.h>
+#include <common.h>
+#include <config.h>
+
+u32 crc32c_cal(u32 crc, const char *data, size_t length, u32 *crc32c_table)
+{
+	while (length--)
+		crc = crc32c_table[(u8)(crc ^ *data++)] ^ (crc >> 8);
+
+	return crc;
+}
+
+void crc32c_init(u32 *crc32c_table, u32 pol)
+{
+	int i, j;
+	u32 v;
+	const u32 poly = pol; /* Bit-reflected CRC32C polynomial */
+
+	for (i = 0; i < 256; i++) {
+		v = i;
+		for (j = 0; j < 8; j++)
+			v = (v >> 1) ^ ((v & 1) ? poly : 0);
+
+		crc32c_table[i] = v;
+	}
+}
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH RESEND 1/1 Introduced btrfs file-system with btrload command

Quoted 6 lines · Adnan Ali

Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.

Quoted 6 lines
v9:     patch problem reworked.
v8:     patch problem reworked.
v5:     merged with master.
v4:     btrls command added.

First, this should be v10 not "RESEND". And that means the next version should be v11.

One of the rules of adding code to U-Boot is we don't add "dead" code that's not built somewhere. So you should be adding CONFIG_CMD_BTR somewhere like to say include/configs/sandbox.h (which has ext4/fat support, but can't yet use them).

Another rule is no adding code with compiler warning. This code has _a_lot_ of warnings. This is due in part to how you've ported the syslinux generic inode/fs_info structure over to U-Boot (as we need to spend some time here cleaning up our code, but I'm not asking you to do that). I started digging into fixing these warnings but then found your changes to btrfs_read_super_block() where you removed the syslinux check over all possible superblock areas. Why are we deviating here? Are there other deviations from syslinux in the driver itself? Thanks.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130328/68e6b208/attachment.pgp>
author
#2 lore raw

PATCH RESEND 1/1 Introduced btrfs file-system with btrload command

Quoted 8 lines · Tom Rini
Quoted 6 lines · Adnan Ali

Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.

Quoted 8 lines
Quoted 6 lines
v9:     patch problem reworked.
v8:     patch problem reworked.
v5:     merged with master.
v4:     btrls command added.

First, this should be v10 not "RESEND". And that means the next version should be v11.

ok

Quoted 5 lines

One of the rules of adding code to U-Boot is we don't add "dead" code that's not built somewhere. So you should be adding CONFIG_CMD_BTR somewhere like to say include/configs/sandbox.h (which has ext4/fat support, but can't yet use them).

You mean adding to one of the configs, I used include/configs/mx53loco
the reason i didn't added config file to patch as some one told not to
add config file as part of port. Is that what you mean.

Quoted 6 lines

Another rule is no adding code with compiler warning. This code has _a_lot_ of warnings. This is due in part to how you've ported the syslinux generic inode/fs_info structure over to U-Boot (as we need to spend some time here cleaning up our code, but I'm not asking you to do that). I started digging into fixing these warnings but then found your

Thanks if you are doing it.

Quoted 4 lines

changes to btrfs_read_super_block() where you removed the syslinux check over all possible superblock areas. Why are we deviating here? Are there other deviations from syslinux in the driver itself? Thanks.

The first super is the real one the rest of them are just mirrors
of the first . If you want it to be added i can do it.

#3 lore raw

PATCH RESEND 1/1 Introduced btrfs file-system with btrload command

Quoted 19 lines · Adnan Ali
Quoted 8 lines · Tom Rini
Quoted 6 lines · Adnan Ali

Introduces btrfs file-system to read file from volume/sub-volumes with btrload command. This implementation has read-only support.
This btrfs implementation is based on syslinux btrfs code, commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.

Quoted 8 lines
Quoted 6 lines
v9:     patch problem reworked.
v8:     patch problem reworked.
v5:     merged with master.
v4:     btrls command added.

First, this should be v10 not "RESEND". And that means the next version should be v11.

ok

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

One of the rules of adding code to U-Boot is we don't add "dead" code that's not built somewhere. So you should be adding CONFIG_CMD_BTR somewhere like to say include/configs/sandbox.h (which has ext4/fat support, but can't yet use them).

You mean adding to one of the configs, I used include/configs/mx53loco
the reason i didn't added config file to patch as some one told not to
add config file as part of port. Is that what you mean.

Yes, true. But that's what multi-part series are for. Patch 1, add the code, patch 2, enable it.

Quoted 6 lines
Quoted 5 lines

Another rule is no adding code with compiler warning. This code has _a_lot_ of warnings. This is due in part to how you've ported the syslinux generic inode/fs_info structure over to U-Boot (as we need to spend some time here cleaning up our code, but I'm not asking you to do that). I started digging into fixing these warnings but then found your

Thanks if you are doing it.

At some point after your patch and I'll clean up btrfs, yes.

Quoted 6 lines
Quoted 4 lines

changes to btrfs_read_super_block() where you removed the syslinux check over all possible superblock areas. Why are we deviating here? Are there other deviations from syslinux in the driver itself? Thanks.

The first super is the real one the rest of them are just mirrors
of the first . If you want it to be added i can do it.

Well, not exactly. If I follow both the code and comments, and my recollection of one of the btrfs talks, it's possible that the first superblock isn't the most recent one, hence checking them all so that we start off with the most recent one. So yes please, lets stay in sync.

But that's the only implementation deviation you made from the syslinux code? Thanks.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130328/b68892dd/attachment.pgp>