Skip to content

Commit e1d0126

Browse files
committed
Merge tag 'xfs-5.9-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Darrick Wong: "Various small corruption fixes that have come in during the past month: - Avoid a log recovery failure for an insert range operation by rolling deferred ops incrementally instead of at the end. - Fix an off-by-one error when calculating log space reservations for anything involving an inode allocation or free. - Fix a broken shortform xattr verifier. - Ensure that the shortform xattr header padding is always initialized to zero" * tag 'xfs-5.9-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: initialize the shortform attr header padding entry xfs: fix boundary test in xfs_attr_shortform_verify xfs: fix off-by-one in inode alloc block reservation calculation xfs: finish dfops on every insert range shift iteration
2 parents 54e54d5 + 125eac2 commit e1d0126

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ xfs_attr_shortform_create(
653653
ASSERT(ifp->if_flags & XFS_IFINLINE);
654654
}
655655
xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
656-
hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
657-
hdr->count = 0;
656+
hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
657+
memset(hdr, 0, sizeof(*hdr));
658658
hdr->totsize = cpu_to_be16(sizeof(*hdr));
659659
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
660660
}
@@ -1036,8 +1036,10 @@ xfs_attr_shortform_verify(
10361036
* struct xfs_attr_sf_entry has a variable length.
10371037
* Check the fixed-offset parts of the structure are
10381038
* within the data buffer.
1039+
* xfs_attr_sf_entry is defined with a 1-byte variable
1040+
* array at the end, so we must subtract that off.
10391041
*/
1040-
if (((char *)sfep + sizeof(*sfep)) >= endp)
1042+
if (((char *)sfep + sizeof(*sfep) - 1) >= endp)
10411043
return __this_address;
10421044

10431045
/* Don't allow names with known bad length. */

fs/xfs/libxfs/xfs_ialloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ xfs_ialloc_ag_alloc(
688688
args.minalignslop = igeo->cluster_align - 1;
689689

690690
/* Allow space for the inode btree to split. */
691-
args.minleft = igeo->inobt_maxlevels - 1;
691+
args.minleft = igeo->inobt_maxlevels;
692692
if ((error = xfs_alloc_vextent(&args)))
693693
return error;
694694

@@ -736,7 +736,7 @@ xfs_ialloc_ag_alloc(
736736
/*
737737
* Allow space for the inode btree to split.
738738
*/
739-
args.minleft = igeo->inobt_maxlevels - 1;
739+
args.minleft = igeo->inobt_maxlevels;
740740
if ((error = xfs_alloc_vextent(&args)))
741741
return error;
742742
}

fs/xfs/libxfs/xfs_trans_space.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#define XFS_IALLOC_SPACE_RES(mp) \
5959
(M_IGEO(mp)->ialloc_blks + \
6060
((xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1) * \
61-
(M_IGEO(mp)->inobt_maxlevels - 1)))
61+
M_IGEO(mp)->inobt_maxlevels))
6262

6363
/*
6464
* Space reservation values for various transactions.

fs/xfs/xfs_bmap_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ xfs_insert_file_space(
11651165
goto out_trans_cancel;
11661166

11671167
do {
1168-
error = xfs_trans_roll_inode(&tp, ip);
1168+
error = xfs_defer_finish(&tp);
11691169
if (error)
11701170
goto out_trans_cancel;
11711171

0 commit comments

Comments
 (0)