Skip to content

Commit 7e17483

Browse files
Christoph Hellwigbrauner
authored andcommitted
xfs: cleanup xfs_vn_getattr
Split the two bits of optional statx reporting into their own helpers so that they are self-contained instead of deeply indented in the main getattr handler. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: John Garry <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 7ed6cbe commit 7e17483

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

fs/xfs/xfs_iops.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,28 @@ xfs_stat_blksize(
573573
}
574574

575575
static void
576-
xfs_get_atomic_write_attr(
576+
xfs_report_dioalign(
577577
struct xfs_inode *ip,
578-
unsigned int *unit_min,
579-
unsigned int *unit_max)
578+
struct kstat *stat)
580579
{
581-
if (!xfs_inode_can_atomicwrite(ip)) {
582-
*unit_min = *unit_max = 0;
583-
return;
584-
}
580+
struct xfs_buftarg *target = xfs_inode_buftarg(ip);
581+
struct block_device *bdev = target->bt_bdev;
585582

586-
*unit_min = *unit_max = ip->i_mount->m_sb.sb_blocksize;
583+
stat->result_mask |= STATX_DIOALIGN;
584+
stat->dio_mem_align = bdev_dma_alignment(bdev) + 1;
585+
stat->dio_offset_align = bdev_logical_block_size(bdev);
586+
}
587+
588+
static void
589+
xfs_report_atomic_write(
590+
struct xfs_inode *ip,
591+
struct kstat *stat)
592+
{
593+
unsigned int unit_min = 0, unit_max = 0;
594+
595+
if (xfs_inode_can_atomicwrite(ip))
596+
unit_min = unit_max = ip->i_mount->m_sb.sb_blocksize;
597+
generic_fill_statx_atomic_writes(stat, unit_min, unit_max);
587598
}
588599

589600
STATIC int
@@ -647,22 +658,10 @@ xfs_vn_getattr(
647658
stat->rdev = inode->i_rdev;
648659
break;
649660
case S_IFREG:
650-
if (request_mask & STATX_DIOALIGN) {
651-
struct xfs_buftarg *target = xfs_inode_buftarg(ip);
652-
struct block_device *bdev = target->bt_bdev;
653-
654-
stat->result_mask |= STATX_DIOALIGN;
655-
stat->dio_mem_align = bdev_dma_alignment(bdev) + 1;
656-
stat->dio_offset_align = bdev_logical_block_size(bdev);
657-
}
658-
if (request_mask & STATX_WRITE_ATOMIC) {
659-
unsigned int unit_min, unit_max;
660-
661-
xfs_get_atomic_write_attr(ip, &unit_min,
662-
&unit_max);
663-
generic_fill_statx_atomic_writes(stat,
664-
unit_min, unit_max);
665-
}
661+
if (request_mask & STATX_DIOALIGN)
662+
xfs_report_dioalign(ip, stat);
663+
if (request_mask & STATX_WRITE_ATOMIC)
664+
xfs_report_atomic_write(ip, stat);
666665
fallthrough;
667666
default:
668667
stat->blksize = xfs_stat_blksize(ip);

0 commit comments

Comments
 (0)