Skip to content

Commit 16d9154

Browse files
committed
Merge tag 'xfs-5.8-merge-8' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs updates from Darrick Wong: "Most of the changes this cycle are refactoring of existing code in preparation for things landing in the future. We also fixed various problems and deficiencies in the quota implementation, and (I hope) the last of the stale read vectors by forcing write allocations to go through the unwritten state until the write completes. Summary: - Various cleanups to remove dead code, unnecessary conditionals, asserts, etc. - Fix a linker warning caused by xfs stuffing '-g' into CFLAGS redundantly. - Tighten up our dmesg logging to ensure that everything is prefixed with 'XFS' for easier grepping. - Kill a bunch of typedefs. - Refactor the deferred ops code to reduce indirect function calls. - Increase type-safety with the deferred ops code. - Make the DAX mount options a tri-state. - Fix some error handling problems in the inode flush code and clean up other inode flush warts. - Refactor log recovery so that each log item recovery functions now live with the other log item processing code. - Fix some SPDX forms. - Fix quota counter corruption if the fs crashes after running quotacheck but before any dquots get logged. - Don't fail metadata verification on zero-entry attr leaf blocks, since they're just part of the disk format now due to a historic lack of log atomicity. - Don't allow SWAPEXT between files with different [ugp]id when quotas are enabled. - Refactor inode fork reading and verification to run directly from the inode-from-disk function. This means that we now actually guarantee that _iget'ted inodes are totally verified and ready to go. - Move the incore inode fork format and extent counts to the ifork structure. - Scalability improvements by reducing cacheline pingponging in struct xfs_mount. - More scalability improvements by removing m_active_trans from the hot path. - Fix inode counter update sanity checking to run /only/ on debug kernels. - Fix longstanding inconsistency in what error code we return when a program hits project quota limits (ENOSPC). - Fix group quota returning the wrong error code when a program hits group quota limits. - Fix per-type quota limits and grace periods for group and project quotas so that they actually work. - Allow extension of individual grace periods. - Refactor the non-reclaim inode radix tree walking code to remove a bunch of stupid little functions and straighten out the inconsistent naming schemes. - Fix a bug in speculative preallocation where we measured a new allocation based on the last extent mapping in the file instead of looking farther for the last contiguous space allocation. - Force delalloc writes to unwritten extents. This closes a stale disk contents exposure vector if the system goes down before the write completes. - More lockdep whackamole" * tag 'xfs-5.8-merge-8' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (129 commits) xfs: more lockdep whackamole with kmem_alloc* xfs: force writes to delalloc regions to unwritten xfs: refactor xfs_iomap_prealloc_size xfs: measure all contiguous previous extents for prealloc size xfs: don't fail unwritten extent conversion on writeback due to edquot xfs: rearrange xfs_inode_walk_ag parameters xfs: straighten out all the naming around incore inode tree walks xfs: move xfs_inode_ag_iterator to be closer to the perag walking code xfs: use bool for done in xfs_inode_ag_walk xfs: fix inode ag walk predicate function return values xfs: refactor eofb matching into a single helper xfs: remove __xfs_icache_free_eofblocks xfs: remove flags argument from xfs_inode_ag_walk xfs: remove xfs_inode_ag_iterator_flags xfs: remove unused xfs_inode_ag_iterator function xfs: replace open-coded XFS_ICI_NO_TAG xfs: move eofblocks conversion function to xfs_ioctl.c xfs: allow individual quota grace period extension xfs: per-type quota timers and warn limits xfs: switch xfs_get_defquota to take explicit type ...
2 parents d9afbb3 + 6dcde60 commit 16d9154

File tree

102 files changed

+4366
-4939
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4366
-4939
lines changed

Documentation/filesystems/xfs-self-describing-metadata.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ buffer.
340340

341341
The structure of the verifiers and the identifiers checks is very similar to the
342342
buffer code described above. The only difference is where they are called. For
343-
example, inode read verification is done in xfs_iread() when the inode is first
344-
read out of the buffer and the struct xfs_inode is instantiated. The inode is
345-
already extensively verified during writeback in xfs_iflush_int, so the only
346-
addition here is to add the LSN and CRC to the inode as it is copied back into
347-
the buffer.
343+
example, inode read verification is done in xfs_inode_from_disk() when the inode
344+
is first read out of the buffer and the struct xfs_inode is instantiated. The
345+
inode is already extensively verified during writeback in xfs_iflush_int, so the
346+
only addition here is to add the LSN and CRC to the inode as it is copied back
347+
into the buffer.
348348

349349
XXX: inode unlinked list modification doesn't recalculate the inode CRC! None of
350350
the unlinked list modifications check or update CRCs, neither during unlink nor

fs/xfs/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
ccflags-y += -I $(srctree)/$(src) # needed for trace events
88
ccflags-y += -I $(srctree)/$(src)/libxfs
99

10-
ccflags-$(CONFIG_XFS_DEBUG) += -g
11-
1210
obj-$(CONFIG_XFS_FS) += xfs.o
1311

1412
# this one should be compiled first, as the tracing macros can easily blow up
@@ -101,9 +99,12 @@ xfs-y += xfs_log.o \
10199
xfs_log_cil.o \
102100
xfs_bmap_item.o \
103101
xfs_buf_item.o \
102+
xfs_buf_item_recover.o \
103+
xfs_dquot_item_recover.o \
104104
xfs_extfree_item.o \
105105
xfs_icreate_item.o \
106106
xfs_inode_item.o \
107+
xfs_inode_item_recover.o \
107108
xfs_refcount_item.o \
108109
xfs_rmap_item.o \
109110
xfs_log_recover.o \

fs/xfs/kmem.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: GPL-2.0
1+
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
33
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
44
* All Rights Reserved.
@@ -19,6 +19,7 @@ typedef unsigned __bitwise xfs_km_flags_t;
1919
#define KM_NOFS ((__force xfs_km_flags_t)0x0004u)
2020
#define KM_MAYFAIL ((__force xfs_km_flags_t)0x0008u)
2121
#define KM_ZERO ((__force xfs_km_flags_t)0x0010u)
22+
#define KM_NOLOCKDEP ((__force xfs_km_flags_t)0x0020u)
2223

2324
/*
2425
* We use a special process flag to avoid recursive callbacks into
@@ -30,7 +31,7 @@ kmem_flags_convert(xfs_km_flags_t flags)
3031
{
3132
gfp_t lflags;
3233

33-
BUG_ON(flags & ~(KM_NOFS|KM_MAYFAIL|KM_ZERO));
34+
BUG_ON(flags & ~(KM_NOFS | KM_MAYFAIL | KM_ZERO | KM_NOLOCKDEP));
3435

3536
lflags = GFP_KERNEL | __GFP_NOWARN;
3637
if (flags & KM_NOFS)
@@ -49,6 +50,9 @@ kmem_flags_convert(xfs_km_flags_t flags)
4950
if (flags & KM_ZERO)
5051
lflags |= __GFP_ZERO;
5152

53+
if (flags & KM_NOLOCKDEP)
54+
lflags |= __GFP_NOLOCKDEP;
55+
5256
return lflags;
5357
}
5458

fs/xfs/libxfs/xfs_ag_resv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: GPL-2.0+
1+
/* SPDX-License-Identifier: GPL-2.0+ */
22
/*
33
* Copyright (C) 2016 Oracle. All Rights Reserved.
44
* Author: Darrick J. Wong <[email protected]>

fs/xfs/libxfs/xfs_alloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: GPL-2.0
1+
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
33
* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
44
* All Rights Reserved.

fs/xfs/libxfs/xfs_alloc_btree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: GPL-2.0
1+
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
33
* Copyright (c) 2000,2005 Silicon Graphics, Inc.
44
* All Rights Reserved.

fs/xfs/libxfs/xfs_attr.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ xfs_inode_hasattr(
6161
struct xfs_inode *ip)
6262
{
6363
if (!XFS_IFORK_Q(ip) ||
64-
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
65-
ip->i_d.di_anextents == 0))
64+
(ip->i_afp->if_format == XFS_DINODE_FMT_EXTENTS &&
65+
ip->i_afp->if_nextents == 0))
6666
return 0;
6767
return 1;
6868
}
@@ -84,7 +84,7 @@ xfs_attr_get_ilocked(
8484
if (!xfs_inode_hasattr(args->dp))
8585
return -ENOATTR;
8686

87-
if (args->dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL)
87+
if (args->dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL)
8888
return xfs_attr_shortform_getvalue(args);
8989
if (xfs_bmap_one_block(args->dp, XFS_ATTR_FORK))
9090
return xfs_attr_leaf_get(args);
@@ -212,14 +212,14 @@ xfs_attr_set_args(
212212
* If the attribute list is non-existent or a shortform list,
213213
* upgrade it to a single-leaf-block attribute list.
214214
*/
215-
if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL ||
216-
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
217-
dp->i_d.di_anextents == 0)) {
215+
if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL ||
216+
(dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS &&
217+
dp->i_afp->if_nextents == 0)) {
218218

219219
/*
220220
* Build initial attribute list (if required).
221221
*/
222-
if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS)
222+
if (dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS)
223223
xfs_attr_shortform_create(args);
224224

225225
/*
@@ -272,7 +272,7 @@ xfs_attr_remove_args(
272272

273273
if (!xfs_inode_hasattr(dp)) {
274274
error = -ENOATTR;
275-
} else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
275+
} else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) {
276276
ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
277277
error = xfs_attr_shortform_remove(args);
278278
} else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {

fs/xfs/libxfs/xfs_attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: GPL-2.0
1+
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
33
* Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
44
* All Rights Reserved.

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,6 @@ xfs_attr3_leaf_verify(
308308
if (fa)
309309
return fa;
310310

311-
/*
312-
* In recovery there is a transient state where count == 0 is valid
313-
* because we may have transitioned an empty shortform attr to a leaf
314-
* if the attr didn't fit in shortform.
315-
*/
316-
if (!xfs_log_in_recovery(mp) && ichdr.count == 0)
317-
return __this_address;
318-
319311
/*
320312
* firstused is the block offset of the first name info structure.
321313
* Make sure it doesn't go off the block or crash into the header.
@@ -331,6 +323,13 @@ xfs_attr3_leaf_verify(
331323
(char *)bp->b_addr + ichdr.firstused)
332324
return __this_address;
333325

326+
/*
327+
* NOTE: This verifier historically failed empty leaf buffers because
328+
* we expect the fork to be in another format. Empty attr fork format
329+
* conversions are possible during xattr set, however, and format
330+
* conversion is not atomic with the xattr set that triggers it. We
331+
* cannot assume leaf blocks are non-empty until that is addressed.
332+
*/
334333
buf_end = (char *)bp->b_addr + mp->m_attr_geo->blksize;
335334
for (i = 0, ent = entries; i < ichdr.count; ent++, i++) {
336335
fa = xfs_attr3_leaf_verify_entry(mp, buf_end, leaf, &ichdr,
@@ -489,7 +488,7 @@ xfs_attr_copy_value(
489488
}
490489

491490
if (!args->value) {
492-
args->value = kmem_alloc_large(valuelen, 0);
491+
args->value = kmem_alloc_large(valuelen, KM_NOLOCKDEP);
493492
if (!args->value)
494493
return -ENOMEM;
495494
}
@@ -539,7 +538,7 @@ xfs_attr_shortform_bytesfit(
539538
/* rounded down */
540539
offset = (XFS_LITINO(mp) - bytes) >> 3;
541540

542-
if (dp->i_d.di_format == XFS_DINODE_FMT_DEV) {
541+
if (dp->i_df.if_format == XFS_DINODE_FMT_DEV) {
543542
minforkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
544543
return (offset >= minforkoff) ? minforkoff : 0;
545544
}
@@ -567,7 +566,7 @@ xfs_attr_shortform_bytesfit(
567566

568567
dsize = dp->i_df.if_bytes;
569568

570-
switch (dp->i_d.di_format) {
569+
switch (dp->i_df.if_format) {
571570
case XFS_DINODE_FMT_EXTENTS:
572571
/*
573572
* If there is no attr fork and the data fork is extents,
@@ -636,22 +635,19 @@ xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
636635
* Create the initial contents of a shortform attribute list.
637636
*/
638637
void
639-
xfs_attr_shortform_create(xfs_da_args_t *args)
638+
xfs_attr_shortform_create(
639+
struct xfs_da_args *args)
640640
{
641-
xfs_attr_sf_hdr_t *hdr;
642-
xfs_inode_t *dp;
643-
struct xfs_ifork *ifp;
641+
struct xfs_inode *dp = args->dp;
642+
struct xfs_ifork *ifp = dp->i_afp;
643+
struct xfs_attr_sf_hdr *hdr;
644644

645645
trace_xfs_attr_sf_create(args);
646646

647-
dp = args->dp;
648-
ASSERT(dp != NULL);
649-
ifp = dp->i_afp;
650-
ASSERT(ifp != NULL);
651647
ASSERT(ifp->if_bytes == 0);
652-
if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) {
648+
if (ifp->if_format == XFS_DINODE_FMT_EXTENTS) {
653649
ifp->if_flags &= ~XFS_IFEXTENTS; /* just in case */
654-
dp->i_d.di_aformat = XFS_DINODE_FMT_LOCAL;
650+
ifp->if_format = XFS_DINODE_FMT_LOCAL;
655651
ifp->if_flags |= XFS_IFINLINE;
656652
} else {
657653
ASSERT(ifp->if_flags & XFS_IFINLINE);
@@ -719,13 +715,12 @@ xfs_attr_fork_remove(
719715
struct xfs_inode *ip,
720716
struct xfs_trans *tp)
721717
{
722-
xfs_idestroy_fork(ip, XFS_ATTR_FORK);
723-
ip->i_d.di_forkoff = 0;
724-
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
725-
726-
ASSERT(ip->i_d.di_anextents == 0);
727-
ASSERT(ip->i_afp == NULL);
718+
ASSERT(ip->i_afp->if_nextents == 0);
728719

720+
xfs_idestroy_fork(ip->i_afp);
721+
kmem_cache_free(xfs_ifork_zone, ip->i_afp);
722+
ip->i_afp = NULL;
723+
ip->i_d.di_forkoff = 0;
729724
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
730725
}
731726

@@ -775,7 +770,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
775770
totsize -= size;
776771
if (totsize == sizeof(xfs_attr_sf_hdr_t) &&
777772
(mp->m_flags & XFS_MOUNT_ATTR2) &&
778-
(dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
773+
(dp->i_df.if_format != XFS_DINODE_FMT_BTREE) &&
779774
!(args->op_flags & XFS_DA_OP_ADDNAME)) {
780775
xfs_attr_fork_remove(dp, args->trans);
781776
} else {
@@ -785,7 +780,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
785780
ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) ||
786781
(args->op_flags & XFS_DA_OP_ADDNAME) ||
787782
!(mp->m_flags & XFS_MOUNT_ATTR2) ||
788-
dp->i_d.di_format == XFS_DINODE_FMT_BTREE);
783+
dp->i_df.if_format == XFS_DINODE_FMT_BTREE);
789784
xfs_trans_log_inode(args->trans, dp,
790785
XFS_ILOG_CORE | XFS_ILOG_ADATA);
791786
}
@@ -962,7 +957,7 @@ xfs_attr_shortform_allfit(
962957
+ be16_to_cpu(name_loc->valuelen);
963958
}
964959
if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
965-
(dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
960+
(dp->i_df.if_format != XFS_DINODE_FMT_BTREE) &&
966961
(bytes == sizeof(struct xfs_attr_sf_hdr)))
967962
return -1;
968963
return xfs_attr_shortform_bytesfit(dp, bytes);
@@ -981,7 +976,7 @@ xfs_attr_shortform_verify(
981976
int i;
982977
int64_t size;
983978

984-
ASSERT(ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL);
979+
ASSERT(ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL);
985980
ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
986981
sfp = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
987982
size = ifp->if_bytes;
@@ -1085,7 +1080,7 @@ xfs_attr3_leaf_to_shortform(
10851080

10861081
if (forkoff == -1) {
10871082
ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
1088-
ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE);
1083+
ASSERT(dp->i_df.if_format != XFS_DINODE_FMT_BTREE);
10891084
xfs_attr_fork_remove(dp, args->trans);
10901085
goto out;
10911086
}

fs/xfs/libxfs/xfs_attr_leaf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-License-Identifier: GPL-2.0
1+
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
33
* Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
44
* Copyright (c) 2013 Red Hat, Inc.

0 commit comments

Comments
 (0)