Commit c676bc1c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ef20d933
#!/usr/bin/env bpftrace
# ievicttrace - trace from where / how inodes are evicted by Linux kernel
#include <linux/fs.h>
/*
kprobe:evict {
@ievict[kstack] = count();
}
interval:s:3 {
print(@ievict);
clear(@ievict);
}
*/
kprobe:fuse_evict_inode {
$inode = (inode *)arg0;
$t = elapsed / 1000;
printf("%d.%d EVICT i%d: %s\n", $t/1000000, $t%1000000, $inode->i_ino, kstack);
}
package test
// demonstrate that idir can be evicted/forgotten while its child ifile is active
import (
"os"
"testing"
"time"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/internal/testutil"
"lab.nexedi.com/kirr/go123/exc"
)
func TestIEvict(t *testing.T) {
X := exc.Raiseif
dir := testutil.TempDir()
defer func() {
err := os.Remove(dir); X(err)
}()
// setup a filesystem with / -> A -> B -> file
root := nodefs.NewDefaultNode()
opts := nodefs.NewOptions() // entry timeout = 1s
opts.Debug = testutil.VerboseTest()
srv, fsconn, err := nodefs.MountRoot(dir, root, opts); X(err)
Adir := nodefs.NewDefaultNode()
Bdir := nodefs.NewDefaultNode()
root.Inode().NewChild("A", true, Adir)
Adir.Inode().NewChild("B", true, Bdir)
data0 := "hello world"
file := NewDataNode([]byte(data0))
Bdir.Inode().NewChild("hello.txt", false, file)
go srv.Serve()
err = srv.WaitMount(); X(err)
defer func() {
err := srv.Unmount(); X(err)
}()
// open file, this will Lookup A, Lookup B, Lookup file, and open file
f, err := os.Open(dir + "/A/B/hello.txt"); X(err)
defer func() {
println("closed")
time.Sleep(5*time.Second)
println()
}()
defer f.Close()
// sleep 3s: during this time dentry root["A"] should be timed out and invalidated.
// the kernel evicts inode for A
println()
time.Sleep(1*time.Second)
//os.Stat(dir + "/A")
//st := fsconn.EntryNotify(root.Inode(), "A")
//st := fsconn.EntryNotify(Adir.Inode(), "B")
//st := fsconn.DeleteNotify(root.Inode(), Adir.Inode(), "A")
st := fsconn.DeleteNotify(Bdir.Inode(), file.Inode(), "hello.txt")
if !st.Ok() {
t.Fatalf("entry_notify: %s", st)
}
time.Sleep(1*time.Second)
println()
st = fsconn.DeleteNotify(Adir.Inode(), Bdir.Inode(), "B")
if !st.Ok() {
t.Fatalf("entry_notify: %s", st)
}
time.Sleep(1*time.Second)
println()
// now issue read for file.
buf := make([]byte, 1024)
_, err = f.Read(buf); X(err)
time.Sleep(1*time.Second)
println()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment