* [PATCH 1/2] erofs-utils: don't create hardlinked directories [not found] <20201204172042.24180-1-hsiangkao.ref@aol.com> @ 2020-12-04 17:20 ` Gao Xiang via Linux-erofs 2020-12-04 17:20 ` [PATCH 2/2] erofs-utils: fix cross-device sub-mounts Gao Xiang via Linux-erofs 2020-12-05 7:53 ` [PATCH 1/2] erofs-utils: don't create hardlinked directories Li GuiFu via Linux-erofs 0 siblings, 2 replies; 5+ messages in thread From: Gao Xiang via Linux-erofs @ 2020-12-04 17:20 UTC (permalink / raw) To: linux-erofs From: Gao Xiang <hsiangkao@redhat.com> From: Gao Xiang <hsiangkao@aol.com> Fix an issue which behaves the same as the following mkisofs BZ due to bindmount: https://bugzilla.redhat.com/show_bug.cgi?id=1749860 Fixes: a17497f0844a ("erofs-utils: introduce inode operations") Signed-off-by: Gao Xiang <hsiangkao@aol.com> --- regression testcases will be uploaded to: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/log/?h=experimental-tests for now (erofs-utils v1.3 will include testcases then.) lib/inode.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/inode.c b/lib/inode.c index 388d21db3845..1cf813daa396 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -823,9 +823,16 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src) if (ret) return ERR_PTR(-errno); - inode = erofs_iget(st.st_ino); - if (inode) - return inode; + /* + * lookup in hash table first, if it already exists we have a + * hard-link, just return it. Also don't lookup for directories + * since hard-link directory isn't allowed. + */ + if (!S_ISDIR(st.st_mode)) { + inode = erofs_iget(st.st_ino); + if (inode) + return inode; + } /* cannot find in the inode cache */ inode = erofs_new_inode(); -- 2.24.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] erofs-utils: fix cross-device sub-mounts 2020-12-04 17:20 ` [PATCH 1/2] erofs-utils: don't create hardlinked directories Gao Xiang via Linux-erofs @ 2020-12-04 17:20 ` Gao Xiang via Linux-erofs 2020-12-04 17:56 ` [PATCH v2 2/2] erofs-utils: fix cross-device submounts Gao Xiang via Linux-erofs 2020-12-05 7:53 ` [PATCH 1/2] erofs-utils: don't create hardlinked directories Li GuiFu via Linux-erofs 1 sibling, 1 reply; 5+ messages in thread From: Gao Xiang via Linux-erofs @ 2020-12-04 17:20 UTC (permalink / raw) To: linux-erofs From: Gao Xiang <hsiangkao@redhat.com> From: Gao Xiang <hsiangkao@aol.com> Use device ID and inode number to identify hardlinks rather than inode number only. Fixes: a17497f0844a ("erofs-utils: introduce inode operations") Signed-off-by: Gao Xiang <hsiangkao@aol.com> --- include/erofs/internal.h | 7 ++++++- lib/inode.c | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/erofs/internal.h b/include/erofs/internal.h index bf13c166ba16..ac5b270329e2 100644 --- a/include/erofs/internal.h +++ b/include/erofs/internal.h @@ -112,7 +112,12 @@ EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM) struct erofs_inode { struct list_head i_hash, i_subdirs, i_xattrs; - unsigned int flags; + union { + /* (erofsfuse) runtime flags */ + unsigned int flags; + /* (mkfs.erofs) device ID containing source file */ + u32 dev; + }; unsigned int i_count; struct erofs_inode *i_parent; diff --git a/lib/inode.c b/lib/inode.c index 1cf813daa396..cad94270e6bc 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -35,7 +35,7 @@ static unsigned char erofs_type_by_mode[S_IFMT >> S_SHIFT] = { [S_IFLNK >> S_SHIFT] = EROFS_FT_SYMLINK, }; -#define NR_INODE_HASHTABLE 64 +#define NR_INODE_HASHTABLE 16384 struct list_head inode_hashtable[NR_INODE_HASHTABLE]; @@ -54,14 +54,14 @@ static struct erofs_inode *erofs_igrab(struct erofs_inode *inode) } /* get the inode from the (source) inode # */ -struct erofs_inode *erofs_iget(ino_t ino) +struct erofs_inode *erofs_iget(dev_t dev, ino_t ino) { struct list_head *head = - &inode_hashtable[ino % NR_INODE_HASHTABLE]; + &inode_hashtable[(ino ^ dev) % NR_INODE_HASHTABLE]; struct erofs_inode *inode; list_for_each_entry(inode, head, i_hash) - if (inode->i_ino[1] == ino) + if (inode->i_ino[1] == ino && inode->dev == dev) return erofs_igrab(inode); return NULL; } @@ -764,6 +764,7 @@ int erofs_fill_inode(struct erofs_inode *inode, strncpy(inode->i_srcpath, path, sizeof(inode->i_srcpath) - 1); inode->i_srcpath[sizeof(inode->i_srcpath) - 1] = '\0'; + inode->dev = st->st_dev; inode->i_ino[1] = st->st_ino; if (erofs_should_use_inode_extended(inode)) { @@ -778,7 +779,8 @@ int erofs_fill_inode(struct erofs_inode *inode, } list_add(&inode->i_hash, - &inode_hashtable[st->st_ino % NR_INODE_HASHTABLE]); + &inode_hashtable[(st->st_ino ^ st->st_dev) % + NR_INODE_HASHTABLE]); return 0; } @@ -824,12 +826,12 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src) return ERR_PTR(-errno); /* - * lookup in hash table first, if it already exists we have a - * hard-link, just return it. Also don't lookup for directories + * lookup in hash table first, if it already exists we have + * a hard-link, just return it. Don't lookup for directories * since hard-link directory isn't allowed. */ if (!S_ISDIR(st.st_mode)) { - inode = erofs_iget(st.st_ino); + inode = erofs_iget(st.st_dev, st.st_ino); if (inode) return inode; } -- 2.24.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] erofs-utils: fix cross-device submounts 2020-12-04 17:20 ` [PATCH 2/2] erofs-utils: fix cross-device sub-mounts Gao Xiang via Linux-erofs @ 2020-12-04 17:56 ` Gao Xiang via Linux-erofs 2020-12-05 7:53 ` Li GuiFu via Linux-erofs 0 siblings, 1 reply; 5+ messages in thread From: Gao Xiang via Linux-erofs @ 2020-12-04 17:56 UTC (permalink / raw) To: linux-erofs From: Gao Xiang <hsiangkao@aol.com> Use device ID and inode number to identify hardlinks rather than inode number only. Fixes: a17497f0844a ("erofs-utils: introduce inode operations") Signed-off-by: Gao Xiang <hsiangkao@aol.com> --- changes since v1: - fix improper inline comment update; include/erofs/internal.h | 7 ++++++- lib/inode.c | 14 ++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/erofs/internal.h b/include/erofs/internal.h index bf13c166ba16..ac5b270329e2 100644 --- a/include/erofs/internal.h +++ b/include/erofs/internal.h @@ -112,7 +112,12 @@ EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM) struct erofs_inode { struct list_head i_hash, i_subdirs, i_xattrs; - unsigned int flags; + union { + /* (erofsfuse) runtime flags */ + unsigned int flags; + /* (mkfs.erofs) device ID containing source file */ + u32 dev; + }; unsigned int i_count; struct erofs_inode *i_parent; diff --git a/lib/inode.c b/lib/inode.c index 1cf813daa396..618eb284550f 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -35,7 +35,7 @@ static unsigned char erofs_type_by_mode[S_IFMT >> S_SHIFT] = { [S_IFLNK >> S_SHIFT] = EROFS_FT_SYMLINK, }; -#define NR_INODE_HASHTABLE 64 +#define NR_INODE_HASHTABLE 16384 struct list_head inode_hashtable[NR_INODE_HASHTABLE]; @@ -54,14 +54,14 @@ static struct erofs_inode *erofs_igrab(struct erofs_inode *inode) } /* get the inode from the (source) inode # */ -struct erofs_inode *erofs_iget(ino_t ino) +struct erofs_inode *erofs_iget(dev_t dev, ino_t ino) { struct list_head *head = - &inode_hashtable[ino % NR_INODE_HASHTABLE]; + &inode_hashtable[(ino ^ dev) % NR_INODE_HASHTABLE]; struct erofs_inode *inode; list_for_each_entry(inode, head, i_hash) - if (inode->i_ino[1] == ino) + if (inode->i_ino[1] == ino && inode->dev == dev) return erofs_igrab(inode); return NULL; } @@ -764,6 +764,7 @@ int erofs_fill_inode(struct erofs_inode *inode, strncpy(inode->i_srcpath, path, sizeof(inode->i_srcpath) - 1); inode->i_srcpath[sizeof(inode->i_srcpath) - 1] = '\0'; + inode->dev = st->st_dev; inode->i_ino[1] = st->st_ino; if (erofs_should_use_inode_extended(inode)) { @@ -778,7 +779,8 @@ int erofs_fill_inode(struct erofs_inode *inode, } list_add(&inode->i_hash, - &inode_hashtable[st->st_ino % NR_INODE_HASHTABLE]); + &inode_hashtable[(st->st_ino ^ st->st_dev) % + NR_INODE_HASHTABLE]); return 0; } @@ -829,7 +831,7 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src) * since hard-link directory isn't allowed. */ if (!S_ISDIR(st.st_mode)) { - inode = erofs_iget(st.st_ino); + inode = erofs_iget(st.st_dev, st.st_ino); if (inode) return inode; } -- 2.24.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] erofs-utils: fix cross-device submounts 2020-12-04 17:56 ` [PATCH v2 2/2] erofs-utils: fix cross-device submounts Gao Xiang via Linux-erofs @ 2020-12-05 7:53 ` Li GuiFu via Linux-erofs 0 siblings, 0 replies; 5+ messages in thread From: Li GuiFu via Linux-erofs @ 2020-12-05 7:53 UTC (permalink / raw) To: Gao Xiang, linux-erofs On 2020/12/5 1:56, Gao Xiang via Linux-erofs wrote: > From: Gao Xiang <hsiangkao@aol.com> > > Use device ID and inode number to identify hardlinks > rather than inode number only. > > Fixes: a17497f0844a ("erofs-utils: introduce inode operations") > Signed-off-by: Gao Xiang <hsiangkao@aol.com> > --- > changes since v1: > - fix improper inline comment update; > > include/erofs/internal.h | 7 ++++++- > lib/inode.c | 14 ++++++++------ > 2 files changed, 14 insertions(+), 7 deletions(-) > It looks good Reviewed-by: Li Guifu <bluce.lee@aliyun.com> Thanks, ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] erofs-utils: don't create hardlinked directories 2020-12-04 17:20 ` [PATCH 1/2] erofs-utils: don't create hardlinked directories Gao Xiang via Linux-erofs 2020-12-04 17:20 ` [PATCH 2/2] erofs-utils: fix cross-device sub-mounts Gao Xiang via Linux-erofs @ 2020-12-05 7:53 ` Li GuiFu via Linux-erofs 1 sibling, 0 replies; 5+ messages in thread From: Li GuiFu via Linux-erofs @ 2020-12-05 7:53 UTC (permalink / raw) To: Gao Xiang, linux-erofs On 2020/12/5 1:20, Gao Xiang via Linux-erofs wrote: > From: Gao Xiang <hsiangkao@redhat.com> > > From: Gao Xiang <hsiangkao@aol.com> > > Fix an issue which behaves the same as the following > mkisofs BZ due to bindmount: > https://bugzilla.redhat.com/show_bug.cgi?id=1749860 > > Fixes: a17497f0844a ("erofs-utils: introduce inode operations") > Signed-off-by: Gao Xiang <hsiangkao@aol.com> > --- > regression testcases will be uploaded to: > https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/log/?h=experimental-tests > for now (erofs-utils v1.3 will include testcases then.) > > lib/inode.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > It looks good Reviewed-by: Li Guifu <bluce.lee@aliyun.com> Thanks, ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-05 7:54 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20201204172042.24180-1-hsiangkao.ref@aol.com> 2020-12-04 17:20 ` [PATCH 1/2] erofs-utils: don't create hardlinked directories Gao Xiang via Linux-erofs 2020-12-04 17:20 ` [PATCH 2/2] erofs-utils: fix cross-device sub-mounts Gao Xiang via Linux-erofs 2020-12-04 17:56 ` [PATCH v2 2/2] erofs-utils: fix cross-device submounts Gao Xiang via Linux-erofs 2020-12-05 7:53 ` Li GuiFu via Linux-erofs 2020-12-05 7:53 ` [PATCH 1/2] erofs-utils: don't create hardlinked directories Li GuiFu via Linux-erofs
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).