Skip to content

Commit c3a60b6

Browse files
committed
Merge branch 'xfs-6.15-folios_vmalloc' into XFS-for-linus-6.15-merge
Merge buffer cache conversion to folios and vmalloc Signed-off-by: Carlos Maiolino <[email protected]>
2 parents 8e64154 + 89ce287 commit c3a60b6

File tree

16 files changed

+204
-435
lines changed

16 files changed

+204
-435
lines changed

Documentation/filesystems/iomap/operations.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ IOMAP_WRITE`` with any combination of the following enhancements:
514514
if the mapping is unwritten and the filesystem cannot handle zeroing
515515
the unaligned regions without exposing stale contents.
516516

517-
* ``IOMAP_ATOMIC``: This write is being issued with torn-write
518-
protection.
517+
* ``IOMAP_ATOMIC_HW``: This write is being issued with torn-write
518+
protection based on HW-offload support.
519519
Only a single bio can be created for the write, and the write must
520520
not be split into multiple I/O requests, i.e. flag REQ_ATOMIC must be
521521
set.
@@ -526,8 +526,20 @@ IOMAP_WRITE`` with any combination of the following enhancements:
526526
conversion or copy on write), all updates for the entire file range
527527
must be committed atomically as well.
528528
Only one space mapping is allowed per untorn write.
529-
Untorn writes must be aligned to, and must not be longer than, a
530-
single file block.
529+
Untorn writes may be longer than a single file block. In all cases,
530+
the mapping start disk block must have at least the same alignment as
531+
the write offset.
532+
533+
* ``IOMAP_ATOMIC_SW``: This write is being issued with torn-write
534+
protection via a software mechanism provided by the filesystem.
535+
All the disk block alignment and single bio restrictions which apply
536+
to IOMAP_ATOMIC_HW do not apply here.
537+
SW-based untorn writes would typically be used as a fallback when
538+
HW-based untorn writes may not be issued, e.g. the range of the write
539+
covers multiple extents, meaning that it is not possible to issue
540+
a single bio.
541+
All filesystem metadata updates for the entire file range must be
542+
committed atomically as well.
531543

532544
Callers commonly hold ``i_rwsem`` in shared or exclusive mode before
533545
calling this function.

fs/ext4/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3467,7 +3467,7 @@ static inline bool ext4_want_directio_fallback(unsigned flags, ssize_t written)
34673467
return false;
34683468

34693469
/* atomic writes are all-or-nothing */
3470-
if (flags & IOMAP_ATOMIC)
3470+
if (flags & IOMAP_ATOMIC_HW)
34713471
return false;
34723472

34733473
/* can only try again if we wrote nothing */

fs/iomap/direct-io.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio,
317317
* clearing the WRITE_THROUGH flag in the dio request.
318318
*/
319319
static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio,
320-
const struct iomap *iomap, bool use_fua, bool atomic)
320+
const struct iomap *iomap, bool use_fua, bool atomic_hw)
321321
{
322322
blk_opf_t opflags = REQ_SYNC | REQ_IDLE;
323323

@@ -329,7 +329,7 @@ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio,
329329
opflags |= REQ_FUA;
330330
else
331331
dio->flags &= ~IOMAP_DIO_WRITE_THROUGH;
332-
if (atomic)
332+
if (atomic_hw)
333333
opflags |= REQ_ATOMIC;
334334

335335
return opflags;
@@ -340,8 +340,8 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
340340
const struct iomap *iomap = &iter->iomap;
341341
struct inode *inode = iter->inode;
342342
unsigned int fs_block_size = i_blocksize(inode), pad;
343+
bool atomic_hw = iter->flags & IOMAP_ATOMIC_HW;
343344
const loff_t length = iomap_length(iter);
344-
bool atomic = iter->flags & IOMAP_ATOMIC;
345345
loff_t pos = iter->pos;
346346
blk_opf_t bio_opf;
347347
struct bio *bio;
@@ -351,7 +351,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
351351
u64 copied = 0;
352352
size_t orig_count;
353353

354-
if (atomic && length != fs_block_size)
354+
if (atomic_hw && length != iter->len)
355355
return -EINVAL;
356356

357357
if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1) ||
@@ -428,7 +428,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
428428
goto out;
429429
}
430430

431-
bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua, atomic);
431+
bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua, atomic_hw);
432432

433433
nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS);
434434
do {
@@ -461,7 +461,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
461461
}
462462

463463
n = bio->bi_iter.bi_size;
464-
if (WARN_ON_ONCE(atomic && n != length)) {
464+
if (WARN_ON_ONCE(atomic_hw && n != length)) {
465465
/*
466466
* This bio should have covered the complete length,
467467
* which it doesn't, so error. We may need to zero out
@@ -650,9 +650,6 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
650650
if (iocb->ki_flags & IOCB_NOWAIT)
651651
iomi.flags |= IOMAP_NOWAIT;
652652

653-
if (iocb->ki_flags & IOCB_ATOMIC)
654-
iomi.flags |= IOMAP_ATOMIC;
655-
656653
if (iov_iter_rw(iter) == READ) {
657654
/* reads can always complete inline */
658655
dio->flags |= IOMAP_DIO_INLINE_COMP;
@@ -687,6 +684,11 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
687684
iomi.flags |= IOMAP_OVERWRITE_ONLY;
688685
}
689686

687+
if (dio_flags & IOMAP_DIO_ATOMIC_SW)
688+
iomi.flags |= IOMAP_ATOMIC_SW;
689+
else if (iocb->ki_flags & IOCB_ATOMIC)
690+
iomi.flags |= IOMAP_ATOMIC_HW;
691+
690692
/* for data sync or sync, we need sync completion processing */
691693
if (iocb_is_dsync(iocb)) {
692694
dio->flags |= IOMAP_DIO_NEED_SYNC;

fs/iomap/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ DEFINE_RANGE_EVENT(iomap_dio_rw_queued);
9999
{ IOMAP_FAULT, "FAULT" }, \
100100
{ IOMAP_DIRECT, "DIRECT" }, \
101101
{ IOMAP_NOWAIT, "NOWAIT" }, \
102-
{ IOMAP_ATOMIC, "ATOMIC" }
102+
{ IOMAP_ATOMIC_HW, "ATOMIC_HW" }
103103

104104
#define IOMAP_F_FLAGS_STRINGS \
105105
{ IOMAP_F_NEW, "NEW" }, \

fs/xfs/libxfs/xfs_ialloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ xfs_ialloc_inode_init(
364364
(j * M_IGEO(mp)->blocks_per_cluster));
365365
error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
366366
mp->m_bsize * M_IGEO(mp)->blocks_per_cluster,
367-
XBF_UNMAPPED, &fbuf);
367+
0, &fbuf);
368368
if (error)
369369
return error;
370370

fs/xfs/libxfs/xfs_inode_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ xfs_imap_to_bp(
137137
int error;
138138

139139
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
140-
imap->im_len, XBF_UNMAPPED, bpp, &xfs_inode_buf_ops);
140+
imap->im_len, 0, bpp, &xfs_inode_buf_ops);
141141
if (xfs_metadata_is_sick(error))
142142
xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, imap->im_blkno),
143143
XFS_SICK_AG_INODES);

fs/xfs/scrub/inode_repair.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,7 @@ xrep_dinode_core(
15601560

15611561
/* Read the inode cluster buffer. */
15621562
error = xfs_trans_read_buf(sc->mp, sc->tp, sc->mp->m_ddev_targp,
1563-
ri->imap.im_blkno, ri->imap.im_len, XBF_UNMAPPED, &bp,
1564-
NULL);
1563+
ri->imap.im_blkno, ri->imap.im_len, 0, &bp, NULL);
15651564
if (error)
15661565
return error;
15671566

0 commit comments

Comments
 (0)