mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-26 04:57:57 +00:00
Clear caches when opening and closing devices
This should fix problems with cache aliases in the kernel
This commit is contained in:
parent
6cd836d7d9
commit
8fe354744c
@ -641,6 +641,9 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
|
|||||||
if (sb_bytenr == 0)
|
if (sb_bytenr == 0)
|
||||||
sb_bytenr = BTRFS_SUPER_INFO_OFFSET;
|
sb_bytenr = BTRFS_SUPER_INFO_OFFSET;
|
||||||
|
|
||||||
|
/* try to drop all the caches */
|
||||||
|
posix_fadvise(fp, 0, 0, POSIX_FADV_DONTNEED);
|
||||||
|
|
||||||
ret = btrfs_scan_one_device(fp, path, &fs_devices,
|
ret = btrfs_scan_one_device(fp, path, &fs_devices,
|
||||||
&total_devs, sb_bytenr);
|
&total_devs, sb_bytenr);
|
||||||
|
|
||||||
@ -1091,6 +1094,10 @@ static int close_all_devices(struct btrfs_fs_info *fs_info)
|
|||||||
list = &fs_info->fs_devices->devices;
|
list = &fs_info->fs_devices->devices;
|
||||||
list_for_each(next, list) {
|
list_for_each(next, list) {
|
||||||
device = list_entry(next, struct btrfs_device, dev_list);
|
device = list_entry(next, struct btrfs_device, dev_list);
|
||||||
|
if (device->fd) {
|
||||||
|
fsync(device->fd);
|
||||||
|
posix_fadvise(device->fd, 0, 0, POSIX_FADV_DONTNEED);
|
||||||
|
}
|
||||||
close(device->fd);
|
close(device->fd);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -176,6 +176,8 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
|
||||||
|
|
||||||
if (device->devid == fs_devices->latest_devid)
|
if (device->devid == fs_devices->latest_devid)
|
||||||
fs_devices->latest_bdev = fd;
|
fs_devices->latest_bdev = fd;
|
||||||
if (device->devid == fs_devices->lowest_devid)
|
if (device->devid == fs_devices->lowest_devid)
|
||||||
|
Loading…
Reference in New Issue
Block a user