Skip to content

Commit 85bf2df

Browse files
author
Darrick J. Wong
committed
xfs: ignore HW which cannot atomic write a single block
Currently only HW which can write at least 1x block is supported. For supporting atomic writes > 1x block, a CoW-based method will also be used and this will not be resticted to using HW which can write >= 1x block. However for deciding if HW-based atomic writes can be used, we need to start adding checks for write length < HW min, which complicates the code. Indeed, a statx field similar to unit_max_opt should also be added for this minimum, which is undesirable. HW which can only write > 1x blocks would be uncommon and quite weird, so let's just not support it. Signed-off-by: "Darrick J. Wong" <[email protected]> Signed-off-by: John Garry <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 805f898 commit 85bf2df

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

fs/xfs/xfs_buf.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,11 +1722,23 @@ static inline void
17221722
xfs_configure_buftarg_atomic_writes(
17231723
struct xfs_buftarg *btp)
17241724
{
1725+
struct xfs_mount *mp = btp->bt_mount;
17251726
unsigned int min_bytes, max_bytes;
17261727

17271728
min_bytes = bdev_atomic_write_unit_min_bytes(btp->bt_bdev);
17281729
max_bytes = bdev_atomic_write_unit_max_bytes(btp->bt_bdev);
17291730

1731+
/*
1732+
* Ignore atomic write geometry that is nonsense or doesn't even cover
1733+
* a single fsblock.
1734+
*/
1735+
if (min_bytes > max_bytes ||
1736+
min_bytes > mp->m_sb.sb_blocksize ||
1737+
max_bytes < mp->m_sb.sb_blocksize) {
1738+
min_bytes = 0;
1739+
max_bytes = 0;
1740+
}
1741+
17301742
btp->bt_bdev_awu_min = min_bytes;
17311743
btp->bt_bdev_awu_max = max_bytes;
17321744
}

fs/xfs/xfs_buf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct xfs_buftarg {
112112
struct percpu_counter bt_readahead_count;
113113
struct ratelimit_state bt_ioerror_rl;
114114

115-
/* Atomic write unit values */
115+
/* Atomic write unit values, bytes */
116116
unsigned int bt_bdev_awu_min;
117117
unsigned int bt_bdev_awu_max;
118118

fs/xfs/xfs_inode.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,7 @@ static inline bool xfs_inode_has_bigrtalloc(const struct xfs_inode *ip)
358358

359359
static inline bool xfs_inode_can_hw_atomic_write(const struct xfs_inode *ip)
360360
{
361-
struct xfs_mount *mp = ip->i_mount;
362-
struct xfs_buftarg *target = xfs_inode_buftarg(ip);
363-
364-
if (mp->m_sb.sb_blocksize < target->bt_bdev_awu_min)
365-
return false;
366-
if (mp->m_sb.sb_blocksize > target->bt_bdev_awu_max)
367-
return false;
368-
369-
return true;
361+
return xfs_inode_buftarg(ip)->bt_bdev_awu_max > 0;
370362
}
371363

372364
/*

0 commit comments

Comments
 (0)