Dave Chinner thought that names IOMAP_ATOMIC_HW and IOMAP_ATOMIC_SW were not appropopiate. Specifically because IOMAP_ATOMIC_HW could actually be realised with a SW-based method in the block or md/dm layers. So rename to IOMAP_ATOMIC_BIO and IOMAP_ATOMIC_FS. Also renumber the flags so that the atomic flags are adjacent. Signed-off-by: John Garry <john.g.garry@xxxxxxxxxx> --- Documentation/filesystems/iomap/operations.rst | 6 +++--- fs/ext4/inode.c | 2 +- fs/iomap/direct-io.c | 18 +++++++++--------- fs/iomap/trace.h | 3 ++- fs/xfs/xfs_file.c | 4 ++-- fs/xfs/xfs_iomap.c | 10 +++++----- include/linux/iomap.h | 10 +++++----- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Documentation/filesystems/iomap/operations.rst b/Documentation/filesystems/iomap/operations.rst index b08a79d11d9f..f1d9aa767d30 100644 --- a/Documentation/filesystems/iomap/operations.rst +++ b/Documentation/filesystems/iomap/operations.rst @@ -514,7 +514,7 @@ IOMAP_WRITE`` with any combination of the following enhancements: if the mapping is unwritten and the filesystem cannot handle zeroing the unaligned regions without exposing stale contents. - * ``IOMAP_ATOMIC_HW``: This write is being issued with torn-write + * ``IOMAP_BIO_ATOMIC``: This write is being issued with torn-write protection based on HW-offload support. Only a single bio can be created for the write, and the write must not be split into multiple I/O requests, i.e. flag REQ_ATOMIC must be @@ -530,10 +530,10 @@ IOMAP_WRITE`` with any combination of the following enhancements: the mapping start disk block must have at least the same alignment as the write offset. - * ``IOMAP_ATOMIC_SW``: This write is being issued with torn-write + * ``IOMAP_FS_ATOMIC``: This write is being issued with torn-write protection via a software mechanism provided by the filesystem. All the disk block alignment and single bio restrictions which apply - to IOMAP_ATOMIC_HW do not apply here. + to IOMAP_BIO_ATOMIC do not apply here. SW-based untorn writes would typically be used as a fallback when HW-based untorn writes may not be issued, e.g. the range of the write covers multiple extents, meaning that it is not possible to issue diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ba2f1e3db7c7..da385862c1b5 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3467,7 +3467,7 @@ static inline bool ext4_want_directio_fallback(unsigned flags, ssize_t written) return false; /* atomic writes are all-or-nothing */ - if (flags & IOMAP_ATOMIC_HW) + if (flags & IOMAP_BIO_ATOMIC) return false; /* can only try again if we wrote nothing */ diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 5299f70428ef..d728d894bd90 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -317,7 +317,7 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, * clearing the WRITE_THROUGH flag in the dio request. */ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, - const struct iomap *iomap, bool use_fua, bool atomic_hw) + const struct iomap *iomap, bool use_fua, bool bio_atomic) { blk_opf_t opflags = REQ_SYNC | REQ_IDLE; @@ -329,7 +329,7 @@ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, opflags |= REQ_FUA; else dio->flags &= ~IOMAP_DIO_WRITE_THROUGH; - if (atomic_hw) + if (bio_atomic) opflags |= REQ_ATOMIC; return opflags; @@ -340,7 +340,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio) const struct iomap *iomap = &iter->iomap; struct inode *inode = iter->inode; unsigned int fs_block_size = i_blocksize(inode), pad; - bool atomic_hw = iter->flags & IOMAP_ATOMIC_HW; + bool bio_atomic = iter->flags & IOMAP_BIO_ATOMIC; const loff_t length = iomap_length(iter); loff_t pos = iter->pos; blk_opf_t bio_opf; @@ -351,7 +351,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio) u64 copied = 0; size_t orig_count; - if (atomic_hw && length != iter->len) + if (bio_atomic && length != iter->len) return -EINVAL; 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) goto out; } - bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua, atomic_hw); + bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua, bio_atomic); nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS); do { @@ -461,7 +461,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio) } n = bio->bi_iter.bi_size; - if (WARN_ON_ONCE(atomic_hw && n != length)) { + if (WARN_ON_ONCE(bio_atomic && n != length)) { /* * This bio should have covered the complete length, * which it doesn't, so error. We may need to zero out @@ -686,10 +686,10 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, iomi.flags |= IOMAP_OVERWRITE_ONLY; } - if (dio_flags & IOMAP_DIO_ATOMIC_SW) - iomi.flags |= IOMAP_ATOMIC_SW; + if (dio_flags & IOMAP_DIO_FS_ATOMIC) + iomi.flags |= IOMAP_FS_ATOMIC; else if (iocb->ki_flags & IOCB_ATOMIC) - iomi.flags |= IOMAP_ATOMIC_HW; + iomi.flags |= IOMAP_BIO_ATOMIC; /* for data sync or sync, we need sync completion processing */ if (iocb_is_dsync(iocb)) { diff --git a/fs/iomap/trace.h b/fs/iomap/trace.h index 69af89044ebd..4b71f1711b69 100644 --- a/fs/iomap/trace.h +++ b/fs/iomap/trace.h @@ -99,7 +99,8 @@ DEFINE_RANGE_EVENT(iomap_dio_rw_queued); { IOMAP_FAULT, "FAULT" }, \ { IOMAP_DIRECT, "DIRECT" }, \ { IOMAP_NOWAIT, "NOWAIT" }, \ - { IOMAP_ATOMIC_HW, "ATOMIC_HW" } + { IOMAP_BIO_ATOMIC, "ATOMIC_BIO" }, \ + { IOMAP_FS_ATOMIC, "ATOMIC_FS" } #define IOMAP_F_FLAGS_STRINGS \ { IOMAP_F_NEW, "NEW" }, \ diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 16739c408af3..4ad80179173a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -755,9 +755,9 @@ xfs_file_dio_write_atomic( &xfs_dio_write_ops, dio_flags, NULL, 0); if (ret == -EAGAIN && !(iocb->ki_flags & IOCB_NOWAIT) && - !(dio_flags & IOMAP_DIO_ATOMIC_SW)) { + !(dio_flags & IOMAP_DIO_FS_ATOMIC)) { xfs_iunlock(ip, iolock); - dio_flags = IOMAP_DIO_ATOMIC_SW | IOMAP_DIO_FORCE_WAIT; + dio_flags = IOMAP_DIO_FS_ATOMIC | IOMAP_DIO_FORCE_WAIT; iolock = XFS_IOLOCK_EXCL; goto retry; } diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 6c963786530d..71ddd5979091 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -830,7 +830,7 @@ xfs_direct_write_iomap_begin( xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); xfs_fileoff_t end_fsb = xfs_iomap_end_fsb(mp, offset, length); xfs_fileoff_t orig_end_fsb = end_fsb; - bool atomic_hw = flags & IOMAP_ATOMIC_HW; + bool atomic_bio = flags & IOMAP_BIO_ATOMIC; int nimaps = 1, error = 0; unsigned int reflink_flags = 0; bool shared = false; @@ -895,7 +895,7 @@ xfs_direct_write_iomap_begin( if (error) goto out_unlock; if (shared) { - if (atomic_hw && + if (atomic_bio && !xfs_bmap_valid_for_atomic_write(&cmap, offset_fsb, end_fsb)) { error = -EAGAIN; @@ -909,7 +909,7 @@ xfs_direct_write_iomap_begin( needs_alloc = imap_needs_alloc(inode, flags, &imap, nimaps); - if (atomic_hw) { + if (atomic_bio) { error = -EAGAIN; /* * Use CoW method for when we need to alloc > 1 block, @@ -1141,11 +1141,11 @@ xfs_atomic_write_iomap_begin( ASSERT(flags & IOMAP_WRITE); ASSERT(flags & IOMAP_DIRECT); - if (flags & IOMAP_ATOMIC_SW) + if (flags & IOMAP_FS_ATOMIC) return xfs_atomic_write_sw_iomap_begin(inode, offset, length, flags, iomap, srcmap); - ASSERT(flags & IOMAP_ATOMIC_HW); + ASSERT(flags & IOMAP_BIO_ATOMIC); return xfs_direct_write_iomap_begin(inode, offset, length, flags, iomap, srcmap); } diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 9cd93530013c..5e44ca17a64a 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -189,9 +189,9 @@ struct iomap_folio_ops { #else #define IOMAP_DAX 0 #endif /* CONFIG_FS_DAX */ -#define IOMAP_ATOMIC_HW (1 << 9) /* HW-based torn-write protection */ -#define IOMAP_DONTCACHE (1 << 10) -#define IOMAP_ATOMIC_SW (1 << 11)/* SW-based torn-write protection */ +#define IOMAP_DONTCACHE (1 << 9) +#define IOMAP_BIO_ATOMIC (1 << 10) /* Use REQ_ATOMIC on single bio */ +#define IOMAP_FS_ATOMIC (1 << 11) /* FS-based torn-write protection */ struct iomap_ops { /* @@ -504,9 +504,9 @@ struct iomap_dio_ops { #define IOMAP_DIO_PARTIAL (1 << 2) /* - * Use software-based torn-write protection. + * Use FS-based torn-write protection. */ -#define IOMAP_DIO_ATOMIC_SW (1 << 3) +#define IOMAP_DIO_FS_ATOMIC (1 << 3) ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, const struct iomap_dio_ops *dops, -- 2.31.1