Change seen_fsid to hold fd and DIR in order to keep access to each fs.
This will be used for 'subvol delete --commit-after'.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
u64 devs_found = 0;
u64 total;
- if (add_seen_fsid(fs_devices->fsid, seen_fsid_hash))
+ if (add_seen_fsid(fs_devices->fsid, seen_fsid_hash, -1, NULL))
return;
uuid_unparse(fs_devices->fsid, uuidbuf);
struct btrfs_ioctl_dev_info_args *tmp_dev_info;
int ret;
- ret = add_seen_fsid(fs_info->fsid, seen_fsid_hash);
+ ret = add_seen_fsid(fs_info->fsid, seen_fsid_hash, -1, NULL);
if (ret == -EEXIST)
return 0;
else if (ret)
return 0;
}
-int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[])
+int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[],
+ int fd, DIR *dirstream)
{
u8 hash = fsid[0];
int slot = hash % SEEN_FSID_HASH_SIZE;
alloc->next = NULL;
memcpy(alloc->fsid, fsid, BTRFS_FSID_SIZE);
+ alloc->fd = fd;
+ alloc->dirstream = dirstream;
if (seen)
seen->next = alloc;
seen = seen_fsid_hash[slot];
while (seen) {
next = seen->next;
+ close_file_or_dir(seen->fd, seen->dirstream);
free(seen);
seen = next;
}
struct seen_fsid {
u8 fsid[BTRFS_FSID_SIZE];
struct seen_fsid *next;
+ DIR *dirstream;
+ int fd;
};
int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
int get_fsid(const char *path, u8 *fsid, int silent);
int is_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[]);
-int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[]);
+int add_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[],
+ int fd, DIR *dirstream);
void free_seen_fsid(struct seen_fsid *seen_fsid_hash[]);
int get_label(const char *btrfs_dev, char *label);