Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
obj-m += simplefs.o
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o hash.o

KDIR ?= /lib/modules/$(shell uname -r)/build

Expand Down
8 changes: 5 additions & 3 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ static int simplefs_iterate(struct file *dir, struct dir_context *ctx)
for (; remained_nr_files && ei < SIMPLEFS_MAX_EXTENTS; ei++) {
if (eblock->extents[ei].ee_start == 0)
continue;

int ei_nr = eblock->extents[ei].nr_files;
/* Iterate over blocks in one extent */
for (bi = 0; bi < eblock->extents[ei].ee_len && remained_nr_files;
for (bi = 0;
bi < eblock->extents[ei].ee_len && remained_nr_files && ei_nr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often does ei_nr actually hit 0 during the loop check? Is the overhead of maintaining ei_nr really justified by the benefit of terminating the loop early?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full_name_hash in remove file

          83278.61 msec task-clock                       #    0.967 CPUs utilized
             52431      context-switches                 #  629.585 /sec
              1309      cpu-migrations                   #   15.718 /sec
           3796501      page-faults                      #   45.588 K/sec
      199894058328      cycles                           #    2.400 GHz
      110625460371      instructions                     #    0.55  insn per cycle
       20325767251      branches                         #  244.069 M/sec
         490549944      branch-misses                    #    2.41% of all branches

      86.132655220 seconds time elapsed
      19.180209000 seconds user
      68.476075000 seconds sys

remove ei_nr:
         136413.23 msec task-clock                       #    0.962 CPUs utilized
             54993      context-switches                 #  403.135 /sec
              2504      cpu-migrations                   #   18.356 /sec
           3827233      page-faults                      #   28.056 K/sec
      323663184097      cycles                           #    2.373 GHz
      154283317313      instructions                     #    0.48  insn per cycle
       30531054743      branches                         #  223.813 M/sec
         561254005      branch-misses                    #    1.84% of all branches

     141.745463391 seconds time elapsed
      21.300616000 seconds user
     120.011093000 seconds sys

full_name_hash in list single file
min time: 0.00171 s
max time: 0.03588 s
avg time: 0.00305601 s
tot time: 93.514040 s

remove ei_nr:
total test 30600
min: 0.0017 s
max: 0.0432 s
avg: 0.00342463 s
tot: 104.793540 s

bi++) {
bh2 = sb_bread(sb, eblock->extents[ei].ee_start + bi);
if (!bh2) {
Expand All @@ -80,12 +81,13 @@ static int simplefs_iterate(struct file *dir, struct dir_context *ctx)
continue;
}

for (fi = 0; fi < SIMPLEFS_FILES_PER_BLOCK;) {
for (fi = 0; fi < SIMPLEFS_FILES_PER_BLOCK && dblock->nr_files;) {
if (dblock->files[fi].inode != 0) {
if (offset) {
offset--;
} else {
remained_nr_files--;
ei_nr--;
if (!dir_emit(ctx, dblock->files[fi].filename,
SIMPLEFS_FILENAME_LEN,
dblock->files[fi].inode, DT_UNKNOWN)) {
Expand Down
9 changes: 9 additions & 0 deletions hash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <linux/stringhash.h>
#include <linux/types.h>
#include "simplefs.h"

uint32_t simplefs_hash(struct dentry *dentry)
{
return full_name_hash(dentry, dentry->d_name.name,
strlen(dentry->d_name.name));
}
Loading