All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] xfs: reverse mapping fixes
@ 2016-08-24  2:20 Darrick J. Wong
  2016-08-24  2:20 ` [PATCH 1/5] xfs: don't log the entire end of the AGF Darrick J. Wong
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Darrick J. Wong @ 2016-08-24  2:20 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, xfs

Hi all,

This is a roll-up of a few fixes[1] for reverse-mapping in 4.8.

The patches have been xfstested with the 'auto' group on x64
and (afaict) don't cause any regressions.

This is an extraordinary way to eat your data.  Enjoy! 
Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux/tree/for-dave-for-4.8-6

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/5] xfs: don't log the entire end of the AGF
  2016-08-24  2:20 [PATCH 0/5] xfs: reverse mapping fixes Darrick J. Wong
@ 2016-08-24  2:20 ` Darrick J. Wong
  2016-08-25  8:09   ` Christoph Hellwig
  2016-08-24  2:20 ` [PATCH 2/5] xfs: don't perform lookups on zero-height btrees Darrick J. Wong
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2016-08-24  2:20 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, xfs

When we're logging the last non-spare field in the AGF, we don't
need to log the spare fields, so plumb in a new AGF logging flag
to help us avoid that.

(This patch is already in xfsprogs.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_alloc.c  |    2 ++
 fs/xfs/libxfs/xfs_format.h |    6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 3dd8f1d..05b5243 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -2278,6 +2278,8 @@ xfs_alloc_log_agf(
 		offsetof(xfs_agf_t, agf_btreeblks),
 		offsetof(xfs_agf_t, agf_uuid),
 		offsetof(xfs_agf_t, agf_rmap_blocks),
+		/* needed so that we don't log the whole rest of the structure: */
+		offsetof(xfs_agf_t, agf_spare64),
 		sizeof(xfs_agf_t)
 	};
 
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index e6a8bea..270fb5c 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -674,7 +674,8 @@ typedef struct xfs_agf {
 #define	XFS_AGF_BTREEBLKS	0x00000800
 #define	XFS_AGF_UUID		0x00001000
 #define	XFS_AGF_RMAP_BLOCKS	0x00002000
-#define	XFS_AGF_NUM_BITS	14
+#define	XFS_AGF_SPARE64		0x00004000
+#define	XFS_AGF_NUM_BITS	15
 #define	XFS_AGF_ALL_BITS	((1 << XFS_AGF_NUM_BITS) - 1)
 
 #define XFS_AGF_FLAGS \
@@ -691,7 +692,8 @@ typedef struct xfs_agf {
 	{ XFS_AGF_LONGEST,	"LONGEST" }, \
 	{ XFS_AGF_BTREEBLKS,	"BTREEBLKS" }, \
 	{ XFS_AGF_UUID,		"UUID" }, \
-	{ XFS_AGF_RMAP_BLOCKS,	"RMAP_BLOCKS" }
+	{ XFS_AGF_RMAP_BLOCKS,	"RMAP_BLOCKS" }, \
+	{ XFS_AGF_SPARE64,	"SPARE64" }
 
 /* disk block (xfs_daddr_t) in the AG */
 #define XFS_AGF_DADDR(mp)	((xfs_daddr_t)(1 << (mp)->m_sectbb_log))

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/5] xfs: don't perform lookups on zero-height btrees
  2016-08-24  2:20 [PATCH 0/5] xfs: reverse mapping fixes Darrick J. Wong
  2016-08-24  2:20 ` [PATCH 1/5] xfs: don't log the entire end of the AGF Darrick J. Wong
@ 2016-08-24  2:20 ` Darrick J. Wong
  2016-08-25  8:10   ` Christoph Hellwig
  2016-08-24  2:20 ` [PATCH 3/5] xfs: fix some key handling problems in _btree_simple_query_range Darrick J. Wong
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2016-08-24  2:20 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, xfs

If the caller passes in a cursor to a zero-height btree (which is
impossible), we never set block to anything but NULL, which causes the
later dereference of it to crash.  Instead, just return -EFSCORRUPTED.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_btree.c |    4 ++++
 1 file changed, 4 insertions(+)


diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index b5c213a..33f1406 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -1814,6 +1814,10 @@ xfs_btree_lookup(
 
 	XFS_BTREE_STATS_INC(cur, lookup);
 
+	/* No such thing as a zero-level tree. */
+	if (cur->bc_nlevels == 0)
+		return -EFSCORRUPTED;
+
 	block = NULL;
 	keyno = 0;
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] xfs: fix some key handling problems in _btree_simple_query_range
  2016-08-24  2:20 [PATCH 0/5] xfs: reverse mapping fixes Darrick J. Wong
  2016-08-24  2:20 ` [PATCH 1/5] xfs: don't log the entire end of the AGF Darrick J. Wong
  2016-08-24  2:20 ` [PATCH 2/5] xfs: don't perform lookups on zero-height btrees Darrick J. Wong
@ 2016-08-24  2:20 ` Darrick J. Wong
  2016-08-25  8:10   ` Christoph Hellwig
  2016-08-24  2:20 ` [PATCH 4/5] xfs: simple btree query range should look right if LE lookup fails Darrick J. Wong
  2016-08-24  2:20 ` [PATCH 5/5] xfs: disallow mounting of realtime + rmap filesystems Darrick J. Wong
  4 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2016-08-24  2:20 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, xfs

We only need the record's high key for the first record that we look
at; for all records, we /definitely/ need the regular record key.
Therefore, fix how the simple range query function gets its keys.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_btree.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 33f1406..b70d9f9 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -4563,10 +4563,10 @@ xfs_btree_simple_query_range(
 		error = xfs_btree_get_rec(cur, &recp, &stat);
 		if (error || !stat)
 			break;
-		cur->bc_ops->init_high_key_from_rec(&rec_key, recp);
 
 		/* Skip if high_key(rec) < low_key. */
 		if (firstrec) {
+			cur->bc_ops->init_high_key_from_rec(&rec_key, recp);
 			firstrec = false;
 			diff = cur->bc_ops->diff_two_keys(cur, low_key,
 					&rec_key);
@@ -4575,6 +4575,7 @@ xfs_btree_simple_query_range(
 		}
 
 		/* Stop if high_key < low_key(rec). */
+		cur->bc_ops->init_key_from_rec(&rec_key, recp);
 		diff = cur->bc_ops->diff_two_keys(cur, &rec_key, high_key);
 		if (diff > 0)
 			break;

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] xfs: simple btree query range should look right if LE lookup fails
  2016-08-24  2:20 [PATCH 0/5] xfs: reverse mapping fixes Darrick J. Wong
                   ` (2 preceding siblings ...)
  2016-08-24  2:20 ` [PATCH 3/5] xfs: fix some key handling problems in _btree_simple_query_range Darrick J. Wong
@ 2016-08-24  2:20 ` Darrick J. Wong
  2016-08-25  8:11   ` Christoph Hellwig
  2016-08-24  2:20 ` [PATCH 5/5] xfs: disallow mounting of realtime + rmap filesystems Darrick J. Wong
  4 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2016-08-24  2:20 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, xfs

If the initial LOOKUP_LE in the simple query range fails to find
anything, we should attempt to increment the btree cursor to see
if there actually /are/ records for what we're trying to find.
Without this patch, a bnobt range query of (0, $agsize) returns
no results because the leftmost record never has a startblock
of zero.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_btree.c |    7 +++++++
 1 file changed, 7 insertions(+)


diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index b70d9f9..0856979 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -4558,6 +4558,13 @@ xfs_btree_simple_query_range(
 	if (error)
 		goto out;
 
+	/* Nothing?  See if there's anything to the right. */
+	if (!stat) {
+		error = xfs_btree_increment(cur, 0, &stat);
+		if (error)
+			goto out;
+	}
+
 	while (stat) {
 		/* Find the record. */
 		error = xfs_btree_get_rec(cur, &recp, &stat);

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] xfs: disallow mounting of realtime + rmap filesystems
  2016-08-24  2:20 [PATCH 0/5] xfs: reverse mapping fixes Darrick J. Wong
                   ` (3 preceding siblings ...)
  2016-08-24  2:20 ` [PATCH 4/5] xfs: simple btree query range should look right if LE lookup fails Darrick J. Wong
@ 2016-08-24  2:20 ` Darrick J. Wong
  2016-08-25  8:11   ` Christoph Hellwig
  4 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2016-08-24  2:20 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, xfs

Since the kernel doesn't currently support the realtime rmapbt,
don't allow such filesystems to be mounted.  Support will appear
in a future release.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_super.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)


diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 24ef83e..fd6be45 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1574,9 +1574,16 @@ xfs_fs_fill_super(
 		}
 	}
 
-	if (xfs_sb_version_hasrmapbt(&mp->m_sb))
+	if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {
+		if (mp->m_sb.sb_rblocks) {
+			xfs_alert(mp,
+	"EXPERIMENTAL reverse mapping btree not compatible with realtime device!");
+			error = -EINVAL;
+			goto out_filestream_unmount;
+		}
 		xfs_alert(mp,
 	"EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!");
+	}
 
 	error = xfs_mountfs(mp);
 	if (error)

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] xfs: don't log the entire end of the AGF
  2016-08-24  2:20 ` [PATCH 1/5] xfs: don't log the entire end of the AGF Darrick J. Wong
@ 2016-08-25  8:09   ` Christoph Hellwig
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2016-08-25  8:09 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, xfs

On Tue, Aug 23, 2016 at 07:20:35PM -0700, Darrick J. Wong wrote:
> When we're logging the last non-spare field in the AGF, we don't
> need to log the spare fields, so plumb in a new AGF logging flag
> to help us avoid that.
> 
> (This patch is already in xfsprogs.)

Looks fine, and reminds me that I need to send out my patches that
fix the SGF/AGI logging API..

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/5] xfs: don't perform lookups on zero-height btrees
  2016-08-24  2:20 ` [PATCH 2/5] xfs: don't perform lookups on zero-height btrees Darrick J. Wong
@ 2016-08-25  8:10   ` Christoph Hellwig
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2016-08-25  8:10 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, xfs

Looks fine, but could probably use an unlikely():

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] xfs: fix some key handling problems in _btree_simple_query_range
  2016-08-24  2:20 ` [PATCH 3/5] xfs: fix some key handling problems in _btree_simple_query_range Darrick J. Wong
@ 2016-08-25  8:10   ` Christoph Hellwig
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2016-08-25  8:10 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, xfs

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] xfs: simple btree query range should look right if LE lookup fails
  2016-08-24  2:20 ` [PATCH 4/5] xfs: simple btree query range should look right if LE lookup fails Darrick J. Wong
@ 2016-08-25  8:11   ` Christoph Hellwig
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2016-08-25  8:11 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, xfs

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] xfs: disallow mounting of realtime + rmap filesystems
  2016-08-24  2:20 ` [PATCH 5/5] xfs: disallow mounting of realtime + rmap filesystems Darrick J. Wong
@ 2016-08-25  8:11   ` Christoph Hellwig
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2016-08-25  8:11 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, xfs

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-08-25  8:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24  2:20 [PATCH 0/5] xfs: reverse mapping fixes Darrick J. Wong
2016-08-24  2:20 ` [PATCH 1/5] xfs: don't log the entire end of the AGF Darrick J. Wong
2016-08-25  8:09   ` Christoph Hellwig
2016-08-24  2:20 ` [PATCH 2/5] xfs: don't perform lookups on zero-height btrees Darrick J. Wong
2016-08-25  8:10   ` Christoph Hellwig
2016-08-24  2:20 ` [PATCH 3/5] xfs: fix some key handling problems in _btree_simple_query_range Darrick J. Wong
2016-08-25  8:10   ` Christoph Hellwig
2016-08-24  2:20 ` [PATCH 4/5] xfs: simple btree query range should look right if LE lookup fails Darrick J. Wong
2016-08-25  8:11   ` Christoph Hellwig
2016-08-24  2:20 ` [PATCH 5/5] xfs: disallow mounting of realtime + rmap filesystems Darrick J. Wong
2016-08-25  8:11   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.