All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: mwilck@suse.com
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	David Disseldorp <ddiss@suse.com>,
	J??rgen Gro?? <jgross@suse.com>
Subject: Re: [PATCH] target: pscsi: avoid OOM in pscsi_map_sg()
Date: Tue, 23 Mar 2021 16:29:05 +0000	[thread overview]
Message-ID: <20210323162905.GA2449048@infradead.org> (raw)
In-Reply-To: <20210323162203.30942-1-mwilck@suse.com>

On Tue, Mar 23, 2021 at 05:22:03PM +0100, mwilck@suse.com wrote:
> Avoid this by simply not resetting nr_pages to 0 after allocating the
> bio. This way, the client receives an IO error when it tries to send
> requests exceeding the devices max_sectors_kb, and eventually gets
> it right. The client must still limit max_sectors_kb e.g. by an udev
> rule if (like in my case) the driver doesn't report valid block
> limits, otherwise it encounters I/O errors.

FYI, I think the what you did here is correct, but not enough.
When pscsi_get_bio (that is bio_kmalloc) fails, this function needs
to unwind and return an error insted of blindly retrying the allocation,
else we can't recover from a memory shortage.

  reply	other threads:[~2021-03-23 16:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 16:22 [PATCH] target: pscsi: avoid OOM in pscsi_map_sg() mwilck
2021-03-23 16:29 ` Christoph Hellwig [this message]
2021-03-23 20:01   ` Martin Wilck
2021-03-23 18:07 ` Chaitanya Kulkarni
2021-03-23 21:20   ` Martin Wilck
2021-03-23 21:25     ` Chaitanya Kulkarni

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=20210323162905.GA2449048@infradead.org \
    --to=hch@infradead.org \
    --cc=ddiss@suse.com \
    --cc=jgross@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    --cc=target-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.