Skip to content

Commit e02003b

Browse files
committed
Merge tag 'xfs-for-linus-4.10-rc3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Darrick Wong: - fixes for crashes and double-cleanup errors - XFS maintainership handover - fix to prevent absurdly large block reservations - fix broken sysfs getter/setters * tag 'xfs-for-linus-4.10-rc3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: fix max_retries _show and _store functions xfs: update MAINTAINERS xfs: fix crash and data corruption due to removal of busy COW extents xfs: use the actual AG length when reserving blocks xfs: fix double-cleanup when CUI recovery fails
2 parents 4cf1846 + ff97f23 commit e02003b

File tree

10 files changed

+42
-18
lines changed

10 files changed

+42
-18
lines changed

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13534,11 +13534,11 @@ F: arch/x86/xen/*swiotlb*
1353413534
F: drivers/xen/*swiotlb*
1353513535

1353613536
XFS FILESYSTEM
13537-
M: Dave Chinner <david@fromorbit.com>
13537+
M: Darrick J. Wong <darrick.wong@oracle.com>
1353813538
M: linux-xfs@vger.kernel.org
1353913539
L: linux-xfs@vger.kernel.org
1354013540
W: http://xfs.org/
13541-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git
13541+
T: git git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git
1354213542
S: Supported
1354313543
F: Documentation/filesystems/xfs.txt
1354413544
F: fs/xfs/

fs/xfs/libxfs/xfs_ag_resv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ xfs_ag_resv_init(
256256
goto out;
257257
}
258258

259+
ASSERT(xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved +
260+
xfs_perag_resv(pag, XFS_AG_RESV_AGFL)->ar_reserved <=
261+
pag->pagf_freeblks + pag->pagf_flcount);
259262
out:
260263
return error;
261264
}

fs/xfs/libxfs/xfs_refcount_btree.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,14 @@ xfs_refcountbt_calc_size(
409409
*/
410410
xfs_extlen_t
411411
xfs_refcountbt_max_size(
412-
struct xfs_mount *mp)
412+
struct xfs_mount *mp,
413+
xfs_agblock_t agblocks)
413414
{
414415
/* Bail out if we're uninitialized, which can happen in mkfs. */
415416
if (mp->m_refc_mxr[0] == 0)
416417
return 0;
417418

418-
return xfs_refcountbt_calc_size(mp, mp->m_sb.sb_agblocks);
419+
return xfs_refcountbt_calc_size(mp, agblocks);
419420
}
420421

421422
/*
@@ -430,22 +431,24 @@ xfs_refcountbt_calc_reserves(
430431
{
431432
struct xfs_buf *agbp;
432433
struct xfs_agf *agf;
434+
xfs_agblock_t agblocks;
433435
xfs_extlen_t tree_len;
434436
int error;
435437

436438
if (!xfs_sb_version_hasreflink(&mp->m_sb))
437439
return 0;
438440

439-
*ask += xfs_refcountbt_max_size(mp);
440441

441442
error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
442443
if (error)
443444
return error;
444445

445446
agf = XFS_BUF_TO_AGF(agbp);
447+
agblocks = be32_to_cpu(agf->agf_length);
446448
tree_len = be32_to_cpu(agf->agf_refcount_blocks);
447449
xfs_buf_relse(agbp);
448450

451+
*ask += xfs_refcountbt_max_size(mp, agblocks);
449452
*used += tree_len;
450453

451454
return error;

fs/xfs/libxfs/xfs_refcount_btree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
6666

6767
extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
6868
unsigned long long len);
69-
extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp);
69+
extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
70+
xfs_agblock_t agblocks);
7071

7172
extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
7273
xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);

fs/xfs/libxfs/xfs_rmap_btree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,14 @@ xfs_rmapbt_calc_size(
550550
*/
551551
xfs_extlen_t
552552
xfs_rmapbt_max_size(
553-
struct xfs_mount *mp)
553+
struct xfs_mount *mp,
554+
xfs_agblock_t agblocks)
554555
{
555556
/* Bail out if we're uninitialized, which can happen in mkfs. */
556557
if (mp->m_rmap_mxr[0] == 0)
557558
return 0;
558559

559-
return xfs_rmapbt_calc_size(mp, mp->m_sb.sb_agblocks);
560+
return xfs_rmapbt_calc_size(mp, agblocks);
560561
}
561562

