Message ID | 20240506103313.773503-2-chao@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Commit | a798ff17cd2dabe47d5d4ed3d509631793c36e19 |
Headers | show |
Series | [f2fs-dev,1/3] f2fs: fix to release node block count in error path of f2fs_new_node_page() | expand |
On 05/06, Chao Yu wrote: > During gc_data_segment(), if inode state is abnormal, it missed to call > iput(), fix it. > > Fixes: 132e3209789c ("f2fs: remove false alarm on iget failure during GC") > Fixes: 9056d6489f5a ("f2fs: fix to do sanity check on inode type during garbage collection") > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/gc.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > index 8852814dab7f..e86c7f01539a 100644 > --- a/fs/f2fs/gc.c > +++ b/fs/f2fs/gc.c > @@ -1554,10 +1554,15 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, > int err; > > inode = f2fs_iget(sb, dni.ino); > - if (IS_ERR(inode) || is_bad_inode(inode) || > - special_file(inode->i_mode)) > + if (IS_ERR(inode)) > continue; > > + if (is_bad_inode(inode) || > + special_file(inode->i_mode)) { > + iput(inode); iget_failed() called iput()? > + continue; > + } > + > err = f2fs_gc_pinned_control(inode, gc_type, segno); > if (err == -EAGAIN) { > iput(inode); > -- > 2.40.1
On 2024/5/9 8:46, Jaegeuk Kim wrote: > On 05/06, Chao Yu wrote: >> During gc_data_segment(), if inode state is abnormal, it missed to call >> iput(), fix it. >> >> Fixes: 132e3209789c ("f2fs: remove false alarm on iget failure during GC") >> Fixes: 9056d6489f5a ("f2fs: fix to do sanity check on inode type during garbage collection") >> Signed-off-by: Chao Yu <chao@kernel.org> >> --- >> fs/f2fs/gc.c | 9 +++++++-- >> 1 file changed, 7 insertions(+), 2 deletions(-) >> >> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c >> index 8852814dab7f..e86c7f01539a 100644 >> --- a/fs/f2fs/gc.c >> +++ b/fs/f2fs/gc.c >> @@ -1554,10 +1554,15 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, >> int err; >> >> inode = f2fs_iget(sb, dni.ino); >> - if (IS_ERR(inode) || is_bad_inode(inode) || >> - special_file(inode->i_mode)) >> + if (IS_ERR(inode)) >> continue; >> >> + if (is_bad_inode(inode) || >> + special_file(inode->i_mode)) { >> + iput(inode); > > iget_failed() called iput()? It looks the bad inode was referenced in this context, it needs to be iput()ed here. The bad inode was made in other thread, please check description in commit b73e52824c89 ("f2fs: reposition unlock_new_inode to prevent accessing invalid inode"). Thanks, > > >> + continue; >> + } >> + >> err = f2fs_gc_pinned_control(inode, gc_type, segno); >> if (err == -EAGAIN) { >> iput(inode); >> -- >> 2.40.1
On 05/09, Chao Yu wrote: > On 2024/5/9 8:46, Jaegeuk Kim wrote: > > On 05/06, Chao Yu wrote: > > > During gc_data_segment(), if inode state is abnormal, it missed to call > > > iput(), fix it. > > > > > > Fixes: 132e3209789c ("f2fs: remove false alarm on iget failure during GC") > > > Fixes: 9056d6489f5a ("f2fs: fix to do sanity check on inode type during garbage collection") > > > Signed-off-by: Chao Yu <chao@kernel.org> > > > --- > > > fs/f2fs/gc.c | 9 +++++++-- > > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > > > index 8852814dab7f..e86c7f01539a 100644 > > > --- a/fs/f2fs/gc.c > > > +++ b/fs/f2fs/gc.c > > > @@ -1554,10 +1554,15 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, > > > int err; > > > inode = f2fs_iget(sb, dni.ino); > > > - if (IS_ERR(inode) || is_bad_inode(inode) || > > > - special_file(inode->i_mode)) > > > + if (IS_ERR(inode)) > > > continue; > > > + if (is_bad_inode(inode) || > > > + special_file(inode->i_mode)) { > > > + iput(inode); > > > > iget_failed() called iput()? > > It looks the bad inode was referenced in this context, it needs to be iput()ed > here. > > The bad inode was made in other thread, please check description in commit > b73e52824c89 ("f2fs: reposition unlock_new_inode to prevent accessing invalid > inode"). Ah, it's non-error case. Right. > > Thanks, > > > > > > > > + continue; > > > + } > > > + > > > err = f2fs_gc_pinned_control(inode, gc_type, segno); > > > if (err == -EAGAIN) { > > > iput(inode); > > > -- > > > 2.40.1
On 2024/5/9 10:49, Chao Yu wrote: > On 2024/5/9 8:46, Jaegeuk Kim wrote: >> On 05/06, Chao Yu wrote: >>> During gc_data_segment(), if inode state is abnormal, it missed to call >>> iput(), fix it. >>> >>> Fixes: 132e3209789c ("f2fs: remove false alarm on iget failure during GC") Oh, this line should be replaced w/ below one, let me revise the patch. Fixes: b73e52824c89 ("f2fs: reposition unlock_new_inode to prevent accessing invalid inode"). Thanks, >>> Fixes: 9056d6489f5a ("f2fs: fix to do sanity check on inode type during garbage collection") >>> Signed-off-by: Chao Yu <chao@kernel.org> >>> --- >>> fs/f2fs/gc.c | 9 +++++++-- >>> 1 file changed, 7 insertions(+), 2 deletions(-) >>> >>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c >>> index 8852814dab7f..e86c7f01539a 100644 >>> --- a/fs/f2fs/gc.c >>> +++ b/fs/f2fs/gc.c >>> @@ -1554,10 +1554,15 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, >>> int err; >>> inode = f2fs_iget(sb, dni.ino); >>> - if (IS_ERR(inode) || is_bad_inode(inode) || >>> - special_file(inode->i_mode)) >>> + if (IS_ERR(inode)) >>> continue; >>> + if (is_bad_inode(inode) || >>> + special_file(inode->i_mode)) { >>> + iput(inode); >> >> iget_failed() called iput()? > > It looks the bad inode was referenced in this context, it needs to be iput()ed > here. > > The bad inode was made in other thread, please check description in commit > b73e52824c89 ("f2fs: reposition unlock_new_inode to prevent accessing invalid > inode"). > > Thanks, > >> >> >>> + continue; >>> + } >>> + >>> err = f2fs_gc_pinned_control(inode, gc_type, segno); >>> if (err == -EAGAIN) { >>> iput(inode); >>> -- >>> 2.40.1 > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 8852814dab7f..e86c7f01539a 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1554,10 +1554,15 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, int err; inode = f2fs_iget(sb, dni.ino); - if (IS_ERR(inode) || is_bad_inode(inode) || - special_file(inode->i_mode)) + if (IS_ERR(inode)) continue; + if (is_bad_inode(inode) || + special_file(inode->i_mode)) { + iput(inode); + continue; + } + err = f2fs_gc_pinned_control(inode, gc_type, segno); if (err == -EAGAIN) { iput(inode);
During gc_data_segment(), if inode state is abnormal, it missed to call iput(), fix it. Fixes: 132e3209789c ("f2fs: remove false alarm on iget failure during GC") Fixes: 9056d6489f5a ("f2fs: fix to do sanity check on inode type during garbage collection") Signed-off-by: Chao Yu <chao@kernel.org> --- fs/f2fs/gc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)