bio_add_page only returns 0 or the same value passed as length, there is no need to compare its return value against the passed length. Just check if the return value is 0 or not. Signed-off-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx> --- P.S. Patch survived xfstests using different block sizes fs/xfs/xfs_buf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index e839907e8492..a353b39b00e2 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -1306,14 +1306,14 @@ xfs_buf_ioapply_map( bio_set_op_attrs(bio, op, op_flags); for (; size && nr_pages; nr_pages--, page_index++) { - int rbytes, nbytes = PAGE_SIZE - offset; + int nbytes = PAGE_SIZE - offset; if (nbytes > size) nbytes = size; - rbytes = bio_add_page(bio, bp->b_pages[page_index], nbytes, - offset); - if (rbytes < nbytes) + /* Stop if bio is full */ + if (!(bio_add_page(bio, bp->b_pages[page_index], nbytes, + offset))) break; offset = 0; -- 2.14.3