* [PATCH 1/4] libxfs: refactor inode flags propagation code
2020-09-15 1:51 [PATCH 0/4] xfsprogs: even more fixes for 5.9 Darrick J. Wong
@ 2020-09-15 1:51 ` Darrick J. Wong
2020-09-17 8:01 ` Christoph Hellwig
2020-09-15 1:51 ` [PATCH 2/4] libxfs: don't propagate RTINHERIT -> REALTIME when there is no rtdev Darrick J. Wong
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Darrick J. Wong @ 2020-09-15 1:51 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
Hoist the code that propagates di_flags from a parent to a new child
into a separate function.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
libxfs/util.c | 55 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 32 insertions(+), 23 deletions(-)
diff --git a/libxfs/util.c b/libxfs/util.c
index 7fb0a99596f4..78519872e8e8 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -207,6 +207,36 @@ xfs_flags2diflags2(
return di_flags2;
}
+/* Propagate di_flags from a parent inode to a child inode. */
+static void
+xfs_inode_propagate_flags(
+ struct xfs_inode *ip,
+ const struct xfs_inode *pip)
+{
+ unsigned int di_flags = 0;
+ umode_t mode = VFS_I(ip)->i_mode;
+
+ if ((mode & S_IFMT) == S_IFDIR) {
+ if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
+ di_flags |= XFS_DIFLAG_RTINHERIT;
+ if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
+ di_flags |= XFS_DIFLAG_EXTSZINHERIT;
+ ip->i_d.di_extsize = pip->i_d.di_extsize;
+ }
+ } else {
+ if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {
+ di_flags |= XFS_DIFLAG_REALTIME;
+ }
+ if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
+ di_flags |= XFS_DIFLAG_EXTSIZE;
+ ip->i_d.di_extsize = pip->i_d.di_extsize;
+ }
+ }
+ if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
+ di_flags |= XFS_DIFLAG_PROJINHERIT;
+ ip->i_d.di_flags |= di_flags;
+}
+
/*
* Allocate an inode on disk and return a copy of its in-core version.
* Set mode, nlink, and rdev appropriately within the inode.
@@ -299,29 +329,8 @@ libxfs_ialloc(
break;
case S_IFREG:
case S_IFDIR:
- if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
- uint di_flags = 0;
-
- if ((mode & S_IFMT) == S_IFDIR) {
- if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
- di_flags |= XFS_DIFLAG_RTINHERIT;
- if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
- di_flags |= XFS_DIFLAG_EXTSZINHERIT;
- ip->i_d.di_extsize = pip->i_d.di_extsize;
- }
- } else {
- if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {
- di_flags |= XFS_DIFLAG_REALTIME;
- }
- if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
- di_flags |= XFS_DIFLAG_EXTSIZE;
- ip->i_d.di_extsize = pip->i_d.di_extsize;
- }
- }
- if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
- di_flags |= XFS_DIFLAG_PROJINHERIT;
- ip->i_d.di_flags |= di_flags;
- }
+ if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY))
+ xfs_inode_propagate_flags(ip, pip);
/* FALLTHROUGH */
case S_IFLNK:
ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/4] libxfs: don't propagate RTINHERIT -> REALTIME when there is no rtdev
2020-09-15 1:51 [PATCH 0/4] xfsprogs: even more fixes for 5.9 Darrick J. Wong
2020-09-15 1:51 ` [PATCH 1/4] libxfs: refactor inode flags propagation code Darrick J. Wong
@ 2020-09-15 1:51 ` Darrick J. Wong
2020-09-17 8:02 ` Christoph Hellwig
2020-09-28 21:26 ` Eric Sandeen
2020-09-15 1:51 ` [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file Darrick J. Wong
2020-09-15 1:51 ` [PATCH 4/4] xfs_repair: don't flag RTINHERIT files when no rt volume Darrick J. Wong
3 siblings, 2 replies; 13+ messages in thread
From: Darrick J. Wong @ 2020-09-15 1:51 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
When creating a file inside a directory that has RTINHERIT set, only
propagate the REALTIME flag to the file if the filesystem actually has a
realtime volume configured. Otherwise, we end up writing inodes that
trip the verifiers.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
libxfs/util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libxfs/util.c b/libxfs/util.c
index 78519872e8e8..f1b4759728ec 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -224,9 +224,9 @@ xfs_inode_propagate_flags(
ip->i_d.di_extsize = pip->i_d.di_extsize;
}
} else {
- if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {
+ if ((pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) &&
+ xfs_sb_version_hasrealtime(&ip->i_mount->m_sb))
di_flags |= XFS_DIFLAG_REALTIME;
- }
if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
di_flags |= XFS_DIFLAG_EXTSIZE;
ip->i_d.di_extsize = pip->i_d.di_extsize;
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 2/4] libxfs: don't propagate RTINHERIT -> REALTIME when there is no rtdev
2020-09-15 1:51 ` [PATCH 2/4] libxfs: don't propagate RTINHERIT -> REALTIME when there is no rtdev Darrick J. Wong
@ 2020-09-17 8:02 ` Christoph Hellwig
2020-09-28 21:26 ` Eric Sandeen
1 sibling, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2020-09-17 8:02 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, linux-xfs
On Mon, Sep 14, 2020 at 06:51:17PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> When creating a file inside a directory that has RTINHERIT set, only
> propagate the REALTIME flag to the file if the filesystem actually has a
> realtime volume configured. Otherwise, we end up writing inodes that
> trip the verifiers.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/4] libxfs: don't propagate RTINHERIT -> REALTIME when there is no rtdev
2020-09-15 1:51 ` [PATCH 2/4] libxfs: don't propagate RTINHERIT -> REALTIME when there is no rtdev Darrick J. Wong
2020-09-17 8:02 ` Christoph Hellwig
@ 2020-09-28 21:26 ` Eric Sandeen
1 sibling, 0 replies; 13+ messages in thread
From: Eric Sandeen @ 2020-09-28 21:26 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On 9/14/20 8:51 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> When creating a file inside a directory that has RTINHERIT set, only
> propagate the REALTIME flag to the file if the filesystem actually has a
> realtime volume configured. Otherwise, we end up writing inodes that
> trip the verifiers.
The "else" means this is only for non-directories; we still propagate
the inherit flag to dirs even without an RT subdir, because .... *shrug*
kernel lets you set it explicitly, and repair (now) doesn't care either?
Ok, seems reasonable.
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
-Eric
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> libxfs/util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>
> diff --git a/libxfs/util.c b/libxfs/util.c
> index 78519872e8e8..f1b4759728ec 100644
> --- a/libxfs/util.c
> +++ b/libxfs/util.c
> @@ -224,9 +224,9 @@ xfs_inode_propagate_flags(
> ip->i_d.di_extsize = pip->i_d.di_extsize;
> }
> } else {
> - if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {
> + if ((pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) &&
> + xfs_sb_version_hasrealtime(&ip->i_mount->m_sb))
> di_flags |= XFS_DIFLAG_REALTIME;
> - }
> if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
> di_flags |= XFS_DIFLAG_EXTSIZE;
> ip->i_d.di_extsize = pip->i_d.di_extsize;
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file
2020-09-15 1:51 [PATCH 0/4] xfsprogs: even more fixes for 5.9 Darrick J. Wong
2020-09-15 1:51 ` [PATCH 1/4] libxfs: refactor inode flags propagation code Darrick J. Wong
2020-09-15 1:51 ` [PATCH 2/4] libxfs: don't propagate RTINHERIT -> REALTIME when there is no rtdev Darrick J. Wong
@ 2020-09-15 1:51 ` Darrick J. Wong
2020-09-17 8:02 ` Christoph Hellwig
2020-09-28 21:10 ` Eric Sandeen
2020-09-15 1:51 ` [PATCH 4/4] xfs_repair: don't flag RTINHERIT files when no rt volume Darrick J. Wong
3 siblings, 2 replies; 13+ messages in thread
From: Darrick J. Wong @ 2020-09-15 1:51 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
If someone runs mkfs with rtinherit=1, a realtime volume configured, and
a protofile that creates a regular file in the filesystem, mkfs will
error out with "Function not implemented" because userspace doesn't know
how to allocate extents from the rt bitmap. Catch this specific case
and hand back a somewhat nicer explanation of what happened.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
mkfs/proto.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 9db8fe2d6447..20a7cc3bb5d5 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -244,6 +244,12 @@ newfile(
nb = XFS_B_TO_FSB(mp, len);
nmap = 1;
error = -libxfs_bmapi_write(tp, ip, 0, nb, 0, nb, &map, &nmap);
+ if (error == ENOSYS && XFS_IS_REALTIME_INODE(ip)) {
+ fprintf(stderr,
+ _("%s: creating realtime files from proto file not supported.\n"),
+ progname);
+ exit(1);
+ }
if (error) {
fail(_("error allocating space for a file"), error);
}
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file
2020-09-15 1:51 ` [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file Darrick J. Wong
@ 2020-09-17 8:02 ` Christoph Hellwig
2020-09-17 16:25 ` Darrick J. Wong
2020-09-28 21:10 ` Eric Sandeen
1 sibling, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2020-09-17 8:02 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, linux-xfs
On Mon, Sep 14, 2020 at 06:51:23PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> If someone runs mkfs with rtinherit=1, a realtime volume configured, and
> a protofile that creates a regular file in the filesystem, mkfs will
> error out with "Function not implemented" because userspace doesn't know
> how to allocate extents from the rt bitmap. Catch this specific case
> and hand back a somewhat nicer explanation of what happened.
Would this be so hard to fix?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file
2020-09-17 8:02 ` Christoph Hellwig
@ 2020-09-17 16:25 ` Darrick J. Wong
0 siblings, 0 replies; 13+ messages in thread
From: Darrick J. Wong @ 2020-09-17 16:25 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: sandeen, linux-xfs
On Thu, Sep 17, 2020 at 09:02:34AM +0100, Christoph Hellwig wrote:
> On Mon, Sep 14, 2020 at 06:51:23PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > If someone runs mkfs with rtinherit=1, a realtime volume configured, and
> > a protofile that creates a regular file in the filesystem, mkfs will
> > error out with "Function not implemented" because userspace doesn't know
> > how to allocate extents from the rt bitmap. Catch this specific case
> > and hand back a somewhat nicer explanation of what happened.
>
> Would this be so hard to fix?
Probably not, but I'd prefer to see users asking for this feature before
porting more code to userspace.
I guess I could take a look for 5.10, maybe it's not that difficult.
Though given the amount of bitrot and math errors I've seen recently, I
get the funny sense that my crash test box and TV are the only things
using rt support.
--D
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file
2020-09-15 1:51 ` [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file Darrick J. Wong
2020-09-17 8:02 ` Christoph Hellwig
@ 2020-09-28 21:10 ` Eric Sandeen
1 sibling, 0 replies; 13+ messages in thread
From: Eric Sandeen @ 2020-09-28 21:10 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On 9/14/20 8:51 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> If someone runs mkfs with rtinherit=1, a realtime volume configured, and
> a protofile that creates a regular file in the filesystem, mkfs will
> error out with "Function not implemented" because userspace doesn't know
> how to allocate extents from the rt bitmap. Catch this specific case
> and hand back a somewhat nicer explanation of what happened.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
hch has a point about "maybe we should fix it" but it seems like it's
not somewhere we really need to spend development effort right now.
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> ---
> mkfs/proto.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index 9db8fe2d6447..20a7cc3bb5d5 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -244,6 +244,12 @@ newfile(
> nb = XFS_B_TO_FSB(mp, len);
> nmap = 1;
> error = -libxfs_bmapi_write(tp, ip, 0, nb, 0, nb, &map, &nmap);
> + if (error == ENOSYS && XFS_IS_REALTIME_INODE(ip)) {
> + fprintf(stderr,
> + _("%s: creating realtime files from proto file not supported.\n"),
> + progname);
> + exit(1);
> + }
> if (error) {
> fail(_("error allocating space for a file"), error);
> }
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/4] xfs_repair: don't flag RTINHERIT files when no rt volume
2020-09-15 1:51 [PATCH 0/4] xfsprogs: even more fixes for 5.9 Darrick J. Wong
` (2 preceding siblings ...)
2020-09-15 1:51 ` [PATCH 3/4] mkfs: don't allow creation of realtime files from a proto file Darrick J. Wong
@ 2020-09-15 1:51 ` Darrick J. Wong
2020-09-17 8:02 ` Christoph Hellwig
3 siblings, 1 reply; 13+ messages in thread
From: Darrick J. Wong @ 2020-09-15 1:51 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
Don't flag directories with the RTINHERIT flag set when the filesystem
doesn't have a realtime volume configured. The kernel has let us set
RTINHERIT without a rt volume for ages, so it's not an invalid state.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
repair/dinode.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/repair/dinode.c b/repair/dinode.c
index 48b75f7883c5..8aee9f9e8343 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -2393,17 +2393,14 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),
flags &= XFS_DIFLAG_ANY;
}
- if (flags & (XFS_DIFLAG_REALTIME | XFS_DIFLAG_RTINHERIT)) {
- /* need an rt-dev! */
- if (!rt_name) {
- if (!uncertain) {
- do_warn(
+ /* need an rt-dev for the realtime flag! */
+ if ((flags & XFS_DIFLAG_REALTIME) && !rt_name) {
+ if (!uncertain) {
+ do_warn(
_("inode %" PRIu64 " has RT flag set but there is no RT device\n"),
- lino);
- }
- flags &= ~(XFS_DIFLAG_REALTIME |
- XFS_DIFLAG_RTINHERIT);
+ lino);
}
+ flags &= ~XFS_DIFLAG_REALTIME;
}
if (flags & XFS_DIFLAG_NEWRTBM) {
/* must be a rt bitmap inode */
^ permalink raw reply related [flat|nested] 13+ messages in thread