linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: fdmanana@gmail.com
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: not a disk error if the bio_add_page fails
Date: Wed, 3 Jan 2018 21:53:53 +0800	[thread overview]
Message-ID: <ceffe3f0-0691-03a7-f954-ad23386307cb@oracle.com> (raw)
In-Reply-To: <CAL3q7H7DG_J3zgKurZB+ba7GxiW4_EUTh2i_3a54iRecruNixA@mail.gmail.com>



On 01/03/2018 07:34 PM, Filipe Manana wrote:
> On Wed, Jan 3, 2018 at 8:07 AM, Anand Jain <anand.jain@oracle.com> wrote:
>> bio_add_page() can fail for logical reasons as from the bio_add_page()
>> comments:- 'This will only fail if either
>> bio->bi_vcnt == bio->bi_max_vecs or it's a cloned bio.' Don't inc the
>> write error statistics for this. And set -EINVAL instead of -EIO.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   fs/btrfs/scrub.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
>> index d766c73eb29a..8c1508a41f90 100644
>> --- a/fs/btrfs/scrub.c
>> +++ b/fs/btrfs/scrub.c
>> @@ -4618,15 +4618,15 @@ static int write_page_nocow(struct scrub_ctx *sctx,
>>          bio->bi_opf = REQ_OP_WRITE | REQ_SYNC;
>>          ret = bio_add_page(bio, page, PAGE_SIZE, 0);
>>          if (ret != PAGE_SIZE) {
>> -leave_with_eio:
>>                  bio_put(bio);
>> +               return -EINVAL;
>> +       }
>> +
>> +       if (btrfsic_submit_bio_wait(bio)) {
>>                  btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
>>                  return -EIO;
>>          }
> 
> You are now introducing a leak of the bio. Missing bio_put(bio) before
> returning.

  Oops. My bad. Thanks. Now fixed in v2.

- Anand

>>
>> -       if (btrfsic_submit_bio_wait(bio))
>> -               goto leave_with_eio;
>> -
>>          bio_put(bio);
>>          return 0;
>>   }
>> --
>> 2.15.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 

  reply	other threads:[~2018-01-03 13:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03  8:07 [PATCH] btrfs: not a disk error if the bio_add_page fails Anand Jain
2018-01-03 11:34 ` Filipe Manana
2018-01-03 13:53   ` Anand Jain [this message]
2018-01-03 13:52 ` [PATCH v2] " Anand Jain
2018-01-04 17:47   ` Liu Bo
2018-01-04 18:50     ` Liu Bo
2018-01-05  2:25       ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ceffe3f0-0691-03a7-f954-ad23386307cb@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=fdmanana@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).