Skip to content

Commit 1524cb2

Browse files
committed
Merge tag 'xfs-fixes-6.15-rc7' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Carlos Maiolino: "This includes a bug fix for a possible data corruption vector on the zoned allocator garbage collector" * tag 'xfs-fixes-6.15-rc7' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: Fix comment on xfs_trans_ail_update_bulk() xfs: Fix a comment on xfs_ail_delete xfs: Fail remount with noattr2 on a v5 with v4 enabled xfs: fix zoned GC data corruption due to wrong bv_offset xfs: free up mp->m_free[0].count in error case
2 parents 3c21441 + 08c73a4 commit 1524cb2

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed

fs/xfs/xfs_super.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ xfs_init_percpu_counters(
11491149
return 0;
11501150

11511151
free_freecounters:
1152-
while (--i > 0)
1152+
while (--i >= 0)
11531153
percpu_counter_destroy(&mp->m_free[i].count);
11541154
percpu_counter_destroy(&mp->m_delalloc_rtextents);
11551155
free_delalloc:
@@ -2114,6 +2114,21 @@ xfs_fs_reconfigure(
21142114
if (error)
21152115
return error;
21162116

2117+
/* attr2 -> noattr2 */
2118+
if (xfs_has_noattr2(new_mp)) {
2119+
if (xfs_has_crc(mp)) {
2120+
xfs_warn(mp,
2121+
"attr2 is always enabled for a V5 filesystem - can't be changed.");
2122+
return -EINVAL;
2123+
}
2124+
mp->m_features &= ~XFS_FEAT_ATTR2;
2125+
mp->m_features |= XFS_FEAT_NOATTR2;
2126+
} else if (xfs_has_attr2(new_mp)) {
2127+
/* noattr2 -> attr2 */
2128+
mp->m_features &= ~XFS_FEAT_NOATTR2;
2129+
mp->m_features |= XFS_FEAT_ATTR2;
2130+
}
2131+
21172132
/* inode32 -> inode64 */
21182133
if (xfs_has_small_inums(mp) && !xfs_has_small_inums(new_mp)) {
21192134
mp->m_features &= ~XFS_FEAT_SMALL_INUMS;
@@ -2126,6 +2141,17 @@ xfs_fs_reconfigure(
21262141
mp->m_maxagi = xfs_set_inode_alloc(mp, mp->m_sb.sb_agcount);
21272142
}
21282143

2144+
/*
2145+
* Now that mp has been modified according to the remount options, we
2146+
* do a final option validation with xfs_finish_flags() just like it is
2147+
* just like it is done during mount. We cannot use
2148+
* done during mount. We cannot use xfs_finish_flags() on new_mp as it
2149+
* contains only the user given options.
2150+
*/
2151+
error = xfs_finish_flags(mp);
2152+
if (error)
2153+
return error;
2154+
21292155
/* ro -> rw */
21302156
if (xfs_is_readonly(mp) && !(flags & SB_RDONLY)) {
21312157
error = xfs_remount_rw(mp);

fs/xfs/xfs_trans_ail.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ xfs_ail_splice(
315315
}
316316

317317
/*
318-
* Delete the given item from the AIL. Return a pointer to the item.
318+
* Delete the given item from the AIL.
319319
*/
320320
static void
321321
xfs_ail_delete(
@@ -777,26 +777,28 @@ xfs_ail_update_finish(
777777
}
778778

779779
/*
780-
* xfs_trans_ail_update - bulk AIL insertion operation.
780+
* xfs_trans_ail_update_bulk - bulk AIL insertion operation.
781781
*
782-
* @xfs_trans_ail_update takes an array of log items that all need to be
782+
* @xfs_trans_ail_update_bulk takes an array of log items that all need to be
783783
* positioned at the same LSN in the AIL. If an item is not in the AIL, it will
784-
* be added. Otherwise, it will be repositioned by removing it and re-adding
785-
* it to the AIL. If we move the first item in the AIL, update the log tail to
786-
* match the new minimum LSN in the AIL.
784+
* be added. Otherwise, it will be repositioned by removing it and re-adding
785+
* it to the AIL.
787786
*
788-
* This function takes the AIL lock once to execute the update operations on
789-
* all the items in the array, and as such should not be called with the AIL
790-
* lock held. As a result, once we have the AIL lock, we need to check each log
791-
* item LSN to confirm it needs to be moved forward in the AIL.
787+
* If we move the first item in the AIL, update the log tail to match the new
788+
* minimum LSN in the AIL.
792789
*
793-
* To optimise the insert operation, we delete all the items from the AIL in
794-
* the first pass, moving them into a temporary list, then splice the temporary
795-
* list into the correct position in the AIL. This avoids needing to do an
796-
* insert operation on every item.
790+
* This function should be called with the AIL lock held.
797791
*
798-
* This function must be called with the AIL lock held. The lock is dropped
799-
* before returning.
792+
* To optimise the insert operation, we add all items to a temporary list, then
793+
* splice this list into the correct position in the AIL.
794+
*
795+
* Items that are already in the AIL are first deleted from their current
796+
* location before being added to the temporary list.
797+
*
798+
* This avoids needing to do an insert operation on every item.
799+
*
800+
* The AIL lock is dropped by xfs_ail_update_finish() before returning to
801+
* the caller.
800802
*/
801803
void
802804
xfs_trans_ail_update_bulk(

fs/xfs/xfs_zone_gc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,8 @@ xfs_zone_gc_write_chunk(
807807
{
808808
struct xfs_zone_gc_data *data = chunk->data;
809809
struct xfs_mount *mp = chunk->ip->i_mount;
810-
unsigned int folio_offset = chunk->bio.bi_io_vec->bv_offset;
810+
phys_addr_t bvec_paddr =
811+
bvec_phys(bio_first_bvec_all(&chunk->bio));
811812
struct xfs_gc_bio *split_chunk;
812813

813814
if (chunk->bio.bi_status)
@@ -822,7 +823,7 @@ xfs_zone_gc_write_chunk(
822823

823824
bio_reset(&chunk->bio, mp->m_rtdev_targp->bt_bdev, REQ_OP_WRITE);
824825
bio_add_folio_nofail(&chunk->bio, chunk->scratch->folio, chunk->len,
825-
folio_offset);
826+
offset_in_folio(chunk->scratch->folio, bvec_paddr));
826827

827828
while ((split_chunk = xfs_zone_gc_split_write(data, chunk)))
828829
xfs_zone_gc_submit_write(data, split_chunk);

0 commit comments

Comments
 (0)