Improve object and block writting performance.

This commit is contained in:
Jiaqiang Xu 2014-05-16 15:24:06 +08:00
parent 8b04dc0dac
commit f7007d41fa
2 changed files with 16 additions and 6 deletions

View File

@ -141,6 +141,11 @@ create_parent_path (const char *path)
if (!dir)
return -1;
if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
g_free (dir);
return 0;
}
if (g_mkdir_with_parents (dir, 0777) < 0) {
seaf_warning ("Failed to create object parent path: %s.\n", dir);
g_free (dir);

View File

@ -266,6 +266,11 @@ create_parent_path (const char *path)
if (!dir)
return -1;
if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
g_free (dir);
return 0;
}
if (g_mkdir_with_parents (dir, 0777) < 0) {
seaf_warning ("Failed to create object parent path: %s.\n", dir);
g_free (dir);
@ -289,15 +294,15 @@ obj_backend_fs_write (ObjBackend *bend,
id_to_path (bend->priv, obj_id, path, repo_id, version);
/* GTimeVal s, e; */
/* g_get_current_time (&s); */
if (create_parent_path (path) < 0) {
seaf_warning ("[obj backend] Failed to create path for obj %s.\n", obj_id);
return -1;
}
/* GTimeVal s, e; */
/* g_get_current_time (&s); */
if (save_obj_contents (path, data, len, need_sync) < 0) {
seaf_warning ("[obj backend] Failed to write obj %s.\n", obj_id);
return -1;
@ -305,8 +310,8 @@ obj_backend_fs_write (ObjBackend *bend,
/* g_get_current_time (&e); */
/* seaf_message ("write obj time: %ldms.\n", */
/* ((e.tv_sec*1000000+e.tv_usec) - (s.tv_sec*1000000+s.tv_usec))/1000); */
/* seaf_message ("write obj time: %ldus.\n", */
/* ((e.tv_sec*1000000+e.tv_usec) - (s.tv_sec*1000000+s.tv_usec))); */
return 0;
}