* [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs
@ 2020-05-26 7:45 Wangyan
2020-05-27 22:52 ` Andrew Morton
2020-06-01 8:30 ` Joseph Qi
0 siblings, 2 replies; 7+ messages in thread
From: Wangyan @ 2020-05-26 7:45 UTC (permalink / raw)
To: ocfs2-devel
In this condition, the inode can not be wiped when error happened.
ocfs2_mkdir()
->ocfs2_mknod()
->ocfs2_mknod_locked()
->__ocfs2_mknod_locked()
->ocfs2_set_links_count() // i_links_count is 2
-> ... // an error accrue, goto roll_back or leave.
->ocfs2_commit_trans()
->iput(inode)
->evict()
->ocfs2_evict_inode()
->ocfs2_delete_inode()
->ocfs2_inode_lock()
->ocfs2_inode_lock_update()
->ocfs2_refresh_inode()
->set_nlink(); // inode->i_nlink is 2 now.
/* if wipe is 0, it will goto bail_unlock_inode */
->ocfs2_query_inode_wipe()
->if (inode->i_nlink) return; // wipe is 0.
/* inode can not be wiped */
->ocfs2_wipe_inode()
So, we need clear links before the transaction committed.
Signed-off-by: Yan Wang <wangyan122@huawei.com>
Reviewed-by: Jun Piao <piaojun@huawei.com>
---
fs/ocfs2/namei.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 5381020aaa9a..e61fdd8972ec 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -453,8 +453,12 @@ static int ocfs2_mknod(struct inode *dir,
leave:
if (status < 0 && did_quota_inode)
dquot_free_inode(inode);
- if (handle)
+ if (handle) {
+ if (status < 0 && new_fe_bh != NULL)
+ ocfs2_set_links_count((struct ocfs2_dinode *)
+ new_fe_bh->b_data, 0);
ocfs2_commit_trans(osb, handle);
+ }
ocfs2_inode_unlock(dir, 1);
if (did_block_signals)
@@ -598,6 +602,8 @@ static int __ocfs2_mknod_locked(struct inode *dir,
leave:
if (status < 0) {
if (*new_fe_bh) {
+ if (fe)
+ ocfs2_set_links_count(fe, 0);
brelse(*new_fe_bh);
*new_fe_bh = NULL;
}
@@ -2023,8 +2029,12 @@ static int ocfs2_symlink(struct inode *dir,
ocfs2_clusters_to_bytes(osb->sb, 1));
if (status < 0 && did_quota_inode)
dquot_free_inode(inode);
- if (handle)
+ if (handle) {
+ if (status < 0 && new_fe_bh != NULL)
+ ocfs2_set_links_count((struct ocfs2_dinode *)
+ new_fe_bh->b_data, 0);
ocfs2_commit_trans(osb, handle);
+ }
ocfs2_inode_unlock(dir, 1);
if (did_block_signals)
--
2.23.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs
2020-05-26 7:45 [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs Wangyan
@ 2020-05-27 22:52 ` Andrew Morton
2020-05-28 0:43 ` Wangyan
2020-06-01 8:30 ` Joseph Qi
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2020-05-27 22:52 UTC (permalink / raw)
To: ocfs2-devel
On Tue, 26 May 2020 15:45:35 +0800 Wangyan <wangyan122@huawei.com> wrote:
> In this condition, the inode can not be wiped when error happened.
> ocfs2_mkdir()
> ->ocfs2_mknod()
> ->ocfs2_mknod_locked()
> ->__ocfs2_mknod_locked()
> ->ocfs2_set_links_count() // i_links_count is 2
> -> ... // an error accrue, goto roll_back or leave.
> ->ocfs2_commit_trans()
> ->iput(inode)
> ->evict()
> ->ocfs2_evict_inode()
> ->ocfs2_delete_inode()
> ->ocfs2_inode_lock()
> ->ocfs2_inode_lock_update()
> ->ocfs2_refresh_inode()
> ->set_nlink(); // inode->i_nlink is 2 now.
> /* if wipe is 0, it will goto bail_unlock_inode */
> ->ocfs2_query_inode_wipe()
> ->if (inode->i_nlink) return; // wipe is 0.
> /* inode can not be wiped */
> ->ocfs2_wipe_inode()
> So, we need clear links before the transaction committed.
Do we think these fixes should be backported into -stable kernels?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs
2020-05-27 22:52 ` Andrew Morton
@ 2020-05-28 0:43 ` Wangyan
0 siblings, 0 replies; 7+ messages in thread
From: Wangyan @ 2020-05-28 0:43 UTC (permalink / raw)
To: ocfs2-devel
Yes, I think these fixes should be backported into -stable kernels.
On 2020/5/28 6:52, Andrew Morton wrote:
> On Tue, 26 May 2020 15:45:35 +0800 Wangyan <wangyan122@huawei.com> wrote:
>
>> In this condition, the inode can not be wiped when error happened.
>> ocfs2_mkdir()
>> ->ocfs2_mknod()
>> ->ocfs2_mknod_locked()
>> ->__ocfs2_mknod_locked()
>> ->ocfs2_set_links_count() // i_links_count is 2
>> -> ... // an error accrue, goto roll_back or leave.
>> ->ocfs2_commit_trans()
>> ->iput(inode)
>> ->evict()
>> ->ocfs2_evict_inode()
>> ->ocfs2_delete_inode()
>> ->ocfs2_inode_lock()
>> ->ocfs2_inode_lock_update()
>> ->ocfs2_refresh_inode()
>> ->set_nlink(); // inode->i_nlink is 2 now.
>> /* if wipe is 0, it will goto bail_unlock_inode */
>> ->ocfs2_query_inode_wipe()
>> ->if (inode->i_nlink) return; // wipe is 0.
>> /* inode can not be wiped */
>> ->ocfs2_wipe_inode()
>> So, we need clear links before the transaction committed.
>
> Do we think these fixes should be backported into -stable kernels?
>
>
>
> .
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs
2020-05-26 7:45 [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs Wangyan
2020-05-27 22:52 ` Andrew Morton
@ 2020-06-01 8:30 ` Joseph Qi
2020-08-07 3:49 ` Andrew Morton
1 sibling, 1 reply; 7+ messages in thread
From: Joseph Qi @ 2020-06-01 8:30 UTC (permalink / raw)
To: ocfs2-devel
Hi,
On 2020/5/26 15:45, Wangyan wrote:
> In this condition, the inode can not be wiped when error happened.
> ocfs2_mkdir()
> ->ocfs2_mknod()
> ->ocfs2_mknod_locked()
> ->__ocfs2_mknod_locked()
> ->ocfs2_set_links_count() // i_links_count is 2
> -> ... // an error accrue, goto roll_back or leave.
> ->ocfs2_commit_trans()
> ->iput(inode)
> ->evict()
> ->ocfs2_evict_inode()
> ->ocfs2_delete_inode()
> ->ocfs2_inode_lock()
> ->ocfs2_inode_lock_update()
> ->ocfs2_refresh_inode()
> ->set_nlink(); // inode->i_nlink is 2 now.
> /* if wipe is 0, it will goto bail_unlock_inode */
> ->ocfs2_query_inode_wipe()
> ->if (inode->i_nlink) return; // wipe is 0.
> /* inode can not be wiped */
> ->ocfs2_wipe_inode()
> So, we need clear links before the transaction committed.
>
> Signed-off-by: Yan Wang <wangyan122@huawei.com>
> Reviewed-by: Jun Piao <piaojun@huawei.com>
> ---
> fs/ocfs2/namei.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 5381020aaa9a..e61fdd8972ec 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -453,8 +453,12 @@ static int ocfs2_mknod(struct inode *dir,
> leave:
> if (status < 0 && did_quota_inode)
> dquot_free_inode(inode);
> - if (handle)
> + if (handle) {
> + if (status < 0 && new_fe_bh != NULL)
> + ocfs2_set_links_count((struct ocfs2_dinode *)
> + new_fe_bh->b_data, 0);
Seems no need to do this rollback under handle?
Only if (status < 0 && new_fe_bh) will be okay.
> ocfs2_commit_trans(osb, handle);
> + }
>
> ocfs2_inode_unlock(dir, 1);
> if (did_block_signals)
> @@ -598,6 +602,8 @@ static int __ocfs2_mknod_locked(struct inode *dir,
> leave:
> if (status < 0) {
> if (*new_fe_bh) {
> + if (fe)
> + ocfs2_set_links_count(fe, 0);
Leave this to caller will be enough.
Thanks,
Joseph
> brelse(*new_fe_bh);> *new_fe_bh = NULL;
> }
> @@ -2023,8 +2029,12 @@ static int ocfs2_symlink(struct inode *dir,
> ocfs2_clusters_to_bytes(osb->sb, 1));
> if (status < 0 && did_quota_inode)
> dquot_free_inode(inode);
> - if (handle)
> + if (handle) {
> + if (status < 0 && new_fe_bh != NULL)
> + ocfs2_set_links_count((struct ocfs2_dinode *)
> + new_fe_bh->b_data, 0);
> ocfs2_commit_trans(osb, handle);
> + }
>
> ocfs2_inode_unlock(dir, 1);
> if (did_block_signals)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs
2020-06-01 8:30 ` Joseph Qi
@ 2020-08-07 3:49 ` Andrew Morton
2022-10-16 23:32 ` Andrew Morton via Ocfs2-devel
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2020-08-07 3:49 UTC (permalink / raw)
To: ocfs2-devel
On Mon, 1 Jun 2020 16:30:30 +0800 Joseph Qi <jiangqi903@gmail.com> wrote:
> Hi,
>
> On 2020/5/26 15:45, Wangyan wrote:
> > In this condition, the inode can not be wiped when error happened.
> > ocfs2_mkdir()
> > ->ocfs2_mknod()
> > ->ocfs2_mknod_locked()
> > ->__ocfs2_mknod_locked()
> > ->ocfs2_set_links_count() // i_links_count is 2
> > -> ... // an error accrue, goto roll_back or leave.
> > ->ocfs2_commit_trans()
> > ->iput(inode)
> > ->evict()
> > ->ocfs2_evict_inode()
> > ->ocfs2_delete_inode()
> > ->ocfs2_inode_lock()
> > ->ocfs2_inode_lock_update()
> > ->ocfs2_refresh_inode()
> > ->set_nlink(); // inode->i_nlink is 2 now.
> > /* if wipe is 0, it will goto bail_unlock_inode */
> > ->ocfs2_query_inode_wipe()
> > ->if (inode->i_nlink) return; // wipe is 0.
> > /* inode can not be wiped */
> > ->ocfs2_wipe_inode()
> > So, we need clear links before the transaction committed.
> >
> > Signed-off-by: Yan Wang <wangyan122@huawei.com>
> > Reviewed-by: Jun Piao <piaojun@huawei.com>
> > ---
> > fs/ocfs2/namei.c | 14 ++++++++++++--
> > 1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> > index 5381020aaa9a..e61fdd8972ec 100644
> > --- a/fs/ocfs2/namei.c
> > +++ b/fs/ocfs2/namei.c
> > @@ -453,8 +453,12 @@ static int ocfs2_mknod(struct inode *dir,
> > leave:
> > if (status < 0 && did_quota_inode)
> > dquot_free_inode(inode);
> > - if (handle)
> > + if (handle) {
> > + if (status < 0 && new_fe_bh != NULL)
> > + ocfs2_set_links_count((struct ocfs2_dinode *)
> > + new_fe_bh->b_data, 0);
>
> Seems no need to do this rollback under handle?
> Only if (status < 0 && new_fe_bh) will be okay.
>
> > ocfs2_commit_trans(osb, handle);
> > + }
> >
> > ocfs2_inode_unlock(dir, 1);
> > if (did_block_signals)
> > @@ -598,6 +602,8 @@ static int __ocfs2_mknod_locked(struct inode *dir,
> > leave:
> > if (status < 0) {
> > if (*new_fe_bh) {
> > + if (fe)
> > + ocfs2_set_links_count(fe, 0);
>
> Leave this to caller will be enough.
Are we still awaiting a response to these review comments?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs
2020-08-07 3:49 ` Andrew Morton
@ 2022-10-16 23:32 ` Andrew Morton via Ocfs2-devel
2022-10-17 1:57 ` Joseph Qi via Ocfs2-devel
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton via Ocfs2-devel @ 2022-10-16 23:32 UTC (permalink / raw)
To: Joseph Qi, ocfs2-devel, Wangyan
I've been sitting on this patch series for over two years! I assume
the problem isn't terribly serious.
Can we please come to a decision on how to proceed? Thanks.
The current patches from the mm tree are below.
From: Wangyan <wangyan122@huawei.com>
Subject: ocfs2: clear links count in ocfs2_mknod() if an error occurs
In this condition, the inode can not be wiped when error happened.
ocfs2_mkdir()
->ocfs2_mknod()
->ocfs2_mknod_locked()
->__ocfs2_mknod_locked()
->ocfs2_set_links_count() // i_links_count is 2
-> ... // an error accrue, goto roll_back or leave.
->ocfs2_commit_trans()
->iput(inode)
->evict()
->ocfs2_evict_inode()
->ocfs2_delete_inode()
->ocfs2_inode_lock()
->ocfs2_inode_lock_update()
->ocfs2_refresh_inode()
->set_nlink(); // inode->i_nlink is 2 now.
/* if wipe is 0, it will goto bail_unlock_inode */
->ocfs2_query_inode_wipe()
->if (inode->i_nlink) return; // wipe is 0.
/* inode can not be wiped */
->ocfs2_wipe_inode()
So, we need clear links before the transaction committed.
Link: http://lkml.kernel.org/r/d8147c41-fb2b-bdf7-b660-1f3c8448c33f@huawei.com
Signed-off-by: Yan Wang <wangyan122@huawei.com>
Reviewed-by: Jun Piao <piaojun@huawei.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/ocfs2/namei.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
--- a/fs/ocfs2/namei.c~ocfs2-clear-links-count-in-ocfs2_mknod-if-an-error-occurs
+++ a/fs/ocfs2/namei.c
@@ -454,8 +454,12 @@ roll_back:
leave:
if (status < 0 && did_quota_inode)
dquot_free_inode(inode);
- if (handle)
+ if (handle) {
+ if (status < 0 && new_fe_bh != NULL)
+ ocfs2_set_links_count((struct ocfs2_dinode *)
+ new_fe_bh->b_data, 0);
ocfs2_commit_trans(osb, handle);
+ }
ocfs2_inode_unlock(dir, 1);
if (did_block_signals)
@@ -599,6 +603,8 @@ static int __ocfs2_mknod_locked(struct i
leave:
if (status < 0) {
if (*new_fe_bh) {
+ if (fe)
+ ocfs2_set_links_count(fe, 0);
brelse(*new_fe_bh);
*new_fe_bh = NULL;
}
@@ -2028,8 +2034,12 @@ bail:
ocfs2_clusters_to_bytes(osb->sb, 1));
if (status < 0 && did_quota_inode)
dquot_free_inode(inode);
- if (handle)
+ if (handle) {
+ if (status < 0 && new_fe_bh != NULL)
+ ocfs2_set_links_count((struct ocfs2_dinode *)
+ new_fe_bh->b_data, 0);
ocfs2_commit_trans(osb, handle);
+ }
ocfs2_inode_unlock(dir, 1);
if (did_block_signals)
_
From: Wangyan <wangyan122@huawei.com>
Subject: ocfs2: fix ocfs2 corrupt when iputting an inode
In this condition, it will cause an bug on error.
ocfs2_mkdir()
->ocfs2_mknod()
->ocfs2_mknod_locked()
->__ocfs2_mknod_locked()
//Assume inode->i_generation is genN.
->inode->i_generation = osb->s_next_generation++;
// The inode lockres has been initialized.
->ocfs2_populate_inode()
->ocfs2_create_new_inode_locks()
->An error happened, returned value is non-zero
// free the start_bit x in bg_blkno
->ocfs2_free_suballoc_bits()
->... /* Another process execute mkdir success in this place,
and it occupied the start_bit x in bg_blkno
which has been freed before. Its inode->i_generation
is genN + 1 */
->iput(inode)
->evict()
->ocfs2_evict_inode()
->ocfs2_delete_inode()
->ocfs2_inode_lock()
->ocfs2_inode_lock_update()
/* Bug on here, genN != genN + 1 */
->mlog_bug_on_msg(inode->i_generation !=
le32_to_cpu(fe->i_generation))
So, we need not to reclaim the inode when the inode->ip_inode_lockres
has been initialized. It will be freed in iput().
Link: http://lkml.kernel.org/r/ef080ca3-5d74-e276-17a1-d9e7c7e662c9@huawei.com
Fixes: b1529a41f777 ("ocfs2: should reclaim the inode if '__ocfs2_mknod_locked' returns an error")
Signed-off-by: Yan Wang <wangyan122@huawei.com>
Reviewed-by: Jun Piao <piaojun@huawei.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/ocfs2/namei.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/fs/ocfs2/namei.c~ocfs2-fix-ocfs2-corrupt-when-iputting-an-inode
+++ a/fs/ocfs2/namei.c
@@ -641,7 +641,8 @@ static int ocfs2_mknod_locked(struct ocf
status = __ocfs2_mknod_locked(dir, inode, dev, new_fe_bh,
parent_fe_bh, handle, inode_ac,
fe_blkno, suballoc_loc, suballoc_bit);
- if (status < 0) {
+ if (status < 0 && !(OCFS2_I(inode)->ip_inode_lockres.l_flags &
+ OCFS2_LOCK_INITIALIZED)) {
u64 bg_blkno = ocfs2_which_suballoc_group(fe_blkno, suballoc_bit);
int tmp = ocfs2_free_suballoc_bits(handle, inode_ac->ac_inode,
inode_ac->ac_bh, suballoc_bit, bg_blkno, 1);
_
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs
2022-10-16 23:32 ` Andrew Morton via Ocfs2-devel
@ 2022-10-17 1:57 ` Joseph Qi via Ocfs2-devel
0 siblings, 0 replies; 7+ messages in thread
From: Joseph Qi via Ocfs2-devel @ 2022-10-17 1:57 UTC (permalink / raw)
To: Andrew Morton, ocfs2-devel, Wangyan
Hi Andrew,
On 10/17/22 7:32 AM, Andrew Morton wrote:
>
> I've been sitting on this patch series for over two years! I assume
> the problem isn't terribly serious.
>
> Can we please come to a decision on how to proceed? Thanks.
>
> The current patches from the mm tree are below.
>
It seems I commented before, but without any response.
I'll take a look and send a new version base on the latest base today.
Thanks,
Joseph
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-17 1:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 7:45 [Ocfs2-devel] [PATCH 1/2] ocfs2: clear links count in ocfs2_mknod() if an error occurs Wangyan
2020-05-27 22:52 ` Andrew Morton
2020-05-28 0:43 ` Wangyan
2020-06-01 8:30 ` Joseph Qi
2020-08-07 3:49 ` Andrew Morton
2022-10-16 23:32 ` Andrew Morton via Ocfs2-devel
2022-10-17 1:57 ` Joseph Qi via Ocfs2-devel
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).