As Joe Perches suggested [1],
err = bio_add_page(bio, page, PAGE_SIZE, 0);
- if (unlikely(err != PAGE_SIZE)) {
+ if (err != PAGE_SIZE) {
err = -EFAULT;
goto err_out;
}
The initial assignment to err is odd as it's not
actually an error value -E<FOO> but a int size
from a unsigned int len.
Here the return is either 0 or PAGE_SIZE.
This would be more legible to me as:
if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
err = -EFAULT;
goto err_out;
}
[1] https://lore.kernel.org/r/[email protected]/
Reported-by: Joe Perches <[email protected]>
Signed-off-by: Gao Xiang <[email protected]>
---
v3: fix a typo in subject line.
fs/erofs/data.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 0f2f1a839372..0983807737fd 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -69,8 +69,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
goto err_out;
}
- err = bio_add_page(bio, page, PAGE_SIZE, 0);
- if (err != PAGE_SIZE) {
+ if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
err = -EFAULT;
goto err_out;
}
--
2.17.1
On 2019/8/30 11:36, Gao Xiang wrote:
> As Joe Perches suggested [1],
> err = bio_add_page(bio, page, PAGE_SIZE, 0);
> - if (unlikely(err != PAGE_SIZE)) {
> + if (err != PAGE_SIZE) {
> err = -EFAULT;
> goto err_out;
> }
>
> The initial assignment to err is odd as it's not
> actually an error value -E<FOO> but a int size
> from a unsigned int len.
>
> Here the return is either 0 or PAGE_SIZE.
>
> This would be more legible to me as:
>
> if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
> err = -EFAULT;
> goto err_out;
> }
>
> [1] https://lore.kernel.org/r/[email protected]/
> Reported-by: Joe Perches <[email protected]>
> Signed-off-by: Gao Xiang <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Thanks,
> - err = bio_add_page(bio, page, PAGE_SIZE, 0);
> - if (err != PAGE_SIZE) {
> + if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
> err = -EFAULT;
> goto err_out;
> }
This patch looks like an improvement. But looking at that whole
area just makes me cringe.
Why is there __erofs_get_meta_page with the two weird booleans instead
of a single erofs_get_meta_page that gets and gfp_t for additional
flags and an unsigned int for additional bio op flags.
Why do need ioprio support to start with? Seeing that in a new
fs look kinda odd. Do you have benchmarks that show the difference?
That function then calls erofs_grab_bio, which tries to handle a
bio_alloc failure, except that the function will not actually fail
due the mempool backing it. It also seems like and awfully
huge function to inline.
Why is there __submit_bio which really just obsfucates what is
going on? Also why is __submit_bio using bio_set_op_attrs instead
of opencode it as the comment right next to it asks you to?
Also I really don't understand why you can't just use read_cache_page
or even read_cache_page_gfp instead of __erofs_get_meta_page.
That function is a whole lot of duplication of functionality shared
by a lot of other file systems.
Hi Christoph,
On Fri, Aug 30, 2019 at 09:28:12AM -0700, Christoph Hellwig wrote:
> > - err = bio_add_page(bio, page, PAGE_SIZE, 0);
> > - if (err != PAGE_SIZE) {
> > + if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
> > err = -EFAULT;
> > goto err_out;
> > }
>
> This patch looks like an improvement. But looking at that whole
> area just makes me cringe.
OK, I agree with you, I will improve it or just kill them all with
new iomap approach after it supports tail-end packing inline.
>
> Why is there __erofs_get_meta_page with the two weird booleans instead
> of a single erofs_get_meta_page that gets and gfp_t for additional
> flags and an unsigned int for additional bio op flags.
I agree with you. Thanks for your suggestion.
>
> Why do need ioprio support to start with? Seeing that in a new
> fs look kinda odd. Do you have benchmarks that show the difference?
I don't have some benchmark for all of these, can I just set
REQ_PRIO for all metadata? is that reasonable?
Could you kindly give some suggestion on this?
>
> That function then calls erofs_grab_bio, which tries to handle a
> bio_alloc failure, except that the function will not actually fail
> due the mempool backing it. It also seems like and awfully
> huge function to inline.
OK, I will simplify it. Thanks for your suggestion.
>
> Why is there __submit_bio which really just obsfucates what is
> going on? Also why is __submit_bio using bio_set_op_attrs instead
> of opencode it as the comment right next to it asks you to?
Originally, mainly due to backport consideration since some
of our smartphones use 3.x kernel as well...
>
> Also I really don't understand why you can't just use read_cache_page
> or even read_cache_page_gfp instead of __erofs_get_meta_page.
> That function is a whole lot of duplication of functionality shared
> by a lot of other file systems.
OK, I have to admit, that code was originally just copied from f2fs
with some modification (maybe it's not a good example for us).
Thanks,
Gao Xiang