562563
/*
@@ -571,25 +572,24 @@ xfs_rmapbt_calc_reserves(
571572
{
572573
struct xfs_buf *agbp;
573574
struct xfs_agf *agf;
574-
xfs_extlen_t pool_len;
575+
xfs_agblock_t agblocks;
575576
xfs_extlen_t tree_len;
576577
int error;
577578

578579
if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
579580
return 0;
580581

581-
/* Reserve 1% of the AG or enough for 1 block per record. */
582-
pool_len = max(mp->m_sb.sb_agblocks / 100, xfs_rmapbt_max_size(mp));
583-
*ask += pool_len;
584-
585582
error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
586583
if (error)
587584
return error;
588585

589586
agf = XFS_BUF_TO_AGF(agbp);
587+
agblocks = be32_to_cpu(agf->agf_length);
590588
tree_len = be32_to_cpu(agf->agf_rmap_blocks);
591589
xfs_buf_relse(agbp);
592590

591+
/* Reserve 1% of the AG or enough for 1 block per record. */
592+
*ask += max(agblocks / 100, xfs_rmapbt_max_size(mp, agblocks));
593593
*used += tree_len;
594594

595595
return error;

fs/xfs/libxfs/xfs_rmap_btree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp);
6060

6161
extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
6262
unsigned long long len);
63-
extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp);
63+
extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
64+
xfs_agblock_t agblocks);
6465

6566
extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
6667
xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);

fs/xfs/xfs_fsops.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,20 @@ xfs_growfs_data_private(
631631
xfs_set_low_space_thresholds(mp);
632632
mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
633633

634+
/*
635+
* If we expanded the last AG, free the per-AG reservation
636+
* so we can reinitialize it with the new size.
637+
*/
638+
if (new) {
639+
struct xfs_perag *pag;
640+
641+
pag = xfs_perag_get(mp, agno);
642+
error = xfs_ag_resv_free(pag);
643+
xfs_perag_put(pag);
644+
if (error)
645+
goto out;
646+
}
647+
634648
/* Reserve AG metadata blocks. */
635649
error = xfs_fs_reserve_ag_blocks(mp);
636650
if (error && error != -ENOSPC)

fs/xfs/xfs_icache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,8 @@ xfs_inode_free_cowblocks(
15971597
* If the mapping is dirty or under writeback we cannot touch the
15981598
* CoW fork. Leave it alone if we're in the midst of a directio.
15991599
*/
1600-
if (mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) ||
1600+
if ((VFS_I(ip)->i_state & I_DIRTY_PAGES) ||
1601+
mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY) ||
16011602
mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_WRITEBACK) ||
16021603
atomic_read(&VFS_I(ip)->i_dio_count))
16031604
return 0;

fs/xfs/xfs_refcount_item.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,14 @@ xfs_cui_recover(
526526
xfs_refcount_finish_one_cleanup(tp, rcur, error);
527527
error = xfs_defer_finish(&tp, &dfops, NULL);
528528
if (error)
529-
goto abort_error;
529+
goto abort_defer;
530530
set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags);
531531
error = xfs_trans_commit(tp);
532532
return error;
533533

534534
abort_error:
535535
xfs_refcount_finish_one_cleanup(tp, rcur, error);
536+
abort_defer:
536537
xfs_defer_cancel(&dfops);
537538
xfs_trans_cancel(tp);
538539
return error;

fs/xfs/xfs_sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ max_retries_show(
396396
int retries;
397397
struct xfs_error_cfg *cfg = to_error_cfg(kobject);
398398

399-
if (cfg->retry_timeout == XFS_ERR_RETRY_FOREVER)
399+
if (cfg->max_retries == XFS_ERR_RETRY_FOREVER)
400400
retries = -1;
401401
else
402402
retries = cfg->max_retries;
@@ -422,7 +422,7 @@ max_retries_store(
422422
return -EINVAL;
423423

424424
if (val == -1)
425-
cfg->retry_timeout = XFS_ERR_RETRY_FOREVER;
425+
cfg->max_retries = XFS_ERR_RETRY_FOREVER;
426426
else
427427
cfg->max_retries = val;
428428
return count;

0 commit comments

Comments
 (0)