![Christoph Hellwig](/assets/img/avatar_default.png)
xfs_trans_iget is a wrapper for xfs_iget that adds the inode to the transaction after it is read. Except when the inode already is in the inode cache, in which case it returns the existing locked inode with increment lock recursion counts. Now, no one in the tree every decrements these lock recursion counts, so any user of this gets a potential double unlock when both the original owner of the inode and the xfs_trans_iget caller unlock it. When looking back in a git bisect in the historic XFS tree there was only one place that decremented these counts, xfs_trans_iput. Introduced in commit ca25df7a840f426eb566d52667b6950b92bb84b5 by Adam Sweeney in 1993, and removed in commit 19f899a3ab155ff6a49c0c79b06f2f61059afaf3 by Steve Lord in 2003. And as long as it didn't slip through git bisects cracks never actually used in that time frame. A quick audit of the callers of xfs_trans_iget shows that no caller really relies on this behaviour fortunately - xfs_ialloc allows this inode from disk so it must not be there before, and all the RT allocator routines only every add each RT bitmap inode once. In addition to removing lots of code and reducing the size of the inode item this patch also avoids the double inode cache lookup in each create/mkdir/mknod transaction. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com> Signed-off-by: Felix Blyakher <felixb@sgi.com>
179 lines
6.2 KiB
C
179 lines
6.2 KiB
C
/*
|
|
* Copyright (c) 2000,2005 Silicon Graphics, Inc.
|
|
* All Rights Reserved.
|
|
*
|
|
* 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.
|
|
*
|
|
* This program is distributed in the hope that it would be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write the Free Software Foundation,
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
#ifndef __XFS_INODE_ITEM_H__
|
|
#define __XFS_INODE_ITEM_H__
|
|
|
|
/*
|
|
* This is the structure used to lay out an inode log item in the
|
|
* log. The size of the inline data/extents/b-tree root to be logged
|
|
* (if any) is indicated in the ilf_dsize field. Changes to this structure
|
|
* must be added on to the end.
|
|
*/
|
|
typedef struct xfs_inode_log_format {
|
|
__uint16_t ilf_type; /* inode log item type */
|
|
__uint16_t ilf_size; /* size of this item */
|
|
__uint32_t ilf_fields; /* flags for fields logged */
|
|
__uint16_t ilf_asize; /* size of attr d/ext/root */
|
|
__uint16_t ilf_dsize; /* size of data/ext/root */
|
|
__uint64_t ilf_ino; /* inode number */
|
|
union {
|
|
__uint32_t ilfu_rdev; /* rdev value for dev inode*/
|
|
uuid_t ilfu_uuid; /* mount point value */
|
|
} ilf_u;
|
|
__int64_t ilf_blkno; /* blkno of inode buffer */
|
|
__int32_t ilf_len; /* len of inode buffer */
|
|
__int32_t ilf_boffset; /* off of inode in buffer */
|
|
} xfs_inode_log_format_t;
|
|
|
|
typedef struct xfs_inode_log_format_32 {
|
|
__uint16_t ilf_type; /* inode log item type */
|
|
__uint16_t ilf_size; /* size of this item */
|
|
__uint32_t ilf_fields; /* flags for fields logged */
|
|
__uint16_t ilf_asize; /* size of attr d/ext/root */
|
|
__uint16_t ilf_dsize; /* size of data/ext/root */
|
|
__uint64_t ilf_ino; /* inode number */
|
|
union {
|
|
__uint32_t ilfu_rdev; /* rdev value for dev inode*/
|
|
uuid_t ilfu_uuid; /* mount point value */
|
|
} ilf_u;
|
|
__int64_t ilf_blkno; /* blkno of inode buffer */
|
|
__int32_t ilf_len; /* len of inode buffer */
|
|
__int32_t ilf_boffset; /* off of inode in buffer */
|
|
} __attribute__((packed)) xfs_inode_log_format_32_t;
|
|
|
|
typedef struct xfs_inode_log_format_64 {
|
|
__uint16_t ilf_type; /* inode log item type */
|
|
__uint16_t ilf_size; /* size of this item */
|
|
__uint32_t ilf_fields; /* flags for fields logged */
|
|
__uint16_t ilf_asize; /* size of attr d/ext/root */
|
|
__uint16_t ilf_dsize; /* size of data/ext/root */
|
|
__uint32_t ilf_pad; /* pad for 64 bit boundary */
|
|
__uint64_t ilf_ino; /* inode number */
|
|
union {
|
|
__uint32_t ilfu_rdev; /* rdev value for dev inode*/
|
|
uuid_t ilfu_uuid; /* mount point value */
|
|
} ilf_u;
|
|
__int64_t ilf_blkno; /* blkno of inode buffer */
|
|
__int32_t ilf_len; /* len of inode buffer */
|
|
__int32_t ilf_boffset; /* off of inode in buffer */
|
|
} xfs_inode_log_format_64_t;
|
|
|
|
/*
|
|
* Flags for xfs_trans_log_inode flags field.
|
|
*/
|
|
#define XFS_ILOG_CORE 0x001 /* log standard inode fields */
|
|
#define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */
|
|
#define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
|
|
#define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */
|
|
#define XFS_ILOG_DEV 0x010 /* log the dev field */
|
|
#define XFS_ILOG_UUID 0x020 /* log the uuid field */
|
|
#define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */
|
|
#define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */
|
|
#define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */
|
|
|
|
#define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
|
|
XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
|
|
XFS_ILOG_UUID | XFS_ILOG_ADATA | \
|
|
XFS_ILOG_AEXT | XFS_ILOG_ABROOT)
|
|
|
|
#define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
|
|
XFS_ILOG_DBROOT)
|
|
|
|
#define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
|
|
XFS_ILOG_ABROOT)
|
|
|
|
#define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \
|
|
XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \
|
|
XFS_ILOG_DEV | XFS_ILOG_UUID | \
|
|
XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
|
|
XFS_ILOG_ABROOT)
|
|
|
|
#define XFS_ILI_HOLD 0x1
|
|
#define XFS_ILI_IOLOCKED_EXCL 0x2
|
|
#define XFS_ILI_IOLOCKED_SHARED 0x4
|
|
|
|
#define XFS_ILI_IOLOCKED_ANY (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED)
|
|
|
|
static inline int xfs_ilog_fbroot(int w)
|
|
{
|
|
return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
|
|
}
|
|
|
|
static inline int xfs_ilog_fext(int w)
|
|
{
|
|
return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
|
|
}
|
|
|
|
static inline int xfs_ilog_fdata(int w)
|
|
{
|
|
return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
|
|
}
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
struct xfs_buf;
|
|
struct xfs_bmbt_rec_64;
|
|
struct xfs_inode;
|
|
struct xfs_mount;
|
|
|
|
|
|
typedef struct xfs_inode_log_item {
|
|
xfs_log_item_t ili_item; /* common portion */
|
|
struct xfs_inode *ili_inode; /* inode ptr */
|
|
xfs_lsn_t ili_flush_lsn; /* lsn at last flush */
|
|
xfs_lsn_t ili_last_lsn; /* lsn at last transaction */
|
|
unsigned short ili_flags; /* misc flags */
|
|
unsigned short ili_logged; /* flushed logged data */
|
|
unsigned int ili_last_fields; /* fields when flushed */
|
|
struct xfs_bmbt_rec_64 *ili_extents_buf; /* array of logged
|
|
data exts */
|
|
struct xfs_bmbt_rec_64 *ili_aextents_buf; /* array of logged
|
|
attr exts */
|
|
unsigned int ili_pushbuf_flag; /* one bit used in push_ail */
|
|
|
|
#ifdef DEBUG
|
|
uint64_t ili_push_owner; /* one who sets pushbuf_flag
|
|
above gets to push the buf */
|
|
#endif
|
|
#ifdef XFS_TRANS_DEBUG
|
|
int ili_root_size;
|
|
char *ili_orig_root;
|
|
#endif
|
|
xfs_inode_log_format_t ili_format; /* logged structure */
|
|
} xfs_inode_log_item_t;
|
|
|
|
|
|
static inline int xfs_inode_clean(xfs_inode_t *ip)
|
|
{
|
|
return (!ip->i_itemp ||
|
|
!(ip->i_itemp->ili_format.ilf_fields & XFS_ILOG_ALL)) &&
|
|
!ip->i_update_core;
|
|
}
|
|
|
|
extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
|
|
extern void xfs_inode_item_destroy(struct xfs_inode *);
|
|
extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *);
|
|
extern void xfs_istale_done(struct xfs_buf *, xfs_inode_log_item_t *);
|
|
extern void xfs_iflush_abort(struct xfs_inode *);
|
|
extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
|
|
xfs_inode_log_format_t *);
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* __XFS_INODE_ITEM_H__ */
|