Skip to content

Commit

Permalink
lib-fs: Fixes to stats count tracking
Browse files Browse the repository at this point in the history
fs_exists(), fs_copy(), fs_rename() and fs_delete() could have increased the
count multiple times on async operations.
  • Loading branch information
sirainen committed May 11, 2016
1 parent 34d1717 commit 5b98064
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/lib-fs/fs-api.c
Expand Up @@ -749,13 +749,14 @@ int fs_exists(struct fs_file *file)
else
return errno == ENOENT ? 0 : -1;
}
file->fs->stats.exists_count++;
fs_file_timing_start(file, FS_OP_EXISTS);
T_BEGIN {
ret = file->fs->v.exists(file);
} T_END;
if (!(ret < 0 && errno == EAGAIN))
if (!(ret < 0 && errno == EAGAIN)) {
file->fs->stats.exists_count++;
fs_file_timing_end(file, FS_OP_EXISTS);
}
return ret;
}

Expand Down Expand Up @@ -843,13 +844,13 @@ int fs_copy(struct fs_file *src, struct fs_file *dest)
return -1;
}

dest->fs->stats.copy_count++;
fs_file_timing_start(dest, FS_OP_COPY);
T_BEGIN {
ret = src->fs->v.copy(src, dest);
} T_END;
if (!(ret < 0 && errno == EAGAIN)) {
fs_file_timing_end(dest, FS_OP_COPY);
dest->fs->stats.copy_count++;
dest->metadata_changed = FALSE;
}
return ret;
Expand All @@ -864,6 +865,7 @@ int fs_copy_finish_async(struct fs_file *dest)
} T_END;
if (!(ret < 0 && errno == EAGAIN)) {
fs_file_timing_end(dest, FS_OP_COPY);
dest->fs->stats.copy_count++;
dest->metadata_changed = FALSE;
}
return ret;
Expand All @@ -875,27 +877,29 @@ int fs_rename(struct fs_file *src, struct fs_file *dest)

i_assert(src->fs == dest->fs);

dest->fs->stats.rename_count++;
fs_file_timing_start(dest, FS_OP_RENAME);
T_BEGIN {
ret = src->fs->v.rename(src, dest);
} T_END;
if (!(ret < 0 && errno == EAGAIN))
if (!(ret < 0 && errno == EAGAIN)) {
dest->fs->stats.rename_count++;
fs_file_timing_end(dest, FS_OP_RENAME);
}
return ret;
}

int fs_delete(struct fs_file *file)
{
int ret;

file->fs->stats.delete_count++;
fs_file_timing_start(file, FS_OP_DELETE);
T_BEGIN {
ret = file->fs->v.delete_file(file);
} T_END;
if (!(ret < 0 && errno == EAGAIN))
if (!(ret < 0 && errno == EAGAIN)) {
file->fs->stats.delete_count++;
fs_file_timing_end(file, FS_OP_DELETE);
}
return ret;
}

Expand Down

0 comments on commit 5b98064

Please sign in to comment.