diff mbox series

[v2] libxfs: disallow filesystems with reverse mapping and reflink and realtime

Message ID 20200930160112.GN49547@magnolia (mailing list archive)
State Accepted
Headers show
Series [v2] libxfs: disallow filesystems with reverse mapping and reflink and realtime | expand

Commit Message

Darrick J. Wong Sept. 30, 2020, 4:01 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Neither the kernel nor the code in xfsprogs support filesystems that
have (either reverse mapping btrees or reflink) enabled and a realtime
volume configured.  The kernel rejects such combinations and mkfs
refuses to format such a config, but xfsprogs doesn't check and can do
Bad Things, so port those checks before someone shreds their filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: move code to rtmount_init where it belongs
---
 libxfs/init.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Eric Sandeen Sept. 30, 2020, 4:09 p.m. UTC | #1
On 9/30/20 11:01 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Neither the kernel nor the code in xfsprogs support filesystems that
> have (either reverse mapping btrees or reflink) enabled and a realtime
> volume configured.  The kernel rejects such combinations and mkfs
> refuses to format such a config, but xfsprogs doesn't check and can do
> Bad Things, so port those checks before someone shreds their filesystem.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>


so now xfs_db won't even touch it, I'm not sure that's desirable.

# db/xfs_db fsfile
xfs_db: Reflink not compatible with realtime device. Please try a newer xfsprogs.
xfs_db: realtime device init failed
xfs_db: device fsfile unusable (not an XFS filesystem?)

-Eric

> ---
> v2: move code to rtmount_init where it belongs
> ---
>  libxfs/init.c |   15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/libxfs/init.c b/libxfs/init.c
> index cb8967bc77d4..330c645190d9 100644
> --- a/libxfs/init.c
> +++ b/libxfs/init.c
> @@ -428,6 +428,21 @@ rtmount_init(
>  	sbp = &mp->m_sb;
>  	if (sbp->sb_rblocks == 0)
>  		return 0;
> +
> +	if (xfs_sb_version_hasreflink(sbp)) {
> +		fprintf(stderr,
> +	_("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),
> +				progname);
> +		return -1;
> +	}
> +
> +	if (xfs_sb_version_hasrmapbt(sbp)) {
> +		fprintf(stderr,
> +	_("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
> +				progname);
> +		return -1;
> +	}
> +
>  	if (mp->m_rtdev_targp->dev == 0 && !(flags & LIBXFS_MOUNT_DEBUGGER)) {
>  		fprintf(stderr, _("%s: filesystem has a realtime subvolume\n"),
>  			progname);
>
Darrick J. Wong Sept. 30, 2020, 4:19 p.m. UTC | #2
On Wed, Sep 30, 2020 at 11:09:29AM -0500, Eric Sandeen wrote:
> On 9/30/20 11:01 AM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Neither the kernel nor the code in xfsprogs support filesystems that
> > have (either reverse mapping btrees or reflink) enabled and a realtime
> > volume configured.  The kernel rejects such combinations and mkfs
> > refuses to format such a config, but xfsprogs doesn't check and can do
> > Bad Things, so port those checks before someone shreds their filesystem.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 
> so now xfs_db won't even touch it, I'm not sure that's desirable.
> 
> # db/xfs_db fsfile
> xfs_db: Reflink not compatible with realtime device. Please try a newer xfsprogs.
> xfs_db: realtime device init failed
> xfs_db: device fsfile unusable (not an XFS filesystem?)

Er... did you specially craft fsfile to have rblocks>0 and reflink=1?
Or are you saying that it rejects any reflink=1 filesystem now?

--D

> 
> -Eric
> 
> > ---
> > v2: move code to rtmount_init where it belongs
> > ---
> >  libxfs/init.c |   15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/libxfs/init.c b/libxfs/init.c
> > index cb8967bc77d4..330c645190d9 100644
> > --- a/libxfs/init.c
> > +++ b/libxfs/init.c
> > @@ -428,6 +428,21 @@ rtmount_init(
> >  	sbp = &mp->m_sb;
> >  	if (sbp->sb_rblocks == 0)
> >  		return 0;
> > +
> > +	if (xfs_sb_version_hasreflink(sbp)) {
> > +		fprintf(stderr,
> > +	_("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),
> > +				progname);
> > +		return -1;
> > +	}
> > +
> > +	if (xfs_sb_version_hasrmapbt(sbp)) {
> > +		fprintf(stderr,
> > +	_("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
> > +				progname);
> > +		return -1;
> > +	}
> > +
> >  	if (mp->m_rtdev_targp->dev == 0 && !(flags & LIBXFS_MOUNT_DEBUGGER)) {
> >  		fprintf(stderr, _("%s: filesystem has a realtime subvolume\n"),
> >  			progname);
> >
Eric Sandeen Sept. 30, 2020, 4:21 p.m. UTC | #3
On 9/30/20 11:01 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Neither the kernel nor the code in xfsprogs support filesystems that
> have (either reverse mapping btrees or reflink) enabled and a realtime
> volume configured.  The kernel rejects such combinations and mkfs
> refuses to format such a config, but xfsprogs doesn't check and can do
> Bad Things, so port those checks before someone shreds their filesystem.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Ok, we already reject any other incompatibilities elsewehre, for any user
of the libxfs_mount callchain, so this is consistent.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
> v2: move code to rtmount_init where it belongs
> ---
>  libxfs/init.c |   15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/libxfs/init.c b/libxfs/init.c
> index cb8967bc77d4..330c645190d9 100644
> --- a/libxfs/init.c
> +++ b/libxfs/init.c
> @@ -428,6 +428,21 @@ rtmount_init(
>  	sbp = &mp->m_sb;
>  	if (sbp->sb_rblocks == 0)
>  		return 0;
> +
> +	if (xfs_sb_version_hasreflink(sbp)) {
> +		fprintf(stderr,
> +	_("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),
> +				progname);
> +		return -1;
> +	}
> +
> +	if (xfs_sb_version_hasrmapbt(sbp)) {
> +		fprintf(stderr,
> +	_("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
> +				progname);
> +		return -1;
> +	}
> +
>  	if (mp->m_rtdev_targp->dev == 0 && !(flags & LIBXFS_MOUNT_DEBUGGER)) {
>  		fprintf(stderr, _("%s: filesystem has a realtime subvolume\n"),
>  			progname);
>
Eric Sandeen Sept. 30, 2020, 5:14 p.m. UTC | #4
On 9/30/20 11:19 AM, Darrick J. Wong wrote:
> On Wed, Sep 30, 2020 at 11:09:29AM -0500, Eric Sandeen wrote:
>> On 9/30/20 11:01 AM, Darrick J. Wong wrote:
>>> From: Darrick J. Wong <darrick.wong@oracle.com>
>>>
>>> Neither the kernel nor the code in xfsprogs support filesystems that
>>> have (either reverse mapping btrees or reflink) enabled and a realtime
>>> volume configured.  The kernel rejects such combinations and mkfs
>>> refuses to format such a config, but xfsprogs doesn't check and can do
>>> Bad Things, so port those checks before someone shreds their filesystem.
>>>
>>> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
>>
>>
>> so now xfs_db won't even touch it, I'm not sure that's desirable.
>>
>> # db/xfs_db fsfile
>> xfs_db: Reflink not compatible with realtime device. Please try a newer xfsprogs.
>> xfs_db: realtime device init failed
>> xfs_db: device fsfile unusable (not an XFS filesystem?)
> 
> Er... did you specially craft fsfile to have rblocks>0 and reflink=1?
> Or are you saying that it rejects any reflink=1 filesystem now?

crafted.  sorry didn't mean to scare you ;)

-Eric
diff mbox series

Patch

diff --git a/libxfs/init.c b/libxfs/init.c
index cb8967bc77d4..330c645190d9 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -428,6 +428,21 @@  rtmount_init(
 	sbp = &mp->m_sb;
 	if (sbp->sb_rblocks == 0)
 		return 0;
+
+	if (xfs_sb_version_hasreflink(sbp)) {
+		fprintf(stderr,
+	_("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),
+				progname);
+		return -1;
+	}
+
+	if (xfs_sb_version_hasrmapbt(sbp)) {
+		fprintf(stderr,
+	_("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
+				progname);
+		return -1;
+	}
+
 	if (mp->m_rtdev_targp->dev == 0 && !(flags & LIBXFS_MOUNT_DEBUGGER)) {
 		fprintf(stderr, _("%s: filesystem has a realtime subvolume\n"),
 			progname);