Daeseok Youn
2015-Feb-27 23:48 UTC
[Ocfs2-devel] [PATCH 1/4 V2] ocfs2: use retval instead of status for checking error
The use of 'status' in __ocfs2_add_entry() can return wrong
status when some functions are failed.
If ocfs2_journal_access_db() in __ocfs2_add_entry() is failed,
that status is saved to 'status' but return variable is 'retval'
which is saved 'success' status. In case of this, __ocfs2_add_entry()
is failed but can be returned as 'success'.
So replace 'status' with 'retval'.
Signed-off-by: Daeseok Youn <daeseok.youn at gmail.com>
---
V2 : update changelog
fs/ocfs2/dir.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index b08050b..1478a50 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1617,7 +1617,7 @@ int __ocfs2_add_entry(handle_t *handle,
struct ocfs2_dir_entry *de, *de1;
struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data;
struct super_block *sb = dir->i_sb;
- int retval, status;
+ int retval;
unsigned int size = sb->s_blocksize;
struct buffer_head *insert_bh = lookup->dl_leaf_bh;
char *data_start = insert_bh->b_data;
@@ -1695,22 +1695,22 @@ int __ocfs2_add_entry(handle_t *handle,
}
if (insert_bh == parent_fe_bh)
- status = ocfs2_journal_access_di(handle,
+ retval = ocfs2_journal_access_di(handle,
INODE_CACHE(dir),
insert_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
else {
- status = ocfs2_journal_access_db(handle,
+ retval = ocfs2_journal_access_db(handle,
INODE_CACHE(dir),
insert_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ocfs2_dir_indexed(dir)) {
- status = ocfs2_dx_dir_insert(dir,
+ retval = ocfs2_dx_dir_insert(dir,
handle,
lookup);
- if (status) {
- mlog_errno(status);
+ if (retval) {
+ mlog_errno(retval);
goto bail;
}
}
--
1.7.1
Richard Weinberger
2015-Mar-02 09:04 UTC
[Ocfs2-devel] [PATCH 1/4 V2] ocfs2: use retval instead of status for checking error
Am 28.02.2015 um 00:48 schrieb Daeseok Youn:> The use of 'status' in __ocfs2_add_entry() can return wrong > status when some functions are failed. > > If ocfs2_journal_access_db() in __ocfs2_add_entry() is failed, > that status is saved to 'status' but return variable is 'retval' > which is saved 'success' status. In case of this, __ocfs2_add_entry() > is failed but can be returned as 'success'. > > So replace 'status' with 'retval'.As this patch is untested and the issue is theoretical I'm nervous. But the final decision is up to ocfs2 maintainers. Thanks, //richard
DaeSeok Youn
2015-Mar-13 03:59 UTC
[Ocfs2-devel] [PATCH 1/4 V2] ocfs2: use retval instead of status for checking error
Hi, This patch have been pending for 2 weeks. Do I need to check other things? please, check for me. Thanks! regards, Daeseok Youn 2015-02-28 8:48 GMT+09:00 Daeseok Youn <daeseok.youn at gmail.com>:> The use of 'status' in __ocfs2_add_entry() can return wrong > status when some functions are failed. > > If ocfs2_journal_access_db() in __ocfs2_add_entry() is failed, > that status is saved to 'status' but return variable is 'retval' > which is saved 'success' status. In case of this, __ocfs2_add_entry() > is failed but can be returned as 'success'. > > So replace 'status' with 'retval'. > > Signed-off-by: Daeseok Youn <daeseok.youn at gmail.com> > --- > V2 : update changelog > > fs/ocfs2/dir.c | 12 ++++++------ > 1 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c > index b08050b..1478a50 100644 > --- a/fs/ocfs2/dir.c > +++ b/fs/ocfs2/dir.c > @@ -1617,7 +1617,7 @@ int __ocfs2_add_entry(handle_t *handle, > struct ocfs2_dir_entry *de, *de1; > struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data; > struct super_block *sb = dir->i_sb; > - int retval, status; > + int retval; > unsigned int size = sb->s_blocksize; > struct buffer_head *insert_bh = lookup->dl_leaf_bh; > char *data_start = insert_bh->b_data; > @@ -1695,22 +1695,22 @@ int __ocfs2_add_entry(handle_t *handle, > } > > if (insert_bh == parent_fe_bh) > - status = ocfs2_journal_access_di(handle, > + retval = ocfs2_journal_access_di(handle, > INODE_CACHE(dir), > insert_bh, > OCFS2_JOURNAL_ACCESS_WRITE); > else { > - status = ocfs2_journal_access_db(handle, > + retval = ocfs2_journal_access_db(handle, > INODE_CACHE(dir), > insert_bh, > OCFS2_JOURNAL_ACCESS_WRITE); > > if (ocfs2_dir_indexed(dir)) { > - status = ocfs2_dx_dir_insert(dir, > + retval = ocfs2_dx_dir_insert(dir, > handle, > lookup); > - if (status) { > - mlog_errno(status); > + if (retval) { > + mlog_errno(retval); > goto bail; > } > } > -- > 1.7.1 >
Joseph Qi
2015-Mar-19 06:24 UTC
[Ocfs2-devel] [PATCH 1/4 V2] ocfs2: use retval instead of status for checking error
Looks good to me. On 2015/2/28 7:48, Daeseok Youn wrote:> The use of 'status' in __ocfs2_add_entry() can return wrong > status when some functions are failed. > > If ocfs2_journal_access_db() in __ocfs2_add_entry() is failed, > that status is saved to 'status' but return variable is 'retval' > which is saved 'success' status. In case of this, __ocfs2_add_entry() > is failed but can be returned as 'success'. > > So replace 'status' with 'retval'. > > Signed-off-by: Daeseok Youn <daeseok.youn at gmail.com>Reviewed-by: Joseph Qi <joseph.qi at huawei.com>> --- > V2 : update changelog > > fs/ocfs2/dir.c | 12 ++++++------ > 1 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c > index b08050b..1478a50 100644 > --- a/fs/ocfs2/dir.c > +++ b/fs/ocfs2/dir.c > @@ -1617,7 +1617,7 @@ int __ocfs2_add_entry(handle_t *handle, > struct ocfs2_dir_entry *de, *de1; > struct ocfs2_dinode *di = (struct ocfs2_dinode *)parent_fe_bh->b_data; > struct super_block *sb = dir->i_sb; > - int retval, status; > + int retval; > unsigned int size = sb->s_blocksize; > struct buffer_head *insert_bh = lookup->dl_leaf_bh; > char *data_start = insert_bh->b_data; > @@ -1695,22 +1695,22 @@ int __ocfs2_add_entry(handle_t *handle, > } > > if (insert_bh == parent_fe_bh) > - status = ocfs2_journal_access_di(handle, > + retval = ocfs2_journal_access_di(handle, > INODE_CACHE(dir), > insert_bh, > OCFS2_JOURNAL_ACCESS_WRITE); > else { > - status = ocfs2_journal_access_db(handle, > + retval = ocfs2_journal_access_db(handle, > INODE_CACHE(dir), > insert_bh, > OCFS2_JOURNAL_ACCESS_WRITE); > > if (ocfs2_dir_indexed(dir)) { > - status = ocfs2_dx_dir_insert(dir, > + retval = ocfs2_dx_dir_insert(dir, > handle, > lookup); > - if (status) { > - mlog_errno(status); > + if (retval) { > + mlog_errno(retval); > goto bail; > } > } >
Andrew Morton
2015-Mar-19 22:23 UTC
[Ocfs2-devel] [PATCH 1/4 V2] ocfs2: use retval instead of status for checking error
On Sat, 28 Feb 2015 08:48:40 +0900 Daeseok Youn <daeseok.youn at gmail.com> wrote:> The use of 'status' in __ocfs2_add_entry() can return wrong > status when some functions are failed. > > If ocfs2_journal_access_db() in __ocfs2_add_entry() is failed, > that status is saved to 'status' but return variable is 'retval' > which is saved 'success' status. In case of this, __ocfs2_add_entry() > is failed but can be returned as 'success'. > > So replace 'status' with 'retval'. > > - mlog_errno(status); > + if (retval) { > + mlog_errno(retval); > goto bail;and bail: if (retval) mlog_errno(retval); return retval; } so we'll clearly log the same error twice.