Skip to content

Commit 129ef5a

Browse files
committed
Go read-only if we can't read ephemeral objects
Failing to read an ephemeral object does not abort the transaction, it just returns an error. The problem is that, by this point, nx_eph_list is already set: the next time a transaction starts the reads will get skipped, and things will proceed as if there was no error. I got this series of messages from xfstests (no idea which test, but clearly one that fakes I/O errors): [18920.212351] Buffer I/O error on dev dm-0, logical block 3932144, async page read [18920.515341] APFS (dm-0:0): failed to read cpm block (apfs_read_single_cpm_block:231) [18920.520378] APFS (dm-0:0): failed to read cpm block 0 (apfs_read_ephemeral_objects:300) [18920.524371] APFS (dm-0:0): failed to read the ephemeral objects (apfs_transaction_start:384) [18920.529524] APFS (dm-0:0): no mapping for oid 0x400 (apfs_ephemeral_object_lookup:216) [18920.532784] APFS (dm-0:0): no spaceman object for oid 0x400 (apfs_read_spaceman:744) [18920.536222] APFS (dm-0:0): failed to read the spaceman (apfs_transaction_start:395) [18920.538634] APFS (dm-0:0): aborting transaction (apfs_transaction_abort:1001) [18920.646469] APFS (dm-0:0): no mapping for oid 0x400 (apfs_ephemeral_object_lookup:216) [18920.653922] APFS (dm-0:0): no spaceman object for oid 0x400 (apfs_spaceman_get_free_blkcnt:1468) [18920.766489] APFS (dm-0:0): no mapping for oid 0x400 (apfs_ephemeral_object_lookup:216) [18920.770446] APFS (dm-0:0): no spaceman object for oid 0x400 (apfs_spaceman_get_free_blkcnt:1468) No harm was done because the next transaction still got aborted as soon as we tried to read the spaceman. But, if at some point in the future we stop fully flushing free queues on each start, we could run into more subtle bugs involving missing fq nodes. This all seems unlikely but, to be safe, make the mount read-only when we fail to get the ephemeral objects. It's really the same situation as any other abort, so it's not a problem. Signed-off-by: Ernesto A. Fernández <[email protected]>
1 parent c012e6c commit 129ef5a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

transaction.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ static int apfs_read_single_cpm_block(struct super_block *sb, u64 cpm_bno)
263263
return err;
264264
}
265265

266+
static void apfs_force_readonly(struct apfs_nxsb_info *nxi);
267+
266268
/**
267269
* apfs_read_ephemeral_objects - Read all ephemeral objects to memory
268270
* @sb: superblock structure
@@ -298,6 +300,8 @@ int apfs_read_ephemeral_objects(struct super_block *sb)
298300
err = apfs_read_single_cpm_block(sb, cpm_bno);
299301
if (err) {
300302
apfs_err(sb, "failed to read cpm block %u", i);
303+
/* No transaction to abort yet */
304+
apfs_force_readonly(nxi);
301305
return err;
302306
}
303307
}

0 commit comments

Comments
 (0)