f2fs: remove unnecessary read for F2FS_FITS_IN_INODE
PATCH 1/1 f2fs: remove unnecessary read for F2FS_FITS_IN_INODE
F2FS_FITS_IN_INODE only cares the type of f2fs inode, so there is no need to read node page of f2fs inode.
--- fs/f2fs/file.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
fs/f2fs/file.c +2 -8
@@ -2999,7 +2999,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) {struct f2fs_inode_info *fi =F2FS_I (inode);struct f2fs_sb_info *sbi =F2FS_I_SB (inode); -struct page *ipage; +struct f2fs_inode *ri;kprojid_t kprojid;int err;
@@ -3023,17 +3023,11 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)if (IS_NOQUOTA (inode))return err; - ipage =f2fs_get_node_page (sbi, inode->i_ino); -if (IS_ERR (ipage)) -return PTR_ERR (ipage); -if (!F2FS_FITS_IN_INODE (F2FS_INODE (ipage), fi->i_extra_isize, - i_projid)) { +if (!F2FS_FITS_IN_INODE (ri, fi->i_extra_isize, i_projid)) { err = -EOVERFLOW ; -f2fs_put_page (ipage,1 );return err; } -f2fs_put_page (ipage,1 ); err =f2fs_dquot_initialize (inode);if (err)
Signature · 8 lines
2.22.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerQuoted 13 lines · On 2022/3/7 16:12, Jia Yang via Linux-f2fs-devel wrote:
F2FS_FITS_IN_INODEonly cares the type of f2fs inode, so there is no need to read node page of f2fs inode.Signed-off-by Jia Yang <[email protected]>--- fs/f2fs/file.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/f2fs/file.c +0
-0
fs/f2fs/file.c static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) · line 3002
Quoted 5 lines
fs/f2fs/file.c +1
-1@@ -2999,7 +2999,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) {struct f2fs_inode_info *fi =F2FS_I (inode);struct f2fs_sb_info *sbi =F2FS_I_SB (inode); -struct page *ipage; +struct f2fs_inode *ri;
struct f2fs_inode *ri = NULL;
(offsetof(typeof(*(f2fs_inode)), field) +
sizeof((f2fs_inode)->field)
A little bit worry about using a NULL pointer here, due to not sure the result of offsetof() and sizeof() will always be calculated at compiling time for all kind of compilers, can we guarantee that?
Quoted 7 lines
fs/f2fs/file.c +0
-0kprojid_t kprojid;int err;@@ -3023,17 +3023,11 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)if (IS_NOQUOTA (inode))return err;
fs/f2fs/file.c static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) · line 3029
Quoted 10 lines
fs/f2fs/file.c +1
-6- ipage =f2fs_get_node_page (sbi, inode->i_ino); -if (IS_ERR (ipage)) -return PTR_ERR (ipage); -if (!F2FS_FITS_IN_INODE (F2FS_INODE (ipage), fi->i_extra_isize, - i_projid)) { +if (!F2FS_FITS_IN_INODE (ri, fi->i_extra_isize, i_projid)) { err = -EOVERFLOW ; -f2fs_put_page (ipage,1 );return err;
return -EOVERFLOW;
Thanks,
fs/f2fs/file.c static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) · line 3033
Quoted 5 lines
fs/f2fs/file.c +0
-1} -f2fs_put_page (ipage,1 ); err =f2fs_dquot_initialize (inode);if (err)
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 22 lines · Chao Yu
Quoted 13 lines · On 2022/3/7 16:12, Jia Yang via Linux-f2fs-devel wrote:
F2FS_FITS_IN_INODEonly cares the type of f2fs inode, so there is no need to read node page of f2fs inode.Signed-off-by Jia Yang <[email protected]>---
fs/f2fs/file.c| 10 ++--------1 file changed, 2 insertions(+), 8 deletions(-)fs/f2fs/file.c +0
-0fs/f2fs/file.c static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) · line 3002
Quoted 5 lines
fs/f2fs/file.c +1
-1@@ -2999,7 +2999,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) { struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - struct page *ipage; + struct f2fs_inode *ri;struct
f2fs_inode*ri = NULL;
Quoted 6 lines
(
offsetof(typeof(*(f2fs_inode)), field)+
sizeof((f2fs_inode)->field)A little bit worry about using a NULL pointer here, due to not sure the result of
offsetof()andsizeof()will always be calculated at compiling time for all kind of compilers, can we guarantee that?
We can't guarantee that, but I see that f2fs_getattr also runs in this way. Do you think that allocating memory for f2fs inode is available?
Thanks.
Quoted 18 lines
Quoted 7 lines
fs/f2fs/file.c +0
-0kprojid_t kprojid; int err; @@ -3023,17 +3023,11 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)if (
IS_NOQUOTA(inode))
return err;
- ipage =f2fs_get_node_page(sbi, inode->i_ino);Quoted 8 lines
- if (
IS_ERR(ipage))
- returnPTR_ERR(ipage);
- if (!F2FS_FITS_IN_INODE(F2FS_INODE(ipage),fi->i_extra_isize, -i_projid)) {
+ if (!F2FS_FITS_IN_INODE(ri,fi->i_extra_isize,i_projid)) { err =-EOVERFLOW;
-f2fs_put_page(ipage, 1);
return err;return
-EOVERFLOW;
Quoted 7 lines
Thanks,
Quoted 4 lines
}
-f2fs_put_page(ipage, 1);
err =f2fs_dquot_initialize(inode);
if (err).
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerQuoted 28 lines · On 2022/3/8 16:19, Jia Yang via Linux-f2fs-devel wrote:
Quoted 25 lines · Chao Yu
Quoted 13 lines · On 2022/3/7 16:12, Jia Yang via Linux-f2fs-devel wrote:
F2FS_FITS_IN_INODEonly cares the type of f2fs inode, so there is no need to read node page of f2fs inode.Signed-off-by Jia Yang <[email protected]>--- fs/f2fs/file.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/f2fs/file.c +0
-0fs/f2fs/file.c static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) · line 3002
Quoted 5 lines
fs/f2fs/file.c +1
-1@@ -2999,7 +2999,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) { struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - struct page *ipage; + struct f2fs_inode *ri;struct
f2fs_inode*ri = NULL;(
offsetof(typeof(*(f2fs_inode)), field)+
sizeof((f2fs_inode)->field)
Quoted 6 lines
Quoted 3 lines
A little bit worry about using a NULL pointer here, due to not sure the result of
offsetof()andsizeof()will always be calculated at compiling time for all kind of compilers, can we guarantee that?We can't guarantee that, but I see that
f2fs_getattralso runs in this way. Do you think that allocating memory for f2fs inode is available?
Well, it looks ext4_getattr() also did this way...
How about initializing ri w/ NULL at least?
Thanks,
Quoted 27 lines
Thanks.
Quoted 24 lines
Quoted 7 lines
fs/f2fs/file.c +0
-0kprojid_t kprojid; int err; @@ -3023,17 +3023,11 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)if (
IS_NOQUOTA(inode))
return err;
- ipage =f2fs_get_node_page(sbi, inode->i_ino);Quoted 8 lines
- if (
IS_ERR(ipage))
- returnPTR_ERR(ipage);
- if (!F2FS_FITS_IN_INODE(F2FS_INODE(ipage),fi->i_extra_isize,
-i_projid)) {
+ if (!F2FS_FITS_IN_INODE(ri,fi->i_extra_isize,i_projid)) {
err =-EOVERFLOW;
-f2fs_put_page(ipage, 1);
return err;return
-EOVERFLOW;Thanks,
Quoted 4 lines
}
-f2fs_put_page(ipage, 1);
err =f2fs_dquot_initialize(inode);
if (err)
Quoted 7 lines
Quoted 1 line
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 33 lines · Chao Yu
Quoted 32 lines · On 2022/3/8 16:19, Jia Yang via Linux-f2fs-devel wrote:
Quoted 28 lines · Chao Yu
Quoted 13 lines · On 2022/3/7 16:12, Jia Yang via Linux-f2fs-devel wrote:
F2FS_FITS_IN_INODEonly cares the type of f2fs inode, so there is no need to read node page of f2fs inode.Signed-off-by Jia Yang <[email protected]>---
fs/f2fs/file.c| 10 ++--------1 file changed, 2 insertions(+), 8 deletions(-)fs/f2fs/file.c +0
-0fs/f2fs/file.c static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) · line 3002
Quoted 5 lines
fs/f2fs/file.c +1
-1@@ -2999,7 +2999,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid) { struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - struct page *ipage; + struct f2fs_inode *ri;struct
f2fs_inode*ri = NULL;(
offsetof(typeof(*(f2fs_inode)), field)+
sizeof((f2fs_inode)->field)A little bit worry about using a NULL pointer here, due to not sure the result of
offsetof()andsizeof()will always be calculated at compiling time for all kind of compilers, can we guarantee that?
Quoted 7 lines
Quoted 2 lines
We can't guarantee that, but I see that
f2fs_getattralso runs in this way. Do you think that allocating memory for f2fs inode is available?Well, it looks
ext4_getattr()also did this way...How about initializing ri w/ NULL at least?
I agree with that and I will fix it in V2 version.
Thanks,
Quoted 29 lines
Thanks,
Quoted 27 lines
Thanks.
Quoted 24 lines
Quoted 7 lines
fs/f2fs/file.c +0
-0kprojid_t kprojid; int err; @@ -3023,17 +3023,11 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)if (
IS_NOQUOTA(inode))
return err;
- ipage =f2fs_get_node_page(sbi, inode->i_ino);Quoted 8 lines
- if (
IS_ERR(ipage))
- returnPTR_ERR(ipage);
- if (!F2FS_FITS_IN_INODE(F2FS_INODE(ipage),fi->i_extra_isize, -i_projid)) {
+ if (!F2FS_FITS_IN_INODE(ri,fi->i_extra_isize,i_projid)) { err =-EOVERFLOW;
-f2fs_put_page(ipage, 1);
return err;return
-EOVERFLOW;Thanks,
Quoted 4 lines
}
-f2fs_put_page(ipage, 1);
err =f2fs_dquot_initialize(inode);
if (err)
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel