path: root/volumes.c
diff options
authorMiao Xie <>2013-07-03 21:25:11 +0800
committerChris Mason <>2013-07-03 14:06:54 -0400
commitd25aa23b0236418e891e1db66562035891a8faa8 (patch)
tree74db86927c6cd437babc868c0c687052b8831916 /volumes.c
parent0daa219ee1119e30059077da5be03c4506963fe2 (diff)
Btrfs-progs: Don't free the devices when close the ctree
Some commands(such as btrfs-convert) access the devices again after we close the ctree, so it is better that we don't free the devices objects when the ctree is closed, or we need re-allocate the memory for the devices. We needn't worry the memory leak problem, because all the memory will be freed after the taskes die. Signed-off-by: Miao Xie <> Signed-off-by: Chris Mason <>
Diffstat (limited to 'volumes.c')
1 files changed, 3 insertions, 0 deletions
diff --git a/volumes.c b/volumes.c
index b88385bb..0f6a35ba 100644
--- a/volumes.c
+++ b/volumes.c
@@ -163,6 +163,9 @@ again:
list_for_each(cur, &fs_devices->devices) {
device = list_entry(cur, struct btrfs_device, dev_list);
if (device->fd != -1) {
+ fsync(device->fd);
+ if (posix_fadvise(device->fd, 0, 0, POSIX_FADV_DONTNEED))
+ fprintf(stderr, "Warning, could not drop caches\n");
device->fd = -1;