summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisono, Tomohiro <misono.tomohiro@jp.fujitsu.com>2017-09-27 11:02:47 +0900
committerDavid Sterba <dsterba@suse.com>2017-10-06 13:23:30 +0200
commit26908f61461c1897198b457a76856c78e849153f (patch)
treea7d46ca7f5070032612ad2822e01a092ef349d08
parent836aa5202a4fa2ca34a5705c8808c7f7f1d40a8b (diff)
btrfs-progs: change seen_fsid to hold fd and DIR
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>
-rw-r--r--cmds-filesystem.c4
-rw-r--r--utils.c6
-rw-r--r--utils.h5
3 files changed, 11 insertions, 4 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 6208fb18..c39f2d15 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -277,7 +277,7 @@ static void print_one_uuid(struct btrfs_fs_devices *fs_devices,
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);
@@ -324,7 +324,7 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
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)
diff --git a/utils.c b/utils.c
index 3db8bdd1..9d20cab0 100644
--- a/utils.c
+++ b/utils.c
@@ -1804,7 +1804,8 @@ int is_seen_fsid(u8 *fsid, struct seen_fsid *seen_fsid_hash[])
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;
@@ -1831,6 +1832,8 @@ insert:
alloc->next = NULL;
memcpy(alloc->fsid, fsid, BTRFS_FSID_SIZE);
+ alloc->fd = fd;
+ alloc->dirstream = dirstream;
if (seen)
seen->next = alloc;
@@ -1850,6 +1853,7 @@ void free_seen_fsid(struct seen_fsid *seen_fsid_hash[])
seen = seen_fsid_hash[slot];
while (seen) {
next = seen->next;
+ close_file_or_dir(seen->fd, seen->dirstream);
free(seen);
seen = next;
}
diff --git a/utils.h b/utils.h
index 7e9d5ac6..e47b257b 100644
--- a/utils.h
+++ b/utils.h
@@ -73,6 +73,8 @@ void units_set_base(unsigned *units, unsigned base);
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,
@@ -110,7 +112,8 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
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);