Skip to content

Commit 50caca9

Browse files
committed
Merge tag 'xfs-5.5-merge-17' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Darrick Wong: "Fix a couple of resource management errors and a hang: - fix a crash in the log setup code when log mounting fails - fix a hang when allocating space on the realtime device - fix a block leak when freeing space on the realtime device" * tag 'xfs-5.5-merge-17' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: fix mount failure crash on invalid iclog memory access xfs: don't check for AG deadlock for realtime files in bunmapi xfs: fix realtime file data space leak
2 parents 316933c + 798a9ca commit 50caca9

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5404,7 +5404,7 @@ __xfs_bunmapi(
54045404
* Make sure we don't touch multiple AGF headers out of order
54055405
* in a single transaction, as that could cause AB-BA deadlocks.
54065406
*/
5407-
if (!wasdel) {
5407+
if (!wasdel && !isrt) {
54085408
agno = XFS_FSB_TO_AGNO(mp, del.br_startblock);
54095409
if (prev_agno != NULLAGNUMBER && prev_agno > agno)
54105410
break;
@@ -5480,16 +5480,17 @@ __xfs_bunmapi(
54805480
}
54815481
div_u64_rem(del.br_startblock, mp->m_sb.sb_rextsize, &mod);
54825482
if (mod) {
5483+
xfs_extlen_t off = mp->m_sb.sb_rextsize - mod;
5484+
54835485
/*
54845486
* Realtime extent is lined up at the end but not
54855487
* at the front. We'll get rid of full extents if
54865488
* we can.
54875489
*/
5488-
mod = mp->m_sb.sb_rextsize - mod;
5489-
if (del.br_blockcount > mod) {
5490-
del.br_blockcount -= mod;
5491-
del.br_startoff += mod;
5492-
del.br_startblock += mod;
5490+
if (del.br_blockcount > off) {
5491+
del.br_blockcount -= off;
5492+
del.br_startoff += off;
5493+
del.br_startblock += off;
54935494
} else if (del.br_startoff == start &&
54945495
(del.br_state == XFS_EXT_UNWRITTEN ||
54955496
tp->t_blk_res == 0)) {
@@ -5507,6 +5508,7 @@ __xfs_bunmapi(
55075508
continue;
55085509
} else if (del.br_state == XFS_EXT_UNWRITTEN) {
55095510
struct xfs_bmbt_irec prev;
5511+
xfs_fileoff_t unwrite_start;
55105512

55115513
/*
55125514
* This one is already unwritten.
@@ -5520,12 +5522,13 @@ __xfs_bunmapi(
55205522
ASSERT(!isnullstartblock(prev.br_startblock));
55215523
ASSERT(del.br_startblock ==
55225524
prev.br_startblock + prev.br_blockcount);
5523-
if (prev.br_startoff < start) {
5524-
mod = start - prev.br_startoff;
5525-
prev.br_blockcount -= mod;
5526-
prev.br_startblock += mod;
5527-
prev.br_startoff = start;
5528-
}
5525+
unwrite_start = max3(start,
5526+
del.br_startoff - mod,
5527+
prev.br_startoff);
5528+
mod = unwrite_start - prev.br_startoff;
5529+
prev.br_startoff = unwrite_start;
5530+
prev.br_startblock += mod;
5531+
prev.br_blockcount -= mod;
55295532
prev.br_state = XFS_EXT_UNWRITTEN;
55305533
error = xfs_bmap_add_extent_unwritten_real(tp,
55315534
ip, whichfork, &icur, &cur,

fs/xfs/xfs_log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,8 @@ xlog_alloc_log(
15421542
prev_iclog = iclog->ic_next;
15431543
kmem_free(iclog->ic_data);
15441544
kmem_free(iclog);
1545+
if (prev_iclog == log->l_iclog)
1546+
break;
15451547
}
15461548
out_free_log:
15471549
kmem_free(log);

0 commit comments

Comments
 (0)