#include <linux/hdreg.h>
#include <time.h>
#include <linux/fs.h>
+#include <uuid/uuid.h>
#include "f2fs_format.h"
/ f2fs_params.segs_per_sec);
super_block.segment_count_main = cpu_to_le32(
- le32_to_cpu(super_block.section_count) *
+ le32_to_cpu(super_block.section_count) *
f2fs_params.segs_per_sec);
if ((le32_to_cpu(super_block.segment_count_main) - 2) <
}
super_block.failure_safe_block_distance = 0;
- super_block.volume_serial_number = 0;
+ uuid_generate(super_block.uuid);
ASCIIToUNICODE(super_block.volume_name, f2fs_params.vol_label);
super_block.meta_ino = cpu_to_le32(2);
super_block.root_ino = cpu_to_le32(3);
- total_zones = ((le32_to_cpu(super_block.segment_count_main) - 1) /
+ total_zones = ((le32_to_cpu(super_block.segment_count_main) - 1) /
f2fs_params.segs_per_sec) /
f2fs_params.secs_per_zone;
if (total_zones <= 6) {
SET_SUM_TYPE((&sum->footer), SUM_TYPE_DATA);
sum->entries[0].nid = super_block.root_ino;
- sum->entries[0].bidx = 0;
+ sum->entries[0].ofs_in_node = 0;
cp_seg_blk_offset += blk_size_bytes;
if (writetodisk(f2fs_params.fd, sum, cp_seg_blk_offset,
#define F2FS_CP_BLOCK_SIZE (DEFAULT_SECTOR_SIZE * \
DEFAULT_SECTORS_PER_BLOCK)
+/*
+ * For further optimization on multi-head logs, on-disk layout supports maximum
+ * 16 logs by default. The number, 16, is expected to cover all the cases
+ * enoughly.
+*/
#define MAX_ACTIVE_LOGS 16
#define MAX_ACTIVE_NODE_LOGS 8
#define MAX_ACTIVE_DATA_LOGS 8
__le32 root_ino; /* Root directory inode number */
__le32 node_ino; /* node inode number */
__le32 meta_ino; /* meta inode number */
- __le32 volume_serial_number; /* VSN is optional field */
+ __u8 uuid[16]; /* 128-bit uuid for volume */
__le16 volume_name[512]; /* Volume Name */
__le32 extension_count;
__u8 extension_list[F2FS_MAX_EXTENSION][8]; /* extension array */
#define SIT_VBLOCK_MAP_SIZE 64
#define SIT_ENTRY_PER_BLOCK (PAGE_CACHE_SIZE / sizeof(struct f2fs_sit_entry))
+/*
+ * Note that f2fs_sit_entry->vblocks has the following bit-field information.
+ * [15:10] : allocation type such as CURSEG_XXXX_TYPE
+ * [9:0] : valid block count
+ */
struct f2fs_sit_entry {
__le16 vblocks;
__u8 valid_map[SIT_VBLOCK_MAP_SIZE];
struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK];
} __attribute__((packed));
+/**
+ * For segment summary
+ *
+ * NOTE : For initializing fields, you must use set_summary
+ *
+ * - If data page, nid represents dnode's nid
+ * - If node page, nid represents the node page's nid.
+ *
+ * The ofs_in_node is used by only data page. It represents offset
+ * from node's page's beginning to get a data block address.
+ * ex) data_blkaddr = (block_t)(nodepage_start_address + ofs_in_node)
+ */
struct f2fs_summary {
__le32 nid; /* parent node id */
union {
__u8 reserved[3];
struct {
__u8 version; /* node version number */
- __le16 bidx; /* block index in parent node */
+ __le16 ofs_in_node; /* block index in parent node */
} __attribute__((packed));
};
} __attribute__((packed));
/*
* For directory operations
*/
-#define F2FS_NAME_LEN 8 /* 256 Unicode */
-#define NR_DENTRY_IN_BLOCK 214 /* the number of dentry in a block */
-#define MAX_DIR_HASH_DEPTH 63 /* MAX level for dir lookup */
+/* One directory entry slot covers 8bytes-long file name */
+#define F2FS_NAME_LEN 8
+
+/* the number of dentry in a block */
+#define NR_DENTRY_IN_BLOCK 214
+
+/* MAX level for dir lookup */
+#define MAX_DIR_HASH_DEPTH 63
#define SIZE_OF_DIR_ENTRY 11 /* by byte */
#define SIZE_OF_DENTRY_BITMAP ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \