Skip to content

Commit d3426a6

Browse files
committed
Merge tag 'xfs-6.11-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Chandan Babu: - Fix memory leak when corruption is detected during scrubbing parent pointers - Allow SECURE namespace xattrs to use reserved block pool to in order to prevent ENOSPC - Save stack space by passing tracepoint's char array to file_path() instead of another stack variable - Remove unused parameter in macro XFS_DQUOT_LOGRES - Replace comma with semicolon in a couple of places * tag 'xfs-6.11-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: convert comma to semicolon xfs: convert comma to semicolon xfs: remove unused parameter in macro XFS_DQUOT_LOGRES xfs: fix file_path handling in tracepoints xfs: allow SECURE namespace xattrs to use reserved block pool xfs: fix a memory leak
2 parents 1dd950f + 7bf888f commit d3426a6

File tree

8 files changed

+44
-31
lines changed

8 files changed

+44
-31
lines changed

fs/xfs/libxfs/xfs_quota_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ typedef uint8_t xfs_dqtype_t;
5656
* And, of course, we also need to take into account the dquot log format item
5757
* used to describe each dquot.
5858
*/
59-
#define XFS_DQUOT_LOGRES(mp) \
59+
#define XFS_DQUOT_LOGRES \
6060
((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6)
6161

6262
#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)

fs/xfs/libxfs/xfs_trans_resv.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,11 @@ xfs_calc_write_reservation(
338338
blksz);
339339
t1 += adj;
340340
t3 += adj;
341-
return XFS_DQUOT_LOGRES(mp) + max3(t1, t2, t3);
341+
return XFS_DQUOT_LOGRES + max3(t1, t2, t3);
342342
}
343343

344344
t4 = xfs_calc_refcountbt_reservation(mp, 1);
345-
return XFS_DQUOT_LOGRES(mp) + max(t4, max3(t1, t2, t3));
345+
return XFS_DQUOT_LOGRES + max(t4, max3(t1, t2, t3));
346346
}
347347

348348
unsigned int
@@ -410,11 +410,11 @@ xfs_calc_itruncate_reservation(
410410
xfs_refcountbt_block_count(mp, 4),
411411
blksz);
412412

413-
return XFS_DQUOT_LOGRES(mp) + max3(t1, t2, t3);
413+
return XFS_DQUOT_LOGRES + max3(t1, t2, t3);
414414
}
415415

416416
t4 = xfs_calc_refcountbt_reservation(mp, 2);
417-
return XFS_DQUOT_LOGRES(mp) + max(t4, max3(t1, t2, t3));
417+
return XFS_DQUOT_LOGRES + max(t4, max3(t1, t2, t3));
418418
}
419419

