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