Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Writing a 9P server from scratch (2016) (aqwari.net)
99 points by miduil on Oct 31, 2017 | hide | past | favorite | 23 comments


9P2000 is available on Linux with the CONFIG_9P_FS and related kernel compile options, which say things like:

"If you say Y here, you will get experimental support for Plan 9 resource sharing via the 9P2000 protocol. See http://v9fs.sf.net for more information."


It's also the native host-guest file sharing protocol used by KVM: https://www.linux-kvm.org/page/9p_virtio

It works in at least Ubuntu & Fedora out of the box, and is used by the virt-manager GUI to set up shares, so not too experimental to enable by default I guess.


That's been experimental for a long time - https://github.com/torvalds/linux/tree/master/fs/9p

I guess file systems don't go into staging/?


On Arch Linux, it's been enabled by default for several years, and I've been using it daily for that time.

On x86_64, it's plenty stable, but I see why it's still experimental: On i686 there's a bug where files are mysteriously missing from directory listings. I tried to debug it once; it's reading them from the protocol correctly, but they're being dropped in the VFS layer, which is a bit more complicated than the network protocol.


Maybe, once FUSE came along, 9pfuse made more sense than putting 9p in the kernel?

https://9fans.github.io/plan9port/man/man4/9pfuse.html


I was just wondering, as I began to read the article: which would perform better - in-kernel 9P, or FUSE?

Intuitively I get the idea that FUSE is going to be the better performer overall because of lack of network overhead.

But I wonder how much worse 9P would be.


I'm having a hard time finding any kind of feature comparison or list. What makes v9fs stand out?


9p or v9fs?

9p is really easy to implement. That is a key feature as it makes it easy to create new clients and servers (and presumedly makes bugs rarer). Much like FUSE has been adapted to countless things. I don't know how implementing a FUSE server or client compares to this though.

Unfortunately, the simplicity also means giving up something. Where quite-complicated NFSv4 can be very efficient over slow links (leases makes it a bit like a cache coherency protocol), 9p requires all writes to be committed to the server (for coherency).


I was wondering how v9fs compares to vanilla filesystems like ext2... I suspect I'm comparing the wrong thing and it's a just a NFS-like protocol and not a on disk format? If so, what is the plan9 on-disk format?

I feel like I'm missing the point and should be asking "what's cool about 9p?" to which you provided a very helpful response. Thanks!


> If so, what is the plan9 on-disk format?

Which one? For most user storage, there's kenfs, fossil, venti, hjfs, cwfs, and a few others. But 9p is disjoint from where data is stored, it's just a protocol for doing RPCs on endpoints in a heirarchical namespace.

As a result, everything is served up over 9p on plan 9. iso9660, the device tree, the network subsystem, ftpfs, sshfs, hgwebfs, the vt100 emulator, the keyboard, the mouse, the CD burner commands, and so on. To a good approximation, the only things you can do without going over 9p is starting processes.

This has interesting implications; For example, the Plan 9 equivalent of ssh simply opens a connection to the remote system, and mounts the local /dev before the remote one. That means that remote programs simply open the local devices, such as the mouse and keyboard, and use them in preference to the devices that are connected to the remote machine.

The equivalent to VNC on Plan 9 is simply namespace management to redirect which devices programs use. Here's the full implementation: http://code.9front.org/hg/plan9front/file/fd023f8fd074/rc/bi...

Yes, it is just a shell script.


Cool. Is that sh? I'm not familiar with the [1=2] stuff... looks like it's remapping file descriptors, is there something special about 10, 11 and 12? I can feel my weekend slipping away...



IIRC the native Plan9 FS is still something very similar to tradional unix filesystems, but it is intended to be replaced with Fossil (http://doc.cat-v.org/plan_9/4th_edition/papers/fossil/). It's copy on write filesystem (like ZFS or BtrFS, but it only implements the filesystem part) with interesting property that it supports cheap snapshots which can be offloaded into Venti, which is content addressable object store (similar to Git's internal object store)


According to Wikipedia, Plan 9 has been using fossil as the default file system since 2003.


> Everything really was a file

I wonder how that would change if the system was designed today.

Everything a stream of JSON objects?


If you were going to build a JSON based file system today, then I would study the Newton’s Soup which was based on frames. It was pretty cool and had some interesting capabilities (remove half the storage from a running system, ok what’s next). I would imagine queries would make a reappearance in a much nicer form.


Thats exactly what I thought. Newton Soups and NewtonScript were both awesome. I miss that kind of system these days, it still amazes me how it was all integrated.


I wish 9P was named differently. Would actually speed adoption with a bit of "marketing".


9P from Bell Labs? :p


The Unix room scientists at Bell Labs deliberately chose anti-marketing names.

Well done guys, you played yourselves.


How is Upspin related to 9P?


It's not.


It's not so simple. The API is a simplified version of 9P and directly inspired by it.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: