Thread View: muc.lists.freebsd.hackers
3 messages
3 total messages
Started by Andrea Cocito
Thu, 15 Oct 2026 06:55
FemtoFS
Author: Andrea Cocito
Date: Thu, 15 Oct 2026 06:55
Date: Thu, 15 Oct 2026 06:55
98 lines
9392 bytes
9392 bytes
--Apple-Mail=_87C232B2-557B-4CC2-84D6-E740E48965F3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hello, As a weekend project I am working on a small filesystem.=20 The idea is to have a read-only filesystem focused at efficiency useable = for =E2=80=9Cfirmare images=E2=80=9D or projects like NanoBSD or mfsBSD, = where using a full UFS image is a waste of space and resources. I am at a point where I have it more or less working (see = git@github.com:puffetto/FemtoFS.git / = https://github.com/puffetto/FemtoFS.git ); but need advice and a second = opinion about a design issue. Currently the code, when mounting an image off md(4), duplicates the = whole memory area to have a private copy. To avoid this I see two options: a. Add two hooks in md(4): md_image_hold(*consumer, **address, *size) = and md_image_release(*consumer) which basically tell md(4): =E2=80=9CThis = image is now locked for my use, don=E2=80=99t touch it=E2=80=9D and = =E2=80=9CHere is it, it's back yours=E2=80=9D. b. Implement a separate (and simplified) =E2=80=9Crmd=E2=80=9D driver = which exposes those two hooks in a simplified =E2=80=9Cmd=E2=80=9D = provider. I think that option =E2=80=98a.=E2=80=99 is cleaner, but I wonder = if/when a small patch providing those hooks would ever make it into the = FreeBSD tree.=20 Opinions? While here if anyone wants to take a look at the specification and code = and report me any issue, mistake or bug they find it would be great. A = lot of work, admittedly, was done by Codex. All the best, A. --Apple-Mail=_87C232B2-557B-4CC2-84D6-E740E48965F3 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" = content=3D"text/html; charset=3Dutf-8"></head><body = style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; = line-break: after-white-space;">Hello,<div><br></div><div>As a weekend = project I am working on a small = filesystem. </div><div><br></div><div>The idea is to have a = read-only filesystem focused at efficiency useable for =E2=80=9Cfirmare = images=E2=80=9D or projects like NanoBSD or mfsBSD, where using a full = UFS image is a waste of space and resources.</div><div><br></div><div>I = am at a point where I have it more or less working (see = git@github.com:puffetto/FemtoFS.git / <a = href=3D"https://github.com/puffetto/FemtoFS.git">https://github.com/puffet= to/FemtoFS.git</a> ); but need advice and a second opinion about a = design issue.</div><div><br></div><div>Currently the code, when mounting = an image off md(4), duplicates the whole memory area to have a private = copy.</div><div><br></div><div>To avoid this I see two = options:</div><div><br></div><div>a. Add two hooks in md(4): = md_image_hold(*consumer, **address, *size) and = md_image_release(*consumer) which basically tell md(4): =E2=80=9CThis = image is now locked for my use, don=E2=80=99t touch it=E2=80=9D and = =E2=80=9CHere is it, it's back yours=E2=80=9D.</div><div><br></div><div>b.= Implement a separate (and simplified) =E2=80=9Crmd=E2=80=9D driver = which exposes those two hooks in a simplified =E2=80=9Cmd=E2=80=9D = provider.</div><div><br></div><div>I think that option =E2=80=98a.=E2=80=99= is cleaner, but I wonder if/when a small patch providing those hooks = would ever make it into the FreeBSD = tree. </div><div><br></div><div>Opinions?</div><div><br></div><div>Wh= ile here if anyone wants to take a look at the specification and code = and report me any issue, mistake or bug they find it would be great. A = lot of work, admittedly, was done by Codex.</div><div><br></div><div>All = the = best,</div><div><br></div><div>A.</div><div><br></div><div><br></div><div>= <br></div><div><br></div><div><br></div><div><br></div></body></html>= --Apple-Mail=_87C232B2-557B-4CC2-84D6-E740E48965F3-- -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: FemtoFS
Author: Adrian Chadd
Date: Thu, 15 Oct 2026 21:22
Date: Thu, 15 Oct 2026 21:22
118 lines
10689 bytes
10689 bytes
--0000000000002aaaed065de7a7a2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 14 Oct 2026 at 23:56, Andrea Cocito <andrea@cocito.eu> wrote: > Hello, > > As a weekend project I am working on a small filesystem. > > The idea is to have a read-only filesystem focused at efficiency useable > for =E2=80=9Cfirmare images=E2=80=9D or projects like NanoBSD or mfsBSD, = where using a full > UFS image is a waste of space and resources. > > I am at a point where I have it more or less working (see git@github.com:= puffetto/FemtoFS.git > / https://github.com/puffetto/FemtoFS.git ); but need advice and a second > opinion about a design issue. > > Currently the code, when mounting an image off md(4), duplicates the whol= e > memory area to have a private copy. > > To avoid this I see two options: > > a. Add two hooks in md(4): md_image_hold(*consumer, **address, *size) and > md_image_release(*consumer) which basically tell md(4): =E2=80=9CThis ima= ge is now > locked for my use, don=E2=80=99t touch it=E2=80=9D and =E2=80=9CHere is i= t, it's back yours=E2=80=9D. > > b. Implement a separate (and simplified) =E2=80=9Crmd=E2=80=9D driver whi= ch exposes those > two hooks in a simplified =E2=80=9Cmd=E2=80=9D provider. > > I think that option =E2=80=98a.=E2=80=99 is cleaner, but I wonder if/when= a small patch > providing those hooks would ever make it into the FreeBSD tree. > Oh, interesting. You're not accessing the backing device via bio calls. Your code treats the filesystem as one big chunk of memory. I think that's the big disconnect here - md doesn't expose the memory region as a single huge region. It would change your filesystem to be quite a bit more complicated because your code would have to grow bio and sleep/wakeup code. > Opinions? > > While here if anyone wants to take a look at the specification and code > and report me any issue, mistake or bug they find it would be great. A lo= t > of work, admittedly, was done by Codex. > It definitely needs a bunch of cleanup work and layout work but i mean, if it works it works! It's a good starting point, and I think the first filesystem I've seen written for FreeBSD in a while now. :-) -adrian --0000000000002aaaed065de7a7a2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote g= mail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, 14 Oct = 2026 at 23:56, Andrea Cocito <<a href=3D"mailto:andrea@cocito.eu">andrea= @cocito.eu</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex"><div>Hello,<div><br></div><div>As a weekend project I am working= on a small filesystem.=C2=A0</div><div><br></div><div>The idea is to have = a read-only filesystem focused at efficiency useable for =E2=80=9Cfirmare i= mages=E2=80=9D or projects like NanoBSD or mfsBSD, where using a full UFS i= mage is a waste of space and resources.</div><div><br></div><div>I am at a = point where I have it more or less working (see git@github.com:puffetto/Fem= toFS.git / <a href=3D"https://github.com/puffetto/FemtoFS.git" target=3D"_b= lank">https://github.com/puffetto/FemtoFS.git</a> ); but need advice and a = second opinion about a design issue.</div><div><br></div><div>Currently the= code, when mounting an image off md(4), duplicates the whole memory area t= o have a private copy.</div><div><br></div><div>To avoid this I see two opt= ions:</div><div><br></div><div>a. Add two hooks in md(4): md_image_hold(*co= nsumer, **address, *size) and md_image_release(*consumer) which basically t= ell md(4): =E2=80=9CThis image is now locked for my use, don=E2=80=99t touc= h it=E2=80=9D and =E2=80=9CHere is it, it's back yours=E2=80=9D.</div><= div><br></div><div>b. Implement a separate (and simplified) =E2=80=9Crmd=E2= =80=9D driver which exposes those two hooks in a simplified =E2=80=9Cmd=E2= =80=9D provider.</div><div><br></div><div>I think that option =E2=80=98a.= =E2=80=99 is cleaner, but I wonder if/when a small patch providing those ho= oks would ever make it into the FreeBSD tree.=C2=A0</div></div></blockquote= ><div><br></div><div>Oh, interesting. You're not accessing the backing = device via bio calls. Your code treats the filesystem as one big chunk of m= emory.</div><div>I think that's the big disconnect here - md doesn'= t expose the memory region as a single huge region.</div><div><br></div><di= v>It would change your filesystem to be quite a bit more complicated becaus= e your code would have to grow bio and sleep/wakeup code.</div><div><br></d= iv><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bord= er-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div><d= iv>Opinions?</div><div><br></div><div>While here if anyone wants to take a = look at the specification and code and report me any issue, mistake or bug = they find it would be great. A lot of work, admittedly, was done by Codex.<= /div></div></blockquote><div><br></div><div>It definitely needs a bunch of = cleanup work and layout work but i mean, if it works it works! It's a g= ood starting point, and I think the first filesystem I've seen written = for FreeBSD in a while now. :-)</div><div><br></div><div><br></div><div><br= ></div><div>-adrian</div><div><br></div></div></div> --0000000000002aaaed065de7a7a2-- -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: FemtoFS
Author: Andrea Cocito
Date: Fri, 16 Oct 2026 10:04
Date: Fri, 16 Oct 2026 10:04
205 lines
15639 bytes
15639 bytes
--Apple-Mail=_00990E5F-3203-4DFB-AA93-CD68A8406936 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hello Adrian, adding -fs@ in the loop. > On 15 Oct 2026, at 23:22, Adrian Chadd <adrian@freebsd.org> wrote: > On Wed, 14 Oct 2026 at 23:56, Andrea Cocito <andrea@cocito.eu = <mailto:andrea@cocito.eu>> wrote: >> Hello, >>=20 >> As a weekend project I am working on a small filesystem.=20 >>=20 >> The idea is to have a read-only filesystem focused at efficiency = useable for =E2=80=9Cfirmare images=E2=80=9D or projects like NanoBSD or = mfsBSD, where using a full UFS image is a waste of space and resources. >>=20 >> I am at a point where I have it more or less working (see = git@github.com:puffetto/FemtoFS.git / = https://github.com/puffetto/FemtoFS.git ); but need advice and a second = opinion about a design issue. >>=20 >> Currently the code, when mounting an image off md(4), duplicates the = whole memory area to have a private copy. >>=20 >> To avoid this I see two options: >>=20 >> a. Add two hooks in md(4): md_image_hold(*consumer, **address, *size) = and md_image_release(*consumer) which basically tell md(4): =E2=80=9CThis = image is now locked for my use, don=E2=80=99t touch it=E2=80=9D and = =E2=80=9CHere is it, it's back yours=E2=80=9D. >>=20 >> b. Implement a separate (and simplified) =E2=80=9Crmd=E2=80=9D driver = which exposes those two hooks in a simplified =E2=80=9Cmd=E2=80=9D = provider. >>=20 >> I think that option =E2=80=98a.=E2=80=99 is cleaner, but I wonder = if/when a small patch providing those hooks would ever make it into the = FreeBSD tree.=20 >=20 > Oh, interesting. You're not accessing the backing device via bio = calls. Your code treats the filesystem as one big chunk of memory. > I think that's the big disconnect here - md doesn't expose the memory = region as a single huge region. >=20 > It would change your filesystem to be quite a bit more complicated = because your code would have to grow bio and sleep/wakeup code. The point is exactly not using bio*, take the case when we boot off an = md image as mfsBSD/NanoBSD and think of libc.so <http://libc.so/>, with = UFS: - The bootloader uncompresses the image in physical RAM - Each and every binary mmap() libc.so and makes a new copy of it Avoiding it would mean, as a minimum, use a sector size of 4KiB for the = image and make substantial work in UFS. While with FemtoFS once a file is made of pages of physical memory it = can be mmap=E2=80=99ed in process memory without copying anything: just = moving pointers*. One copy, without changing md(4) or using another driver, is still = needed when =E2=80=9Cmounting=E2=80=9D the filesystem; changing md to = expose the backing memory pages (obviously when in RAM) would avoid that = copy. The impact would not be huge: a few dozens of real lines of code in = md(4) and no expected change in behaviour unless one uses those hooks: = https://github.com/freebsd/freebsd-src/compare/releng/15.1...puffetto:free= bsd-src:femtofs/md-preload-15.1 [Code is mine, docs and tests done by LLM] The other way could be to used something dedicated instead of md(4), and = which way to follow is the open question. *) Actually when FemtoFS mounts in =E2=80=9Cclean=E2=80=9D mode the last = page of the file needs to be copied, only one and only the first time we = mmap(), as the free space after EOF could have been reused to store some = small file and full posix compliance requires it to be zeroed. Thanks for you advice, A. >=20 >>=20 >> Opinions? >>=20 >> While here if anyone wants to take a look at the specification and = code and report me any issue, mistake or bug they find it would be = great. A lot of work, admittedly, was done by Codex. >=20 > It definitely needs a bunch of cleanup work and layout work but i = mean, if it works it works! It's a good starting point, and I think the = first filesystem I've seen written for FreeBSD in a while now. :-) >=20 >=20 >=20 > -adrian >=20 --Apple-Mail=_00990E5F-3203-4DFB-AA93-CD68A8406936 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" = content=3D"text/html; charset=3Dutf-8"></head><body = style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; = line-break: after-white-space;">Hello Adrian, adding -fs@ in the = loop.<br id=3D"lineBreakAtBeginningOfMessage"><div><br><blockquote = type=3D"cite"><div>On 15 Oct 2026, at 23:22, Adrian Chadd = <adrian@freebsd.org> wrote:</div><div><div dir=3D"ltr"><div = class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" = class=3D"gmail_attr">On Wed, 14 Oct 2026 at 23:56, Andrea Cocito <<a = href=3D"mailto:andrea@cocito.eu">andrea@cocito.eu</a>> = wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px = 0px 0px 0.8ex;border-left:1px solid = rgb(204,204,204);padding-left:1ex"><div>Hello,<div><br></div><div>As a = weekend project I am working on a small = filesystem. </div><div><br></div><div>The idea is to have a = read-only filesystem focused at efficiency useable for =E2=80=9Cfirmare = images=E2=80=9D or projects like NanoBSD or mfsBSD, where using a full = UFS image is a waste of space and resources.</div><div><br></div><div>I = am at a point where I have it more or less working (see = git@github.com:puffetto/FemtoFS.git / <a = href=3D"https://github.com/puffetto/FemtoFS.git" = target=3D"_blank">https://github.com/puffetto/FemtoFS.git</a> ); but = need advice and a second opinion about a design = issue.</div><div><br></div><div>Currently the code, when mounting an = image off md(4), duplicates the whole memory area to have a private = copy.</div><div><br></div><div>To avoid this I see two = options:</div><div><br></div><div>a. Add two hooks in md(4): = md_image_hold(*consumer, **address, *size) and = md_image_release(*consumer) which basically tell md(4): =E2=80=9CThis = image is now locked for my use, don=E2=80=99t touch it=E2=80=9D and = =E2=80=9CHere is it, it's back yours=E2=80=9D.</div><div><br></div><div>b.= Implement a separate (and simplified) =E2=80=9Crmd=E2=80=9D driver = which exposes those two hooks in a simplified =E2=80=9Cmd=E2=80=9D = provider.</div><div><br></div><div>I think that option =E2=80=98a.=E2=80=99= is cleaner, but I wonder if/when a small patch providing those hooks = would ever make it into the FreeBSD = tree. </div></div></blockquote><div><br></div><div>Oh, interesting. = You're not accessing the backing device via bio calls. Your code treats = the filesystem as one big chunk of memory.</div><div>I think that's the = big disconnect here - md doesn't expose the memory region as a single = huge region.</div><div><br></div><div>It would change your filesystem to = be quite a bit more complicated because your code would have to grow bio = and sleep/wakeup = code.</div></div></div></div></blockquote><div><br></div><div>The point = is exactly not using bio*, take the case when we boot off an md image as = mfsBSD/NanoBSD and think of <a href=3D"http://libc.so">libc.so</a>, with = UFS:</div><div>- The bootloader uncompresses the image in physical = RAM</div><div>- Each and every binary mmap() libc.so and makes a new = copy of it</div><div>Avoiding it would mean, as a minimum, use a sector = size of 4KiB for the image and make substantial work in = UFS.</div><div><br></div><div>While with FemtoFS once a file is made of = pages of physical memory it can be mmap=E2=80=99ed in process memory = without copying anything: just moving = pointers*.</div><div><br></div><div>One copy, without changing md(4) or = using another driver, is still needed when =E2=80=9Cmounting=E2=80=9D = the filesystem; changing md to expose the backing memory pages = (obviously when in RAM) would avoid that = copy.</div><div><br></div><div>The impact would not be huge: a few = dozens of real lines of code in md(4) and no expected change in = behaviour unless one uses those = hooks:</div><div><br></div><div> https://github.com/freebsd/freebsd-s= rc/compare/releng/15.1...puffetto:freebsd-src:femtofs/md-preload-15.1</div= ><div><br></div><div>[Code is mine, docs and tests done by = LLM]</div><div><br></div><div>The other way could be to used something = dedicated instead of md(4), and which way to follow is the open = question.</div><div><br></div><div>*) Actually when FemtoFS mounts in = =E2=80=9Cclean=E2=80=9D mode the last page of the file needs to be = copied, only one and only the first time we mmap(), as the free space = after EOF could have been reused to store some small file and full posix = compliance requires it to be zeroed.</div><div><br></div><div>Thanks for = you = advice,</div><div><br></div><div>A.</div><div><br></div><br><blockquote = type=3D"cite"><div><div dir=3D"ltr"><div class=3D"gmail_quote = gmail_quote_container"><div><br></div><blockquote class=3D"gmail_quote" = style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid = rgb(204,204,204);padding-left:1ex"><div><div><br></div><div>Opinions?</div= ><div><br></div><div>While here if anyone wants to take a look at the = specification and code and report me any issue, mistake or bug they find = it would be great. A lot of work, admittedly, was done by = Codex.</div></div></blockquote><div><br></div><div>It definitely needs a = bunch of cleanup work and layout work but i mean, if it works it works! = It's a good starting point, and I think the first filesystem I've seen = written for FreeBSD in a while now. = :-)</div><div><br></div><div><br></div><div><br></div><div>-adrian</div><d= iv><br></div></div></div> </div></blockquote></div><br></body></html>= --Apple-Mail=_00990E5F-3203-4DFB-AA93-CD68A8406936-- -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads