blobfs_bdev_ut : fix memory leak
This memory leak bug is very easy to reproduce. You can follow this step to reproduce: 1. clone master spdk , update submoudle 2. ./configure --with-fuse && make -j24 3. valgrind --leak-check=full --error-exitcode=2 test/unit/lib/blobfs/blobfs_bdev.c/blobfs_bdev_ut It show the memory when you run valgrind. This is because the ctx in spdk_blobfs_bdev_mount have not freed when spdk_fs_load(override in blobfs_bdev_ut) passed. So i added a unmount operation after mount operation to fix this problem. Signed-off-by: jiaqizho <jiaqi.zhou@intel.com> Change-Id: I770f914123e353dc42d0420c1fb8b34ebdf88f6c Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473171 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
861010b2d3
commit
2271c69500
@ -45,6 +45,7 @@ bool g_fs_load_fail = false;
|
||||
bool g_fs_unload_fail = false;
|
||||
bool g_bs_bdev_claim_fail = false;
|
||||
bool g_blobfs_fuse_start_fail = false;
|
||||
struct blobfs_bdev_operation_ctx *g_fs_ctx;
|
||||
|
||||
const char *g_bdev_name = "ut_bdev";
|
||||
|
||||
@ -88,6 +89,7 @@ spdk_fs_load(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn,
|
||||
}
|
||||
|
||||
cb_fn(cb_arg, NULL, rc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -122,7 +124,7 @@ spdk_fs_init(struct spdk_bs_dev *dev, struct spdk_blobfs_opts *opt,
|
||||
int
|
||||
spdk_bs_bdev_claim(struct spdk_bs_dev *bs_dev, struct spdk_bdev_module *module)
|
||||
{
|
||||
if (g_bs_bdev_claim_fail == true) {
|
||||
if (g_bs_bdev_claim_fail) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -133,10 +135,13 @@ int
|
||||
spdk_blobfs_fuse_start(const char *bdev_name, const char *mountpoint, struct spdk_filesystem *fs,
|
||||
blobfs_fuse_unmount_cb cb_fn, void *cb_arg, struct spdk_blobfs_fuse **_bfuse)
|
||||
{
|
||||
if (g_blobfs_fuse_start_fail == true) {
|
||||
if (g_blobfs_fuse_start_fail) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* store the ctx for unmount operation */
|
||||
g_fs_ctx = cb_arg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -312,6 +317,11 @@ spdk_blobfs_bdev_mount_test(void)
|
||||
/* no fail */
|
||||
spdk_blobfs_bdev_mount(g_bdev_name, mountpoint, blobfs_bdev_op_complete, NULL);
|
||||
CU_ASSERT(g_fserrno == 0);
|
||||
CU_ASSERT(g_fs_ctx != NULL);
|
||||
|
||||
/* after mount operation success , we need make sure unmount operation success */
|
||||
blobfs_bdev_unmount(g_fs_ctx);
|
||||
CU_ASSERT(g_fserrno == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user