From: Douglas Gilbert <dgilbert@interlog.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Richard Weinberger <richard.weinberger@gmail.com>,
drorl@infinidat.com, LKML <linux-kernel@vger.kernel.org>,
linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: Recent removal of bsg read/write support
Date: Tue, 4 Sep 2018 05:38:21 +0200 [thread overview]
Message-ID: <731941f0-c80d-605a-2750-01c8d5ec4dd9@interlog.com> (raw)
In-Reply-To: <20180903122804.GA15074@dhcp22.suse.cz>
On 2018-09-03 02:28 PM, Michal Hocko wrote:
> On Sun 02-09-18 21:16:10, Douglas Gilbert wrote:
>> On 2018-09-02 01:44 PM, Richard Weinberger wrote:
>>> CC'ing relevant people. Otherwise your mail might get lost.
>>>
>>> On Sun, Sep 2, 2018 at 1:37 PM Dror Levin <drorl@infinidat.com> wrote:
>>>>
>>>> Note: I am not subscribed to LKML so please CC replies to this email.
>>>>
>>>> Hi,
>>>>
>>>> We have an internal tool that uses the bsg read/write interface to
>>>> issue SCSI commands as part of a test suite for a storage device.
>>>>
>>>> After recently reading on LWN that this interface is to be removed we
>>>> tried porting our code to use sg instead. However, that raises new
>>>> issues - mainly getting ENOMEM over iSCSI for unknown reasons.
>>>>
>>>> Because of this we would like to continue using the bsg interface,
>>>> even if some changes are required to meet security concerns.
>>>>
>>>> Is there any chance for this removal to be reverted? I saw it was
>>>> already included in 4.19-rc1.
>>
>> Hi,
>> Both bsg and sg are relatively thin shims over the same block layer
>> pass-through calls. And neither driver will themselves generate ENOMEM
>> unless the CPU is running low of memory.
>>
>> In my experience, the main reason for unexpected ENOMEMs *** is from
>> blk_rq_map_user_iov() in block/blk_map.c called from both drivers.
>> That is a particular resource shortage rather than memory in general.
>> I do notice the blk_rq_map_user_iov() is/was called with GFP_KERNEL
>> in bsg and GFP_ATOMIC by sg. That suggests when you call write() on
>> a sg device and get ENOMEM, then wait a little (depends on your app)
>> and try again.
>
> Well, what is the reason to use GFP_ATOMIC in the first place? I am not
> familiar with the code so I might be easily wrong but sg_start_req which
> calls blk_rq_map_user_iov resp. blk_rq_map_user with GFP_ATOMIC uses
> mutex. It is a conditional usage so the sleeping context might depend
> on the caller. But I guess it would be better to double check. It looks
> suspicious to me.
Of the hundreds of 'hacks' on the sg driver over the years, the most
common is an expert arguing that GFP_ATOMIC should be changed to GFP_KERNEL.
They usually get their way. That is followed around 6 to 9 months later by
a sg user complaining about an unexpected broken app. So back it goes to
GFP_ATOMIC.
Welcome to the merry-go-round.
Doug Gilbert
next prev parent reply other threads:[~2018-09-04 3:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-02 11:35 Dror Levin
2018-09-02 11:44 ` Richard Weinberger
2018-09-02 17:55 ` Linus Torvalds
2018-09-03 8:34 ` Dror Levin
2018-09-04 4:10 ` Douglas Gilbert
2018-10-04 6:58 ` Dror Levin
2018-10-05 22:35 ` Greg KH
2018-10-05 23:27 ` Douglas Gilbert
2019-02-01 17:44 ` Douglas Gilbert
2018-09-02 19:16 ` Douglas Gilbert
2018-09-03 12:28 ` Michal Hocko
2018-09-04 3:38 ` Douglas Gilbert [this message]
2018-09-04 6:59 ` Michal Hocko
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=731941f0-c80d-605a-2750-01c8d5ec4dd9@interlog.com \
--to=dgilbert@interlog.com \
--cc=axboe@kernel.dk \
--cc=drorl@infinidat.com \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=richard.weinberger@gmail.com \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®