Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1626193imm; Mon, 3 Sep 2018 05:29:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaOmlQKCeIQRqBzf/1CyVH1PDMSaxzW3g2WtxbxO/x1GSdC6hFpnIKGEn4oLiGBgdXJ07lJ X-Received: by 2002:a62:5ec3:: with SMTP id s186-v6mr29345733pfb.146.1535977777804; Mon, 03 Sep 2018 05:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535977777; cv=none; d=google.com; s=arc-20160816; b=UdrNE7Tg6BqjO0ct2GVlNOhWuHhgm7UTgPsx45TFMcCDwMEPk/MGdB2BV8ZJB4j6AJ +l7WBfAS+acHIEzXAN6V/huap0VV2Zx7hrvO4nGoSOdWq+0DTi8vkUoHcSQN9JiMtdxg GPES2Mt03eoCNsR//02ksoBu+To8a+y5UhrV8h7SZAJ+C/bS67jVD2PigrJZ2/gJrNTZ 0M1C+O5l4Cuq+MrUJPvcCrxji7MzylI8GmyV2BmqqqPi2w2Jk4pzaN+FB+Z75gdVSNJc AZL3cIXQDH+uOw8PVM2RGIJmvjvazAzvpn1qwT1ReJUVahIIntzakpwrMWaLRG2uB5cG ejig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=4b85vKo3cPi/UJShMdDPX247xE49ZM6rtoEWfsKyqoQ=; b=T8Zs+Gfr36DKpFY8VBQD1JCWi6tWX6qaAOsU35rZPcDQ1zzOZajrgdm0/eX6rZ4l58 5BRKWU++vaUoc+xmwti59zxUzooFHoPws8fnz28X0lUdAXM2soHIi7hVTe4uCtKnET9M cTX5TQ/Lr3gkuSbwjxTCL0ten800FtpPDygm3mqA5q7OVdajkjQEnp/WuPS+TgIXV2ar xALPNyhJ+Mip8zsAKdSdthgUKmRb45I6BEZmSop0KNKV+FrdIga60VSgjmnYxzx4dloJ iASSJBL5LFhodnH9oKrXXjuptrcbw5+GLZCQCUiaAxKJG/z6n07HeppXbfV6mvFq/44C WWwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 25-v6si19085287pfk.287.2018.09.03.05.29.21; Mon, 03 Sep 2018 05:29:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbeICQsF (ORCPT + 99 others); Mon, 3 Sep 2018 12:48:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:56790 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727186AbeICQsF (ORCPT ); Mon, 3 Sep 2018 12:48:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 73C80AFE7; Mon, 3 Sep 2018 12:28:08 +0000 (UTC) Date: Mon, 3 Sep 2018 14:28:04 +0200 From: Michal Hocko To: Douglas Gilbert Cc: Richard Weinberger , drorl@infinidat.com, LKML , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, Linus Torvalds , Christoph Hellwig , Jens Axboe Subject: Re: Recent removal of bsg read/write support Message-ID: <20180903122804.GA15074@dhcp22.suse.cz> References: <6b907fed-d83f-de75-bde4-11270a0b1b0b@interlog.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b907fed-d83f-de75-bde4-11270a0b1b0b@interlog.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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. -- Michal Hocko SUSE Labs