ref: 19dc7164950ad60ac727482b9abb82badf6364eb
parent: 5fc13b08deef36bbf24c6c23d2fa397de63604e7
author: Michael Forney <[email protected]>
date: Sun Feb 20 22:44:18 EST 2022
fs: fix first snapshot generation after mount When we mount a snap, we want to create a new pending snap so our writes turn into a new snap instead of modifying the old one.
--- a/fs.c
+++ b/fs.c
@@ -698,6 +698,7 @@
Kvp kv;
Key dk;
Fid f;
+ Tree *t;
if((mnt = mallocz(sizeof(Mount), 1)) == nil){
rerror(m, Enomem);
@@ -718,10 +719,15 @@
}
runlock(&fs->userlk);
- if((mnt->root = openlabel(m->aname)) == nil){
+ if((t = openlabel(m->aname)) == nil){
rerror(m, Enosnap);
return;
}
+ if((mnt->root = newsnap(t)) == nil){
+ rerror(m, Enomem);
+ return;
+ }
+ closesnap(t);
if((p = packdkey(dbuf, sizeof(dbuf), -1ULL, "")) == nil){
rerror(m, Elength);
--- a/snap.c
+++ b/snap.c
@@ -389,7 +389,7 @@
Tree *r;
int i;
- if(modifysnap(Oinsert, t) != nil)
+ if(t->dirty && modifysnap(Oinsert, t) != nil)
return nil;
if((r = calloc(sizeof(Tree), 1)) == nil)