14 aoû 2018

62846

0

GSoC 2018 - Final report

Introduction

WinBtrfs is a feature-complete IFSD (Installable File System Driver) for NT operating systems, written by Mark Harmstone. This driver is checked into the ReactOS source code for some time already. My main goal for this GSoC project was to implement all missing features (and fix bugs, of course) in ReactOS that prevents booting from BTRFS file system.

Links

All work is merged into gsoc2018_all branch in my ReactOS fork on GitHub. A pull-request can be found here and unified diff is here. You can check it out like an ordinary ReactOS repo and build it as. See official Building Instructions for full information.

What has been done

FreeLoader BTRFS support

Basic read-only support has been implemented in the “FreeLoader” bootloader. The implementation is able to do path traversing, can handle hard and symbolic links and reads files splitted to several extents.
Only single-disk uncompressed setup is supported right now. Other WinBtrfs features can be added once ReactOS will support them.

Code for a VBR (Volume Boot Record) has also been written from scratch in ASM to support early boot phase when CPU is in real mode. It loads main bootloader executable into memory - freeldr.sys

Installer

ReactOS first-stage installer (usetup.exe) is now able to format partitions to BTRFS file system, install proper VBR for it and of course copy all the needed ReactOS files into it :)

Driver fixes

A couple of bugs were found in WinBtrfs driver during testing. One is related to NtQueryDirectoryFile kernel function, which returned wrong information under some circumstances.
Another one is about driver behaviour upon system shutdown. The driver tried to free its structures too early and that led to occasional BSODs.
Both fixes were sent upstream (PR#102 and PR#103) and are waiting to be merged.

ReactOS fixes

Not only driver issues were found during testing of BTRFS boot. Another bug was found and fixed in FastIO code, which is not used within the FAT file system. This small fix made WinBtrfs work in a much more stable way, and other third-party drivers can benefit from it too. There is also a memory leak which I was not able to triage before the GSoC ending. This leak prevents ReactOS self-hosting on BTRFS filesystem (because checking out the source code and building binaries requires a lot of IO). I’m going to fix it after GSoC ending.

Other tools

For faster development, I have made a python tool for traversing BTRFS structures on raw disk (or binary file, converted from VM image). It can be found at modules/rosapps/applications/devutils/btrfstools

Conclusion

All this work lead to successfully booting ReactOS from BTRFS partition! Sounds too simple :) Thanks cernodile and Illen from the community, who made a video of the process:

What has not been done

Windows 2003 still has issues with booting from BTRFS using FreeLoader. This is the only goal which has not been reached during this GSoC. But this is not the end, I will fix it later, of course (see news from the upcoming Hackfest).

There are still issues with BTRFS on ReactOS (see memory leak above), so it is not yet as stable as the FAT filesystem.

What's next

First of all, I thank GSoC that gave me an opportunity to work with such great team. I will definitely stay with ReactOS project and will continue kernel development here.

During upcoming Hackfest, It is planned to merge all BTRFS work. I am also going to fix as much bugs as possible and will try to make ReactOS as stable with BTRFS as it is with FAT file system :)

This blog post represents the personal opinion of the author and is not representative of the position of the ReactOS Project.