Skip to content

Move meta file usage to a file backed hashtable#11

Open
corbinlc wants to merge 11 commits intomasterfrom
leveldb
Open

Move meta file usage to a file backed hashtable#11
corbinlc wants to merge 11 commits intomasterfrom
leveldb

Conversation

@corbinlc
Copy link
Member

Going to do much more testing now, but wanted to get this out, so we could get a code review going


if (err != NULL) {
read_len = 0;
fprintf(stderr, "Read fail.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like you might want a more verbose error message here.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

lcl_mode = hash_read_value->mode;
*owner = hash_read_value->owner;
*group = hash_read_value->group;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible that the meta file is deleted in this branch with the call to unlink but the process dies before a call that writes it to the hash?

Copy link
Member Author

Choose a reason for hiding this comment

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

that is true, should do a put here

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 for matt

@@ -341,11 +394,11 @@ int read_meta_file(char path[PATH_MAX], mode_t *mode, uid_t *owner, gid_t *group
int write_meta_file(char path[PATH_MAX], mode_t mode, uid_t owner, gid_t group,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should rename this function.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


if ((status == 0) && (addr > 0)) {
ht_value = malloc(sizeof(diskhash_struct_t));
ht_value->mode = dtoo(mode);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we aren't saving the mode in a human-readable file anymore, maybe we should just abandon the otod and dtoo conversions?

Copy link
Member Author

Choose a reason for hiding this comment

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

not going to do this just yet, need to convince myself that everyone expects it one way. i know we we check permissions we want it in the octal format. everywhere else maybe decimal format


options = leveldb_options_create();
leveldb_options_set_create_if_missing(options, 1);
db = leveldb_open(options, "/tmp/testExtract/testdb", &err);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think test terminology should be changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

ht_value->group = group;
leveldb_put(db, woptions, (char *)&addr, sizeof(ino_t), (char *)ht_value, sizeof(diskhash_struct_t), &err);
if (err != NULL) {
fprintf(stderr, "Write fail.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think you may end up wanting a more verbose error message here as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

if(status == 1)
return 0;

/* If the file already existed get iyt*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo in this comment could be misread as 'it' instead of 'out'.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

*group = config->egid;
*mode = otod(755);
return 0;
int status;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you might have an easier time removing metafile functionality during a later refactor if you extracted the leveldb read into its own routine, and did metafile reading fallback if that routine fails. At the very least, I think it would be useful to have clearer semantics concerning what read_meta_file does. It's called in a lot of places, but "reading a meta file" isn't really the intent of this function anymore.

return 0;
}

/** Handles open, openat, and creat syscalls. Creates meta files to match the
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment seems a little disingenuous, and it comes down again to the naming convention of writing/reading "meta files". It seems like that's not really what we're trying to accomplish anymore.

Config *config;
int uid, gid;

#ifdef USERLAND
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we use this definition everywhere we make calls to read_ and write_ meta files now? Otherwise, what happens when access to the hash is attempted?

return status;

perms = get_permissions(meta_path, config, 0);
perms = get_permissions(path, config, 0);
Copy link
Member Author

Choose a reason for hiding this comment

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

This should be shorten_path not path. $^%&!

@Unrud
Copy link

Unrud commented Apr 20, 2019

Wouldn't it be easier to store the metadata in extended attributes? Otherwise, the file system and the database must kept in sync, when files or whole folders are renamed.

@corbinlc
Copy link
Member Author

@Unrud that is a really great idea! I stopped looking at this because I found that there was still too much of a performance impact of keeping track of the emulated file ownership and such. There is a reasonable impact to intercepting system calls that happen often like open (which sets the initial ownership and permissions of a new file). This idea though, might make it worthwhile to revisit this.

@corbinlc
Copy link
Member Author

Really brilliant idea if it works though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants