Commit 56d1115c authored by Brian Foster's avatar Brian Foster Committed by Dave Chinner

xfs: allocate sparse inode chunks on full chunk allocation failure

xfs_ialloc_ag_alloc() makes several attempts to allocate a full inode
chunk. If all else fails, reduce the allocation to the sparse length and
alignment and attempt to allocate a sparse inode chunk.

If sparse chunk allocation succeeds, check whether an inobt record
already exists that can track the chunk. If so, inherit and update the
existing record. Otherwise, insert a new record for the sparse chunk.

Create helpers to align sparse chunk inode records and insert or update
existing records in the inode btrees. The xfs_inobt_insert_sprec()
helper implements the merge or update semantics required for sparse
inode records with respect to both the inobt and finobt. To update the
inobt, either insert a new record or merge with an existing record. To
update the finobt, use the updated inobt record to either insert or
replace an existing record.
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 4148c347
This diff is collapsed.
...@@ -478,3 +478,34 @@ xfs_inobt_irec_to_allocmask( ...@@ -478,3 +478,34 @@ xfs_inobt_irec_to_allocmask(
return bitmap; return bitmap;
} }
#if defined(DEBUG) || defined(XFS_WARN)
/*
* Verify that an in-core inode record has a valid inode count.
*/
int
xfs_inobt_rec_check_count(
struct xfs_mount *mp,
struct xfs_inobt_rec_incore *rec)
{
int inocount = 0;
int nextbit = 0;
uint64_t allocbmap;
int wordsz;
wordsz = sizeof(allocbmap) / sizeof(unsigned int);
allocbmap = xfs_inobt_irec_to_allocmask(rec);
nextbit = xfs_next_bit((uint *) &allocbmap, wordsz, nextbit);
while (nextbit != -1) {
inocount++;
nextbit = xfs_next_bit((uint *) &allocbmap, wordsz,
nextbit + 1);
}
if (inocount != rec->ir_count)
return -EFSCORRUPTED;
return 0;
}
#endif /* DEBUG */
...@@ -65,4 +65,11 @@ extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int); ...@@ -65,4 +65,11 @@ extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int);
/* ir_holemask to inode allocation bitmap conversion */ /* ir_holemask to inode allocation bitmap conversion */
uint64_t xfs_inobt_irec_to_allocmask(struct xfs_inobt_rec_incore *); uint64_t xfs_inobt_irec_to_allocmask(struct xfs_inobt_rec_incore *);
#if defined(DEBUG) || defined(XFS_WARN)
int xfs_inobt_rec_check_count(struct xfs_mount *,
struct xfs_inobt_rec_incore *);
#else
#define xfs_inobt_rec_check_count(mp, rec) 0
#endif /* DEBUG */
#endif /* __XFS_IALLOC_BTREE_H__ */ #endif /* __XFS_IALLOC_BTREE_H__ */
...@@ -738,6 +738,53 @@ TRACE_EVENT(xfs_iomap_prealloc_size, ...@@ -738,6 +738,53 @@ TRACE_EVENT(xfs_iomap_prealloc_size,
__entry->blocks, __entry->shift, __entry->writeio_blocks) __entry->blocks, __entry->shift, __entry->writeio_blocks)
) )
TRACE_EVENT(xfs_irec_merge_pre,
TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
uint16_t holemask, xfs_agino_t nagino, uint16_t nholemask),
TP_ARGS(mp, agno, agino, holemask, nagino, nholemask),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(xfs_agnumber_t, agno)
__field(xfs_agino_t, agino)
__field(uint16_t, holemask)
__field(xfs_agino_t, nagino)
__field(uint16_t, nholemask)
),
TP_fast_assign(
__entry->dev = mp->m_super->s_dev;
__entry->agno = agno;
__entry->agino = agino;
__entry->holemask = holemask;
__entry->nagino = nagino;
__entry->nholemask = holemask;
),
TP_printk("dev %d:%d agno %d inobt (%u:0x%x) new (%u:0x%x)",
MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno,
__entry->agino, __entry->holemask, __entry->nagino,
__entry->nholemask)
)
TRACE_EVENT(xfs_irec_merge_post,
TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
uint16_t holemask),
TP_ARGS(mp, agno, agino, holemask),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(xfs_agnumber_t, agno)
__field(xfs_agino_t, agino)
__field(uint16_t, holemask)
),
TP_fast_assign(
__entry->dev = mp->m_super->s_dev;
__entry->agno = agno;
__entry->agino = agino;
__entry->holemask = holemask;
),
TP_printk("dev %d:%d agno %d inobt (%u:0x%x)", MAJOR(__entry->dev),
MINOR(__entry->dev), __entry->agno, __entry->agino,
__entry->holemask)
)
#define DEFINE_IREF_EVENT(name) \ #define DEFINE_IREF_EVENT(name) \
DEFINE_EVENT(xfs_iref_class, name, \ DEFINE_EVENT(xfs_iref_class, name, \
TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \ TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment