Skip to content

Commit 7af4046

Browse files
author
CKI KWF Bot
committed
Merge: xfs: Updates for 10.1
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1180 JIRA: https://issues.redhat.com/browse/RHEL-85590 This is a pro-active update for xfs targeting 10.1 Because RHEL10 is based on Linux v6.12, there are not many patches needed for now. Just backport some essential ones, as we prepare a more complete rebase for 10.2. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Approved-by: Brian Foster <bfoster@redhat.com> Approved-by: Eric Sandeen <esandeen@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents adf8dfb + 390c9dc commit 7af4046

File tree

11 files changed

+96
-75
lines changed

11 files changed

+96
-75
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3531,12 +3531,12 @@ xfs_bmap_btalloc_at_eof(
35313531
int error;
35323532

35333533
/*
3534-
* If there are already extents in the file, try an exact EOF block
3535-
* allocation to extend the file as a contiguous extent. If that fails,
3536-
* or it's the first allocation in a file, just try for a stripe aligned
3537-
* allocation.
3534+
* If there are already extents in the file, and xfs_bmap_adjacent() has
3535+
* given a better blkno, try an exact EOF block allocation to extend the
3536+
* file as a contiguous extent. If that fails, or it's the first
3537+
* allocation in a file, just try for a stripe aligned allocation.
35383538
*/
3539-
if (ap->offset) {
3539+
if (ap->eof) {
35403540
xfs_extlen_t nextminlen = 0;
35413541

35423542
/*
@@ -3704,7 +3704,8 @@ xfs_bmap_btalloc_best_length(
37043704
int error;
37053705

37063706
ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino);
3707-
xfs_bmap_adjacent(ap);
3707+
if (!xfs_bmap_adjacent(ap))
3708+
ap->eof = false;
37083709

37093710
/*
37103711
* Search for an allocation group with a single extent large enough for

fs/xfs/scrub/common.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ static inline bool xchk_skip_xref(struct xfs_scrub_metadata *sm)
179179
bool xchk_dir_looks_zapped(struct xfs_inode *dp);
180180
bool xchk_pptr_looks_zapped(struct xfs_inode *ip);
181181

182-
#ifdef CONFIG_XFS_ONLINE_REPAIR
183182
/* Decide if a repair is required. */
184183
static inline bool xchk_needs_repair(const struct xfs_scrub_metadata *sm)
185184
{
@@ -199,10 +198,6 @@ static inline bool xchk_could_repair(const struct xfs_scrub *sc)
199198
return (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) &&
200199
!(sc->flags & XREP_ALREADY_FIXED);
201200
}
202-
#else
203-
# define xchk_needs_repair(sc) (false)
204-
# define xchk_could_repair(sc) (false)
205-
#endif /* CONFIG_XFS_ONLINE_REPAIR */
206201

207202
int xchk_metadata_inode_forks(struct xfs_scrub *sc);
208203

fs/xfs/scrub/repair.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,16 @@ bool xrep_buf_verify_struct(struct xfs_buf *bp, const struct xfs_buf_ops *ops);
163163
#else
164164

165165
#define xrep_ino_dqattach(sc) (0)
166-
#define xrep_will_attempt(sc) (false)
166+
167+
/*
168+
* When online repair is not built into the kernel, we still want to attempt
169+
* the repair so that the stub xrep_attempt below will return EOPNOTSUPP.
170+
*/
171+
static inline bool xrep_will_attempt(const struct xfs_scrub *sc)
172+
{
173+
return (sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
174+
xchk_needs_repair(sc->sm);
175+
}
167176

168177
static inline int
169178
xrep_attempt(

fs/xfs/scrub/scrub.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ xchk_probe(
149149
if (xchk_should_terminate(sc, &error))
150150
return error;
151151

152+
/*
153+
* If the caller is probing to see if repair works but repair isn't
154+
* built into the kernel, return EOPNOTSUPP because that's the signal
155+
* that userspace expects. If online repair is built in, set the
156+
* CORRUPT flag (without any of the usual tracing/logging) to force us
157+
* into xrep_probe.
158+
*/
159+
if (xchk_could_repair(sc)) {
160+
if (!IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR))
161+
return -EOPNOTSUPP;
162+
sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
163+
}
152164
return 0;
153165
}
154166

fs/xfs/scrub/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ TRACE_EVENT(xchk_ifork_btree_op_error,
601601
TP_fast_assign(
602602
xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
603603
__entry->dev = sc->mp->m_super->s_dev;
604-
__entry->ino = sc->ip->i_ino;
604+
__entry->ino = cur->bc_ino.ip->i_ino;
605605
__entry->whichfork = cur->bc_ino.whichfork;
606606
__entry->type = sc->sm->sm_type;
607607
__assign_str(name);

fs/xfs/xfs_bmap_util.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,14 @@ xfs_can_free_eofblocks(
546546
return false;
547547

548548
/*
549-
* Check if there is an post-EOF extent to free.
549+
* Check if there is an post-EOF extent to free. If there are any
550+
* delalloc blocks attached to the inode (data fork delalloc
551+
* reservations or CoW extents of any kind), we need to free them so
552+
* that inactivation doesn't fail to erase them.
550553
*/
551554
xfs_ilock(ip, XFS_ILOCK_SHARED);
552-
if (xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap))
555+
if (ip->i_delayed_blks ||
556+
xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap))
553557
found_blocks = true;
554558
xfs_iunlock(ip, XFS_ILOCK_SHARED);
555559
return found_blocks;

fs/xfs/xfs_buf.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,10 +1656,8 @@ _xfs_buf_ioapply(
16561656
op |= REQ_META;
16571657

16581658
/* in-memory targets are directly mapped, no IO required. */
1659-
if (xfs_buftarg_is_mem(bp->b_target)) {
1660-
xfs_buf_ioend(bp);
1659+
if (xfs_buftarg_is_mem(bp->b_target))
16611660
return;
1662-
}
16631661

16641662
/*
16651663
* Walk all the vectors issuing IO on them. Set up the initial offset

fs/xfs/xfs_buf_item_recover.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,11 +1036,20 @@ xlog_recover_buf_commit_pass2(
10361036
error = xlog_recover_do_primary_sb_buffer(mp, item, bp, buf_f,
10371037
current_lsn);
10381038
if (error)
1039-
goto out_release;
1039+
goto out_writebuf;
10401040
} else {
10411041
xlog_recover_do_reg_buffer(mp, item, bp, buf_f, current_lsn);
10421042
}
10431043

1044+
/*
1045+
* Buffer held by buf log item during 'normal' buffer recovery must
1046+
* be committed through buffer I/O submission path to ensure proper
1047+
* release. When error occurs during sb buffer recovery, log shutdown
1048+
* will be done before submitting buffer list so that buffers can be
1049+
* released correctly through ioend failure path.
1050+
*/
1051+
out_writebuf:
1052+
10441053
/*
10451054
* Perform delayed write on the buffer. Asynchronous writes will be
10461055
* slower when taking into account all the buffers to be flushed.

fs/xfs/xfs_exchrange.c

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -326,22 +326,6 @@ xfs_exchrange_mappings(
326326
* successfully but before locks are dropped.
327327
*/
328328

329-
/* Verify that we have security clearance to perform this operation. */
330-
static int
331-
xfs_exchange_range_verify_area(
332-
struct xfs_exchrange *fxr)
333-
{
334-
int ret;
335-
336-
ret = remap_verify_area(fxr->file1, fxr->file1_offset, fxr->length,
337-
true);
338-
if (ret)
339-
return ret;
340-
341-
return remap_verify_area(fxr->file2, fxr->file2_offset, fxr->length,
342-
true);
343-
}
344-
345329
/*
346330
* Performs necessary checks before doing a range exchange, having stabilized
347331
* mutable inode attributes via i_rwsem.
@@ -352,11 +336,13 @@ xfs_exchange_range_checks(
352336
unsigned int alloc_unit)
353337
{
354338
struct inode *inode1 = file_inode(fxr->file1);
339+
loff_t size1 = i_size_read(inode1);
355340
struct inode *inode2 = file_inode(fxr->file2);
341+
loff_t size2 = i_size_read(inode2);
356342
uint64_t allocmask = alloc_unit - 1;
357343
int64_t test_len;
358344
uint64_t blen;
359-
loff_t size1, size2, tmp;
345+
loff_t tmp;
360346
int error;
361347

362348
/* Don't touch certain kinds of inodes */
@@ -365,24 +351,25 @@ xfs_exchange_range_checks(
365351
if (IS_SWAPFILE(inode1) || IS_SWAPFILE(inode2))
366352
return -ETXTBSY;
367353

368-
size1 = i_size_read(inode1);
369-
size2 = i_size_read(inode2);
370-
371354
/* Ranges cannot start after EOF. */
372355
if (fxr->file1_offset > size1 || fxr->file2_offset > size2)
373356
return -EINVAL;
374357

375-
/*
376-
* If the caller said to exchange to EOF, we set the length of the
377-
* request large enough to cover everything to the end of both files.
378-
*/
379358
if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) {
359+
/*
360+
* If the caller said to exchange to EOF, we set the length of
361+
* the request large enough to cover everything to the end of
362+
* both files.
363+
*/
380364
fxr->length = max_t(int64_t, size1 - fxr->file1_offset,
381365
size2 - fxr->file2_offset);
382-
383-
error = xfs_exchange_range_verify_area(fxr);
384-
if (error)
385-
return error;
366+
} else {
367+
/*
368+
* Otherwise we require both ranges to end within EOF.
369+
*/
370+
if (fxr->file1_offset + fxr->length > size1 ||
371+
fxr->file2_offset + fxr->length > size2)
372+
return -EINVAL;
386373
}
387374

388375
/*
@@ -398,15 +385,6 @@ xfs_exchange_range_checks(
398385
check_add_overflow(fxr->file2_offset, fxr->length, &tmp))
399386
return -EINVAL;
400387

401-
/*
402-
* We require both ranges to end within EOF, unless we're exchanging
403-
* to EOF.
404-
*/
405-
if (!(fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) &&
406-
(fxr->file1_offset + fxr->length > size1 ||
407-
fxr->file2_offset + fxr->length > size2))
408-
return -EINVAL;
409-
410388
/*
411389
* Make sure we don't hit any file size limits. If we hit any size
412390
* limits such that test_length was adjusted, we abort the whole
@@ -744,6 +722,7 @@ xfs_exchange_range(
744722
{
745723
struct inode *inode1 = file_inode(fxr->file1);
746724
struct inode *inode2 = file_inode(fxr->file2);
725+
loff_t check_len = fxr->length;
747726
int ret;
748727

749728
BUILD_BUG_ON(XFS_EXCHANGE_RANGE_ALL_FLAGS &
@@ -776,14 +755,18 @@ xfs_exchange_range(
776755
return -EBADF;
777756

778757
/*
779-
* If we're not exchanging to EOF, we can check the areas before
780-
* stabilizing both files' i_size.
758+
* If we're exchanging to EOF we can't calculate the length until taking
759+
* the iolock. Pass a 0 length to remap_verify_area similar to the
760+
* FICLONE and FICLONERANGE ioctls that support cloning to EOF as well.
781761
*/
782-
if (!(fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF)) {
783-
ret = xfs_exchange_range_verify_area(fxr);
784-
if (ret)
785-
return ret;
786-
}
762+
if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF)
763+
check_len = 0;
764+
ret = remap_verify_area(fxr->file1, fxr->file1_offset, check_len, true);
765+
if (ret)
766+
return ret;
767+
ret = remap_verify_area(fxr->file2, fxr->file2_offset, check_len, true);
768+
if (ret)
769+
return ret;
787770

788771
/* Update cmtime if the fd/inode don't forbid it. */
789772
if (!(fxr->file1->f_mode & FMODE_NOCMTIME) && !IS_NOCMTIME(inode1))

fs/xfs/xfs_fsmap.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ struct xfs_getfsmap_info {
162162
xfs_daddr_t next_daddr; /* next daddr we expect */
163163
/* daddr of low fsmap key when we're using the rtbitmap */
164164
xfs_daddr_t low_daddr;
165-
xfs_daddr_t end_daddr; /* daddr of high fsmap key */
165+
/* daddr of high fsmap key, or the last daddr on the device */
166+
xfs_daddr_t end_daddr;
166167
u64 missing_owner; /* owner of holes */
167168
u32 dev; /* device id */
168169
/*
@@ -305,8 +306,8 @@ xfs_getfsmap_helper(
305306
* we calculated from userspace's high key to synthesize the record.
306307
* Note that if the btree query found a mapping, there won't be a gap.
307308
*/
308-
if (info->last && info->end_daddr != XFS_BUF_DADDR_NULL)
309-
rec_daddr = info->end_daddr;
309+
if (info->last)
310+
rec_daddr = info->end_daddr + 1;
310311

311312
/* Are we just counting mappings? */
312313
if (info->head->fmh_count == 0) {
@@ -898,7 +899,10 @@ xfs_getfsmap(
898899
struct xfs_trans *tp = NULL;
899900
struct xfs_fsmap dkeys[2]; /* per-dev keys */
900901
struct xfs_getfsmap_dev handlers[XFS_GETFSMAP_DEVS];
901-
struct xfs_getfsmap_info info = { NULL };
902+
struct xfs_getfsmap_info info = {
903+
.fsmap_recs = fsmap_recs,
904+
.head = head,
905+
};
902906
bool use_rmap;
903907
int i;
904908
int error = 0;
@@ -963,9 +967,6 @@ xfs_getfsmap(
963967

964968
info.next_daddr = head->fmh_keys[0].fmr_physical +
965969
head->fmh_keys[0].fmr_length;
966-
info.end_daddr = XFS_BUF_DADDR_NULL;
967-
info.fsmap_recs = fsmap_recs;
968-
info.head = head;
969970

970971
/* For each device we support... */
971972
for (i = 0; i < XFS_GETFSMAP_DEVS; i++) {
@@ -978,17 +979,23 @@ xfs_getfsmap(
978979
break;
979980

980981
/*
981-
* If this device number matches the high key, we have
982-
* to pass the high key to the handler to limit the
983-
* query results. If the device number exceeds the
984-
* low key, zero out the low key so that we get
985-
* everything from the beginning.
982+
* If this device number matches the high key, we have to pass
983+
* the high key to the handler to limit the query results, and
984+
* set the end_daddr so that we can synthesize records at the
985+
* end of the query range or device.
986986
*/
987987
if (handlers[i].dev == head->fmh_keys[1].fmr_device) {
988988
dkeys[1] = head->fmh_keys[1];
989989
info.end_daddr = min(handlers[i].nr_sectors - 1,
990990
dkeys[1].fmr_physical);
991+
} else {
992+
info.end_daddr = handlers[i].nr_sectors - 1;
991993
}
994+
995+
/*
996+
* If the device number exceeds the low key, zero out the low
997+
* key so that we get everything from the beginning.
998+
*/
992999
if (handlers[i].dev > head->fmh_keys[0].fmr_device)
9931000
memset(&dkeys[0], 0, sizeof(struct xfs_fsmap));
9941001

0 commit comments

Comments
 (0)