420420
unsigned int
@@ -466,7 +466,7 @@ STATIC uint
466466
xfs_calc_rename_reservation(
467467
struct xfs_mount *mp)
468468
{
469-
unsigned int overhead = XFS_DQUOT_LOGRES(mp);
469+
unsigned int overhead = XFS_DQUOT_LOGRES;
470470
struct xfs_trans_resv *resp = M_RES(mp);
471471
unsigned int t1, t2, t3 = 0;
472472

@@ -577,7 +577,7 @@ STATIC uint
577577
xfs_calc_link_reservation(
578578
struct xfs_mount *mp)
579579
{
580-
unsigned int overhead = XFS_DQUOT_LOGRES(mp);
580+
unsigned int overhead = XFS_DQUOT_LOGRES;
581581
struct xfs_trans_resv *resp = M_RES(mp);
582582
unsigned int t1, t2, t3 = 0;
583583

@@ -641,7 +641,7 @@ STATIC uint
641641
xfs_calc_remove_reservation(
642642
struct xfs_mount *mp)
643643
{
644-
unsigned int overhead = XFS_DQUOT_LOGRES(mp);
644+
unsigned int overhead = XFS_DQUOT_LOGRES;
645645
struct xfs_trans_resv *resp = M_RES(mp);
646646
unsigned int t1, t2, t3 = 0;
647647

@@ -729,7 +729,7 @@ xfs_calc_icreate_reservation(
729729
struct xfs_mount *mp)
730730
{
731731
struct xfs_trans_resv *resp = M_RES(mp);
732-
unsigned int overhead = XFS_DQUOT_LOGRES(mp);
732+
unsigned int overhead = XFS_DQUOT_LOGRES;
733733
unsigned int t1, t2, t3 = 0;
734734

735735
t1 = xfs_calc_icreate_resv_alloc(mp);
@@ -747,7 +747,7 @@ STATIC uint
747747
xfs_calc_create_tmpfile_reservation(
748748
struct xfs_mount *mp)
749749
{
750-
uint res = XFS_DQUOT_LOGRES(mp);
750+
uint res = XFS_DQUOT_LOGRES;
751751

752752
res += xfs_calc_icreate_resv_alloc(mp);
753753
return res + xfs_calc_iunlink_add_reservation(mp);
@@ -829,7 +829,7 @@ STATIC uint
829829
xfs_calc_ifree_reservation(
830830
struct xfs_mount *mp)
831831
{
832-
return XFS_DQUOT_LOGRES(mp) +
832+
return XFS_DQUOT_LOGRES +
833833
xfs_calc_inode_res(mp, 1) +
834834
xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
835835
xfs_calc_iunlink_remove_reservation(mp) +
@@ -846,7 +846,7 @@ STATIC uint
846846
xfs_calc_ichange_reservation(
847847
struct xfs_mount *mp)
848848
{
849-
return XFS_DQUOT_LOGRES(mp) +
849+
return XFS_DQUOT_LOGRES +
850850
xfs_calc_inode_res(mp, 1) +
851851
xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
852852

@@ -955,7 +955,7 @@ STATIC uint
955955
xfs_calc_addafork_reservation(
956956
struct xfs_mount *mp)
957957
{
958-
return XFS_DQUOT_LOGRES(mp) +
958+
return XFS_DQUOT_LOGRES +
959959
xfs_calc_inode_res(mp, 1) +
960960
xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
961961
xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
@@ -1003,7 +1003,7 @@ STATIC uint
10031003
xfs_calc_attrsetm_reservation(
10041004
struct xfs_mount *mp)
10051005
{
1006-
return XFS_DQUOT_LOGRES(mp) +
1006+
return XFS_DQUOT_LOGRES +
10071007
xfs_calc_inode_res(mp, 1) +
10081008
xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
10091009
xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH, XFS_FSB_TO_B(mp, 1));
@@ -1043,7 +1043,7 @@ STATIC uint
10431043
xfs_calc_attrrm_reservation(
10441044
struct xfs_mount *mp)
10451045
{
1046-
return XFS_DQUOT_LOGRES(mp) +
1046+
return XFS_DQUOT_LOGRES +
10471047
max((xfs_calc_inode_res(mp, 1) +
10481048
xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH,
10491049
XFS_FSB_TO_B(mp, 1)) +

fs/xfs/scrub/agheader_repair.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ xrep_agfl_init_header(
696696
* step.
697697
*/
698698
xagb_bitmap_init(&af.used_extents);
699-
af.agfl_bno = xfs_buf_to_agfl_bno(agfl_bp),
699+
af.agfl_bno = xfs_buf_to_agfl_bno(agfl_bp);
700700
xagb_bitmap_walk(agfl_extents, xrep_agfl_fill, &af);
701701
error = xagb_bitmap_disunion(agfl_extents, &af.used_extents);
702702
if (error)

fs/xfs/scrub/parent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ xchk_parent_pptr(
799799
}
800800

801801
if (pp->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
802-
goto out_pp;
802+
goto out_names;
803803

804804
/*
805805
* Complain if the number of parent pointers doesn't match the link

fs/xfs/scrub/trace.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,18 +959,16 @@ TRACE_EVENT(xfile_create,
959959
TP_STRUCT__entry(
960960
__field(dev_t, dev)
961961
__field(unsigned long, ino)
962-
__array(char, pathname, 256)
962+
__array(char, pathname, MAXNAMELEN)
963963
),
964964
TP_fast_assign(
965-
char pathname[257];
966965
char *path;
967966

968967
__entry->ino = file_inode(xf->file)->i_ino;
969-
memset(pathname, 0, sizeof(pathname));
970-
path = file_path(xf->file, pathname, sizeof(pathname) - 1);
968+
path = file_path(xf->file, __entry->pathname, MAXNAMELEN);
971969
if (IS_ERR(path))
972-
path = "(unknown)";
973-
strncpy(__entry->pathname, path, sizeof(__entry->pathname));
970+
strncpy(__entry->pathname, "(unknown)",
971+
sizeof(__entry->pathname));
974972
),
975973
TP_printk("xfino 0x%lx path '%s'",
976974
__entry->ino,

fs/xfs/xfs_attr_list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ xfs_attr_shortform_list(
139139
sbp->name = sfe->nameval;
140140
sbp->namelen = sfe->namelen;
141141
/* These are bytes, and both on-disk, don't endian-flip */
142-
sbp->value = &sfe->nameval[sfe->namelen],
142+
sbp->value = &sfe->nameval[sfe->namelen];
143143
sbp->valuelen = sfe->valuelen;
144144
sbp->flags = sfe->flags;
145145
sbp->hash = xfs_attr_hashval(dp->i_mount, sfe->flags,

fs/xfs/xfs_trace.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4715,20 +4715,18 @@ TRACE_EVENT(xmbuf_create,
47154715
TP_STRUCT__entry(
47164716
__field(dev_t, dev)
47174717
__field(unsigned long, ino)
4718-
__array(char, pathname, 256)
4718+
__array(char, pathname, MAXNAMELEN)
47194719
),
47204720
TP_fast_assign(
4721-
char pathname[257];
47224721
char *path;
47234722
struct file *file = btp->bt_file;
47244723

47254724
__entry->dev = btp->bt_mount->m_super->s_dev;
47264725
__entry->ino = file_inode(file)->i_ino;
4727-
memset(pathname, 0, sizeof(pathname));
4728-
path = file_path(file, pathname, sizeof(pathname) - 1);
4726+
path = file_path(file, __entry->pathname, MAXNAMELEN);
47294727
if (IS_ERR(path))
4730-
path = "(unknown)";
4731-
strncpy(__entry->pathname, path, sizeof(__entry->pathname));
4728+
strncpy(__entry->pathname, "(unknown)",
4729+
sizeof(__entry->pathname));
47324730
),
47334731
TP_printk("dev %d:%d xmino 0x%lx path '%s'",
47344732
MAJOR(__entry->dev), MINOR(__entry->dev),

fs/xfs/xfs_xattr.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,24 @@ xfs_attr_change(
110110
args->whichfork = XFS_ATTR_FORK;
111111
xfs_attr_sethash(args);
112112

113-
return xfs_attr_set(args, op, args->attr_filter & XFS_ATTR_ROOT);
113+
/*
114+
* Some xattrs must be resistant to allocation failure at ENOSPC, e.g.
115+
* creating an inode with ACLs or security attributes requires the
116+
* allocation of the xattr holding that information to succeed. Hence
117+
* we allow xattrs in the VFS TRUSTED, SYSTEM, POSIX_ACL and SECURITY
118+
* (LSM xattr) namespaces to dip into the reserve block pool to allow
119+
* manipulation of these xattrs when at ENOSPC. These VFS xattr
120+
* namespaces translate to the XFS_ATTR_ROOT and XFS_ATTR_SECURE on-disk
121+
* namespaces.
122+
*
123+
* For most of these cases, these special xattrs will fit in the inode
124+
* itself and so consume no extra space or only require temporary extra
125+
* space while an overwrite is being made. Hence the use of the reserved
126+
* pool is largely to avoid the worst case reservation from preventing
127+
* the xattr from being created at ENOSPC.
128+
*/
129+
return xfs_attr_set(args, op,
130+
args->attr_filter & (XFS_ATTR_ROOT | XFS_ATTR_SECURE));
114131
}
115132

116133

0 commit comments

Comments
 (0)