Skip to content

Commit 6413a01

Browse files
committed
xfs: create bmbt update intent log items
Create bmbt update intent/done log items to record redo information in the log. Because we roll transactions multiple times for reflink operations, we also have to track the status of the metadata updates that will be recorded in the post-roll transactions in case we crash before committing the final transaction. This mechanism enables log recovery to finish what was already started. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 350a27a commit 6413a01

File tree

5 files changed

+546
-2
lines changed

5 files changed

+546
-2
lines changed

fs/xfs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ xfs-y += xfs_aops.o \
102102
# low-level transaction/log code
103103
xfs-y += xfs_log.o \
104104
xfs_log_cil.o \
105+
xfs_bmap_item.o \
105106
xfs_buf_item.o \
106107
xfs_extfree_item.o \
107108
xfs_icreate_item.o \

fs/xfs/libxfs/xfs_log_format.h

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ static inline uint xlog_get_cycle(char *ptr)
114114
#define XLOG_REG_TYPE_RUD_FORMAT 22
115115
#define XLOG_REG_TYPE_CUI_FORMAT 23
116116
#define XLOG_REG_TYPE_CUD_FORMAT 24
117-
#define XLOG_REG_TYPE_MAX 24
117+
#define XLOG_REG_TYPE_BUI_FORMAT 25
118+
#define XLOG_REG_TYPE_BUD_FORMAT 26
119+
#define XLOG_REG_TYPE_MAX 26
118120

119121
/*
120122
* Flags to log operation header
@@ -235,6 +237,8 @@ typedef struct xfs_trans_header {
235237
#define XFS_LI_RUD 0x1241
236238
#define XFS_LI_CUI 0x1242 /* refcount update intent */
237239
#define XFS_LI_CUD 0x1243
240+
#define XFS_LI_BUI 0x1244 /* bmbt update intent */
241+
#define XFS_LI_BUD 0x1245
238242

239243
#define XFS_LI_TYPE_DESC \
240244
{ XFS_LI_EFI, "XFS_LI_EFI" }, \
@@ -248,7 +252,9 @@ typedef struct xfs_trans_header {
248252
{ XFS_LI_RUI, "XFS_LI_RUI" }, \
249253
{ XFS_LI_RUD, "XFS_LI_RUD" }, \
250254
{ XFS_LI_CUI, "XFS_LI_CUI" }, \
251-
{ XFS_LI_CUD, "XFS_LI_CUD" }
255+
{ XFS_LI_CUD, "XFS_LI_CUD" }, \
256+
{ XFS_LI_BUI, "XFS_LI_BUI" }, \
257+
{ XFS_LI_BUD, "XFS_LI_BUD" }
252258

253259
/*
254260
* Inode Log Item Format definitions.
@@ -724,6 +730,54 @@ struct xfs_cud_log_format {
724730
__uint64_t cud_cui_id; /* id of corresponding cui */
725731
};
726732

733+
/*
734+
* BUI/BUD (inode block mapping) log format definitions
735+
*/
736+
737+
/* bmbt me_flags: upper bits are flags, lower byte is type code */
738+
/* Type codes are taken directly from enum xfs_bmap_intent_type. */
739+
#define XFS_BMAP_EXTENT_TYPE_MASK 0xFF
740+
741+
#define XFS_BMAP_EXTENT_ATTR_FORK (1U << 31)
742+
#define XFS_BMAP_EXTENT_UNWRITTEN (1U << 30)
743+
744+
#define XFS_BMAP_EXTENT_FLAGS (XFS_BMAP_EXTENT_TYPE_MASK | \
745+
XFS_BMAP_EXTENT_ATTR_FORK | \
746+
XFS_BMAP_EXTENT_UNWRITTEN)
747+
748+
/*
749+
* This is the structure used to lay out an bui log item in the
750+
* log. The bui_extents field is a variable size array whose
751+
* size is given by bui_nextents.
752+
*/
753+
struct xfs_bui_log_format {
754+
__uint16_t bui_type; /* bui log item type */
755+
__uint16_t bui_size; /* size of this item */
756+
__uint32_t bui_nextents; /* # extents to free */
757+
__uint64_t bui_id; /* bui identifier */
758+
struct xfs_map_extent bui_extents[]; /* array of extents to bmap */
759+
};
760+
761+
static inline size_t
762+
xfs_bui_log_format_sizeof(
763+
unsigned int nr)
764+
{
765+
return sizeof(struct xfs_bui_log_format) +
766+
nr * sizeof(struct xfs_map_extent);
767+
}
768+
769+
/*
770+
* This is the structure used to lay out an bud log item in the
771+
* log. The bud_extents array is a variable size array whose
772+
* size is given by bud_nextents;
773+
*/
774+
struct xfs_bud_log_format {
775+
__uint16_t bud_type; /* bud log item type */
776+
__uint16_t bud_size; /* size of this item */
777+
__uint32_t __pad;
778+
__uint64_t bud_bui_id; /* id of corresponding bui */
779+
};
780+
727781
/*
728782
* Dquot Log format definitions.
729783
*

0 commit comments

Comments
 (0)