mirror of
https://github.com/torvalds/linux.git
synced 2024-11-29 07:31:29 +00:00
603f000b15
The RTINHERIT bit can be set on a directory so that newly created regular files will have the REALTIME bit set to store their data on the realtime volume. If an extent size hint (and EXTSZINHERIT) are set on the directory, the hint will also be copied into the new file. As pointed out in previous patches, for realtime files we require the extent size hint be an integer multiple of the realtime extent, but we don't perform the same validation on a directory with both RTINHERIT and EXTSZINHERIT set, even though the only use-case of that combination is to propagate extent size hints into new realtime files. This leads to inode corruption errors when the bad values are propagated. Because there may be existing filesystems with such a configuration, we cannot simply amend the inode verifier to trip on these directories and call it a day because that will cause previously "working" filesystems to start throwing errors abruptly. Note that it's valid to have directories with rtinherit set even if there is no realtime volume, in which case the problem does not manifest because rtinherit is ignored if there's no realtime device; and it's possible that someone set the flag, crashed, repaired the filesystem (which clears the hint on the realtime file) and continued. Therefore, mitigate this issue in several ways: First, if we try to write out an inode with both rtinherit/extszinherit set and an unaligned extent size hint, turn off the hint to correct the error. Second, if someone tries to misconfigure a directory via the fssetxattr ioctl, fail the ioctl. Third, reverify both extent size hint values when we propagate heritable inode attributes from parent to child, to prevent misconfigurations from spreading. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
88 lines
3.0 KiB
C
88 lines
3.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __XFS_MESSAGE_H
|
|
#define __XFS_MESSAGE_H 1
|
|
|
|
struct xfs_mount;
|
|
|
|
extern __printf(2, 3)
|
|
void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...);
|
|
extern __printf(2, 3)
|
|
void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...);
|
|
extern __printf(3, 4)
|
|
void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...);
|
|
extern __printf(2, 3)
|
|
void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...);
|
|
extern __printf(2, 3)
|
|
void xfs_err(const struct xfs_mount *mp, const char *fmt, ...);
|
|
extern __printf(2, 3)
|
|
void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...);
|
|
extern __printf(2, 3)
|
|
void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...);
|
|
extern __printf(2, 3)
|
|
void xfs_info(const struct xfs_mount *mp, const char *fmt, ...);
|
|
|
|
#ifdef DEBUG
|
|
extern __printf(2, 3)
|
|
void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...);
|
|
#else
|
|
static inline __printf(2, 3)
|
|
void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#define xfs_printk_ratelimited(func, dev, fmt, ...) \
|
|
do { \
|
|
static DEFINE_RATELIMIT_STATE(_rs, \
|
|
DEFAULT_RATELIMIT_INTERVAL, \
|
|
DEFAULT_RATELIMIT_BURST); \
|
|
if (__ratelimit(&_rs)) \
|
|
func(dev, fmt, ##__VA_ARGS__); \
|
|
} while (0)
|
|
|
|
#define xfs_printk_once(func, dev, fmt, ...) \
|
|
({ \
|
|
static bool __section(".data.once") __print_once; \
|
|
bool __ret_print_once = !__print_once; \
|
|
\
|
|
if (!__print_once) { \
|
|
__print_once = true; \
|
|
func(dev, fmt, ##__VA_ARGS__); \
|
|
} \
|
|
unlikely(__ret_print_once); \
|
|
})
|
|
|
|
#define xfs_emerg_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_emerg, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_alert_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_alert, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_crit_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_crit, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_err_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_err, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_warn_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_warn, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_notice_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_notice, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_info_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_info, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_debug_ratelimited(dev, fmt, ...) \
|
|
xfs_printk_ratelimited(xfs_debug, dev, fmt, ##__VA_ARGS__)
|
|
|
|
#define xfs_warn_once(dev, fmt, ...) \
|
|
xfs_printk_once(xfs_warn, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_notice_once(dev, fmt, ...) \
|
|
xfs_printk_once(xfs_notice, dev, fmt, ##__VA_ARGS__)
|
|
#define xfs_info_once(dev, fmt, ...) \
|
|
xfs_printk_once(xfs_info, dev, fmt, ##__VA_ARGS__)
|
|
|
|
void assfail(struct xfs_mount *mp, char *expr, char *f, int l);
|
|
void asswarn(struct xfs_mount *mp, char *expr, char *f, int l);
|
|
|
|
extern void xfs_hex_dump(const void *p, int length);
|
|
|
|
void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg,
|
|
const char *fmt, ...);
|
|
|
|
#endif /* __XFS_MESSAGE_H */
|