Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
xfsprogs.21270
xfsprogs-xfs-introduce-inode-log-format-object....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xfsprogs-xfs-introduce-inode-log-format-object.patch of Package xfsprogs.21270
From 138659f139b51ffadc72deb8af356fbfdf745abe Mon Sep 17 00:00:00 2001 From: Dave Chinner <dchinner@redhat.com> Date: Wed, 17 Feb 2016 17:10:02 +1100 Subject: [PATCH] xfs: introduce inode log format object Git-commit: 138659f139b51ffadc72deb8af356fbfdf745abe Patch-mainline: v4.7.0-rc1 References: bsc#1171812 Source kernel commit f8d55aa0523ad0f78979c222ed18b78ea7be793a We currently carry around and log an entire inode core in the struct xfs_inode. A lot of the information in the inode core is duplicated in the VFS inode, but we cannot remove this duplication of infomration because the inode core is logged directly in xfs_inode_item_format(). Add a new function xfs_inode_item_format_core() that copies the inode core data into a struct xfs_icdinode that is pulled directly from the log vector buffer. This means we no longer directly copy the inode core, but copy the structures one member at a time. This will be slightly less efficient than copying, but will allow us to remove duplicate and unnecessary items from the struct xfs_inode. To enable us to do this, call the new structure a xfs_log_dinode, so that we know it's different to the physical xfs_dinode and the in-core xfs_icdinode. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com> Acked-by: Anthony Iliopoulos <ailiop@suse.com> --- db/check.c | 2 +- libxfs/util.c | 2 +- libxfs/xfs_inode_buf.c | 8 +++--- libxfs/xfs_inode_buf.h | 53 +++++++++++++++++++++++++++++++++++++++- libxfs/xfs_log_format.h | 15 ++++++------ logprint/log_misc.c | 7 +++--- logprint/log_print_all.c | 13 +++++----- repair/phase6.c | 8 +++--- repair/phase7.c | 2 +- 9 files changed, 82 insertions(+), 28 deletions(-) diff --git a/db/check.c b/db/check.c index 838db53f7572c6..d6d1d57a33668c 100644 --- a/db/check.c +++ b/db/check.c @@ -2619,7 +2619,7 @@ process_inode( { blkmap_t *blkmap; xfs_fsblock_t bno = 0; - xfs_icdinode_t idic; + struct xfs_icdinode idic; inodata_t *id = NULL; xfs_ino_t ino; xfs_extnum_t nextents = 0; diff --git a/libxfs/util.c b/libxfs/util.c index 4a72e894e2b73e..787fd5ddd61729 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -345,7 +345,7 @@ void libxfs_iprint( xfs_inode_t *ip) { - xfs_icdinode_t *dip; + struct xfs_icdinode *dip; xfs_bmbt_rec_host_t *ep; xfs_extnum_t i; xfs_extnum_t nextents; diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 89c05ad9476d19..dbea592ba1be03 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -205,8 +205,8 @@ xfs_imap_to_bp( void xfs_dinode_from_disk( - xfs_icdinode_t *to, - xfs_dinode_t *from) + struct xfs_icdinode *to, + struct xfs_dinode *from) { to->di_magic = be16_to_cpu(from->di_magic); to->di_mode = be16_to_cpu(from->di_mode); @@ -252,8 +252,8 @@ xfs_dinode_from_disk( void xfs_dinode_to_disk( - xfs_dinode_t *to, - xfs_icdinode_t *from) + struct xfs_dinode *to, + struct xfs_icdinode *from) { to->di_magic = cpu_to_be16(from->di_magic); to->di_mode = cpu_to_be16(from->di_mode); diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index 03f2a906c58c84..da66458fb80774 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -20,7 +20,58 @@ struct xfs_inode; struct xfs_dinode; -struct xfs_icdinode; + +/* + * In memory representation of the XFS inode. This is held in the in-core + * struct xfs_inode to represent the on disk values, but no longer needs to be + * identical to the on-disk structure as it is always translated to on-disk + * format specific structures at the appropriate time. + */ +struct xfs_icdinode { + __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ + __uint16_t di_mode; /* mode and type of file */ + __int8_t di_version; /* inode version */ + __int8_t di_format; /* format of di_c data */ + __uint16_t di_onlink; /* old number of links to file */ + __uint32_t di_uid; /* owner's user id */ + __uint32_t di_gid; /* owner's group id */ + __uint32_t di_nlink; /* number of links to file */ + __uint16_t di_projid_lo; /* lower part of owner's project id */ + __uint16_t di_projid_hi; /* higher part of owner's project id */ + __uint8_t di_pad[6]; /* unused, zeroed space */ + __uint16_t di_flushiter; /* incremented on flush */ + xfs_ictimestamp_t di_atime; /* time last accessed */ + xfs_ictimestamp_t di_mtime; /* time last modified */ + xfs_ictimestamp_t di_ctime; /* time created/inode modified */ + xfs_fsize_t di_size; /* number of bytes in file */ + xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ + xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ + xfs_extnum_t di_nextents; /* number of extents in data fork */ + xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ + __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ + __int8_t di_aformat; /* format of attr fork's data */ + __uint32_t di_dmevmask; /* DMIG event mask */ + __uint16_t di_dmstate; /* DMIG state info */ + __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ + __uint32_t di_gen; /* generation number */ + + /* di_next_unlinked is the only non-core field in the old dinode */ + xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */ + + /* start of the extended dinode, writable fields */ + __uint32_t di_crc; /* CRC of the inode */ + __uint64_t di_changecount; /* number of attribute changes */ + xfs_lsn_t di_lsn; /* flush sequence */ + __uint64_t di_flags2; /* more random flags */ + __uint8_t di_pad2[16]; /* more padding for future expansion */ + + /* fields only written to during inode creation */ + xfs_ictimestamp_t di_crtime; /* time created */ + xfs_ino_t di_ino; /* inode number */ + uuid_t di_uuid; /* UUID of the filesystem */ + + /* structure must be padded to 64 bit alignment */ +}; /* * Inode location information. Stored in the inode and passed to diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h index c8603459224cb8..85d47324dbf7ca 100644 --- a/libxfs/xfs_log_format.h +++ b/libxfs/xfs_log_format.h @@ -290,6 +290,7 @@ typedef struct xfs_inode_log_format_64 { __int32_t ilf_boffset; /* off of inode in buffer */ } xfs_inode_log_format_64_t; + /* * Flags for xfs_trans_log_inode flags field. */ @@ -360,10 +361,10 @@ typedef struct xfs_ictimestamp { } xfs_ictimestamp_t; /* - * NOTE: This structure must be kept identical to struct xfs_dinode - * except for the endianness annotations. + * Define the format of the inode core that is logged. This structure must be + * kept identical to struct xfs_dinode except for the endianness annotations. */ -typedef struct xfs_icdinode { +struct xfs_log_dinode { __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ __uint16_t di_mode; /* mode and type of file */ __int8_t di_version; /* inode version */ @@ -407,13 +408,13 @@ typedef struct xfs_icdinode { uuid_t di_uuid; /* UUID of the filesystem */ /* structure must be padded to 64 bit alignment */ -} xfs_icdinode_t; +}; -static inline uint xfs_icdinode_size(int version) +static inline uint xfs_log_dinode_size(int version) { if (version == 3) - return sizeof(struct xfs_icdinode); - return offsetof(struct xfs_icdinode, di_next_unlinked); + return sizeof(struct xfs_log_dinode); + return offsetof(struct xfs_log_dinode, di_next_unlinked); } /* diff --git a/logprint/log_misc.c b/logprint/log_misc.c index 7378fe114dcf9f..e6ee832cdf6e4b 100644 --- a/logprint/log_misc.c +++ b/logprint/log_misc.c @@ -588,7 +588,8 @@ xlog_print_trans_qoff(char **ptr, uint len) void -xlog_print_trans_inode_core(xfs_icdinode_t *ip) +xlog_print_trans_inode_core( + struct xfs_log_dinode *ip) { printf(_("INODE CORE\n")); printf(_("magic 0x%hx mode 0%ho version %d format %d\n"), @@ -652,7 +653,7 @@ xlog_print_trans_inode( int num_ops, int continued) { - xfs_icdinode_t dino; + struct xfs_log_dinode dino; xlog_op_header_t *op_head; xfs_inode_log_format_t dst_lbuf; xfs_inode_log_format_64_t src_lbuf; /* buffer of biggest one */ @@ -705,7 +706,7 @@ xlog_print_trans_inode( mode = dino.di_mode & S_IFMT; size = (int)dino.di_size; xlog_print_trans_inode_core(&dino); - *ptr += xfs_icdinode_size(dino.di_version); + *ptr += xfs_log_dinode_size(dino.di_version); if (*i == num_ops-1 && f->ilf_size == 3) { return 1; diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c index ba2640880d5323..1bc18af9ca8d77 100644 --- a/logprint/log_print_all.c +++ b/logprint/log_print_all.c @@ -250,7 +250,7 @@ xlog_recover_print_dquot( STATIC void xlog_recover_print_inode_core( - xfs_icdinode_t *di) + struct xfs_log_dinode *di) { printf(_(" CORE inode:\n")); if (!print_inode) @@ -259,8 +259,9 @@ xlog_recover_print_inode_core( "onlink:%d\n"), (di->di_magic>>8) & 0xff, di->di_magic & 0xff, di->di_mode, di->di_version, di->di_format, di->di_onlink); - printf(_(" uid:%d gid:%d nlink:%d projid:%u\n"), - di->di_uid, di->di_gid, di->di_nlink, xfs_get_projid(di)); + printf(_(" uid:%d gid:%d nlink:%d projid:0x%04x%04x\n"), + di->di_uid, di->di_gid, di->di_nlink, + di->di_projid_hi, di->di_projid_lo); printf(_(" atime:%d mtime:%d ctime:%d\n"), di->di_atime.t_sec, di->di_mtime.t_sec, di->di_ctime.t_sec); printf(_(" flushiter:%d\n"), di->di_flushiter); @@ -293,9 +294,9 @@ xlog_recover_print_inode( f->ilf_dsize); /* core inode comes 2nd */ - ASSERT(item->ri_buf[1].i_len == xfs_icdinode_size(1) || - item->ri_buf[1].i_len == xfs_icdinode_size(3)); - xlog_recover_print_inode_core((xfs_icdinode_t *) + ASSERT(item->ri_buf[1].i_len == xfs_log_dinode_size(2) || + item->ri_buf[1].i_len == xfs_log_dinode_size(3)); + xlog_recover_print_inode_core((struct xfs_log_dinode *) item->ri_buf[1].i_addr); hasdata = (f->ilf_fields & XFS_ILOG_DFORK) != 0; diff --git a/repair/phase6.c b/repair/phase6.c index eb36520691d904..3aa109de8c3aaa 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -507,8 +507,8 @@ mk_rbmino(xfs_mount_t *mp) error); } - vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1; - memset(&ip->i_d, 0, xfs_icdinode_size(vers)); + vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2; + memset(&ip->i_d, 0, sizeof(ip->i_d)); ip->i_d.di_magic = XFS_DINODE_MAGIC; ip->i_d.di_mode = S_IFREG; @@ -767,7 +767,7 @@ mk_rsumino(xfs_mount_t *mp) } vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1; - memset(&ip->i_d, 0, xfs_icdinode_size(vers)); + memset(&ip->i_d, 0, sizeof(ip->i_d)); ip->i_d.di_magic = XFS_DINODE_MAGIC; ip->i_d.di_mode = S_IFREG; @@ -882,7 +882,7 @@ mk_root_dir(xfs_mount_t *mp) * take care of the core -- initialization from xfs_ialloc() */ vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2; - memset(&ip->i_d, 0, xfs_icdinode_size(vers)); + memset(&ip->i_d, 0, sizeof(ip->i_d)); ip->i_d.di_magic = XFS_DINODE_MAGIC; ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR; diff --git a/repair/phase7.c b/repair/phase7.c index 640eaec87ad177..72a8adedf9eb1e 100644 --- a/repair/phase7.c +++ b/repair/phase7.c @@ -31,7 +31,7 @@ /* dinoc is a pointer to the IN-CORE dinode core */ static void set_nlinks( - xfs_icdinode_t *dinoc, + struct xfs_icdinode *dinoc, xfs_ino_t ino, __uint32_t nrefs, int *dirty) -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor