+
+ if (new_max_bytes) {
+ xfs_extlen_t max_write_fsbs =
+ rounddown_pow_of_two(XFS_B_TO_FSB(mp, MAX_RW_COUNT));
+ xfs_extlen_t max_group_fsbs =
+ max(mp->m_groups[XG_TYPE_AG].blocks,
+ mp->m_groups[XG_TYPE_RTG].blocks);
+
+ ASSERT(max_write_fsbs <= U32_MAX);
+
+ if (new_max_bytes % mp->m_sb.sb_blocksize > 0) {
+ xfs_warn(mp,
+ "max atomic write size of %llu bytes not aligned with fsblock",
+ new_max_bytes);
+ return -EINVAL;
+ }
+
+ if (new_max_fsbs > max_write_fsbs) {
+ xfs_warn(mp,
+ "max atomic write size of %lluk cannot be larger than max write size %lluk",
+ new_max_bytes >> 10,
+ XFS_FSB_TO_B(mp, max_write_fsbs) >> 10);
+ return -EINVAL;
+ }
+
+ if (new_max_fsbs > max_group_fsbs) {
+ xfs_warn(mp,
+ "max atomic write size of %lluk cannot be larger than allocation group size %lluk",
+ new_max_bytes >> 10,
+ XFS_FSB_TO_B(mp, max_group_fsbs) >> 10);
+ return -EINVAL;
+ }
+ }
+