diff mbox series

[3/4] mkfs: don't allow creation of realtime files from a proto file

Message ID 160013468391.2932378.13825727040727340226.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfsprogs: even more fixes for 5.9 | expand

Commit Message

Darrick J. Wong Sept. 15, 2020, 1:51 a.m. UTC
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(+)

Comments

Christoph Hellwig Sept. 17, 2020, 8:02 a.m. UTC | #1
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?
Darrick J. Wong Sept. 17, 2020, 4:25 p.m. UTC | #2
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
Eric Sandeen Sept. 28, 2020, 9:10 p.m. UTC | #3
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);
>  		}
>
diff mbox series

Patch

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);
 		}