Skip to content

Added P12-log#8

Open
Amber-Agarwal wants to merge 4 commits intocodenet:p4-trapsfrom
Amber-Agarwal:p12-log
Open

Added P12-log#8
Amber-Agarwal wants to merge 4 commits intocodenet:p4-trapsfrom
Amber-Agarwal:p12-log

Conversation

@Amber-Agarwal
Copy link
Copy Markdown

@Amber-Agarwal Amber-Agarwal commented Feb 15, 2026

IMPORTANT:- Note that in the implementation I have committed I have taken the MKFS from the C directory only so my makefile assumes MKFS to be already present in a specified folder. This was done as I didn't have the code for MKFS in rust. Once that code is added we can change the mkfs dependency in the Makefile.

I have implemented the redo logging functionality analogous to the one done in the C code although the file layer is not yet added. I built it on the write commit which I made

  • Added src/log.rs implementing:
    • initlog(dev)
    • begin_op()
    • end_op()
    • log_write(buf_idx)
  • Internal log mechanics:
    • read_head()
    • write_head()
    • write_log()
    • install_trans()
    • recover_from_log()
    • commit()

Behavior matches the simple single-transaction model:

  • begin_op() is a no-op
  • end_op() commits immediately
  • log header and logged blocks are written in commit order
  • recovery replays committed log entries at boot
  1. Added log sizing constants
  • Updated src/param.rs:
    • MAXOPBLOCKS
    • LOGSIZE = MAXOPBLOCKS * 3
  1. Integrated log into filesystem writes
    Updated src/fs.rs so mutating operations use log_write() instead of direct bwrite():
  • block zeroing/allocation path (bzero, balloc)
  • inode allocation/update (ialloc, iupdate)
  • indirect mapping updates in bmap
  • inode data writes in writei

This ensures modified blocks are tracked in the transaction and written through the log commit path.

  1. Boot-time initialization and transaction boundaries
  • Updated src/lib.rs:
    • call log::initlog(ROOTDEV) after iinit(ROOTDEV)
    • wrap mutation paths in welcome() with begin_op() / end_op()

Validation

  • make xv6.img fs.img succeeds
  • make qemu boots and runs correctly
  • Fresh image boot confirms creation paths still work
  • Reboot confirms persisted state can be read correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant