* [PATCH 0/2 RESEND] xfs: small bugfixes
@ 2014-10-01 15:18 Eric Sandeen
2014-10-01 15:22 ` [PATCH 1/2] xfs: don't send null bp to xfs_trans_brelse() Eric Sandeen
2014-10-01 15:24 ` [PATCH 2/2] xfs: fix crc field handling in xfs_sb_to/from_disk Eric Sandeen
0 siblings, 2 replies; 6+ messages in thread
From: Eric Sandeen @ 2014-10-01 15:18 UTC (permalink / raw)
To: xfs-oss
These are 2 patches which were already sent for kernel
& userspace; they made it to userspace, but I don't see
them in for-next, so resending.
Thanks,
-Eric
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] xfs: don't send null bp to xfs_trans_brelse()
2014-10-01 15:18 [PATCH 0/2 RESEND] xfs: small bugfixes Eric Sandeen
@ 2014-10-01 15:22 ` Eric Sandeen
2014-10-01 15:55 ` Christoph Hellwig
2014-10-01 15:24 ` [PATCH 2/2] xfs: fix crc field handling in xfs_sb_to/from_disk Eric Sandeen
1 sibling, 1 reply; 6+ messages in thread
From: Eric Sandeen @ 2014-10-01 15:22 UTC (permalink / raw)
To: xfs-oss
In this case, if bp is NULL, error is set, and we send a
NULL bp to xfs_trans_brelse, which will try to dereference it.
Test whether we actually have a buffer before we try to
free it.
Coverity spotted this.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 2c42ae2..fd82753 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2563,7 +2563,8 @@ xfs_da_get_buf(
mapp, nmap, 0);
error = bp ? bp->b_error : -EIO;
if (error) {
- xfs_trans_brelse(trans, bp);
+ if (bp)
+ xfs_trans_brelse(trans, bp);
goto out_free;
}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] xfs: fix crc field handling in xfs_sb_to/from_disk
2014-10-01 15:18 [PATCH 0/2 RESEND] xfs: small bugfixes Eric Sandeen
2014-10-01 15:22 ` [PATCH 1/2] xfs: don't send null bp to xfs_trans_brelse() Eric Sandeen
@ 2014-10-01 15:24 ` Eric Sandeen
2014-10-01 15:56 ` Christoph Hellwig
1 sibling, 1 reply; 6+ messages in thread
From: Eric Sandeen @ 2014-10-01 15:24 UTC (permalink / raw)
To: xfs-oss
I discovered this in userspace, but the same change applies
to the kernel.
If we xfs_mdrestore an image from a non-crc filesystem, lo
and behold the restored image has gained a CRC:
# db/xfs_metadump.sh -o /dev/sdc1 - | xfs_mdrestore - test.img
# xfs_db -c "sb 0" -c "p crc" /dev/sdc1
crc = 0 (correct)
# xfs_db -c "sb 0" -c "p crc" test.img
crc = 0xb6f8d6a0 (correct)
This is because xfs_sb_from_disk doesn't fill in sb_crc,
but xfs_sb_to_disk(XFS_SB_ALL_BITS) does write the in-memory
CRC to disk - so we get uninitialized memory on disk.
Fix this by always initializing sb_crc to 0 when we read
the superblock, and masking out the CRC bit from ALL_BITS
when we write it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 8426e5e..5f902fa 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -445,6 +445,8 @@ __xfs_sb_from_disk(
to->sb_features_incompat = be32_to_cpu(from->sb_features_incompat);
to->sb_features_log_incompat =
be32_to_cpu(from->sb_features_log_incompat);
+ /* crc is only used on disk, not in memory; just init to 0 here. */
+ to->sb_crc = 0;
to->sb_pad = 0;
to->sb_pquotino = be64_to_cpu(from->sb_pquotino);
to->sb_lsn = be64_to_cpu(from->sb_lsn);
@@ -550,6 +552,9 @@ xfs_sb_to_disk(
if (!fields)
return;
+ /* We should never write the crc here, it's updated in the IO path */
+ fields &= ~XFS_SB_CRC;
+
xfs_sb_quota_to_disk(to, from, &fields);
while (fields) {
f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-01 22:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-01 15:18 [PATCH 0/2 RESEND] xfs: small bugfixes Eric Sandeen
2014-10-01 15:22 ` [PATCH 1/2] xfs: don't send null bp to xfs_trans_brelse() Eric Sandeen
2014-10-01 15:55 ` Christoph Hellwig
2014-10-01 15:24 ` [PATCH 2/2] xfs: fix crc field handling in xfs_sb_to/from_disk Eric Sandeen
2014-10-01 15:56 ` Christoph Hellwig
2014-10-01 22:56 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox