dinode endianess annotations
PATCH 1/1 dinode endianess annotations
Biggest bit is duplicating the dinode structure so we have one annoted for native endianess and one for disk endinaess. The other significant change is that xfs_xlate_dinode_core is split into one helper per direction to allow for proper annotations, everything else is trivial.
As a sidenode splitting out the incore dinode means we can move it into xfs_inode.h in a later patch and severly improving on the include hell in xfs.
fs/xfs/dmapi/xfs_dm.c +28 -28
@@ -347,7 +347,7 @@ STATIC uintxfs_ip2dmflags ( xfs_inode_t *ip) { -xfs_dinode_core_t *dic = &ip->i_d; +xfs_dinode_incore_t *dic = &ip->i_d;return _xfs_dic2dmflags (dic->di_flags) | (XFS_CFORK_Q (dic) ?DM_XFLAG_HASATTR :0 );
@@ -357,7 +357,7 @@ STATIC uintxfs_dic2dmflags ( xfs_dinode_core_t *dic) { -return _xfs_dic2dmflags (INT_GET (dic->di_flags,ARCH_CONVERT )) | +return _xfs_dic2dmflags (be16_to_cpu (dic->di_flags)) | (XFS_CFORK_Q_DISK (dic) ?DM_XFLAG_HASATTR :0 ); }
@@ -387,32 +387,33 @@ xfs_dip_to_stat(* the new format. We don't change the version number so that we * can distinguish this from a real new format inode. */ -if (INT_GET (dic->di_version,ARCH_CONVERT ) ==XFS_DINODE_VERSION_1 ) { - buf->dt_nlink =INT_GET (dic->di_onlink,ARCH_CONVERT ); +if (dic->di_version ==XFS_DINODE_VERSION_1 ) { + buf->dt_nlink =be16_to_cpu (dic->di_onlink);/*buf->dt_xfs_projid = 0;*/ }else { - buf->dt_nlink =INT_GET (dic->di_nlink,ARCH_CONVERT ); -/*buf->dt_xfs_projid = INT_GET(dic->di_projid, ARCH_CONVERT);*/ + buf->dt_nlink =be32_to_cpu (dic->di_nlink); +/*buf->dt_xfs_projid = be16_to_cpu(dic->di_projid);*/ } buf->dt_ino = ino; buf->dt_dev =XFS_TO_HOST_DEVT (mp); - buf->dt_mode =INT_GET (dic->di_mode,ARCH_CONVERT ); - buf->dt_uid =INT_GET (dic->di_uid,ARCH_CONVERT ); - buf->dt_gid =INT_GET (dic->di_gid,ARCH_CONVERT ); - buf->dt_size =INT_GET (dic->di_size,ARCH_CONVERT ); - buf->dt_atime =INT_GET (dic->di_atime.t_sec,ARCH_CONVERT ); - buf->dt_mtime =INT_GET (dic->di_mtime.t_sec,ARCH_CONVERT ); - buf->dt_ctime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); + buf->dt_mode =be16_to_cpu (dic->di_mode); + buf->dt_uid =be32_to_cpu (dic->di_uid); + buf->dt_gid =be32_to_cpu (dic->di_gid); + buf->dt_size =be64_to_cpu (dic->di_size); + buf->dt_atime =be32_to_cpu (dic->di_atime.t_sec); + buf->dt_mtime =be32_to_cpu (dic->di_mtime.t_sec); + buf->dt_ctime =be32_to_cpu (dic->di_ctime.t_sec); buf->dt_xfs_xflags =xfs_dic2dmflags (dic); - buf->dt_xfs_extsize =INT_GET (dic->di_extsize,ARCH_CONVERT ) << mp->m_sb.sb_blocklog; - buf->dt_xfs_extents =INT_GET (dic->di_nextents,ARCH_CONVERT ); - buf->dt_xfs_aextents =INT_GET (dic->di_anextents,ARCH_CONVERT ); - buf->dt_xfs_igen =INT_GET (dic->di_gen,ARCH_CONVERT ); - buf->dt_xfs_dmstate =INT_GET (dic->di_dmstate,ARCH_CONVERT ); + buf->dt_xfs_extsize = +be32_to_cpu (dic->di_extsize) << mp->m_sb.sb_blocklog; + buf->dt_xfs_extents =be32_to_cpu (dic->di_nextents); + buf->dt_xfs_aextents =be16_to_cpu (dic->di_anextents); + buf->dt_xfs_igen =be32_to_cpu (dic->di_gen); + buf->dt_xfs_dmstate =be16_to_cpu (dic->di_dmstate); -switch (INT_GET (dic->di_format,ARCH_CONVERT )) { +switch (dic->di_format) {case XFS_DINODE_FMT_DEV : - buf->dt_rdev =INT_GET (dip->di_u.di_dev,ARCH_CONVERT ); + buf->dt_rdev =be32_to_cpu (dip->di_u.di_dev); buf->dt_blksize =BLKDEV_IOSIZE ; buf->dt_blocks =0 ;break ;
@@ -426,8 +427,8 @@ xfs_dip_to_stat(case XFS_DINODE_FMT_BTREE : buf->dt_rdev =0 ; buf->dt_blksize = mp->m_sb.sb_blocksize; - buf->dt_blocks =XFS_FSB_TO_BB (mp, -INT_GET (dic->di_nblocks,ARCH_CONVERT )); + buf->dt_blocks = +XFS_FSB_TO_BB (mp,be64_to_cpu (dic->di_nblocks));break ; }
@@ -439,8 +440,8 @@ xfs_dip_to_stat( buf->dt_pers =0 ; buf->dt_change =0 ; buf->dt_nevents =DM_EVENT_MAX ; - buf->dt_emask =INT_GET (dic->di_dmevmask,ARCH_CONVERT ); - buf->dt_dtime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); + buf->dt_emask =be32_to_cpu (dic->di_dmevmask); + buf->dt_dtime =be32_to_cpu (dic->di_ctime.t_sec);/* Set if one of READ, WRITE or TRUNCATE bits is set in emask */ buf->dt_pmanreg = (DMEV_ISSET(DM_EVENT_READ, buf->dt_emask) || DMEV_ISSET(DM_EVENT_WRITE, buf->dt_emask) ||
@@ -458,7 +459,7 @@ xfs_ip_to_stat( xfs_inode_t *ip, dm_stat_t *buf) { -xfs_dinode_core_t *dic = &ip->i_d; +xfs_dinode_incore_t *dic = &ip->i_d;bhv_vnode_t *vp =XFS_ITOV (ip); buf->dt_ino = ino;
@@ -604,8 +605,7 @@ xfs_dm_inline_attr( caddr_t attr_buf, int *value_lenp) { -if (INT_GET (dip->di_core.di_aformat,ARCH_CONVERT ) == -XFS_DINODE_FMT_LOCAL ) { +if (dip->di_core.di_aformat ==XFS_DINODE_FMT_LOCAL ) {xfs_attr_shortform_t *sf;xfs_attr_sf_entry_t *sfe;unsigned int namelen =strlen (attr_name);
@@ -649,7 +649,7 @@ dm_dip_to_handle( xfid->fid_len =sizeof (xfs_fid2_t) -sizeof (xfid->fid_len); xfid->fid_pad =0 ; xfid->fid_ino = ino; - xfid->fid_gen =INT_GET (dip->di_core.di_gen,ARCH_CONVERT ); + xfid->fid_gen =be32_to_cpu (dip->di_core.di_gen);memcpy (&handlep->ha_fsid, fsid,sizeof (*fsid));memcpy (&handlep->ha_fid, &fid, fid.dm_fid_len +sizeof (fid.dm_fid_len));
fs/xfs/xfs_dinode.h +51 -14
111 lines not on this page · raw message
fs/xfs/xfs_ialloc.c +3 -3
@@ -293,9 +293,9 @@ xfs_ialloc_ag_alloc(xfs_biozero (fbuf,0 , ninodes << args.mp->m_sb.sb_inodelog);for (i =0 ; i < ninodes; i++) { free =XFS_MAKE_IPTR (args.mp, fbuf, i); -INT_SET (free->di_core.di_magic,ARCH_CONVERT ,XFS_DINODE_MAGIC ); -INT_SET (free->di_core.di_version,ARCH_CONVERT , version); -INT_SET (free->di_next_unlinked,ARCH_CONVERT ,NULLAGINO ); + free->di_core.di_magic =cpu_to_be16 (XFS_DINODE_MAGIC ); + free->di_core.di_version = version; + free->di_next_unlinked =cpu_to_be32 (NULLAGINO );xfs_ialloc_log_di (tp, fbuf, i,XFS_DI_CORE_BITS |XFS_DI_NEXT_UNLINKED ); }
fs/xfs/xfs_inode.c +107 -106
394 lines not on this page · raw message
fs/xfs/xfs_itable.c +27 -28
94 lines not on this page · raw message
fs/xfs/xfs_log_recover.c +11 -14
@@ -2245,7 +2245,7 @@ xlog_recover_do_inode_trans(int error;int attr_index;uint fields; -xfs_dinode_core_t *dicp; +xfs_dinode_incore_t *dicp;int need_free =0 ;if (pass ==XLOG_RECOVER_PASS1 ) {
@@ -2309,7 +2309,7 @@ xlog_recover_do_inode_trans(* Make sure the place we're flushing out to really looks * like an inode! */ -if (unlikely (INT_GET (dip->di_core.di_magic,ARCH_CONVERT ) !=XFS_DINODE_MAGIC )) { +if (unlikely (be16_to_cpu (dip->di_core.di_magic) !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp, "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld",
@@ -2319,7 +2319,7 @@ xlog_recover_do_inode_trans( error =EFSCORRUPTED ; goto error; } - dicp = (xfs_dinode_core_t *)(item->ri_buf[1 ].i_addr); + dicp = (xfs_dinode_incore_t *)(item->ri_buf[1 ].i_addr);if (unlikely (dicp->di_magic !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp,
@@ -2332,15 +2332,13 @@ xlog_recover_do_inode_trans( }/* Skip replay when the on disk inode is newer than the log one */ -if (dicp->di_flushiter < -INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT )) { +if (dicp->di_flushiter <be16_to_cpu (dip->di_core.di_flushiter)) {/* * Deal with the wrap case, DI_MAX_FLUSH is less * than smaller numbers */ -if ((INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT ) - ==DI_MAX_FLUSH ) && - (dicp->di_flushiter < (DI_MAX_FLUSH >>1 ))) { +if (be16_to_cpu (dip->di_core.di_flushiter) ==DI_MAX_FLUSH && + dicp->di_flushiter < (DI_MAX_FLUSH >>1 )) {/* do nothing */ }else {xfs_buf_relse (bp);
@@ -2411,8 +2409,8 @@ xlog_recover_do_inode_trans( }/* The core is in in-core format */ -xfs_xlate_dinode_core ((xfs_caddr_t)&dip->di_core, - (xfs_dinode_core_t *)item->ri_buf[1 ].i_addr,-1 ); +xfs_dinode_to_disk (&dip->di_core, + (xfs_dinode_incore_t *)item->ri_buf[1 ].i_addr);/* the rest is in on-disk format */ if (item->ri_buf[1 ].i_len >sizeof (xfs_dinode_core_t)) {
@@ -2424,8 +2422,7 @@ xlog_recover_do_inode_trans( fields = in_f->ilf_fields;switch (fields & (XFS_ILOG_DEV |XFS_ILOG_UUID )) {case XFS_ILOG_DEV : -INT_SET (dip->di_u.di_dev,ARCH_CONVERT , in_f->ilf_u.ilfu_rdev); - + dip->di_u.di_dev =cpu_to_be32 (in_f->ilf_u.ilfu_rdev);break ;case XFS_ILOG_UUID : dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid;
@@ -3234,8 +3231,8 @@ xlog_recover_process_iunlinks(ASSERT (ip->i_d.di_nlink ==0 );/* setup for the next pass */ - agino =INT_GET (dip->di_next_unlinked, -ARCH_CONVERT ); + agino =be32_to_cpu ( + dip->di_next_unlinked);xfs_buf_relse (ibp);/* * Prevent any DMAPI event from
fs/xfs/xfsidbg.c +8 -9
@@ -232,7 +232,7 @@ static char * xfs_fmtsize(size_t i);static char *xfs_fmtuuid (uuid_t *);static void xfs_inode_item_print (xfs_inode_log_item_t *ilip,int summary);static void xfs_inodebuf (xfs_buf_t *bp); -static void xfs_prdinode_core (xfs_dinode_core_t *dip); +static void xfs_prdinode_incore (xfs_dinode_incore_t *dip);static void xfs_qoff_item_print (xfs_qoff_logitem_t *lip,int summary);static void xfs_xexlist_fork (xfs_inode_t *ip,int whichfork);static void xfs_xnode_fork (char *name,xfs_ifork_t *f);
@@ -3828,7 +3828,7 @@ static void xfs_inodebuf(xfs_buf_t *bp) {xfs_dinode_t *di; -xfs_dinode_core_t dic; +xfs_dinode_incore_t dic;int n, i; n =XFS_BUF_COUNT (bp) >>8 ;
@@ -3836,11 +3836,10 @@ xfs_inodebuf(xfs_buf_t *bp) di = (xfs_dinode_t *)xfs_buf_offset (bp, i *256 ); -xfs_xlate_dinode_core ((xfs_caddr_t)&di->di_core, &dic,1 ); -xfs_prdinode_core (&dic); +xfs_dinode_from_disk (&dic, &di->di_core); +xfs_prdinode_incore (&dic);kdb_printf ("next_unlinked 0x%x u@0x%p\n" , -INT_GET (di->di_next_unlinked,ARCH_CONVERT ), - &di->di_u); +be32_to_cpu (di->di_next_unlinked), &di->di_u); } }
@@ -3981,7 +3980,7 @@ xfs_inval_cached_trace_entry(ktrace_entr* Print disk inode core. */ static void -xfs_prdinode_core (xfs_dinode_core_t *dip) +xfs_prdinode_incore (xfs_dinode_incore_t *dip) {static char *diflags[] = {"realtime" ,/* XFS_DIFLAG_REALTIME */
@@ -5059,7 +5058,7 @@ xfsidbg_xbuf_real(xfs_buf_t *bp, int sumkdb_printf ("buf 0x%p dir/attr node 0x%p\n" , bp, node);xfsidbg_xdanode (node); } - }else if (INT_GET ((di = d)->di_core.di_magic,ARCH_CONVERT ) ==XFS_DINODE_MAGIC ) { + }else if (be16_to_cpu ((di = d)->di_core.di_magic) ==XFS_DINODE_MAGIC ) {if (summary) {kdb_printf ("Disk Inode (at 0x%p)\n" , di); }else {
@@ -6907,7 +6906,7 @@ xfsidbg_xnode(xfs_inode_t *ip)xfs_xnode_fork ("data" , &ip->i_df);xfs_xnode_fork ("attr" , ip->i_afp);kdb_printf ("\n" ); -xfs_prdinode_core (&ip->i_d); +xfs_prdinode_incore (&ip->i_d); } static void
fs/xfs/linux-2.6/xfs_ksyms.c +1 -1
@@ -325,7 +325,7 @@ EXPORT_SYMBOL(xfs_vfsops);EXPORT_SYMBOL (xfs_vnodeops);EXPORT_SYMBOL (xfs_vtoi);EXPORT_SYMBOL (xfs_write_clear_setuid); -EXPORT_SYMBOL (xfs_xlate_dinode_core); +EXPORT_SYMBOL (xfs_dinode_from_disk);EXPORT_SYMBOL (xfs_xlatesb);EXPORT_SYMBOL (xfs_zero_eof);EXPORT_SYMBOL (xlog_recover_process_iunlinks);
fs/xfs/xfs_inode.h +6 -3
@@ -282,7 +282,7 @@ typedef struct xfs_inode {unsigned int i_gen;/* generation count */ unsigned int i_delayed_blks;/* count of delay alloc blks */ -xfs_dinode_core_t i_d;/* most of ondisk inode */ +xfs_dinode_incore_t i_d;/* most of ondisk inode */ xfs_chashlist_t *i_chash;/* cluster hash list header */ struct xfs_inode *i_cnext;/* cluster hash link forward */ struct xfs_inode *i_cprev;/* cluster hash link backward */
@@ -514,8 +514,11 @@ int xfs_iread_extents(struct xfs_transint xfs_ialloc (struct xfs_trans *,xfs_inode_t *,mode_t ,xfs_nlink_t ,xfs_dev_t ,struct cred *,xfs_prid_t ,int ,struct xfs_buf **,boolean_t *,xfs_inode_t **); -void xfs_xlate_dinode_core (xfs_caddr_t ,struct xfs_dinode_core *, -int ); +void xfs_dinode_from_disk (xfs_dinode_incore_t *, +xfs_dinode_core_t *); +void xfs_dinode_to_disk (xfs_dinode_core_t *, +xfs_dinode_incore_t *); +uint xfs_ip2xflags (struct xfs_inode *);uint xfs_dic2xflags (struct xfs_dinode_core *); int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
Quoted 4 lines · Christoph Hellwig
Biggest bit is duplicating the dinode structure so we have one annoted for native endianess and one for disk endinaess. The other significant change is that
xfs_xlate_dinode_coreis split into one helper per direction to allow for proper annotations, everything else is trivial.
Ok, we've needed to do that for a while....
Quoted 3 lines
As a sidenode splitting out the incore dinode means we can move it into
xfs_inode.hin a later patch and severly improving on the include hell in xfs.
Excellent!
Couple of comments, though....
Quoted 5 lines
Index:
linux-2.6-xfs/fs/xfs/xfs_dinode.h
===================================================================
fs/xfs/xfs_dinode.h struct xfs_mount; · line 40
Quoted 10 lines
fs/xfs/xfs_dinode.h +3
-2@@ -33,16 +33,17 @@ struct xfs_mount;* with the last field expanding. It is split into the core and "other" * because we only need the core part in the in-core inode. */ -typedef struct xfs_timestamp { + +typedef struct xfs_timestamp_incore {__int32_t t_sec;/* timestamp seconds */ __int32_t t_nsec;/* timestamp nanoseconds */ -}xfs_timestamp_t ; +}xfs_timestamp_incore_t ;
This is a bit ugly - we typically use the "ic" prefix to indicate "in-core" e.g. "l_iclogbufs", "xfs_icsb_cnts_t".
Perhaps "xfs_ictimestamp_t" or "xfs_ictstamp_t" would be more consistent with other code. Not sure it really matters, but it would fix up some of the formatting issues such a long variable introduces....
fs/xfs/xfs_dinode.h struct xfs_mount; · line 46
Quoted 8 lines
fs/xfs/xfs_dinode.h +3
-3/* -* Note: Coordinate changes to this structure with the XFS_DI_* #defines -* below and the offsets table in xfs_ialloc_log_di(). +* Incore dinode core. Must match xfs_dinode_core except for endianess +* annotations. */ -typedef struct xfs_dinode_core +typedef struct xfs_dinode_incore
So now we have:
- struct inode (linux in memory inode)
- struct xfs_inode (xfs in memory inode)
- struct xfs_dinode_incore (xfs in memory disk inode core)
- struct xfs_dinode_core (xfs on disk inode core)
I think the xfs_dinode_incore is badly named, because the "core" part of xfs_dinode_core refers to the main part (or "core") of the on disk inode. i.e. the non-literal area of the inode. IOWs, "core" in this context has very different meaning to "incore" (see XFS_ILOG_CORE and friends, for example).
Perhaps "struct xfs_icdinode_core" as per the above?
Cheers,
Dave.
Signature · 3 lines
Dave Chinner Principal Engineer SGI Australian Software Group
Quoted 7 lines · David Chinner
This is a bit ugly - we typically use the "ic" prefix to indicate "in-core" e.g. "
l_iclogbufs", "xfs_icsb_cnts_t".Perhaps "
xfs_ictimestamp_t" or "xfs_ictstamp_t" would be more consistent with other code. Not sure it really matters, but it would fix up some of the formatting issues such a long variable introduces....
I've done xfs_ictimestamp_t.
Quoted 6 lines
So now we have:
- struct inode (linux in memory inode)
- structxfs_inode(xfs in memory inode)
- structxfs_dinode_incore(xfs in memory disk inode core)
- structxfs_dinode_core(xfs on disk inode core)
- struct bhv_vnode
but I have some experimental patches to kill it..
Quoted 7 lines
I think the
xfs_dinode_incoreis badly named, because the "core" part ofxfs_dinode_corerefers to the main part (or "core") of the on disk inode. i.e. the non-literal area of the inode. IOWs, "core" in this context has very different meaning to "incore" (seeXFS_ILOG_COREand friends, for example).Perhaps "struct
xfs_icdinode_core" as per the above?
I've renamed it to xfs_icdinode
Updated patch below:
fs/xfs/dmapi/xfs_dm.c +31 -33
@@ -345,19 +345,17 @@ _xfs_dic2dmflags( STATIC uintxfs_ip2dmflags ( -xfs_inode_t *ip) +xfs_inode_t *ip) { -xfs_dinode_core_t *dic = &ip->i_d; - -return _xfs_dic2dmflags (dic->di_flags) | +return _xfs_dic2dmflags (ip->i_d.di_flags) | (XFS_CFORK_Q (dic) ?DM_XFLAG_HASATTR :0 ); } STATIC uintxfs_dic2dmflags ( -xfs_dinode_core_t *dic) +xfs_dinode_t *dip) { -return _xfs_dic2dmflags (INT_GET (dic->di_flags,ARCH_CONVERT )) | +return _xfs_dic2dmflags (be16_to_cpu (dip->di_core.di_flags)) | (XFS_CFORK_Q_DISK (dic) ?DM_XFLAG_HASATTR :0 ); }
@@ -387,32 +385,33 @@ xfs_dip_to_stat(* the new format. We don't change the version number so that we * can distinguish this from a real new format inode. */ -if (INT_GET (dic->di_version,ARCH_CONVERT ) ==XFS_DINODE_VERSION_1 ) { - buf->dt_nlink =INT_GET (dic->di_onlink,ARCH_CONVERT ); +if (dic->di_version ==XFS_DINODE_VERSION_1 ) { + buf->dt_nlink =be16_to_cpu (dic->di_onlink);/*buf->dt_xfs_projid = 0;*/ }else { - buf->dt_nlink =INT_GET (dic->di_nlink,ARCH_CONVERT ); -/*buf->dt_xfs_projid = INT_GET(dic->di_projid, ARCH_CONVERT);*/ + buf->dt_nlink =be32_to_cpu (dic->di_nlink); +/*buf->dt_xfs_projid = be16_to_cpu(dic->di_projid);*/ } buf->dt_ino = ino; buf->dt_dev =XFS_TO_HOST_DEVT (mp); - buf->dt_mode =INT_GET (dic->di_mode,ARCH_CONVERT ); - buf->dt_uid =INT_GET (dic->di_uid,ARCH_CONVERT ); - buf->dt_gid =INT_GET (dic->di_gid,ARCH_CONVERT ); - buf->dt_size =INT_GET (dic->di_size,ARCH_CONVERT ); - buf->dt_atime =INT_GET (dic->di_atime.t_sec,ARCH_CONVERT ); - buf->dt_mtime =INT_GET (dic->di_mtime.t_sec,ARCH_CONVERT ); - buf->dt_ctime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); - buf->dt_xfs_xflags =xfs_dic2dmflags (dic); - buf->dt_xfs_extsize =INT_GET (dic->di_extsize,ARCH_CONVERT ) << mp->m_sb.sb_blocklog; - buf->dt_xfs_extents =INT_GET (dic->di_nextents,ARCH_CONVERT ); - buf->dt_xfs_aextents =INT_GET (dic->di_anextents,ARCH_CONVERT ); - buf->dt_xfs_igen =INT_GET (dic->di_gen,ARCH_CONVERT ); - buf->dt_xfs_dmstate =INT_GET (dic->di_dmstate,ARCH_CONVERT ); + buf->dt_mode =be16_to_cpu (dic->di_mode); + buf->dt_uid =be32_to_cpu (dic->di_uid); + buf->dt_gid =be32_to_cpu (dic->di_gid); + buf->dt_size =be64_to_cpu (dic->di_size); + buf->dt_atime =be32_to_cpu (dic->di_atime.t_sec); + buf->dt_mtime =be32_to_cpu (dic->di_mtime.t_sec); + buf->dt_ctime =be32_to_cpu (dic->di_ctime.t_sec); + buf->dt_xfs_xflags =xfs_dic2dmflags (dip); + buf->dt_xfs_extsize = +be32_to_cpu (dic->di_extsize) << mp->m_sb.sb_blocklog; + buf->dt_xfs_extents =be32_to_cpu (dic->di_nextents); + buf->dt_xfs_aextents =be16_to_cpu (dic->di_anextents); + buf->dt_xfs_igen =be32_to_cpu (dic->di_gen); + buf->dt_xfs_dmstate =be16_to_cpu (dic->di_dmstate); -switch (INT_GET (dic->di_format,ARCH_CONVERT )) { +switch (dic->di_format) {case XFS_DINODE_FMT_DEV : - buf->dt_rdev =INT_GET (dip->di_u.di_dev,ARCH_CONVERT ); + buf->dt_rdev =be32_to_cpu (dip->di_u.di_dev); buf->dt_blksize =BLKDEV_IOSIZE ; buf->dt_blocks =0 ;break ;
@@ -426,8 +425,8 @@ xfs_dip_to_stat(case XFS_DINODE_FMT_BTREE : buf->dt_rdev =0 ; buf->dt_blksize = mp->m_sb.sb_blocksize; - buf->dt_blocks =XFS_FSB_TO_BB (mp, -INT_GET (dic->di_nblocks,ARCH_CONVERT )); + buf->dt_blocks = +XFS_FSB_TO_BB (mp,be64_to_cpu (dic->di_nblocks));break ; }
@@ -439,8 +438,8 @@ xfs_dip_to_stat( buf->dt_pers =0 ; buf->dt_change =0 ; buf->dt_nevents =DM_EVENT_MAX ; - buf->dt_emask =INT_GET (dic->di_dmevmask,ARCH_CONVERT ); - buf->dt_dtime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); + buf->dt_emask =be32_to_cpu (dic->di_dmevmask); + buf->dt_dtime =be32_to_cpu (dic->di_ctime.t_sec);/* Set if one of READ, WRITE or TRUNCATE bits is set in emask */ buf->dt_pmanreg = (DMEV_ISSET(DM_EVENT_READ, buf->dt_emask) || DMEV_ISSET(DM_EVENT_WRITE, buf->dt_emask) ||
@@ -458,7 +457,7 @@ xfs_ip_to_stat( xfs_inode_t *ip, dm_stat_t *buf) { -xfs_dinode_core_t *dic = &ip->i_d; +xfs_icdinode_t *dic = &ip->i_d;bhv_vnode_t *vp =XFS_ITOV (ip); buf->dt_ino = ino;
@@ -604,8 +603,7 @@ xfs_dm_inline_attr( caddr_t attr_buf, int *value_lenp) { -if (INT_GET (dip->di_core.di_aformat,ARCH_CONVERT ) == -XFS_DINODE_FMT_LOCAL ) { +if (dip->di_core.di_aformat ==XFS_DINODE_FMT_LOCAL ) {xfs_attr_shortform_t *sf;xfs_attr_sf_entry_t *sfe;unsigned int namelen =strlen (attr_name);
@@ -649,7 +647,7 @@ dm_dip_to_handle( xfid->fid_len =sizeof (xfs_fid2_t) -sizeof (xfid->fid_len); xfid->fid_pad =0 ; xfid->fid_ino = ino; - xfid->fid_gen =INT_GET (dip->di_core.di_gen,ARCH_CONVERT ); + xfid->fid_gen =be32_to_cpu (dip->di_core.di_gen);memcpy (&handlep->ha_fsid, fsid,sizeof (*fsid));memcpy (&handlep->ha_fid, &fid, fid.dm_fid_len +sizeof (fid.dm_fid_len));
fs/xfs/xfs_dinode.h +51 -14
111 lines not on this page · raw message
fs/xfs/xfs_ialloc.c +3 -3
@@ -293,9 +293,9 @@ xfs_ialloc_ag_alloc(xfs_biozero (fbuf,0 , ninodes << args.mp->m_sb.sb_inodelog);for (i =0 ; i < ninodes; i++) { free =XFS_MAKE_IPTR (args.mp, fbuf, i); -INT_SET (free->di_core.di_magic,ARCH_CONVERT ,XFS_DINODE_MAGIC ); -INT_SET (free->di_core.di_version,ARCH_CONVERT , version); -INT_SET (free->di_next_unlinked,ARCH_CONVERT ,NULLAGINO ); + free->di_core.di_magic =cpu_to_be16 (XFS_DINODE_MAGIC ); + free->di_core.di_version = version; + free->di_next_unlinked =cpu_to_be32 (NULLAGINO );xfs_ialloc_log_di (tp, fbuf, i,XFS_DI_CORE_BITS |XFS_DI_NEXT_UNLINKED ); }
fs/xfs/xfs_inode.c +107 -106
394 lines not on this page · raw message
fs/xfs/xfs_itable.c +27 -28
94 lines not on this page · raw message
fs/xfs/xfs_log_recover.c +11 -14
@@ -2245,7 +2245,7 @@ xlog_recover_do_inode_trans(int error;int attr_index;uint fields; -xfs_dinode_core_t *dicp; +xfs_icdinode_t *dicp;int need_free =0 ;if (pass ==XLOG_RECOVER_PASS1 ) {
@@ -2309,7 +2309,7 @@ xlog_recover_do_inode_trans(* Make sure the place we're flushing out to really looks * like an inode! */ -if (unlikely (INT_GET (dip->di_core.di_magic,ARCH_CONVERT ) !=XFS_DINODE_MAGIC )) { +if (unlikely (be16_to_cpu (dip->di_core.di_magic) !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp, "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld",
@@ -2319,7 +2319,7 @@ xlog_recover_do_inode_trans( error =EFSCORRUPTED ; goto error; } - dicp = (xfs_dinode_core_t *)(item->ri_buf[1 ].i_addr); + dicp = (xfs_icdinode_t *)(item->ri_buf[1 ].i_addr);if (unlikely (dicp->di_magic !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp,
@@ -2332,15 +2332,13 @@ xlog_recover_do_inode_trans( }/* Skip replay when the on disk inode is newer than the log one */ -if (dicp->di_flushiter < -INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT )) { +if (dicp->di_flushiter <be16_to_cpu (dip->di_core.di_flushiter)) {/* * Deal with the wrap case, DI_MAX_FLUSH is less * than smaller numbers */ -if ((INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT ) - ==DI_MAX_FLUSH ) && - (dicp->di_flushiter < (DI_MAX_FLUSH >>1 ))) { +if (be16_to_cpu (dip->di_core.di_flushiter) ==DI_MAX_FLUSH && + dicp->di_flushiter < (DI_MAX_FLUSH >>1 )) {/* do nothing */ }else {xfs_buf_relse (bp);
@@ -2411,8 +2409,8 @@ xlog_recover_do_inode_trans( }/* The core is in in-core format */ -xfs_xlate_dinode_core ((xfs_caddr_t)&dip->di_core, - (xfs_dinode_core_t *)item->ri_buf[1 ].i_addr,-1 ); +xfs_dinode_to_disk (&dip->di_core, + (xfs_icdinode_t *)item->ri_buf[1 ].i_addr);/* the rest is in on-disk format */ if (item->ri_buf[1 ].i_len >sizeof (xfs_dinode_core_t)) {
@@ -2424,8 +2422,7 @@ xlog_recover_do_inode_trans( fields = in_f->ilf_fields;switch (fields & (XFS_ILOG_DEV |XFS_ILOG_UUID )) {case XFS_ILOG_DEV : -INT_SET (dip->di_u.di_dev,ARCH_CONVERT , in_f->ilf_u.ilfu_rdev); - + dip->di_u.di_dev =cpu_to_be32 (in_f->ilf_u.ilfu_rdev);break ;case XFS_ILOG_UUID : dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid;
@@ -3234,8 +3231,8 @@ xlog_recover_process_iunlinks(ASSERT (ip->i_d.di_nlink ==0 );/* setup for the next pass */ - agino =INT_GET (dip->di_next_unlinked, -ARCH_CONVERT ); + agino =be32_to_cpu ( + dip->di_next_unlinked);xfs_buf_relse (ibp);/* * Prevent any DMAPI event from
fs/xfs/xfsidbg.c +8 -9
@@ -232,7 +232,7 @@ static char * xfs_fmtsize(size_t i);static char *xfs_fmtuuid (uuid_t *);static void xfs_inode_item_print (xfs_inode_log_item_t *ilip,int summary);static void xfs_inodebuf (xfs_buf_t *bp); -static void xfs_prdinode_core (xfs_dinode_core_t *dip); +static void xfs_prdinode_incore (xfs_icdinode_t *dip);static void xfs_qoff_item_print (xfs_qoff_logitem_t *lip,int summary);static void xfs_xexlist_fork (xfs_inode_t *ip,int whichfork);static void xfs_xnode_fork (char *name,xfs_ifork_t *f);
@@ -3828,7 +3828,7 @@ static void xfs_inodebuf(xfs_buf_t *bp) {xfs_dinode_t *di; -xfs_dinode_core_t dic; +xfs_icdinode_t dic;int n, i; n =XFS_BUF_COUNT (bp) >>8 ;
@@ -3836,11 +3836,10 @@ xfs_inodebuf(xfs_buf_t *bp) di = (xfs_dinode_t *)xfs_buf_offset (bp, i *256 ); -xfs_xlate_dinode_core ((xfs_caddr_t)&di->di_core, &dic,1 ); -xfs_prdinode_core (&dic); +xfs_dinode_from_disk (&dic, &di->di_core); +xfs_prdinode_incore (&dic);kdb_printf ("next_unlinked 0x%x u@0x%p\n" , -INT_GET (di->di_next_unlinked,ARCH_CONVERT ), - &di->di_u); +be32_to_cpu (di->di_next_unlinked), &di->di_u); } }
@@ -3981,7 +3980,7 @@ xfs_inval_cached_trace_entry(ktrace_entr* Print disk inode core. */ static void -xfs_prdinode_core (xfs_dinode_core_t *dip) +xfs_prdinode_incore (xfs_icdinode_t *dip) {static char *diflags[] = {"realtime" ,/* XFS_DIFLAG_REALTIME */
@@ -5059,7 +5058,7 @@ xfsidbg_xbuf_real(xfs_buf_t *bp, int sumkdb_printf ("buf 0x%p dir/attr node 0x%p\n" , bp, node);xfsidbg_xdanode (node); } - }else if (INT_GET ((di = d)->di_core.di_magic,ARCH_CONVERT ) ==XFS_DINODE_MAGIC ) { + }else if (be16_to_cpu ((di = d)->di_core.di_magic) ==XFS_DINODE_MAGIC ) {if (summary) {kdb_printf ("Disk Inode (at 0x%p)\n" , di); }else {
@@ -6907,7 +6906,7 @@ xfsidbg_xnode(xfs_inode_t *ip)xfs_xnode_fork ("data" , &ip->i_df);xfs_xnode_fork ("attr" , ip->i_afp);kdb_printf ("\n" ); -xfs_prdinode_core (&ip->i_d); +xfs_prdinode_incore (&ip->i_d); } static void
fs/xfs/linux-2.6/xfs_ksyms.c +1 -1
@@ -325,7 +325,7 @@ EXPORT_SYMBOL(xfs_vfsops);EXPORT_SYMBOL (xfs_vnodeops);EXPORT_SYMBOL (xfs_vtoi);EXPORT_SYMBOL (xfs_write_clear_setuid); -EXPORT_SYMBOL (xfs_xlate_dinode_core); +EXPORT_SYMBOL (xfs_dinode_from_disk);EXPORT_SYMBOL (xfs_xlatesb);EXPORT_SYMBOL (xfs_zero_eof);EXPORT_SYMBOL (xlog_recover_process_iunlinks);
fs/xfs/xfs_inode.h +6 -3
@@ -282,7 +282,7 @@ typedef struct xfs_inode {unsigned int i_gen;/* generation count */ unsigned int i_delayed_blks;/* count of delay alloc blks */ -xfs_dinode_core_t i_d;/* most of ondisk inode */ +xfs_icdinode_t i_d;/* most of ondisk inode */ xfs_chashlist_t *i_chash;/* cluster hash list header */ struct xfs_inode *i_cnext;/* cluster hash link forward */ struct xfs_inode *i_cprev;/* cluster hash link backward */
@@ -514,8 +514,11 @@ int xfs_iread_extents(struct xfs_transint xfs_ialloc (struct xfs_trans *,xfs_inode_t *,mode_t ,xfs_nlink_t ,xfs_dev_t ,struct cred *,xfs_prid_t ,int ,struct xfs_buf **,boolean_t *,xfs_inode_t **); -void xfs_xlate_dinode_core (xfs_caddr_t ,struct xfs_dinode_core *, -int ); +void xfs_dinode_from_disk (xfs_icdinode_t *, +xfs_dinode_core_t *); +void xfs_dinode_to_disk (xfs_dinode_core_t *, +xfs_icdinode_t *); +uint xfs_ip2xflags (struct xfs_inode *);uint xfs_dic2xflags (struct xfs_dinode_core *); int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
The updated patch didn't actually compile with dmapi enabled. Here's a fixed version:
fs/xfs/dmapi/xfs_dm.c +34 -35
@@ -345,20 +345,19 @@ _xfs_dic2dmflags( STATIC uintxfs_ip2dmflags ( -xfs_inode_t *ip) +xfs_inode_t *ip) { -xfs_dinode_core_t *dic = &ip->i_d; - -return _xfs_dic2dmflags (dic->di_flags) | - (XFS_CFORK_Q (dic) ?DM_XFLAG_HASATTR :0 ); +return _xfs_dic2dmflags (ip->i_d.di_flags) | + (XFS_CFORK_Q (&ip->i_d) ?DM_XFLAG_HASATTR :0 ); } STATIC uintxfs_dic2dmflags ( -xfs_dinode_core_t *dic) +xfs_dinode_t *dip) { -return _xfs_dic2dmflags (INT_GET (dic->di_flags,ARCH_CONVERT )) | - (XFS_CFORK_Q_DISK (dic) ?DM_XFLAG_HASATTR :0 ); +return _xfs_dic2dmflags (be16_to_cpu (dip->di_core.di_flags)) | + (XFS_CFORK_Q_DISK (&dip->di_core) ? +DM_XFLAG_HASATTR :0 ); }/*
@@ -387,32 +386,33 @@ xfs_dip_to_stat(* the new format. We don't change the version number so that we * can distinguish this from a real new format inode. */ -if (INT_GET (dic->di_version,ARCH_CONVERT ) ==XFS_DINODE_VERSION_1 ) { - buf->dt_nlink =INT_GET (dic->di_onlink,ARCH_CONVERT ); +if (dic->di_version ==XFS_DINODE_VERSION_1 ) { + buf->dt_nlink =be16_to_cpu (dic->di_onlink);/*buf->dt_xfs_projid = 0;*/ }else { - buf->dt_nlink =INT_GET (dic->di_nlink,ARCH_CONVERT ); -/*buf->dt_xfs_projid = INT_GET(dic->di_projid, ARCH_CONVERT);*/ + buf->dt_nlink =be32_to_cpu (dic->di_nlink); +/*buf->dt_xfs_projid = be16_to_cpu(dic->di_projid);*/ } buf->dt_ino = ino; buf->dt_dev =XFS_TO_HOST_DEVT (mp); - buf->dt_mode =INT_GET (dic->di_mode,ARCH_CONVERT ); - buf->dt_uid =INT_GET (dic->di_uid,ARCH_CONVERT ); - buf->dt_gid =INT_GET (dic->di_gid,ARCH_CONVERT ); - buf->dt_size =INT_GET (dic->di_size,ARCH_CONVERT ); - buf->dt_atime =INT_GET (dic->di_atime.t_sec,ARCH_CONVERT ); - buf->dt_mtime =INT_GET (dic->di_mtime.t_sec,ARCH_CONVERT ); - buf->dt_ctime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); - buf->dt_xfs_xflags =xfs_dic2dmflags (dic); - buf->dt_xfs_extsize =INT_GET (dic->di_extsize,ARCH_CONVERT ) << mp->m_sb.sb_blocklog; - buf->dt_xfs_extents =INT_GET (dic->di_nextents,ARCH_CONVERT ); - buf->dt_xfs_aextents =INT_GET (dic->di_anextents,ARCH_CONVERT ); - buf->dt_xfs_igen =INT_GET (dic->di_gen,ARCH_CONVERT ); - buf->dt_xfs_dmstate =INT_GET (dic->di_dmstate,ARCH_CONVERT ); + buf->dt_mode =be16_to_cpu (dic->di_mode); + buf->dt_uid =be32_to_cpu (dic->di_uid); + buf->dt_gid =be32_to_cpu (dic->di_gid); + buf->dt_size =be64_to_cpu (dic->di_size); + buf->dt_atime =be32_to_cpu (dic->di_atime.t_sec); + buf->dt_mtime =be32_to_cpu (dic->di_mtime.t_sec); + buf->dt_ctime =be32_to_cpu (dic->di_ctime.t_sec); + buf->dt_xfs_xflags =xfs_dic2dmflags (dip); + buf->dt_xfs_extsize = +be32_to_cpu (dic->di_extsize) << mp->m_sb.sb_blocklog; + buf->dt_xfs_extents =be32_to_cpu (dic->di_nextents); + buf->dt_xfs_aextents =be16_to_cpu (dic->di_anextents); + buf->dt_xfs_igen =be32_to_cpu (dic->di_gen); + buf->dt_xfs_dmstate =be16_to_cpu (dic->di_dmstate); -switch (INT_GET (dic->di_format,ARCH_CONVERT )) { +switch (dic->di_format) {case XFS_DINODE_FMT_DEV : - buf->dt_rdev =INT_GET (dip->di_u.di_dev,ARCH_CONVERT ); + buf->dt_rdev =be32_to_cpu (dip->di_u.di_dev); buf->dt_blksize =BLKDEV_IOSIZE ; buf->dt_blocks =0 ;break ;
@@ -426,8 +426,8 @@ xfs_dip_to_stat(case XFS_DINODE_FMT_BTREE : buf->dt_rdev =0 ; buf->dt_blksize = mp->m_sb.sb_blocksize; - buf->dt_blocks =XFS_FSB_TO_BB (mp, -INT_GET (dic->di_nblocks,ARCH_CONVERT )); + buf->dt_blocks = +XFS_FSB_TO_BB (mp,be64_to_cpu (dic->di_nblocks));break ; }
@@ -439,8 +439,8 @@ xfs_dip_to_stat( buf->dt_pers =0 ; buf->dt_change =0 ; buf->dt_nevents =DM_EVENT_MAX ; - buf->dt_emask =INT_GET (dic->di_dmevmask,ARCH_CONVERT ); - buf->dt_dtime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); + buf->dt_emask =be32_to_cpu (dic->di_dmevmask); + buf->dt_dtime =be32_to_cpu (dic->di_ctime.t_sec);/* Set if one of READ, WRITE or TRUNCATE bits is set in emask */ buf->dt_pmanreg = (DMEV_ISSET(DM_EVENT_READ, buf->dt_emask) || DMEV_ISSET(DM_EVENT_WRITE, buf->dt_emask) ||
@@ -458,7 +458,7 @@ xfs_ip_to_stat( xfs_inode_t *ip, dm_stat_t *buf) { -xfs_dinode_core_t *dic = &ip->i_d; +xfs_icdinode_t *dic = &ip->i_d;bhv_vnode_t *vp =XFS_ITOV (ip); buf->dt_ino = ino;
@@ -604,8 +604,7 @@ xfs_dm_inline_attr( caddr_t attr_buf, int *value_lenp) { -if (INT_GET (dip->di_core.di_aformat,ARCH_CONVERT ) == -XFS_DINODE_FMT_LOCAL ) { +if (dip->di_core.di_aformat ==XFS_DINODE_FMT_LOCAL ) {xfs_attr_shortform_t *sf;xfs_attr_sf_entry_t *sfe;unsigned int namelen =strlen (attr_name);
@@ -649,7 +648,7 @@ dm_dip_to_handle( xfid->fid_len =sizeof (xfs_fid2_t) -sizeof (xfid->fid_len); xfid->fid_pad =0 ; xfid->fid_ino = ino; - xfid->fid_gen =INT_GET (dip->di_core.di_gen,ARCH_CONVERT ); + xfid->fid_gen =be32_to_cpu (dip->di_core.di_gen);memcpy (&handlep->ha_fsid, fsid,sizeof (*fsid));memcpy (&handlep->ha_fid, &fid, fid.dm_fid_len +sizeof (fid.dm_fid_len));
fs/xfs/xfs_dinode.h +51 -14
111 lines not on this page · raw message
fs/xfs/xfs_ialloc.c +3 -3
@@ -293,9 +293,9 @@ xfs_ialloc_ag_alloc(xfs_biozero (fbuf,0 , ninodes << args.mp->m_sb.sb_inodelog);for (i =0 ; i < ninodes; i++) { free =XFS_MAKE_IPTR (args.mp, fbuf, i); -INT_SET (free->di_core.di_magic,ARCH_CONVERT ,XFS_DINODE_MAGIC ); -INT_SET (free->di_core.di_version,ARCH_CONVERT , version); -INT_SET (free->di_next_unlinked,ARCH_CONVERT ,NULLAGINO ); + free->di_core.di_magic =cpu_to_be16 (XFS_DINODE_MAGIC ); + free->di_core.di_version = version; + free->di_next_unlinked =cpu_to_be32 (NULLAGINO );xfs_ialloc_log_di (tp, fbuf, i,XFS_DI_CORE_BITS |XFS_DI_NEXT_UNLINKED ); }
fs/xfs/xfs_inode.c +107 -106
394 lines not on this page · raw message
fs/xfs/xfs_itable.c +27 -28
94 lines not on this page · raw message
fs/xfs/xfs_log_recover.c +11 -14
@@ -2245,7 +2245,7 @@ xlog_recover_do_inode_trans(int error;int attr_index;uint fields; -xfs_dinode_core_t *dicp; +xfs_icdinode_t *dicp;int need_free =0 ;if (pass ==XLOG_RECOVER_PASS1 ) {
@@ -2309,7 +2309,7 @@ xlog_recover_do_inode_trans(* Make sure the place we're flushing out to really looks * like an inode! */ -if (unlikely (INT_GET (dip->di_core.di_magic,ARCH_CONVERT ) !=XFS_DINODE_MAGIC )) { +if (unlikely (be16_to_cpu (dip->di_core.di_magic) !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp, "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld",
@@ -2319,7 +2319,7 @@ xlog_recover_do_inode_trans( error =EFSCORRUPTED ; goto error; } - dicp = (xfs_dinode_core_t *)(item->ri_buf[1 ].i_addr); + dicp = (xfs_icdinode_t *)(item->ri_buf[1 ].i_addr);if (unlikely (dicp->di_magic !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp,
@@ -2332,15 +2332,13 @@ xlog_recover_do_inode_trans( }/* Skip replay when the on disk inode is newer than the log one */ -if (dicp->di_flushiter < -INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT )) { +if (dicp->di_flushiter <be16_to_cpu (dip->di_core.di_flushiter)) {/* * Deal with the wrap case, DI_MAX_FLUSH is less * than smaller numbers */ -if ((INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT ) - ==DI_MAX_FLUSH ) && - (dicp->di_flushiter < (DI_MAX_FLUSH >>1 ))) { +if (be16_to_cpu (dip->di_core.di_flushiter) ==DI_MAX_FLUSH && + dicp->di_flushiter < (DI_MAX_FLUSH >>1 )) {/* do nothing */ }else {xfs_buf_relse (bp);
@@ -2411,8 +2409,8 @@ xlog_recover_do_inode_trans( }/* The core is in in-core format */ -xfs_xlate_dinode_core ((xfs_caddr_t)&dip->di_core, - (xfs_dinode_core_t *)item->ri_buf[1 ].i_addr,-1 ); +xfs_dinode_to_disk (&dip->di_core, + (xfs_icdinode_t *)item->ri_buf[1 ].i_addr);/* the rest is in on-disk format */ if (item->ri_buf[1 ].i_len >sizeof (xfs_dinode_core_t)) {
@@ -2424,8 +2422,7 @@ xlog_recover_do_inode_trans( fields = in_f->ilf_fields;switch (fields & (XFS_ILOG_DEV |XFS_ILOG_UUID )) {case XFS_ILOG_DEV : -INT_SET (dip->di_u.di_dev,ARCH_CONVERT , in_f->ilf_u.ilfu_rdev); - + dip->di_u.di_dev =cpu_to_be32 (in_f->ilf_u.ilfu_rdev);break ;case XFS_ILOG_UUID : dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid;
@@ -3234,8 +3231,8 @@ xlog_recover_process_iunlinks(ASSERT (ip->i_d.di_nlink ==0 );/* setup for the next pass */ - agino =INT_GET (dip->di_next_unlinked, -ARCH_CONVERT ); + agino =be32_to_cpu ( + dip->di_next_unlinked);xfs_buf_relse (ibp);/* * Prevent any DMAPI event from
fs/xfs/xfsidbg.c +8 -9
@@ -232,7 +232,7 @@ static char * xfs_fmtsize(size_t i);static char *xfs_fmtuuid (uuid_t *);static void xfs_inode_item_print (xfs_inode_log_item_t *ilip,int summary);static void xfs_inodebuf (xfs_buf_t *bp); -static void xfs_prdinode_core (xfs_dinode_core_t *dip); +static void xfs_prdinode_incore (xfs_icdinode_t *dip);static void xfs_qoff_item_print (xfs_qoff_logitem_t *lip,int summary);static void xfs_xexlist_fork (xfs_inode_t *ip,int whichfork);static void xfs_xnode_fork (char *name,xfs_ifork_t *f);
@@ -3828,7 +3828,7 @@ static void xfs_inodebuf(xfs_buf_t *bp) {xfs_dinode_t *di; -xfs_dinode_core_t dic; +xfs_icdinode_t dic;int n, i; n =XFS_BUF_COUNT (bp) >>8 ;
@@ -3836,11 +3836,10 @@ xfs_inodebuf(xfs_buf_t *bp) di = (xfs_dinode_t *)xfs_buf_offset (bp, i *256 ); -xfs_xlate_dinode_core ((xfs_caddr_t)&di->di_core, &dic,1 ); -xfs_prdinode_core (&dic); +xfs_dinode_from_disk (&dic, &di->di_core); +xfs_prdinode_incore (&dic);kdb_printf ("next_unlinked 0x%x u@0x%p\n" , -INT_GET (di->di_next_unlinked,ARCH_CONVERT ), - &di->di_u); +be32_to_cpu (di->di_next_unlinked), &di->di_u); } }
@@ -3981,7 +3980,7 @@ xfs_inval_cached_trace_entry(ktrace_entr* Print disk inode core. */ static void -xfs_prdinode_core (xfs_dinode_core_t *dip) +xfs_prdinode_incore (xfs_icdinode_t *dip) {static char *diflags[] = {"realtime" ,/* XFS_DIFLAG_REALTIME */
@@ -5059,7 +5058,7 @@ xfsidbg_xbuf_real(xfs_buf_t *bp, int sumkdb_printf ("buf 0x%p dir/attr node 0x%p\n" , bp, node);xfsidbg_xdanode (node); } - }else if (INT_GET ((di = d)->di_core.di_magic,ARCH_CONVERT ) ==XFS_DINODE_MAGIC ) { + }else if (be16_to_cpu ((di = d)->di_core.di_magic) ==XFS_DINODE_MAGIC ) {if (summary) {kdb_printf ("Disk Inode (at 0x%p)\n" , di); }else {
@@ -6907,7 +6906,7 @@ xfsidbg_xnode(xfs_inode_t *ip)xfs_xnode_fork ("data" , &ip->i_df);xfs_xnode_fork ("attr" , ip->i_afp);kdb_printf ("\n" ); -xfs_prdinode_core (&ip->i_d); +xfs_prdinode_incore (&ip->i_d); } static void
fs/xfs/linux-2.6/xfs_ksyms.c +1 -1
@@ -325,7 +325,7 @@ EXPORT_SYMBOL(xfs_vfsops);EXPORT_SYMBOL (xfs_vnodeops);EXPORT_SYMBOL (xfs_vtoi);EXPORT_SYMBOL (xfs_write_clear_setuid); -EXPORT_SYMBOL (xfs_xlate_dinode_core); +EXPORT_SYMBOL (xfs_dinode_from_disk);EXPORT_SYMBOL (xfs_xlatesb);EXPORT_SYMBOL (xfs_zero_eof);EXPORT_SYMBOL (xlog_recover_process_iunlinks);
fs/xfs/xfs_inode.h +6 -3
@@ -282,7 +282,7 @@ typedef struct xfs_inode {unsigned int i_gen;/* generation count */ unsigned int i_delayed_blks;/* count of delay alloc blks */ -xfs_dinode_core_t i_d;/* most of ondisk inode */ +xfs_icdinode_t i_d;/* most of ondisk inode */ xfs_chashlist_t *i_chash;/* cluster hash list header */ struct xfs_inode *i_cnext;/* cluster hash link forward */ struct xfs_inode *i_cprev;/* cluster hash link backward */
@@ -514,8 +514,11 @@ int xfs_iread_extents(struct xfs_transint xfs_ialloc (struct xfs_trans *,xfs_inode_t *,mode_t ,xfs_nlink_t ,xfs_dev_t ,struct cred *,xfs_prid_t ,int ,struct xfs_buf **,boolean_t *,xfs_inode_t **); -void xfs_xlate_dinode_core (xfs_caddr_t ,struct xfs_dinode_core *, -int ); +void xfs_dinode_from_disk (xfs_icdinode_t *, +xfs_dinode_core_t *); +void xfs_dinode_to_disk (xfs_dinode_core_t *, +xfs_icdinode_t *); +uint xfs_ip2xflags (struct xfs_inode *);uint xfs_dic2xflags (struct xfs_dinode_core *); int xfs_ifree(struct xfs_trans *, xfs_inode_t *,
Quoted 2 lines · Christoph Hellwig
The updated patch didn't actually compile with dmapi enabled. Here's a fixed version:
And here's another iteration.
I started doing some local patches that include xfs_inode.h in a lot more places and really got nnoyed by the tail of includes xfs_dinode.h requires to compile. So this patch includes the move of xfs_icdinode to xfs_inode.h that I suggested previously.
fs/xfs/dmapi/xfs_dm.c +34 -35
@@ -345,20 +345,19 @@ _xfs_dic2dmflags( STATIC uintxfs_ip2dmflags ( -xfs_inode_t *ip) +xfs_inode_t *ip) { -xfs_dinode_core_t *dic = &ip->i_d; - -return _xfs_dic2dmflags (dic->di_flags) | - (XFS_CFORK_Q (dic) ?DM_XFLAG_HASATTR :0 ); +return _xfs_dic2dmflags (ip->i_d.di_flags) | + (XFS_CFORK_Q (&ip->i_d) ?DM_XFLAG_HASATTR :0 ); } STATIC uintxfs_dic2dmflags ( -xfs_dinode_core_t *dic) +xfs_dinode_t *dip) { -return _xfs_dic2dmflags (INT_GET (dic->di_flags,ARCH_CONVERT )) | - (XFS_CFORK_Q_DISK (dic) ?DM_XFLAG_HASATTR :0 ); +return _xfs_dic2dmflags (be16_to_cpu (dip->di_core.di_flags)) | + (XFS_CFORK_Q_DISK (&dip->di_core) ? +DM_XFLAG_HASATTR :0 ); }/*
@@ -387,32 +386,33 @@ xfs_dip_to_stat(* the new format. We don't change the version number so that we * can distinguish this from a real new format inode. */ -if (INT_GET (dic->di_version,ARCH_CONVERT ) ==XFS_DINODE_VERSION_1 ) { - buf->dt_nlink =INT_GET (dic->di_onlink,ARCH_CONVERT ); +if (dic->di_version ==XFS_DINODE_VERSION_1 ) { + buf->dt_nlink =be16_to_cpu (dic->di_onlink);/*buf->dt_xfs_projid = 0;*/ }else { - buf->dt_nlink =INT_GET (dic->di_nlink,ARCH_CONVERT ); -/*buf->dt_xfs_projid = INT_GET(dic->di_projid, ARCH_CONVERT);*/ + buf->dt_nlink =be32_to_cpu (dic->di_nlink); +/*buf->dt_xfs_projid = be16_to_cpu(dic->di_projid);*/ } buf->dt_ino = ino; buf->dt_dev =XFS_TO_HOST_DEVT (mp); - buf->dt_mode =INT_GET (dic->di_mode,ARCH_CONVERT ); - buf->dt_uid =INT_GET (dic->di_uid,ARCH_CONVERT ); - buf->dt_gid =INT_GET (dic->di_gid,ARCH_CONVERT ); - buf->dt_size =INT_GET (dic->di_size,ARCH_CONVERT ); - buf->dt_atime =INT_GET (dic->di_atime.t_sec,ARCH_CONVERT ); - buf->dt_mtime =INT_GET (dic->di_mtime.t_sec,ARCH_CONVERT ); - buf->dt_ctime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); - buf->dt_xfs_xflags =xfs_dic2dmflags (dic); - buf->dt_xfs_extsize =INT_GET (dic->di_extsize,ARCH_CONVERT ) << mp->m_sb.sb_blocklog; - buf->dt_xfs_extents =INT_GET (dic->di_nextents,ARCH_CONVERT ); - buf->dt_xfs_aextents =INT_GET (dic->di_anextents,ARCH_CONVERT ); - buf->dt_xfs_igen =INT_GET (dic->di_gen,ARCH_CONVERT ); - buf->dt_xfs_dmstate =INT_GET (dic->di_dmstate,ARCH_CONVERT ); + buf->dt_mode =be16_to_cpu (dic->di_mode); + buf->dt_uid =be32_to_cpu (dic->di_uid); + buf->dt_gid =be32_to_cpu (dic->di_gid); + buf->dt_size =be64_to_cpu (dic->di_size); + buf->dt_atime =be32_to_cpu (dic->di_atime.t_sec); + buf->dt_mtime =be32_to_cpu (dic->di_mtime.t_sec); + buf->dt_ctime =be32_to_cpu (dic->di_ctime.t_sec); + buf->dt_xfs_xflags =xfs_dic2dmflags (dip); + buf->dt_xfs_extsize = +be32_to_cpu (dic->di_extsize) << mp->m_sb.sb_blocklog; + buf->dt_xfs_extents =be32_to_cpu (dic->di_nextents); + buf->dt_xfs_aextents =be16_to_cpu (dic->di_anextents); + buf->dt_xfs_igen =be32_to_cpu (dic->di_gen); + buf->dt_xfs_dmstate =be16_to_cpu (dic->di_dmstate); -switch (INT_GET (dic->di_format,ARCH_CONVERT )) { +switch (dic->di_format) {case XFS_DINODE_FMT_DEV : - buf->dt_rdev =INT_GET (dip->di_u.di_dev,ARCH_CONVERT ); + buf->dt_rdev =be32_to_cpu (dip->di_u.di_dev); buf->dt_blksize =BLKDEV_IOSIZE ; buf->dt_blocks =0 ;break ;
@@ -426,8 +426,8 @@ xfs_dip_to_stat(case XFS_DINODE_FMT_BTREE : buf->dt_rdev =0 ; buf->dt_blksize = mp->m_sb.sb_blocksize; - buf->dt_blocks =XFS_FSB_TO_BB (mp, -INT_GET (dic->di_nblocks,ARCH_CONVERT )); + buf->dt_blocks = +XFS_FSB_TO_BB (mp,be64_to_cpu (dic->di_nblocks));break ; }
@@ -439,8 +439,8 @@ xfs_dip_to_stat( buf->dt_pers =0 ; buf->dt_change =0 ; buf->dt_nevents =DM_EVENT_MAX ; - buf->dt_emask =INT_GET (dic->di_dmevmask,ARCH_CONVERT ); - buf->dt_dtime =INT_GET (dic->di_ctime.t_sec,ARCH_CONVERT ); + buf->dt_emask =be32_to_cpu (dic->di_dmevmask); + buf->dt_dtime =be32_to_cpu (dic->di_ctime.t_sec);/* Set if one of READ, WRITE or TRUNCATE bits is set in emask */ buf->dt_pmanreg = (DMEV_ISSET(DM_EVENT_READ, buf->dt_emask) || DMEV_ISSET(DM_EVENT_WRITE, buf->dt_emask) ||
@@ -458,7 +458,7 @@ xfs_ip_to_stat( xfs_inode_t *ip, dm_stat_t *buf) { -xfs_dinode_core_t *dic = &ip->i_d; +xfs_icdinode_t *dic = &ip->i_d;bhv_vnode_t *vp =XFS_ITOV (ip); buf->dt_ino = ino;
@@ -604,8 +604,7 @@ xfs_dm_inline_attr( caddr_t attr_buf, int *value_lenp) { -if (INT_GET (dip->di_core.di_aformat,ARCH_CONVERT ) == -XFS_DINODE_FMT_LOCAL ) { +if (dip->di_core.di_aformat ==XFS_DINODE_FMT_LOCAL ) {xfs_attr_shortform_t *sf;xfs_attr_sf_entry_t *sfe;unsigned int namelen =strlen (attr_name);
@@ -649,7 +648,7 @@ dm_dip_to_handle( xfid->fid_len =sizeof (xfs_fid2_t) -sizeof (xfid->fid_len); xfid->fid_pad =0 ; xfid->fid_ino = ino; - xfid->fid_gen =INT_GET (dip->di_core.di_gen,ARCH_CONVERT ); + xfid->fid_gen =be32_to_cpu (dip->di_core.di_gen);memcpy (&handlep->ha_fsid, fsid,sizeof (*fsid));memcpy (&handlep->ha_fid, &fid, fid.dm_fid_len +sizeof (fid.dm_fid_len));
fs/xfs/xfs_dinode.h +32 -33
102 lines not on this page · raw message
fs/xfs/xfs_ialloc.c +3 -3
@@ -293,9 +293,9 @@ xfs_ialloc_ag_alloc(xfs_biozero (fbuf,0 , ninodes << args.mp->m_sb.sb_inodelog);for (i =0 ; i < ninodes; i++) { free =XFS_MAKE_IPTR (args.mp, fbuf, i); -INT_SET (free->di_core.di_magic,ARCH_CONVERT ,XFS_DINODE_MAGIC ); -INT_SET (free->di_core.di_version,ARCH_CONVERT , version); -INT_SET (free->di_next_unlinked,ARCH_CONVERT ,NULLAGINO ); + free->di_core.di_magic =cpu_to_be16 (XFS_DINODE_MAGIC ); + free->di_core.di_version = version; + free->di_next_unlinked =cpu_to_be32 (NULLAGINO );xfs_ialloc_log_di (tp, fbuf, i,XFS_DI_CORE_BITS |XFS_DI_NEXT_UNLINKED ); }
fs/xfs/xfs_inode.c +107 -106
394 lines not on this page · raw message
fs/xfs/xfs_itable.c +27 -28
94 lines not on this page · raw message
fs/xfs/xfs_log_recover.c +11 -14
@@ -2245,7 +2245,7 @@ xlog_recover_do_inode_trans(int error;int attr_index;uint fields; -xfs_dinode_core_t *dicp; +xfs_icdinode_t *dicp;int need_free =0 ;if (pass ==XLOG_RECOVER_PASS1 ) {
@@ -2309,7 +2309,7 @@ xlog_recover_do_inode_trans(* Make sure the place we're flushing out to really looks * like an inode! */ -if (unlikely (INT_GET (dip->di_core.di_magic,ARCH_CONVERT ) !=XFS_DINODE_MAGIC )) { +if (unlikely (be16_to_cpu (dip->di_core.di_magic) !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp, "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld",
@@ -2319,7 +2319,7 @@ xlog_recover_do_inode_trans( error =EFSCORRUPTED ; goto error; } - dicp = (xfs_dinode_core_t *)(item->ri_buf[1 ].i_addr); + dicp = (xfs_icdinode_t *)(item->ri_buf[1 ].i_addr);if (unlikely (dicp->di_magic !=XFS_DINODE_MAGIC )) {xfs_buf_relse (bp); xfs_fs_cmn_err(CE_ALERT, mp,
@@ -2332,15 +2332,13 @@ xlog_recover_do_inode_trans( }/* Skip replay when the on disk inode is newer than the log one */ -if (dicp->di_flushiter < -INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT )) { +if (dicp->di_flushiter <be16_to_cpu (dip->di_core.di_flushiter)) {/* * Deal with the wrap case, DI_MAX_FLUSH is less * than smaller numbers */ -if ((INT_GET (dip->di_core.di_flushiter,ARCH_CONVERT ) - ==DI_MAX_FLUSH ) && - (dicp->di_flushiter < (DI_MAX_FLUSH >>1 ))) { +if (be16_to_cpu (dip->di_core.di_flushiter) ==DI_MAX_FLUSH && + dicp->di_flushiter < (DI_MAX_FLUSH >>1 )) {/* do nothing */ }else {xfs_buf_relse (bp);
@@ -2411,8 +2409,8 @@ xlog_recover_do_inode_trans( }/* The core is in in-core format */ -xfs_xlate_dinode_core ((xfs_caddr_t)&dip->di_core, - (xfs_dinode_core_t *)item->ri_buf[1 ].i_addr,-1 ); +xfs_dinode_to_disk (&dip->di_core, + (xfs_icdinode_t *)item->ri_buf[1 ].i_addr);/* the rest is in on-disk format */ if (item->ri_buf[1 ].i_len >sizeof (xfs_dinode_core_t)) {
@@ -2424,8 +2422,7 @@ xlog_recover_do_inode_trans( fields = in_f->ilf_fields;switch (fields & (XFS_ILOG_DEV |XFS_ILOG_UUID )) {case XFS_ILOG_DEV : -INT_SET (dip->di_u.di_dev,ARCH_CONVERT , in_f->ilf_u.ilfu_rdev); - + dip->di_u.di_dev =cpu_to_be32 (in_f->ilf_u.ilfu_rdev);break ;case XFS_ILOG_UUID : dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid;
@@ -3234,8 +3231,8 @@ xlog_recover_process_iunlinks(ASSERT (ip->i_d.di_nlink ==0 );/* setup for the next pass */ - agino =INT_GET (dip->di_next_unlinked, -ARCH_CONVERT ); + agino =be32_to_cpu ( + dip->di_next_unlinked);xfs_buf_relse (ibp);/* * Prevent any DMAPI event from
fs/xfs/xfsidbg.c +8 -9
@@ -232,7 +232,7 @@ static char * xfs_fmtsize(size_t i);static char *xfs_fmtuuid (uuid_t *);static void xfs_inode_item_print (xfs_inode_log_item_t *ilip,int summary);static void xfs_inodebuf (xfs_buf_t *bp); -static void xfs_prdinode_core (xfs_dinode_core_t *dip); +static void xfs_prdinode_incore (xfs_icdinode_t *dip);static void xfs_qoff_item_print (xfs_qoff_logitem_t *lip,int summary);static void xfs_xexlist_fork (xfs_inode_t *ip,int whichfork);static void xfs_xnode_fork (char *name,xfs_ifork_t *f);
@@ -3828,7 +3828,7 @@ static void xfs_inodebuf(xfs_buf_t *bp) {xfs_dinode_t *di; -xfs_dinode_core_t dic; +xfs_icdinode_t dic;int n, i; n =XFS_BUF_COUNT (bp) >>8 ;
@@ -3836,11 +3836,10 @@ xfs_inodebuf(xfs_buf_t *bp) di = (xfs_dinode_t *)xfs_buf_offset (bp, i *256 ); -xfs_xlate_dinode_core ((xfs_caddr_t)&di->di_core, &dic,1 ); -xfs_prdinode_core (&dic); +xfs_dinode_from_disk (&dic, &di->di_core); +xfs_prdinode_incore (&dic);kdb_printf ("next_unlinked 0x%x u@0x%p\n" , -INT_GET (di->di_next_unlinked,ARCH_CONVERT ), - &di->di_u); +be32_to_cpu (di->di_next_unlinked), &di->di_u); } }
@@ -3981,7 +3980,7 @@ xfs_inval_cached_trace_entry(ktrace_entr* Print disk inode core. */ static void -xfs_prdinode_core (xfs_dinode_core_t *dip) +xfs_prdinode_incore (xfs_icdinode_t *dip) {static char *diflags[] = {"realtime" ,/* XFS_DIFLAG_REALTIME */
@@ -5059,7 +5058,7 @@ xfsidbg_xbuf_real(xfs_buf_t *bp, int sumkdb_printf ("buf 0x%p dir/attr node 0x%p\n" , bp, node);xfsidbg_xdanode (node); } - }else if (INT_GET ((di = d)->di_core.di_magic,ARCH_CONVERT ) ==XFS_DINODE_MAGIC ) { + }else if (be16_to_cpu ((di = d)->di_core.di_magic) ==XFS_DINODE_MAGIC ) {if (summary) {kdb_printf ("Disk Inode (at 0x%p)\n" , di); }else {
@@ -6906,7 +6905,7 @@ xfsidbg_xnode(xfs_inode_t *ip)xfs_xnode_fork ("data" , &ip->i_df);xfs_xnode_fork ("attr" , ip->i_afp);kdb_printf ("\n" ); -xfs_prdinode_core (&ip->i_d); +xfs_prdinode_incore (&ip->i_d); } static void
fs/xfs/linux-2.6/xfs_ksyms.c +1 -1
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(xfs_vfsops);EXPORT_SYMBOL (xfs_vnodeops);EXPORT_SYMBOL (xfs_vtoi);EXPORT_SYMBOL (xfs_write_clear_setuid); -EXPORT_SYMBOL (xfs_xlate_dinode_core); +EXPORT_SYMBOL (xfs_dinode_from_disk);EXPORT_SYMBOL (xfs_xlatesb);EXPORT_SYMBOL (xfs_zero_eof);EXPORT_SYMBOL (xlog_recover_process_iunlinks);
fs/xfs/xfs_inode.h +43 -3
64 lines not on this page · raw message