forked from Minki/linux
f59cf5c299
If we create a new file we will need an inode, and usually some metadata in the parent direction. Aiming for everything to go well despite the lack of a reservation leads to dirty transactions cancelled under a heavy create/delete load. This patch removes those nospace transactions, which will lead to slightly earlier ENOSPC on some workloads, but instead prevent file system shutdowns due to cancelling dirty transactions for others. A customer could observe assertations failures and shutdowns due to cancelation of dirty transactions during heavy NFS workloads as shown below: 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728125] XFS: Assertion failed: error != -ENOSPC, file: fs/xfs/xfs_inode.c, line: 1262 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728222] Call Trace: 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728246] [<ffffffff81795daf>] dump_stack+0x63/0x81 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728262] [<ffffffff810a1a5a>] warn_slowpath_common+0x8a/0xc0 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728264] [<ffffffff810a1b8a>] warn_slowpath_null+0x1a/0x20 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728285] [<ffffffffa01bf403>] asswarn+0x33/0x40 [xfs] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728308] [<ffffffffa01bb07e>] xfs_create+0x7be/0x7d0 [xfs] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728329] [<ffffffffa01b6ffb>] xfs_generic_create+0x1fb/0x2e0 [xfs] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728348] [<ffffffffa01b7114>] xfs_vn_mknod+0x14/0x20 [xfs] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728366] [<ffffffffa01b7153>] xfs_vn_create+0x13/0x20 [xfs] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728380] [<ffffffff81231de5>] vfs_create+0xd5/0x140 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728390] [<ffffffffa045ddb9>] do_nfsd_create+0x499/0x610 [nfsd] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728396] [<ffffffffa0465fa5>] nfsd3_proc_create+0x135/0x210 [nfsd] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728401] [<ffffffffa04561e3>] nfsd_dispatch+0xc3/0x210 [nfsd] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728416] [<ffffffffa03bfa43>] svc_process_common+0x453/0x6f0 [sunrpc] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728423] [<ffffffffa03bfdf3>] svc_process+0x113/0x1f0 [sunrpc] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728427] [<ffffffffa0455bcf>] nfsd+0x10f/0x180 [nfsd] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728432] [<ffffffffa0455ac0>] ? nfsd_destroy+0x80/0x80 [nfsd] 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728438] [<ffffffff810c0d58>] kthread+0xd8/0xf0 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728441] [<ffffffff810c0c80>] ? kthread_create_on_node+0x1b0/0x1b0 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728451] [<ffffffff8179d962>] ret_from_fork+0x42/0x70 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728453] [<ffffffff810c0c80>] ? kthread_create_on_node+0x1b0/0x1b0 2017-05-30 21:17:06 kernel: WARNING: [ 2670.728454] ---[ end trace f9822c842fec81d4 ]--- 2017-05-30 21:17:06 kernel: ALERT: [ 2670.728477] XFS (sdb): Internal error xfs_trans_cancel at line 983 of file fs/xfs/xfs_trans.c. Caller xfs_create+0x4ee/0x7d0 [xfs] 2017-05-30 21:17:06 kernel: ALERT: [ 2670.728684] XFS (sdb): Corruption of in-memory data detected. Shutting down filesystem 2017-05-30 21:17:06 kernel: ALERT: [ 2670.728685] XFS (sdb): Please umount the filesystem and rectify the problem(s) Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
184 lines
6.0 KiB
C
184 lines
6.0 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_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 */
|
|
};
|
|
|
|
/* Calculate and return the number of filesystem blocks per inode cluster */
|
|
static inline int
|
|
xfs_icluster_size_fsb(
|
|
struct xfs_mount *mp)
|
|
{
|
|
if (mp->m_sb.sb_blocksize >= mp->m_inode_cluster_size)
|
|
return 1;
|
|
return mp->m_inode_cluster_size >> mp->m_sb.sb_blocklog;
|
|
}
|
|
|
|
/*
|
|
* 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_defer_ops *dfops, /* extents to free */
|
|
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 */
|
|
|
|
/*
|
|
* Compute and fill in value of m_in_maxlevels.
|
|
*/
|
|
void
|
|
xfs_ialloc_compute_maxlevels(
|
|
struct xfs_mount *mp); /* file system mount structure */
|
|
|
|
/*
|
|
* 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_cluster_alignment(struct xfs_mount *mp);
|
|
void xfs_ialloc_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
|
|
xfs_agino_t *first, xfs_agino_t *last);
|
|
bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno,
|
|
xfs_agino_t agino);
|
|
bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
|
|
bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
|
|
bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
|
|
|
|
#endif /* __XFS_IALLOC_H__ */
|