Some fixes

This commit is contained in:
Caleb Gardner
2026-06-07 02:03:48 -05:00
parent 039e517183
commit 515513bda3
+18 -37
View File
@@ -28,7 +28,7 @@ pub fn extractAsync(
var xattr_table: XattrTable = try .init(alloc, cache, super.xattr_start);
defer xattr_table.deinit(io);
var sel_buffer: [100]ReturnUnion = undefined;
var sel_buffer: [500]ReturnUnion = undefined;
var sel: Io.Select(ReturnUnion) = .init(io, &sel_buffer);
defer {
while (sel.cancel()) |ret| switch (ret) {
@@ -47,17 +47,12 @@ pub fn extractAsync(
};
}
var concurrent = true;
var loop = io.concurrent(returnLoop, .{ alloc, io, &sel, &id_table, &xattr_table, options, inode.hdr.num }) catch blk: {
concurrent = false;
break :blk io.async(returnLoop, .{ alloc, io, &sel, &id_table, &xattr_table, options, inode.hdr.num });
};
var loop = io.async(returnLoop, .{ alloc, io, &sel, &id_table, &xattr_table, options, inode.hdr.num });
var frag_table: Lookup.Table(Lookup.FragmentEntry) = .init(alloc, cache, super.frag_start, super.frag_count);
defer frag_table.deinit(io);
try extractReal(alloc, io, cache, super, &frag_table, &sel, concurrent, null, path, inode);
try extractReal(alloc, io, cache, super, &frag_table, &sel, null, path, inode);
try loop.await(io);
}
@@ -69,8 +64,7 @@ fn extractReal(
super: Superblock,
frag_table: *Lookup.Table(Lookup.FragmentEntry),
sel: *Io.Select(ReturnUnion),
concurrent: bool,
parent: ?*Atomic(u32),
parent: ?*Atomic(usize),
path: []const u8,
inode: Inode,
) !void {
@@ -80,22 +74,10 @@ fn extractReal(
};
switch (inode.hdr.type) {
.dir, .ext_dir => if (concurrent)
try sel.concurrent(.dir_ret, extractDir, .{ alloc, io, cache, super, frag_table, sel, concurrent, parent, path, inode })
else
sel.async(.dir_ret, extractDir, .{ alloc, io, cache, super, frag_table, sel, concurrent, parent, path, inode }),
.file, .ext_file => if (concurrent)
try sel.concurrent(.file_ret, extractFile, .{ alloc, io, cache, frag_table, super.block_size, parent, path, inode })
else
sel.async(.file_ret, extractFile, .{ alloc, io, cache, frag_table, super.block_size, parent, path, inode }),
.symlink, .ext_symlink => if (concurrent)
try sel.concurrent(.num_ret, extractSymlink, .{ alloc, io, parent, path, inode })
else
sel.async(.num_ret, extractSymlink, .{ alloc, io, parent, path, inode }),
else => if (concurrent)
try sel.concurrent(.file_ret, extractNod, .{ alloc, parent, path, inode })
else
sel.async(.file_ret, extractNod, .{ alloc, parent, path, inode }),
.dir, .ext_dir => sel.async(.dir_ret, extractDir, .{ alloc, io, cache, super, frag_table, sel, parent, path, inode }),
.file, .ext_file => sel.async(.file_ret, extractFile, .{ alloc, io, cache, frag_table, super.block_size, parent, path, inode }),
.symlink, .ext_symlink => sel.async(.num_ret, extractSymlink, .{ alloc, io, parent, path, inode }),
else => sel.async(.file_ret, extractNod, .{ alloc, parent, path, inode }),
}
}
@@ -106,13 +88,14 @@ fn extractDir(
super: Superblock,
frag_table: *Lookup.Table(Lookup.FragmentEntry),
sel: *Io.Select(ReturnUnion),
concurrent: bool,
parent: ?*Atomic(u32),
parent: ?*Atomic(usize),
path: []const u8,
inode: Inode,
) Error!DirReturn {
errdefer if (parent != null) alloc.free(path);
try Io.Dir.cwd().createDirPath(io, path);
var dir = inode.directory(alloc, io, cache, super.dir_start) catch |err| switch (err) {
error.NotDirectory => unreachable,
else => |e| return e,
@@ -131,7 +114,7 @@ fn extractDir(
return err;
};
try extractReal(alloc, io, cache, super, frag_table, sel, concurrent, parent, new_path, new_inode);
try extractReal(alloc, io, cache, super, frag_table, sel, children, new_path, new_inode);
}
return .{
@@ -155,14 +138,12 @@ fn extractFile(
cache: *DecompCache,
frag_table: *Lookup.Table(Lookup.FragmentEntry),
block_size: u32,
parent: ?*Atomic(u32),
parent: ?*Atomic(usize),
path: []const u8,
inode: Inode,
) Error!FileReturn {
defer if (parent != null) {
defer if (parent != null)
inode.deinit(alloc);
_ = parent.?.fetchSub(1, .acquire);
};
errdefer alloc.free(path);
var atomic = try Io.Dir.cwd().createFileAtomic(io, path, .{});
@@ -212,7 +193,7 @@ fn extractFile(
return ret;
}
fn extractSymlink(alloc: std.mem.Allocator, io: Io, parent: ?*Atomic(u32), path: []const u8, inode: Inode) Error!u32 {
fn extractSymlink(alloc: std.mem.Allocator, io: Io, parent: ?*Atomic(usize), path: []const u8, inode: Inode) Error!u32 {
defer {
alloc.free(path);
if (parent != null) {
@@ -231,7 +212,7 @@ fn extractSymlink(alloc: std.mem.Allocator, io: Io, parent: ?*Atomic(u32), path:
return inode.hdr.num;
}
fn extractNod(alloc: std.mem.Allocator, parent: ?*Atomic(u32), path: []const u8, inode: Inode) Error!FileReturn {
fn extractNod(alloc: std.mem.Allocator, parent: ?*Atomic(usize), path: []const u8, inode: Inode) Error!FileReturn {
errdefer if (parent != null) alloc.free(path);
var ret: FileReturn = .{
@@ -369,7 +350,7 @@ const ReturnUnion = union(enum) {
const FileReturn = struct {
hdr: Inode.Header,
path: []const u8,
parent: ?*Atomic(u32),
parent: ?*Atomic(usize),
xattr_idx: ?u32 = null,
@@ -384,7 +365,7 @@ const FileReturn = struct {
const DirReturn = struct {
hdr: Inode.Header,
path: []const u8,
parent: ?*Atomic(u32),
parent: ?*Atomic(usize),
children: *Atomic(usize),
xattr_idx: ?u32 = null,