* [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