mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-08 23:07:28 -04:00
main: drop nlink optimization
calculate the nlink for the directory on each stat. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
da13832baa
commit
f703870668
@ -33,7 +33,6 @@ struct ovl_ino
|
||||
dev_t dev;
|
||||
int lookups;
|
||||
mode_t mode;
|
||||
int nlinks;
|
||||
};
|
||||
|
||||
struct ovl_node
|
||||
|
17
main.c
17
main.c
@ -690,8 +690,8 @@ rpl_stat (fuse_req_t req, struct ovl_node *node, int fd, const char *path, struc
|
||||
ret = stat (path, st);
|
||||
else if (node->hidden)
|
||||
ret = fstatat (node_dirfd (node), node->path, st, AT_SYMLINK_NOFOLLOW);
|
||||
else
|
||||
ret = l->ds->statat (l, node->path, st, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS);
|
||||
else
|
||||
ret = l->ds->statat (l, node->path, st, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -701,7 +701,7 @@ rpl_stat (fuse_req_t req, struct ovl_node *node, int fd, const char *path, struc
|
||||
|
||||
st->st_ino = node->tmp_ino;
|
||||
st->st_dev = node->tmp_dev;
|
||||
if (ret == 0 && node_dirp (node) && node->ino->nlinks <= 0)
|
||||
if (ret == 0 && node_dirp (node))
|
||||
{
|
||||
struct ovl_node *it;
|
||||
|
||||
@ -712,7 +712,6 @@ rpl_stat (fuse_req_t req, struct ovl_node *node, int fd, const char *path, struc
|
||||
if (node_dirp (it))
|
||||
st->st_nlink++;
|
||||
}
|
||||
node->ino->nlinks = st->st_nlink;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -1347,19 +1346,13 @@ insert_node (struct ovl_node *parent, struct ovl_node *item, bool replace)
|
||||
{
|
||||
if (hash_lookup (prev_parent->children, item) == item)
|
||||
hash_delete (prev_parent->children, item);
|
||||
if (is_dir)
|
||||
prev_parent->ino->nlinks--;
|
||||
}
|
||||
|
||||
if (replace)
|
||||
{
|
||||
old = hash_delete (parent->children, item);
|
||||
if (old)
|
||||
{
|
||||
if (node_dirp (old))
|
||||
parent->ino->nlinks--;
|
||||
node_free (old);
|
||||
}
|
||||
node_free (old);
|
||||
}
|
||||
|
||||
ret = hash_insert_if_absent (parent->children, item, (const void **) &old);
|
||||
@ -1376,8 +1369,6 @@ insert_node (struct ovl_node *parent, struct ovl_node *item, bool replace)
|
||||
}
|
||||
|
||||
item->parent = parent;
|
||||
if (is_dir)
|
||||
parent->ino->nlinks++;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -145,3 +145,27 @@ test -e merged/a/test
|
||||
ls -l merged/b
|
||||
|
||||
test -e merged/b/test
|
||||
|
||||
#### Correct number of directory nlink
|
||||
|
||||
umount merged
|
||||
|
||||
rm -rf lower upper workdir merged
|
||||
mkdir lower upper workdir merged
|
||||
mkdir lower/a lower/a/1 lower/a/2 lower/a/3
|
||||
|
||||
fuse-overlayfs -o lowerdir=lower,upperdir=upper,workdir=workdir merged
|
||||
|
||||
test $(stat -c %h merged/a) = 5
|
||||
|
||||
mkdir merged/a/4
|
||||
|
||||
test $(stat -c %h merged/a) = 6
|
||||
|
||||
rm -rf merged/a/4
|
||||
|
||||
test $(stat -c %h merged/a) = 5
|
||||
|
||||
rm -rf merged/a/3
|
||||
|
||||
test $(stat -c %h merged/a) = 4
|
||||
|
Loading…
x
Reference in New Issue
Block a user