file: don't trample on xfs flags when setting xfs size hint
file: don't trample on xfs flags when setting xfs size hint

When the extent_allocation_size_hint option is set, we use
the XFS_IOC_FSSETXATTR ioctl to pass it to the kernel, to set
the preferred extent size, avoiding trouble with direct I/O
block allocation. However, we also trample on other flags
and settings in the process, including the fsx_projid attribute
that controls quota management.

Fix by using read-modify-write to avoid unsetting these other
flags. We ignore errors on reads (as we do on writes) since the
ioctl may fail on non-xfs filesystems. Of course if the read fails
we must not issue the write ioctl.

While at it, move the no-op test (if no extent allocation hint
or using the page cache) to guard the get operation, not just set.

Credit to Maciej Zimnoch <maciej@scylladb.com> for isolating the
problem.

Fixes #1057
Message-Id: <9e35dbe4cc28950740606ba4caaaa1ce6e165ba7@scylladb.com>

scylladb/seastar,scylladb/seastar,syuu1228/seastar,avikivity/seastar,avikivity/seastar,syuu1228/seastar,avikivity/seastar,syuu1228/seastar,scylladb/seastar