mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
13eaec4b2a
Alex Lyakas reported[1] that mounting an xfs filesystem with new sunit and swidth values could cause xfs_repair to fail loudly. The problem here is that repair calculates the where mkfs should have allocated the root inode, based on the superblock geometry. The allocation decisions depend on sunit, which means that we really can't go updating sunit if it would lead to a subsequent repair failure on an otherwise correct filesystem. Port from xfs_repair some code that computes the location of the root inode and teach mount to skip the ondisk update if it would cause problems for repair. Along the way we'll update the documentation, provide a function for computing the minimum AGFL size instead of open-coding it, and cut down some indenting in the mount code. Note that we allow the mount to proceed (and new allocations will reflect this new geometry) because we've never screened this kind of thing before. We'll have to wait for a new future incompat feature to enforce correct behavior, alas. Note that the geometry reporting always uses the superblock values, not the incore ones, so that is what xfs_info and xfs_growfs will report. [1] https://lore.kernel.org/linux-xfs/20191125130744.GA44777@bfoster/T/#m00f9594b511e076e2fcdd489d78bc30216d72a7d Reported-by: Alex Lyakas <alex@zadara.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
158 lines
5.1 KiB
C
158 lines
5.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2000,2005 Silicon Graphics, Inc.
|
|
* All Rights Reserved.
|
|
*/
|
|
#ifndef __XFS_IALLOC_H__
|
|
#define __XFS_IALLOC_H__
|
|
|
|
struct xfs_buf;
|
|
struct xfs_dinode;
|
|
struct xfs_imap;
|
|
struct xfs_mount;
|
|
struct xfs_trans;
|
|
struct xfs_btree_cur;
|
|
|
|
/* Move inodes in clusters of this size */
|
|
#define XFS_INODE_BIG_CLUSTER_SIZE 8192
|
|
|
|
struct xfs_icluster {
|
|
bool deleted; /* record is deleted */
|
|
xfs_ino_t first_ino; /* first inode number */
|
|
uint64_t alloc; /* inode phys. allocation bitmap for
|
|
* sparse chunks */
|
|
};
|
|
|
|
/*
|
|
* Make an inode pointer out of the buffer/offset.
|
|
*/
|
|
static inline struct xfs_dinode *
|
|
xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
|
|
{
|
|
return xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog);
|
|
}
|
|
|
|
/*
|
|
* Allocate an inode on disk.
|
|
* Mode is used to tell whether the new inode will need space, and whether
|
|
* it is a directory.
|
|
*
|
|
* To work within the constraint of one allocation per transaction,
|
|
* xfs_dialloc() is designed to be called twice if it has to do an
|
|
* allocation to make more free inodes. If an inode is
|
|
* available without an allocation, agbp would be set to the current
|
|
* agbp and alloc_done set to false.
|
|
* If an allocation needed to be done, agbp would be set to the
|
|
* inode header of the allocation group and alloc_done set to true.
|
|
* The caller should then commit the current transaction and allocate a new
|
|
* transaction. xfs_dialloc() should then be called again with
|
|
* the agbp value returned from the previous call.
|
|
*
|
|
* Once we successfully pick an inode its number is returned and the
|
|
* on-disk data structures are updated. The inode itself is not read
|
|
* in, since doing so would break ordering constraints with xfs_reclaim.
|
|
*
|
|
* *agbp should be set to NULL on the first call, *alloc_done set to FALSE.
|
|
*/
|
|
int /* error */
|
|
xfs_dialloc(
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
xfs_ino_t parent, /* parent inode (directory) */
|
|
umode_t mode, /* mode bits for new inode */
|
|
struct xfs_buf **agbp, /* buf for a.g. inode header */
|
|
xfs_ino_t *inop); /* inode number allocated */
|
|
|
|
/*
|
|
* Free disk inode. Carefully avoids touching the incore inode, all
|
|
* manipulations incore are the caller's responsibility.
|
|
* The on-disk inode is not changed by this operation, only the
|
|
* btree (free inode mask) is changed.
|
|
*/
|
|
int /* error */
|
|
xfs_difree(
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
xfs_ino_t inode, /* inode to be freed */
|
|
struct xfs_icluster *ifree); /* cluster info if deleted */
|
|
|
|
/*
|
|
* Return the location of the inode in imap, for mapping it into a buffer.
|
|
*/
|
|
int
|
|
xfs_imap(
|
|
struct xfs_mount *mp, /* file system mount structure */
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
xfs_ino_t ino, /* inode to locate */
|
|
struct xfs_imap *imap, /* location map structure */
|
|
uint flags); /* flags for inode btree lookup */
|
|
|
|
/*
|
|
* Log specified fields for the ag hdr (inode section)
|
|
*/
|
|
void
|
|
xfs_ialloc_log_agi(
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
struct xfs_buf *bp, /* allocation group header buffer */
|
|
int fields); /* bitmask of fields to log */
|
|
|
|
/*
|
|
* Read in the allocation group header (inode allocation section)
|
|
*/
|
|
int /* error */
|
|
xfs_ialloc_read_agi(
|
|
struct xfs_mount *mp, /* file system mount structure */
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
xfs_agnumber_t agno, /* allocation group number */
|
|
struct xfs_buf **bpp); /* allocation group hdr buf */
|
|
|
|
/*
|
|
* Read in the allocation group header to initialise the per-ag data
|
|
* in the mount structure
|
|
*/
|
|
int
|
|
xfs_ialloc_pagi_init(
|
|
struct xfs_mount *mp, /* file system mount structure */
|
|
struct xfs_trans *tp, /* transaction pointer */
|
|
xfs_agnumber_t agno); /* allocation group number */
|
|
|
|
/*
|
|
* Lookup a record by ino in the btree given by cur.
|
|
*/
|
|
int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino,
|
|
xfs_lookup_t dir, int *stat);
|
|
|
|
/*
|
|
* Get the data from the pointed-to record.
|
|
*/
|
|
int xfs_inobt_get_rec(struct xfs_btree_cur *cur,
|
|
xfs_inobt_rec_incore_t *rec, int *stat);
|
|
|
|
/*
|
|
* Inode chunk initialisation routine
|
|
*/
|
|
int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
|
|
struct list_head *buffer_list, int icount,
|
|
xfs_agnumber_t agno, xfs_agblock_t agbno,
|
|
xfs_agblock_t length, unsigned int gen);
|
|
|
|
int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
|
|
xfs_agnumber_t agno, struct xfs_buf **bpp);
|
|
|
|
union xfs_btree_rec;
|
|
void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec,
|
|
struct xfs_inobt_rec_incore *irec);
|
|
int xfs_ialloc_has_inodes_at_extent(struct xfs_btree_cur *cur,
|
|
xfs_agblock_t bno, xfs_extlen_t len, bool *exists);
|
|
int xfs_ialloc_has_inode_record(struct xfs_btree_cur *cur, xfs_agino_t low,
|
|
xfs_agino_t high, bool *exists);
|
|
int xfs_ialloc_count_inodes(struct xfs_btree_cur *cur, xfs_agino_t *count,
|
|
xfs_agino_t *freecount);
|
|
int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask,
|
|
uint8_t count, int32_t freecount, xfs_inofree_t free,
|
|
int *stat);
|
|
|
|
int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
|
|
void xfs_ialloc_setup_geometry(struct xfs_mount *mp);
|
|
xfs_ino_t xfs_ialloc_calc_rootino(struct xfs_mount *mp, int sunit);
|
|
|
|
#endif /* __XFS_IALLOC_H__ */
|